import{a as e,c as t,i as n,n as r,t as i}from"./app-C-4jOatG.js";import{t as a}from"./AuthenticatedLayout-CXpLpvfQ.js";import{t as o}from"./swal-C9zpmKwY.js";t();var s=i();function c({logs:t,users:i}){let{data:c,setData:l,post:u,processing:d,reset:f,errors:p}=e({title:``,body:``,image_url:``,deep_link:``,target_type:`all`,target_user_id:``});return(0,s.jsxs)(a,{children:[(0,s.jsx)(r,{title:`Push Notifications`}),(0,s.jsx)(`div`,{className:`flex items-center justify-between mb-8 anim-down`,children:(0,s.jsxs)(`div`,{children:[(0,s.jsx)(`h1`,{className:`text-xl font-bold text-[#3D4E4B] tracking-tight leading-none`,children:`Notification Center`}),(0,s.jsx)(`p`,{className:`text-sm font-semibold text-gray-400 tracking-tight mt-2`,children:`Broadcast messages and alerts to Android devices`})]})}),(0,s.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-12 gap-8`,children:[(0,s.jsx)(`div`,{className:`lg:col-span-5`,children:(0,s.jsxs)(`div`,{className:`bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden anim-up`,children:[(0,s.jsxs)(`div`,{className:`px-6 py-4 border-b border-gray-50 bg-gray-50/30`,children:[(0,s.jsx)(`h2`,{className:`text-sm font-bold text-[#3D4E4B] tracking-tight`,children:`Compose Broadcast`}),(0,s.jsx)(`p`,{className:`text-[10px] text-gray-400 font-bold uppercase tracking-widest mt-1`,children:`New FCM Message`})]}),(0,s.jsx)(`div`,{className:`p-8`,children:(0,s.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),u(route(`notifications.store`),{onSuccess:()=>{f(),o.success(`Dispatched`,`Notification has been sent to devices.`)}})},className:`space-y-6`,children:[(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,s.jsx)(`label`,{className:`text-xs font-bold text-gray-500 ml-1`,children:`Message Title`}),(0,s.jsx)(`input`,{value:c.title,onChange:e=>l(`title`,e.target.value),placeholder:`e.g. Flash Sale Alert!`,className:`input-field ${p.title?`is-error`:``}`}),p.title&&(0,s.jsx)(`p`,{className:`text-[10px] text-red-500 font-bold ml-1`,children:p.title})]}),(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,s.jsx)(`label`,{className:`text-xs font-bold text-gray-500 ml-1`,children:`Message Body`}),(0,s.jsx)(`textarea`,{value:c.body,onChange:e=>l(`body`,e.target.value),rows:3,placeholder:`Write your notification message here...`,className:`input-field py-3 resize-none ${p.body?`is-error`:``}`}),p.body&&(0,s.jsx)(`p`,{className:`text-[10px] text-red-500 font-bold ml-1`,children:p.body})]}),(0,s.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,s.jsxs)(`div`,{className:`space-y-1.5 text-xs font-bold text-gray-500 ml-1`,children:[(0,s.jsx)(`label`,{children:`Target Audience`}),(0,s.jsxs)(`select`,{value:c.target_type,onChange:e=>l(`target_type`,e.target.value),className:`input-field mt-1.5 h-10`,children:[(0,s.jsx)(`option`,{value:`all`,children:`All Users`}),(0,s.jsx)(`option`,{value:`individual`,children:`Specific User`})]})]}),c.target_type===`individual`&&(0,s.jsxs)(`div`,{className:`space-y-1.5 text-xs font-bold text-gray-500 ml-1`,children:[(0,s.jsx)(`label`,{children:`Select User`}),(0,s.jsxs)(`select`,{value:c.target_user_id,onChange:e=>l(`target_user_id`,e.target.value),className:`input-field mt-1.5 h-10`,children:[(0,s.jsx)(`option`,{value:``,children:`Choose User...`}),i.map(e=>(0,s.jsxs)(`option`,{value:e.id,children:[e.first_name,` `,e.last_name]},e.id))]})]})]}),(0,s.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,s.jsx)(`label`,{className:`text-xs font-bold text-gray-500 ml-1`,children:`Deep Link (Optional)`}),(0,s.jsx)(`input`,{value:c.deep_link,onChange:e=>l(`deep_link`,e.target.value),placeholder:`app://screen/profile`,className:`input-field`})]}),(0,s.jsx)(`div`,{className:`pt-4 border-t border-gray-50`,children:(0,s.jsx)(`button`,{type:`submit`,disabled:d,className:`w-full h-11 bg-[#3D4E4B] text-white text-xs font-black uppercase tracking-widest rounded-xl hover:bg-[#2D3A38] transition-all shadow-lg shadow-[#3D4E4B]/20 disabled:opacity-60`,children:d?`Sending...`:`Send Notification`})})]})})]})}),(0,s.jsx)(`div`,{className:`lg:col-span-7`,children:(0,s.jsxs)(`div`,{className:`bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden anim-up`,style:{animationDelay:`0.1s`},children:[(0,s.jsx)(`div`,{className:`px-6 py-4 border-b border-gray-50`,children:(0,s.jsx)(`h2`,{className:`text-sm font-bold text-[#3D4E4B] tracking-tight`,children:`Recent Broadcasts`})}),(0,s.jsx)(`div`,{className:`overflow-x-auto`,children:(0,s.jsxs)(`table`,{className:`w-full text-left border-collapse`,children:[(0,s.jsx)(`thead`,{className:`bg-gray-50/50`,children:(0,s.jsxs)(`tr`,{children:[(0,s.jsx)(`th`,{className:`px-6 py-3 text-[10px] font-black text-gray-400 uppercase tracking-widest`,children:`Message`}),(0,s.jsx)(`th`,{className:`px-6 py-3 text-[10px] font-black text-gray-400 uppercase tracking-widest`,children:`Target`}),(0,s.jsx)(`th`,{className:`px-6 py-3 text-[10px] font-black text-gray-400 uppercase tracking-widest`,children:`Status`}),(0,s.jsx)(`th`,{className:`px-6 py-3 text-[10px] font-black text-gray-400 uppercase tracking-widest`,children:`Sent At`})]})}),(0,s.jsxs)(`tbody`,{className:`divide-y divide-gray-50`,children:[t.data.map(e=>(0,s.jsxs)(`tr`,{className:`hover:bg-gray-50/30 transition-colors group`,children:[(0,s.jsxs)(`td`,{className:`px-6 py-4`,children:[(0,s.jsx)(`div`,{className:`text-sm font-bold text-[#3D4E4B] tracking-tight`,children:e.title}),(0,s.jsx)(`div`,{className:`text-[10px] text-gray-400 font-medium truncate max-w-[200px] mt-0.5`,children:e.body})]}),(0,s.jsx)(`td`,{className:`px-6 py-4`,children:(0,s.jsx)(`span`,{className:`text-[10px] font-black uppercase tracking-widest ${e.target_type===`all`?`text-[#D4A017]`:`text-blue-600`}`,children:e.target_type===`all`?`All Devices`:e.target_user?.first_name||`Individual`})}),(0,s.jsx)(`td`,{className:`px-6 py-4`,children:(0,s.jsx)(`span`,{className:`px-2 py-0.5 rounded-md text-[9px] font-black uppercase tracking-widest border ${e.status===`sent`?`bg-emerald-50 text-emerald-600 border-emerald-100`:`bg-red-50 text-red-500 border-red-100`}`,children:e.status})}),(0,s.jsx)(`td`,{className:`px-6 py-4 text-[10px] font-bold text-gray-400`,children:new Date(e.created_at).toLocaleDateString(`en-GB`,{day:`2-digit`,month:`short`,year:`numeric`})})]},e.id)),t.data.length===0&&(0,s.jsx)(`tr`,{children:(0,s.jsx)(`td`,{colSpan:4,className:`px-6 py-16 text-center`,children:(0,s.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,s.jsx)(`div`,{className:`w-12 h-12 rounded-2xl bg-gray-50 border border-gray-100 flex items-center justify-center`,children:(0,s.jsx)(`svg`,{className:`w-5 h-5 text-gray-300`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,s.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9`})})}),(0,s.jsx)(`p`,{className:`text-xs font-bold text-gray-300`,children:`No broadcasts sent yet`})]})})})]})]})}),t.meta&&t.meta.last_page>1&&(0,s.jsxs)(`div`,{className:`px-6 py-4 border-t border-gray-50 flex items-center justify-between`,children:[(0,s.jsxs)(`p`,{className:`text-[10px] font-bold text-gray-400 uppercase tracking-widest`,children:[t.meta.total,` total — page `,t.meta.current_page,` of `,t.meta.last_page]}),(0,s.jsx)(`div`,{className:`flex items-center gap-1`,children:t.links.map((e,t)=>(0,s.jsx)(`button`,{disabled:!e.url||e.active,onClick:()=>e.url&&n.get(e.url,{},{preserveScroll:!0}),className:`h-8 min-w-[2rem] px-2 rounded-lg text-xs font-bold transition-all border ${e.active?`bg-[#3D4E4B] text-white border-[#3D4E4B]`:`bg-white text-gray-400 border-gray-100 hover:border-gray-200 hover:text-[#3D4E4B]`} ${e.url?`cursor-pointer`:`opacity-30 cursor-not-allowed`}`,dangerouslySetInnerHTML:{__html:e.label}},t))})]})]})})]})]})}export{c as default};