import{r as h,j as e,N as o,cY as u,L as j,x as p,T as v,e as i}from"./vendor-rThclpOQ.js";import{B as t}from"./button-ZcsoqUQn.js";import{C as N,a as C,c as f,d as g,b as y}from"./card-HXna_7vU.js";import{D as k,b,c as w,d as _}from"./dialog-CDEDwQhm.js";import{S as D}from"./scroll-area-BCwyUKIK.js";import S from"./marksheet-preview-B28bhn9e.js";import"./index-DquVdLUg.js";import"./utils-8KAaAB9H.js";const H=({type:d,template:s})=>{const[r,l]=h.useState(null),n=a=>{i.post(route("marksheet.templates.activate",a),{type:d},{preserveScroll:!0})},c=a=>{confirm("Are you sure you want to delete this marksheet template?")&&i.delete(route("marksheet.templates.destroy",a),{preserveScroll:!0})},m=a=>{l(a)},x=()=>{l(null)};return e.jsxs(e.Fragment,{children:[e.jsxs(N,{className:`relative ${s.is_active?"ring-primary ring-2":""}`,children:[s.is_active&&e.jsxs("div",{className:"bg-primary text-primary-foreground absolute top-4 right-4 rounded-full px-3 py-1 text-xs font-semibold",children:[e.jsx(o,{className:"mr-1 inline h-3 w-3"}),"Active"]}),e.jsxs(C,{children:[e.jsxs(f,{className:"flex items-center",children:[e.jsx(u,{className:"mr-2 h-5 w-5"}),s.name]}),e.jsxs(g,{children:["Created: ",new Date(s.created_at).toLocaleDateString()]})]}),e.jsxs(y,{className:"space-y-4",children:[e.jsxs("div",{className:"cursor-pointer rounded-lg border-2 p-4 text-center transition-all hover:shadow-md",style:{backgroundColor:s.template_data.backgroundColor,borderColor:s.template_data.borderColor},onClick:()=>m(s),children:[e.jsx("div",{className:"mb-2 text-xs font-bold",style:{color:s.template_data.primaryColor},children:s.template_data.headerText}),e.jsx("div",{className:"text-[8px]",style:{color:s.template_data.secondaryColor},children:s.template_data.institutionName})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"h-4 w-4 rounded border",style:{backgroundColor:s.template_data.primaryColor}}),e.jsx("span",{className:"text-xs",children:"Primary"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"h-4 w-4 rounded border",style:{backgroundColor:s.template_data.secondaryColor}}),e.jsx("span",{className:"text-xs",children:"Secondary"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[!s.is_active&&e.jsxs(t,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>n(s.id),children:[e.jsx(o,{className:"mr-1 h-3 w-3"}),"Activate"]}),e.jsx(t,{asChild:!0,size:"sm",variant:"outline",className:"flex-1",children:e.jsxs(j,{href:route("marksheet.templates.edit",s.id),children:[e.jsx(p,{className:"mr-1 h-3 w-3"}),"Edit"]})}),e.jsx(t,{size:"sm",variant:"destructive",onClick:()=>c(s.id),children:e.jsx(v,{className:"h-3 w-3"})})]})]})]},s.id),r&&e.jsx(k,{open:!!r,onOpenChange:a=>!a&&x(),children:e.jsx(b,{className:"w-full gap-0 overflow-y-auto p-0 sm:max-w-4xl",children:e.jsx(D,{className:"max-h-[90vh]",children:e.jsxs("div",{className:"p-6",children:[e.jsx(w,{className:"mb-6",children:e.jsxs(_,{children:["Preview: ",r==null?void 0:r.name]})}),e.jsx(S,{template:r,studentName:"John Doe",courseName:"Sample Course Name",completionDate:"January 1, 2025"})]})})})})]})};export{H as default};
