import{u as v,j as e,ct as b,bm as j,e as g,c0 as _,c7 as C,x as Q,T as k,n as N,a8 as D,cu as A}from"./vendor-BKmmeuxg.js";import{D as S}from"./data-sort-modal-B2Yf_crJ.js";import{Q as P}from"./question-type-badge-C65yTFrV.js";import{D as T}from"./delete-modal-D1GJlb1P.js";import{B as a}from"./button-BpNwv2aE.js";import{C as n,b as f}from"./card-D9_SJYq6.js";import{e as z}from"./richtor-CRcM6Du2.js";import o from"./question-dialog-DeJfEfRF.js";import"./utils-DxSsnXxD.js";import"./dialog-B2gN9MvT.js";import"./scroll-area-C8HGru-R.js";import"./badge-AQfLLMpR.js";import"./index-WW_1X1qx.js";import"./input-error-LaPr_4wd.js";import"./loading-button-BnTVAMJ7.js";import"./input-DM0goJrn.js";import"./label-HmIcv5Yx.js";import"./select-CD9o3HN1.js";import"./inertia-SZXqLvQm.js";import"./fill-blank-form-D0Ep5llL.js";import"./listening-form-JPfVJits.js";import"./chunked-uploader-input-D0XPVOTS.js";import"./index-D9-QKOod.js";import"./radio-group-C0C2vfl-.js";import"./textarea-CyndvowL.js";import"./matching-form-DGgyfKHG.js";import"./multiple-choice-form-Dm-x1oeK.js";import"./checkbox-BBZKtHnN.js";import"./ordering-form-DjRuOH93.js";import"./short-answer-form-Ct6uyXHG.js";const ce=()=>{const{props:y}=v(),{exam:r}=y,{questions:i}=r,w=s=>{g.post(route("exam-questions.duplicate",{question:s}),{},{preserveScroll:!0})};return i.length===0?e.jsx(n,{children:e.jsxs(f,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx("div",{className:"mb-4 rounded-full bg-gray-100 p-6",children:e.jsx(b,{className:"h-12 w-12 text-gray-400"})}),e.jsx("h3",{className:"mb-2 text-xl font-semibold text-gray-900",children:"No Questions Yet"}),e.jsx("p",{className:"mb-6 max-w-md text-center text-gray-600",children:"Start building your exam by adding questions. You can create multiple choice, short answer, and many other question types."}),e.jsx(o,{exam:r,handler:e.jsxs(a,{children:[e.jsx(j,{className:"h-4 w-4"}),"Add First Question"]})})]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Exam Questions"}),e.jsxs("p",{className:"text-sm text-gray-600",children:[i.length," ",i.length===1?"question":"questions"," • Total: ",r.total_marks," marks"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(S,{title:"Questions",data:i,handler:e.jsxs(a,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(_,{className:"h-4 w-4"}),"Reorder"]}),onOrderChange:(s,m)=>{g.post(route("exam-questions.reorder"),{sortedData:s},{preserveScroll:!0,onSuccess:()=>m&&m(!1)})},renderContent:s=>e.jsx(n,{className:"flex w-full items-center justify-between px-4 py-3",children:e.jsx("p",{children:s.title})})}),e.jsx(o,{exam:r,handler:e.jsxs(a,{children:[e.jsx(j,{className:"h-4 w-4"}),"Add Question"]})})]})]}),e.jsx("div",{className:"space-y-3",children:i.map((s,m)=>{var c,d,x,p,h,u;return e.jsx(n,{className:"transition-shadow hover:shadow-md",children:e.jsxs(f,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-gray-500",children:["Q",m+1]}),e.jsx(P,{type:s.question_type}),e.jsxs("span",{className:"text-sm font-medium text-blue-600",children:[s.marks," marks"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a,{size:"icon",variant:"ghost",className:"bg-muted hover:bg-muted-foreground/10 h-8 w-8 rounded-full p-0",onClick:()=>w(s.id),children:e.jsx(C,{className:"h-4 w-4"})}),e.jsx(o,{exam:r,question:s,handler:e.jsx(a,{size:"icon",variant:"ghost",className:"bg-muted hover:bg-muted-foreground/10 h-8 w-8 rounded-full p-0",children:e.jsx(Q,{className:"h-4 w-4"})})}),e.jsx(T,{message:"Are you sure you want to delete this question?",routePath:route("exam-questions.destroy",s.id),actionComponent:e.jsx(a,{size:"icon",variant:"ghost",className:"bg-destructive/8 hover:bg-destructive/6 h-8 w-8 rounded-full p-0",children:e.jsx(k,{className:"text-destructive text-sm"})})})]})]}),e.jsx("h4",{className:"mb-1 font-medium text-gray-900",children:s.title}),e.jsx(z,{value:s.description||""}),(s.question_type==="multiple_choice"||s.question_type==="multiple_select")&&s.question_options&&s.question_options.length>0&&e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-x-6 gap-y-3",children:s.question_options.map(t=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.is_correct?e.jsx(N,{strokeWidth:3,className:"h-4 w-4 text-green-500"}):e.jsx(D,{strokeWidth:3,className:"h-4 w-4 text-gray-300"}),e.jsx("span",{className:t.is_correct?"font-medium text-green-700":"text-gray-600",children:t.option_text})]},t.id))}),s.question_type==="matching"&&((c=s.options)==null?void 0:c.matches)&&s.options.matches.length>0&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-gray-500",children:"Matching Pairs:"}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:s.options.matches.map((t,l)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-gray-50 p-2 text-sm",children:[e.jsx("span",{className:"text-gray-700",children:t.question}),e.jsx(A,{className:"h-3 w-3 text-gray-400"}),e.jsx("span",{className:"font-medium text-green-600",children:t.answer})]},l))})]}),s.question_type==="fill_blank"&&((d=s.options)==null?void 0:d.answers)&&s.options.answers.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"mb-1 text-xs font-medium text-gray-500",children:"Accepted Answers:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.options.answers.map((t,l)=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-green-50 px-2 py-1 text-sm font-medium text-green-700",children:[e.jsx(N,{className:"h-3 w-3"}),t]},l))})]}),s.question_type==="ordering"&&((x=s.options)==null?void 0:x.items)&&s.options.items.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"mb-1 text-xs font-medium text-gray-500",children:"Correct Order:"}),e.jsx("ol",{className:"list-inside list-decimal space-y-1 text-sm text-gray-700",children:s.options.items.map((t,l)=>e.jsx("li",{children:t},l))})]}),s.question_type==="short_answer"&&((p=s.options)==null?void 0:p.sample_answer)&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"mb-1 text-xs font-medium text-gray-500",children:"Guidelines:"}),e.jsx("p",{className:"rounded-md bg-gray-50 p-2 text-sm text-gray-700",children:s.options.sample_answer})]}),s.question_type==="listening"&&e.jsxs("div",{className:"mt-3 space-y-2",children:[((h=s.options)==null?void 0:h.audio_url)&&e.jsxs("audio",{controls:!0,className:"h-11 w-full",children:[e.jsx("source",{src:s.options.audio_url,type:"audio/mpeg"}),"Your browser does not support the audio element."]}),((u=s.options)==null?void 0:u.instructions)&&e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-xs font-medium text-gray-500",children:"Instructions:"}),e.jsx("p",{className:"text-sm text-gray-700",children:s.options.instructions})]})]})]})},s.id)})})]})};export{ce as default};