"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[35609],{10133:(e,t,r)=>{r.d(t,{C_:()=>g,D9:()=>d,J4:()=>c,OM:()=>n,PG:()=>s,RD:()=>l,Wp:()=>S,YG:()=>u,kw:()=>p,tR:()=>m,zs:()=>h});var a=r(59185),i=r(76541),o=r(16099);let n=async e=>{try{let t=(await i.uE.get(o.Sn.COURSES.LIST,{params:e})).data;if(t.success&&t.data)return{data:t.data,pagination:t.pagination||{page:e?.page||1,limit:e?.limit||10,total:t.data.length,pages:1}};throw Error("Failed to fetch courses")}catch(e){throw Error((0,i.hS)(e))}},s=async e=>{try{let t=(await i.uE.get(o.Sn.COURSES.FILTER,{params:e})).data;if(t.success&&t.data)return{data:t.data,pagination:t.pagination||{page:e?.page||1,limit:e?.limit||10,total:t.data.length,pages:1}};throw Error("Failed to filter courses")}catch(e){throw Error((0,i.hS)(e))}},d=async()=>{try{let e=(await i.uE.get(o.Sn.COURSES.FEATURED_LIST)).data;if(e?.success&&Array.isArray(e.data)||Array.isArray(e?.data))return e.data;return[]}catch(e){return console.error("getFeaturedCourses error:",e),[]}},p=async()=>{try{let e=await i.uE.get(o.Sn.COURSES.ONGOING);return(0,i.yH)(e)}catch(e){throw Error((0,i.hS)(e))}},l=async()=>{try{return(await n({status:"UPCOMING_EVENTS",limit:20})).data||[]}catch{return[]}},u=async e=>{try{let t=await i.uE.get(o.Sn.COURSES.BY_ID(e)),r=t.data;if(r.success&&r.data)return r.data;return(0,i.yH)(t)}catch(e){throw Error((0,i.hS)(e))}},g=async e=>{try{if(e.onProgress?.(0),!e.title||!e.title.trim())throw Error("Title is required");let t=new FormData;t.append("title",e.title.trim()),e.instructorIds?.length&&t.append("instructorIds",JSON.stringify(e.instructorIds)),e.instructorId?.trim()&&t.append("instructorId",e.instructorId.trim()),e.slug&&t.append("slug",e.slug.trim()),e.description&&t.append("description",e.description),e.shortDescription&&t.append("shortDescription",e.shortDescription),e.thumbnail&&!e.thumbnailFile&&t.append("thumbnail",e.thumbnail),void 0!==e.price&&t.append("price",e.price.toString()),void 0!==e.originalPrice&&t.append("originalPrice",e.originalPrice.toString()),void 0!==e.isFree&&t.append("isFree",e.isFree.toString()),t.append("status",e.status||"PUBLISHED"),e.audienceType&&t.append("audienceType",e.audienceType),e.level&&t.append("level",e.level),void 0!==e.duration&&t.append("duration",e.duration.toString()),e.language&&t.append("language",e.language),void 0!==e.featured&&t.append("featured",e.featured.toString()),void 0!==e.isOngoing&&t.append("isOngoing",e.isOngoing.toString()),void 0!==e.startDate&&e.startDate&&t.append("startDate",e.startDate),void 0!==e.endDate&&e.endDate&&t.append("endDate",e.endDate),e.tags&&t.append("tags",e.tags),e.learningOutcomes&&Array.isArray(e.learningOutcomes)&&t.append("learningOutcomes",JSON.stringify(e.learningOutcomes)),e.skills&&Array.isArray(e.skills)&&t.append("skills",JSON.stringify(e.skills)),e.promoVideoSlots&&e.promoVideoSlots.length>0?(t.append("promoVideoSlots",JSON.stringify(e.promoVideoSlots)),e.videoFiles?.forEach(e=>t.append("video",e))):e.videoUrl&&e.videoUrl.trim()&&t.append("videoUrl",e.videoUrl.trim()),e.categoryId&&e.categoryId.trim()&&t.append("categoryId",e.categoryId.trim()),e.thumbnailFile&&t.append("thumbnail",e.thumbnailFile),!e.promoVideoSlots?.length&&e.videoFile&&t.append("video",e.videoFile),e.onProgress?.(0);let r=e.videoFile||e.thumbnailFile||e.videoFiles&&e.videoFiles.length>0,a=await i.uE.post(o.Sn.COURSES.LIST,t,{headers:{"Content-Type":"multipart/form-data"},timeout:r?72e5:12e4,onUploadProgress:t=>{if(e.onProgress){if(null!=t.total&&t.total>0){let r=Math.round(t.loaded/t.total*100);e.onProgress(Math.min(r,99))}else if(null!=t.loaded){let r=t.loaded/1048576,a=5+90*Math.min(1,r/200);e.onProgress(Math.min(Math.round(a),99))}}}});return e.onProgress?.(100),(0,i.yH)(a)}catch(t){if(a.A.isAxiosError(t)){if(console.error("Course creation error details:",{status:t.response?.status,statusText:t.response?.statusText,data:t.response?.data,message:t.message,requestData:{title:e.title,instructorId:e.instructorId,hasThumbnail:!!e.thumbnailFile}}),"ECONNABORTED"===t.code||t.message?.includes("timeout"))throw Error("Upload took too long. For 300MB+ videos use a fast connection or try a smaller file. You can also add the video later from the course edit page.");if(t.response?.status===408)throw Error("Request timed out during file upload. Please try again.");if(t.response?.status===400){let e=t.response.data;if(e?.errors&&Array.isArray(e.errors)&&e.errors.length>0){let t=e.errors.map(e=>{let t=e.param||e.path||e.field||"field",r=e.msg||e.message||"Invalid value";return`${t}: ${r}`}).join("\n");throw Error(`Validation failed:
${t}`)}throw Error((0,i.hS)(t))}if(t.response?.status===503)throw Error((0,i.hS)(t));if(!t.response)throw Error("Network error. Please check your internet connection and try again.")}throw Error((0,i.hS)(t))}},c=async(e,t)=>{try{let r=new FormData;t.title&&r.append("title",t.title.trim()),t.slug&&r.append("slug",t.slug),void 0!==t.description&&r.append("description",t.description),void 0!==t.shortDescription&&r.append("shortDescription",t.shortDescription),t.thumbnail&&!t.thumbnailFile&&r.append("thumbnail",t.thumbnail),void 0!==t.price&&r.append("price",t.price.toString()),void 0!==t.originalPrice&&r.append("originalPrice",t.originalPrice.toString()),void 0!==t.isFree&&r.append("isFree",t.isFree.toString()),void 0!==t.status&&r.append("status",t.status),void 0!==t.audienceType&&r.append("audienceType",t.audienceType||""),t.level&&r.append("level",t.level),void 0!==t.duration&&r.append("duration",t.duration.toString()),t.language&&r.append("language",t.language),void 0!==t.featured&&r.append("featured",t.featured.toString()),void 0!==t.isOngoing&&r.append("isOngoing",t.isOngoing.toString()),void 0!==t.startDate&&r.append("startDate",t.startDate||""),void 0!==t.endDate&&r.append("endDate",t.endDate||""),void 0!==t.tags&&r.append("tags",t.tags),t.promoVideoSlots&&t.promoVideoSlots.length>0?(r.append("promoVideoSlots",JSON.stringify(t.promoVideoSlots)),t.videoFiles?.forEach(e=>r.append("video",e))):t.promoVideoSlots&&0===t.promoVideoSlots.length?r.append("promoVideoSlots","[]"):void 0!==t.videoUrl&&r.append("videoUrl",null!==t.videoUrl?String(t.videoUrl).trim():""),void 0!==t.learningOutcomes&&(Array.isArray(t.learningOutcomes)&&t.learningOutcomes.length>0?r.append("learningOutcomes",JSON.stringify(t.learningOutcomes)):r.append("learningOutcomes","")),void 0!==t.skills&&(Array.isArray(t.skills)&&t.skills.length>0?r.append("skills",JSON.stringify(t.skills)):r.append("skills","")),t.instructorIds?.length&&r.append("instructorIds",JSON.stringify(t.instructorIds)),t.instructorId&&r.append("instructorId",t.instructorId.trim()),void 0!==t.categoryId&&r.append("categoryId",t.categoryId||""),t.thumbnailFile&&r.append("thumbnail",t.thumbnailFile),!t.promoVideoSlots?.length&&t.videoFile&&r.append("video",t.videoFile);let a=t.onProgress;a?.(0);let n=t.thumbnailFile||t.videoFile||t.videoFiles&&t.videoFiles.length>0,s=await i.uE.put(o.Sn.COURSES.BY_ID(e),r,{headers:{"Content-Type":"multipart/form-data"},timeout:n?72e5:6e4,onUploadProgress:e=>{if(a){if(null!=e.total&&e.total>0){let t=Math.round(e.loaded/e.total*100);a(Math.min(t,99))}else if(null!=e.loaded){let t=e.loaded/1048576,r=5+90*Math.min(1,t/200);a(Math.min(Math.round(r),99))}}}});return a?.(100),(0,i.yH)(s)}catch(e){if(a.A.isAxiosError(e)&&e.response?.status===400){let t=e.response.data;if(t?.errors&&Array.isArray(t.errors)&&t.errors.length>0){let e=t.errors.map(e=>{let t=e.param||e.path||e.field||"field",r=e.msg||e.message||"Invalid value";return`${t}: ${r}`}).join("\n");throw Error(`Validation failed:
${e}`)}}throw a.A.isAxiosError(e)&&e.response?.status,Error((0,i.hS)(e))}},m=async(e,t)=>{try{let r=(await i.uE.patch(o.Sn.COURSES.FEATURED(e),{featured:t})).data;if(r.success&&r.data)return r.data;throw Error(r.message||"Failed to update popular")}catch(e){throw Error((0,i.hS)(e))}},h=async e=>{try{await i.uE.delete(o.Sn.COURSES.BY_ID(e))}catch(e){throw Error((0,i.hS)(e))}},S=async(e,t)=>{try{let r=(await i.uE.post(o.Sn.COURSES.CERTIFICATE_TEMPLATE(e),t,{headers:{"Content-Type":"multipart/form-data"}})).data;if(r.success&&r.data)return r.data;throw Error(r.message||"Failed to upload certificate template")}catch(e){throw Error((0,i.hS)(e))}}},82181:(e,t,r)=>{r.d(t,{GW:()=>d,aN:()=>n,fI:()=>p,ow:()=>s,r$:()=>l,t1:()=>o});var a=r(76541),i=r(16099);let o=async e=>{try{let t=(await a.uE.get(i.Sn.TESTIMONIALS.LIST,{params:e})).data;if(t.success&&t.data)return{data:t.data,pagination:t.pagination||{page:e?.page||1,limit:e?.limit||10,total:t.data.length,pages:1}};throw Error("Failed to fetch testimonials")}catch(e){throw Error((0,a.hS)(e))}},n=async e=>{try{let t=await a.uE.get(i.Sn.TESTIMONIALS.BY_ID(e));return(0,a.yH)(t)}catch(e){throw Error((0,a.hS)(e))}},s=async e=>{try{let t={...e};e?.isPublished!==void 0&&(t.isPublished=String(e.isPublished));let r=(await a.uE.get(i.Sn.TESTIMONIALS.LIST,{params:t})).data;if(r.success&&r.data)return{data:r.data,pagination:r.pagination||{page:e?.page||1,limit:e?.limit||10,total:r.data.length,pages:1}};throw Error("Failed to fetch testimonials")}catch(e){throw Error((0,a.hS)(e))}},d=async e=>{try{let t=new FormData;t.append("name",e.name.trim()),e.comment&&t.append("comment",e.comment),e.audienceType&&t.append("audienceType",e.audienceType),e.designation&&t.append("designation",e.designation.trim()),e.company&&t.append("company",e.company.trim()),void 0!==e.rating&&t.append("rating",e.rating.toString()),e.courseId&&t.append("courseId",e.courseId),void 0!==e.isPublished&&t.append("isPublished",e.isPublished.toString()),void 0!==e.featured&&t.append("featured",e.featured.toString()),void 0!==e.order&&t.append("order",e.order.toString()),e.image&&!e.imageFile&&t.append("image",e.image),e.imageFile&&t.append("image",e.imageFile);let r=await a.uE.post(i.Sn.TESTIMONIALS.LIST,t,{headers:{"Content-Type":"multipart/form-data"}});return(0,a.yH)(r)}catch(e){throw Error((0,a.hS)(e))}},p=async(e,t)=>{try{let r=new FormData;t.name&&r.append("name",t.name.trim()),void 0!==t.comment&&r.append("comment",t.comment),void 0!==t.audienceType&&r.append("audienceType",t.audienceType),void 0!==t.designation&&r.append("designation",t.designation?.trim()||""),void 0!==t.company&&r.append("company",t.company?.trim()||""),void 0!==t.rating&&r.append("rating",t.rating.toString()),void 0!==t.courseId&&r.append("courseId",t.courseId||""),void 0!==t.isPublished&&r.append("isPublished",t.isPublished.toString()),void 0!==t.featured&&r.append("featured",t.featured.toString()),void 0!==t.order&&r.append("order",t.order.toString()),t.image&&!t.imageFile&&r.append("image",t.image),t.imageFile&&r.append("image",t.imageFile);let o=await a.uE.put(i.Sn.TESTIMONIALS.BY_ID(e),r,{headers:{"Content-Type":"multipart/form-data"}});return(0,a.yH)(o)}catch(e){throw Error((0,a.hS)(e))}},l=async e=>{try{await a.uE.delete(i.Sn.TESTIMONIALS.BY_ID(e))}catch(e){throw Error((0,a.hS)(e))}}}}]);