import{At as e,Dt as t,J as n,Lt as r,M as i,Q as a,U as o,a as s,jt as c,kt as l,nt as u,u as d,v as f}from"./chunk.p3hCiSrt.js";var p=r(c(),1),m=e(),h=e=>new Date(e).toLocaleString(),g=e=>{let t=Date.now()-new Date(e).getTime();return t<1e3?`just now`:t<6e4?`${Math.floor(t/1e3)}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:`${Math.floor(t/36e5)}h ago`},_=()=>{let e=l(t),[r,c]=(0,p.useState)([]),[_,v]=(0,p.useState)(null),[y,b]=(0,p.useState)(``),x=(0,p.useCallback)(async()=>{if(document.visibilityState===`visible`)try{let t=(await e.fetch(`/__devtools/api/sms`)).data;c(t?.messages??[])}catch{}},[e]);(0,p.useEffect)(()=>{x();let e=setInterval(x,1e4);return()=>clearInterval(e)},[x]);let S=r.filter(e=>{if(!y)return!0;let t=y.toLowerCase();return e.to.toLowerCase().includes(t)||e.message.toLowerCase().includes(t)}),C=_===null?null:S[_];return(0,m.jsxs)(s,{style:{flex:1,overflow:`hidden`},direction:`column`,children:[(0,m.jsxs)(s,{px:`md`,py:`xs`,gap:`sm`,align:`center`,style:{borderBottom:`1px solid ${d.colors.border}`,flexShrink:0},children:[(0,m.jsx)(i,{size:`xs`,placeholder:`Search...`,leftSection:(0,m.jsx)(f,{size:14}),value:y,onChange:e=>b(e.currentTarget.value),style:{flex:1,minWidth:150,maxWidth:300}}),(0,m.jsxs)(o,{variant:`light`,color:`gray`,size:`sm`,children:[S.length,` messages`]})]}),(0,m.jsxs)(s,{style:{flex:1,overflow:`hidden`},children:[(0,m.jsx)(s,{direction:`column`,style:{flex:1,overflow:`hidden`},children:(0,m.jsxs)(u,{style:{flex:1},children:[S.length===0&&(0,m.jsx)(s,{align:`center`,justify:`center`,py:`xl`,c:`dimmed`,children:(0,m.jsx)(n,{fz:`sm`,children:`No messages to display`})}),S.map((e,t)=>{let r=_===t;return(0,m.jsxs)(s,{direction:`column`,px:`md`,py:`xs`,onClick:()=>v(r?null:t),style:{borderBottom:`1px solid ${d.colors.border}20`,background:r?d.colors.elevated:`transparent`,cursor:`pointer`,transition:`background 100ms`},onMouseEnter:e=>{r||(e.currentTarget.style.background=`${d.colors.elevated}80`)},onMouseLeave:e=>{r||(e.currentTarget.style.background=`transparent`)},children:[(0,m.jsxs)(s,{justify:`space-between`,align:`center`,children:[(0,m.jsx)(n,{fz:`sm`,truncate:!0,children:e.to}),(0,m.jsx)(n,{fz:11,c:`dimmed`,style:{flexShrink:0},children:g(e.sentAt)})]}),(0,m.jsx)(n,{fz:`xs`,c:`dimmed`,truncate:!0,children:e.message})]},`${e.sentAt}-${t}`)})]})}),C&&(0,m.jsxs)(s,{w:400,direction:`column`,style:{borderLeft:`1px solid ${d.colors.border}`,flexShrink:0,overflow:`hidden`},children:[(0,m.jsxs)(s,{px:`md`,py:`xs`,align:`center`,justify:`space-between`,style:{borderBottom:`1px solid ${d.colors.border}`,flexShrink:0},children:[(0,m.jsx)(n,{fz:`xs`,fw:600,tt:`uppercase`,c:`dimmed`,lts:.5,children:`Message Detail`}),(0,m.jsx)(a,{size:`xs`,onClick:()=>v(null)})]}),(0,m.jsx)(u,{style:{flex:1},p:`md`,children:(0,m.jsxs)(s,{direction:`column`,gap:`md`,children:[(0,m.jsxs)(s,{direction:`column`,children:[(0,m.jsx)(n,{fz:10,c:`dimmed`,tt:`uppercase`,fw:600,lts:.5,mb:4,children:`To`}),(0,m.jsx)(n,{fz:`xs`,children:C.to})]}),(0,m.jsxs)(s,{direction:`column`,children:[(0,m.jsx)(n,{fz:10,c:`dimmed`,tt:`uppercase`,fw:600,lts:.5,mb:4,children:`Date`}),(0,m.jsx)(n,{fz:`xs`,children:h(C.sentAt)})]}),(0,m.jsxs)(s,{direction:`column`,children:[(0,m.jsx)(n,{fz:10,c:`dimmed`,tt:`uppercase`,fw:600,lts:.5,mb:4,children:`Message`}),(0,m.jsx)(n,{fz:`xs`,style:{whiteSpace:`pre-wrap`},children:C.message})]})]})})]})]})]})};export{_ as DevSms,_ as default};