import{r as h,j as e,K as l,A as u,L as j,x as p,T as v,e as o}from"./vendor-BKmmeuxg.js";import{B as t}from"./button-BpNwv2aE.js";import{C as f,a as C,c as N,d as g,b as y}from"./card-D9_SJYq6.js";import{D as w,b,c as _,d as D}from"./dialog-B2gN9MvT.js";import{S as k}from"./scroll-area-C8HGru-R.js";import S from"./certificate-preview-vee_nlMq.js";import"./index-WW_1X1qx.js";import"./utils-DxSsnXxD.js";const J=({type:c,template:s})=>{const[r,i]=h.useState(null),d=a=>{o.post(route("certificate.templates.activate",a),{type:c},{preserveScroll:!0})},n=a=>{confirm("Are you sure you want to delete this certificate template?")&&o.delete(route("certificate.templates.destroy",a),{preserveScroll:!0})},m=a=>{i(a)},x=()=>{i(null)};return e.jsxs(e.Fragment,{children:[e.jsxs(f,{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(l,{className:"mr-1 inline h-3 w-3"}),"Active"]}),e.jsxs(C,{children:[e.jsxs(N,{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.titleText}),e.jsx("div",{className:"text-[8px]",style:{color:s.template_data.secondaryColor},children:s.template_data.descriptionText})]}),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:()=>d(s.id),children:[e.jsx(l,{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("certificate.templates.edit",s.id),children:[e.jsx(p,{className:"mr-1 h-3 w-3"}),"Edit"]})}),e.jsx(t,{size:"sm",variant:"destructive",onClick:()=>n(s.id),children:e.jsx(v,{className:"h-3 w-3"})})]})]})]},s.id),r&&e.jsx(w,{open:!!r,onOpenChange:a=>!a&&x(),children:e.jsx(b,{className:"w-full gap-0 overflow-y-auto p-0 sm:max-w-3xl",children:e.jsx(k,{className:"max-h-[90vh]",children:e.jsxs("div",{className:"p-6",children:[e.jsx(_,{className:"mb-6",children:e.jsxs(D,{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{J as default};