import{jsxs as a,jsx as e}from"react/jsx-runtime";import{useForm as x,Head as N}from"@inertiajs/react";import{A as y}from"./layout-CssQHtfO.js";import{C,b as S,c as w,d as B,a as _}from"./card-Zg0WOx-j.js";import{I as A}from"./input-qMvM9qch.js";import{L as d}from"./label-DMnntKPk.js";import{B as I}from"./button-BvFBRYHq.js";import{B as m}from"./badge-CFi7bqqA.js";import{A as j,a as D}from"./alert-CsSMIr96.js";import{T as L}from"./textarea-DGUf1VTd.js";import{Radio as F,AlertCircle as T,Send as H}from"lucide-react";import{useState as M}from"react";import"./app-sidebar-header-BX2s-HO_.js";import"@radix-ui/react-collapsible";import"./dropdown-menu-BP80qPHw.js";import"@radix-ui/react-dropdown-menu";import"./utils-CMbmcP35.js";import"clsx";import"tailwind-merge";import"./app-logo-icon-beRg1XGs.js";import"./fonts-CqawFh47.js";import"@radix-ui/react-slot";import"class-variance-authority";import"@radix-ui/react-dialog";import"@radix-ui/react-tooltip";import"@radix-ui/react-avatar";import"../app.js";/* empty css     */import"axios";import"sonner";import"react-dom/client";import"./toaster-DuLpwsc2.js";import"@radix-ui/react-label";const R=[{title:"System",href:"#"},{title:"Broadcast",href:"/admin/system/broadcast"}];function fe({channels:c,serverOnline:r}){const{data:i,setData:o,post:h,processing:p,errors:t,reset:u}=x({message:"",channel:9,sender_role_id:0}),[g,n]=M(0),f=s=>{s.preventDefault(),h("/admin/system/broadcast/send",{preserveState:!1,onSuccess:()=>{u("message"),n(0)}})},b=s=>{const l=s.target.value;o("message",l),n(l.length)},v=Object.entries(c).map(([s,l])=>({value:s,label:`${l} (${s})`}));return a(y,{breadcrumbs:R,children:[e(N,{title:"Broadcast System"}),a("div",{className:"space-y-2",children:[a("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e("div",{children:e("h1",{className:"text-1xl font-bold",children:"Broadcast System"})}),a("div",{className:"flex items-center gap-2",children:[e(F,{className:"h-4 w-4"}),r?e(m,{className:"bg-green-600 hover:bg-green-700 text-white",children:"Server Online"}):e(m,{variant:"destructive",children:"Server Offline"})]})]}),!r&&a(j,{variant:"destructive",children:[e(T,{className:"h-4 w-4"}),e(D,{children:"Game server is offline. Broadcasts cannot be sent at this time."})]}),e("div",{className:"gap-6",children:e("div",{className:"w-full",children:a(C,{children:[a(S,{children:[e(w,{children:"Send Broadcast"}),e(B,{children:"Send a message to all players in-game"})]}),e(_,{children:a("form",{onSubmit:f,className:"space-y-6",children:[a("div",{className:"space-y-2",children:[e(d,{htmlFor:"message",children:"Message"}),e(L,{id:"message",value:i.message,onChange:b,placeholder:"Enter your broadcast message...",rows:4,maxLength:500,disabled:!r,className:t.message?"border-red-500":""}),a("div",{className:"flex justify-between items-center",children:[t.message&&e("p",{className:"text-sm text-red-500",children:t.message}),a("p",{className:"text-sm text-muted-foreground ml-auto",children:[g,"/500 characters"]})]})]}),a("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[a("div",{className:"space-y-2",children:[e(d,{htmlFor:"channel",children:"Channel"}),e("select",{id:"channel",value:i.channel,onChange:s=>o("channel",parseInt(s.target.value)),className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",disabled:!r,children:v.map(s=>e("option",{value:s.value,children:s.label},s.value))}),t.channel&&e("p",{className:"text-sm text-red-500",children:t.channel})]}),a("div",{className:"space-y-2",children:[e(d,{htmlFor:"sender_role_id",children:"Sender Role ID (Optional)"}),e(A,{id:"sender_role_id",type:"number",value:i.sender_role_id,onChange:s=>o("sender_role_id",parseInt(s.target.value)||0),placeholder:"0 (System)",disabled:!r}),e("p",{className:"text-xs text-muted-foreground",children:"Leave as 0 for system message"})]})]}),a(I,{type:"submit",disabled:p||!r||!i.message.trim(),className:"w-full",children:[e(H,{className:"mr-2 h-4 w-4"}),"Send Broadcast"]})]})})]})})})]})]})}export{fe as default};
