"use strict";exports.id=75961,exports.ids=[75961],exports.modules={75961:(a,b,c)=>{c.r(b),c.d(b,{default:()=>o});var d=c(48249),e=c(67484),f=c(19099),g=c(60932),h=c(41090),i=c(20524),j=c(3430),k=c(76219),l=c(39356),m=c(91115),n=c(40433);function o({params:a}){let b=(0,f.useRouter)(),c=(0,e.use)(a),o=c?.id,[p,q]=(0,e.useState)(null),[r,s]=(0,e.useState)(!0),[t,u]=(0,e.useState)(!1),[v,w]=(0,e.useState)(""),[x,y]=(0,e.useState)(""),[z,A]=(0,e.useState)(null),[B,C]=(0,e.useState)(null),[D,E]=(0,e.useState)(null),F=async a=>{if(a.preventDefault(),o){u(!0);try{let a;if(z){let{url:b}=await (0,l.S)(z,"lms/carousel");a=b}await k.db(o,{altText:v.trim(),videoEmbedUrl:x.trim()||void 0,image:a,videoFile:B||void 0}),(0,m.Te)("Slide updated"),b.push(`${n.bw.ADMIN}/carousel`)}catch(a){(0,m.Qg)(a instanceof Error?a.message:"Failed to update slide")}finally{u(!1)}}};return r?(0,d.jsx)("div",{className:"py-8 text-center",children:"Loading..."}):p?(0,d.jsxs)("div",{children:[(0,d.jsxs)("div",{className:"mb-8",children:[(0,d.jsx)("h1",{className:"text-3xl font-bold text-[var(--foreground)]",children:"Edit Carousel Slide"}),(0,d.jsx)("p",{className:"text-[var(--muted-foreground)] mt-2",children:"Slide must have either an image OR a video, not both."})]}),(0,d.jsx)(h.Z,{padding:"lg",children:(0,d.jsxs)("form",{onSubmit:F,className:"space-y-6 max-w-2xl",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-[var(--foreground)] mb-1",children:"Image (optional – use for image-only slide)"}),(0,d.jsx)("input",{type:"file",accept:"image/*",onChange:a=>{let b=a.target.files?.[0];b?(A(b),E(URL.createObjectURL(b)),y(""),C(null)):(A(null),p?.videoEmbedUrl||p?.videoUrl||E(p?.image||null))},className:"block w-full text-sm text-[var(--muted-foreground)] file:mr-4 file:py-2 file:px-4 file:rounded file:border-0 file:text-sm file:font-medium file:bg-[var(--primary)] file:text-white"}),D&&(0,d.jsx)("div",{className:"mt-2 relative w-full max-w-md h-40 rounded overflow-hidden bg-gray-100",children:(0,d.jsx)("img",{src:D,alt:"Preview",className:"w-full h-full object-cover"})})]}),(0,d.jsxs)("div",{className:"border-t border-[var(--border)] pt-6",children:[(0,d.jsx)("p",{className:"text-sm font-medium text-[var(--foreground)] mb-2",children:"Or video (embed or upload)"}),(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm text-[var(--muted-foreground)] mb-1",children:"Video embed URL"}),(0,d.jsx)(j.p,{value:x,onChange:a=>{y(a.target.value),a.target.value.trim()?(A(null),E(null),C(null)):p?.image&&E(p.image)},placeholder:"https://www.youtube.com/embed/..."})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm text-[var(--muted-foreground)] mb-1",children:"Or upload video"}),(0,d.jsx)("input",{type:"file",accept:"video/mp4,video/webm,video/ogg",onChange:a=>{let b=a.target.files?.[0];C(b||null),b?(A(null),E(null)):p?.image&&E(p.image)},className:"block w-full text-sm text-[var(--muted-foreground)] file:mr-4 file:py-2 file:px-4 file:rounded file:border-0 file:text-sm file:font-medium file:bg-[var(--muted)]"})]})]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-sm font-medium text-[var(--foreground)] mb-1",children:"Alt text"}),(0,d.jsx)(j.p,{value:v,onChange:a=>w(a.target.value),placeholder:"Alt text for accessibility"})]}),(0,d.jsxs)("div",{className:"flex gap-3",children:[(0,d.jsx)(i.$,{type:"submit",variant:"primary",disabled:t,children:t?"Saving...":"Save"}),(0,d.jsx)(g.u,{href:`${n.bw.ADMIN}/carousel`,children:(0,d.jsx)(i.$,{type:"button",variant:"outline",children:"Cancel"})})]})]})})]}):(0,d.jsx)("div",{className:"py-8 text-center",children:"Slide not found."})}}};