| 1 |
- import{a as e,n as t,r as n}from"./react-dom-stZKkA6x.js";import{a as r,c as i,d as a,r as o,u as s}from"./theme-CVfSdO4m.js";import{At as c,J as l,ct as ee,i as u,l as te,n as d,t as f}from"./jsx-runtime-C5RSiriy.js";import{n as ne,r as p,t as m}from"./card-DMbCO2Fu.js";import{n as re,t as ie}from"./table-DDUhevyo.js";import{t as h}from"./badge-CFbskMgu.js";import{a as ae,n as oe,r as se,t as ce}from"./StatusPill-BYj3zI1_.js";import{t as le}from"./input-number-Cb6-nOBv.js";import{t as g}from"./descriptions-gniVz27W.js";import{t as _}from"./form-y5mvm6Rb.js";import{t as v}from"./input-7g-iBRng.js";import{t as y}from"./list-6VGU-0Wr.js";import{t as ue}from"./modal-C7xDa6TW.js";import{t as de}from"./CopyOutlined-BbN7wZaI.js";import{t as b}from"./DeleteOutlined-J0odQPKG.js";import{t as fe}from"./PlusOutlined-B79Dovl9.js";import{t as pe}from"./ReloadOutlined-By3LF9WE.js";import{t as me}from"./SearchOutlined-8ZUFC3UK.js";import{d as he,f as ge,g as _e,i as x,m as ve,n as S,o as C,p as ye,r as be,t as xe,y as Se}from"./index-Dy4xV4t8.js";import{t as w}from"./EmptyState-CeUjt5Wb.js";import{t as T}from"./CodeBlock-Cehl-9Ci.js";import{n as E,t as Ce}from"./navigation-state-ixI_efPF.js";var we=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={icon:{tag:`svg`,attrs:{viewBox:`64 64 896 896`,focusable:`false`},children:[{tag:`path`,attrs:{d:`M832 64H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V96c0-17.7-14.3-32-32-32zm-40 824H232V687h97.9c11.6 32.8 32 62.3 59.1 84.7 34.5 28.5 78.2 44.3 123 44.3s88.5-15.7 123-44.3c27.1-22.4 47.5-51.9 59.1-84.7H792v-63H643.6l-5.2 24.7C626.4 708.5 573.2 752 512 752s-114.4-43.5-126.5-103.3l-5.2-24.7H232V136h560v752zM320 341h384c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H320c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8zm0 160h384c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H320c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8z`}}]},name:`container`,theme:`outlined`}})),D=e(t()),O=e(we());function k(){return k=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},k.apply(this,arguments)}var Te=D.forwardRef((e,t)=>D.createElement(s,k({},e,{ref:t,icon:O.default}))),A=e(n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={icon:{tag:`svg`,attrs:{viewBox:`64 64 896 896`,focusable:`false`},children:[{tag:`path`,attrs:{d:`M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM790.2 326H602V137.8L790.2 326zm1.8 562H232V136h302v216a42 42 0 0042 42h216v494zM504 618H320c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h184c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8zM312 490v48c0 4.4 3.6 8 8 8h384c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8H320c-4.4 0-8 3.6-8 8z`}}]},name:`file-text`,theme:`outlined`}}))());function j(){return j=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},j.apply(this,arguments)}var M=D.forwardRef((e,t)=>D.createElement(s,j({},e,{ref:t,icon:A.default}))),Ee=e(n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default={icon:{tag:`svg`,attrs:{viewBox:`64 64 896 896`,focusable:`false`},children:[{tag:`path`,attrs:{d:`M880 298.4H521L403.7 186.2a8.15 8.15 0 00-5.5-2.2H144c-17.7 0-32 14.3-32 32v592c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V330.4c0-17.7-14.3-32-32-32zM840 768H184V256h188.5l119.6 114.4H840V768z`}}]},name:`folder`,theme:`outlined`}}))());function N(){return N=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},N.apply(this,arguments)}var P=D.forwardRef((e,t)=>D.createElement(s,N({},e,{ref:t,icon:Ee.default}))),F=f(),I=[`INBOX`,`Sent`,`Drafts`,`Trash`,`Junk`,`Archive`];function De(){let{message:e}=a.useApp(),t=te.useBreakpoint(),{locale:n,t:s}=r(),{config:f}=xe(),h=he(),g=ge(),de=ye(),[b,x]=ve(),[S]=_.useForm(),[C]=_.useForm(),[T,we]=(0,D.useState)([]),[O,k]=(0,D.useState)([]),[Te,A]=(0,D.useState)(R()),[j,M]=(0,D.useState)([]),[Ee,N]=(0,D.useState)(0),[P,I]=(0,D.useState)(null),[De,L]=(0,D.useState)(!0),[Pe,Ie]=(0,D.useState)(!1),[z,ze]=(0,D.useState)(!1),[Be,Ve]=(0,D.useState)(``),[He,Ue]=(0,D.useState)(``),[We,B]=(0,D.useState)(``),[Ge,V]=(0,D.useState)(``),[Ke,qe]=(0,D.useState)(b.get(`q`)||``),[Je,H]=(0,D.useState)(!1),[Ye,U]=(0,D.useState)(null),[W,Xe]=(0,D.useState)(null),Ze=(0,D.useRef)(null),G=b.get(`workspace`)===`routing`?`routing`:`messages`,K=Number(b.get(`mailboxId`)||0)||null,q=b.get(`folder`)||`INBOX`,J=b.get(`read`)||`all`,Qe=b.get(`q`)||``,$e=Math.max(1,Number(b.get(`page`)||1)||1),Y=Number(de.messageId||0)||null,et=je(b.get(`tab`)),X=O.find(e=>e.id===K)||null,Z=(0,D.useCallback)(async()=>{L(!0),Ve(``);try{let[e,t]=await Promise.all([o.domains(),o.inboundMailboxes()]);we(e.domains||[]),k(t.mailboxes||[])}catch(e){Ve(e instanceof Error?e.message:s(`common.error`))}finally{L(!1)}},[s]);(0,D.useEffect)(()=>{Z()},[Z]),(0,D.useEffect)(()=>{if(!O.length||Y&&(!b.has(`mailboxId`)||!b.has(`folder`))||K&&O.some(e=>e.id===K))return;let e=new URLSearchParams(b);e.set(`mailboxId`,String(O[0].id)),e.set(`folder`,`INBOX`),e.set(`page`,`1`),x(e,{replace:!0})},[O,Y,b,K,x]);let Q=(0,D.useCallback)(async()=>{if(!K){A(R());return}try{let e=await o.inboundFolders(K);A(e.folders?.length?e.folders:R(X||void 0))}catch{A(R(X||void 0))}},[X,K]);(0,D.useEffect)(()=>{Q()},[Q]);let $=(0,D.useCallback)(async()=>{if(!K||G!==`messages`){M([]),N(0);return}Ie(!0),Ue(``);try{let e=await o.inboundMessages({mailboxId:K,folder:q,page:$e,pageSize:25,q:Qe||void 0,read:J===`read`?!0:J===`unread`?!1:void 0});M(e.messages||[]),N(e.total??e.messages?.length??0)}catch(e){Ue(e instanceof Error?e.message:s(`common.error`))}finally{Ie(!1)}},[q,$e,Qe,J,K,s,G]);(0,D.useEffect)(()=>{$()},[$]),(0,D.useEffect)(()=>{if(!Y){I(null),B(``);return}let e=!0;return ze(!0),B(``),o.inboundMessage(Y).then(async t=>{if(!e)return;let n=t.message;if(!n){B(s(`inbox.messageNotFound`));return}if(I(n),!n.read){if(await o.markInboundMessageRead(n.id,!0),!e)return;I({...n,read:!0}),M(e=>e.map(e=>e.id===n.id?{...e,read:!0}:e)),Q()}}).catch(t=>{e&&B(t instanceof Error?t.message:s(`inbox.detailLoadFailed`))}).finally(()=>{e&&ze(!1)}),()=>{e=!1}},[Q,Y,s]),(0,D.useEffect)(()=>{if(!Y||P?.id!==Y||b.has(`mailboxId`)&&b.has(`folder`))return;let e=new URLSearchParams(b);e.set(`mailboxId`,String(P.mailboxId)),e.set(`folder`,P.folder||`INBOX`),x(e,{replace:!0})},[Y,b,P,x]),(0,D.useEffect)(()=>{let e=Ze.current;!e||E(h.state)?.origin===`direct`||(Ze.current=null,g(e,{replace:!0}))},[h.key,h.state,g]);function tt(e){let t=new URLSearchParams(b);Object.entries(e).forEach(([e,n])=>{n===null||n===``?t.delete(e):t.set(e,String(n))}),x(t)}function nt(e){let t=new URLSearchParams(b);e===`routing`?t.set(`workspace`,`routing`):t.delete(`workspace`);let n=t.toString();g(`/inbox${n?`?${n}`:``}`)}function rt(e){let t=new URLSearchParams(b);t.set(`mailboxId`,String(e)),t.set(`folder`,`INBOX`),t.set(`page`,`1`);let n=t.toString();g(`/inbox${n?`?${n}`:``}`)}function it(e){let t=new URLSearchParams(b);t.set(`folder`,e),t.set(`page`,`1`);let n=t.toString();g(`/inbox${n?`?${n}`:``}`)}function at(e){I(e);let t=b.toString(),n=`/inbox/messages/${e.id}${t?`?${t}`:``}`,r=E(h.state);if(r){g(n,{state:Ce(r.listPath,r.depth+1,r.origin)});return}if(Y){g(n,{replace:!0});return}g(n,{state:Ce(`${h.pathname}${h.search}`,1)})}function ot(){let e=E(h.state);if(e?.origin===`list`){g(-e.depth);return}let t=P?.id===Y?P:null,n=Me(b,t);if(e?.origin===`direct`){Ze.current=n,g(-e.depth);return}g(n,{replace:!0})}function st(e){let t=new URLSearchParams(b);e===`text`?t.delete(`tab`):t.set(`tab`,e);let n=E(h.state),r=P?.id===Y?P:null,i=t.toString();g({pathname:h.pathname,search:i?`?${i}`:``},{state:Ce(n?.listPath||Me(b,r),(n?.depth||0)+1,n?.origin||`direct`)})}async function ct(t){t&&(await navigator.clipboard.writeText(t),e.success(s(`common.copied`)))}function lt(){S.resetFields(),S.setFieldsValue({domain:T[0]?.domain,password:Re(),quotaMb:1024,keepForwarded:!0}),H(!0)}async function ut(){let t=await S.validateFields();V(`mailbox:create`);try{let n=await o.createInboundMailbox({address:`${t.localPart}@${t.domain}`,displayName:t.displayName,password:t.password,aliases:t.aliases,forwardTo:t.forwardTo,keepForwarded:t.keepForwarded,quotaMb:t.quotaMb});e.success(s(`actions.inboundMailboxCreated`)),H(!1),S.resetFields(),U(n.clientConfig||Le(n.mailbox,f,t.password)),await Z()}catch(t){e.error(t instanceof Error?t.message:s(`common.error`))}finally{V(``)}}function dt(e){Xe(e),C.setFieldsValue({catchAllAddress:e.catchAllAddress||``})}async function ft(){if(!W)return;let t=await C.validateFields();V(`catch-all:${W.id}`);try{let n=await o.patchDomain(W.id,{catchAllAddress:String(t.catchAllAddress||``).trim()});we(e=>e.map(e=>e.id===n.domain.id?n.domain:e)),Xe(null),e.success(s(`actions.domainSaved`))}catch(t){e.error(t instanceof Error?t.message:s(`common.error`))}finally{V(``)}}let pt=[{title:s(`inbox.mailboxAddress`),dataIndex:`address`,render:(e,t)=>(0,F.jsxs)(u,{direction:`vertical`,size:0,children:[(0,F.jsx)(d.Text,{strong:!0,children:e}),t.displayName?(0,F.jsx)(d.Text,{type:`secondary`,children:t.displayName}):null]})},{title:s(`common.status`),dataIndex:`status`,width:120,render:e=>(0,F.jsx)(ce,{tone:e===`active`?`success`:`warning`,children:e})},{title:s(`inbox.forwardTo`),dataIndex:`forwardTo`,render:(e,t)=>e?.length?(0,F.jsxs)(u,{direction:`vertical`,size:2,children:[(0,F.jsx)(d.Text,{children:e.join(`, `)}),(0,F.jsx)(_e,{children:t.keepForwarded?s(`inbox.keepForwarded`):s(`inbox.forwardOnly`)})]}):`—`},{title:s(`inbox.unread`),dataIndex:`unreadCount`,width:90},{title:s(`inbox.messageCount`),dataIndex:`messageCount`,width:100},{title:s(`common.actions`),width:230,render:(e,t)=>(0,F.jsxs)(u,{wrap:!0,children:[(0,F.jsx)(c,{icon:(0,F.jsx)(be,{}),onClick:()=>U(Le(t,f)),children:s(`inbox.clientConfig`)}),(0,F.jsx)(c,{icon:(0,F.jsx)(i,{}),onClick:()=>g(`/integrations/webhooks?mailboxId=${t.id}`),children:s(`inbox.mailboxWebhooks`)})]})}],mt=[{title:s(`domains.domain`),dataIndex:`domain`,render:e=>(0,F.jsx)(d.Text,{strong:!0,children:e})},{title:s(`inbox.catchAllAddress`),dataIndex:`catchAllAddress`,render:e=>e?(0,F.jsx)(_e,{color:e===`/dev/null`?`default`:`blue`,children:e}):(0,F.jsx)(_e,{children:s(`inbox.catchAllDisabled`)})},{title:s(`common.actions`),width:130,render:(e,t)=>(0,F.jsx)(c,{icon:(0,F.jsx)(be,{}),onClick:()=>dt(t),children:s(`common.edit`)})}];return De?(0,F.jsx)(oe,{children:(0,F.jsx)(ee,{active:!0,paragraph:{rows:12}})}):(0,F.jsxs)(u,{direction:`vertical`,size:20,className:`full-width`,children:[(0,F.jsx)(se,{title:s(`inbox.title`),subtitle:s(`inbox.subtitle`),extra:G===`routing`?(0,F.jsx)(c,{type:`primary`,icon:(0,F.jsx)(fe,{}),disabled:!T.length,onClick:lt,style:{minHeight:44},children:s(`inbox.createMailbox`)}):null}),Be?(0,F.jsx)(p,{type:`error`,showIcon:!0,message:Be,action:(0,F.jsx)(c,{icon:(0,F.jsx)(pe,{}),onClick:()=>void Z(),children:s(`common.refresh`)})}):null,f?.submission?.inboundEnabled===!1?(0,F.jsx)(p,{type:`warning`,showIcon:!0,message:s(`inbox.inboundDisabled`)}):null,(0,F.jsx)(ne,{activeKey:G,onChange:nt,items:[{key:`messages`,label:(0,F.jsxs)(u,{children:[(0,F.jsx)(i,{}),n.startsWith(`en`)?`Mail`:`邮件`]})},{key:`routing`,label:(0,F.jsxs)(u,{children:[(0,F.jsx)(be,{}),n.startsWith(`en`)?`Mailboxes & routing`:`邮箱与路由`]})}]}),G===`messages`?O.length?(0,F.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:t.lg?`220px minmax(320px, 380px) minmax(0, 1fr)`:t.md?`220px minmax(0, 1fr)`:`minmax(0, 1fr)`,gap:16,minWidth:0},children:[t.md?(0,F.jsx)(Oe,{mailboxes:O,selectedMailboxId:K,folders:Te,activeFolder:q,onMailbox:rt,onFolder:it,locale:n}):null,(0,F.jsxs)(m,{styles:{body:{padding:0,minWidth:0}},children:[(0,F.jsxs)(`div`,{style:{padding:12,borderBottom:`1px solid #EAECF0`},children:[t.md?null:(0,F.jsxs)(u,{direction:`vertical`,size:8,className:`full-width`,style:{marginBottom:8},children:[(0,F.jsx)(l,{value:K||void 0,onChange:rt,options:O.map(e=>({value:e.id,label:e.address})),className:`full-width`,"aria-label":s(`inbox.mailboxFilter`)}),(0,F.jsx)(l,{value:q,onChange:it,options:Te.map(e=>({value:e.name,label:`${Fe(e.name,n)} (${e.unreadCount})`})),className:`full-width`,"aria-label":n.startsWith(`en`)?`Folder`:`文件夹`})]}),(0,F.jsxs)(u.Compact,{block:!0,children:[(0,F.jsx)(v,{value:Ke,allowClear:!0,prefix:(0,F.jsx)(me,{}),placeholder:s(`inbox.searchPlaceholder`),onChange:e=>qe(e.target.value),onPressEnter:()=>tt({q:Ke.trim(),page:1})}),(0,F.jsx)(c,{"aria-label":s(`common.refresh`),icon:(0,F.jsx)(pe,{}),loading:Pe,onClick:()=>void $()})]}),(0,F.jsx)(l,{value:J,onChange:e=>tt({read:e===`all`?null:e,page:1}),style:{width:`100%`,marginTop:8},"aria-label":n.startsWith(`en`)?`Read state`:`阅读状态`,options:[{value:`all`,label:n.startsWith(`en`)?`All mail`:`全部邮件`},{value:`unread`,label:s(`inbox.unread`)},{value:`read`,label:s(`inbox.read`)}]})]}),He?(0,F.jsx)(p,{type:`error`,showIcon:!0,message:He,action:(0,F.jsx)(c,{onClick:()=>void $(),children:s(`common.refresh`)})}):null,(0,F.jsx)(ke,{items:j,loading:Pe,activeId:Y,onOpen:at,locale:n,t:s}),Ee>25?(0,F.jsx)(`div`,{style:{padding:12,display:`flex`,justifyContent:`center`},children:(0,F.jsx)(ae,{size:`small`,current:$e,pageSize:25,total:Ee,showSizeChanger:!1,onChange:e=>tt({page:e})})}):null]}),t.lg?(0,F.jsx)(m,{styles:{body:{padding:20,minWidth:0}},children:(0,F.jsx)(Ae,{message:P,loading:z,error:We,activeTab:et,onTabChange:st,onCopy:ct,t:s})}):null]}):(0,F.jsx)(w,{description:n.startsWith(`en`)?`No receiving mailbox has been created yet.`:`尚未创建收信邮箱。`,action:(0,F.jsx)(c,{icon:(0,F.jsx)(fe,{}),disabled:!T.length,onClick:()=>{nt(`routing`),lt()},children:s(`inbox.createMailbox`)})}):(0,F.jsxs)(u,{direction:`vertical`,size:20,className:`full-width`,children:[(0,F.jsx)(oe,{title:s(`inbox.mailboxes`),extra:(0,F.jsx)(ce,{tone:`neutral`,children:O.length}),children:O.length?t.md?(0,F.jsx)(ie,{rowKey:`id`,columns:pt,dataSource:O,scroll:{x:940}}):(0,F.jsx)(y,{dataSource:O,renderItem:e=>(0,F.jsx)(y.Item,{children:(0,F.jsx)(m,{size:`small`,className:`full-width`,title:e.address,children:(0,F.jsxs)(u,{direction:`vertical`,className:`full-width`,children:[(0,F.jsxs)(d.Text,{type:`secondary`,children:[e.messageCount,` `,s(`inbox.messageCount`),` · `,e.unreadCount,` `,s(`inbox.unread`)]}),(0,F.jsxs)(u,{wrap:!0,children:[(0,F.jsx)(c,{onClick:()=>U(Le(e,f)),children:s(`inbox.clientConfig`)}),(0,F.jsx)(c,{onClick:()=>g(`/integrations/webhooks?mailboxId=${e.id}`),children:s(`inbox.mailboxWebhooks`)})]})]})})})}):(0,F.jsx)(w,{description:s(`inbox.noDomain`),action:(0,F.jsx)(c,{icon:(0,F.jsx)(fe,{}),disabled:!T.length,onClick:lt,children:s(`inbox.createMailbox`)})})}),(0,F.jsx)(oe,{title:s(`inbox.domainRoutes`),extra:(0,F.jsx)(ce,{tone:`neutral`,children:T.length}),children:T.length?t.md?(0,F.jsx)(ie,{rowKey:`id`,columns:mt,dataSource:T}):(0,F.jsx)(y,{dataSource:T,renderItem:e=>(0,F.jsx)(y.Item,{actions:[(0,F.jsx)(c,{onClick:()=>dt(e),children:s(`common.edit`)},`edit`)],children:(0,F.jsx)(y.Item.Meta,{title:e.domain,description:e.catchAllAddress||s(`inbox.catchAllDisabled`)})})}):(0,F.jsx)(w,{description:s(`inbox.noDomain`),action:(0,F.jsx)(c,{onClick:()=>g(`/domains?create=1`),children:s(`common.addDomain`)})})})]}),t.lg?null:(0,F.jsx)(Se,{title:s(`inbox.messageDetail`),width:t.md?680:`100%`,open:!!Y,onClose:ot,children:(0,F.jsx)(Ae,{message:P,loading:z,error:We,activeTab:et,onTabChange:st,onCopy:ct,t:s})}),(0,F.jsx)(Se,{title:s(`inbox.createMailbox`),width:560,open:Je,onClose:()=>H(!1),destroyOnHidden:!0,footer:(0,F.jsxs)(u,{style:{display:`flex`,justifyContent:`flex-end`},children:[(0,F.jsx)(c,{onClick:()=>H(!1),children:s(`common.cancel`)}),(0,F.jsx)(c,{type:`primary`,loading:Ge===`mailbox:create`,onClick:()=>void ut(),children:s(`inbox.createMailbox`)})]}),children:T.length?(0,F.jsxs)(_,{form:S,layout:`vertical`,children:[(0,F.jsxs)(u.Compact,{block:!0,children:[(0,F.jsx)(_.Item,{name:`localPart`,label:s(`inbox.localPart`),rules:[{required:!0,message:s(`inbox.localPartRequired`)},{pattern:/^[^@\s]+$/,message:s(`inbox.localPartInvalid`)}],style:{flex:1},children:(0,F.jsx)(v,{autoComplete:`off`})}),(0,F.jsx)(_.Item,{name:`domain`,label:s(`domains.domain`),rules:[{required:!0,message:s(`inbox.domainRequired`)}],style:{minWidth:220},children:(0,F.jsx)(l,{options:T.map(e=>({value:e.domain,label:`@${e.domain}`}))})})]}),(0,F.jsx)(_.Item,{name:`displayName`,label:s(`inbox.displayName`),children:(0,F.jsx)(v,{})}),(0,F.jsx)(_.Item,{name:`password`,label:s(`inbox.password`),rules:[{required:!0,message:s(`inbox.passwordRequired`)},{min:8,message:s(`inbox.passwordMin`)}],children:(0,F.jsx)(v.Password,{autoComplete:`new-password`})}),(0,F.jsx)(c,{onClick:()=>S.setFieldValue(`password`,Re()),children:s(`inbox.generatePassword`)}),(0,F.jsx)(_.Item,{name:`quotaMb`,label:`${s(`inbox.quotaMb`)} (MB)`,style:{marginTop:20},children:(0,F.jsx)(le,{min:1,className:`full-width`})}),(0,F.jsx)(_.Item,{name:`aliases`,label:s(`inbox.aliases`),extra:s(`inbox.aliasesExtra`),children:(0,F.jsx)(v.TextArea,{rows:3})}),(0,F.jsx)(_.Item,{name:`forwardTo`,label:s(`inbox.forwardTo`),extra:s(`inbox.forwardToExtra`),children:(0,F.jsx)(v.TextArea,{rows:3})}),(0,F.jsx)(_.Item,{name:`keepForwarded`,valuePropName:`checked`,children:(0,F.jsx)(re,{children:s(`inbox.keepForwarded`)})})]}):(0,F.jsx)(p,{type:`warning`,showIcon:!0,message:s(`inbox.noDomain`)})}),(0,F.jsx)(ue,{title:s(`inbox.catchAllTitle`),open:!!W,confirmLoading:Ge.startsWith(`catch-all:`),onCancel:()=>Xe(null),onOk:()=>void ft(),children:(0,F.jsx)(_,{form:C,layout:`vertical`,children:(0,F.jsx)(_.Item,{name:`catchAllAddress`,label:s(`inbox.catchAllAddress`),extra:s(`inbox.catchAllExtra`),children:(0,F.jsx)(v,{placeholder:`catchall@example.com / /dev/null`})})})}),(0,F.jsx)(ue,{title:s(`inbox.clientConfig`),open:!!Ye,width:720,footer:(0,F.jsx)(c,{type:`primary`,onClick:()=>U(null),children:s(`common.confirm`)}),onCancel:()=>U(null),children:Ye?(0,F.jsx)(Ne,{config:Ye,onCopy:ct,t:s}):null})]})}function Oe({mailboxes:e,selectedMailboxId:t,folders:n,activeFolder:r,onMailbox:i,onFolder:a,locale:o}){return(0,F.jsxs)(m,{styles:{body:{padding:8}},children:[(0,F.jsx)(l,{value:t||void 0,onChange:i,options:e.map(e=>({value:e.id,label:e.address})),className:`full-width`,style:{marginBottom:12}}),(0,F.jsx)(u,{direction:`vertical`,size:2,className:`full-width`,children:n.map(e=>(0,F.jsxs)(c,{type:r===e.name?`primary`:`text`,icon:Ie(e.name),onClick:()=>a(e.name),style:{width:`100%`,minHeight:44,display:`flex`,alignItems:`center`,justifyContent:`flex-start`},children:[(0,F.jsx)(`span`,{style:{flex:1,textAlign:`left`},children:Fe(e.name,o)}),e.unreadCount?(0,F.jsx)(h,{count:e.unreadCount,size:`small`}):(0,F.jsx)(d.Text,{type:`secondary`,children:e.messageCount})]},e.name))})]})}function ke({items:e,loading:t,activeId:n,onOpen:r,locale:i,t:a}){return t?(0,F.jsx)(`div`,{style:{padding:16},children:(0,F.jsx)(ee,{active:!0,paragraph:{rows:8}})}):e.length?(0,F.jsx)(y,{dataSource:e,split:!0,renderItem:e=>(0,F.jsx)(y.Item,{style:{padding:0},children:(0,F.jsx)(`button`,{type:`button`,"aria-label":`${e.subject||a(`inbox.noSubject`)} · ${e.sender}`,onClick:()=>r(e),style:{width:`100%`,minHeight:88,padding:`12px 16px`,border:0,textAlign:`left`,background:n===e.id?`#EEF2FF`:e.read?`#FFFFFF`:`#F8FAFF`,cursor:`pointer`},children:(0,F.jsxs)(u,{direction:`vertical`,size:4,style:{width:`100%`},children:[(0,F.jsxs)(u,{style:{width:`100%`,justifyContent:`space-between`},children:[(0,F.jsx)(d.Text,{strong:!e.read,ellipsis:!0,style:{maxWidth:`65%`},children:e.sender||`—`}),(0,F.jsx)(d.Text,{type:`secondary`,style:{fontSize:12},children:ze(e.receivedAt)})]}),(0,F.jsx)(d.Text,{strong:!e.read,ellipsis:!0,children:e.subject||a(`inbox.noSubject`)}),(0,F.jsx)(d.Text,{type:`secondary`,ellipsis:!0,children:e.preview||`—`})]})})})}):(0,F.jsx)(w,{description:i.startsWith(`en`)?`No messages match this folder and filter.`:`当前文件夹和筛选条件下没有邮件。`})}function Ae({message:e,loading:t,error:n,activeTab:r,onTabChange:i,onCopy:a,t:o}){return t?(0,F.jsx)(ee,{active:!0,paragraph:{rows:12}}):n?(0,F.jsx)(p,{type:`error`,showIcon:!0,message:n}):e?(0,F.jsxs)(u,{direction:`vertical`,size:20,className:`full-width`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(d.Title,{level:4,style:{marginBottom:4},children:e.subject||o(`inbox.noSubject`)}),(0,F.jsx)(d.Text,{type:`secondary`,children:Be(e.receivedAt)})]}),(0,F.jsxs)(g,{column:1,size:`small`,children:[(0,F.jsx)(g.Item,{label:o(`inbox.sender`),children:e.sender||`—`}),(0,F.jsx)(g.Item,{label:o(`inbox.recipients`),children:e.recipients.join(`, `)||`—`}),(0,F.jsx)(g.Item,{label:o(`logs.messageId`),children:(0,F.jsx)(d.Text,{code:!0,copyable:{onCopy:()=>a(e.messageId)},children:e.messageId||`—`})})]}),(0,F.jsx)(ne,{activeKey:r,onChange:e=>i(je(e)),items:[{key:`text`,label:o(`inbox.textBody`),children:e.textBody?(0,F.jsx)(`pre`,{className:`inbox-message-body`,children:e.textBody}):(0,F.jsx)(w,{description:o(`inbox.noTextBody`)})},{key:`html`,label:o(`inbox.htmlBody`),children:e.htmlBody?(0,F.jsx)(T,{value:e.htmlBody,onCopy:a}):(0,F.jsx)(w,{description:o(`inbox.noHtmlBody`)})},{key:`raw`,label:o(`inbox.rawMessage`),children:e.rawMessage?(0,F.jsx)(T,{value:e.rawMessage,onCopy:a}):(0,F.jsx)(w,{description:o(`inbox.noRawMessage`)})}]})]}):(0,F.jsx)(w,{description:o(`inbox.messageDetail`)})}function je(e){return e===`html`||e===`raw`?e:`text`}function Me(e,t){let n=new URLSearchParams(e);n.delete(`tab`),t&&(!n.has(`mailboxId`)||!n.has(`folder`))&&(n.set(`mailboxId`,String(t.mailboxId)),n.set(`folder`,t.folder||`INBOX`));let r=n.toString();return`/inbox${r?`?${r}`:``}`}function Ne({config:e,onCopy:t,t:n}){let r=[{key:`imap`,label:n(`inbox.incomingConfig`),value:e.incoming},...e.pop3?[{key:`pop3`,label:n(`inbox.pop3Config`),value:e.pop3}]:[],{key:`smtp`,label:n(`inbox.outgoingConfig`),value:e.outgoing}];return(0,F.jsxs)(u,{direction:`vertical`,size:16,className:`full-width`,children:[(0,F.jsx)(p,{type:`info`,showIcon:!0,message:n(`inbox.clientConfigHelpSummary`)}),(0,F.jsxs)(g,{bordered:!0,column:1,size:`small`,children:[(0,F.jsx)(g.Item,{label:n(`inbox.configUsername`),children:L(e.username,t)}),(0,F.jsx)(g.Item,{label:n(`inbox.configPassword`),children:e.password?L(e.password,t):(0,F.jsx)(d.Text,{type:`secondary`,children:n(`inbox.passwordNotShown`)})})]}),(0,F.jsx)(ne,{items:r.map(e=>({key:e.key,label:e.label,children:(0,F.jsxs)(g,{bordered:!0,column:1,size:`small`,children:[(0,F.jsx)(g.Item,{label:n(`inbox.configHost`),children:L(e.value.host,t)}),(0,F.jsx)(g.Item,{label:n(`inbox.configPort`),children:L(e.value.port,t)}),(0,F.jsx)(g.Item,{label:n(`inbox.configSecurity`),children:e.value.security}),(0,F.jsx)(g.Item,{label:n(`inbox.configAuthMethod`),children:e.value.authMethod})]})}))})]})}function L(e,t){return(0,F.jsxs)(u,{children:[(0,F.jsx)(d.Text,{code:!0,children:e}),(0,F.jsx)(c,{"aria-label":`Copy`,icon:(0,F.jsx)(de,{}),onClick:()=>void t(String(e))})]})}function R(e){return I.map(t=>({name:t,specialUse:Pe(t),messageCount:t===`INBOX`&&e?.messageCount||0,unreadCount:t===`INBOX`&&e?.unreadCount||0}))}function Pe(e){return{INBOX:null,Sent:`\\Sent`,Drafts:`\\Drafts`,Trash:`\\Trash`,Junk:`\\Junk`,Archive:`\\Archive`}[e]??null}function Fe(e,t){return t.startsWith(`en`)?e:{INBOX:`收件箱`,Sent:`已发送`,Drafts:`草稿`,Trash:`已删除`,Junk:`垃圾邮件`,Archive:`归档`}[e]||e}function Ie(e){return e===`INBOX`?(0,F.jsx)(C,{}):e===`Sent`?(0,F.jsx)(x,{}):e===`Drafts`?(0,F.jsx)(M,{}):e===`Trash`?(0,F.jsx)(b,{}):e===`Junk`?(0,F.jsx)(S,{}):e===`Archive`?(0,F.jsx)(Te,{}):(0,F.jsx)(P,{})}function Le(e,t,n=``){let r=z(t?.submission?.ports||[],[587,465]),i=z(t?.mailAccess?.imap.ports||[],[993,143]),a=z(t?.mailAccess?.pop3.ports||[],[995,110]),o=t?.mailAccess?.host||t?.submission?.host||t?.mailHostname||e.domain;return{username:e.address,password:n,incoming:{protocol:`IMAP`,host:o,port:i?.port||143,security:i?.protocol||`IMAP + STARTTLS`,authMethod:`Normal password`,username:e.address,password:n},pop3:{protocol:`POP3`,host:o,port:a?.port||110,security:a?.protocol||`POP3 + STLS`,authMethod:`Normal password`,username:e.address,password:n},outgoing:{protocol:`SMTP`,host:t?.submission?.host||t?.mailHostname||e.domain,port:r?.port||587,security:r?.protocol||`SMTP + STARTTLS`,authMethod:`Normal password`,username:e.address,password:n}}}function z(e,t){for(let n of t){let t=e.find(e=>e.port===n);if(t)return t}return e[0]||null}function Re(){let e=new Uint8Array(14);return globalThis.crypto.getRandomValues(e),Array.from(e,e=>(e%36).toString(36)).join(``)}function ze(e){let t=new Date(e),n=new Date;return t.toDateString()===n.toDateString()?t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):t.toLocaleDateString()}function Be(e){return e?new Date(e).toLocaleString():`—`}export{De as default};
|