"use strict";exports.id=16037,exports.ids=[11289,16037,33670,39356],exports.modules={33670:(a,b,c)=>{c.d(b,{T:()=>g});var d=c(48249),e=c(67484),f=c(14113);let g=({label:a,error:b,helperText:c,className:g,id:h,variant:i="default",...j})=>{let k=(0,e.useId)(),l=h||k,m="marketing"===i;return(0,d.jsxs)("div",{className:"w-full",children:[a&&(0,d.jsx)("label",{htmlFor:l,className:m?"mb-1.5 block text-sm font-medium text-slate-800":"mb-1 block text-sm font-medium text-[var(--foreground)]",children:a}),(0,d.jsx)("textarea",{id:l,className:(0,f.xW)("w-full resize-y transition-colors focus:outline-none",m?"rounded-lg border border-slate-200 bg-white px-3 py-2.5 text-sm text-slate-900 shadow-none placeholder:text-slate-400 focus:border-secondary-800 focus:ring-2 focus:ring-secondary-900/15":"rounded-none border px-4 py-2 focus:ring-2 focus:ring-[var(--primary-500)] focus:border-transparent",!m&&(b?"border-[var(--error)] focus:ring-red-500":"border-[var(--border)]"),m&&b?"border-red-400 focus:border-red-500 focus:ring-red-500/20":"",m?"":"bg-[var(--input)] text-[var(--foreground)]",g),...j}),b&&(0,d.jsx)("p",{className:"mt-1 text-sm text-[var(--error)]",children:b}),c&&!b&&(0,d.jsx)("p",{className:"mt-1 text-sm text-[var(--muted-foreground)]",children:c})]})}},39356:(a,b,c)=>{c.d(b,{S:()=>f});var d=c(23971),e=c(40433);async function f(a,b){let c=new FormData;c.append("file",a),c.append("folder",b);let f=await d.uE.post(e.Sn.UPLOAD.IMAGE,c,{headers:{"Content-Type":"multipart/form-data"}});return(0,d.yH)(f)}},74457:(a,b,c)=>{c.r(b),c.d(b,{default:()=>m});var d=c(48249),e=c(67484),f=c(19099),g=c(94446),h=c(30611);c(79465),c(36605);var i=c(71091),j=c(112),k=c(91115),l=c(23557);function m(){let a=(0,f.useRouter)(),[b,c]=(0,e.useState)([]),[m,n]=(0,e.useState)([]),[o,p]=(0,e.useState)(!0),[q,r]=(0,e.useState)(!1),[s,t]=(0,e.useState)(null),u=async(b,c)=>{try{r(!0);let d=s?await h.J4(s.id,b):await h.C_(b);if(t(d),b.curriculumData&&d.id)try{for(let a of(console.log("Creating curriculum data..."),b.curriculumData.chapters)){let b={courseId:d.id,title:a.title,description:a.description||void 0,isLocked:a.isLocked||!1,isPreview:a.isPreview||!1,order:a.order},c=await i.gC(b);if(c)for(let b of(console.log("Chapter created:",c),a.lessons||[])){let a={courseId:d.id,chapterId:c.id,title:b.title,description:b.description||void 0,content:b.content||void 0,lessonType:b.lessonType||"VIDEO",videoUrl:b.videoUrl||void 0,isPreview:b.isPreview||!1,isLocked:b.isLocked||!1,order:b.order};await j.Dn(a)}}(0,k.Te)("Course and curriculum created successfully!")}catch(a){console.error("Error creating curriculum:",a),(0,k.Te)("Course created successfully! Some curriculum items may need to be added manually.")}else c?.buildCurriculum?(0,k.Te)("Course saved! Now build your curriculum."):(0,k.Te)(s?"Course updated successfully!":"Course created successfully!");if(c?.buildCurriculum)return d;(0,l.yK)("/admin/courses",a)}catch(b){console.error("Error creating course:",b);let a="Failed to create course";if(b?.response?.data?.errors&&Array.isArray(b.response.data.errors)){let c=b.response.data.errors.map(a=>`${a.param||a.field||"Field"}: ${a.msg||a.message||"Invalid value"}`).join("\n");a=`Validation failed:
${c}`}else b?.message?.includes("timed out")||b?.message?.includes("timeout")||b?.code==="ECONNABORTED"?a=b?.message||"Upload took too long. Try a faster connection, a smaller video, or add the video later from the course edit page.":b?.message?.includes("upload")?a="File upload failed. Please try with a smaller image or check your internet connection.":b?.message?.includes("network")||b?.message?.includes("Network Error")?a="Network error. Please check your internet connection and try again.":b?.message&&(a=b.message);(0,k.Qg)(a)}finally{r(!1)}};return o?(0,d.jsxs)("div",{className:"animate-in fade-in duration-200 flex gap-6",children:[(0,d.jsx)("div",{className:"h-[400px] w-[274px] shrink-0 bg-[var(--muted)] rounded animate-pulse"}),(0,d.jsxs)("div",{className:"flex-1 space-y-6",children:[(0,d.jsx)("div",{className:"h-9 w-64 bg-[var(--muted)] rounded animate-pulse"}),(0,d.jsx)("div",{className:"h-64 bg-[var(--card)] border border-[var(--border)] rounded-xl animate-pulse"})]})]}):(0,d.jsx)("div",{className:"animate-in fade-in duration-300 lg:flex lg:min-h-0 lg:flex-1 lg:flex-col lg:h-full",children:(0,d.jsx)(g.i,{course:s??void 0,categories:b,instructors:m,onSubmit:u,onCancel:()=>{(0,l.yK)("/admin/courses",a)},isLoading:q})})}}};