1"use strict";(globalThis.webpackChunkbixjet_ai=globalThis.webpackChunkbixjet_ai||[]).push([[1926,3377],{36669(e,t,n){n.d(t,{A:()=>s});n(9950);var i=n(10226),r=n(83274),o=n(25333),l=n(99600),a=n(44414);function s(e){let{label:t="Back",onClick:n,variant:s="default",sx:d}=e;return"text"===s?(0,a.jsx)(i.A,{onClick:n,startIcon:(0,a.jsx)(l.A,{sx:{fontSize:"16px !important"}}),sx:{textTransform:"none",fontWeight:600,fontSize:13,color:"text.secondary",px:0,mb:1.5,minWidth:0,"&:hover":{bgcolor:"transparent",color:"text.primary"},...d},children:t}):(0,a.jsx)(r.A,{title:t,children:(0,a.jsx)(o.A,{onClick:n,size:"small",sx:{border:"1px solid",borderColor:"divider",borderRadius:2,width:36,height:36,"&:hover":{bgcolor:"action.hover"},...d},children:(0,a.jsx)(l.A,{sx:{fontSize:18}})})})}},69445(e,t,n){n.d(t,{GH:()=>o,Jw:()=>g,Q9:()=>j,QZ:()=>h,Rr:()=>v,Yq:()=>d,bB:()=>u,bP:()=>l,dy:()=>p,eB:()=>a,h6:()=>f,jD:()=>m,lD:()=>A,om:()=>c,ri:()=>r,wx:()=>b,xI:()=>s});const i={"& .MuiOutlinedInput-root":{borderRadius:"14px",minHeight:44,backgroundColor:"background.paper",transition:"box-shadow .15s ease, border-color .15s ease","& fieldset":{borderColor:"rgba(15,23,42,0.12)"},"&:hover fieldset":{borderColor:"rgba(15,23,42,0.24)"},"&.Mui-focused fieldset":{borderColor:"primary.main",borderWidth:"1.5px"},"&.Mui-focused":{boxShadow:"0 0 0 3px rgba(99,102,241,0.10)"}},"& .MuiOutlinedInput-input":{padding:"11px 14px"},"& .MuiInputLabel-root":{transform:"translate(14px, 12px) scale(1)",color:"text.secondary"},"& .MuiInputLabel-root.MuiInputLabel-shrink":{transform:"translate(14px, -7px) scale(0.78)",backgroundColor:"background.paper",padding:"0 6px"}},r={borderRadius:"12px",textTransform:"none",fontWeight:600,letterSpacing:.1,paddingX:2.25,minHeight:40,boxShadow:"none","&:hover":{boxShadow:"0 4px 14px rgba(99,102,241,0.18)"}},o={borderRadius:3,border:"1px solid",borderColor:"divider",backgroundColor:"background.paper",transition:"transform .18s ease, box-shadow .18s ease, border-color .18s ease","&:hover":{transform:"translateY(-1px)",boxShadow:"0 6px 20px rgba(15,23,42,0.06)",borderColor:"rgba(15,23,42,0.12)"}},l={fontSize:12,fontWeight:700,letterSpacing:.6,color:"text.secondary",textTransform:"uppercase",marginBottom:1.5},a={textTransform:"none",fontWeight:600,fontSize:14,minHeight:44,paddingX:2,letterSpacing:.1};function s(){const e=e=>{try{return JSON.parse(e)}catch{return e}};return{userId:e(localStorage.getItem("userid")),locationId:e(localStorage.getItem("location_Id")),businessId:e(localStorage.getItem("business_Id")),token:localStorage.getItem("token"),user:e(localStorage.getItem("user"))}}function d(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"fullDateTime";if(!e)return"";if(t=/^\d+$/.test(String(e))?new Date(parseInt(e,10)):new Date(e),isNaN(t.getTime()))return"";const i=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()],r=String(t.getDate()).padStart(2,"0"),o=t.getFullYear();let l=t.getHours();const a=String(t.getMinutes()).padStart(2,"0"),s=l>=12?"PM":"AM";return l=l%12||12,"date"===n?`${i} ${r}, ${o}`:"time"===n?`${l}:${a} ${s}`:`${i} ${r}, ${o} \xb7 ${l}:${a} ${s}`}function c(e){if(!e)return"";let t;if(t=/^\d+$/.test(String(e))?new Date(parseInt(e,10)):new Date(e),isNaN(t.getTime()))return"";const n=Date.now()-t.getTime(),i=Math.floor(n/6e4);if(i<1)return"just now";if(i<60)return`${i}m ago`;const r=Math.floor(i/60);if(r<24)return`${r}h ago`;const o=Math.floor(r/24);return o<7?`${o}d ago`:d(t,"date")}function u(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter(Boolean).map(e=>String(e).trim()[0]).filter(Boolean).slice(0,2).join("").toUpperCase()||"?"}const x=["#6366f1","#8b5cf6","#ec4899","#ef4444","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#0ea5e9"];function p(e){if(!e)return x[0];let t=0;for(let n=0;n<e.length;n+=1)t=31*t+e.charCodeAt(n)>>>0;return x[t%x.length]}function h(e){if(!e)return"";const t="undefined"!==typeof document?document.createElement("div"):null;return t?(t.innerHTML=String(e),(t.textContent||t.innerText||"").replace(/\s+/g," ").trim()):String(e).replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim()}function m(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null===e||void 0===e)return t;if("string"!==typeof e)return e;try{return JSON.parse(e)}catch{}try{return JSON.parse(e.split('\\"').join("'"))}catch{}return t}const v={1:{label:"Not Started",bg:"#fef3c7",color:"#92400e"},2:{label:"In Progress",bg:"#dbeafe",color:"#1d4ed8"},3:{label:"Completed",bg:"#dcfce7",color:"#166534"},4:{label:"Overdue",bg:"#fee2e2",color:"#991b1b"}
1,5:{label:"Stuck",bg:"#f3e8ff",color:"#6b21a8"}},f={1:"Todo",2:"Call",3:"Email",4:"Meeting",5:"Text (SMS)",6:"Follow-up",7:"Other"},g={1:{label:"High",color:"#dc2626",bg:"#fee2e2"},2:{label:"Medium",color:"#ca8a04",bg:"#fef3c7"},3:{label:"Low",color:"#16a34a",bg:"#dcfce7"}},b={Singlelinetext:1,Multilinetext:2,Singlecheckbox:3,Multiplecheckbox:4,Dropdownselect:5,Radioselect:6,Datepicker:7,Numbers:8,Phonenumber:9,Rating:10,Divider:12,Label:13,Section:15},A={contactForm:1,inquiryForm:2,dealForm:3},j=[{fieldtype:1,isrequired:!0,name:"Deal Name",objecttype:"deal",propertyname:"Deal Name",dbfieldname:"dealname"},{fieldtype:2,isrequired:!1,name:"Description",objecttype:"deal",propertyname:"Description",dbfieldname:"description"},{fieldtype:5,isrequired:!1,name:"Pipeline",objecttype:"deal",propertyname:"Pipeline",dbfieldname:"pipelineid"},{fieldtype:5,isrequired:!1,name:"Stage",objecttype:"deal",propertyname:"Stage",dbfieldname:"stageid"},{fieldtype:5,isrequired:!1,name:"Type",objecttype:"deal",propertyname:"Deal Type",dbfieldname:"dealtype"},{fieldtype:5,isrequired:!1,name:"Product",objecttype:"deal",propertyname:"Product",dbfieldname:"productid"},{fieldtype:8,isrequired:!1,name:"Product Quantity",objecttype:"deal",propertyname:"Product Quantity",dbfieldname:"productquantity"},{fieldtype:8,isrequired:!0,name:"Amount",objecttype:"deal",propertyname:"Amount",dbfieldname:"dealamount"},{fieldtype:7,isrequired:!1,name:"Close Date",objecttype:"deal",propertyname:"Close Date",dbfieldname:"closedate"},{fieldtype:5,isrequired:!1,name:"Deal Owner",objecttype:"deal",propertyname:"Deal Owner",dbfieldname:"ownerid"},{fieldtype:5,isrequired:!1,name:"Contact",objecttype:"deal",propertyname:"Contact",dbfieldname:"associatedcontact"}]},6167(e,t,n){n.r(t),n.d(t,{default:()=>Ye});var i=n(9950),r=n(10300),o=n(28429),l=n(16491),a=n(93230),s=n(82053),d=n(46639),c=n(41413),u=n(83274),x=n(25333),p=n(74745),h=n(8145),m=n(10226),v=n(63464),f=n(40033),g=n(28170),b=n(79739),A=n(46589),j=n(60899),y=n(25979),S=n(19647),w=n(70006),z=n(23266),C=n(20544),D=n(25277),k=n(2046),$=n(29277),M=n(58567),W=n(16497),I=n(85815),H=n(93038),O=n(3632),R=n(66699),L=n(48089),T=n(11966),F=n(84142),N=n(88060),B=n(83239),V=n(14857),q=n(97497),P=n(77642),E=n(13047),X=n(35436),U=n(76265),J=n(36658),Y=n(83975),Q=n(30798),_=n(3263),K=n(20803),Z=n(45453),G=n(53377),ee=n(63435),te=n(68742),ne=n(53777),ie=n(86825),re=n(53518),oe=n(70225),le=n(87785),ae=n(66559),se=n(82864),de=n(27e3),ce=n(36089),ue=n(10158),xe=n(97913),pe=n(12501),he=n(82460),me=n(91548),ve=n(69445),fe=n(62534),ge=n(24921),be=n(16243),Ae=n(6986),je=n(57236),ye=n(36669),Se=n(44414);const we=(0,i.lazy)(()=>Promise.all([n.e(4416),n.e(9507),n.e(2906),n.e(673),n.e(6484)]).then(n.bind(n,60673))),ze=(0,i.lazy)(()=>Promise.all([n.e(310),n.e(4416),n.e(1286),n.e(9549),n.e(6088),n.e(3287)]).then(n.bind(n,46088))),Ce=(0,i.lazy)(()=>Promise.all([n.e(4619),n.e(6715),n.e(9715),n.e(3529)]).then(n.bind(n,9715))),De=(0,i.lazy)(()=>Promise.all([n.e(4862),n.e(2893),n.e(1830),n.e(4931),n.e(2585),n.e(5988)]).then(n.bind(n,32585))),ke=(0,i.lazy)(()=>n.e(4143).then(n.bind(n,4143))),$e=(0,i.lazy)(()=>Promise.all([n.e(6715),n.e(718),n.e(1564)]).then(n.bind(n,718))),Me=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"USD";if(null===e||void 0===e||""===e)return"$0";const n="string"===typeof e?parseFloat(e):e;if(isNaN(n))return"$0";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:t,maximumFractionDigits:0}).format(n)}catch{return`$${Math.round(n).toLocaleString()}`}},We=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"USD";try{return(0).toLocaleString("en-US",{style:"currency",currency:e,maximumFractionDigits:0}).replace(/[0-9.,\s]/g,"")||"$"}catch{return"$"}},Ie=e=>String(e).padStart(2,"0"),He=e=>{if(!e)return"";const t=/^\d+$/.test(String(e))?new Date(parseInt(e,10)):new Date(e);return isNaN(t.getTime())?"":`${t.getFullYear()}-${Ie(t.getMonth()+1)}-${Ie(t.getDate())}T${Ie(t.getHours())}:${Ie(t.getMinutes())}`},Oe=()=>{const e=new Date;return e.setDate(e.getDate()+30),`${e.getFullYear()}-${Ie(e.getMonth()+1)}-${Ie(e.getDate())}T${Ie(e.getHours())}:${Ie(e.getMinutes())}`},Re=e=>{if(!e)return"";const t=/^\d+$/.test(String(e))?new Date(parseInt(e,10)):new Date(e);return isNaN(t.getTime())?"":(0,xe.A)(t).format("ddd, MMM DD, YYYY h:mm A")},Le=e=>"pipelineid"===e.dbfieldname,Te=e=>"stageid"===e.dbfieldname,Fe=e=>"productquantity"===e.dbfieldname,Ne=e=>"associatedcontact"===e.dbfieldname||"contactid"===e.dbfieldname,Be={fieldtype:ve.wx.Dropdownselect,isrequired:!1,name:"Product",propertyname:"Product",objecttype:"deal",dbfieldname:"productid"},Ve={fieldtype:ve.wx.Numbers,isrequired:!1,name:"Product Quantity",propertyname:"Product Quantity",objecttype:"deal",dbfieldname:"productquantity"},qe={borderRadius:"999px",textTransform:"none",fontWeight:600,fontSize:13,px:2,py:.75,boxSh
1adow:"none"};function Pe(e){let{dealId:t,contactId:r}=e;const o="dark"===(0,V.A)().palette.mode,A=(0,i.useMemo)(()=>{try{return JSON.parse(localStorage.getItem("userid"))}catch{return null}},[]),j=(0,i.useMemo)(()=>{try{return JSON.parse(localStorage.getItem("user"))}catch{return null}},[]),[y,S]=(0,i.useState)([]),[w,z]=(0,i.useState)(!1),[C,D]=(0,i.useState)(""),[k,$]=(0,i.useState)(!1),[M,W]=(0,i.useState)(null),[I,H]=(0,i.useState)(""),[O,R]=(0,i.useState)(null),[L,T]=(0,i.useState)(null),F=(0,i.useCallback)(async()=>{if(t){z(!0);try{var e,i;const{SalesDeal:r}=await Promise.resolve().then(n.bind(n,6986)),o=await(0,ge.e6)(be.A.baseURLApi,{query:r,variables:{dealid:t}}),l=null===o||void 0===o||null===(e=o.data)||void 0===e||null===(i=e.salesdeal)||void 0===i?void 0:i.comments;S(Array.isArray(l)?l:[])}catch{S([])}finally{z(!1)}}},[t]);(0,i.useEffect)(()=>{F()},[F]);const N=async()=>{if(C.trim()){$(!0);try{var e;const n=await(0,ge.e6)(be.A.baseURLApi,{query:Ae.e9,variables:{description:C.trim().split().join("\\n").split('"').join('\\"'),contactid:r,parentid:t,type:je.yW.deal,createdby:A}});null!==n&&void 0!==n&&null!==(e=n.data)&&void 0!==e&&e.createComment&&(D(""),null===fe.D||void 0===fe.D||(0,fe.D)("Comment added","success"),F())}catch{null===fe.D||void 0===fe.D||(0,fe.D)("Could not add comment","error")}finally{$(!1)}}},B=async()=>{if(I.trim()&&M){$(!0);try{var e;const n=await(0,ge.e6)(be.A.baseURLApi,{query:Ae.o0,variables:{commentid:M,description:I.trim().split().join("\\n").split('"').join('\\"'),contactid:r,parentid:t,type:je.yW.deal,updatedby:A}});null!==n&&void 0!==n&&null!==(e=n.data)&&void 0!==e&&e.editComment&&(W(null),H(""),null===fe.D||void 0===fe.D||(0,fe.D)("Comment updated","success"),F())}catch{null===fe.D||void 0===fe.D||(0,fe.D)("Could not update comment","error")}finally{$(!1)}}};return(0,Se.jsxs)(l.A,{children:[(0,Se.jsxs)(a.A,{direction:"row",alignItems:"center",spacing:1,sx:{mb:2},children:[(0,Se.jsx)(l.A,{sx:{width:30,height:30,borderRadius:1.5,bgcolor:(0,q.X4)("#6366F1",o?.18:.1),display:"flex",alignItems:"center",justifyContent:"center"},children:(0,Se.jsx)(se.A,{sx:{fontSize:15,color:"primary.main"}})}),(0,Se.jsxs)(s.A,{sx:{fontSize:13,fontWeight:700,color:"text.secondary"},children:["Comments",y.length>0&&(0,Se.jsx)(l.A,{component:"span",sx:{ml:1,px:.9,py:.2,borderRadius:"999px",fontSize:11,bgcolor:(0,q.X4)("#6366F1",o?.18:.1),color:"primary.main",fontWeight:700},children:y.length})]}),w&&(0,Se.jsx)(d.A,{size:12,sx:{ml:"auto"}})]}),!w&&0===y.length&&(0,Se.jsxs)(l.A,{sx:{py:4,textAlign:"center",border:"1px dashed",borderColor:"divider",borderRadius:2,mb:2},children:[(0,Se.jsx)(se.A,{sx:{fontSize:28,color:"text.disabled",mb:.5}}),(0,Se.jsx)(s.A,{variant:"body2",color:"text.disabled",children:"No comments yet \u2014 be the first to leave one."})]}),(0,Se.jsx)(a.A,{spacing:1.5,sx:{mb:2.5},children:y.map(e=>{var t,n;const i=M===e.commentid,r=O===e.commentid,d=e.updatedAt&&e.updatedAt!==e.createdAt,v=(null===(t=e.createdUser)||void 0===t?void 0:t.firstname)||(null===j||void 0===j?void 0:j.firstname)||"",f=(null===(n=e.createdUser)||void 0===n?void 0:n.lastname)||(null===j||void 0===j?void 0:j.lastname)||"",g=`${v} ${f}`.trim()||"User",b=(v[0]||"")+(f[0]||"")||"?";return(0,Se.jsxs)(l.A,{sx:{borderRadius:2,border:"1px solid",borderColor:"divider",bgcolor:o?"rgba(255,255,255,0.025)":"rgba(99,102,241,0.018)",overflow:"hidden",opacity:r?.5:1,transition:"opacity .2s"},children:[(0,Se.jsxs)(a.A,{direction:"row",alignItems:"center",spacing:1,sx:{px:1.75,pt:1.25,pb:.75},children:[(0,Se.jsx)(c.A,{sx:{width:26,height:26,fontSize:10,fontWeight:700,bgcolor:(0,q.X4)("#6366F1",.15),color:"primary.main"},children:b.toUpperCase()}),(0,Se.jsxs)(l.A,{sx:{flex:1,minWidth:0},children:[(0,Se.jsx)(s.A,{sx:{fontSize:12.5,fontWeight:700,lineHeight:1.2},children:g}),(0,Se.jsx)(s.A,{sx:{fontSize:10.5,color:"text.disabled"},children:d?`Edited ${Re(e.updatedAt)}`:Re(e.createdAt)})]}),(0,Se.jsx)(u.A,{title:"Edit",children:(0,Se.jsx)(x.A,{size:"small",disabled:r||Boolean(M),onClick:()=>(async e=>{try{var t,n;const i=await(0,ge.e6)(be.A.baseURLApi,{query:Ae.Og,variables:{commentid:e}});H((null===i||void 0===i||null===(t=i.data)||void 0===t||null===(n=t.comment)||void 0===n?void 0:n.description)||"")}catch{const t=y.find(t=>t.commentid===e);H((null===t||void 0===t?void 0:t.description)||"")}W(e)})(e.commentid),sx:{width:26,height:26,color:"text.secondary","&:hover":{color:"primary.main",bgcolor:(0,q.X4)("#6366F1",.08)}},children:(0,Se.jsx)(ce.A,{sx:{fontSize:13}})})}),(0,Se.jsx)(u.A,{title:"Delete",children:(0,Se.jsx)(x.A,{size:"small",disabled:r||Boolean(M),onClick:()=>T(e.commentid),sx:{width:26,height:26,color:"text.secondary","&:hover":{color:"#EF4444",bgcolor:(0,q.X4)("#EF4444",.08)}},children:(0,Se.jsx)(ue.A,{sx:{fontSize:13}})})})]}),(0,Se.jsx)(p.A,{}),(0,Se.jsx)(l.A,{sx:{px:1.75,py:1.25},children:i?(0,Se.jsxs)(a.A,{spacing:1,children:[(0,Se.jsx)(h.A,{fullWidth:!0,multiline:!0,minRows:2,size:"small",value:I,onChange:e=>H(e.target.value),autoFocus:!0,sx:{"& .MuiOutlinedInput-root":{borderRadius:2}}}),(0,Se.jsxs)(a.A,{direction:"row",spacing:1,justifyContent:"flex-end",children:[(0,Se.jsx)(m.A,{size:"small",sx:{...qe,py:.4,px:1.5,fontSize:12},onClick:()=>{W(null),H("")},children:"Cancel"}),(0,Se.jsx)(m.A,{size:"small",variant:"contained",disabled:k||!I.trim(),sx:{...qe,py:.4,px:1.5,fontSize:12}
1,onClick:B,children:k?"Saving\u2026":"Save"})]})]}):(0,Se.jsx)(s.A,{sx:{fontSize:13,color:"text.primary",lineHeight:1.65,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e.description})})]},e.commentid)})}),(0,Se.jsxs)(l.A,{sx:{borderRadius:2.5,border:"1px solid",borderColor:"divider",bgcolor:"background.paper",overflow:"hidden"},children:[(0,Se.jsx)(h.A,{fullWidth:!0,multiline:!0,minRows:2,placeholder:"Write a comment\u2026",value:C,onChange:e=>D(e.target.value),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&(e.preventDefault(),N())},sx:{"& .MuiOutlinedInput-root":{border:"none",borderRadius:0,"& fieldset":{border:"none"}},"& textarea":{fontSize:13,p:1.5}}}),(0,Se.jsxs)(a.A,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{px:1.5,py:1,borderTop:"1px solid",borderColor:"divider"},children:[(0,Se.jsx)(s.A,{sx:{fontSize:10.5,color:"text.disabled"},children:"Ctrl + Enter to send"}),(0,Se.jsx)(m.A,{size:"small",variant:"contained",disabled:k||!C.trim(),startIcon:k?(0,Se.jsx)(d.A,{size:12,sx:{color:"inherit"}}):(0,Se.jsx)(de.A,{sx:{fontSize:14}}),onClick:N,sx:{...qe,py:.5,px:1.75,fontSize:12},children:k?"Sending\u2026":"Send"})]})]}),(0,Se.jsxs)(v.A,{open:Boolean(L),onClose:()=>T(null),PaperProps:{sx:{borderRadius:3}},maxWidth:"xs",fullWidth:!0,children:[(0,Se.jsx)(f.A,{sx:{fontSize:15,fontWeight:700},children:"Delete comment?"}),(0,Se.jsx)(g.A,{children:(0,Se.jsx)(s.A,{variant:"body2",color:"text.secondary",children:"This action can't be undone."})}),(0,Se.jsxs)(b.A,{sx:{p:2},children:[(0,Se.jsx)(m.A,{onClick:()=>T(null),sx:qe,children:"Cancel"}),(0,Se.jsx)(m.A,{color:"error",variant:"contained",disabled:Boolean(O),onClick:()=>(async e=>{R(e);try{var t;const n=await(0,ge.e6)(be.A.baseURLApi,{query:Ae.LW,variables:{commentid:e}});null!==n&&void 0!==n&&null!==(t=n.data)&&void 0!==t&&t.deleteComment&&(null===fe.D||void 0===fe.D||(0,fe.D)("Comment deleted","success"),F())}catch{null===fe.D||void 0===fe.D||(0,fe.D)("Could not delete comment","error")}finally{R(null),T(null)}})(L),sx:qe,children:"Delete"})]})]})]})}function Ee(e){let{stages:t,currentStageId:n}=e;const i=(0,V.A)();if(!t||0===t.length)return null;const r=t.findIndex(e=>e.stageid===n);return(0,Se.jsx)(l.A,{sx:{display:"flex",alignItems:"center",gap:.5,flexWrap:"wrap",mb:2},children:t.map((e,o)=>{const a=e.stageid===n,s=r>-1&&o<r,d=String(e.name||"").toLowerCase(),c=d.includes("won")?"#10B981":d.includes("lost")?"#EF4444":"#6366F1",u=a?c:s?(0,q.X4)(c,"dark"===i.palette.mode?.3:.2):"transparent",x=a?"#fff":s?"dark"===i.palette.mode?(0,q.X4)(c,.95):c:"text.secondary";return(0,Se.jsxs)(l.A,{sx:{display:"flex",alignItems:"center",gap:.5},children:[(0,Se.jsx)(l.A,{sx:{px:1.5,py:.6,borderRadius:"999px",bgcolor:u,border:"1px solid",borderColor:a?c:s?(0,q.X4)(c,.4):"divider",color:x,fontSize:12,fontWeight:600,whiteSpace:"nowrap",transition:"all .15s"},children:e.name}),o<t.length-1&&(0,Se.jsx)(l.A,{sx:{width:12,height:1.5,bgcolor:"divider",flexShrink:0}})]},e.stageid||o)})})}function Xe(e){let{activity:t,ownerEmail:n}=e;return t&&0!==t.length?(0,Se.jsxs)(l.A,{sx:{position:"relative",pl:2},children:[(0,Se.jsx)(l.A,{sx:{position:"absolute",left:7,top:8,bottom:8,width:2,bgcolor:"divider"}}),(0,Se.jsx)(a.A,{spacing:2.5,children:t.map((e,t)=>(0,Se.jsxs)(l.A,{sx:{position:"relative",pl:3},children:[(0,Se.jsx)(l.A,{sx:{position:"absolute",left:-1,top:2,width:16,height:16,borderRadius:"50%",bgcolor:"background.paper",border:"2px solid",borderColor:"primary.main",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,Se.jsx)(ae.A,{sx:{fontSize:10,color:"primary.main"}})}),(0,Se.jsx)(s.A,{sx:{fontSize:13.5,fontWeight:700},children:e.dealstagename||e.stagename||e.name||"Stage update"}),(0,Se.jsxs)(s.A,{variant:"caption",color:"text.secondary",children:[n?`by ${n} \xb7 `:"",e.createdAt?(0,xe.A)(/^\d+$/.test(String(e.createdAt))?parseInt(e.createdAt,10):e.createdAt).format("ddd, MMM DD, YYYY h:mm A"):""]})]},t))})]}):(0,Se.jsxs)(l.A,{sx:{py:8,textAlign:"center",color:"text.disabled"},children:[(0,Se.jsx)(ae.A,{sx:{fontSize:44,mb:1}}),(0,Se.jsx)(s.A,{variant:"body2",color:"text.secondary",children:"This section displays all stage activity for the deal."})]})}function Ue(e){let{open:t,onCancel:n,onConfirm:i}=e;return(0,Se.jsxs)(v.A,{open:t,onClose:n,PaperProps:{sx:{borderRadius:3}},children:[(0,Se.jsx)(f.A,{sx:{fontSize:16,fontWeight:700},children:"Discard changes?"}),(0,Se.jsx)(g.A,{children:(0,Se.jsx)(s.A,{variant:"body2",color:"text.secondary",children:"You have unsaved changes. Leaving now will lose them."})}),(0,Se.jsxs)(b.A,{sx:{p:2},children:[(0,Se.jsx)(m.A,{onClick:n,sx:qe,children:"Keep editing"}),(0,Se.jsx)(m.A,{color:"error",variant:"contained",onClick:i,sx:qe,children:"Discard"})]})]})}function Je(e){let{label:t}=e;return(0,Se.jsx)(l.A,{sx:{py:8,textAlign:"center",border:"2px dashed",borderColor:"divider",borderRadius:2},children:(0,Se.jsxs)(s.A,{variant:"body2",color:"text.secondary",children:[t," are scoped to the deal's linked contact. Save the deal with a contact first, then this tab will activate."]})})}function Ye(){var e,t,n,ne,ie,le,ae,se,de,ce,ue,xe,ge,be,Ae,je;const Ie=(0,r.wA)(),Re=(0,o.Zp)(),Ye=(0,o.zy)(),_e=(0,V.A)(),Ke=((0,A.A)(_e.breakpoints.down("md")),(0,i.useMemo)(()=>
1new URLSearchParams(Ye.search||""),[Ye.search])),Ze=Ke.get("did"),Ge="1"===Ke.get("new")||!Ze,et=Ke.get("cid"),tt=Ke.get("pid"),nt=Ke.get("sid"),it=(0,r.d4)(e=>e.pipelines.list),rt=(0,r.d4)(e=>e.contactDetail.dealFormFields),ot=(0,r.d4)(e=>e.contactDetail.dealFormLoading),lt=(0,r.d4)(e=>e.contactDetail.dealSections),at=(0,r.d4)(e=>e.contactDetail.users),st=(0,r.d4)(e=>e.contactDetail.products),dt=(0,r.d4)(e=>e.contactDetail.productsLoading),ct=(0,r.d4)(e=>e.contactDetail.contactSearchResults),ut=(0,r.d4)(e=>e.contactDetail.contactSearchLoading),xt=(0,r.d4)(e=>e.contactDetail.dealDetail),pt=(0,r.d4)(e=>e.contactDetail.dealDetailLoading),ht=(0,r.d4)(e=>e.contactDetail.contact),mt=((0,r.d4)(e=>e.deals.mutating),(0,i.useMemo)(()=>{try{return JSON.parse(localStorage.getItem("user"))}catch{return null}},[])),vt=(0,i.useMemo)(()=>{try{return JSON.parse(localStorage.getItem("userid"))}catch{return(null===mt||void 0===mt?void 0:mt.userid)||null}},[mt]),[ft,gt]=(0,i.useState)(0),[bt,At]=(0,i.useState)(!1),[jt,yt]=(0,i.useState)(!1),[St,wt]=(0,i.useState)(!1),[zt,Ct]=(0,i.useState)(""),[Dt,kt]=(0,i.useState)(!1),[$t,Mt]=(0,i.useState)(null),[Wt,It]=(0,i.useState)(null),Ht=()=>It(null),[Ot,Rt]=(0,i.useState)(0),[Lt,Tt]=(0,i.useState)({}),[Ft,Nt]=(0,i.useState)([]),[Bt,Vt]=(0,i.useState)(""),[qt,Pt]=(0,i.useState)(null),[Et,Xt]=(0,i.useState)(""),[Ut,Jt]=(0,i.useState)({}),Yt=(0,i.useRef)(!1),Qt=(e,t)=>Tt(n=>({...n,[e]:t})),_t=(0,i.useRef)({values:"",contacts:"",product:null}),Kt=(e,t,n)=>{_t.current={values:JSON.stringify(e||{}),contacts:JSON.stringify(t||[]),product:JSON.stringify((null===n||void 0===n?void 0:n.productserviceid)||null)}},Zt=JSON.stringify(Lt)!==_t.current.values||JSON.stringify(Ft)!==_t.current.contacts||JSON.stringify((null===qt||void 0===qt?void 0:qt.productserviceid)||null)!==_t.current.product;(0,i.useEffect)(()=>{Ie((0,he.q1)()),Ie((0,pe.N8)()),Ie((0,pe.Ng)({formtype:ve.lD.dealForm})),at&&0!==at.length||Ie((0,pe.eM)()),Ze&&Ie((0,pe.zi)(Ze)),et&&Ie((0,pe.tS)(et))},[]),(0,i.useEffect)(()=>{const e=setTimeout(()=>Ie((0,pe._N)({searchtext:Bt,pagesize:20})),300);return()=>clearTimeout(e)},[Bt,Ie]),(0,i.useEffect)(()=>{const e=setTimeout(()=>Ie((0,pe.j0)({searchtext:Et,pagesize:25})),300);return()=>clearTimeout(e)},[Et,Ie]);const Gt=(0,i.useRef)(!1);(0,i.useEffect)(()=>{var e,t,n,i,r;if(!Ge)return;if(Gt.current)return;if(!it||0===it.length)return;const o=tt||(null===(e=it[0])||void 0===e?void 0:e.pipelineid)||"",l=it.find(e=>e.pipelineid===o),a=nt||(null===l||void 0===l||null===(t=l.stages)||void 0===t||null===(n=t[0])||void 0===n?void 0:n.stageid)||"",s=(lt||[]).find(e=>"deals"===e.objecttype),d=null===s||void 0===s||null===(i=s.properties)||void 0===i?void 0:i.find(e=>"dealtype"===e.dbfieldname||"Deal Type"===e.name),c=(0,ve.jD)(null===d||void 0===d?void 0:d.options,null)||[{internal:"newBusiness",label:"New Business"}],u={pipelineid:o,stageid:a,dealtype:(null===(r=c[0])||void 0===r?void 0:r.internal)||"newBusiness",ownerid:vt||"",closedate:Oe()};Tt(u),Yt.current=!1;const x=et&&(null===ht||void 0===ht?void 0:ht.contactid)===et?[{contactid:ht.contactid,firstname:ht.firstname,lastname:ht.lastname,primaryemail:ht.primaryemail}]:[];Nt(x),Kt(u,x,null),Gt.current=!0},[Ge,it,lt,tt,nt,et,ht,vt]),(0,i.useEffect)(()=>{var e,t,n,i,r,o,l;if(Ge)return;if(!xt)return;if(xt.dealid!==Ze)return;const a={...xt};xt.closedate&&(a.closedate=He(xt.closedate)),!a.pipelineid&&xt.pipeline&&(a.pipelineid=xt.pipeline),!a.stageid&&xt.dealstage&&(a.stageid=xt.dealstage),null!==(e=xt.ownerusers)&&void 0!==e&&null!==(t=e[0])&&void 0!==t&&t.userid?a.ownerid=String(xt.ownerusers[0].userid):null!==(n=xt.ownerusers)&&void 0!==n&&n.userid&&(a.ownerid=String(xt.ownerusers.userid)),null!=xt.productquantity&&(a.productquantity=String(xt.productquantity)),Tt(a),Yt.current=!0;const s=xt.productid?{productserviceid:xt.productid,name:xt.productname||(null===(i=xt.product)||void 0===i?void 0:i.name)||"Selected product",salesprice:null!==(r=null===(o=xt.product)||void 0===o?void 0:o.salesprice)&&void 0!==r?r:xt.salesprice}:null;Pt(s);const d=null!==(l=xt.contact)&&void 0!==l&&l.contactid?[{contactid:xt.contact.contactid,firstname:xt.contact.firstname,lastname:xt.contact.lastname,primaryemail:xt.contact.primaryemail}]:[];Nt(d),Kt(a,d,s)},[xt,Ze,Ge]);const en=(0,i.useMemo)(()=>{const e=Array.isArray(rt)&&rt.length>0?rt:ve.Q9,t=t=>e.some(e=>e.dbfieldname===t),n=[];return t("productid")||n.push(Be),t("productquantity")||n.push(Ve),n.length?[...e,...n]:e},[rt]),tn=(0,i.useMemo)(()=>(it||[]).find(e=>e.pipelineid===Lt.pipelineid),[it,Lt.pipelineid]),nn=(null===tn||void 0===tn?void 0:tn.stages)||[],rn=(null===tn||void 0===tn?void 0:tn.dealcurrency)||"USD",on=(0,i.useMemo)(()=>{var e;const t=(lt||[]).find(e=>"deals"===e.objecttype),n=null===t||void 0===t||null===(e=t.properties)||void 0===e?void 0:e.find(e=>"dealtype"===e.dbfieldname||"Deal Type"===e.name),i=(0,ve.jD)(null===n||void 0===n?void 0:n.options,null);return Array.isArray(i)&&i.length>0?i:[{internal:"newBusiness",label:"New Business"},{internal:"existingBusiness",label:"Existing Business"}]},[lt]),ln=(0,i.useMemo)(()=>{const e=[...at||[]];return null!==mt&&void 0!==mt&&mt.userid&&!e.some(e=>e.userid===mt.userid)&&e.push({userid:mt.userid,email:mt.email,firstname:mt.firstname,lastname:mt.lastname}),[...new Map(e.map(e=>[e.userid,e])).values()]},[at,mt]);(0,i.useEffect)(()=>
1{if(Yt.current)return;const e=Number(null===qt||void 0===qt?void 0:qt.salesprice),t=Number(Lt.productquantity);if(e&&t&&!Number.isNaN(e)&&!Number.isNaN(t)){const n=e*t;Tt(e=>{var t;return String(null!==(t=e.dealamount)&&void 0!==t?t:"")===String(n)?e:{...e,dealamount:n}})}},[qt,Lt.productquantity]);const an=()=>{var e;const t=en.map(e=>{let t;if(Ne(e))t=Ft[0]?{id:Ft[0].contactid}:null;else if("closedate"===e.dbfieldname&&Lt.closedate)t=new Date(Lt.closedate).toISOString();else if(e.fieldtype===ve.wx.Numbers||Fe(e)){const n=Lt[e.dbfieldname];t=""===n||null===n||void 0===n?null:parseFloat(n)}else{var n;t=null!==(n=Lt[e.dbfieldname])&&void 0!==n?n:null}return{name:e.name,custom_name:e.name,value:t,dbfieldName:e.dbfieldname}});return t.push({name:"deal_contactid",custom_name:"deal_contactid",value:null===(e=Ft[0])||void 0===e?void 0:e.contactid,dbfieldName:"contactid"}),t},sn=async(e,t)=>{if(Ze){kt(!0);try{await Ie((0,me.Qf)({dealid:Ze,status:e,lostreason:t||""})).unwrap();const n=e===me.cd.Won?"won":e===me.cd.Lost?"lost":e===me.cd.Archived?"archived":"restored";null===fe.D||void 0===fe.D||(0,fe.D)(`Deal marked as ${n}`,"success"),Re("/contacts?tab=deals")}catch(n){null===fe.D||void 0===fe.D||(0,fe.D)("string"===typeof n?n:"Could not update status","error")}finally{kt(!1)}}},dn=(0,i.useMemo)(()=>{if(Ge||!xt)return me.cd.Open;const e=xt.status;if(null==e)return me.cd.Open;const t=Number(e);if(Number.isFinite(t))return t;const n=String(e).toLowerCase();return"won"===n?me.cd.Won:"lost"===n?me.cd.Lost:"archived"===n?me.cd.Archived:me.cd.Open},[xt,Ge]),cn=dn!==me.cd.Open&&2!==dn,un=(e,t)=>{const n=e.dbfieldname,r=e.propertyname||e.name,o=Boolean(e.isrequired),d=Ut[n],c=(e=>Le(e)||Ne(e)||(e=>"dealname"===e.dbfieldname)(e)||(e=>"description"===e.dbfieldname)(e)||e.fieldtype===ve.wx.Multilinetext||e.fieldtype===ve.wx.Section||e.fieldtype===ve.wx.Divider||e.fieldtype===ve.wx.Label)(e)?12:6;if(Te(e))return null;if(Fe(e))return null;if(e.fieldtype===ve.wx.Section)return(0,Se.jsx)(j.Ay,{item:!0,xs:12,children:(0,Se.jsx)(s.A,{variant:"subtitle2",sx:{mt:1,fontWeight:700,color:"text.secondary"},children:r})},`${n}-${t}`);if(e.fieldtype===ve.wx.Divider)return(0,Se.jsx)(j.Ay,{item:!0,xs:12,children:(0,Se.jsx)(p.A,{sx:{my:.5}})},`${n}-${t}`);if(e.fieldtype===ve.wx.Label)return(0,Se.jsx)(j.Ay,{item:!0,xs:12,children:(0,Se.jsx)(s.A,{variant:"body2",color:"text.secondary",children:r})},`${n}-${t}`);if(Le(e)){const e=en.find(Te);return(0,Se.jsxs)(i.Fragment,{children:[(0,Se.jsx)(j.Ay,{item:!0,xs:12,sm:6,children:(0,Se.jsxs)(y.A,{fullWidth:!0,size:"small",error:Boolean(d),children:[(0,Se.jsxs)(S.A,{children:[r,o?" *":""]}),(0,Se.jsx)(w.A,{value:Lt.pipelineid||"",label:r,onChange:e=>{const t=e.target.value,n=(it||[]).find(e=>e.pipelineid===t);Tt(e=>{var i,r;return{...e,pipelineid:t,stageid:(null===n||void 0===n||null===(i=n.stages)||void 0===i||null===(r=i[0])||void 0===r?void 0:r.stageid)||""}})},sx:{borderRadius:"12px"},children:(it||[]).map(e=>(0,Se.jsx)(z.A,{value:e.pipelineid,children:e.name},e.pipelineid))})]})}),e&&(0,Se.jsx)(j.Ay,{item:!0,xs:12,sm:6,children:(0,Se.jsxs)(y.A,{fullWidth:!0,size:"small",disabled:!nn.length,error:Boolean(Ut.stageid),children:[(0,Se.jsxs)(S.A,{children:[e.propertyname||e.name||"Stage",e.isrequired?" *":""]}),(0,Se.jsx)(w.A,{value:Lt.stageid||"",label:e.propertyname||e.name||"Stage",onChange:e=>Qt("stageid",e.target.value),sx:{borderRadius:"12px"},children:nn.map(e=>(0,Se.jsx)(z.A,{value:e.stageid,children:e.name},e.stageid))})]})})]},`${n}-${t}`)}var u;if((e=>"dealtype"===e.dbfieldname)(e))return(0,Se.jsx)(j.Ay,{item:!0,xs:12,sm:6,children:(0,Se.jsxs)(y.A,{fullWidth:!0,size:"small",error:Boolean(d),children:[(0,Se.jsxs)(S.A,{children:[r,o?" *":""]}),(0,Se.jsx)(w.A,{value:null!==(u=Lt.dealtype)&&void 0!==u?u:"",label:r,onChange:e=>Qt("dealtype",e.target.value),sx:{borderRadius:"12px"},children:on.map((e,t)=>{var n,i,r,o,l;const a=null!==(n=null!==(i=e.internal)&&void 0!==i?i:e.value)&&void 0!==n?n:e,s=null!==(r=null!==(o=null!==(l=e.label)&&void 0!==l?l:e.key)&&void 0!==o?o:e.name)&&void 0!==r?r:String(e);return(0,Se.jsx)(z.A,{value:a,children:s},`${a}-${t}`)})})]})},`${n}-${t}`);
1if((e=>"productid"===e.dbfieldname)(e)){var x;const e=en.find(Fe);return(0,Se.jsxs)(i.Fragment,{children:[(0,Se.jsx)(j.Ay,{item:!0,xs:12,sm:6,children:(0,Se.jsx)(C.A,{size:"small",options:st||[],value:qt,onChange:(e,t)=>{Pt(t),Qt("productid",(null===t||void 0===t?void 0:t.productserviceid)||""),Yt.current=!1},inputValue:Et,onInputChange:(e,t)=>Xt(t),loading:dt,getOptionLabel:e=>(null===e||void 0===e?void 0:e.name)||"",isOptionEqualToValue:(e,t)=>(null===e||void 0===e?void 0:e.productserviceid)===(null===t||void 0===t?void 0:t.productserviceid),renderOption:(e,t)=>{var n;return(0,i.createElement)("li",{...e,key:t.productserviceid},(0,Se.jsxs)(l.A,{children:[(0,Se.jsx)(s.A,{variant:"body2",fontWeight:600,children:t.name}),(t.salesprice||t.actualprice)&&(0,Se.jsxs)(s.A,{variant:"caption",color:"text.secondary",children:[t.currency||We(rn),null!==(n=t.salesprice)&&void 0!==n?n:t.actualprice]})]}))},renderInput:e=>(0,Se.jsx)(h.A,{...e,label:`${r}${o?" *":""}`,error:Boolean(d),helperText:d})})}),e&&(0,Se.jsx)(j.Ay,{item:!0,xs:12,sm:6,children:(0,Se.jsx)(h.A,{label:"Product Quantity",fullWidth:!0,size:"small",type:"number",value:null!==(x=Lt.productquantity)&&void 0!==x?x:"",onChange:e=>{Qt("productquantity",e.target.value),Yt.current=!1},onWheel:e=>e.target.blur(),onKeyDown:e=>{38!==e.keyCode&&40!==e.keyCode||e.preventDefault()},helperText:null!==qt&&void 0!==qt&&qt.salesprice?`Unit price ${Me(qt.salesprice,rn)}`:" "})})]},`${n}-${t}`)}if((e=>"ownerid"===e.dbfieldname)(e))return(0,Se.jsx)(j.Ay,{item:!0,xs:12,sm:6,children:(0,Se.jsxs)(y.A,{fullWidth:!0,size:"small",error:Boolean(d),children:[(0,Se.jsxs)(S.A,{children:[r,o?" *":""]}),(0,Se.jsx)(w.A,{value:null!=Lt.ownerid?String(Lt.ownerid):"",label:r,onChange:e=>Qt("ownerid",e.target.value),sx:{borderRadius:"12px"},children:ln.map(e=>(0,Se.jsxs)(z.A,{value:String(e.userid),children:[e.firstname," ",e.lastname," (",e.email,")"]},e.userid))})]})},`${n}-${t}`);if(Ne(e))return(0,Se.jsx)(j.Ay,{item:!0,xs:12,sm:6,children:(0,Se.jsx)(C.A,{multiple:!0,size:"small",options:ct||[],value:Ft,onChange:(e,t)=>
1{Nt(t||[]),t&&t.length>0&&Ut.contactid&&Jt(e=>{const t={...e};return delete t.contactid,t})},inputValue:Bt,onInputChange:(e,t)=>Vt(t),loading:ut,getOptionLabel:e=>{if(!e)return"";const t=`${e.firstname||""} ${e.lastname||""}`.trim();return e.primaryemail?`${t} (${e.primaryemail})`:t},isOptionEqualToValue:(e,t)=>(null===e||void 0===e?void 0:e.contactid)===(null===t||void 0===t?void 0:t.contactid),renderTags:(e,t)=>e.map((e,n)=>{const i=t({index:n});return(0,Se.jsx)(D.A,{size:"small",...i,label:`${e.firstname||""} ${e.lastname||""}`.trim()||e.primaryemail||"Contact",sx:{borderRadius:"8px",fontWeight:600,bgcolor:(0,q.X4)("#6366F1",.1),color:"primary.main","& .MuiChip-deleteIcon":{color:"primary.main"}}})}),renderInput:e=>(0,Se.jsx)(h.A,{...e,required:!0,label:r||"Contact",placeholder:0===Ft.length?"Search contacts\u2026":"",error:Boolean(d||Ut.contactid),helperText:d||Ut.contactid||"Required \u2014 pick at least one contact"})})},`${n}-${t}`);const m=(0,ve.jD)(e.options,null);switch(e.fieldtype){case ve.wx.Singlelinetext:return(0,Se.jsx)(j.Ay,{item:!0,xs:12,sm:c,children:(0,Se.jsx)(h.A,{label:`${r}${o?" *":""}`,fullWidth:!0,size:"small",value:Lt[n]||"",onChange:e=>Qt(n,e.target.value),error:Boolean(d),helperText:d})},`${n}-${t}`);case ve.wx.Multilinetext:return(0,Se.jsx)(j.Ay,{item:!0,xs:12,children:(0,Se.jsx)(h.A,{label:`${r}${o?" *":""}`,fullWidth:!0,multiline:!0,minRows:3,value:Lt[n]||"",onChange:e=>Qt(n,e.target.value),error:Boolean(d),helperText:d})},`${n}-${t}`);case ve.wx.Numbers:{var v;const i=(e=>"dealamount"===e.dbfieldname)(e);return(0,Se.jsx)(j.Ay,{item:!0,xs:12,sm:6,children:(0,Se.jsx)(h.A,{label:`${r}${o?" *":""}`,fullWidth:!0,size:"small",type:"number",value:null!==(v=Lt[n])&&void 0!==v?v:"",onChange:e=>{Qt(n,e.target.value),i&&(Yt.current=!0)},error:Boolean(d),helperText:d,InputProps:i?{startAdornment:(0,Se.jsx)(k.A,{position:"start",children:We(rn)})}:void 0})},`${n}-${t}`)}case ve.wx.Phonenumber:return(0,Se.jsx)(j.Ay,{item:!0,xs:12,sm:6,children:(0,Se.jsx)(h.A,{label:`${r}${o?" *":""}`,fullWidth:!0,size:"small",value:Lt[n]||"",onChange:e=>Qt(n,e.target.value),error:Boolean(d),helperText:d})},`${n}-${t}`);case ve.wx.Datepicker:return(0,Se.jsx)(j.Ay,{item:!0,xs:12,sm:6,children:(0,Se.jsx)(h.A,{label:`${r}${o?" *":""}`,fullWidth:!0,size:"small",type:"datetime-local",value:Lt[n]?He(Lt[n]):"",onChange:e=>Qt(n,e.target.value),InputLabelProps:{shrink:!0},error:Boolean(d),helperText:d})},`${n}-${t}`);case ve.wx.Dropdownselect:{var f;const e=Array.isArray(m)?m:[];return(0,Se.jsx)(j.Ay,{item:!0,xs:12,sm:6,children:(0,Se.jsxs)(y.A,{fullWidth:!0,size:"small",error:Boolean(d),children:[(0,Se.jsxs)(S.A,{children:[r,o?" *":""]}),(0,Se.jsx)(w.A,{value:null!==(f=Lt[n])&&void 0!==f?f:"",label:r,onChange:e=>Qt(n,e.target.value),sx:{borderRadius:"12px"},children:e.map((e,t)=>{var n,i,r,o,l;const a=null!==(n=null!==(i=e.internal)&&void 0!==i?i:e.value)&&void 0!==n?n:e,s=null!==(r=null!==(o=null!==(l=e.label)&&void 0!==l?l:e.key)&&void 0!==o?o:e.name)&&void 0!==r?r:String(e);return(0,Se.jsx)(z.A,{value:a,children:s},`${a}-${t}`)})})]})},`${n}-${t}`)}case ve.wx.Radioselect:{var g;const e=Array.isArray(m)?m:[];return(0,Se.jsx)(j.Ay,{item:!0,xs:12,children:(0,Se.jsxs)(y.A,{error:Boolean(d),children:[(0,Se.jsxs)($.A,{sx:{fontSize:13,fontWeight:600,mb:.5},children:[r,o?" *":""]}),(0,Se.jsx)(M.A,{row:!0,value:String(null!==(g=Lt[n])&&void 0!==g?g:""),onChange:(e,t)=>
1Qt(n,t),children:e.map((e,t)=>{var n,i,r,o,l;const a=null!==(n=null!==(i=e.internal)&&void 0!==i?i:e.value)&&void 0!==n?n:e,s=null!==(r=null!==(o=null!==(l=e.label)&&void 0!==l?l:e.key)&&void 0!==o?o:e.name)&&void 0!==r?r:String(e);return(0,Se.jsx)(W.A,{value:String(a),control:(0,Se.jsx)(I.A,{size:"small"}),label:s},`${a}-${t}`)})})]})},`${n}-${t}`)}case ve.wx.Singlecheckbox:return(0,Se.jsx)(j.Ay,{item:!0,xs:12,sm:6,children:(0,Se.jsx)(W.A,{control:(0,Se.jsx)(H.A,{checked:Boolean(Lt[n]),onChange:e=>Qt(n,e.target.checked)}),label:`${r}${o?" *":""}`})},`${n}-${t}`);case ve.wx.Multiplecheckbox:{const e=Array.isArray(m)?m:[],i=Array.isArray(Lt[n])?Lt[n]:[];return(0,Se.jsxs)(j.Ay,{item:!0,xs:12,children:[(0,Se.jsxs)($.A,{sx:{fontSize:13,fontWeight:600,mb:.5,display:"block"},children:[r,o?" *":""]}),(0,Se.jsx)(a.A,{direction:"row",flexWrap:"wrap",gap:.5,children:e.map((e,t)=>{var r,o,l,a,s;const d=null!==(r=null!==(o=e.internal)&&void 0!==o?o:e.value)&&void 0!==r?r:e,c=null!==(l=null!==(a=null!==(s=e.label)&&void 0!==s?s:e.key)&&void 0!==a?a:e.name)&&void 0!==l?l:String(e),u=i.includes(d);return(0,Se.jsx)(W.A,{control:(0,Se.jsx)(H.A,{size:"small",checked:u,onChange:e=>{const t=e.target.checked?[...i,d]:i.filter(e=>e!==d);Qt(n,t)}}),label:c},`${d}-${t}`)})})]},`${n}-${t}`)}case ve.wx.Rating:return(0,Se.jsxs)(j.Ay,{item:!0,xs:12,sm:6,children:[(0,Se.jsxs)(s.A,{variant:"caption",color:"text.secondary",sx:{display:"block",fontWeight:600},children:[r,o?" *":""]}),(0,Se.jsx)(O.A,{size:"large",precision:.5,value:Number(Lt[n])||0,onChange:(e,t)=>
1Qt(n,null!==t&&void 0!==t?t:0)})]},`${n}-${t}`);default:return(0,Se.jsx)(j.Ay,{item:!0,xs:12,sm:6,children:(0,Se.jsx)(h.A,{label:`${r}${o?" *":""}`,fullWidth:!0,size:"small",value:Lt[n]||"",onChange:e=>Qt(n,e.target.value)})},`${n}-${t}`)}},xn=Ge?"New Deal":Lt.dealname||(null===xt||void 0===xt?void 0:xt.dealname)||"Deal",pn=parseFloat(Lt.dealamount)||parseFloat(null===xt||void 0===xt?void 0:xt.dealamount)||0,hn=Ft[0],mn=(null===hn||void 0===hn?void 0:hn.contactid)||(null===xt||void 0===xt||null===(e=xt.contact)||void 0===e?void 0:e.contactid)||et||null,vn=hn?`${hn.firstname||""} ${hn.lastname||""}`.trim():"",fn=(null===hn||void 0===hn?void 0:hn.primaryemail)||(null===xt||void 0===xt||null===(t=xt.contact)||void 0===t?void 0:t.primaryemail)||"",gn=(null===xt||void 0===xt||null===(n=xt.contact)||void 0===n?void 0:n.contactavatar)||"",bn=(null===xt||void 0===xt||null===(ne=xt.contact)||void 0===ne?void 0:ne.organization)||(null===ht||void 0===ht?void 0:ht.organization),An=null===(ie=Array.isArray(null===xt||void 0===xt?void 0:xt.ownerusers)?xt.ownerusers[0]:null===xt||void 0===xt?void 0:xt.ownerusers)||void 0===ie?void 0:ie.email;return(0,Se.jsxs)(l.A,{sx:{p:{xs:1.5,md:2.5},pb:6},children:[(0,Se.jsxs)(a.A,{direction:"row",alignItems:"center",spacing:1.5,sx:{mb:2},children:[(0,Se.jsx)(ye.A,{label:"Back to Deals",onClick:()=>{!Zt||Dt?Re("/contacts?tab=deals"):At(!0)}}),(0,Se.jsxs)(l.A,{sx:{flex:1,minWidth:0},children:[(0,Se.jsx)(s.A,{sx:{fontSize:11,fontWeight:700,color:"text.secondary",textTransform:"uppercase",letterSpacing:.5},children:Ge?"New deal":"Editing deal"}),(0,Se.jsx)(s.A,{sx:{fontSize:{xs:16,md:18},fontWeight:700,lineHeight:1.2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:xn})]}),(0,Se.jsx)(m.A,{variant:"contained",startIcon:Dt?(0,Se.jsx)(d.A,{size:14,thickness:5,sx:{color:"inherit"}}):(0,Se.jsx)(X.A,{sx:{fontSize:16}}),onClick:async()=>{if((()=>{const e={};return en.forEach(t=>{if(!t.isrequired)return;if(Ne(t))return void(0===Ft.length&&(e[t.dbfieldname]=`${t.propertyname||t.name} is required`));const n=Lt[t.dbfieldname];(void 0===n||null===n||""===n||Array.isArray(n)&&0===n.length)&&(e[t.dbfieldname]=`${t.propertyname||t.name} is required`)}),0===Ft.length&&(e.contactid="Please link at least one contact"),Jt(e),0===Object.keys(e).length})()){kt(!0);try{var e;if(Ge)await Ie((0,pe.ro)({dealsdata:JSON.stringify(an())})).unwrap(),null===fe.D||void 0===fe.D||(0,fe.D)("Deal created","success");else await Ie((0,pe.Kd)({dealid:Ze,dealname:Lt.dealname,description:Lt.description||null,dealtype:Lt.dealtype,pipelineid:Lt.pipelineid||null,stageid:Lt.stageid||null,dealamount:parseFloat(Lt.dealamount)||0,productid:Lt.productid||null,productquantity:Lt.productquantity?Number(Lt.productquantity):null,closedate:Lt.closedate?new Date(Lt.closedate).toISOString().replace("T"," "):null,ownerid:Lt.ownerid||null,contactid:null===(e=Ft[0])||void 0===e?void 0:e.contactid})).unwrap(),null===fe.D||void 0===fe.D||(0,fe.D)("Deal updated","success");Re("/contacts?tab=deals")}catch(t){null===fe.D||void 0===fe.D||(0,fe.D)("string"===typeof t?t:"Could not save deal","error")}finally{kt(!1)}}},disabled:Dt||ot,sx:{borderRadius:"999px",textTransform:"none",fontSize:13,fontWeight:700,px:2.5,py:.75,boxShadow:"none"},children:Dt?"Saving\u2026":"Save Changes"})]}),pt&&!xt&&(0,Se.jsx)(R.A,{sx:{height:2,mb:2,borderRadius:1}}),(0,Se.jsxs)(j.Ay,{container:!0,spacing:2,children:[(0,Se.jsx)(j.Ay,{item:!0,xs:12,md:3.5,children:(0,Se.jsxs)(a.A,{spacing:2,children:[(0,Se.jsxs)(L.A,{elevation:0,sx:{borderRadius:3,border:"1px solid",borderColor:"divider",p:2.5,textAlign:"center",position:"relative",overflow:"hidden",boxShadow:"dark"===_e.palette.mode?"0 1px 3px rgba(0,0,0,0.4)":"0 1px 3px rgba(15,23,42,0.06)","&::before":{content:'""',position:"absolute",top:0,left:0,right:0,height:64,background:`linear-gradient(135deg, ${(0,q.X4)("#6366F1","dark"===_e.palette.mode?.28:.14)} 0%, ${(0,q.X4)("#8B5CF6","dark"===_e.palette.mode?.18:.08)} 100%)`}},children:[(0,Se.jsx)(c.A,{sx:{width:72,height:72,mx:"auto",mb:1.5,fontSize:28,fontWeight:700,position:"relative",zIndex:1,bgcolor:"background.paper",color:"primary.main",border:"3px solid",borderColor:"background.paper",boxShadow:`0 0 0 1px ${(0,q.X4)("#6366F1",.25)}, 0 4px 12px ${(0,q.X4)("#6366F1",.2)}`},children:We(rn)}),(0,Se.jsx)(s.A,{sx:{fontSize:23,fontWeight:800,color:"text.primary",fontVariantNumeric:"tabular-nums",lineHeight:1.1,letterSpacing:-.5},children:Me(pn,rn)}),(0,Se.jsx)(s.A,{sx:{fontSize:14,fontWeight:600,color:"text.secondary",mt:.5},children:xn}),!Ge&&(0,Se.jsx)(D.A,{size:"small",label:dn===me.cd.Won?"Won":dn===me.cd.Lost?"Lost":dn===me.cd.Archived?"Archived":"Open",sx:{mt:1.5,fontSize:10.5,fontWeight:700,height:22,bgcolor:dn===me.cd.Won?(0,q.X4)("#10B981",.14):dn===me.cd.Lost?(0,q.X4)("#EF4444",.14):dn===me.cd.Archived?(0,q.X4)("#64748B",.14):(0,q.X4)("#6366F1",.14),color:dn===me.cd.Won?"#10B981":dn===me.cd.Lost?"#EF4444":dn===me.cd.Archived?"#64748B":"#6366F1"}}),!Ge&&(0,Se.jsxs)(Se.Fragment,{children:[(0,Se.jsx)(p.A,{sx:{my:2}}),(0,Se.jsxs)(a.A,{spacing:1,children:[cn?(0,Se.jsx)(m.A,{fullWidth:!0,size:"small",variant:"outlined",startIcon:(0,Se.jsx)(Q.A,{sx:{fontSize:15}}),onClick:()=>sn(me.cd.Open),disabled:Dt,sx:{borderRadius:2,textTransform:"none",fontWeight:600,fontSize:12,color:"#6366F1",borderColor:(0,q.X4)("#6366F1",.4),"&:hover":{borderColor:"#6366F1",bgcolor:(0,q.X4)("#6366F1",.06)}},children:"Restore to Open"}):(0,Se.jsxs)(a.A,{direction:"row",spacing:1,children:[(0,Se.jsx)(m.A,{fullWidth:!0,size:"small",variant:"outlined",startIcon:(0,Se.jsx)(U.A,{s
1x:{fontSize:15}}),onClick:()=>sn(me.cd.Won),disabled:Dt,sx:{borderRadius:2,textTransform:"none",fontWeight:600,fontSize:12,color:"#10B981",borderColor:(0,q.X4)("#10B981",.4),"&:hover":{borderColor:"#10B981",bgcolor:(0,q.X4)("#10B981",.06)}},children:"Won"}),(0,Se.jsx)(m.A,{fullWidth:!0,size:"small",variant:"outlined",startIcon:(0,Se.jsx)(J.A,{sx:{fontSize:15}}),onClick:()=>wt(!0),disabled:Dt,sx:{borderRadius:2,textTransform:"none",fontWeight:600,fontSize:12,color:"#EF4444",borderColor:(0,q.X4)("#EF4444",.4),"&:hover":{borderColor:"#EF4444",bgcolor:(0,q.X4)("#EF4444",.06)}},children:"Lost"})]}),(0,Se.jsxs)(a.A,{direction:"row",spacing:1,children:[!cn&&(0,Se.jsx)(m.A,{fullWidth:!0,size:"small",variant:"text",startIcon:(0,Se.jsx)(Y.A,{sx:{fontSize:15}}),onClick:()=>sn(me.cd.Archived),disabled:Dt,sx:{borderRadius:2,textTransform:"none",fontWeight:600,fontSize:12,color:"text.secondary"},children:"Archive"}),(0,Se.jsx)(m.A,{fullWidth:!0,size:"small",variant:"text",startIcon:(0,Se.jsx)(_.A,{sx:{fontSize:15}}),onClick:()=>yt(!0),disabled:Dt,sx:{borderRadius:2,textTransform:"none",fontWeight:600,fontSize:12,color:"error.main"},children:"Delete"})]})]})]})]}),hn&&(0,Se.jsxs)(L.A,{elevation:0,sx:{borderRadius:3,border:"1px solid",borderColor:"divider",p:2,boxShadow:"dark"===_e.palette.mode?"0 1px 3px rgba(0,0,0,0.4)":"0 1px 3px rgba(15,23,42,0.06)"},children:[(0,Se.jsxs)(a.A,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{mb:1.25},children:[(0,Se.jsx)(s.A,{sx:{fontSize:12,fontWeight:700,textTransform:"uppercase",letterSpacing:.5,color:"text.secondary"},children:"Person"}),(0,Se.jsx)(m.A,{size:"small",onClick:()=>Mt(mn),endIcon:(0,Se.jsx)(te.A,{sx:{fontSize:13}}),sx:{fontSize:11.5,textTransform:"none",minWidth:0,py:0},children:"View"})]}),(0,Se.jsxs)(a.A,{direction:"row",spacing:1.25,alignItems:"center",children:[(0,Se.jsx)(c.A,{src:gn||void 0,sx:{width:36,height:36,fontSize:14,fontWeight:700,bgcolor:"primary.main"},children:(null===(le=vn[0])||void 0===le?void 0:le.toUpperCase())||"?"}),(0,Se.jsxs)(l.A,{sx:{minWidth:0,flex:1},children:[(0,Se.jsx)(s.A,{sx:{fontSize:13.5,fontWeight:600,lineHeight:1.2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:vn||"\u2014"}),fn&&(0,Se.jsx)(s.A,{sx:{fontSize:11.5,color:"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:fn})]})]}),(0,Se.jsxs)(a.A,{direction:"row",spacing:1,sx:{mt:1.5,justifyContent:"center"},children:[(0,Se.jsx)(u.A,{title:"Emails",children:(0,Se.jsx)(x.A,{size:"small",onClick:()=>{gt(4),Rt(e=>e+1)},sx:{width:32,height:32,bgcolor:(0,q.X4)("#6366F1",.1),color:"primary.main","&:hover":{bgcolor:(0,q.X4)("#6366F1",.18)}},children:(0,Se.jsx)(Z.A,{sx:{fontSize:16}})})}),(0,Se.jsx)(u.A,{title:"Tasks",children:(0,Se.jsx)(x.A,{size:"small",onClick:()=>gt(3),sx:{width:32,height:32,bgcolor:(0,q.X4)("#6366F1",.1),color:"primary.main","&:hover":{bgcolor:(0,q.X4)("#6366F1",.18)}},children:(0,Se.jsx)(oe.A,{sx:{fontSize:16}})})}),(0,Se.jsx)(u.A,{title:"Notes",children:(0,Se.jsx)(x.A,{size:"small",onClick:()=>gt(2),sx:{width:32,height:32,bgcolor:(0,q.X4)("#6366F1",.1),color:"primary.main","&:hover":{bgcolor:(0,q.X4)("#6366F1",.18)}},children:(0,Se.jsx)(re.A,{sx:{fontSize:16}})})})]})]}),(null===bn||void 0===bn?void 0:bn.name)&&(0,Se.jsxs)(L.A,{elevation:0,sx:{borderRadius:3,border:"1px solid",borderColor:"divider",p:2,boxShadow:"dark"===_e.palette.mode?"0 1px 3px rgba(0,0,0,0.4)":"0 1px 3px rgba(15,23,42,0.06)"},children:[(0,Se.jsxs)(a.A,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{mb:1.25},children:[(0,Se.jsx)(s.A,{sx:{fontSize:12,fontWeight:700,textTransform:"uppercase",letterSpacing:.5,color:"text.secondary"},children:"Organization"}),bn.organizationid&&(0,Se.jsx)(m.A,{size:"small",onClick:()=>It({id:bn.organizationid,name:bn.name}),endIcon:(0,Se.jsx)(te.A,{sx:{fontSize:13}}),sx:{fontSize:11.5,textTransform:"none",minWidth:0,py:0},children:"View"})]}),(0,Se.jsxs)(a.A,{spacing:.75,children:[(0,Se.jsxs)(a.A,{direction:"row",spacing:1,alignItems:"center",children:[(0,Se.jsx)(K.A,{sx:{fontSize:14,color:"text.disabled",flexShrink:0}}),(0,Se.jsx)(s.A,{sx:{fontSize:12.5,fontWeight:600},children:bn.name})]}),bn.orgemail&&(0,Se.jsxs)(a.A,{direction:"row",spacing:1,alignItems:"center",children:[(0,Se.jsx)(Z.A,{sx:{fontSize:14,color:"text.disabled",flexShrink:0}}),(0,Se.jsx)(s.A,{sx:{fontSize:12,color:"text.secondary",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:bn.orgemail})]}),bn.orgphonenumber&&(0,Se.jsxs)(a.A,{direction:"row",spacing:1,alignItems:"center",children:[(0,Se.jsx)(G.A,{sx:{fontSize:14,color:"text.disabled",flexShrink:0}}),(0,Se.jsx)(s.A,{sx:{fontSize:12,color:"text.secondary"},children:bn.orgphonenumber})]}),((null===(ae=bn.address)||void 0===ae?void 0:ae.city)||(null===(se=bn.address)||void 0===se||null===(de=se.state)||void 0===de?void 0:de.name)||(null===(ce=bn.address)||void 0===ce||null===(ue=ce.country)||void 0===ue?void 0:ue.name))&&(0,Se.jsxs)(a.A,{direction:"row",spacing:1,alignItems:"center",children:[(0,Se.jsx)(ee.A,{sx:{fontSize:14,color:"text.disabled",flexShrink:0}}),(0,Se.jsx)(s.A,{sx:{fontSize:12,color:"text.secondary"},children:[null===(xe=bn.address)||void 0===xe?void 0:xe.city,null===(ge=bn.address)||void 0===ge||null===(be=ge.state)||void 0===be?void 0:be.name,null===(Ae=bn.address)||void 0===Ae||null===(je=Ae.country)||void 0===je?void 0:je.name].filter(
1Boolean).join(", ")})]})]})]})]})}),(0,Se.jsx)(j.Ay,{item:!0,xs:12,md:8.5,children:(0,Se.jsxs)(L.A,{elevation:0,sx:{borderRadius:3,border:"1px solid",borderColor:"divider",overflow:"hidden",boxShadow:"dark"===_e.palette.mode?"0 1px 3px rgba(0,0,0,0.4)":"0 1px 3px rgba(15,23,42,0.06)"},children:[(0,Se.jsx)(l.A,{sx:{p:{xs:2,md:2.5},pb:{xs:1.5,md:2}},children:(0,Se.jsx)(Ee,{stages:nn,currentStageId:Lt.stageid})}),(0,Se.jsx)(T.A,{value:ft,onChange:(e,t)=>gt(t),variant:"scrollable",scrollButtons:"auto",sx:{borderTop:"1px solid",borderColor:"divider",borderBottom:"1px solid",px:1,minHeight:46,bgcolor:"dark"===_e.palette.mode?"rgba(255,255,255,0.015)":"rgba(99,102,241,0.018)","& .MuiTabs-indicator":{height:3,borderRadius:"3px 3px 0 0"},"& .MuiTab-root":{textTransform:"none",fontWeight:600,fontSize:13,minHeight:46,py:.5,gap:.5,color:"text.secondary",transition:"color .15s, background-color .15s","&:hover":{color:"primary.main",bgcolor:(0,q.X4)("#6366F1",.04)},"&.Mui-selected":{color:"primary.main",fontWeight:700}}},children:Qe.map((e,t)=>{const n=e.icon;return(0,Se.jsx)(F.A,{iconPosition:"start",icon:(0,Se.jsx)(n,{sx:{fontSize:16}}),label:e.label,disabled:t>0&&Ge},e.key)})}),(0,Se.jsx)(l.A,{sx:{p:{xs:2,md:2.5}},children:0===ft?ot&&0===en.length?(0,Se.jsx)(l.A,{display:"flex",justifyContent:"center",py:6,children:(0,Se.jsx)(d.A,{size:28})}):0===((null===it||void 0===it?void 0:it.length)||0)?(0,Se.jsxs)(l.A,{textAlign:"center",py:4,children:[(0,Se.jsx)(s.A,{variant:"body1",color:"text.secondary",mb:2,children:"You don't have a pipeline yet. Create one before adding deals."}),(0,Se.jsx)(m.A,{variant:"contained",onClick:()=>Re("/pipeline-manage"),sx:qe,children:"Create a pipeline"})]}):(0,Se.jsxs)(l.A,{children:[!Ge&&pt&&(0,Se.jsxs)(l.A,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:1,py:1,mb:2,borderRadius:2,bgcolor:(0,q.X4)("#6366F1",.06)},children:[(0,Se.jsx)(d.A,{size:14}),(0,Se.jsx)(s.A,{variant:"caption",color:"text.secondary",children:"Loading deal details\u2026"})]}),(0,Se.jsx)(j.Ay,{container:!0,spacing:2,children:en.map(un)}),!Ge&&Ze&&(0,Se.jsxs)(Se.Fragment,{children:[(0,Se.jsx)(p.A,{sx:{my:3}}),(0,Se.jsx)(Pe,{dealId:Ze,contactId:mn})]})]}):1===ft?Ge?(0,Se.jsx)(Je,{label:"Activities"}):(0,Se.jsx)(Xe,{activity:null===xt||void 0===xt?void 0:xt.dealactives,ownerEmail:An}):2===ft?mn?(0,Se.jsx)(i.Suspense,{fallback:(0,Se.jsx)(l.A,{sx:{textAlign:"center",py:6},children:(0,Se.jsx)(d.A,{})}),children:(0,Se.jsx)($e,{contactId:mn})}):(0,Se.jsx)(Je,{label:"Notes"}):3===ft?mn?(0,Se.jsx)(i.Suspense,{fallback:(0,Se.jsx)(l.A,{sx:{textAlign:"center",py:6},children:(0,Se.jsx)(d.A,{})}),children:(0,Se.jsx)(Ce,{contactId:mn})}):(0,Se.jsx)(Je,{label:"Tasks"}):4===ft?mn?(0,Se.jsx)(i.Suspense,{fallback:(0,Se.jsx)(l.A,{sx:{textAlign:"center",py:6},children:(0,Se.jsx)(d.A,{})}),children:(0,Se.jsx)(De,{contactId:mn,contactEmail:fn,contactName:vn,contactPhotoUrl:gn,onOpenContact:e=>Mt(e),autoOpenComposeKey:Ot})}):(0,Se.jsx)(Je,{label:"Emails"}):5===ft?mn?(0,Se.jsx)(i.Suspense,{fallback:(0,Se.jsx)(l.A,{sx:{textAlign:"center",py:6},children:(0,Se.jsx)(d.A,{})}),children:(0,Se.jsx)(ke,{contactId:mn})}):(0,Se.jsx)(Je,{label:"Documents"}):null})]})})]}),(0,Se.jsx)(Ue,{open:bt,onCancel:()=>At(!1),onConfirm:()=>{At(!1),Re("/contacts?tab=deals")}}),(0,Se.jsxs)(v.A,{open:jt,onClose:()=>yt(!1),PaperProps:{sx:{borderRadius:3}},children:[(0,Se.jsx)(f.A,{children:"Delete this deal?"}),(0,Se.jsx)(g.A,{children:(0,Se.jsx)(s.A,{variant:"body2",color:"text.secondary",children:"This will also remove its comments and history. Can't be undone."})}),(0,Se.jsxs)(b.A,{sx:{p:2},children:[(0,Se.jsx)(m.A,{onClick:()=>yt(!1),sx:qe,children:"Cancel"}),(0,Se.jsx)(m.A,{color:"error",variant:"contained",disabled:Dt,onClick:async()=>{if(Ze){kt(!0);try{await Ie((0,me.wj)(Ze)).unwrap(),null===fe.D||void 0===fe.D||(0,fe.D)("Deal deleted","success"),Re("/contacts?tab=deals")}catch(e){null===fe.D||void 0===fe.D||(0,fe.D)("string"===typeof e?e:"Could not delete","error")}finally{kt(!1),yt(!1)}}},sx:qe,children:"Delete"})]})]}),(0,Se.jsxs)(v.A,{open:St,onClose:Dt?void 0:()=>wt(!1),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:3}},children:[(0,Se.jsxs)(f.A,{sx:{fontSize:16,fontWeight:700,display:"flex",alignItems:"center",gap:1},children:[(0,Se.jsx)(J.A,{sx:{fontSize:20,color:"#EF4444"}})," Mark as lost"]}),(0,Se.jsxs)(g.A,{children:[(0,Se.jsx)(s.A,{variant:"body2",color:"text.secondary",sx:{mb:2},children:"A reason helps the team learn from it."}),(0,Se.jsx)(h.A,{autoFocus:!0,fullWidth:!0,multiline:!0,minRows:3,size:"small",label:"Reason (optional)",value:zt,onCh
1ange:e=>Ct(e.target.value),placeholder:"e.g. Lost to competitor, budget constraint, timing\u2026"})]}),(0,Se.jsxs)(b.A,{sx:{p:2},children:[(0,Se.jsx)(m.A,{onClick:()=>wt(!1),disabled:Dt,sx:qe,children:"Cancel"}),(0,Se.jsx)(m.A,{color:"error",variant:"contained",disabled:Dt,onClick:()=>{wt(!1),sn(me.cd.Lost,zt)},sx:qe,children:Dt?"Saving\u2026":"Mark lost"})]})]}),(0,Se.jsxs)(v.A,{open:Boolean($t),onClose:()=>Mt(null),maxWidth:"xl",fullWidth:!0,PaperProps:{sx:{bgcolor:"background.default"}},children:[(0,Se.jsx)(N.A,{position:"sticky",color:"default",elevation:0,sx:{borderBottom:1,borderColor:"divider",bgcolor:"background.paper"},children:(0,Se.jsxs)(B.A,{sx:{minHeight:56,gap:1},children:[(0,Se.jsx)(x.A,{edge:"start",onClick:()=>Mt(null),children:(0,Se.jsx)(P.A,{})}),(0,Se.jsx)(s.A,{sx:{fontSize:15,fontWeight:700,flex:1},children:vn||"Contact"})]})}),(0,Se.jsx)(l.A,{sx:{overflowY:"auto",flex:1},children:(0,Se.jsx)(i.Suspense,{fallback:(0,Se.jsx)(l.A,{sx:{textAlign:"center",py:8},children:(0,Se.jsx)(d.A,{})}),children:$t&&(0,Se.jsx)(we,{embedded:!0,contactIds:$t,onClose:()=>Mt(null)})})})]}),(0,Se.jsxs)(v.A,{open:Boolean(Wt),onClose:Ht,fullWidth:!0,maxWidth:"xl",PaperProps:{sx:{bgcolor:"background.default"}},children:[(0,Se.jsx)(N.A,{position:"sticky",color:"default",elevation:0,sx:{borderBottom:1,borderColor:"divider",bgcolor:"background.paper"},children:(0,Se.jsxs)(B.A,{sx:{minHeight:56,gap:1},children:[(0,Se.jsx)(x.A,{edge:"start",onClick:Ht,children:(0,Se.jsx)(P.A,{})}),(0,Se.jsx)(s.A,{sx:{fontSize:15,fontWeight:700,flex:1},children:(null===Wt||void 0===Wt?void 0:Wt.name)||"Organization"}),(0,Se.jsx)(u.A,{title:"Open in full page",children:(0,Se.jsx)(x.A,{onClick:()=>{const e=null===Wt||void 0===Wt?void 0:Wt.id;Ht(),e&&Re(`/organizations-edit?oid=${e}`)},children:(0,Se.jsx)(E.A,{fontSize:"small"})})})]})}),(0,Se.jsx)(l.A,{sx:{overflowY:"auto",flex:1},children:(0,Se.jsx)(i.Suspense,{fallback:(0,Se.jsx)(l.A,{sx:{textAlign:"center",py:8},children:(0,Se.jsx)(d.A,{})}),children:(null===Wt||void 0===Wt?void 0:Wt.id)&&(0,Se.jsx)(ze,{embedded:!0,organizationid:Wt.id,onClose:Ht})})})]})]})}const Qe=[{key:"details",label:"Details",icon:ne.A},{key:"activities",label:"Activities",icon:ie.A},{key:"notes",label:"Notes",icon:re.A},{key:"tasks",label:"Tasks",icon:oe.A},{key:"emails",label:"Emails",icon:Z.A},{key:"docs",label:"Docs",icon:le.A}]},83975(e,t,n){var i=n(24994);t.A=void 0;var r=i(n(79526)),o=n(44414);t.A=(0,r.default)((0,o.jsx)("path",{d:"m20.54 5.23-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27M6.24 5h11.52l.81.97H5.44zM5 19V8h14v11zm8.45-9h-2.9v3H8l4 4 4-4h-2.55z"}),"ArchiveOutlined")},99600(e,t,n){var i=n(24994);t.A=void 0;var r=i(n(79526)),o=n(44414);t.A=(0,r.default)((0,o.jsx)("path",{d:"M19 11H7.83l4.88-4.88c.39-.39.39-1.03 0-1.42a.9959.9959 0 0 0-1.41 0l-6.59 6.59c-.39.39-.39 1.02 0 1.41l6.59 6.59c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L7.83 13H19c.55 0 1-.45 1-1s-.45-1-1-1"}),"ArrowBackRounded")},70225(e,t,n){var i=n(24994);t.A=void 0;var r=i(n(79526)),o=n(44414);t.A=(0,r.default)((0,o.jsx)("path",{d:"m18 9-1.41-1.42L10 14.17l-2.59-2.58L6 13l4 4zm1-6h-4.18C14.4 1.84 13.3 1 12 1c-1.3 0-2.4.84-2.82 2H5c-.14 0-.27.01-.4.04-.39.08-.74.28-1.01.55-.18.18-.33.4-.43.64-.1.23-.16.49-.16.77v14c0 .27.06.54.16.78s.25.45.43.64c.27.27.62.47 1.01.55.13.02.26.03.4.03h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-7-.25c.41 0 .75.34.75.75s-.34.75-.75.75-.75-.34-.75-.75.34-.75.75-.75M19 19H5V5h14z"}),"AssignmentTurnedInOutlined")},66559(e,t,n){var i=n(24994);t.A=void 0;var r=i(n(79526)),o=n(44414);t.A=(0,r.default)((0,o.jsx)("path",{d:"M11.8 10.9c-2.27-.59-3-1.2-3-2.15 0-1.09 1.01-1.85 2.7-1.85 1.42 0 2.13.54 2.39 1.4.12.4.45.7.87.7h.3c.66 0 1.13-.65.9-1.27-.42-1.18-1.4-2.16-2.96-2.54V4.5c0-.83-.67-1.5-1.5-1.5S10 3.67 10 4.5v.66c-1.94.42-3.5 1.68-3.5 3.61 0 2.31 1.91 3.46 4.7 4.13 2.5.6 3 1.48 3 2.41 0 .69-.49 1.79-2.7 1.79-1.65 0-2.5-.59-2.83-1.43-.15-.39-.49-.67-.9-.67h-.28c-.67 0-1.14.68-.89 1.3.57 1.39 1.9 2.21 3.4 2.53v.67c0 .83.67 1.5 1.5 1.5s1.5-.67 1.5-1.5v-.65c1.95-.37 3.5-1.5 3.5-3.55 0-2.84-2.43-3.81-4.7-4.4"}),"AttachMoneyRounded")},20803(e,t,n){var i=n(24994);t.A=void 0;var r=i(n(79526)),o=n(44414);t.A=(0,r.default)((0,o.jsx)("path",{d:"M12 7V3H2v18h20V7zM6 19H4v-2h2zm0-4H4v-2h2zm0-4H4V9h2zm0-4H4V5h2zm4 12H8v-2h2zm0-4H8v-2h2zm0-4H8V9h2zm0-4H8V5h2zm10 12h-8v-2h2v-2h-2v-2h2v-2h-2V9h8zm-2-8h-2v2h2zm0 4h-2v2h2z"}),"BusinessOutlined")},82864(e,t,n){var i=n(24994);t.A=void 0;var r=i(n(79526)),o=n(44414);t.A=(0,r.default)((0,o.jsx)("path",{d:"M20 4v12H5.17L4 17.17V4zm0-2H4c-1.1 0-2 .9-2 2v15.59c0 .89 1.08 1.34 1.71.71L6 18h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2"}),"ChatBubbleOutlineRounded")},3263(e,t,n){var i=n(24994);t.A=void 0;var r=i(n(79526)),o=n(44414);t.A=(0,r.default)((0,o.jsx)("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V9c0-1.1-.9-2-2-2H8c-1.1 0-2 .9-2 2zM9 9h6c.55 0 1 .45 1 1v8c0 .55-.45 1-1 1H9c-.55 0-1-.45-1-1v-8c0-.55.45-1 1-1m6.5-5-.71-.71c-.18-.18-.44-.29-.7-.29H9.91c-.26 0-.52.11-.7.29L8.5 4H6c-.55 0-1 .45-1 1s.45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1z"}),"DeleteOutlineRounded")},10158(e,t,n){var i=n(24994);t.A=void 0;var r=i(n(79526)),o=n(44414);t.A=(0,r.default)((0,o.jsx)("path",{d:"M16 9v10H8V9zm-1.5-6h-5l-1 1H5v2h14V4h-3.5zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2z"}),"DeleteOutlined")},36089(e,t,n){var i=n(24994);t.A=void 0;var r=i(n(79526)),o=n(44414);t.A=(0,r.default)((0,o.jsx)("path",{d:"m14.06 9.02.92.92L5.92 19H5v-.92zM17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29m-3.6 3.19L3 17.25V21h3.75L17.81 9.94z"}),"EditOutlined")},86825(e,t,n){var i=n(24994);t.A=void 0;var r=i(n(79526)),o=n(44414);t.A=(0,r.default)((0,o.jsx)("path",{d:"M19 3h-1V1h-2v2H8V1H6v2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m0 16H5V9h14zM5 7V5h14v2zm2 4h10v2H7zm0 4h7v2H7z"}),"EventNoteOutlined")},87785(e,t,n){var i=n(24994);t.A=void 0;var r=i(n(79526)),o=n(44414);t.A=(0,r.default)((0,o.jsx)("path",{d:"m9.17 6 2 2H20v10H4V6zM10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8z"}),"FolderOutlined")},68742(e,t,n){var i=n(24994);t.A=void 0;var r=i(n(79526)),o=n(44414);t.A=(0,r.default)((0,o.jsx)("path",{d:"M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3z"}),"LaunchOutlined")},63435(e,t,n){var i=n(24994);t.A=void 0;var r=i(n(79526)),o=n(44414);t.A=(0,r.default)([(0,o.jsx)("path",{d:"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7M7 9c0-2.76 2.24-5 5-5s5 2.24 5 5c0 2.88-2.88 7.19-5 9.88C9.92 16.21 7 11.85 7 9"},"0"),(0,o.jsx)("circle",{cx:"12",cy:"9",r:"2.5"},"1")],"LocationOnOutlined")},53377(e,t,n){var i=n(24994);t.A=void 0;var r=i(n(79526)),o=n(44414);t.A=(0,r.default)((0,o.jsx)("path",{d:"M6.54 5c.06.89.21 1.76.45 2.59l-1.2 1.2c-.41-1.2-.67-2.47-.76-3.79zm9.86 12.02c.85.24 1.72.39 2.6.45v1.49c-1.32-.09-2.59-.35-3.8-.75zM7.5 3H4c-.55 0-1 .45-1 1 0 9.39 7.61 17 17 17 .55 0 1-.45 1-1v-3.49c0-.55-.45-1-1-1-1.24 0-2.45-.2-3.57-.57-.1-.04-.21-.05-.31-.05-.26 0-.51.1-.71.29l-2.2 2.2c-2.83-1.45-5.15-3.76-6.59-6.59l2.2-2.2c.28-.28.36-.67.25-1.02C8.7 6.45 8.5 5.25 8.5 4c0-.55-.45-1-1-1"}),"PhoneOutlined")},35436(e,t,n){var i=n(24994);t.A=void 0;var r=i(n(79526)),o=n(44414);t.A=(0,r.default)((0,o.jsx)("path",{d:"M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7zm2 16H5V5h11.17L19 7.83zm-7-7c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3M6 6h9v4H6z"}),"SaveOutlined")},27e3(e,t,n){var i=n(24994);t.A=void 0;var r=i(n(79526)),o=n(44414);t.A=(0,r.default)((0,o.jsx)("path",{d:"m3.4 20.4 17.45-7.48c.81-.35.81-1.49 0-1.84L3.4 3.6c-.66-.29-1.39.2-1.39.91L2 9.12c0 .5.37.93.87.99L17 12 2.87 13.88c-.5.07-.87.5-.87 1l.01 4.61c0 .71.73 1.2 1.39.91"}),"SendRounded")},53518(e,t,n){var i=n(24994);t.A=void 0;var r=i(n(79526)),o=n(44414);t.A=(0,r.default)((0,o.jsx)("path",{d:"M19 5v9h-5v5H5V5zm0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h10l6-6V5c0-1.1-.9-2-2-2m-7 11H7v-2h5zm5-4H7V8h10z"}),"StickyNote2Outlined")},36658(e,t,n){var i=n(24994);t.A=void 0;var r=i(n(79526)),o=n(44414);t.A=(0,r.default)((0,o.jsx)("path",{d:"M15 3H6c-.83 0-1.54.5-1.84 1.22l-3.02 7.05c-.09.23-.14.47-.14.73v2c0 1.1.9 2 2 2h6.31l
1-.95 4.57-.03.32c0 .41.17.79.44 1.06L9.83 23l6.58-6.59c.37-.36.59-.86.59-1.41V5c0-1.1-.9-2-2-2m0 12-4.34 4.34L11.77 14H3v-2l3-7h9zm4-12h4v12h-4z"}),"ThumbDownAltOutlined")},76265(e,t,n){var i=n(24994);t.A=void 0;var r=i(n(79526)),o=n(44414);t.A=(0,r.default)((0,o.jsx)("path",{d:"M21 8h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.59 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2c0-1.1-.9-2-2-2m0 4-3 7H9V9l4.34-4.34L12.23 10H21zM1 9h4v12H1z"}),"ThumbUpAltOutlined")},30798(e,t,n){var i=n(24994);t.A=void 0;var r=i(n(79526)),o=n(44414);t.A=(0,r.default)((0,o.jsx)("path",{d:"m20.54 5.23-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27M6.24 5h11.52l.83 1H5.42zM5 19V8h14v11zm3-5h2.55v3h2.9v-3H16l-4-4z"}),"UnarchiveOutlined")},88780(e,t,n){n.d(t,{A:()=>o});n(9950);var i=n(65471),r=n(44414);const o=(0,i.A)((0,r.jsx)("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"}),"Close")},46589(e,t,n){var i;n.d(t,{A:()=>u});var r=n(9950),o=n(61399),l=n(51522),a=n(90357);function s(e,t,n,i,l){const[a,s]=r.useState(()=>l&&n?n(e).matches:i?i(e).matches:t);return(0,o.A)(()=>{let t=!0;if(!n)return;const i=n(e),r=()=>{t&&s(i.matches)};return r(),i.addListener(r),()=>{t=!1,i.removeListener(r)}},[e,n]),a}const d=(i||(i=n.t(r,2))).useSyncExternalStore;function c(e,t,n,i,o){const l=r.useCallback(()=>t,[t]),a=r.useMemo(()=>{if(o&&n)return()=>n(e).matches;if(null!==i){const{matches:t}=i(e);return()=>t}return l},[l,e,i,o,n]),[s,c]=r.useMemo(()=>{if(null===n)return[l,()=>()=>{}];const t=n(e);return[()=>t.matches,e=>(t.addListener(e),()=>{t.removeListener(e)})]},[l,n,e]);return d(c,s,a)}function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=(0,a.A)(),i="undefined"!==typeof window&&"undefined"!==typeof window.matchMedia,{defaultMatches:r=!1,matchMedia:o=(i?window.matchMedia:null),ssrMatchMedia:u=null,noSsr:x=!1}=(0,l.A)({name:"MuiUseMediaQuery",props:t,theme:n});let p="function"===typeof e?e(n):e;p=p.replace(/^@media( ?)/m,"");return(void 0!==d?c:s)(p,r,o,u,x)}},29481(e,t,n){n.d(t,{A:()=>r});var i=n(9950);const r=e=>{const t=i.useRef({});return i.useEffect(()=>{t.current=e}),t.current}}}]);
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.