PageSourceSearch

https://email.utobo.com/assets/Received-ClBAKJHG.js

js utobo.com collected 2026-09-26 06:22:25 UTC 12,138 bytes, 7 lines download raw bytes

1import{b as Z,u as P,j as e}from"./vendor-query-CmR8e8UI.js";import{r as m}from"./vendor-react-CtvgsDZ3.js";import{c as J,i as W,B as x,I as S,h as $,M as X,s as g,k as ee}from"./index-B50KUD3M.js";import{P as se}from"./PageHeader-A6CBw4Vp.js";import{I as te}from"./input-BmV0tXlr.js";import{S as ae,a as re,b as ne,d as ie,e as le}from"./select-DGiyEjnw.js";import{C as _,a as C}from"./card-D1HA7iNi.js";import{S as oe,a as de,b as ce,c as me}from"./sheet-CGyD89mb.js";import{S as T}from"./separator-CI9TRuO_.js";import{R as xe}from"./refresh-cw-CPQ-aSPo.js";import{C as ue}from"./copy-DzOoqKYc.js";import{S as pe}from"./search-DkaNWfmt.js";import{C as he}from"./circle-alert-D7LgKkHe.js";import{S as fe}from"./shield-alert-C6L3695R.js";import"./vendor-supabase-GlODc1dO.js";import"./vendor-charts-MzEwy637.js";import"./index-DNcyaA4k.js";import"./index-DotgDK9r.js";import"./index-vlVzEKL-.js";import"./index-DV_vDa7I.js";import"./chevron-down-Bka64g5J.js";import"./check-zxk8COol.js";import"./index-D90OnMJA.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const K=J("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);function ge(t){const a=Date.now()-new Date(t).getTime(),n=Math.floor(a/1e3);if(n<60)return`${n}s ago`;const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const o=Math.floor(r/60);if(o<24)return`${o}h ago`;const i=Math.floor(o/24);return i<7?`${i}d ago`:new Date(t).toLocaleDateString()}function je(t,a="Copied"){navigator.clipboard.writeText(t),$.success(a)}function be(t){return!t||t<1024?`${t||0} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function ve(t){return t.local_part?`${t.local_part}@${t.domain}`:`*@${t.domain}`}const h=50,Ne=[{v:"1",label:"Last 24 hours"},{v:"7",label:"Last 7 days"},{v:"15",label:"Last 15 days"},{v:"30",label:"Last 30 days"},{v:"90",label:"Last 90 days"},{v:"3650",label:"All time"}],k=({label:t,status:a})=>{if(!a)return null;const n=a.toUpperCase()==="PASS",r=a.toUpperCase()==="GRAY"||a.toUpperCase()==="PROCESSING_FAILED";return e.jsxs("span",{className:`inline-flex items-center gap-1 text-[11px] font-medium rounded px-1.5 py-0.5 ${n?"bg-green-50 text-green-700":r?"bg-muted text-muted-foreground":"bg-red-50 text-red-600"}`,children:[n?e.jsx(ee,{className:"size-3"}):e.jsx(fe,{className:"size-3"}),t," ",a.toLowerCase()]})},ye=({email:t,open:a,onClose:n})=>{if(!t)return null;const r=t.auth_results??{},o=t.attachments??[];return e.jsx(oe,{open:a,onOpenChange:i=>!i&&n(),children:e.jsxs(de,{className:"w-[520px] sm:w-[640px] overflow-y-auto",children:[e.jsx(ce,{children:e.jsxs(me,{className:"flex items-center gap-2",children:[e.jsx(X,{className:"size-4"}),t.subject||"(no subject)"]})}),e.jsxs("div",{className:"mt-5 space-y-5",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-0.5",children:"From"}),e.jsxs("p",{className:"text-sm break-words",children:[t.from_name?`${t.from_name} `:"",e.jsxs("span",{className:"text-muted-foreground",children:["<",t.from_email,">"]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-0.5",children:"To"}),e.jsx("p",{className:"text-sm break-words",children:t.to_email})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-0.5",children:"Received"}),e.jsx("p",{className:"text-sm",children:new Date(t.received_at).toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})})]})]}),(r.spf||r.dkim||r.dmarc)&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(k,{label:"SPF",status:r.spf}),e.jsx(k,{label:"DKIM",status:r.dkim}),e.jsx(k,{label:"DMARC",status:r.dmarc})]}),e.jsx(T,{}),e.jsx("div",{children:t.body_html?e.jsx("iframe",{title:"Email body",sandbox:"allow-popups allow-popups-to-escape-sandbox",className:"w-full h-[52vh] rounded-lg border bg-white",srcDoc:t.body_html}):t.body_text?e.jsx("pre",{className:"text-sm whitespace-pre-wrap break-words leading-relaxed",children:t.body_text}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"(no body)"})}),o.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(T,{}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs text-muted-foreground mb-2 flex items-center gap-1.5",children:[e.jsx(K,{className:"size-3.5"})," ",o.length," attachment",o.length>
61?"s":""]}),e.jsx("ul",{className:"space-y-1.5",children:o.map((i,j)=>e.jsxs("li",{className:"flex items-center justify-between text-sm rounded border px-3 py-2",children:[e.jsx("span",{className:"truncate",children:i.filename}),e.jsx("span",{className:"text-xs text-muted-foreground shrink-0 ml-3",children:be(i.size)})]},j))}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-2",children:"Attachment download is coming soon."})]})]})]})]})})},Ge=({embedded:t=!1}={})=>{var R,I,M;const a=Z(),n=(R=W().org)==null?void 0:R.org_id,[r,o]=m.useState("3650"),[i,j]=m.useState(""),[b,O]=m.useState(!1),[u,v]=m.useState(0),[B,Q]=m.useState(null),[U,z]=m.useState(!1),[N,F]=m.useState(!1),A=P({queryKey:["receiving-address"],queryFn:async()=>{const{data:s}=await g.from("receiving_addresses").select("id, domain, local_part, kind").order("created_at",{ascending:!0}).limit(1);return(s==null?void 0:s[0])??null}}),q=s=>{const l=new Date(Date.now()-Number(r)*864e5).toISOString();s=s.gte("received_at",l).order("received_at",{ascending:!1}),b&&(s=s.is("read_at",null));const c=i.trim().replace(/[%,()]/g,"");return c&&(s=s.or(`subject.ilike.%${c}%,from_email.ilike.%${c}%`)),s},d=P({queryKey:["received-emails",r,i,b,u],queryFn:async()=>{const s=g.from("received_emails").select(`id, from_email, from_name, to_email, subject, body_text, body_html,
7           auth_results, attachments, received_at, read_at`,{count:"exact"}),{data:l,error:c,count:Y}=await q(s).range(u*h,u*h+h-1);if(c)throw new Error(c.message);return{rows:l??[],total:Y??0}}}),y=((I=d.data)==null?void 0:I.rows)??[],f=((M=d.data)==null?void 0:M.total)??0,G=f===0?0:u*h+1,D=u*h+y.length,w=s=>{s(),v(0)},H=async s=>{if(Q(s),z(!0),!s.read_at)try{await g.rpc("mark_received_read",{p_id:s.id,p_read:!0}),a.invalidateQueries({queryKey:["received-emails"]})}catch{}},V=async()=>{if(n){F(!0);try{const{data:s,error:l}=await g.rpc("get_or_create_shared_receiving_address",{p_org_id:n});if(l)throw new Error(l.message);$.success(`Inbound address ready: ${s}`),a.invalidateQueries({queryKey:["receiving-address"]})}catch(s){$.error(s.message||"Could not enable receiving")}finally{F(!1)}}},E=()=>{a.invalidateQueries({queryKey:["received-emails"]}),a.invalidateQueries({queryKey:["receiving-address"]})},p=A.data?ve(A.data):null,L=e.jsxs(x,{variant:"outline",size:"sm",onClick:E,disabled:d.isFetching,children:[e.jsx(xe,{className:`size-4 mr-1.5 ${d.isFetching?"animate-spin":""}`}),"Refresh"]});return e.jsxs("div",{"data-clarity-mask":"true",children:[t?e.jsx("div",{className:"flex justify-end mb-3",children:L}):e.jsx(se,{title:"Received",description:"Inbound emails sent to your receiving address.",actions:L}),p&&e.jsx(_,{className:"mt-4",children:e.jsxs(C,{className:"flex items-center gap-3 py-3",children:[e.jsx(S,{className:"size-4 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Your inbound address"}),e.jsx("code",{className:"text-sm font-mono break-all",children:p})]}),e.jsx(x,{size:"sm",variant:"ghost",className:"ml-auto h-7 px-2 shrink-0",onClick:()=>je(p,"Address copied"),children:e.jsx(ue,{className:"size-3.5"})})]})}),e.jsxs("div",{className:"flex flex-wrap gap-2 mt-4 mb-3",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-sm",children:[e.jsx(pe,{className:"absolute left-2.5 top-2.5 size-3.5 text-muted-foreground pointer-events-none"}),e.jsx(te,{className:"pl-8 h-9 text-sm",placeholder:"Search subject or sender…",value:i,onChange:s=>w(()=>j(s.target.value))})]}),e.jsxs(ae,{value:r,onValueChange:s=>w(()=>o(s)),children:[e.jsx(re,{className:"w-36 h-9",children:e.jsx(ne,{})}),e.jsx(ie,{children:Ne.map(s=>e.jsx(le,{value:s.v,children:s.label},s.v))})]}),e.jsx(x,{variant:b?"default":"outline",size:"sm",className:"h-9",onClick:()=>w(()=>O(s=>!s)),children:"Unread only"})]}),d.isLoading?e.jsx("div",{className:"text-sm text-muted-foreground text-center py-20",children:"Loading…"}):d.isError?e.jsx(_,{children:e.jsxs(C,{className:"flex flex-col items-center py-14 text-center gap-3",children:[e.jsx(he,{className:"size-8 text-destructive/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Could not load received emails"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:d.error.message})]}),e.jsx(x,{variant:"outline",size:"sm",onClick:E,children:"Try again"})]})}):y.length===0?e.jsx(_,{children:e.jsxs(C,{className:"flex flex-col items-center py-20 text-center gap-3",children:[e.jsx(S,{className:"size-10 text-muted-foreground
7/25"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"No received emails yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 max-w-md",children:p?e.jsxs(e.Fragment,{children:["Mail sent to ",e.jsx("code",{className:"font-mono",children:p})," will appear here."]}):"Set up a receiving address to start collecting inbound email in your inbox."})]}),!p&&e.jsxs(x,{size:"sm",onClick:V,disabled:N||!n,children:[e.jsx(S,{className:`size-4 mr-1.5 ${N?"animate-pulse":""}`}),N?"Setting up…":"Enable receiving"]})]})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-lg border overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/40",children:[e.jsx("th",{className:"text-left text-xs font-medium text-muted-foreground px-4 py-2.5 w-8"}),e.jsx("th",{className:"text-left text-xs font-medium text-muted-foreground px-4 py-2.5",children:"From"}),e.jsx("th",{className:"text-left text-xs font-medium text-muted-foreground px-4 py-2.5",children:"Subject"}),e.jsx("th",{className:"text-left text-xs font-medium text-muted-foreground px-4 py-2.5 hidden lg:table-cell",children:"To"}),e.jsx("th",{className:"text-right text-xs font-medium text-muted-foreground px-4 py-2.5 whitespace-nowrap",children:"Received"})]})}),e.jsx("tbody",{children:y.map(s=>{var c;const l=!s.read_at;return e.jsxs("tr",{className:`border-b last:border-0 hover:bg-muted/30 cursor-pointer transition-colors ${l?"bg-primary/[0.03]":""}`,onClick:()=>H(s),children:[e.jsx("td",{className:"px-4 py-3",children:l&&e.jsx("span",{className:"inline-block size-2 rounded-full bg-primary","aria-label":"Unread"})}),e.jsx("td",{className:`px-4 py-3 max-w-[180px] truncate ${l?"font-semibold":"text-muted-foreground"}`,children:s.from_name||s.from_email}),e.jsxs("td",{className:`px-4 py-3 max-w-[280px] truncate ${l?"font-medium":""}`,children:[s.subject||e.jsx("span",{className:"text-muted-foreground/60",children:"(no subject)"}),(((c=s.attachments)==null?void 0:c.length)??0)>0&&e.jsx(K,{className:"inline size-3 ml-1.5 text-muted-foreground align-middle"})]}),e.jsx("td",{className:"px-4 py-3 text-xs text-muted-foreground max-w-[160px] truncate hidden lg:table-cell",children:s.to_email}),e.jsx("td",{className:"px-4 py-3 text-xs text-muted-foreground text-right whitespace-nowrap",children:ge(s.received_at)})]},s.id)})})]})}),e.jsxs("div",{className:"flex items-center justify-between mt-3 text-xs text-muted-foreground",children:[e.jsx("span",{children:f>0?`Showing ${G.toLocaleString()}–${D.toLocaleString()} of ${f.toLocaleString()}`:"No results"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(x,{variant:"outline",size:"sm",disabled:u===0||d.isFetching,onClick:()=>v(s=>Math.max(0,s-1)),children:"Previous"}),e.jsx(x,{variant:"outline",size:"sm",disabled:D>=f||d.isFetching,onClick:()=>v(s=>s+1),children:"Next"})]})]})]}),e.jsx(ye,{email:B,open:U,onClose:()=>z(!1)})]})};export{Ge as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.