(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4968],{16891:(e,t,a)=>{"use strict";a.d(t,{F:()=>s});var n=a(95155),l=a(12115),r=a(64792),o=a(53999);let s=l.forwardRef((e,t)=>{let{className:a,children:l,...s}=e;return(0,n.jsxs)(r.bL,{ref:t,className:(0,o.cn)("relative overflow-hidden",a),...s,children:[(0,n.jsx)(r.LM,{className:"h-full w-full rounded-[inherit]",children:l}),(0,n.jsx)(i,{}),(0,n.jsx)(r.OK,{})]})});s.displayName=r.bL.displayName;let i=l.forwardRef((e,t)=>{let{className:a,orientation:l="vertical",...s}=e;return(0,n.jsx)(r.VM,{ref:t,orientation:l,className:(0,o.cn)("flex touch-none select-none transition-colors","vertical"===l&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===l&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",a),...s,children:(0,n.jsx)(r.lr,{className:"relative flex-1 rounded-full bg-border"})})});i.displayName=r.VM.displayName},37777:(e,t,a)=>{"use strict";a.d(t,{Bc:()=>s,ZI:()=>d,k$:()=>c,m_:()=>i});var n=a(95155),l=a(12115),r=a(78082),o=a(53999);let s=r.Kq,i=r.bL,c=r.l9,d=l.forwardRef((e,t)=>{let{className:a,sideOffset:l=4,...s}=e;return(0,n.jsx)(r.UC,{ref:t,sideOffset:l,className:(0,o.cn)("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",a),...s})});d.displayName=r.UC.displayName},38128:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>e_});var n=a(95155),l=a(12115),r=a(35695),o=a(12108),s=a(97108),i=a(12486),c=a(74126),d=a(39022),m=a(13717),u=a(40528),p=a(21380),g=a(74783),h=a(51154),f=a(85339),x=a(5196),b=a(99840),y=a(49026),w=a(16559),E=a(97168),j=a(89852),v=a(82714),N=a(14503),S=a(81497),A=a(28883),T=a(84616),C=a(53904),_=a(47863),L=a(66474),k=a(67133),F=a(34964),D=a(95139);function R(e){let{accounts:t,selectedAccount:a,selectedFolders:r,currentFolder:o,loading:p,unreadCount:g,showAddAccountForm:f,showFolders:x=!0,onFolderChange:b,onRefresh:y,onComposeNew:w,onAccountSelect:N,onShowAddAccountForm:R,onAddAccount:I,onEditAccount:O,onDeleteAccount:M,onSelectEmail:P,onShowFoldersToggle:U}=e,[G,B]=(0,l.useState)(!1),[H,q]=(0,l.useState)({email:"",password:"",displayName:"",host:"",port:"993",useSSL:!0,smtpHost:"",smtpPort:"587",smtpUseSSL:!1}),[z,W]=(0,l.useState)("imap"),$=async e=>{e.preventDefault(),B(!0);try{let e=new FormData;e.append("email",H.email),e.append("password",H.password),e.append("display_name",H.displayName),e.append("host",H.host),e.append("port",H.port),e.append("secure",H.useSSL?"on":"off"),e.append("smtp_host",H.smtpHost),e.append("smtp_port",H.smtpPort),e.append("smtp_secure",H.smtpUseSSL?"on":"off"),await I(e),q({email:"",password:"",displayName:"",host:"",port:"993",useSSL:!0,smtpHost:"",smtpPort:"587",smtpUseSSL:!1}),R(!1)}catch(e){console.error("Failed to add account:",e)}finally{B(!1)}},J=e=>{let{name:t,value:a,type:n,checked:l}=e.target;q(e=>({...e,[t]:"checkbox"===n?l:a}))},K=e=>{let t=e.toLowerCase();if(t.includes("inbox"))return(0,n.jsx)(s.A,{className:"h-4 w-4 text-gray-500"});if(t.includes("sent"))return(0,n.jsx)(i.A,{className:"h-4 w-4 text-gray-500"});if(t.includes("trash"))return(0,n.jsx)(c.A,{className:"h-4 w-4 text-gray-500"});if(t.includes("archive"))return(0,n.jsx)(d.A,{className:"h-4 w-4 text-gray-500"});if(t.includes("draft"))return(0,n.jsx)(m.A,{className:"h-4 w-4 text-gray-500"});else if(t.includes("spam")||t.includes("junk"))return(0,n.jsx)(u.A,{className:"h-4 w-4 text-gray-500"});else return(0,n.jsx)(S.A,{className:"h-4 w-4 text-gray-500"})},Y=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),V=(e,t)=>{var a;let l=e,o=e,s=t;if(e.includes(":")){let t=e.split(":");s=t[0],o=t[1]}else l="".concat(t,":").concat(e);if(s!==t)return null;let i=r[t]===l||r[t]===o||(null==(a=r[t])?void 0:a.split(":")[1])===o,c=0,d="inbox"===o.toLowerCase();if(d&&g&&g[t])if("number"==typeof g[t][o])c=g[t][o];else if("number"==typeof g[t][l])c=g[t][l];else{let e=g[t];for(let t in e)if(t.toLowerCase()===o.toLowerCase()||t.toLowerCase()===l.toLowerCase()){c=e[t];break}}return(0,n.jsx)(E.$,{variant:"ghost",className:"w-full justify-start text-xs py-1 h-7 ".concat(i?"bg-gray-100":""),onClick:()=>{b(e.includes(":")?e:"".concat(t,":").concat(e),t)},children:(0,n.jsxs)("div",{className:"flex items-center w-full",children:[K(o),(0,n.jsx)("span",{className:"ml-2 truncate text-gray-700",children:Y(o)}),d&&c>0&&(0,n.jsx)("span",{className:"ml-auto bg-blue-500 text-white text-[10px] px-1.5 rounded-full",children:c})]})},l)},X=async()=>{try{let e=await fetch("/api/courrier/microsoft"),t=await e.json();e.ok&&t.authUrl?window.location.href=t.authUrl:console.error("Failed to initiate Microsoft authentication:",t.error)}catch(e){console.error("Error connecting Microsoft account:",e)}};return(0,n.jsxs)("div",{className:"w-60 bg-white/95 backdrop-blur-sm border-r border-gray-100 flex flex-col md:flex",style:{display:"flex !important"},children:[(0,n.jsx)("div",{className:"p-3 border-b border-gray-100",children:(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(A.A,{className:"h-6 w-6 text-gray-600"}),(0,n.jsx)("span",{className:"text-xl font-semibold text-gray-900",children:"COURRIER"})]})}),(0,n.jsxs)("div",{className:"p-2 border-b border-gray-100 flex items-center gap-2",children:[(0,n.jsx)(E.$,{className:"flex-1 bg-blue-600 text-white rounded-lg hover:bg-blue-700 flex items-center justify-center transition-all py-1.5 text-sm",onClick:w,children:(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(T.A,{className:"h-3.5 w-3.5"}),(0,n.jsx)("span",{children:"Compose"})]})}),(0,n.jsx)(E.$,{variant:"ghost",size:"icon",className:"h-9 w-9 text-gray-400 hover:text-gray-600",onClick:y,children:(0,n.jsx)(C.A,{className:"h-4 w-4 ".concat(p?"animate-spin":"")})})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,n.jsxs)("div",{className:"p-3 border-b border-gray-100",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,n.jsx)("span",{className:"text-sm font-medium text-gray-500",children:"Accounts"}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)(E.$,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-gray-400 hover:text-gray-600",onClick:()=>null==U?void 0:U(!x),children:x?(0,n.jsx)(_.A,{className:"h-4 w-4"}):(0,n.jsx)(L.A,{className:"h-4 w-4"})}),(0,n.jsx)(E.$,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-gray-400 hover:text-gray-600",onClick:()=>R(!f),children:(0,n.jsx)(T.A,{className:"h-4 w-4"})})]})]}),(0,n.jsxs)("div",{className:"mt-1",children:[f&&(0,n.jsxs)("div",{className:"mb-2 p-2 border border-gray-200 rounded-md bg-white",children:[(0,n.jsx)("h4",{className:"text-xs font-medium mb-0.5 text-gray-700",children:"Add IMAP Account"}),(0,n.jsx)("form",{onSubmit:$,children:(0,n.jsxs)("div",{children:[(0,n.jsxs)(F.tU,{defaultValue:"imap",className:"w-full",children:[(0,n.jsxs)(F.j7,{className:"grid w-full grid-cols-2 h-6 mb-0.5 bg-gray-100",children:[(0,n.jsx)(F.Xi,{value:"imap",className:"text-xs h-5 data-[state=active]:bg-blue-500 data-[state=active]:text-white",children:"IMAP"}),(0,n.jsx)(F.Xi,{value:"smtp",className:"text-xs h-5 data-[state=active]:bg-blue-500 data-[state=active]:text-white",children:"SMTP"})]}),(0,n.jsxs)(F.av,{value:"imap",className:"mt-0.5 space-y-0.5",children:[(0,n.jsx)("div",{children:(0,n.jsx)(j.p,{id:"email",name:"email",placeholder:"email@example.com",className:"h-7 text-xs bg-white border-gray-300 mb-0.5 text-gray-900",required:!0,value:H.email,onChange:J})}),(0,n.jsx)("div",{children:(0,n.jsx)(j.p,{id:"password",name:"password",type:"password",placeholder:"•••••••••",className:"h-7 text-xs bg-white border-gray-300 mb-0.5 text-gray-900",required:!0,value:H.password,onChange:J})}),(0,n.jsx)("div",{children:(0,n.jsx)(j.p,{id:"display_name",name:"displayName",placeholder:"John Doe",className:"h-7 text-xs bg-white border-gray-300 mb-0.5 text-gray-900",value:H.displayName,onChange:J})}),(0,n.jsx)("div",{children:(0,n.jsx)(j.p,{id:"host",name:"host",placeholder:"imap.example.com",className:"h-7 text-xs bg-white border-gray-300 mb-0.5 text-gray-900",required:!0,value:H.host,onChange:J})}),(0,n.jsxs)("div",{className:"flex gap-1",children:[(0,n.jsx)("div",{className:"flex-1",children:(0,n.jsx)(j.p,{id:"port",name:"port",placeholder:"993",className:"h-7 text-xs bg-white border-gray-300 text-gray-900",value:H.port,onChange:J})}),(0,n.jsx)("div",{className:"flex items-center pl-1",children:(0,n.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,n.jsx)(D.S,{id:"useSSL",name:"useSSL",checked:H.useSSL,onCheckedChange:e=>{q(t=>({...t,useSSL:!0===e}))}}),(0,n.jsx)(v.J,{htmlFor:"useSSL",className:"text-xs",children:"SSL"})]})})]})]}),(0,n.jsxs)(F.av,{value:"smtp",className:"mt-0.5 space-y-0.5",children:[(0,n.jsx)("div",{children:(0,n.jsx)(j.p,{id:"smtp_host",name:"smtpHost",placeholder:"smtp.example.com",className:"h-7 text-xs bg-white border-gray-300 mb-0.5 text-gray-900",value:H.smtpHost,onChange:J})}),(0,n.jsxs)("div",{className:"flex gap-1",children:[(0,n.jsx)("div",{className:"flex-1",children:(0,n.jsx)(j.p,{id:"smtp_port",name:"smtpPort",placeholder:"587",className:"h-7 text-xs bg-white border-gray-300 text-gray-900",value:H.smtpPort,onChange:J})}),(0,n.jsx)("div",{className:"flex items-center pl-1",children:(0,n.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,n.jsx)(D.S,{id:"smtp_secure",name:"smtpUseSSL",checked:H.smtpUseSSL,onCheckedChange:e=>{q(t=>({...t,smtpUseSSL:!0===e}))}}),(0,n.jsx)(v.J,{htmlFor:"smtp_secure",className:"text-xs",children:"SSL"})]})})]}),(0,n.jsx)("div",{className:"text-xs text-gray-500 italic",children:"Note: SMTP settings needed for sending emails"})]})]}),(0,n.jsxs)("div",{className:"flex gap-1 mt-1",children:[(0,n.jsxs)(E.$,{type:"submit",className:"flex-1 h-6 text-xs bg-blue-500 hover:bg-blue-600 text-white rounded-md px-2 py-0",disabled:G,children:[G?(0,n.jsx)(h.A,{className:"h-3 w-3 animate-spin mr-1"}):null,"Test & Add"]}),(0,n.jsx)(E.$,{type:"button",className:"h-6 text-xs bg-gray-200 text-gray-800 hover:bg-gray-300 rounded-md px-2 py-0",onClick:()=>R(!1),children:"Cancel"})]})]})}),(0,n.jsx)("div",{className:"mt-2 pt-2 border-t border-gray-100",children:(0,n.jsxs)("button",{type:"button",onClick:X,className:"w-full flex items-center justify-center gap-2 h-7 text-xs bg-[#0078D4] hover:bg-[#106EBE] text-white rounded-md px-2 py-0",children:[(0,n.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 23 23",children:[(0,n.jsx)("path",{fill:"#f3f3f3",d:"M0 0h23v23H0z"}),(0,n.jsx)("path",{fill:"#f35325",d:"M1 1h10v10H1z"}),(0,n.jsx)("path",{fill:"#81bc06",d:"M12 1h10v10H12z"}),(0,n.jsx)("path",{fill:"#05a6f0",d:"M1 12h10v10H1z"}),(0,n.jsx)("path",{fill:"#ffba08",d:"M12 12h10v10H12z"})]}),"Connect Microsoft Account"]})})]}),t.map(e=>{var t;return(0,n.jsxs)("div",{className:"mb-1",children:[(0,n.jsxs)("div",{className:"flex items-center w-full px-1 py-1 rounded-md cursor-pointer ".concat((null==a?void 0:a.id)===e.id?"bg-gray-100":""),onClick:()=>N(e),tabIndex:0,role:"button",onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&N(e)},children:[(0,n.jsx)("div",{className:"w-3 h-3 rounded-full ".concat((null==(t=e.color)?void 0:t.startsWith("#"))?"bg-blue-500":e.color||"bg-blue-500"," mr-2")}),(0,n.jsx)("span",{className:"truncate text-gray-700 flex-1",children:e.name}),"loading-account"!==e.id&&(0,n.jsxs)(k.rI,{children:[(0,n.jsx)(k.ty,{asChild:!0,children:(0,n.jsx)("button",{type:"button",className:"ml-1 text-gray-400 hover:text-gray-600 cursor-pointer flex items-center justify-center h-5 w-5",tabIndex:-1,"aria-label":"Account options",children:(0,n.jsx)("span",{style:{fontSize:"18px",lineHeight:1},children:"⋮"})})}),(0,n.jsxs)(k.SQ,{align:"end",children:[(0,n.jsx)(k._2,{onClick:()=>O(e),children:"Edit"}),(0,n.jsx)(k._2,{onClick:()=>M(e),children:"Delete"})]})]})]}),(null==a?void 0:a.id)===e.id&&x&&e.folders&&e.folders.length>0&&(0,n.jsx)("div",{className:"pl-4",children:e.folders.map(t=>V(t,e.id.toString()))})]},e.id)})]})]})})]})}var I=a(47924),O=a(54416),M=a(38564),P=a(53999);function U(e){var t,a,l,r;let o,{email:s,isSelected:i,isActive:c,onSelect:d,onToggleSelect:m,onToggleStarred:u}=e;return(0,n.jsxs)("div",{className:(0,P.cn)("flex items-center gap-3 px-4 py-2 hover:bg-gray-50/80 cursor-pointer",c?"bg-blue-50/50":"",(null==(t=s.flags)?void 0:t.seen)?"":"bg-blue-50/20"),onClick:e=>{e.target.closest(".checkbox-area")||d()},children:[(0,n.jsx)("div",{className:"flex-shrink-0 pr-2 checkbox-area",onClick:e=>{e.stopPropagation()},children:(0,n.jsx)(D.S,{checked:i,onCheckedChange:e=>{e!==i&&m({stopPropagation:()=>{}})},onClick:e=>{e.stopPropagation()},className:"mt-0.5"})}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,n.jsx)("div",{className:"flex items-center gap-2 min-w-0",children:(0,n.jsx)("span",{className:"text-sm truncate ".concat((null==(a=s.flags)?void 0:a.seen)?"text-gray-600":"font-semibold text-gray-900"),children:(()=>{if(!s.from||0===s.from.length)return"Unknown";let e=s.from[0];return e.name&&e.name.trim()?e.name.trim():e.address||"Unknown"})()})}),(0,n.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[(0,n.jsx)("span",{className:"text-xs text-gray-500 whitespace-nowrap",children:(e=>{let t=new Date(e),a=new Date,n=new Date(a.getFullYear(),a.getMonth(),a.getDate()),l=new Date(n);return(l.setDate(l.getDate()-1),t>=n)?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):t>=l?"Yesterday":t.getFullYear()===a.getFullYear()?t.toLocaleDateString([],{month:"short",day:"numeric"}):t.toLocaleDateString([],{year:"numeric",month:"short",day:"numeric"})})(s.date.toString())}),(0,n.jsx)("button",{className:"h-6 w-6 text-gray-400 hover:text-yellow-400",onClick:e=>{e.stopPropagation(),u(e)},children:(0,n.jsx)(M.A,{className:"h-4 w-4 ".concat((null==(l=s.flags)?void 0:l.flagged)?"fill-yellow-400 text-yellow-400":"")})})]})]}),(0,n.jsx)("h3",{className:"text-sm text-gray-900 truncate",children:s.subject||"(No subject)"}),(0,n.jsx)("div",{className:"text-xs text-gray-500 truncate",children:(r=s.content,o="",(o=(o=(o="string"==typeof r?r:r.text||r.html).replace(/<[^>]+>/g," ")).replace(/\s+/g," ").trim()).length>70?o.substring(0,70)+"...":o)})]})]})}function G(e){let{allSelected:t,someSelected:a,onToggleSelectAll:l,currentFolder:r="Inbox",totalEmails:o=0}=e;return(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 h-14",children:[(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)(D.S,{checked:t,ref:e=>{e&&(e.indeterminate=a&&!t)},onCheckedChange:l,className:"mt-0.5"}),(0,n.jsx)("h2",{className:"text-base font-semibold text-gray-900 capitalize",children:"Messages"})]}),(0,n.jsxs)("span",{className:"text-sm text-gray-600",children:[o," ",1===o?"email":"emails"]})]})}var B=a(78749),H=a(62525),q=a(37777);function z(e){let{selectedCount:t,onBulkAction:a}=e;return(0,n.jsxs)("div",{className:"bg-blue-50 border-b border-blue-100 px-4 py-2 flex items-center justify-between shadow-md transition-all duration-200",children:[(0,n.jsxs)("span",{className:"text-xs font-medium text-blue-700",children:[t," selected"]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)(q.Bc,{children:(0,n.jsxs)(q.m_,{children:[(0,n.jsx)(q.k$,{asChild:!0,children:(0,n.jsx)(E.$,{variant:"ghost",size:"icon",className:"h-7 w-7 text-blue-600 hover:text-blue-900 hover:bg-blue-100",onClick:()=>a("mark-unread"),children:(0,n.jsx)(B.A,{className:"h-3.5 w-3.5"})})}),(0,n.jsx)(q.ZI,{children:(0,n.jsx)("p",{children:"Mark as unread"})})]})}),(0,n.jsx)(q.Bc,{children:(0,n.jsxs)(q.m_,{children:[(0,n.jsx)(q.k$,{asChild:!0,children:(0,n.jsx)(E.$,{variant:"ghost",size:"icon",className:"h-7 w-7 text-blue-600 hover:text-blue-900 hover:bg-blue-100",onClick:()=>a("archive"),children:(0,n.jsx)(d.A,{className:"h-3.5 w-3.5"})})}),(0,n.jsx)(q.ZI,{children:(0,n.jsx)("p",{children:"Archive"})})]})}),(0,n.jsx)(q.Bc,{children:(0,n.jsxs)(q.m_,{children:[(0,n.jsx)(q.k$,{asChild:!0,children:(0,n.jsx)(E.$,{variant:"ghost",size:"icon",className:"h-7 w-7 text-red-600 hover:text-red-700 hover:bg-red-50",onClick:()=>a("delete"),children:(0,n.jsx)(H.A,{className:"h-3.5 w-3.5"})})}),(0,n.jsx)(q.ZI,{children:(0,n.jsx)("p",{children:"Delete"})})]})})]})]})}function W(e){let{emails:t,selectedEmailIds:a,selectedEmail:r,currentFolder:o,isLoading:s,totalEmails:i,hasMoreEmails:c,onSelectEmail:d,onToggleSelect:m,onToggleSelectAll:u,onBulkAction:p,onToggleStarred:g,onLoadMore:h,onSearch:f}=e,[x,b]=(0,l.useState)(0),[y,w]=(0,l.useState)("");if(s&&0===t.length)return(0,n.jsx)("div",{className:"flex justify-center items-center h-full p-8 bg-white/95 backdrop-blur-sm",children:(0,n.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-t-2 border-b-2 border-blue-500"})});if(0===t.length)return(0,n.jsxs)("div",{className:"flex flex-col justify-center items-center h-64 p-8 text-center bg-white/95 backdrop-blur-sm",children:[(0,n.jsx)(A.A,{className:"h-8 w-8 text-gray-400 mb-2"}),(0,n.jsx)("p",{className:"text-gray-500 text-sm",children:y?"No emails match your search":"INBOX"===o?"Your inbox is empty. You're all caught up!":"No emails in this folder"})]});let E=a.length===t.length&&t.length>0,v=a.length>0&&a.length0&&(0,n.jsx)("div",{className:"sticky top-0 z-10",children:(0,n.jsx)(z,{selectedCount:a.length,onBulkAction:p})}),(0,n.jsxs)("div",{className:"border-b border-gray-100",children:[(0,n.jsx)("div",{className:"px-4 py-2",children:(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)(I.A,{className:"absolute left-2 top-2.5 h-4 w-4 text-gray-400"}),(0,n.jsxs)("form",{onSubmit:e=>{e.preventDefault(),null==f||f(y)},children:[(0,n.jsx)(j.p,{type:"search",placeholder:"Search in folder...",className:"pl-8 h-9 bg-gray-50",value:y,onChange:e=>w(e.target.value)}),y&&(0,n.jsx)("button",{type:"button",onClick:()=>{w(""),null==f||f("")},className:"absolute right-2 top-1/2 transform -translate-y-1/2",children:(0,n.jsx)(O.A,{className:"h-4 w-4 text-gray-400"})})]})]})}),(0,n.jsx)(G,{allSelected:E,someSelected:v,onToggleSelectAll:u,currentFolder:o,totalEmails:i})]}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto",onScroll:e=>{let{scrollTop:t,scrollHeight:a,clientHeight:n}=e.target;b(t);let l=a-t-n;console.log("[DEBUG] Scroll metrics - Distance to bottom: ".concat(l,"px, scrollHeight: ").concat(a,", scrollTop: ").concat(t,", clientHeight: ").concat(n));let r=(t+n)/a;console.log("[DEBUG] Scroll percentage: ".concat(Math.round(100*r),"%, hasMoreEmails: ").concat(c,", isLoading: ").concat(s)),(l<500||r>.8)&&c&&!s?(console.log("[DEBUG-TRIGGER] Loading more emails - distance: ".concat(l,"px, percentage: ").concat(Math.round(100*r),"%")),h()):(l<500||r>.8)&&c&&s?console.log("[DEBUG-BLOCKED] Not loading more emails because isLoading is true"):(l<500||r>.8)&&!c&&console.log("[DEBUG-BLOCKED] Not loading more emails because hasMoreEmails is false")},children:(0,n.jsxs)("div",{className:"divide-y divide-gray-100",children:[t.map(e=>(0,n.jsx)(U,{email:e,isSelected:a.includes(e.id),isActive:(null==r?void 0:r.id)===e.id,onSelect:()=>d(e.id,e.accountId||"",e.folder||""),onToggleSelect:t=>{t.stopPropagation(),m(e.id)},onToggleStarred:t=>{t.stopPropagation(),g(e.id)}},e.id)),s&&t.length>0&&(0,n.jsx)("div",{className:"flex items-center justify-center p-4",children:(0,n.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-t-2 border-b-2 border-blue-500"})})]})})]})}var $=a(11518),J=a.n($),K=a(42355),Y=a(54032),V=a(47734),X=a(50005),Z=a(16891),Q=a(69663);function ee(e){var t,a,l,r,o,s,i,c,d,m;let{email:u,onBack:p,onReply:g,onReplyAll:h,onForward:f,onToggleStar:x}=e;return(0,n.jsxs)("div",{className:"jsx-a4b854e4f3e043c7 flex flex-col h-full overflow-hidden",children:[(0,n.jsx)("div",{className:"jsx-a4b854e4f3e043c7 flex-none px-4 py-3 border-b border-gray-100",children:(0,n.jsxs)("div",{className:"jsx-a4b854e4f3e043c7 flex items-center gap-4",children:[(0,n.jsxs)("div",{className:"jsx-a4b854e4f3e043c7 flex items-center gap-2 min-w-0 flex-1",children:[(0,n.jsx)(E.$,{variant:"ghost",size:"icon",onClick:p,className:"md:hidden flex-shrink-0",children:(0,n.jsx)(K.A,{className:"h-5 w-5"})}),(0,n.jsx)("div",{className:"jsx-a4b854e4f3e043c7 min-w-0 max-w-[500px]",children:(0,n.jsx)("h2",{className:"jsx-a4b854e4f3e043c7 text-lg font-semibold text-gray-900 truncate",children:u.subject})})]}),(0,n.jsx)("div",{className:"jsx-a4b854e4f3e043c7 flex items-center gap-1 flex-shrink-0 ml-auto",children:(0,n.jsxs)("div",{className:"jsx-a4b854e4f3e043c7 flex items-center border-l border-gray-200 pl-4",children:[(0,n.jsx)(E.$,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-gray-900 h-9 w-9",onClick:g,children:(0,n.jsx)(Y.A,{className:"h-4 w-4"})}),(0,n.jsx)(E.$,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-gray-900 h-9 w-9",onClick:h,children:(0,n.jsx)(V.A,{className:"h-4 w-4"})}),(0,n.jsx)(E.$,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-gray-900 h-9 w-9",onClick:f,children:(0,n.jsx)(X.A,{className:"h-4 w-4"})}),(0,n.jsx)(E.$,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-gray-900 h-9 w-9",onClick:x,children:(0,n.jsx)(M.A,{className:"h-4 w-4 ".concat(u.starred?"fill-yellow-400 text-yellow-400":"")})})]})})]})}),(0,n.jsx)(Z.F,{className:"flex-1 overflow-auto",children:(0,n.jsxs)("div",{className:"jsx-a4b854e4f3e043c7 p-6",children:[(0,n.jsxs)("div",{className:"jsx-a4b854e4f3e043c7 flex items-center gap-4 mb-6",children:[(0,n.jsx)(Q.eu,{className:"h-10 w-10",children:(0,n.jsx)(Q.q5,{children:((null==(a=u.from)||null==(t=a[0])?void 0:t.name)||"").charAt(0)||((null==(r=u.from)||null==(l=r[0])?void 0:l.address)||"").charAt(0)||"?"})}),(0,n.jsxs)("div",{className:"jsx-a4b854e4f3e043c7 flex-1",children:[(0,n.jsxs)("p",{className:"jsx-a4b854e4f3e043c7 font-medium text-gray-900",children:[(null==(s=u.from)||null==(o=s[0])?void 0:o.name)||""," ",(0,n.jsxs)("span",{className:"jsx-a4b854e4f3e043c7 text-gray-500",children:["<",(null==(c=u.from)||null==(i=c[0])?void 0:i.address)||"",">"]})]}),(0,n.jsxs)("p",{className:"jsx-a4b854e4f3e043c7 text-sm text-gray-500",children:["to ",(null==(m=u.to)||null==(d=m[0])?void 0:d.address)||""]}),u.cc&&u.cc.length>0&&(0,n.jsxs)("p",{className:"jsx-a4b854e4f3e043c7 text-sm text-gray-500",children:["cc ",u.cc.map(e=>e.address).join(", ")]})]}),(0,n.jsx)("div",{className:"jsx-a4b854e4f3e043c7 text-sm text-gray-500 whitespace-nowrap",children:(e=>{let t="string"==typeof e?new Date(e):e,a=new Date;return t.toDateString()===a.toDateString()?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):t.toLocaleDateString([],{month:"short",day:"numeric"})})(u.date)})]}),(0,n.jsx)("div",{className:"jsx-a4b854e4f3e043c7 prose prose-sm max-w-none email-content-wrapper",children:(()=>{try{console.log("EmailDetailView renderEmailContent",{hasContent:!!u.content,contentType:typeof u.content,hasHtml:!!u.html,hasText:!!u.text});let e="";return u.content?"string"==typeof u.content?e=u.content:"object"==typeof u.content&&(e=u.content.html||u.content.text||""):u.html?e=u.html:u.text&&(e=u.text.replace(/&/g,"&").replace(//g,">").replace(/\n/g,"
")),e?(0,n.jsx)("div",{dangerouslySetInnerHTML:{__html:e}}):(0,n.jsx)("div",{className:"text-gray-500",children:"No content available"})}catch(e){return console.error("Error rendering email:",e),(0,n.jsx)("div",{className:"text-gray-500",children:"Failed to render email content"})}})()}),u.hasAttachments&&u.attachments&&u.attachments.length>0&&(0,n.jsxs)("div",{className:"jsx-a4b854e4f3e043c7 mt-6 border-t border-gray-100 pt-4",children:[(0,n.jsx)("h3",{className:"jsx-a4b854e4f3e043c7 text-sm font-medium text-gray-900 mb-2",children:"Attachments"}),(0,n.jsx)("div",{className:"jsx-a4b854e4f3e043c7 grid grid-cols-1 sm:grid-cols-2 gap-2",children:u.attachments.map((e,t)=>(0,n.jsx)("div",{className:"jsx-a4b854e4f3e043c7 flex items-center gap-2 p-2 border border-gray-200 rounded-md",children:(0,n.jsxs)("div",{className:"jsx-a4b854e4f3e043c7 flex-1 min-w-0",children:[(0,n.jsx)("p",{className:"jsx-a4b854e4f3e043c7 text-sm font-medium text-gray-700 truncate",children:e.filename}),(0,n.jsxs)("p",{className:"jsx-a4b854e4f3e043c7 text-xs text-gray-500",children:[(e.size/1024).toFixed(1)," KB"]})]})},t))})]})]})}),(0,n.jsx)(J(),{id:"a4b854e4f3e043c7",children:".email-content-wrapper{width:100%;overflow-wrap:break-word;word-wrap:break-word;word-break:break-word}.email-content-wrapper img{max-width:100%;height:auto}.email-content-wrapper table{max-width:100%;overflow-x:auto;display:block}@media(max-width:640px){.email-content-wrapper{font-size:14px}}"})]})}var et=a(50492),ea=a(50429);a(87548);var en=a(75915),el=a.n(en);function er(e){if(!e)return"";try{return el().sanitize(e,{ADD_ATTR:["style","class","id","align","valign","colspan","rowspan","cellspacing","cellpadding","bgcolor"]}).replace(/