var F=Object.defineProperty,I=Object.defineProperties;var L=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable;var v=(t,s,r)=>s in t?F(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,y=(t,s)=>{for(var r in s||(s={}))B.call(s,r)&&v(t,r,s[r]);if(_)for(var r of _(s))E.call(s,r)&&v(t,r,s[r]);return t},k=(t,s)=>I(t,L(s));import{r as M,aT as O,aU as Q,j as e}from"./react-vendor-xYZnmIII.js";import{I as m}from"./input-error-_LAmvivg.js";import{L as U}from"./loading-button-D7aXR3K4.js";import{J as A,K as J,M as K,e as P,N as R,O as w,L as d,I as c,Q as G,U as V,B as W}from"./ui-components-CQM92IK3.js";import{o as i}from"./inertia-FIn3q7f1.js";import{j as X}from"./richtor-BECSBxkh.js";import"./inertia-vendor-cBbDTmhJ.js";import"./ui-vendor-Ds9iwIxa.js";import"./interactive-vendor-B1OgcAgP.js";const ne=({title:t,quiz:s,handler:r,sectionId:f})=>{const[C,x]=M.useState(!1),{props:j}=O(),{translate:b}=j,{dashboard:h,input:p,button:u}=b,{data:n,setData:o,post:D,put:N,reset:g,errors:l,processing:S}=Q({title:(s==null?void 0:s.title)||"",course_section_id:f,course_id:j.course.id,total_mark:(s==null?void 0:s.total_mark)||"",pass_mark:(s==null?void 0:s.pass_mark)||"",retake:(s==null?void 0:s.retake)||1,summary:(s==null?void 0:s.summary)||"",hours:(s==null?void 0:s.hours)||"",minutes:(s==null?void 0:s.minutes)||"",seconds:(s==null?void 0:s.seconds)||""}),H=a=>{a.preventDefault(),s?N(route("quiz.update",s.id),{onSuccess:()=>{g(),x(!1)}}):D(route("quiz.store"),{onSuccess:()=>{g(),x(!1)}})};return e.jsxs(A,{open:C,onOpenChange:x,children:[e.jsx(J,{children:r}),e.jsx(K,{className:"p-0",children:e.jsxs(P,{className:"max-h-[90vh] p-6",children:[e.jsx(R,{className:"mb-6",children:e.jsx(w,{children:t})}),e.jsxs("form",{onSubmit:H,className:"space-y-4 p-0.5",children:[e.jsxs("div",{children:[e.jsx(d,{children:p.title}),e.jsx(c,{required:!0,type:"text",name:"title",value:n.title,placeholder:p.quiz_title_placeholder,onChange:a=>i(a,o)}),e.jsx(m,{message:l.title})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(d,{children:h.hours}),e.jsx(c,{required:!0,type:"number",name:"hours",value:n.hours,placeholder:p.hours_placeholder,onChange:a=>i(a,o)}),e.jsx(m,{message:l.hours})]}),e.jsxs("div",{children:[e.jsx(d,{children:h.minutes}),e.jsx(c,{required:!0,type:"number",name:"minutes",value:n.minutes,placeholder:p.minutes_placeholder,onChange:a=>i(a,o)}),e.jsx(m,{message:l.minutes})]}),e.jsxs("div",{children:[e.jsx(d,{children:h.seconds}),e.jsx(c,{required:!0,type:"number",name:"seconds",value:n.seconds,placeholder:p.seconds_placeholder,onChange:a=>i(a,o)}),e.jsx(m,{message:l.seconds})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(d,{children:h.total_mark}),e.jsx(c,{required:!0,type:"number",name:"total_mark",value:n.total_mark,onChange:a=>i(a,o)}),e.jsx(m,{message:l.total_mark})]}),e.jsxs("div",{children:[e.jsx(d,{children:h.pass_mark}),e.jsx(c,{required:!0,type:"number",name:"pass_mark",value:n.pass_mark,onChange:a=>i(a,o)}),e.jsx(m,{message:l.pass_mark})]}),e.jsxs("div",{children:[e.jsx(d,{children:p.retake_attempts}),e.jsx(c,{min:"1",required:!0,type:"number",name:"retake",value:n.retake,placeholder:"00",onChange:a=>i(a,o)}),e.jsx(m,{message:l.retake})]})]}),e.jsxs("div",{children:[e.jsx(d,{htmlFor:"summary",children:h.quiz_summary}),e.jsx(X,{ssr:!0,output:"html",placeholder:{paragraph:"Type your content here...",imageCaption:"Type caption for image (optional)"},contentMinHeight:256,contentMaxHeight:640,initialContent:n.summary,onContentChange:a=>o(T=>k(y({},T),{summary:a}))}),e.jsx(m,{message:l.summary})]}),e.jsxs(G,{className:"flex justify-end space-x-2 pt-4",children:[e.jsx(V,{asChild:!0,children:e.jsx(W,{type:"button",variant:"outline",children:u.close})}),e.jsx(U,{loading:S,children:u.submit})]})]})]})})]})};export{ne as default};
