PageSourceSearch

https://weversity.org/assets/NewCoursePage-DxyYvzrE.js

js weversity.org collected 2026-10-02 01:09:34 UTC 154,737 bytes, 11 lines download raw bytes

1import{j as e}from"./index-A5apO8sf.js";import{r as a,R as hs,j as Ks,i as Zs,u as Xs}from"./vendor-react-DXfu0YkJ.js";import{U as rs,s as Js}from"./UniversalBlockEditor-Cy2PN-eD.js";import{C as et}from"./CourseCard-CQsp0Guw.js";import{z as Je,X as Qe,T as st,az as tt}from"./vendor-icons-DAn0tkMA.js";import{D as it,C as gs,P as ps}from"./vendor-ui--7kLNIgQ.js";import{S as Ns,L as _s,B as Cs}from"./index-B47Se-dG.js";import{D as rt}from"./DashboardTour-DkBUbC_C.js";import"./vendor-pdf-v-sEuCgt.js";import"./vendor-supabase-BVvKO2AB.js";import"./vendor-charts-odGm-fv0.js";/* empty css                   */import"./PhoneInput-C3fIbpmz.js";import"./utils-B3zyFVls.js";import"./imageOptimizer-BilA4UWN.js";import"./OptimizedImage-6JiG88Oe.js";const at=()=>e.jsx("svg",{className:"w-3 h-3 text-red-500",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 0L9.8 6.2H16L10.9 9.8L12.7 16L8 12.4L3.3 16L5.1 9.8L0 6.2H6.2L8 0Z"})}),nt=()=>e.jsx("svg",{className:"w-5 h-5 text-purple-500 ml-1",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{d:"M10 2.5L11.5 8.5L17.5 10L11.5 11.5L10 17.5L8.5 11.5L2.5 10L8.5 8.5L10 2.5Z"})}),lt=()=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]}),fs=()=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),ot=()=>e.jsx("svg",{className:"w-10 h-10 text-gray-400 mx-auto",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),bs=()=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),dt=()=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),ys=({checked:s,onChange:r})=>e.jsx("button",{type:"button",className:`${s?"bg-indigo-600":"bg-gray-200"} relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500`,onClick:()=>r(!s),children:e.jsx("span",{className:`${s?"translate-x-6":"translate-x-1"} inline-block h-4 w-4 transform rounded-full bg-white transition-transform`})}),oe=({label:s,children:r,required:l,labelIcon:y})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:e.jsxs("div",{className:"flex items-center",children:[s,l&&e.jsx(at,{}),y]})}),r]}),es=({id:s,name:r,label:l,checked:y,onChange:n})=>e.jsxs("label",{htmlFor:s,className:"flex items-center cursor-pointer",children:[e.jsx("input",{type:"radio",id:s,name:r,checked:y,onChange:n,className:"h-4 w-4 text-indigo-600 border-gray-300 focus:ring-indigo-500"}),e.jsx("span",{className:"ml-3 text-sm text-gray-700",children:l})]}),ct=({courseData:s,setCourseData:r,allCategories:l,allInstructors:y,allFacilities:n,setIsCategoryModalOpen:_,session:o,imagePreview:g,handleImageChange:f,onLiveClassesToggle:v})=>{const[I,P]=a.useState(""),[O,k]=a.useState("general"),[Z,V]=a.useState(""),[ke,te]=a.useState(!1),de=a.useRef(null),[ie,pe]=a.useState(!1),ce=a.useRef(null),[ue,S]=a.useState(""),w=["English","Chinese","Urdu/Hindi"],[T,H]=a.use
1State(!1);a.useEffect(()=>{if(!T&&s.title&&!s.id){const t=s.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");r(i=>({...i,slug:t})),V(`https://weversity.org/course/${t}`)}else{const t=s.slug||s.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");V(`https://weversity.org/course/${t||"new-course"}`)}},[s.title,T,s.slug,s.id,r]),a.useEffect(()=>{const t=i=>{de.current&&!de.current.contains(i.target)&&te(!1),ce.current&&!ce.current.contains(i.target)&&pe(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]);const[R,d]=a.useState(!1),[M,F]=a.useState([]),[D,Y]=a.useState(!1),[p,C]=a.useState({facilityId:"",roomName:"",sessions:10,minutes:60,hourlyRate:10,sessionDates:[]}),[se,re]=a.useState(null);a.useEffect(()=>{(async()=>{var i;if(window.supabase){Y(!0);try{const{data:u,error:m}=await window.supabase.from("form_submissions").select("*").eq("form_type","skill_center_host").eq("status","approved");if(!m&&u){F(u);const b=s.center_id;if(b)C(N=>({...N,facilityId:N.facilityId||String(b)}));else if((i=o==null?void 0:o.user)!=null&&i.id){const N=u.find(z=>z.user_id===o.user.id);N&&C(z=>({...z,facilityId:z.facilityId||String(N.id)}))}}}catch(u){console.error("Error fetching skill centers:",u)}finally{Y(!1)}}})()},[]);const fe=t=>{var m;const i=M.find(b=>String(b.id)===String(t)),u=((m=i==null?void 0:i.data)==null?void 0:m.rooms)||[];C(b=>({...b,facilityId:t,roomName:u.length>0?u[0].name:"",sessionDates:t==="remote_only"?b.sessionDates.map(N=>({...N,type:"live"})):b.sessionDates}))},me=t=>{r(i=>({...i,isPhysical:t,physicalLocations:t?i.physicalLocations||[]:[],facilityId:t?i.facilityId:null,physicalSessionsCount:t?i.physicalSessionsCount:0,sessionDurationHours:t?i.sessionDurationHours:0,facilityFee:t?i.facilityFee:0,price:i.basePrice})),t&&v&&v()},Se=()=>{var xe,Ie;const t=p.sessionDates.slice(0,p.sessions).filter(q=>(q==null?void 0:q.type)==="physical"||(q==null?void 0:q.type)==="hybrid").length,i=p.sessionDates.slice(0,p.sessions).filter(q=>(q==null?void 0:q.type)==="live"||(q==null?void 0:q.type)==="hybrid").length,u=Number((p.hourlyRate*(p.minutes/60)).toFixed(2));let m="Physical Center",b=0,N=p.facilityId||"unknown_center";if(p.facilityId){const q=M.find(E=>String(E.id)===String(p.facilityId));if(q){if(m=((xe=q.data)==null?void 0:xe.centerName)||"Skill Center",p.roomName&&((Ie=q.data)!=null&&Ie.rooms)){const E=q.data.rooms.find(ze=>ze.name===p.roomName);E&&(b=Number(E.price||0)/24)}}else{const E=n.find(ze=>String(ze.id)===String(p.facilityId));E&&(m=E.name,b=E.per_hour_fee||0)}N=p.roomName?`${p.facilityId}:${p.roomName}`:p.facilityId}const z=[],Q=p.sessions;if(Q>0){if(t>0&&(!p.facilityId||p.facilityId==="remote_only")){alert("You have physical sessions but no physical Skill Center is selected. Please select a center.");return}let q=p.facilityId&&p.facilityId!=="remote_only"?N:"live_google_meet",E=m;t>0&&i>0?E=`${m} & Live Google Meet`:t===0&&(E="Live Google Meet Session"),z.push({facility_id:q,physical_sessions_count:Q,session_duration_hours:Number((p.minutes/60).toFixed(4)),facility_fee:u,base_price:u*Q,facility_name:E,per_hour_fee:t>0?b:0})}r(q=>{const E=q.physicalLocations||[],h=[...se?E.filter(W=>String(W.facility_id)!==String(se)):E.filter(W=>String(W.facility_id)!==(p.facilityId&&p.facilityId!=="remote_only"?N:"live_google_meet")),...z],L=h[0]||{},Ne=[...p.sessionDates.slice(0,p.sessions).map((W,Te)=>{const Re=(W==null?void 0:W.type)==="physical"||(W==null?void 0:W.type)==="hybrid",Ae=(W==null?void 0:W.type)==="hybrid";return{course_id:0,session_number:0,start_date:(W==null?void 0:W.start_date)||"",start_time:(W==null?void 0:W.start_time)||"",status:"scheduled",facility_id:Re?N:"live_google_meet",facility_name:Ae?`${m} & Live Google Meet`:Re?m:"Live Google Meet Session"}})].sort((W,Te)=>{const Re=new Date(`${W.start_date}T${W.start_time||"00:00"}`),Ae=new Date(`${Te.start_date}T${Te.start_time||"00:00"}`);return Re.getTime()-Ae.getTime()}).map((W,Te)=>({...W,session_number:Te+1}));return{...q,physicalLocations:h,facilityId:L.facility_id||null,physicalSessionsCount:L.physical_sessions_count||0,sessionDurationHours:L.session_duration_hours||0,facilityFee:L.facility_fee||0,sessions:Ne}}),d(!1),re(null),setSessionType("physical"),C({facilityId:"",roomName:"",sessions:10,minutes:60,hourlyRate:10,sessionDates:[]})},B=t=>{const[i,u]=String(t.facility_id).split(":"),m=String(t.facility_id)==="live_google_meet";C({facilityId:m?"":i,roomName:u||"",sessions:t.physical_sessions_count||10,minutes:Math.round((t.session_duration_hours||1)*60),hourlyRate:typeof t.facility_fee=="number"?Number((t.facility_fee/(t.session_duration_hours||1)).toFixed(2)):10,sessionDates:(s.sessions||[]).map(b=>{var N;return{start_date:b.start_date,start_time:b.start_time,type:b.facility_id==="live_google_meet"?"live":(N=b.facility_name)!=null&&N.includes("Live Google Meet")?"hybrid":"physical"}})}),re(t.facility_id||null),d(!0)},Le=t=>{r(i=>{const u=(i.physicalLocations||[]).filter(N=>String(N.facility_id)!==String(t));if(u.length===0)return{...i,physicalLocations:[],facilityId:null,physicalSessionsCount:0,sessionDurationHours:0,facilityFee:0,price:i.basePrice};const m=u[0],b=(i.sessions||[]).filter(N=>N.facility_id!==String(t)).sort((N,z)=>{const Q=new Date(`${N.start_date}T${N.start_time||"00:00"}`),xe=new Date(`${z.start_date}T${z.start_time||"00:00"}`);return Q.getTime()-xe.getTime()}).map((N,z)=>({...N,session_number:z+1}));return{...i,physicalLocations:u,facilityId:m.facility_id,physicalSessionsCount:m.physical_sessions_count,sessionDurationHours:m.session_duration_hours,facilityFee:m.facility_fee,sessions:b}})},ve=t=>{t.key==="Enter"&&I.trim()!==""&&(t.preventDefault(),s.tags.includes(I.trim())||r(i=>({...i,tags:[...i.tags,I.trim()]})),P(""))},be=t=>{r(i=>({...i,tags:i.tags.filter(u=>u!==t)}))};y.filter(t=>t.id!==s.selectedAuthorId&&!s.selectedInstructors.some(i=>i.id===t.id)&&(!ue||`${t.first_name} ${t.last_name}`.toLowerCase().includes(ue.toLowerCase())||t.username&&t.username.toLowerCase().includes(ue.toLowerCase())));const ye=t=>{r(i=>
1({...i,selectedCategories:i.selectedCategories.includes(t)?i.selectedCategories.filter(u=>u!==t):[...i.selectedCategories,t]}))},ne=y.find(t=>t.id===s.selectedAuthorId),we=t=>`flex-1 lg:flex-initial lg:w-full text-left px-4 py-3 text-sm font-medium flex items-center justify-center lg:justify-start space-x-3 transition-colors ${O===t?"bg-indigo-50 text-indigo-700 border-b-2 lg:border-b-0 lg:border-l-4 border-indigo-500":"text-gray-600 hover:bg-gray-50 border-b-2 lg:border-b-0 lg:border-l-4 border-transparent"}`,je={id:s.id||0,created_at:new Date().toISOString(),title:s.title||"Your Awesome Course Title",imageUrl:g||"https://placehold.co/400x225/E9D5FF/6D28D9?text=Featured+Image",author:ne?`${ne.first_name} ${ne.last_name}`.trim():"Instructor Name",authorAvatar:(ne==null?void 0:ne.avatar_url)||"",level:s.level,price:s.price,rating:0,reviews:0,duration:`${s.courseHours||0}h ${s.courseMinutes||0}m`,lessons:s.curriculum.reduce((t,i)=>t+i.items.length,0),categories:s.selectedCategories.join(", "),type:s.type};return e.jsxs("form",{onSubmit:t=>t.preventDefault(),className:"grid grid-cols-1 lg:grid-cols-3 gap-8 max-w-7xl mx-auto",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-8",children:[e.jsxs("div",{className:"bg-white p-6 rounded-lg shadow-sm border border-gray-200",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[e.jsx("div",{id:"tour-field-title",children:e.jsx(oe,{label:"Title",required:!0,children:e.jsx("input",{type:"text",placeholder:"Course Title",value:s.title,onChange:t=>r(i=>({...i,title:t.target.value})),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500 disabled:bg-gray-100 disabled:text-gray-500 disabled:cursor-not-allowed"})})}),e.jsx("div",{id:"tour-field-language",children:e.jsx(oe,{label:"Language",required:!0,children:e.jsx("select",{value:s.language,onChange:t=>r(i=>({...i,language:t.target.value})),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500 bg-white",children:w.map(t=>e.jsx("option",{value:t,children:t},t))})})})]}),e.jsxs("div",{id:"tour-field-url",className:"mb-4",children:[e.jsx(oe,{label:"Course URL (Slug)",required:!0,children:e.jsxs("div",{className:"flex rounded-lg shadow-sm border border-gray-300 focus-within:ring-1 focus-within:ring-indigo-500 focus-within:border-indigo-500 overflow-hidden",children:[e.jsx("span",{className:"inline-flex items-center px-3 bg-gray-50 text-gray-500 sm:text-sm border-r border-gray-300 select-none",children:"weversity.org/course/"}),e.jsx("input",{type:"text",value:s.slug||"",onChange:t=>{H(!0);const i=t.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"");r(u=>({...u,slug:i}))},className:"flex-1 min-w-0 block w-full px-3 py-2 sm:text-sm focus:outline-none text-indigo-600 font-medium bg-white",placeholder:"your-course-link"})]})}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"This is the public link to your course. You can customize it to be shorter or more SEO friendly."})]}),e.jsx("div",{className:"mt-6",id:"tour-field-description",children:e.jsx(oe,{label:"Description",required:!0,children:e.jsx("div",{className:"min-h-[300px]",children:e.jsx(rs,{initialContent:s.description,onChange:t=>r(i=>({...i,description:t})),uploadFolder:"weversity_courses"},`desc-editor-${s.id||"new"}`)})})})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200",id:"tour-field-options",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-800 p-6 border-b",children:"Options"}),e.jsxs("div",{className:"flex flex-col lg:flex-row",children:[e.jsxs("div",{className:"flex flex-row lg:flex-col lg:w-1/3 border-b lg:border-r lg:border-b-0",children:[e.jsxs("button",{onClick:()=>k("general"),className:we("general"),children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),e.jsx("span",{className:"hidden sm:inline",children:"General"})]}),e.jsxs("button",{onClick:()=>k("enrollment"),className:we("enrollment"),children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h5V4H4zm0 12h5v-5H4v5zm12 0h5v-5h-5v5zm0-12h5V4h-5v5z"})}),e.jsx("span",{className:"hidden sm:inline",children:"Enrollment"})]}),e.jsxs("button",{onClick:()=>k("physical"),className:we("physical"),children:[e.jsx(Je,{size:20}),e.jsx("span",{className:"hidden sm:inline",children:"Live Classes"})]})]}),e.jsxs("div",{className:"w-full lg:w-2/3 p-6 min-h-[24rem]",children:[O==="general"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(oe,{label:"Difficulty Level",required:!0,children:e.jsxs("select",{value:s.level,onChange:t=>r(i=>({...i,level:t.target.value})),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500 bg-white",children:[e.jsx("option",{children:"Beginner"}),e.jsx("option",{children:"Intermediate"}),e.jsx("option",{children:"Expert"})]})}),e.jsx(oe,{label:"Course Type",required:!0,labelIcon:e.jsx(fs,{}
1),children:e.jsxs("select",{value:s.type,onChange:t=>r(i=>({...i,type:t.target.value})),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500 bg-white",children:[e.jsx("option",{value:"Skill",children:"Skill (Creative/Non-Technical)"}),e.jsx("option",{value:"Technical",children:"Technical (Coding/Software)"})]})})]}),O==="enrollment"&&e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"maxStudents",className:"flex items-center text-sm font-medium text-gray-700 mb-2",children:["Maximum Student",e.jsx("span",{className:"ml-1.5",title:"Set the maximum number of students that can enroll in this course. Set 0 for no limits.",children:e.jsx(fs,{})})]}),e.jsx("input",{type:"number",id:"maxStudents",value:s.maxStudents,onChange:t=>{const i=Number(t.target.value);i<=1e3?r(u=>({...u,maxStudents:i>=0?i:0})):alert("Maximum students cannot exceed 1000")},className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500",min:"0",max:"1000"})]}),O==="physical"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-5 bg-gradient-to-r from-indigo-50 to-purple-50 rounded-[15px] border border-indigo-100 shadow-sm transition-all duration-300",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-extrabold text-indigo-900 leading-tight",children:"Live Classes Option"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Offer Live Sessions for this Course (Remote or from Physical Location)"})]}),e.jsx(ys,{checked:s.isPhysical,onChange:me})]}),s.isPhysical&&e.jsxs("div",{className:"space-y-6 animate-in fade-in slide-in-from-top-2 duration-300",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-bold text-gray-800",children:"Learning Centers & Locations"}),e.jsxs("button",{type:"button",onClick:()=>{var t;if(R)re(null),C({facilityId:"",roomName:"",sessions:10,minutes:60,hourlyRate:10,sessionDates:[]});else{const i=(t=(s.physicalLocations||[]).find(b=>b.facility_id&&b.facility_id!=="live_google_meet"&&b.facility_id!=="remote_only"))==null?void 0:t.facility_id,u=i?String(i).split(":")[0]:null,m=s.center_id||u||"";C({facilityId:m,roomName:"",sessions:10,minutes:60,hourlyRate:10,sessionDates:[]})}d(!R)},className:"flex items-center gap-1 text-xs font-bold text-indigo-600 bg-indigo-50 hover:bg-indigo-100 px-3 py-1.5 rounded-lg transition-all",children:[R?e.jsx(Qe,{className:"w-4 h-4"}):e.jsx(bs,{})," ",R?"Cancel":se?"Cancel Edit":"Add Location"]})]}),R&&e.jsxs("div",{className:"p-5 bg-white rounded-[15px] border-2 border-dashed border-indigo-200 space-y-4 shadow-inner animate-in zoom-in-95 duration-200",children:[e.jsxs("h5",{className:"text-xs font-black uppercase tracking-widest text-indigo-500",children:[se?"Edit":"Configure"," Learning Center"]}),e.jsx(oe,{label:s.center_id?"Assigned Skill Center":"Select Skill Center (Optional)",children:e.jsxs("select",{value:p.facilityId,onChange:t=>fe(t.target.value),className:`w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500 bg-white font-medium ${s.center_id?"opacity-75 cursor-not-allowed bg-gray-50":""}`,disabled:!!s.center_id,children:[e.jsx("option",{value:"",children:"Select a skill center..."}),!s.center_id&&e.jsx("option",{value:"remote_only",children:"Remote Sessions Only (Not from a physical center)"}),D?e.jsx("option",{disabled:!0,children:"Loading skill centers..."}):M.filter(t=>{var N;const i=s.center_id,u=(N=(s.physicalLocations||[]).find(z=>z.facility_id&&z.facility_id!=="live_google_meet"&&z.facility_id!=="remote_only"))==null?void 0:N.facility_id,m=u?String(u).split(":")[0]:null,b=i||m;return b?String(t.id)===String(b):!0}).map(t=>{var i,u;return e.jsxs("option",{value:t.id,children:[((i=t.data)==null?void 0:i.centerName)||"Unnamed Center"," - ",((u=t.data)==null?void 0:u.address)||""]},t.id)})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(oe,{label:"Number of Sessions",required:!0,children:e.jsx("input",{type:"number",min:"1",value:p.sessions,onChange:t=>C(i=>({...i,sessions:Math.max(1,parseInt(t.target.value)||1)})),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500"})}),e.jsx(oe,{label:"Session Duration (Minutes)",required:!0,children:e.jsx("input",{type:"number",min:"1",value:p.minutes,onChange:t=>C(i=>({...i,minutes:Math.max(1,parseInt(t.target.value)||1)})),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500"})})]}),e.jsx(oe,{label:"Per Session Fee (for 60 mins) (USD)",required:!0,children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:e.jsx("span",{className:"text-gray-500 sm:text-sm",children:"$"})}),e.jsx("input",{type:"number",min:"0",step:"0.01",value:p.hourlyRate,onChange:t=>C(i=>({...i,hourlyRate:Math.max(0,parseFloat(t.target.value)||0)})),className:"w-full pl-7 pr-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500"})]})}),(()=>{var z;let t=0;const i=p.facilityId?M.find(Q=>String(Q.id)===String(p.facilityId)):null;if(i){if(p.roomName&&((z=i.data)!=null&&z.rooms)){const Q=i.data.rooms.find(xe=>xe.name===p.roomName);Q&&(t=Number(Q.price||0)/24)}}else if(p.facilityId){const Q=n.find(xe=>String(xe.id)===String(p.facilityId));Q&&(t=Q.per_hour_fee||0)}const u=p.sessionDates.slice(0,p.sessions).filter(Q=>(Q==null?void 0:Q.type)==="physical"||(Q==null?void 0:Q.type)==="hybrid").length,m=t*u*(p.minutes/60),N=Number((p.hourlyRate*(p.minutes/60)).toFixed(2))*p.sessions;return e.jsxs("div",{className:"p-4 bg-indigo-50 rounded-xl border border-indigo-100 space-y-2 text-xs",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("span",{className:"text-gray-500",children:["Location Base Price (",p.sessions," sessions × ",p.minutes," mins)"]}),e.jsxs("span",{className:"font-bold text-gray-900",children:["$",N.toFixed(2)]})]}),e.jsxs("div",{className:"pt-2 border-t border-indigo-200 flex justify-between items-center text-sm",children:[e.jsx("span",{className:"font-extrabold text-indigo-900",children:"Estimated Student Price"}),e.jsxs("span",{className:"font-black text-indigo-700",children:["$",(N+m).toFixed(2)]})]})]})})(),e.jsxs("div",{className:"pt-4 border-t border-gray-100",children:[e.jsx("h4",{className:"text-sm font-bold text-gray-800 mb
1-4",children:"Session Schedule"}),e.jsxs("p",{className:"text-xs text-gray-500 mb-4",children:["Configure the date and time for all ",p.sessions," sessions."]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:Array.from({length:p.sessions}).map((t,i)=>{const u=p.sessionDates[i]||{start_date:"",start_time:"",type:"live"};return e.jsxs("div",{className:"p-4 bg-gray-50 border border-gray-200 rounded-lg space-y-3",children:[e.jsx("div",{className:"text-xs font-black uppercase text-indigo-500 tracking-widest mb-2 flex justify-between items-center",children:e.jsxs("span",{children:["Session ",i+1]})}),e.jsxs("div",{className:"flex flex-col gap-2 mb-3",children:[e.jsx(es,{id:`type_live_${i}`,name:`sessionType_${i}`,label:"Live Google Meet",checked:u.type==="live"||!u.type,onChange:()=>{const m=[...p.sessionDates];m[i]||(m[i]={start_date:"",start_time:"",type:"live"}),m[i].type="live",C(b=>({...b,sessionDates:m}))}}),p.facilityId!=="remote_only"&&e.jsxs(e.Fragment,{children:[e.jsx(es,{id:`type_physical_${i}`,name:`sessionType_${i}`,label:"Physical Class",checked:u.type==="physical",onChange:()=>{const m=[...p.sessionDates];m[i]||(m[i]={start_date:"",start_time:"",type:"physical"}),m[i].type="physical",C(b=>({...b,sessionDates:m}))}}),e.jsx(es,{id:`type_hybrid_${i}`,name:`sessionType_${i}`,label:"Live + Physical (Hybrid)",checked:u.type==="hybrid",onChange:()=>{const m=[...p.sessionDates];m[i]||(m[i]={start_date:"",start_time:"",type:"hybrid"}),m[i].type="hybrid",C(b=>({...b,sessionDates:m}))}})]})]}),e.jsx(oe,{label:"Date",required:!0,children:e.jsx("input",{type:"date",value:u.start_date,onChange:m=>{const b=[...p.sessionDates];b[i]||(b[i]={start_date:"",start_time:"",type:"live"}),b[i].start_date=m.target.value,C(N=>({...N,sessionDates:b}))},className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500 bg-white"})}),e.jsx(oe,{label:"Time",required:!0,children:e.jsx("input",{type:"time",value:u.start_time,onChange:m=>{const b=[...p.sessionDates];b[i]||(b[i]={start_date:"",start_time:"",type:"live"}),b[i].start_time=m.target.value,C(N=>({...N,sessionDates:b}))},className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500 bg-white"})})]},i)})})]}),e.jsx("button",{type:"button",onClick:Se,className:"w-full py-2.5 bg-indigo-600 hover:bg-indigo-700 text-white text-xs font-black uppercase tracking-widest rounded-lg shadow-md transition-all duration-200",children:"Save Location Config"})]}),!R&&e.jsxs("div",{className:"space-y-3",children:[!s.physicalLocations||s.physicalLocations.length===0?e.jsxs("div",{className:"text-center py-8 border border-dashed border-gray-200 rounded-[15px] bg-gray-50/50",children:[e.jsx(Je,{className:"w-8 h-8 text-gray-300 mx-auto mb-2"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["No skill centers added yet. Click ",e.jsx("strong",{children:"Add Location"})," above."]})]}):s.physicalLocations.map(t=>{var Q;const i=(t.per_hour_fee||0)*(t.physical_sessions_count||1)*(t.session_duration_hours||1),u=(t.base_price||0)+i,[m,b]=String(t.facility_id).split(":"),N=String(t.facility_id)==="live_google_meet";let z=t.facility_name||"";if(!N){const xe=M.find(Ie=>String(Ie.id)===String(m));if(xe)z=((Q=xe.data)==null?void 0:Q.centerName)||"Skill Center";else{const Ie=n.find(q=>String(q.id)===String(m));Ie&&(z=Ie.name)}}return e.jsxs("div",{className:"flex items-center justify-between p-4 bg-white border border-gray-200 hover:border-indigo-300 rounded-[15px] hover:shadow-md transition-all duration-300",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"p-1 bg-indigo-50 rounded-lg text-indigo-600",children:e.jsx(Je,{className:"w-4 h-4"})}),e.jsxs("h5",{className:"text-sm font-bold text-gray-900 flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{children:z||"Skill Center"}),b&&e.jsx("span",{className:"px-2 py-0.5 text-[10px] font-black uppercase text-indigo-600 bg-indigo-50 border border-indigo-100 rounded-full",children:b})]})]}),e.jsxs("p",{className:"text-xs text-gray-500 pl-8",children:[t.physical_sessions_count," sessions × ",Math.round(Number(t.session_duration_hours||0)*60)," mins per session"]}),e.jsx("div",{className:"flex items-center gap-4 text-xs font-semibold text-gray-600 pl-8 pt-1",children:e.jsxs("span",{className:"text-indigo-600 font-extrabold flex items-center",children:["Total Location Fee: $",u.toFixed(2)]})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>B(t),className:"p-2 text-indigo-500 hover:bg-indigo-50 rounded-lg transition-colors",title:"Edit Location",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})})}),e.jsx("button",{type:"button",onClick:()=>Le(t.facility_id),className:"p-2 text-red-500 hover:bg-red-50 rounded-lg transition-colors",title:"Delete Location",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})]},t.facility_id)}),!R&&s.physicalLocations&&s.physicalLocations.length>0&&e.jsxs("div",{className:"mt-6 p-5 bg-blue-50/80 border border-blue-200 rounded-[15p
1x] flex items-start gap-4 animate-in fade-in slide-in-from-bottom-2 shadow-sm",children:[e.jsx("div",{className:"p-2.5 bg-blue-100/80 rounded-xl shrink-0",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-blue-600",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h5",{className:"text-sm font-black uppercase tracking-wider text-blue-900",children:"Next Steps: Review & Go Live"}),e.jsxs("p",{className:"text-xs text-blue-800 leading-relaxed font-medium",children:["After saving this configuration, the Center Owner will review and approve it.",e.jsx("br",{className:"mb-2"}),"Once your course is live, go to the ",e.jsx("strong",{children:"Google Meet"})," tab and select your course. This session will be ready for you with its date, time, and duration locked. You will just need to fill in the remaining details and submit!"]})]})]})]})]})]})]})]})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"font-bold text-lg text-gray-800 mb-4",children:"Course Preview"}),e.jsx(et,{course:je,onEnrollCourse:()=>{},onInstructorNavigate:()=>{},className:"h-fit shadow-none border-gray-200"})]}),e.jsxs("div",{className:"bg-white p-6 rounded-lg shadow-sm border border-gray-200",children:[e.jsx(oe,{label:"Visibility",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:e.jsx(lt,{})}),e.jsxs("select",{defaultValue:"Public",className:"w-full pl-10 pr-10 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500 bg-white appearance-none",children:[e.jsx("option",{children:"Public"}),e.jsx("option",{children:"Private"})]}),e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:e.jsx("svg",{className:"h-5 w-5 text-gray-400",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})}),e.jsxs("p",{className:"text-xs text-gray-500 mt-4",children:["Last updated on ",new Date().toLocaleDateString()]})]}),e.jsxs("div",{className:"bg-white p-4 rounded-lg shadow-sm border border-gray-200",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-base font-medium text-gray-900",children:"Schedule"}),e.jsx(ys,{checked:s.isScheduled,onChange:t=>r(i=>({...i,isScheduled:t}))})]}),s.isScheduled&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-200 space-y-4",children:[e.jsx("div",{className:"flex border border-gray-300 rounded-md overflow-hidden",children:e.jsxs("div",{className:"relative flex-1",children:[e.jsx("span",{className:"absolute inset-y-0 left-0 flex items-center pl-3 text-gray-500 pointer-events-none",children:e.jsx(dt,{})}),e.jsx("input",{type:"datetime-local",value:s.scheduledDate,onChange:t=>r(i=>({...i,scheduledDate:t.target.value})),className:"w-full pl-10 pr-3 py-2 border-none focus:ring-0 text-sm text-gray-700 bg-white"})]})}),e.jsx("div",{children:e.jsxs("label",{className:"flex items-center text-sm text-gray-600",children:[e.jsx("input",{type:"checkbox",checked:!0,disabled:!0,className:"h-4 w-4 text-indigo-600 border-gray-300 rounded focus:ring-indigo-500"}),e.jsx("span",{className:"ml-2",children:"Show coming soon in course list"})]})})]})]}),e.jsx("div",{className:"bg-white p-6 rounded-lg shadow-sm border border-gray-200",id:"tour-field-image",children:e.jsx(oe,{label:"Featured Image",required:!0,labelIcon:e.jsx(nt,{}),children:e.jsxs("div",{className:"border-2 border-dashed border-gray-300 rounded-lg p-6 text-center",children:[g?e.jsx("img",{src:g,alt:"Thumbn
1ail preview",className:"mx-auto max-h-24 mb-4"}):e.jsx(ot,{}),e.jsx("label",{htmlFor:"image-upload",className:"mt-2 cursor-pointer text-sm font-semibold text-indigo-600 bg-indigo-50 px-3 py-1 rounded-lg hover:bg-indigo-100",children:g?"Change Thumbnail":"Upload Thumbnail"}),e.jsx("input",{id:"image-upload",type:"file",className:"hidden",onChange:f,accept:"image/jpeg, image/png, image/gif, image/webp"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"JPEG, PNG, GIF, and WebP formats, up to 64 MB"})]})})}),e.jsx("div",{className:"bg-white p-6 rounded-lg shadow-sm border border-gray-200",id:"tour-field-video",children:e.jsxs(oe,{label:"Intro Video URL",children:[e.jsx("input",{type:"url",placeholder:"e.g., https://www.youtube.com/watch?v=...",value:s.videoUrl,onChange:t=>r(i=>({...i,videoUrl:t.target.value})),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"Paste a video URL from platforms like YouTube or Vimeo."})]})}),e.jsx("div",{className:"bg-white p-6 rounded-lg shadow-sm border border-gray-200",id:"tour-field-pricing",children:e.jsxs(oe,{label:"Pricing Model",children:[e.jsxs("div",{className:"flex space-x-4",children:[e.jsxs("label",{className:"flex items-center",children:[e.jsx("input",{type:"radio",name:"price",value:"Free",checked:s.basePrice===0,onChange:()=>r(t=>({...t,basePrice:0,price:0})),className:"h-4 w-4 text-indigo-600 border-gray-300 focus:ring-indigo-500 disabled:opacity-50"}),e.jsx("span",{className:"ml-2 text-sm",children:"Free"})]}),e.jsxs("label",{className:"flex items-center",children:[e.jsx("input",{type:"radio",name:"price",value:"Paid",checked:s.basePrice>0,onChange:()=>r(t=>({...t,basePrice:10,price:10})),className:"h-4 w-4 text-indigo-600 border-gray-300 focus:ring-indigo-500 disabled:opacity-50"}),e.jsx("span",{className:"ml-2 text-sm",children:"Paid"})]})]}),s.basePrice>0&&e.jsxs("div",{className:"mt-4",children:[e.jsx("label",{htmlFor:"course-price",className:"block text-sm font-medium text-gray-700",children:"Base Course Price (USD)"}),e.jsx("input",{type:"number",id:"course-price",value:s.basePrice,onChange:t=>{const i=parseFloat(t.target.value)||0;r(u=>({...u,basePrice:i,price:i}))},className:"mt-1 w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500 disabled:bg-gray-100 disabled:text-gray-500 disabled:cursor-not-allowed",min:"0",step:"0.01"}),e.jsxs("div",{className:"mt-6 border-t border-gray-200 pt-4",children:[e.jsx("h4",{className:"text-sm font-bold text-gray-800 mb-2",children:"Discount Coupon"}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-400 uppercase tracking-wider mb-1",children:"Coupon Code"}),e.jsx("input",{type:"text",placeholder:"e.g. SUMMER50",value:s.couponCode||"",onChange:t=>r(i=>({...i,couponCode:t.target.value.toUpperCase()})),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-400 uppercase tracking-wider mb-1",children:"Discount Amount ($)"}),e.jsx("input",{type:"number",min:"0",step:"0.01",placeholder:"e.g. 10",value:s.couponDiscount||"",onChange:t=>r(i=>({...i,couponDiscount:parseFloat(t.target.value)||0})),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500"})]})]}),e.jsx("p",{className:"text-[10px] text-gray-400 mt-2 font-medium",children:"Coupons are only applied to the base course price, not facility fees."})]})]})]})}),e.jsxs("div",{className:"bg-white p-6 rounded-lg shadow-sm border border-gray-200",id:"tour-field-certificate",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(st,{className:"w-5 h-5 text-indigo-600"}),e.jsx("h3",{className:"font-bold text-gray-800",children:"Certificate Settings"})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-gray-400 uppercase tracking-wider mb-2",children:"Issuance Model"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 p-1 bg-gray-50 rounded-[15p
1x] border border-gray-100",children:[e.jsx("button",{type:"button",onClick:()=>r(t=>({...t,certificatePrice:0})),className:`flex items-center justify-center gap-2 py-2 text-sm font-bold rounded-lg transition-all ${s.certificatePrice===0?"bg-white text-indigo-600 shadow-sm border border-gray-100":"text-gray-400 hover:text-gray-600"}`,children:"Free"}),e.jsx("button",{type:"button",onClick:()=>r(t=>({...t,certificatePrice:10})),className:`flex items-center justify-center gap-2 py-2 text-sm font-bold rounded-lg transition-all ${s.certificatePrice>0?"bg-white text-indigo-600 shadow-sm border border-gray-100":"text-gray-400 hover:text-gray-600"}`,children:"Paid"})]})]}),s.certificatePrice>0&&e.jsxs("div",{className:"animate-in fade-in slide-in-from-top-2 duration-300",children:[e.jsx("label",{className:"block text-xs font-bold text-gray-400 uppercase tracking-wider mb-2",children:"Certificate Price"}),e.jsxs("div",{className:"relative group",children:[e.jsx("input",{type:"number",value:s.certificatePrice,onChange:t=>r(i=>({...i,certificatePrice:Math.max(0,parseInt(t.target.value)||0)})),className:"w-full pl-11 pr-4 py-3 bg-gray-50 border border-gray-200 rounded-[15px] text-sm font-bold text-gray-700 focus:ring-2 focus:ring-indigo-500/20 focus:border-indigo-500 transition-all outline-none",min:"0"}),e.jsx("div",{className:"absolute left-3.5 top-1/2 -translate-y-1/2 p-1 bg-white rounded-lg shadow-sm border border-gray-100 group-focus-within:scale-110 transition-transform",children:e.jsx("img",{src:"https://res.cloudinary.com/dn93gd6yw/image/upload/f_auto,q_auto/v1772685212/WE_Coin_1_ysxtkd.png",alt:"WeCoin",className:"w-5 h-5"})}),e.jsx("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 text-[10px] font-black text-gray-300 uppercase tracking-widest",children:"WeCoins"})]}),e.jsx("div",{className:"mt-3 p-3 bg-indigo-50/50 rounded-[15px] border border-indigo-100/50",children:e.jsx("p",{className:"text-[10px] leading-relaxed text-indigo-600/70 font-medium",children:"Students must pay this amount to unlock their verified certificate upon course completion."})})]})]})]}),e.jsx("div",{className:"bg-white p-6 rounded-lg shadow-sm border border-gray-200",id:"tour-field-categories",children:e.jsxs(oe,{label:"Categories",required:!0,children:[e.jsx("div",{className:"border border-gray-300 rounded-lg h-48 overflow-y-auto p-2 space-y-2",children:l.length===0?e.jsx("p",{className:"text-sm text-gray-500 p-2",children:"No categories found. Add one below."}):l.map(t=>e.jsxs("label",{className:"flex items-center text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.selectedCategories.includes(t.name),onChange:()=>ye(t.name),className:"h-4 w-4 text-indigo-600 border-gray-300 rounded focus:ring-indigo-500"}),e.jsx("span",{className:"ml-2",children:t.name})]},t.id))}),e.jsxs("button",{type:"button",onClick:()=>_(!0),className:"mt-2 text-sm font-semibold text-indigo-600 hover:text-indigo-800 flex items-center",children:[e.jsx(bs,{}),"Add"]})]})}),e.jsx("div",{className:"bg-white p-6 rounded-lg shadow-sm border border-gray-200",children:e.jsx(oe,{label:"Tags",children:e.jsxs("div",{className:"border border-gray-300 rounded-lg p-2 flex flex-wrap gap-2",children:[s.tags.map(t=>e.jsxs("div",{className:"flex items-center bg-indigo-100 text-indigo-700 text-sm font-semibold px-2 py-1 rounded",children:[t,e.jsx("button",{onClick:()=>be(t),className:"ml-2 text-indigo-500 hover:text-indigo-700",children:"×"})]},t)),e.jsx("input",{type:"text",placeholder:"Add tags",value:I,onChange:t=>P(t.target.value),onKeyDown:ve,className:"flex-grow min-w-[80px] p-1 text-sm focus:outline-none bg-transparent"})]})})})]})]})},ks=()=>e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",className:"text-gray-400 cursor-grab opacity-70 active:cursor-grabbing",children:[e.jsx("circle",{cx:"9",cy:"9",r:"1.5"}),e.jsx("circle",{cx:"15",cy:"9",r:"1.5"}),e.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),e.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),e.jsx("circle",{cx:"9",cy:"15",r:"1.5"}),e.jsx("circle",{cx:"15",cy:"15",r:"1.5"})]}),We=()=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})}),ut=({open:s})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:`h-5 w-5 text-gray-500 transition-transform duration-200 ${s?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})}),Ss=()=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})}),Ls=()=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.5L15.232 5.232z"})}),mt=()=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-green-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})]}),xt=()=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-purple-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),ht=()=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-orange-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})}),gt=({item:s,onEdit:r,onDelete:l,dragHandleProps:y})=>{const n=()=>{switch(s.type){case"lesson":return e.jsx(mt,{});case"quiz":return e.jsx(xt,{});case"assignment":return e.jsx(ht,{});default:return null}};return e.jsxs("div",{className:"flex items-center justify-between gap-3 p-3 bg-white border border-gray-200 rounded-lg hover:shadow-sm transition-all group",children:[e.jsx("div",{...y,className:"flex-shrink-0 cursor-grab text-gray-300 hover:text-gray-500",children:e.jsx(ks,{})}),e.jsxs("div",{className:"flex items-center space-x-3 flex-grow min-w-0",children:[e.jsx("div",{className:"flex-shrink-0 p-1.5 bg-gray-50 rounded-md",children:n()}),e.jsxs("div",{className:"flex-grow min-w-0",children:[e.jsx("span",{className:"text-sm font-medium text-gray-800 break-words line-clamp-1",children:s.title}),e.jsx("span",{className:"text-xs text-gray-500 capitalize",children:s.type})]})]}),e.jsxs("div",{className:"flex items-center space-x-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:r,className:"p-1.5 text-gray-400 hover:text-indigo-600 hover:bg-indigo-50 rounded",title:"Edit",children:e.jsx(Ls,{})}),e.jsx("button",{onClick:l,className:"p-1.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded",title:"Delete",children:e.jsx(Ss,{})})]})]})},pt=({courseId:s,topics:r=[],setTopics:l,onAddLesson:y,onAddQuiz:n,onAddAssignment:_,onEditItem:o,onDeleteItem:g})=>{const[f,v]=a.useState(r.length>0?[r[0].id]:[]),[I,P]=a.useState(null),[O,k]=a.useState(!1),Z=a.useRef(null),V=Array.isArray(r)?r:[],ke=S=>{v(w=>w.includes(S)?w.filter(T=>T!==S):[...w,S])},te=async()=>
1{if(!s||isNaN(s)){alert("Please save course basics first.");return}k(!0);try{const{data:S}=await window.supabase.from("curriculum_topics").select("order").eq("course_id",s).order("order",{ascending:!1}).limit(1).maybeSingle(),w=((S==null?void 0:S.order)??-1)+1,{data:T,error:H}=await window.supabase.from("curriculum_topics").insert({course_id:s,title:"New Section",order:w}).select().single();if(H)throw H;const R={id:T.id,title:T.title,summary:"",items:[]};l([...V,R]),v(d=>[...d,R.id]),P(R.id)}catch(S){alert("Failed to add section: "+S.message)}finally{k(!1)}},de=async(S,w,T)=>{l(V.map(H=>H.id===S?{...H,[w]:T}:H))},ie=async S=>{P(null),await window.supabase.from("curriculum_topics").update({title:S.title}).eq("id",S.id)},pe=async S=>{if(!confirm("Delete this section and everything inside it?"))return;k(!0);const{error:w}=await window.supabase.from("curriculum_topics").delete().eq("id",S);w||(l(V.filter(T=>T.id!==S)),v(T=>T.filter(H=>H!==S))),k(!1)},ce=S=>{const{destination:w,type:T}=S;if(T==="item"&&w){const H=Number(w.droppableId);f.includes(H)||(Z.current&&clearTimeout(Z.current),Z.current=setTimeout(()=>{v(R=>[...R,H])},600))}else Z.current&&(clearTimeout(Z.current),Z.current=null)},ue=async S=>{Z.current&&(clearTimeout(Z.current),Z.current=null);const{source:w,destination:T,type:H}=S;if(T){if(H==="topic"){if(w.index===T.index)return;const R=Array.from(V),[d]=R.splice(w.index,1);R.splice(T.index,0,d),l(R),k(!0);const M=R.map((F,D)=>window.supabase.from("curriculum_topics").update({order:D}).eq("id",Number(F.id)));await Promise.all(M),k(!1);return}if(H==="item"){const R=Number(w.droppableId),d=Number(T.droppableId),M=V.findIndex(C=>C.id===R),F=V.findIndex(C=>C.id===d);if(M===-1||F===-1)return;const D=[...V],Y=Array.from(D[M].items),[p]=Y.splice(w.index,1);if(k(!0),R===d){if(w.index===T.index){k(!1);return}Y.splice(T.index,0,p),D[M]={...D[M],items:Y},l(D);const C=Y.map((se,re)=>window.supabase.from("curriculum_items").update({order:re}).eq("id",Number(se.id)));await Promise.all(C)}else{const C=Array.from(D[F].items);C.splice(T.index,0,p),D[M]={...D[M],items:Y},D[F]={...D[F],items:C},l(D),await window.supabase.from("curriculum_items").update({topic_id:d}).eq("id",Number(p.id));const se=C.map((fe,me)=>window.supabase.from("curriculum_items").update({order:me}).eq("id",Number(fe.id))),re=Y.map((fe,me)=>window.supabase.from("curriculum_items").update({order:me}).eq("id",Number(fe.id)));await Promise.all([...se,...re])}k(!1)}}};return!s||isNaN(s)?e.jsxs("div",{className:"max-w-4xl mx-auto py-20 px-6 bg-white rounded-[15px] border-2 border-dashed border-gray-200 text-center",children:[e.jsx("p",{className:"text-gray-500 mb-8",children:"Please save course basics first to build your curriculum."}),e.jsx("button",{onClick:()=>window.location.reload(),className:"px-8 py-3 bg-brand-purple text-white font-bold rounded-[15px] shadow-lg hover:bg-brand-purple-dark transition-all",children:"Refresh Page"})]}):e.jsxs("div",{className:"max-w-4xl mx-auto space-y-8 relative",children:[O&&e.jsxs("div",{className:"absolute top-0 right-0 flex items-center text-xs font-bold text-indigo-600 animate-pulse bg-indigo-50 px-3 py-1 rounded-full border border-indigo-100 z-10",children:[e.jsx("span",{className:"w-2 h-2 bg-indigo-600 rounded-full mr-2 animate-ping"}),"Syncing..."]}),e.jsxs("div",{className:"flex justify-between items-end border-b pb-4",children:[e.jsxs("div",{id:"tour-step-curriculum",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-800",children:"Curriculum"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1 font-medium",children:"Organize your course. Drag items between sections. Hover over a closed section while dragging to expand it."})]}),e.jsxs("button",{id:"tour-add-topic",onClick:te,disabled:O,className:"flex items-center justify-center px-4 py-2 text-sm font-bold text-white bg-indigo-600 rounded-lg hover:bg-indigo-700 disabled:opacity-50 transition-colors shadow-sm",children:[e.jsx(We,{})," Add Section"]})]}),e.jsx(it,{onDragEnd:ue,onDragUpdate:ce,children:e.jsx(gs,{droppableId:"all-topics",type:"topic",children:S=>e.jsxs("div",{...S.droppableProps,ref:S.innerRef,className:"space-y-4",children:[V.map((w,T)=>
1{const H=I===w.id,R=f.includes(w.id);return e.jsx(hs.Fragment,{children:e.jsx(ps,{draggableId:String(w.id),index:T,children:(d,M)=>e.jsxs("div",{ref:d.innerRef,...d.draggableProps,className:`bg-white rounded-[15px] shadow-sm border transition-all duration-300 overflow-hidden ${H?"ring-2 ring-indigo-500 border-transparent":"border-gray-200"} ${M.isDragging?"opacity-90 shadow-xl ring-2 ring-indigo-500 scale-[1.02]":""}`,children:[e.jsxs("div",{className:`flex items-center justify-between p-4 cursor-pointer hover:bg-gray-50 transition-colors ${R?"bg-gray-50 border-b border-gray-200":""}`,onClick:()=>!H&&ke(w.id),children:[e.jsxs("div",{className:"flex items-center flex-grow min-w-0 gap-3",children:[e.jsx("span",{className:"cursor-grab text-gray-300 hover:text-gray-500",...d.dragHandleProps,onClick:F=>F.stopPropagation(),children:e.jsx(ks,{})}),H?e.jsx("div",{className:"flex-grow mr-4",children:e.jsx("input",{type:"text",value:w.title,onChange:F=>de(w.id,"title",F.target.value),className:"w-full p-2 border border-gray-300 rounded text-base font-bold focus:ring-2 focus:ring-indigo-500 outline-none",autoFocus:!0,onClick:F=>F.stopPropagation(),onBlur:()=>ie(w),onKeyDown:F=>F.key==="Enter"&&ie(w)})}):e.jsx("div",{className:"flex-grow",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-base font-bold text-gray-800",children:w.title||"Untitled Section"}),e.jsxs("span",{className:"text-[10px] bg-gray-100 text-gray-400 px-2 py-0.5 rounded-full font-black uppercase tracking-tighter border border-gray-200",children:[w.items.length," units"]})]})})]}),e.jsx("div",{className:"flex items-center gap-2",children:!H&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:F=>{F.stopPropagation(),P(w.id)},className:"p-1.5 text-gray-400 hover:text-indigo-600 hover:bg-indigo-50 rounded transition-colors",title:"Rename",children:e.jsx(Ls,{})}),e.jsx("button",{onClick:F=>{F.stopPropagation(),pe(w.id)},className:"p-1.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded transition-colors",title:"Delete",children:e.jsx(Ss,{})}),e.jsx("div",{className:"pl-2 border-l border-gray-200 ml-1",children:e.jsx(ut,{open:R})})]})})]}),e.jsxs("div",{className:`bg-gray-50/50 transition-all duration-300 ${R?"max-h-none p-4 opacity-100":"max-h-0 p-0 opacity-0 overflow-hidden"}`,children:[e.jsx(gs,{droppableId:String(w.id),type:"item",children:(F,D)=>e.jsxs("div",{ref:F.innerRef,...F.droppableProps,className:`space-y-3 min-h-[50px] p-2 rounded-lg transition-all border-2 border-transparent ${D.isDraggingOver?"bg-indigo-50/50 border-dashed border-indigo-200":""}`,children:[w.items.length===0&&!D.isDraggingOver&&e.jsx("div",{className:"text-center py-6 border border-dashed border-gray-200 rounded-lg bg-white",children:e.jsx("p",{className:"text-xs text-gray-400 font-bold  tracking-widest",children:"No units in this section"})}),w.items.map((Y,p)=>e.jsx(hs.Fragment,{children:e.jsx(ps,{draggableId:String(Y.id),index:p,children:(C,se)=>e.jsx("div",{ref:C.innerRef,...C.draggableProps,style:C.draggableProps.style,className:se.isDragging?"opacity-90 shadow-2xl z-50 scale-105":"",children:e.jsx(gt,{item:Y,onEdit:()=>o(w,Y),onDelete:()=>
1g(w.id,Y.id),dragHandleProps:C.dragHandleProps})})})},Y.id)),F.placeholder]})}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-200 grid grid-cols-3 gap-3",children:[e.jsxs("button",{onClick:()=>y(w),className:"flex items-center justify-center px-4 py-2 text-xs font-bold text-gray-500 bg-white border border-gray-200 rounded-lg hover:border-green-400 hover:text-green-700 transition-all shadow-sm",children:[e.jsx("span",{className:"mr-2 text-green-500",children:e.jsx(We,{})})," ","Lesson"]}),e.jsxs("button",{onClick:()=>n(w),className:"flex items-center justify-center px-4 py-2 text-xs font-bold text-gray-500 bg-white border border-gray-200 rounded-lg hover:border-purple-400 hover:text-purple-700 transition-all shadow-sm",children:[e.jsx("span",{className:"mr-2 text-purple-500",children:e.jsx(We,{})})," ","Quiz"]}),e.jsxs("button",{onClick:()=>_(w),className:"flex items-center justify-center px-4 py-2 text-xs font-bold text-gray-500 bg-white border border-gray-200 rounded-lg hover:border-orange-400 hover:text-orange-700 transition-all shadow-sm",children:[e.jsx("span",{className:"mr-2 text-orange-500",children:e.jsx(We,{})})," ","Assignments"]})]})]})]})})},w.id)}),S.placeholder]})})}),V.length===0&&e.jsxs("div",{className:"text-center py-12 bg-gray-50 border-2 border-dashed border-gray-300 rounded-[15px]",children:[e.jsx("p",{className:"text-gray-500 font-medium",children:"No sections yet. Create a section to start adding lessons."}),e.jsx("button",{onClick:te,className:"mt-4 text-indigo-600 font-bold hover:underline",children:"Create your first section"})]})]})},De=({label:s,children:r})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:e.jsx("div",{className:"flex items-center",children:s})}),r]}),ft=({courseData:s,setCourseData:r})=>e.jsx("div",{className:"w-full max-w-7xl mx-auto px-4 lg:px-8",children:e.jsx("div",{className:"w-full space-y-8",children:e.jsxs("div",{id:"tour-step-additional",className:"bg-white p-6 rounded-lg shadow-sm border border-gray-200 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-gray-800",children:"Overview"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Provide essential course information to attract and inform potential students"})]}),e.jsx("div",{id:"tour-field-what-you-will-learn",children:e.jsx(De,{label:"What Will I Learn?",children:e.jsx("textarea",{value:s.whatWillILearn,onChange:l=>r(y=>({...y,whatWillILearn:l.target.value})),rows:4,placeholder:"Define the key takeaways from this course (list one benefit per line)",className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500"})})}),e.jsx("div",{id:"tour-field-target-audience",children:e.jsx(De,{label:"Target Audience",children:e.jsx("textarea",{value:s.targetAudience,onChange:l=>r(y=>({...y,targetAudience:l.target.value})),rows:4,placeholder:"Specify the target audience that will benefit the most from the course. (One Line Per target audience)",className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500"})})}),e.jsxs("div",{id:"tour-field-duration",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Total Course Duration"}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"number",value:s.courseHours,onChange:l=>r(y=>({...y,courseHours:parseInt(l.target.value)})),className:"w-24 px-3 py-2 border border-gray-300 rounded-lg text-sm"}),e.jsx("span",{className:"text-sm text-gray-500",children:"hour(s)"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"number",value:s.courseMinutes,onChange:l=>r(y=>({...y,courseMinutes:parseInt(l.target.value)})),className:"w-24 px-3 py-2 border border-gray-300 rounded-lg text-sm"}),e.jsx("span",{className:"text-sm text-gray-500",children:"min(s)"})]})]})]}),e.jsx("div",{id:"tour-field-materials",children:e.jsx(De,{label:"Materials Included",children:e.jsx("textarea",{value:s.materialsIncluded,onChange:l=>r(y=>({...y,materialsIncluded:l.target.value})),rows:4,placeholder:"A list of assets you will be providing for the students in this course (One Per Line)",className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500"})})}),e.jsx("div",{id:"tour-field-requirements",children:e.jsx(De,{label:"Requirements/Instructions",children:e.jsx("textarea",{value:s.requirements,onChange:l=>r(y=>({...y,requirements:l.target.value})),rows:4,placeholder:"Additional requirements or special instructions for the students (One Per Line)",className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500"})})})]})})}),Is=()=>e.jsx("svg",{className:"w-3 h-3 text-red-500",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 0L9.8 6.2H16L10.9 9.8L12.7 16L8 12.4L3.3 16L5.1 9.8L0 6.2H6.2L8 0Z"})}),bt=()=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),ws=()=>e.jsx("svg",{className:"w-10 h-10 text-gray-400 mx-auto",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})}),yt=()=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.48
16L20.5 13"})}),wt=()=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),Oe=({label:s,children:r,required:l})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:e.jsxs("div",{className:"flex items-center",children:[s,l&&e.jsx(Is,{})]})}),r]}),jt=({checked:s,onChange:r})=>e.jsx("button",{type:"button",className:`${s?"bg-indigo-600":"bg-gray-200"} relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500`,onClick:()=>r(!s),children:e.jsx("span",{className:`${s?"translate-x-6":"translate-x-1"} inline-block h-4 w-4 transform rounded-full bg-white transition-transform`})}),vt=({isOpen:s,onClose:r,topic:l,onSave:y,lessonToEdit:n,isSaving:_=!1})=>{const[o,g]=a.useState(""),[f,v]=a.useState(""),[I,P]=a.useState(""),[O,k]=a.useState(!1),[Z,V]=a.useState(!1),[ke,te]=a.useState(null),[de,ie]=a.useState(null),[pe,ce]=a.useState(null),[ue,S]=a.useState(null),[w,T]=a.useState(!1),[H,R]=a.useState(""),[d,M]=a.useState(""),[F,D]=a.useState(),[Y,p]=a.useState(),[C,se]=a.useState(!1),re=a.useRef(null),[fe,me]=a.useState(!1),[Se,B]=a.useState(null);a.useEffect(()=>{s&&(R(`${(n==null?void 0:n.id)||"new"}-${Date.now()}`),n?(g(n.title),v(n.content),P(n.video_url||""),te(n.image_url||null),ie(n.image_url||null),ce(n.attachment_url||null),S(n.attachment_name||null),k(n.isLocked||!1),V(n.enablePlayground||!1)):(g(""),v(""),P(""),te(null),ie(null),ce(null),S(null),k(!1),V(!1)))},[s,n]);const Le=i=>{if(i.target.files&&i.target.files.length>0){D(void 0);const u=new FileReader;u.addEventListener("load",()=>{var m;M(((m=u.result)==null?void 0:m.toString())||""),se(!0)}),u.readAsDataURL(i.target.files[0]),i.target.value=""}};function ve(i){const{width:u,height:m}=i.currentTarget,b=16/9,N=_s(Cs({unit:"%",width:90},b,u,m),u,m);D(N)}async function be(i,u){const m=document.createElement("canvas"),b=i.naturalWidth/i.width,N=i.naturalHeight/i.height;m.width=u.width,m.height=u.height;const z=m.getContext("2d");return z?(z.drawImage(i,u.x*b,u.y*N,u.width*b,u.height*N,0,0,u.width,u.height),new Promise(Q=>{m.toBlob(xe=>{Q(xe)},"image/jpeg",.8)})):null}async function ye(){if(!Y||!re.current)return;const i=await be(re.current,Y);if(i){me(!0),se(!1),B(null);try{const u=new FormData;u.append("file",i),u.append("upload_preset","weversity_unsigned");const b=await(await fetch("https://api.cloudinary.com/v1_1/dn93gd6yw/image/upload",{method:"POST",body:u})).json();if(b.error)throw new Error(b.error.message);const N=b.secure_url;N&&(te(N),ie(N))}catch(u){B(`Image upload failed: ${u.message}`)}finally{me(!1),M("")}}}const ne=async i=>{if(!i.target.files||i.target.files.length===0)return;const u=i.target.files[0];T(!0),B(null);try{const m=new FormData;m.append("file",u),m.append("upload_preset","weversity_unsigned");const N=await(await fetch("https://api.cloudinary.com/v1_1/dn93gd6yw/raw/upload",{method:"POST",body:m})).json();if(N.error)throw new Error(N.error.message);ce(N.secure_url),S(u.name)}catch(m){B(`Attachment upload failed: ${m.message}`)}finally{T(!1)}},we=()=>{se(!1),M("")},je=()=>{if(!l)return;const i={title:o||"Untitled Lesson",content:f,video_url:I,image_url:ke||void 0,attachment_url:pe||void 0,attachment_name:ue||void 0,isLocked:O,enablePlayground:Z};y(l.id,i)};if(!s||!l)return null;const t=!!n;return e.jsxs(e.Fragment,{children:[C&&e.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[120] p-4",children:e.jsxs("div",{className:"bg-white p-4 sm:p-6 rounded-lg w-full max-w-xs sm:max-w-lg md:max-w-2xl",children:[e.jsx("h3",{className:"text-xl font-bold mb-4 text-gray-800",children:"Crop Lesson Image"}),d&&e.jsx("div",{className:"flex justify-center",children:e.jsx(Ns,{crop:F,onChange:(i,u)=>D(u),onComplete:i=>p(i),aspect:16/9,children:e.jsx("img",{ref:re,src:d,onLoad:ve,style:{maxHeight:"70vh"},alt:"Crop preview"})})}),e.jsxs("div",{className:"flex justify-end space-x-4 mt-4",children:[e.jsx("button",{onClick:we,className:"px-4 py-2 text-gray-700 font-semibold rounded-lg hover:bg-gray-100 transition",children:"Cancel"}),e.jsx("button",{onClick:ye,className:"px-4 py-2 bg-indigo-600 text-white font-semibold rounded-lg hover:bg-indigo-700 transition",disabled:fe,children:fe?"Uploading...":"Upload"})]})]})}),e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-[110] flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-2xl w-full h-full sm:max-w-lg md:max-w-3xl lg:max-w-5xl max-h-[90vh] flex flex-col",children:[e.jsxs("header",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b",children:[e.jsxs("h2",{className:"text-xl font-bold text-gray-800",children:[t?"Edit Lesson":"New Lesson"," ",e.jsxs("span",{className:"text-gray-500 font-medium hidden sm:inline",children:["| Topic: ",l.title||"Untitled Topic"]})]}),e.jsx("button",{onClick:r,className:"p-2 text-gray-500 rounded-full hover:bg-gray-100",children:e.jsx(bt,{})})]}),e.jsxs("main",{className:"p-6 flex-grow overflow-y-auto",children:[Se&&e.jsx("p",{className:"bg-red-100 text-red-700 p-3 rounded-lg text-sm mb-4",children:Se}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsx(Oe,{label:"Name",required:!0,children:e.jsx("input",{type:"text",value:o,onChange:i=>g(i.target.value),placeholder:"Enter Lesson Name",className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500"})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:e.jsxs("div",{className:"flex items-center",children:["Content ",e.jsx(Is,{})]})}),e.jsx("div",{className:"min-h-[300px]",children:e.jsx(rs,{initialContent:f,onChange:v,uploadFolder:"weversity_lessons"},H)})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(Oe,{label:"Featured Image",children:e.jsxs("div",{className:"border-2 border-dashed border-gray-300 rounded-lg p-6 text-center",children:[de?e.jsx("img",{src:de,alt:"Thumbn
1ail preview",className:"mx-auto max-h-24 mb-4"}):e.jsx(ws,{}),e.jsx("label",{htmlFor:"lesson-image-upload",className:"mt-2 cursor-pointer text-sm font-semibold text-indigo-600 bg-indigo-50 px-3 py-1.5 rounded-lg hover:bg-indigo-100",children:de?"Change Image":"Upload Image"}),e.jsx("input",{id:"lesson-image-upload",type:"file",className:"hidden",onChange:Le,accept:"image/jpeg, image/png, image/gif, image/webp"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"16:9 aspect ratio recommended"})]})}),e.jsxs(Oe,{label:"Preview Video URL",children:[e.jsx("input",{type:"url",value:I,onChange:i=>P(i.target.value),placeholder:"e.g., https://www.youtube.com/watch?v=...",className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"Paste a video URL. This will be shown to students."})]}),e.jsx(Oe,{label:"Video Playback Time",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"number",placeholder:"0",className:"w-full text-center px-2 py-2 border border-gray-300 rounded-lg text-sm"}),e.jsx("span",{className:"text-sm text-gray-500",children:"hour"}),e.jsx("input",{type:"number",placeholder:"0",className:"w-full text-center px-2 py-2 border border-gray-300 rounded-lg text-sm"}),e.jsx("span",{className:"text-sm text-gray-500",children:"min"}),e.jsx("input",{type:"number",placeholder:"0",className:"w-full text-center px-2 py-2 border border-gray-300 rounded-lg text-sm"}),e.jsx("span",{className:"text-sm text-gray-500",children:"sec"})]})}),e.jsx(Oe,{label:"Attachments",children:e.jsxs("div",{className:"border-2 border-dashed border-gray-300 rounded-lg p-6 text-center",children:[pe?e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:"bg-indigo-50 text-indigo-600 p-3 rounded-lg mb-2",children:e.jsx(yt,{})}),e.jsx("span",{className:"text-sm font-medium text-gray-700 truncate max-w-full px-4 mb-3",children:ue||"file-attached"})]}):e.jsx(ws,{}),e.jsx("label",{htmlFor:"lesson-attachment-upload",className:"mt-2 cursor-pointer text-sm font-semibold text-indigo-600 bg-indigo-50 px-3 py-1.5 rounded-lg hover:bg-indigo-100 flex items-center justify-center gap-2 mx-auto w-fit",children:w?"Uploading...":pe?"Change File":"Upload Attachment"}),e.jsx("input",{id:"lesson-attachment-upload",type:"file",className:"hidden",onChange:ne,disabled:w}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"PDF, DOC, ZIP or any other resource files"})]})}),e.jsx("div",{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700",children:e.jsxs("div",{className:"flex items-center",children:["Code Playground",e.jsx("span",{className:"ml-2",title:"Enable live code editor for this lesson.",children:e.jsx(wt,{})})]})}),e.jsx(jt,{checked:Z,onChange:V})]})})]})]})]}),e.jsxs("footer",{className:"flex-shrink-0 flex justify-end space-x-3 p-4 bg-gray-50 border-t rounded-b-lg",children:[e.jsx("button",{onClick:r,disabled:_,className:"px-4 py-2 text-sm font-semibold text-gray-700 bg-gray-100 rounded-lg hover:bg-gray-200 disabled:opacity-50",children:"Cancel"}),e.jsxs("button",{onClick:je,disabled:_,className:"px-4 py-2 text-sm font-semibold text-white bg-indigo-600 rounded-lg hover:bg-indigo-700 disabled:opacity-50 flex items-center",children:[_&&e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),_?"Saving...":t?"Update Lesson":"Save Lesson"]})]})]})})]})},Nt=()=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 5v.01M12 12v.01M12 19v.01"})}),as=()=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z",clipRule:"evenodd"})}),_t=()=>e.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center bg-[#81b5e5]",children:e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-white"})}),Ct=()=>e.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center bg-[#a885d8]",children:e.jsx("svg",{className:"w-3 h-3 text-white",f
1ill:"none",stroke:"currentColor",strokeWidth:"3",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M5 13l4 4L19 7"})})}),kt=()=>e.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center bg-orange-300",children:e.jsx("svg",{className:"w-3 h-3 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M2 5a1 1 0 011-1h14a1 1 0 110 2H3a1 1 0 01-1-1zm0 5a1 1 0 011-1h6a1 1 0 110 2H3a1 1 0 01-1-1zm0 5a1 1 0 011-1h14a1 1 0 110 2H3a1 1 0 01-1-1z"})})}),St=()=>e.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center bg-lime-400",children:e.jsx("svg",{className:"w-3.5 h-3.5 text-white",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm10 0a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zm-10 10a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zm10 0a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"})})}),Lt=()=>e.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center bg-blue-500",children:e.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M8 7l4-4 4 4m0 10l-4 4-4-4"})})}),It=[{name:"True/False",icon:e.jsx(_t,{})},{name:"Multiple Choice",icon:e.jsx(Ct,{})},{name:"Fill in the Blanks",icon:e.jsx(kt,{})},{name:"Matching",icon:e.jsx(St,{})},{name:"Ordering",icon:e.jsx(Lt,{})}],Mt=({question:s,onQuestionChange:r})=>{const[l,y]=a.useState(!1);return e.jsxs("div",{className:"mt-8 border-t pt-6",children:[e.jsxs("button",{onClick:()=>y(!l),className:"w-full flex justify-between items-center text-left",children:[e.jsx("h4",{className:"font-semibold text-gray-700",children:"Question Settings"}),e.jsx("svg",{className:`w-5 h-5 text-gray-500 transition-transform ${l?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),l&&e.jsxs("div",{className:"mt-4 space-y-4 animate-fade-in",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Points"}),e.jsx("input",{type:"number",value:s.points,onChange:n=>r({...s,points:parseInt(n.target.value)>=0?parseInt(n.target.value):0}),className:"mt-1 w-full px-3 py-2 border border-gray-300 rounded-lg text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Description (Optional)"}),e.jsx("textarea",{value:s.description||"",onChange:n=>r({...s,description:n.target.value}),rows:3,className:"mt-1 w-full px-3 py-2 border border-gray-300 rounded-lg text-sm"})]})]})]})},Be=({title:s,children:r,question:l,onQuestionChange:y})=>e.jsxs("div",{className:"p-4 sm:p-8 w-full max-w-2xl mx-auto",children:[e.jsxs("h3",{className:"text-lg font-semibold text-gray-800 mb-6",children:["Question Editor: ",s]}),e.jsxs("div",{className:"space-y-6",children:[r,e.jsx(Mt,{question:l,onQuestionChange:y})]})]}),At=({question:s,onQuestionChange:r})=>{var y;const l=n=>{var _;r({...s,options:(_=s.options)==null?void 0:_.map(o=>({...o,isCorrect:o.id===n}))})};return e.jsxs(Be,{title:"True/False",question:s,onQuestionChange:r,children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Question"}),e.jsx("input",{type:"text",value:s.title,onChange:n=>r({...s,title:n.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-base"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Correct Answer"}),e.jsx("div",{className:"space-y-3",children:(y=s.options)==null?void 0:y.map(n=>e.jsxs("label",{className:"flex items-center p-4 border rounded-lg cursor-pointer has-[:checked]:bg-indigo-50 has-[:checked]:border-indigo-400",children:[e.jsx("input",{type:"radio",name:`correct_answer_${s.id}`,value:n.id,checked:n.isCorrect,onChange:()=>l(n.id),className:"h-4 w-4 text-indigo-600"}),e.jsx("span",{className:"ml-3 text-sm font-medium text-gray-900",children:n.text})]},n.id))})]})]})},Pt=({question:s,onQuestionChange:r})=>{var o;const l=(g,f)=>{var v;r({...s,options:(v=s.options)==null?void 0:v.map(I=>I.id===g?{...I,text:f}:I)})},y=g=>{let f=[...s.options||[]];s.allowMultipleCorrect?f=f.map(v=>v.id===g?{...v,isCorrect:!v.isCorrect}:v):f=f.map(v=>({...v,isCorrect:v.id===g})),r({...s,options:f})},n=()=>{const g={id:`opt_${Date.now()}`,text:"",isCorrect:!1};r({...s,options:[...s.options||[],g]})},_=g=>{var f;r({...s,options:(f=s.options)==null?void 0:f.filter(v=>v.id!==g)})};return e.jsxs(Be,{title:"Multiple Choice",question:s,onQuestionChange:r,children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Question"}),e.jsx("input",{type:"text",value:s.title,onChange:g=>r({...s,title:g.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-base"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Options"}),e.jsx("div",{className:"space-y-3",children:(o=s.options)==null?void 0:o.map((g,f)=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:s.allowMultipleCorrect?"checkbox":"radio",name:`correct_answer_${s.id}`,checked:g.isCorrect,onChange:()=>y(g.id),className:"h-4 w-4 text-indigo-600 flex-shrink-0"}),e.jsx("input",{type:"text",value:g.text,onChange:v=>l(g.id,v.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm",placeholder:`Option ${f+1}`}),e.jsx("button",{onClick:()=>_(g.id),className:"p-2 text-gray-500 hover:text-red-600 hover:bg-red-50 rounded-full",children:e.jsx(as,{})})]},g.id))}),e.jsx("button",{onClick:n,className:"mt-4 text-sm font-semibold text-indigo-600 hover:text-indigo-800",children:"Add Option"})]}),e.jsxs("div",{className:"flex items-center justify-between mt-4 p-3 bg-gray-100 rounded-lg",children:[e.jsx("label",{htmlFor:"allow-multiple",className:"text-sm font-medium text-gray-700",children:"Allow multiple correct answers"}),e.jsx("input",{id:"allow-multiple",type:"checkbox",checked:s.allowMultipleCorrect,onChange:g=>r({...s,allowMultipleCorrect:g.target.checked}),className:"h-4 w-4 text-indigo-600 rounded"})]})]})}
1,zt=({question:s,onQuestionChange:r})=>e.jsxs(Be,{title:"Open Ended/Essay",question:s,onQuestionChange:r,children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Question/Prompt"}),e.jsx("textarea",{value:s.title,onChange:l=>r({...s,title:l.target.value}),rows:5,className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-base"})]}),e.jsx("p",{className:"text-sm text-gray-500",children:"Students will be provided with a rich text editor to answer this question. Grading will need to be done manually."})]}),$t=({question:s,onQuestionChange:r})=>e.jsxs(Be,{title:"Short Answer",question:s,onQuestionChange:r,children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Question"}),e.jsx("input",{type:"text",value:s.title,onChange:l=>r({...s,title:l.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-base"})]}),e.jsx("p",{className:"text-sm text-gray-500",children:"Students will provide a short text-based answer. This question type is graded manually."})]}),Ft=({question:s,onQuestionChange:r})=>e.jsxs(Be,{title:"Fill in the Blanks",question:s,onQuestionChange:r,children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Question Title"}),e.jsx("input",{type:"text",value:s.title,onChange:l=>r({...s,title:l.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-base"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Passage"}),e.jsx("textarea",{value:s.content,onChange:l=>r({...s,content:l.target.value}),rows:6,className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-base font-mono"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Create blanks by wrapping the correct word in double square brackets. Example: The capital of France is [[Paris]]."})]})]}),Bt=({question:s,onQuestionChange:r})=>{var _;const l=(o,g,f)=>{var v;r({...s,options:(v=s.options)==null?void 0:v.map(I=>I.id===o?{...I,[g]:f}:I)})},y=()=>{const o={id:`pair_${Date.now()}`,text:"",match:"",isCorrect:!1};r({...s,options:[...s.options||[],o]})},n=o=>{var g;r({...s,options:(g=s.options)==null?void 0:g.filter(f=>f.id!==o)})};return e.jsxs(Be,{title:"Matching",question:s,onQuestionChange:r,children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Question Title/Instructions"}),e.jsx("input",{type:"text",value:s.title,onChange:o=>r({...s,title:o.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-base"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Matching Pairs"}),e.jsx("div",{className:"space-y-3",children:(_=s.options)==null?void 0:_.map(o=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"text",value:o.text,onChange:g=>l(o.id,"text",g.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm",placeholder:"Term"}),e.jsx("span",{className:"text-gray-500",children:"="}),e.jsx("input",{type:"text",value:o.match,onChange:g=>l(o.id,"match",g.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm",placeholder:"Matching Definition"}),e.jsx("button",{onClick:()=>n(o.id),className:"p-2 text-gray-500 hover:text-red-600 hover:bg-red-50 rounded-full",children:e.jsx(as,{})})]},o.id))}),e.jsx("button",{onClick:y,className:"mt-4 text-sm font-semibold text-indigo-600 hover:text-indigo-800",children:"Add Pair"})]})]})},Tt=({question:s,onQuestionChange:r})=>{var l,y;return e.jsxs(Be,{title:"Image Answering",question:s,onQuestionChange:r,children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Question"}),e.jsx("input",{type:"text",value:s.title,onChange:n=>r({...s,title:n.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-base"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Image URL"}),e.jsx("input",{type:"url",value:s.imageUrl,onChange:n=>r({...s,imageUrl:n.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm",placeholder:"https://example.com/image.jpg"}),s.imageUrl&&e.jsx("img",{src:s.imageUrl,alt:"Preview",className:"mt-2 rounded-lg max-h-48 border"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Correct Answer"}),e.jsx("input",{type:"text",value:((y=(l=s.options)==null?void 0:l[0])==null?void 0:y.text)||"",onChange:n=>r({...s,options:[{id:"ans_1",text:n.target.value,isCorrect:!0}]}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm"})]})]})},Rt=({question:s,onQuestionChange:r})=>{var _;const l=(o,g)=>{var f;r({...s,options:(f=s.options)==null?void 0:f.map(v=>v.id===o?{...v,text:g}:v)})},y=()=>{const o={id:`item_${Date.now()}`,text:"",isCorrect:!1};r({...s,options:[...s.options||[],o]})},n=o=>{var g;r({...s,options:(g=s.options)==null?void 0:g.filter(f=>f.id!==o)})};return e.jsxs(Be,{title:"Ordering",question:s,onQuestionChange:r,children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Question Title/Instructions"}),e.jsx("input",{type:"text",value:s.title,onChange:o=>r({...s,title:o.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-base"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Items in Correct Order"}),e.jsx("div",{className:"space-y-3",children:(_=s.options)==null?void 0:_.map((o,g)=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs("span",{className:"font-mono text-gray-500",children:[g+1,"."]}),e.jsx("input",{type:"text",value:o.text,onChange:f=>l(o.id,f.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm",placeholder:`Item ${g+1}`}),e.jsx("button",{onClick:()=>n(o.id),className:"p-2 text-gray-500 hover:text-red-600 hover:bg-red-50 rounded-full",children:e.jsx(as,{})})]},o.id))}),e.jsx("button",{onClick:y,className:"mt-4 text-sm font-semibold text-indigo-600 hover:text-indigo-800",children:"Add Item"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"Enter items in the correct sequence. They will be shuffled for the student."})]})]})},Ut=({question:s,index:r,isActive:l,onSelect:y,onDelete:n})=>
1{const[_,o]=a.useState(!1),g=a.useRef(null);return a.useEffect(()=>{const f=v=>{g.current&&!g.current.contains(v.target)&&o(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]),e.jsx("li",{className:`p-2 rounded-lg transition-colors ${l?"bg-indigo-100":"hover:bg-gray-50"}`,children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("button",{onClick:y,className:"flex-grow text-left",children:e.jsxs("span",{className:"font-medium text-sm text-gray-800",children:[r+1,". ",s.title]})}),e.jsxs("div",{ref:g,className:"relative flex-shrink-0 ml-2",children:[e.jsx("button",{onClick:()=>o(f=>!f),className:"p-1 rounded-full hover:bg-gray-200",children:e.jsx(Nt,{})}),_&&e.jsx("div",{className:"absolute right-0 mt-1 w-28 bg-white rounded-md shadow-lg py-1 z-10 border",children:e.jsx("button",{onClick:n,className:"block w-full text-left px-4 py-2 text-sm text-red-600 hover:bg-red-50",children:"Delete"})})]})]})})},js=({title:s,children:r,isOpen:l,onToggle:y})=>e.jsxs("div",{className:"bg-white p-6 rounded-[15px] border border-gray-200",children:[e.jsxs("button",{onClick:y,className:"w-full flex justify-between items-center text-left",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-800",children:s}),e.jsx("svg",{className:`w-6 h-6 text-gray-500 transition-transform ${l?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),e.jsx("div",{className:`grid transition-all duration-500 ease-in-out ${l?"grid-rows-[1fr] opacity-100 pt-6":"grid-rows-[0fr] opacity-0"}`,children:e.jsx("div",{className:"overflow-hidden space-y-6",children:r})})]}),Et=({tooltip:s})=>e.jsx("span",{className:"ml-2 text-gray-400",title:s,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})})}),Me=({label:s,children:r,tooltip:l})=>e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-2 flex items-center",children:[s," ",l&&e.jsx(Et,{tooltip:l})]}),r]}),ss=({checked:s,onChange:r})=>e.jsx("button",{type:"button",onClick:()=>r(!s),className:`${s?"bg-indigo-600":"bg-gray-200"} relative inline-flex items-center h-6 rounded-full w-11 transition-colors`,children:e.jsx("span",{className:`${s?"translate-x-6":"translate-x-1"} inline-block w-4 h-4 transform bg-white rounded-full transition-transform`})}),Ot=({isOpen:s,onClose:r,topic:l,onSave:y,quizToEdit:n,isSaving:_=!1})=>{const[o,g]=a.useState(""),[f,v]=a.useState(""),[I,P]=a.useState([]),[O,k]=a.useState(null),[Z,V]=a.useState(!1),[ke,te]=a.useState(!1),de=a.useRef(null),[ie,pe]=a.useState(!1),[ce,ue]=a.useState(0),[S,w]=a.useState("Minutes"),[T,H]=a.useState(!1),[R,d]=a.useState("Retry"),[M,F]=a.useState(10),[D,Y]=a.useState(80),[p,C]=a.useState(10),[se,re]=a.useState(!1),[fe,me]=a.useState("Single question"),[Se,B]=a.useState("Random"),[Le,ve]=a.useState(!1),[be,ye]=a.useState(200),[ne,we]=a.useState(500),[je,t]=a.useState(!0),[i,u]=a.useState(!0),[m,b]=a.useState("details");a.useEffect(()=>{var h,L;s&&(n?(pe(!0),g(n.title),v(n.summary),P(n.questions||[]),k(((L=(h=n.questions)==null?void 0:h[0])==null?void 0:L.id)||null),V(!0),ue(n.timeLimit||0),w(n.timeUnit||"Minutes"),F(n.attemptsAllowed||10),Y(n.passingGrade||80),C(n.maxQuestionsAllowed||10),re(n.quizAutoStart||!1),me(n.questionLayout||"Single question"),B(n.questionOrder||"Random"),ve(n.hideQuestionNumber||!1),ye(n.shortAnswerCharLimit||200),we(n.essayCharLimit||500)):(pe(!1),g(""),v(""),P([]),k(null),V(!1),b("details"),te(!1),ue(0),w("Minutes"),H(!1),d("Retry"),F(10),Y(80),C(10),re(!1),me("Single question"),B("Random"),ve(!1),ye(200),we(500),t(!0),u(!0)))},[s,n]),a.useEffect(()=>{const h=L=>{de.current&&!de.current.contains(L.target)&&te(!1)};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[]);const N=h=>{const L=Date.now(),ae={id:`q_${L}`,title:`New ${h} Question`,points:1};let Ne;
1switch(h){case"True/False":Ne={...ae,type:h,options:[{id:`opt_1_${L}`,text:"True",isCorrect:!0},{id:`opt_2_${L}`,text:"False",isCorrect:!1}]};break;case"Multiple Choice":Ne={...ae,type:h,allowMultipleCorrect:!1,options:[{id:`opt_1_${L}`,text:"Option 1",isCorrect:!0},{id:`opt_2_${L}`,text:"Option 2",isCorrect:!1}]};break;case"Open Ended/Essay":case"Short Answer":Ne={...ae,type:h};break;case"Fill in the Blanks":Ne={...ae,type:h,content:"The capital of France is [[Paris]]."};break;case"Matching":Ne={...ae,type:h,options:[{id:`pair_1_${L}`,text:"Term 1",match:"Definition 1",isCorrect:!1}]};break;case"Image Answering":Ne={...ae,type:h,imageUrl:"",options:[{id:`ans_1_${L}`,text:"Correct Answer",isCorrect:!0}]};break;case"Ordering":Ne={...ae,type:h,options:[{id:`item_1_${L}`,text:"First item",isCorrect:!1},{id:`item_2_${L}`,text:"Second item",isCorrect:!1}]};break;default:Ne={...ae,type:h}}P(W=>[...W,Ne]),k(Ne.id),te(!1)},z=h=>{P(L=>L.map(ae=>ae.id===h.id?h:ae))},Q=h=>{if(P(L=>L.filter(ae=>ae.id!==h)),O===h){const L=I.filter(ae=>ae.id!==h);k(L.length>0?L[L.length-1].id:null)}},xe=()=>{o.trim()&&V(!0)},Ie=()=>{if(!l)return;const h={id:ie?n==null?void 0:n.id:void 0,title:o||(ie?"Untitled Quiz":"New Quiz"),summary:f,questions:I,timeLimit:ce,timeUnit:S,attemptsAllowed:M,passingGrade:D,maxQuestionsAllowed:p,quizAutoStart:se,questionLayout:fe,questionOrder:Se,hideQuestionNumber:Le,shortAnswerCharLimit:be,essayCharLimit:ne};y(l.id,h)},q=()=>{m==="details"?b("settings"):Ie()},E=I.find(h=>h.id===O),ze=()=>{if(!E)return e.jsxs("div",{className:"text-center text-gray-500 p-4 max-w-xs mx-auto",children:[e.jsxs("div",{className:"w-48 h-48 relative text-gray-200 flex items-center justify-center",children:[e.jsx("svg",{viewBox:"0 0 200 200",className:"absolute w-full h-full drop-shadow-sm opacity-50",children:e.jsx("path",{fill:"currentColor",d:"M180,100c0,44.183-35.817,80-80,80c-11.222,0-21.873-2.31-31.408-6.526C63.498,178.69,57.387,183.33,50,185c-1.542-4.14-1.2-8.353,0.493-12.493C30.342,161.264,20,146.49,20,130c0-11.233,2.58-21.84,7.072-31.413C12.31,88.528,10,77.01,10,65C10,29.103,49.103,0,95,0s85,29.103,85,65c0,12.01-2.31,23.528-6.497,33.587C177.42,108.16,180,118.767,180,130c0,4.047-0.39,7.98-0.98,11.78Z",transform:"scale(0.95) translate(5, -10)"})}),e.jsxs("div",{className:"relative w-32 h-40 bg-white rounded-lg shadow-lg p-3 transform -rotate-6 border",children:[e.jsx("div",{className:"w-full h-2 bg-gray-200 rounded-sm mb-4"}),e.jsx("div",{className:"space-y-3",children:[...Array(4)].map((h,L)=>e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-gray-300 mr-2"}),e.jsx("div",{className:`h-2 bg-gray-200 rounded-sm ${L===0?"w-20":L===1?"w-16":L===2?"w-12":"w-14"}`})]},L))})]})]}),e.jsx("p",{className:"font-semibold mt-6",children:"Add your first question"}),e.jsx("p",{className:"text-sm",children:"Get started by clicking the plus icon on the left."})]});switch(E.type){case"True/False":return e.jsx(At,{question:E,onQuestionChange:z});case"Multiple Choice":return e.jsx(Pt,{question:E,onQuestionChange:z});case"Open Ended/Essay":return e.jsx(zt,{question:E,onQuestionChange:z});case"Short Answer":return e.jsx($t,{question:E,onQuestionChange:z});case"Fill in the Blanks":return e.jsx(Ft,{question:E,onQuestionChange:z});case"Matching":return e.jsx(Bt,{question:E,onQuestionChange:z});case"Image Answering":return e.jsx(Tt,{question:E,onQuestionChange:z});case"Ordering":return e.jsx(Rt,{question:E,onQuestionChange:z});default:return e.jsxs("div",{className:"p-8",children:["Editor for ",E.type," not implemented."]})}};return!s||!l?null:e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-[110] flex items-center justify-center p-0 sm:p-4",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-2xl w-full h-full sm:max-w-full md:max-w-5xl lg:max-w-7xl sm:h-[90vh] flex flex-col",children:[e.jsxs("header",{className:"flex-shrink-0 bg-white border-b border-gray-200 px-4 sm:px-6",children:[e.jsxs("div",{className:"flex items-center justify-between h-16 relative",children:[e.jsxs("h2",{className:"text-lg font-bold text-gray-800 flex items-center truncate",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 mr-2 text-gray-400 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01"})}),e.jsx("span",{className:"truncate",children:o||(ie?"Edit Quiz":"New Quiz")}),e.jsx("span",{className:"text-gray-400 hidden md:inline mx-2",children:"|"}),e.jsxs("p",{className:"text-sm font-medium text-gray-600 hidden md:inline truncate",children:["Topic: ",l.title]})]}),e.jsx("div",{className:"hidden md:flex absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",children:e.jsxs("nav",{className:"flex space-x-1 bg-gray-100 p-1 rounded-lg",children:[e.jsx("button",{onClick:()=>b("details"),className:`px-4 py-1.5 text-sm font-semibold rounded-md transition-colors ${m==="details"?"bg-white text-gray-800 shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:"Question Details"}),e.jsx("button",{onClick:()=>b("settings"),className:`px-4 py-1.5 text-sm font-semibold rounded-md transition-colors ${m==="settings"?"bg-white text-gray-800 shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:"Settings"})]})}),e.jsxs("div",{className:"flex items-center space-x-2 flex-shrink-0 ml-4",children:[e.jsx("button",{onClick:r,disabled:_,className:"px-4 py-2 text-sm font-semibold text-gray-700 rounded-lg hover:bg-gray-100 disabled:opacity-50",children:"Cancel"}),e.jsxs("button",{onClick:q,disabled:_,className:"px-4 py-2 text-sm font-semibold text-white bg-indigo-600 rounded-lg hover:bg-indigo-700 disabled:opacity-50 flex items-center",children:[_&&e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),_?"Saving...":m==="details"?"Next":ie?"Update Quiz":"Save Quiz"]})]})]}),e.jsx("div",{className:"md:hidden pb-2",children:e.jsxs("nav",{className:"flex space-x-1 bg-gray-100 p-1 rounded-lg w-full",children:[e.jsx("button",{onClick:()=>b("details"),className:`w-1/2 text-center px-4 py-1.5 text-sm font-semibold rounded-md transition-colors ${m==="details"?"bg-white text-gray-800 shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:"Details"}),e.jsx("button",{onClick:()=>b("settings"),className:`w-1/2 text-center px-4 py-1.5 text-sm font-semibold rounded-md transition-colors ${m==="settings"?"bg-white text-gray-800 shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:"Settings"})]})})]}),e.jsx("main",{className:"flex-1 flex flex-col md:flex-row overflow-hidden",children:m==="details"?Z?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"w-full md:w-[320px] lg:w-[360
1px] flex-shrink-0 bg-white border-b md:border-b-0 md:border-r p-4 flex flex-col md:h-full",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold text-gray-800 break-words",children:o}),e.jsx("p",{className:"text-sm text-gray-600 mt-1 break-words",children:f}),e.jsx("button",{onClick:()=>V(!1),className:"text-xs text-indigo-600 hover:underline mt-2",children:"Edit"})]}),e.jsx("div",{className:"border-t my-4"}),e.jsxs("div",{className:"flex-grow flex flex-col min-h-0",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("h3",{className:"text-md font-semibold text-gray-700",children:"Questions"}),e.jsxs("div",{className:"relative",ref:de,children:[e.jsx("button",{onClick:()=>te(h=>!h),className:"p-1.5 bg-gray-200 text-gray-600 rounded-md hover:bg-gray-300",title:"Add Question",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"3",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4v16m8-8H4"})})}),ke&&e.jsxs("div",{className:"absolute right-0 mt-2 w-56 bg-white rounded-lg shadow-xl border z-10 animate-fade-in",children:[e.jsx("div",{className:"p-3 border-b",children:e.jsx("h4",{className:"text-sm font-semibold text-gray-800",children:"Select Question Type"})}),e.jsx("ul",{className:"py-1",children:It.map(h=>e.jsx("li",{children:e.jsxs("button",{onClick:()=>N(h.name),className:"w-full flex items-center px-3 py-2 text-sm text-gray-700 hover:bg-gray-100",children:[e.jsx("span",{className:"mr-3",children:h.icon}),h.name]})},h.name))})]})]})]}),e.jsx("div",{className:"flex-grow overflow-y-auto pr-2 -mr-2",children:I.length===0?e.jsx("p",{className:"text-sm text-gray-500 text-center py-4",children:"No questions added yet."}):e.jsx("ul",{className:"space-y-1",children:I.map((h,L)=>e.jsx(Ut,{question:h,index:L,isActive:O===h.id,onSelect:()=>k(h.id),onDelete:()=>Q(h.id)},h.id))})})]})]}),e.jsx("div",{className:"flex-grow bg-gray-50 flex items-center justify-center h-full overflow-y-auto",children:ze()})]}):e.jsx("div",{className:"flex-1 bg-gray-50 flex items-center justify-center p-4 sm:p-6",children:e.jsxs("div",{className:"w-full max-w-md text-center",children:[e.jsxs("div",{className:"bg-white p-6 rounded-lg shadow-sm border",children:[e.jsx("input",{type:"text",value:o,onChange:h=>g(h.target.value),placeholder:"Quiz Title",className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-base font-semibold focus:ring-indigo-500 focus:border-indigo-500"}),e.jsx("textarea",{value:f,onChange:h=>v(h.target.value),placeholder:"Quiz Summary...",rows:2,className:"w-full mt-2 px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500"}),e.jsx("button",{onClick:xe,disabled:!o.trim(),className:"w-full mt-3 px-4 py-2 text-sm font-semibold text-white bg-indigo-600 rounded-lg hover:bg-indigo-700 disabled:bg-gray-400",children:"OK"})]}),e.jsxs("div",{className:"text-gray-500 mt-8",children:[e.jsx("svg",{className:"w-24 h-24 text-gray-300 mx-auto",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01"})}),e.jsx("p",{className:"font-semibold mt-4",children:"Enter a quiz title to begin."}),e.jsx("p",{className:"text-sm",children:"Choose from a variety of question types to keep things interesting!"})]})]})}):e.jsx("div",{className:"bg-gray-50 h-full overflow-y-auto p-4 sm:p-8",children:e.jsxs("div",{className:"max-w-3xl mx-auto space-y-8",children:[e.jsxs(js,{title:"Basic Settings",isOpen:je,onToggle:()=>t(h=>!h),children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-6",children:[e.jsx(Me,{label:"Time Limit",tooltip:"Set a time limit for the quiz.",children:e.jsxs("div",{className:"flex space-x-2",children:[e.jsx("input",{type:"number",value:ce,onChange:h=>ue(Number(h.target.value)),className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"}),e.jsxs("select",{value:S,onChange:h=>w(h.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm bg-white",children:[e.jsx("option",{children:"Minutes"}),e.jsx("option",{children:"Hours"}),e.jsx("option",{children:"Days"}),e.jsx("option",{children:"Weeks"})]})]})}),e.jsxs("div",{className:"flex items-center justify-between pt-8",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Hide Quiz Time"}),e.jsx(ss,{checked:T,onChange:H})]})]}),e.jsxs(Me,{label:"Feedback Mode",children:[e.jsxs("div",{className:"relative",children:[e.jsxs("select",{value:R,onChange:h=>d(h.target.value),className:"w-full appearance-none pl-10 pr-4 py-3 border border-gray-300 rounded-md text-sm bg-white",children:[e.jsx("option",{value:"Retry",children:"Retry"}),e.jsx("option",{value:"Reveal",children:"Reveal Answer"})]}),e.jsx("div",{className:"absolute inset-y-0 left-3 flex items-center pointer-events-none",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 text-gray-500",viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("path",{d:"M10 12a2 2 0 100-4 2 2 0 000 4z"}),e.jsx("path",{fillRule:"evenodd",d:"M.458 10C3.732 4.943 9.523 3 15 3c5.478 0 11.268 1.943 14.542 7-3.274 5.057-9.064 7-14.542 7-5.477 0-11.268-1.943-14.542-7zM15 10a5 5 0 11-10 0 5 5 0 0110 0z",clipRule:"evenodd"})]})})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"Allows students to retake the quiz after their first attempt."})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-6",children:[e.jsx(Me,{label:"Attempts Allowed",tooltip:"Number of attempts students have.",children:e.jsx("input",{type:"number",value:M,onChange:h=>F(Number(h.target.value)),className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"})}),e.jsx(Me,{label:"Passing Grade (%)",tooltip:"Percentage needed to pass the quiz.",children:e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"number",value:D,onChange:h=>Y(Number(h.target.value)),className:"w-full pl-3 pr-8 py-2 border border-gray-300 rounded-md text-sm"}),e.jsx("span",{className:"absolute inset-y-0 right-3 flex items-center text-gray-500 text-sm",children:"%"})]})}),e.jsx(Me,{label:"Max Question Allowed",tooltip:"Maximum number of questions to be answered in the quiz.",children:e.jsx("input",{type:"number",value:p,onChange:h=>C(Number(h.target.value)),className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"})})]})]}),e.jsxs(js,{title:"Advanced Settings",isOpen:i,onToggle:()=>u(h=>!h),children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(Me,{label:"Quiz Auto Start",tooltip:"Starts the quiz as soon as the student visits the page.",children:e.jsx(ss,{checked:se,onChange:re})})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-6",children:[e.jsx(Me,{label:"Question Layout",children:e.jsxs("select",{value:fe,onChange:h=>me(h.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm bg-white",children:[e.jsx("option",{children:"Single question"}),e.jsx("option",{children:"Multiple questions"})]})}),e.jsx(Me,{label:"Question Order",children:e.jsxs("select",{value:Se,onChange:h=>B(h.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm bg-white",children:[e.jsx("option",{children:"Random"}),e.jsx("option",{children:"Sequential"})]})})]}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsx(Me,{label:"Hide Question Number",children:e.jsx(ss,{checked:Le,onChange:ve})})}),e.jsx(Me,{label:"Set Character Limit for Short Answers",children:e.jsx("input",{type:"number",value:be,onChange:h=>ye(Number(h.target.value)),className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"})}),e.jsx(Me,{label:"Set Character Limit for Open-Ended/Essay Answers",children:e.jsx("input",{type:"number",value:ne,onChange:h=>we(Number(h.target.value)),className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"})})]})]})})})]})})},Ms=()=>e.jsx("svg",{className:"w-3 h-3 text-red-500",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 0L9.8 6.2H16L10.9 9.8L12.7 16L8 12.4L3.3 16L5.1 9.8L0 6.2H6.2L8 0Z"})}),Ht=()=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),Wt=()=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 mr-1",viewBox:"0 0 20 20",fill:"currentColor",children:[e.jsx("path",{d:"M9 2a1 1 0 000 2h2a1 1 0 100-2H9z"}),e.jsx("path",{fillRule:"evenodd",d:"M4 5a2 2 0 012-2h8a2 2 0 012 2v10a2 2 0 01-2 2H6a2 2 0 01-2-2V5zm3 4a1 1 0 000 2h4a1 1 0 100-2H7zm0 4a1 1 0 100 2h4a1 1 0 100-2H7z",clipRule:"evenodd"})]}),ts=()=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),Dt=()=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.48
16L20.5 13"})}),Qt=()=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 mr-1 text-green-500",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),Fe=({label:s,children:r,required:l})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:e.jsxs("div",{className:"flex items-center",children:[s,l&&e.jsx(Ms,{})]})}),r]}),vs=({checked:s,onChange:r})=>e.jsx("button",{type:"button",className:`${s?"bg-indigo-600":"bg-gray-200"} relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500`,onClick:()=>r(!s),children:e.jsx("span",{className:`${s?"translate-x-6":"translate-x-1"} inline-block h-4 w-4 transform rounded-full bg-white transition-transform`})}),Vt=({isOpen:s,onClose:r,topic:l,onSave:y,assignmentToEdit:n,isSaving:_=!1})=>{const[o,g]=a.useState(""),[f,v]=a.useState(""),[I,P]=a.useState(0),[O,k]=a.useState("Weeks"),[Z,V]=a.useState(!1),[ke,te]=a.useState(10),[de,ie]=a.useState(5),[pe,ce]=a.useState(1),[ue,S]=a.useState(2),[w,T]=a.useState(!0),[H,R]=a.useState(5),[d,M]=a.useState(void 0),[F,D]=a.useState(!1),[Y,p]=a.useState(null),C=a.useRef(null),[se,re]=a.useState("");a.useEffect(()=>{s&&(re(`new-assignment-${Date.now()}`),n?(g(n.title),v(n.content),M(n.attachmentUrl),P(n.timeLimit||0),k(n.timeUnit||"Weeks"),V(n.setDeadline||!1),te(n.totalPoints||10),ie(n.minPassPoints||5),ce(n.fileUploadLimit||1),S(n.maxFileSize||2),T(n.allowResubmission!==void 0?n.allowResubmission:!0),R(n.maxResubmissionAttempts||5)):(g(""),v(""),M(void 0),P(0),k("Weeks"),V(!1),te(10),ie(5),ce(1),S(2),T(!0),R(5)))},[s,n]);const fe=async B=>{var ve,be;const Le=(ve=B.target.files)==null?void 0:ve[0];if(Le){D(!0),p(null);try{const{data:{session:ye}}=await window.supabase.auth.getSession(),we=`${((be=ye==null?void 0:ye.user)==null?void 0:be.id)||"public"}/${Date.now()}_${Le.name}`,je="assignment_files",{error:t}=await window.supabase.storage.from(je).upload(we,Le,{cacheControl:"3600",upsert:!0});if(t)throw t;const{data:i}=window.supabase.storage.from(je).getPublicUrl(we),u=i.publicUrl;u&&M(u)}catch(ye){p(ye.message||"Failed to upload file")}finally{D(!1),C.current&&(C.current.value="")}}},me=()=>{if(!l)return;const B={id:n==null?void 0:n.id,title:o||"Untitled Assignment",content:f,attachmentUrl:d,timeLimit:I,timeUnit:O,setDeadline:Z,totalPoints:ke,minPassPoints:de,fileUploadLimit:pe,maxFileSize:ue,allowResubmission:w,maxResubmissionAttempts:H};
1y(l.id,B)};if(!s||!l)return null;const Se=!!n;return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-[110] flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-2xl w-full max-w-lg md:max-w-3xl lg:max-w-5xl max-h-[90vh] flex flex-col",children:[e.jsxs("header",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Wt,{}),e.jsxs("h2",{className:"text-xl font-bold text-gray-800",children:[Se?"Edit Assignment":"New Assignment",e.jsxs("span",{className:"text-gray-500 font-medium hidden sm:inline",children:[" | Topic: ",l.title||"Untitled Topic"]})]})]}),e.jsx("button",{onClick:r,className:"p-2 text-gray-500 rounded-full hover:bg-gray-100",children:e.jsx(Ht,{})})]}),e.jsx("main",{className:"p-6 flex-grow overflow-y-auto",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"md:col-span-2 space-y-6",children:[e.jsx(Fe,{label:"Title",required:!0,children:e.jsx("input",{type:"text",value:o,onChange:B=>g(B.target.value),placeholder:"Enter Assignment Title",className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500"})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:e.jsxs("div",{className:"flex items-center",children:["Content ",e.jsx(Ms,{})]})}),e.jsx("div",{className:"min-h-[300px]",children:e.jsx(rs,{initialContent:f,onChange:v,uploadFolder:"assignment_blocks"},se)})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(Fe,{label:"Attachments",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("button",{onClick:()=>{var B;return(B=C.current)==null?void 0:B.click()},disabled:F,className:"w-full flex items-center justify-center bg-indigo-50 text-indigo-700 font-semibold py-2 px-4 rounded-lg hover:bg-indigo-100 disabled:opacity-50",children:[e.jsx(Dt,{})," ",F?"Uploading...":"Upload Attachment"]}),e.jsx("input",{type:"file",className:"hidden",ref:C,onChange:fe}),Y&&e.jsx("p",{className:"text-xs text-red-500",children:Y}),d&&e.jsxs("div",{className:"flex items-center justify-between text-xs bg-gray-50 p-2 rounded border border-gray-200",children:[e.jsxs("div",{className:"flex items-center text-gray-700 truncate",children:[e.jsx(Qt,{})," File Attached"]}),e.jsx("button",{onClick:()=>M(void 0),className:"text-red-500 hover:text-red-700",children:"Remove"})]})]})}),e.jsx(Fe,{label:"Time Limit",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"number",value:I,onChange:B=>P(Math.max(0,parseInt(B.target.value))),className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"}),e.jsxs("select",{value:O,onChange:B=>k(B.target.value),className:"px-3 py-2 border border-gray-300 rounded-md text-sm bg-white",children:[e.jsx("option",{children:"Weeks"}),e.jsx("option",{children:"Days"}),e.jsx("option",{children:"Hours"}),e.jsx("option",{children:"Minutes"})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("label",{className:"text-sm font-medium text-gray-700 flex items-center",children:["Set Deadline From Assignment Start Time",e.jsx("span",{className:"ml-1",title:"Enforce a deadline based on when the student starts the assignment",children:e.jsx(ts,{})})]}),e.jsx(vs,{checked:Z,onChange:V})]}),e.jsx(Fe,{label:"Total Points",children:e.jsx("input",{type:"number",value:ke,onChange:B=>te(Math.max(0,parseInt(B.target.value))),className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"})}),e.jsx(Fe,{label:"Minimum Pass Points",children:e.jsx("input",{type:"number",value:de,onChange:B=>ie(Math.max(0,parseInt(B.target.value))),className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"})}),e.jsx(Fe,{label:"File Upload Limit",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("input",{type:"number",value:pe,onChange:B=>ce(Math.max(1,parseInt(B.target.value))),className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"}),e.jsx("span",{className:"ml-1",title:"Max files a student can attach",children:e.jsx(ts,{})})]})}),e.jsx(Fe,{label:"Maximum File Size Limit",children:e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"number",value:ue,onChange:B=>S(Math.max(1,parseInt(B.target.value))),className:"w-full pl-3 pr-12 py-2 border border-gray-300 rounded-md text-sm"}),e.jsx("span",{className:"absolute inset-y-0 right-3 flex items-center text-gray-500 text-sm",children:"MB"})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Allow Assignment Resubmission"}),e.jsx(vs,{checked:w,onChange:T})]}),w&&e.jsx(Fe,{label:"Maximum Resubmission Attempts",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("input",{type:"number",value:H,onChange:B=>R(Math.max(1,parseInt(B.target.value))),className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"}),e.jsx("span",{className:"ml-1",title:"How many times a student can try again",children:e.jsx(ts,{})})]})})]})]})}),e.jsxs("footer",{className:"flex justify-end space-x-3 p-4 bg-gray-50 border-t rounded-b-lg",children:[e.jsx("button",{onClick:r,disabled:_,className:"px-4 py-2 text-sm font-semibold text-gray-700 bg-gray-100 rounded-lg hover:bg-gray-200 disabled:opacity-50",children:"Cancel"}),e.jsxs("button",{onClick:me,disabled:F||_,className:"px-4 py-2 text-sm font-semibold text-white bg-indigo-600 rounded-lg hover:bg-indigo-700 disabled:opacity-50 flex items-center",children:[_&&e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),_?"Saving...":Se?"Update Assignment":"Save Assignment"]})]})]})})},qt=()=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})}),Gt=({isOpen:s,onClose:r,allCategories:l,setAllCategories:y})=>{const[n,_]=a.useState(""),[o,g]=a.useState(""),[f,v]=a.useState(!1),[I,P]=a.useState(null),O=async()=>
1{if(!n.trim()){P("Category name cannot be empty.");return}v(!0),P(null);const{error:k}=await window.supabase.from("categories").insert({name:n,parent_id:o?parseInt(o):null});if(k)P(k.message);else{_(""),g(""),r();const{data:Z}=await window.supabase.from("categories").select("id, name, parent_id").order("name",{ascending:!0});Z&&y(Z)}v(!1)};return s?e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-xl w-full max-w-md",children:[e.jsxs("header",{className:"flex items-center justify-between p-4 border-b",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-800",children:"Add New Category"}),e.jsx("button",{onClick:r,className:"p-2 text-gray-500 rounded-full hover:bg-gray-100",children:e.jsx(qt,{})})]}),e.jsxs("main",{className:"p-6",children:[I&&e.jsx("p",{className:"text-red-500 text-sm mb-4",children:I}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("input",{type:"text",placeholder:"Category name",value:n,onChange:k=>_(k.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500"}),e.jsxs("select",{value:o,onChange:k=>g(k.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-indigo-500 focus:border-indigo-500 bg-white",children:[e.jsx("option",{value:"",children:"Select parent"}),l.filter(k=>!k.parent_id).map(k=>e.jsx("option",{value:k.id,children:k.name},k.id))]})]})]}),e.jsxs("footer",{className:"flex justify-end space-x-3 p-4 bg-gray-50 rounded-b-lg",children:[e.jsx("button",{onClick:r,className:"px-4 py-2 text-sm font-semibold text-gray-700 bg-gray-100 rounded-lg hover:bg-gray-200",children:"Cancel"}),e.jsx("button",{onClick:O,disabled:f,className:"px-4 py-2 text-sm font-semibold text-white bg-indigo-600 rounded-lg hover:bg-indigo-700 disabled:opacity-50",children:f?"Adding...":"Ok"})]})]})}):null};function is(s){let r=0,l=0,y=0,n=0;for(let P=0;P<s.length;P++){const O=s.charCodeAt(P);r=r*31+O|0,l=l*17+O|0,y=y*13+O|0,n=n*7+O|0}const _=P=>(P>>>0).toString(16).padStart(8,"0"),o=_(r),g=_(l),f=_(y),v=_(n),I=(o+g+f+v).toLowerCase();return`${I.slice(0,8)}-${I.slice(8,12)}-4${I.slice(13,16)}-8${I.slice(17,20)}-${I.slice(20,32)}`}const Yt=()=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),Kt=({onSave:s,setPage:r,loading:l,currentStep:y,onStepChange:n,status:_,setStatus:o,isScheduled:g,onShowGuide:f,onReplayVideo:v,isCenterCourse:I})=>{const P=O=>y===O?"px-2 sm:px-3 py-2 rounded-md bg-indigo-100 text-indigo-700 font-bold transition-colors cursor-pointer":"px-2 sm:px-3 py-2 rounded-md text-gray-500 hover:bg-gray-100 transition-colors cursor-pointer";return e.jsx("header",{className:"bg-white shadow-sm sticky top-0 z-20",children:e.jsxs("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8 flex items-center justify-between h-16",children:[e.jsx("div",{className:"flex items-center space-x-2 sm:space-x-6",children:e.jsxs("nav",{className:"flex items-center space-x-1 sm:space-x-2 text-xs sm:sm:text-sm font-medium",children:[e.jsxs("button",{id:"tour-step-basics",onClick:()=>n(1),className:P(1),children:["1",e.jsx("span",{className:"hidden sm:inline",children:" Basics"})]}),e.jsx("span",{className:"text-gray-400",children:"-"}),e.jsxs("button",{id:"tour-step-curriculum",onClick:()=>n(2),className:P(2),children:["2",e.jsx("span",{className:"hidden sm:inline",children:" Curriculum"})]}),e.jsx("span",{className:"text-gray-400",children:"-"}),e.jsxs("button",{id:"tour-step-additional",onClick:()=>n(3),className:P(3),children:["3",e.jsx("span",{className:"hidden sm:inline",children:" Additional"})]})]})}),e.jsxs("div",{className:"flex items-center space-x-1 sm:space-x-2",children:[(y===1||y===2)&&e.jsxs("button",{onClick:()=>v(y),className:"flex items-center gap-1.5 px-3 py-2 text-sm font-semibold text-indigo-600 bg-indigo-50 border border-indigo-100 hover:bg-indigo-100 hover:border-indigo-200 rounded-lg transition-colors mr-2",title:"Replay Step Video",children:[e.jsxs("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})]}),e.jsx("span",{className:"hidden sm:inline",children:"Watch Guide"})]}),g?e.jsx("span",{className:"px-3 py-2 text-sm font-semibold text-orange-600 bg-orange-50 rounded-lg border border-orange-200",children:"Scheduled"}
1):e.jsxs("select",{value:_,onChange:O=>o(O.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg text-sm bg-white focus:ring-indigo-500 focus:border-indigo-500",children:[e.jsx("option",{value:"draft",children:"Draft (Hidden)"}),e.jsx("option",{value:"coming_soon",children:"Coming Soon (Locked)"}),I?e.jsx("option",{value:"pending_center_approval",children:"Submit to Center for Review"}):e.jsx("option",{value:"published",children:"Publish - Go Live Now"}),_==="pending_center_approval"&&!I&&e.jsx("option",{value:"pending_center_approval",disabled:!0,children:"Pending Center Approval"})]}),e.jsx("div",{className:"relative",children:e.jsxs("div",{className:"flex items-center gap-2 rounded-lg",children:[y===1&&e.jsx("button",{onClick:f,className:"p-2 text-indigo-600 hover:text-indigo-800 rounded-full hover:bg-indigo-50 transition-colors",title:"Quick Guide",children:e.jsx(tt,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>s(),disabled:l,className:"px-3 sm:px-4 py-2 text-xs sm:text-sm font-semibold text-white bg-indigo-600 rounded-lg hover:bg-indigo-700 disabled:opacity-50",children:l?"Saving...":"Save Changes"})]})}),e.jsx("button",{onClick:()=>
1r("dashboard"),className:"p-2 text-gray-500 hover:text-gray-800 rounded-full hover:bg-gray-100",children:e.jsx(Yt,{})})]})]})})},gi=({session:s,setPage:r,courseId:l,setEditingCourseId:y})=>{const{courseId:n}=Ks(),_=Zs(),o=a.useMemo(()=>n&&!isNaN(parseInt(n))?parseInt(n):l&&!isNaN(l)?l:null,[n,l]),g=Xs(),[f,v]=a.useState(()=>{var c;return((c=g.state)==null?void 0:c.step)||1}),[I,P]=a.useState(!1),[O,k]=a.useState(()=>typeof window<"u"?!n&&!l:!1),Z=()=>{k(!1)},[V,ke]=a.useState(!1),[te,de]=a.useState(!1),[ie,pe]=a.useState(!1),[ce,ue]=a.useState(!1);a.useEffect(()=>{f===2&&!te&&(ke(!0),de(!0))},[f,te]);const S=()=>{ke(!1)},w=()=>{pe(!1)},H={1:[{targetId:"tour-step-basics",title:"Step 1: Basics",description:"Start here! Fill in your course title, language, and core details to lay the foundation.",position:"bottom"},{targetId:"tour-field-title",title:"Catchy Titles",description:"Your course title is your hook. Make it action-oriented (e.g., 'Master React from Scratch').",position:"right"},{targetId:"tour-field-language",title:"Course Language",description:"Select the primary language in which this course is taught.",position:"left"},{targetId:"tour-field-url",title:"Course Link",description:"This is the public URL where students will find your course.",position:"bottom"},{targetId:"tour-field-description",title:"Engaging Description",description:"Use the content blocks to create a rich description. Highlight the transformation your students will achieve.",position:"bottom"},{targetId:"tour-add-content-block",title:"Add Content Block",description:"This is where the magic happens! You can build a beautiful, structured course description by adding various content blocks.",position:"top"},{targetId:"tour-block-heading",title:"Heading Block",description:"Use headings to break your description into scannable, logical sections.",position:"right"},{targetId:"tour-block-richtext",title:"Rich Text Block",description:"Add paragraphs, bullet points, and basic formatting to explain your course details.",position:"right"},{targetId:"tour-block-layout",title:"Layout Block",description:"Create multi-column layouts to present information side-by-side professionally.",position:"left"},{targetId:"tour-block-image",title:"Image Block",description:"Visuals matter! Insert descriptive images or infographics into your course description.",position:"right"},{targetId:"tour-block-video",title:"Video Block",description:"Embed introductory or preview videos directly inside your description.",position:"left"},{targetId:"tour-field-image",title:"High-Quality Thumbnails",description:"Courses with professional, clear thumbnails get 3x more enrollments. Use high-resolution images.",position:"left"},{targetId:"tour-field-video",title:"Intro Video",description:"A 1-minute intro video can increase your course conversions significantly.",position:"left"},{targetId:"tour-field-options",title:"Course Options",description:"Configure pricing, enrollment limits, drip content rules, and difficulty level here.",position:"bottom"},{targetId:"tour-field-pricing",title:"Pricing Model",description:"Decide if your course is free or paid. You can also offer promotional discount coupons here.",position:"left"},{targetId:"tour-field-certificate",title:"Certificate Settings",description:"Set up whether students receive a free or paid verified certificate upon completion.",position:"left"},{targetId:"tour-field-categories",title:"Course Categories",description:"Select categories and tags to help students easily discover your course in the directory.",position:"left"}],2:[],3:[]}[f]||[];a.useEffect(()=>{O||V||ie||f===2&&P(!0)},[f,O,V,ie]);const R={title:"",description:"",contentDripType:"none",isScheduled:!1,scheduledDate:"",level:"Beginner",language:"English",price:0,maxStudents:1e3,imageFile:null,image_url:null,selectedCategories:[],tags:[],selectedAuthorId:s.user.id,selectedInstructors:[],whatWillILearn:"",targetAudience:"",courseHours:0,courseMinutes:0,materialsIncluded:"",requirements:"",curriculum:[],videoUrl:"",status:"draft",type:"Skill",certificatePrice:0,isQuranRelated:!1,isPhysical:!1,facilityId:null,physicalSessionsCount:0,sessionDurationHours:0,facilityFee:0,basePrice:0,physicalLocations:[],is_fixed_center_course:!1,is_center_only:!1,center_id:null,
1sessions:[]},[d,M]=a.useState(R),[F,D]=a.useState(null),[Y,p]=a.useState(!1),[C,se]=a.useState(!1),[re,fe]=a.useState(!1),[me,Se]=a.useState(!1),[B,Le]=a.useState(!1),[ve,be]=a.useState(!1),[ye,ne]=a.useState(!1),[we,je]=a.useState(null),[t,i]=a.useState(null),[u,m]=a.useState([]),[b,N]=a.useState([]),[z,Q]=a.useState([]),[xe,Ie]=a.useState([]),[q,E]=a.useState(!1),[ze,h]=a.useState(null),[L,ae]=a.useState(null),[Ne,W]=a.useState(!1),[Te,Re]=a.useState(null),[Ae,Ve]=a.useState(null),[As,He]=a.useState(!1),[Ps,zs]=a.useState(null),[Ue,qe]=a.useState(null),[$s,ns]=a.useState(!1),[ls,os]=a.useState(""),[Fs,ds]=a.useState(),[cs,Bs]=a.useState(),[Ts,Ge]=a.useState(!1),Ye=a.useRef(null);a.useEffect(()=>{(async()=>{const{data:j}=await window.supabase.from("profiles").select("*").eq("role","instructor").order("first_name");j&&N(j);const{data:$}=await window.supabase.from("categories").select("id, name, parent_id").order("name");$&&Q($);const{data:A}=await window.supabase.from("physical_facilities").select("*").eq("status","active").order("name");A&&Ie(A)})()},[]),a.useEffect(()=>{(async()=>{var j;if(!(!o||Y)){fe(!0);try{const{data:$,error:A}=await window.supabase.from("courses").select("*").eq("id",o).single();if(A)throw A;if(!$){alert("Permission Denied: You do not have access to edit this course, or the course does not exist."),_("/dashboard");return}const x=$;let X=[];if(((j=x.co_instructors)==null?void 0:j.length)>0){const{data:U}=await window.supabase.from("profiles").select("*").in("id",x.co_instructors);U&&(X=U)}let he=[];if(x.is_physical){const{data:U,error:_e}=await window.supabase.from("course_physical_facilities").select("*, physical_facilities(*)").eq("course_id",o);!_e&&U&&(he=U.map(J=>{const G=J.physical_facilities;let Ce=J.facility_id;return G&&G.description&&String(G.description).startsWith("SKILL_CENTER:")&&(Ce=String(G.de
1scription).substring(13)),{id:J.id,course_id:J.course_id,facility_id:Ce,physical_sessions_count:J.physical_sessions_count,session_duration_hours:J.session_duration_hours,facility_fee:typeof J.facility_fee=="number"?J.facility_fee:J.base_price?J.base_price/(J.physical_sessions_count||1):0,base_price:J.base_price,facility_name:(G==null?void 0:G.name)||"",per_hour_fee:(G==null?void 0:G.per_hour_fee)||0}}))}let ee="",le=0;try{const{data:U}=await window.supabase.from("form_submissions").select("data").eq("form_type","course_coupon").eq("data->>courseId",o.toString()).maybeSingle();U&&U.data&&(ee=U.data.code||"",le=U.data.discount||0)}catch(U){console.error("Fetch Coupon Error:",U)}let K=[];if(x.is_physical){const{data:U}=await window.supabase.from("course_sessions").select("*").eq("course_id",o).order("session_number",{ascending:!0});U&&(K=U)}M(U=>({...U,id:x.id,slug:x.slug,title:x.title||"",description:x.description||"",image_url:x.image_url,selectedCategories:typeof x.categories=="string"?x.categories.split(", ").filter(Boolean):Array.isArray(x.categories)?x.categories:[],tags:typeof x.tags=="string"?x.tags.split(",").map(_e=>_e.trim()).filter(Boolean):Array.isArray(x.tags)?x.tags:[],selectedAuthorId:x.instructor_id,selectedInstructors:X,level:x.level||"Beginner",language:x.language||"English",price:x.price||0,maxStudents:x.max_students||0,contentDripType:x.content_drip_type||"none",status:x.status||(x.is_published?"published":"draft"),isScheduled:!!x.scheduled_at,scheduledDate:x.scheduled_at||"",videoUrl:x.introduction_video||"",type:x.type||"Skill",whatWillILearn:Array.isArray(x.what_you_will_learn)?x.what_you_will_learn.join(`
2`):x.what_you_will_learn||"",targetAudience:Array.isArray(x.target_audience)?x.target_audience.join(`
3`):x.target_audience||"",materialsIncluded:Array.isArray(x.materials_included)?x.materials_included.join(`
4`):x.materials_included||"",requirements:Array.isArray(x.requirements)?x.requirements.join(`
5`):x.requirements||"",courseHours:x.duration_hours||0,courseMinutes:x.duration_minutes||0,certificatePrice:x.certificate_price||0,isQuranRelated:x.is_quran_related||!1,isPhysical:x.is_physical||!1,facilityId:x.facility_id||null,physicalSessionsCount:x.physical_sessions_count||0,sessionDurationHours:x.session_duration_hours||0,facilityFee:x.facility_fee||0,basePrice:x.base_price||x.price||0,physicalLocations:he,is_fixed_center_course:x.is_fixed_center_course||!1,is_center_only:x.is_center_only||!1,center_id:x.center_id||null,couponCode:ee,couponDiscount:le,sessions:K})),x.image_url&&D(x.image_url),p(!0)}catch($){console.error("Fetch Basics Error:",$.message)}finally{fe(!1)}}})()},[o,Y,_]);const Ee=a.useCallback(async()=>{if(o){Se(!0);try{const{data:c,error:j}=await window.supabase.from("curriculum_topics").select("*").eq("course_id",o).order("order");if(j)throw j;const{data:$,error:A}=await window.supabase.from("curriculum_items").select("*").eq("course_id",o).order("order");if(A)throw A;const x=(c||[]).map(X=>({id:X.id,title:X.title,summary:X.summary||"",items:($||[]).filter(he=>he.topic_id===X.id).map(he=>{const ee=he.meta_data||{},{id:le,...K}=ee;return{...K,...he,id:String(he.id)}})}));M(X=>({...X,curriculum:x})),se(!0)}catch(c){console.error("Fetch Curriculum Error:",c.message),je("Failed to load curriculum.")}finally{Se(!1)}}},[o]);a.useEffect(()=>{f===2&&!C&&Ee()},[f,C,Ee]);const Ke=async()=>{if(!o)return;const{count:c}=await window.supabase.from("curriculum_items").select("id",{count:"exact",head:!0}).eq("course_id",o).in("type",["lesson","quiz"]);await window.supabase.from("courses").update({total_lessons:c||0}).eq("id",o)},Rs=async c=>{o&&M(j=>({...j,curriculum:c}))},Us=async(c,j)=>{be(!0);try{const $={course_id:o,topic_id:c,type:"lesson",title:j.title,content:j.content,video_url:j.video_url,image_url:j.image_url,is_locked:j.isLocked,meta_data:{enablePlayground:j.enablePlayground,attachment_url:j.attachment_url,attachment_name:j.attachment_name}};if(L){const{error:A}=await window.supabase.from("curriculum_items").update($).eq("id",Number(L.lesson.id));if(A)throw A}else{const{data:A}=await window.supabase.from("curriculum_items").select("order").eq("topic_id",c).order("order",{ascending:!1}).limit(1).maybeSingle();$.order=((A==null?void 0:A.order)??-1)+1;const{error:x}=await window.supabase.from("curriculum_items").insert($);if(x)throw x}await Ee(),Ke(),E(!1),ae(null)}catch($){alert($.message)}finally{be(!1)}},Es=async(c,j)=>{be(!0);try{const{questions:$,id:A,title:x,summary:X,...he}=j,ee={course_id:o,topic_id:c,type:"quiz",title:x,summary:X,meta_data:{...he,questions:$}};if(A&&Ae){const{error:le}=await window.supabase.from("curriculum_items").update(ee).eq("id",Number(A));if(le)throw le}else{const{data:le}=await window.supabase.from("curriculum_items").select("order").eq("topic_id",c).order("order",{ascending:!1}).limit(1).maybeSingle();ee.order=((le==null?void 0:le.order)??-1)+1;const{error:K}=await window.supabase.from("curriculum_items").insert(ee);if(K)throw K}await Ee(),Ke(),W(!1),Ve(null)}catch($){alert($.message)}finally{be(!1)}},Os=async(c,j)=>{be(!0);try{const{title:$,content:A,id:x,...X}=j,he={course_id:o,topic_id:c,type:"assignment",title:$,content:A,meta_data:X};if(x&&Ue){const{error:ee}=await window.supabase.from("curriculum_items").update(he).eq("id",Number(x));if(ee)throw ee}else{const{data:ee}=await window.supabase.from("curriculum_items").select("order").eq("topic_id",c).order("order",{ascending:!1}).limit(1).maybeSingle();he.order=((ee==null?void 0:ee.order)??-1)+1;const{error:le}=await window.supabase.from("curriculum_items").insert(he);if(le)throw le}await Ee(),He(!1),qe(null)}catch($){alert($.message)}finally{be(!1)}},Hs=async(c,j)=>{if(!confirm("Remove this unit from curriculum?"))return;const{error:$}=await window.supabase.from("curriculum_items").delete().eq("id",Number(j));$||(await Ee(),Ke())},Ze=()=>{const c=[];return d.title.trim()||c.push("Course title is compulsory"),(!d.description.trim()||d.description==="<p></p>")&&c.push("Course Description is required."),d.selectedCategories.length===0&&
5c.push("At least one (Category) must be selected."),d.image_url||c.push("Featured Image (Thumbnail) is required."),d.level||c.push("Difficulty Level is required."),d.language||c.push("Course Language is required."),d.type||c.push("Course Type is required."),d.couponCode&&d.couponDiscount&&d.couponDiscount>d.price&&c.push("Coupon discount cannot exceed the course price."),m(c),c.length===0},us=()=>{const c=[];return d.curriculum.length===0?c.push("Please add at least one Topic to your curriculum."):d.curriculum.some($=>$.items.length>0)||c.push("Please add at least one Lesson, Quiz, or Assignment to your curriculum."),m(c),c.length===0},Xe=async c=>{var $;if(!Ze())return null;ne(!0),je(null),i(null);const j=async A=>{try{await window.supabase.from("form_submissions").delete().eq("form_type","course_coupon").eq("data->>courseId",A.toString()),d.price>0&&d.couponCode&&d.couponDiscount&&d.couponDiscount>0&&await window.supabase.from("form_submissions").insert({form_type:"course_coupon",user_id:s.user.id,data:{courseId:A,code:d.couponCode.trim().toUpperCase(),discount:d.couponDiscount,status:"active"}}
5)}catch(x){console.error("Error saving coupon",x)}};try{const A=d.slug||Js(d.title),{data:x}=await window.supabase.from("courses").select("id").eq("slug",A).neq("id",o||0).limit(1).maybeSingle();if(x)return ne(!1),je("This Course URL (Slug) is already taken. Please choose a different one."),m(["This Course URL (Slug) is already taken. Please choose a different one."]),window.scrollTo({top:0,behavior:"smooth"}),null;const X=[];let he=null;if(d.isPhysical&&d.physicalLocations)for(const K of d.physicalLocations){const U=String(K.facility_id),_e=U.includes(":")?U.split(":")[0]:U;if(/^\d+$/.test(_e)&&(he=_e),/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(U))X.push(K);else{const G=is(U);try{const{error:Ce}=await window.supabase.from("physical_facilities").upsert({id:G,name:K.facility_name,address:K.facility_address||"Skill Center Location",description:`SKILL_CENTER:${U}`,per_hour_fee:K.per_hour_fee||0,status:"active"});Ce&&console.warn("Failed to upsert physical facility for skill center room, proceeding anyway:",Ce)}catch(Ce){console.warn("Exception in physical_facilities upsert:",Ce)}X.push({...K,facility_id:G})}}const ee=X&&X.length>0?X[0]:null,le={title:d.title,description:d.description,categories:d.selectedCategories.join(", "),level:d.level,language:d.language,price:d.price,image_url:d.image_url,instructor_id:d.selectedAuthorId||s.user.id,max_students:d.maxStudents||null,content_drip_type:d.contentDripType,tags:d.tags,co_instructors:d.selectedInstructors.map(K=>K.id),introduction_video:d.videoUrl,status:d.status,is_published:d.status==="published"||d.status==="coming_soon",type:d.type,what_you_will_learn:d.whatWillILearn.split(`
6`).filter(Boolean),target_audience:d.targetAudience.split(`
7`).filter(Boolean),materials_included:d.materialsIncluded.split(`
8`).filter(Boolean),requirements:d.requirements.split(`
9`).filter(Boolean),duration_hours:d.courseHours||0,duration_minutes:d.courseMinutes||0,certificate_price:d.certificatePrice||0,is_quran_related:d.isQuranRelated,is_physical:d.isPhysical,facility_id:ee?ee.facility_id:null,center_id:he||d.center_id,physical_sessions_count:ee?ee.physical_sessions_count:0,session_duration_hours:ee?ee.session_duration_hours:0,facility_fee:ee?ee.facility_fee:0,base_price:d.basePrice,slug:A};if(o){const{error:K}=await window.supabase.from("courses").update(le).eq("id",o);if(K)throw K;if(d.isPhysical&&X){if(await window.supabase.from("course_physical_facilities").delete().eq("course_id",o),X.length>0){const U=X.map(J=>({course_id:o,facility_id:J.facility_id,physical_sessions_count:J.physical_sessions_count,session_duration_hours:J.session_duration_hours,facility_fee:J.facility_fee,base_price:J.base_price})),{error:_e}=await window.supabase.from("course_physical_facilities").insert(U);if(_e)throw _e}if(d.sessions&&d.sessions.length>0){const{data:U}=await window.supabase.from("course_sessions").select("id").eq("course_id",o);if(U&&U.length>0){const{error:G,count:Ce}=await window.supabase.from("course_sessions").delete({count:"exact"}).eq("course_id",o);if(G||Ce!==null&&Ce===0)throw console.error("Failed to delete old sessions:",G),alert(`CRITICAL ERROR: Database RLS policy for DELETE is missing!
10
11You must run the SQL command provided in your DB terminal to enable delete permissions for course_sessions. Until then, you cannot update sessions to prevent duplicates.`),new Error("RLS DELETE Policy missing on course_sessions")}const _e=d.sessions.map((G,Ce)=>{const Pe=G.facility_id==="live_google_meet";let $e=G.facility_id;return!Pe&&G.facility_id&&($e=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(String(G.facility_id))?String(G.facility_id):is(String(G.facility_id))),{course_id:o,session_number:Ce+1,start_date:G.start_date||null,start_time:G.start_time||null,status:G.status||"scheduled",facility_id:$e,facility_name:G.facility_name}}),{error:J}=await window.supabase.from("course_sessions").insert(_e);if(J)throw J}}return M(U=>({...U,slug:le.slug})),await j(o),i("Course updated successfully!"),o}else{const{data:K,error:U}=await window.supabase.from("courses").insert(le).select().single();if(U)throw U;if(K){const _e=K.id;if(M(Pe=>({...Pe,slug:le.slug})),d.isPhysical&&X&&X.length>0){const Pe=X.map(ge=>({course_id:_e,facility_id:ge.facility_id,physical_sessions_count:ge.physical_sessions_count,session_duration_hours:ge.session_duration_hours,facility_fee:ge.facility_fee,base_price:ge.base_price})),{error:$e}=await window.supabase.from("course_physical_facilities").insert(Pe);if($e)throw $e}if(d.isPhysical&&d.sessions&&d.sessions.length>0){const Pe=d.sessions.map((ge,Gs)=>{const Ys=ge.facility_id==="live_google_meet";let xs=ge.facility_id;return!Ys&&ge.facility_id&&(xs=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(String(ge.facility_id))?String(ge.facility_id):is(String(ge.facility_id))),{course_id:_e,session_number:Gs+1,start_date:ge.start_date||null,start_time:ge.start_time||null,status:ge.status||"scheduled",facility_id:xs,facility_name:ge.facility_name}}),{error:$e}=await window.supabase.from("course_sessions").insert(Pe);if($e)throw $e}const{data:J,error:G}=await window.supabase.from("chat_groups").insert({course_id:K.id}).select().single();!G&&J&&await window.supabase.from("group_members").insert({group_id:J.id,user_id:s.user.id,role:"instructor"}),M(Pe=>({...Pe,id:K.id,slug:K.slug})),await j(K.id);const Ce=typeof c=="number"?c:1;return _(`/course/edit/${K.id}`,{replace:!0,state:{step:Ce}}),i("Course draft created!"),K.id}}}catch(A){if(($=A.message)!=null&&$.includes("courses_slug_key")||A.code==="23505"){const x="This Course URL (Slug) is already taken. Please change your course slug.";je(x),m([x]),window.scrollTo({top:0,behavior:"smooth"})}else je(A.message);return null}finally{ne(!1),setTimeout(()=>i(null),3e3)}},ms=async c=>{f===1&&c!==1&&(!Ze()||!o&&!await Xe(c))||f===2&&c===3&&!us()||v(c)},Ws=async()=>
11{f===1&&(!Ze()||!await Xe(2))||f===2&&!us()||v(c=>Math.min(3,c+1))},Ds=c=>{const{width:j,height:$}=c.currentTarget,A=16/9,x=_s(Cs({unit:"%",width:90},A,j,$),j,$);ds(x)},Qs=c=>{var j;if((j=c.target.files)!=null&&j[0]){const $=new FileReader;$.onload=()=>{var A;os(((A=$.result)==null?void 0:A.toString())||""),Ge(!0)},$.readAsDataURL(c.target.files[0])}};async function Vs(){if(!(!cs||!Ye.current)){ne(!0);try{const c=await Zt(Ye.current,cs);if(!c)throw new Error("Processing failed.");const j=new FormData;j.append("file",c),j.append("upload_preset","weversity_unsigned");const A=await(await fetch("https://api.cloudinary.com/v1_1/dn93gd6yw/image/upload",{method:"POST",body:j})).json();A.secure_url&&(M(x=>({...x,image_url:A.secure_url})),D(A.secure_url),i("Image uploaded!"))}catch(c){je(c.message)}finally{ne(!1),Ge(!1),os("")}}}const qs=()=>{switch(f){case 1:return e.jsx(ct,{courseData:d,setCourseData:M,allCategories:z,allInstructors:b,allFacilities:xe,setIsCategoryModalOpen:ns,session:s,imagePreview:F,handleImageChange:Qs,onLiveClassesToggle:()=>{ce||(pe(!0),ue(!0))}});case 2:return e.jsx(pt,{courseId:o,topics:d.curriculum,setTopics:Rs,onAddLesson:c=>{h(c),E(!0)},onAddQuiz:c=>{Re(c),W(!0)},onAddAssignment:c=>{zs(c),He(!0)},onEditItem:(c,j)=>{j.type==="lesson"&&ae({topicId:c.id,lesson:j}),j.type==="quiz"&&Ve({topicId:c.id,quiz:j}),j.type==="assignment"&&qe({topicId:c.id,assignment:j}),c.id&&(j.type==="lesson"?E(!0):j.type==="quiz"?W(!0):He(!0))},onDeleteItem:Hs});case 3:return e.jsx(ft,{courseData:d,setCourseData:M});default:return null}};return e.jsxs("div",{className:"min-h-screen bg-gray-50 flex flex-col font-sans",children:[e.jsx(Kt,{onSave:Xe,setPage:r,loading:ye,currentStep:f,onStepChange:ms,status:d.status,setStatus:c=>M({...d,status:c}),isScheduled:d.isScheduled,onShowGuide:()=>P(!0),onReplayVideo:c=>{c===1&&k(!0),c===2&&ke(!0)},isCenterCourse:!!(d.physicalLocations&&d.physicalLocations.length>0&&d.physicalLocations[0].facility_id)}),e.jsx(rt,{isOpen:I,onClose:()=>P(!1),steps:H}),e.jsx(vt,{isOpen:q,onClose:()=>{E(!1),ae(null)},topic:ze||(L?{id:L.topicId}:null),onSave:Us,lessonToEdit:L==null?void 0:L.lesson,isSaving:ve}),e.jsx(Ot,{isOpen:Ne,onClose:()=>{W(!1),Ve(null)},topic:Te||(Ae?{id:Ae.topicId}:null),onSave:Es,quizToEdit:Ae==null?void 0:Ae.quiz,isSaving:ve}),e.jsx(Vt,{isOpen:As,onClose:()=>{He(!1),qe(null)},topic:Ps||(Ue?{id:Ue.topicId}:null),onSave:Os,assignmentToEdit:Ue==null?void 0:Ue.assignment,isSaving:ve}),e.jsx(Gt,{isOpen:$s,onClose:()=>ns(!1),allCategories:z,setAllCategories:Q}),Ts&&e.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white p-6 rounded-lg w-full max-w-2xl",children:[e.jsx("h3",{className:"text-xl font-bold mb-4",children:"Crop Featured Image"}),ls&&e.jsx("div",{className:"flex justify-center",children:e.jsx(Ns,{crop:Fs,onChange:(c,j)=>ds(j),onComplete:c=>Bs(c),aspect:16/9,children:e.jsx("img",{ref:Ye,src:ls,onLoad:Ds,style:{maxHeight:"70vh"},alt:"Crop preview"})})}),e.jsxs("div",{className:"flex justify-end space-x-4 mt-4",children:[e.jsx("button",{onClick:()=>Ge(!1),className:"px-4 py-2 text-gray-700 bg-gray-100 rounded-lg",children:"Cancel"}),e.jsx("button",{onClick:Vs,className:"px-4 py-2 bg-indigo-600 text-white rounded-lg",children:"Upload"})]})]})}),e.jsxs("main",{className:"p-4 sm:p-6 lg:p-8 relative min-h-[calc(100vh-64px)]",children:[we&&e.jsx("p",{className:"bg-red-100 text-red-700 p-3 rounded-lg text-sm mb-4 max-w-7xl mx-auto",children:we}),u.length>0&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-gray-900/50 backdrop-blur-sm animate-in fade-in duration-200",children:e.jsxs("div",{className:"bg-white rounded-[20px] shadow-2xl max-w-md w-full overflow-hidden animate-in zoom-in-95 duration-200 border border-red-100",children:[e.jsxs("div",{className:"bg-red-50 p-6 flex flex-col items-center text-center border-b border-red-100",children:[e.jsx("div",{className:"w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mb-4",children:e.jsx("svg",{className:"h-8 w-8 text-red-500",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),e.jsx("h3",{className:"text-xl font-extrabold text-red-900",children:"Missing Requirements"}),e.jsx("p",{className:"text-sm text-red-600 mt-1",children:"Please fix the following issues before saving."})]}),e.jsx("div",{className:"p-6 bg-white",children:e.jsx("ul",{className:"space-y-3",children:u.map((c,j)=>e.jsxs("li",{className:"flex items-start",children:[e.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-red-100 text-red-600 flex items-center justify-center text-xs font-bold mr-3 mt-0.5",children:j+1}),e.jsx("span",{className:"text-sm font-medium text-gray-700",children:c})]},j))})}),e.jsx("div",{className:"p-4 bg-gray-50 border-t border-gray-100 flex justify-end",children:e.jsx("button",{onClick:()=>m([]),className:"px-6 py-2.5 bg-red-600 hover:bg-red-700 text-white text-sm font-bold rounded-xl shadow-md transition-all duration-200 w-full sm:w-auto",children:"Got it, let me fix them"})})]})}),t&&e.jsx("p",{className:"bg-green-100 text-green-700 p-3 rounded-lg text-sm mb-4 max-w-7xl mx-auto",children:t}),(re||me||B)&&e.jsxs("div",{className:"fixed inset-0 bg-white/80 backdrop-blur-[1px] z-[100] flex flex-col items-center justify-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-indigo-100 border-t-indigo-600 mb-4"}),e.jsx("p",{className:"text-gray-500 font-medium",children:"Loading Step Data..."})]}),e.jsxs("div",{className:re||me||B?"opacity-40 pointer-events-none":"",children:[qs(),e.jsxs("div",{className:"max-w-7xl mx-auto mt-8 flex flex-col-reverse sm:flex-row sm:justify-end sm:items-center gap-2 sm:space-x-4 px-4 sm:px-6 lg:pr-16",children:[f>1&&e.jsx("button",{onClick:()=>ms(f-1),className:"w-full sm:w-auto px-6 py-2 bg-white border border-gray-300 rounded-lg",children:"Previous"}),f<3&&e.jsx("button",{onClick:Ws,className:"w-full sm:w-auto px-6 py-2 bg-indigo-600 text-white rounded-lg",children:"Next"})]})]})]}),O&&e.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center p-4 pt-12 sm:p-6 sm:pt-16 md:p-12 animate-fade-in",onClick:Z,children:[e.jsx("div",{className:"absolute inset-0 bg-slate-900/60 backdrop-blur-xl"}),e.jsxs("div",{className:"relative w-full max-w-2xl transform transition-all",onClick:c=>c.stopPropagation(),children:[e.jsx("button",{onClick:Z,className:"absolute -top-4 -right-4 sm:-top-5 sm:-right-5 z-50 w-8 h-8 sm:w-10 sm:h-10 flex items-center justify-center bg-black/40 hover:bg-black/60 text-white backdrop-blur-md rounded-full shadow-[0_4px_25px_rgba(0,0,0,0.25)] border border-white/20 transition-all duration-300 hover:scale-110 hover:rotate-90","aria-label":"Close modal",children:e.jsx(Qe,{className:"w-4 h-4 sm:w-5 sm:h-5"})}),e.jsxs("div",{className:"w-full bg-white rounded-[10px] shadow-[0_0_50px_-12px_rgba(0,0,0,0.5)] overflow-hidden ring-1 ring-white/20 flex flex-col max-h-[95vh] overflow-y-auto custom-scrollbar",children:[e.jsx("div",{className:"w-full relative flex-shrink-0 group border-b border-slate-100 bg-slate-900 aspect-video",children:e.jsx("iframe",{src:"https://www.youtube.com/embed/0EGz8lMO8wA?autoplay=1",title:"YouTube video player",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowFullScreen:!0,className:"w-full h-full"})}),e.jsxs("div",{className:"p-3 sm:p-4 bg-white flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 sm:gap-4 relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-indigo-500/5 rounded-full blur-3xl -translate-y-1/2 translate-x-1/2 pointer-events-none"}),e.jsxs("div",{className:"relative z-10 max-w-xl",children:[e.jsxs("div",{className:"inline-flex items-center gap-1.5 mb-1.5 px-2.5 py-0.5 rounded-full bg-indigo-50 border border-indigo-100 text-indigo-700 text-[9px] sm:text-[10px] font-bold tracking-widest uppercase shadow-sm",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-indigo-500 animate-pulse"}),"Welcome"]}),e.jsx("h3",{className:"text-lg sm:text-xl font-extrabold text-slate-900 tracking-tight",children:"Create Your First Course"}),e.jsx("p",{className:"text-slate-500 text-xs sm:text-sm mt-1 leading-relaxed font-medium",children:"Watch this quick video guide to learn how to create a high-quality course and reach millions of students worldwide."})]}),e.jsxs("button",{onClick:Z,className:"relative z-10 w-full sm:w-auto bg-indigo-600 text-white px-4 py-2 sm:px-5 sm:py-2.5 rounded-md sm:rounded-lg font-bold text-xs sm:text-sm hover:bg-indigo-700 hover:-translate-y-0.5 active:translate-y-0 transition-all duration-300 shadow-lg shadow-indigo-600/25 flex-shrink-0 flex items-center justify-center gap-1.5 group",children:[e.jsx("span",{children:"Get Started"}),e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5 group-hover:translate-x-1 transition-transform duration-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M14 5l7 7m0 0l-7 7m7-7H3"})})]})]})]})]})]}),V&&e.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center p-4 pt-12 sm:p-6 sm:pt-16 md:p-12 animate-fade-in",onClick:S,children:[e.jsx("div",{className:"absolute inset-0 bg-slate-900/60 backdrop-blur-xl"}),e.jsxs("div",{className:"relative w-full max-w-2xl transform transition-all",onClick:c=>c.stopPropagation(),children:[e.jsx("button",{onClick:S,className:"absolute -top-4 -right-4 sm:-top-5 sm:-right-5 z-50 w-8 h-8 sm:w-10 sm:h-10 flex items-center justify-center bg-black/40 hover:bg-black/60 text-white backdrop-blur-md rounded-full shadow-[0_4px_25px_rgba(0,0,0,0.25)] border border-white/20 transition-all duration-300 hover:scale-110 hover:rotate-90","aria-label":"Close modal",children:e.jsx(Qe,{className:"w-4 h-4 sm:w-5 sm:h-5"})}),e.jsxs("div",{className:"w-full bg-white rounded-[10px] shadow-[0_0_50px_-12px_rgba(0,0,0,0.5)] overflow-hidden ring-1 ring-white/20 flex flex-col max-h-[95vh] overflow-y-auto custom-scrollbar",children:[e.jsx("div",{className:"w-full relative flex-shrink-0 group border-b border-slate-100 bg-slate-900 aspect-video",children:e.jsx("iframe",{src:"https://www.youtube.com/embed/lMUDcVA8_iw?autoplay=1",title:"YouTube video player",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowFullScreen:!0,className:"w-full h-full"})}),e.jsxs("div",{className:"p-3 sm:p-4 bg-white flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 sm:gap-4 relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-indigo-500/5 rounded-full blur-3xl -translate-y-1/2 translate-x-1/2 pointer-events-none"}),e.jsxs("div",{className:"relative z-10 max-w-xl",children:[e.jsxs("div",{className:"inline-flex items-center gap-1.5 mb-1.5 px-2.5 py-0.5 rounded-full bg-indigo-50 border border-indigo-100 text-indigo-700 text-[9px] sm:text-[10px] font-bold tracking-widest uppercase shadow-sm",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-indigo-500 animate-pulse"}),"Curriculum Guide"]}),e.jsx("h3",{className:"text-lg sm:text-xl font-extrabold text-slate-900 tracking-tight",children:"Build Your Curriculum"}),e.jsx("p",{className:"text-slate-500 text-xs sm:text-sm mt-1 leading-relaxed font-medium",children:"Watch this video to learn how to structure your course sections, add engaging lessons, and include quizzes."})]}),e.jsxs("button",{onClick:S,className:"relative z-10 w-full sm:w-auto bg-indigo-600 text-white px-4 py-2 sm:px-5 sm:py-2.5 rounded-md sm:rounded-lg font-bold text-xs sm:text-sm hover:bg-indigo-700 hover:-translate-y-0.5 active:translate-y-0 transition-all duration-300 shadow-lg shadow-indigo-600/25 flex-shrink-0 flex items-center justify-center gap-1.5 group",children:[e.jsx("span",{children:"Get Started"}),e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5 group-hover:translate-x-1 transition-transform duration-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M14 5l7 7m0 0l-7 7m7-7H3"})})]})]})]})]})]}),ie&&e.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center p-4 pt-12 sm:p-6 sm:pt-16 md:p-12 animate-fade-in",onClick:w,children:[e.jsx("div",{className:"absolute inset-0 bg-slate-900/80 backdrop-blur-md"}),e.jsx("div",{className:"relative w-full max-w-4xl max-h-full flex flex-col items-center justify-center animate-in zoom-in-95 duration-300",onClick:c=>c.stopPropagation(),children:e.jsxs("div",{className:"relative w-full max-w-3xl",children:[e.jsx("button",{onClick:w,className:"absolute -top-4 -right-4 sm:-top-5 sm:-right-5 z-50 w-8 h-8 sm:w-10 sm:h-10 flex items-center justify-center bg-black/40 hover:bg-black/60 text-white backdrop-blur-md rounded-full shadow-[0_4px_25px_rgba(0,0,0,0.25)] border border-white/20 transition-all duration-300 hover:scale-110 hover:rotate-90","aria-label":"Close modal",children:e.jsx(Qe,{className:"w-4 h-4 sm:w-5 sm:h-5"})}),e.jsxs("div",{className:"w-full bg-white rounded-[10px] shadow-[0_0_50px_-12px_rgba(0,0,0,0.5)] overflow-hidden ring-1 ring-white/20 flex flex-col max-h-[95vh] overflow-y-auto custom-scrollbar",children:[e.jsx("div",{className:"w-full relative flex-shrink-0 group border-b border-slate-100 bg-slate-900 aspect-video",children:e.jsx("iframe",{src:"https://www.youtube.com/embed/H7SXzTklx6k?autoplay=1",title:"YouTube video player",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowFullScreen:!0,className:"w-full h-full"})}),e.jsxs("div",{className:"p-3 sm:p-4 bg-white flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 sm:gap-4 relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-indigo-500/5 rounded-full blur-3xl -translate-y-1/2 translate-x-1/2 pointer-events-none"}),e.jsxs("div",{className:"relative z-10 max-w-xl",children:[e.jsxs("div",{className:"inline-flex items-center gap-1.5 mb-1.5 px-2.5 py-0.5 rounded-full bg-indigo-50 border border-indigo-100 text-indigo-700 text-[9px] sm:text-[10px] font-bold tracking-widest uppercase shadow-sm",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-indigo-500 animate-pulse"}),"Live Classes Option"]}),e.jsx("h3",{className:"text-lg sm:text-xl font-extrabold text-slate-900 tracking-tight",children:"Hosting Live & Hybrid Sessions"}),e.jsx("p",{className:"text-slate-500 text-xs sm:text-sm mt-1 leading-relaxed font-medium",children:"Watch this quick video to learn how to offer remote live classes via Google Meet, or Hybrid classes at an approved physical skill center."})]}),e.jsxs("button",{onClick:w,className:"relative z-10 w-full sm:w-auto bg-indigo-600 text-white px-4 py-2 sm:px-5 sm:py-2.5 rounded-md sm:rounded-lg font-bold text-xs sm:text-sm hover:bg-indigo-700 hover:-translate-y-0.5 active:translate-y-0 transition-all duration-300 shadow-lg shadow-indigo-600/25 flex-shrink-0 flex items-center justify-center gap-1.5 group",children:[e.jsx("span",{children:"Configure Classes"}),e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-3.5 w-3.5 group-hover:translate-x-1 transition-transform duration-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M14 5l7 7m0 0l-7 7m7-7H3"})})]})]})]})]})})]})]})};async function Zt(s,r){const l=document.createElement("canvas"),y=s.naturalWi
11dth/s.width,n=s.naturalHeight/s.height;l.width=r.width,l.height=r.height;const _=l.getContext("2d");return _?(_.drawImage(s,r.x*y,r.y*n,r.width*y,r.height*n,0,0,r.width,r.height),new Promise(o=>{l.toBlob(g=>o(g),"image/jpeg",.8)})):null}export{gi as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.