import{jsxs as t,jsx as e}from"react/jsx-runtime";import{B as u}from"./button-BvFBRYHq.js";import{C as N}from"./checkbox-DXBO59MA.js";import{D as S,a as w,b as y,c as C,d as D,e as T}from"./dialog-BfGkTFdF.js";import{I as p}from"./input-qMvM9qch.js";import{P as M}from"./progress-DBZY2s3y.js";import{Clock as k,X as B,Loader2 as _}from"lucide-react";import{useState as m}from"react";import"@radix-ui/react-slot";import"class-variance-authority";import"./utils-CMbmcP35.js";import"clsx";import"tailwind-merge";import"@radix-ui/react-checkbox";import"@radix-ui/react-dialog";import"@radix-ui/react-progress";function Q({open:o,onOpenChange:i,onSetTimer:d,settingTimer:l}){const[r,n]=m(60),[s,h]=m(!0),[c,b]=m("Server will be restart"),g=a=>{const f=Math.floor(a/60),x=a%60;return`${f.toString().padStart(2,"0")}:${x.toString().padStart(2,"0")}`},v=()=>{d(r,s,c)};return e(S,{open:o,onOpenChange:i,children:t(w,{children:[t(y,{children:[e(C,{children:"Set Shutdown Timer"}),e(D,{children:"Configure the countdown before all servers shut down gracefully."})]}),t("div",{className:"space-y-4 py-2",children:[t("div",{className:"space-y-2",children:[e("label",{htmlFor:"timer_seconds",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Timer Duration (seconds)"}),e(p,{id:"timer_seconds",type:"number",min:"30",max:"600",placeholder:"60",value:r,onChange:a=>n(parseInt(a.target.value)||60)}),e("p",{className:"text-xs text-muted-foreground",children:"Minimum: 30 seconds | Maximum: 600 seconds (10 minutes)"})]}),t("div",{className:"space-y-2",children:[t("div",{className:"flex items-center space-x-2",children:[e(N,{id:"broadcast_enabled",checked:s,onCheckedChange:a=>h(a)}),e("label",{htmlFor:"broadcast_enabled",className:"cursor-pointer text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Enable Broadcast Messages"})]}),e("p",{className:"text-xs text-muted-foreground",children:"Send countdown messages to all online players"})]}),s&&t("div",{className:"space-y-2",children:[e("label",{htmlFor:"broadcast_message",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Broadcast Message"}),e(p,{id:"broadcast_message",type:"text",placeholder:"Server will be maintaince",value:c,onChange:a=>b(a.target.value)}),t("p",{className:"text-xs text-muted-foreground",children:["Use ","{time}"," as a placeholder for the countdown timer"]})]}),e("div",{className:"pt-2 px-3 py-2 bg-muted rounded-md",children:t("p",{className:"text-sm font-medium",children:["Preview: ",e("span",{className:"text-primary",children:s?c.replace("{time}",g(r)):"No broadcast"})]})})]}),t(T,{children:[e(u,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),t(u,{onClick:v,disabled:l||r<30||r>600,className:"bg-destructive hover:bg-destructive/90",children:[l&&e(_,{className:"mr-2 h-4 w-4 animate-spin"}),"Set Timer & Stop All"]})]})]})})}function R({remaining:o,duration:i,onCancel:d}){return t("div",{className:"mb-4 rounded-lg bg-destructive/10 p-4 border border-destructive/30",children:[t("div",{className:"flex items-center justify-between gap-4",children:[t("div",{className:"flex items-center gap-3",children:[e(k,{className:"h-6 w-6 animate-pulse text-destructive"}),t("div",{children:[e("p",{className:"font-semibold text-foreground",children:"Server Shutdown Scheduled"}),t("p",{className:"text-muted-foreground mt-1",children:["All servers will shut down in: ",e("span",{className:"font-mono font-bold text-lg text-destructive",children:(r=>{const n=Math.floor(r/60),s=r%60;return`${n.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`})(o)})]})]})]}),t(u,{variant:"outline",size:"sm",onClick:d,className:"border-destructive/50 text-destructive hover:bg-destructive/20 hover:text-destructive hover:border-destructive",children:[e(B,{className:"h-4 w-4 mr-1"}),"Cancel Timer"]})]}),e("div",{className:"mt-3",children:e(M,{value:o/i*100,className:"h-2 bg-destructive/20 [&>div]:bg-destructive"})})]})}export{R as ShutdownBanner,Q as ShutdownTimerDialog};
