var M=Object.defineProperty,U=Object.defineProperties;var V=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable;var f=(r,s,t)=>s in r?M(r,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[s]=t,v=(r,s)=>{for(var t in s||(s={}))F.call(s,t)&&f(r,t,s[t]);if(_)for(var t of _(s))J.call(s,t)&&f(r,t,s[t]);return r},b=(r,s)=>U(r,V(s));import{r as K,aT as P,aU as R,j as e,aS as y,aX as N}from"./react-vendor-xYZnmIII.js";import{I as C}from"./input-error-_LAmvivg.js";import{L as X}from"./loading-button-D7aXR3K4.js";import{B as l,c as A,J as S,K as w,M as k,L as z,at as G,au as Q,av as W,aw as Y,ax as Z,N as $,O as ee}from"./ui-components-CQM92IK3.js";import{j as se}from"./richtor-BECSBxkh.js";import"./inertia-vendor-cBbDTmhJ.js";import"./ui-vendor-Ds9iwIxa.js";import"./interactive-vendor-B1OgcAgP.js";const ue=()=>{const[r,s]=K.useState(!1),{props:t}=P(),{translate:D}=t,{dashboard:n,button:c,input:u,common:x}=D,H=t.auth.user,{course:i,watchHistory:o,approvalStatus:L}=t,O=t.statuses.filter(a=>a!==i.status),{approve_able:p,validation_messages:T,counts:d}=L,{data:m,put:q,setData:j,processing:B,errors:g,reset:E}=R({status:"",feedback:""}),I=a=>{a.preventDefault(),q(route("course.status",{id:i.id}),{onSuccess:()=>{E(),s(!1)}})};return e.jsxs("div",{className:"flex flex-wrap items-center gap-4 md:gap-6",children:[e.jsx(l,{children:e.jsx(y,{href:route("course.details",{slug:i.slug,id:i.id}),children:c.course_preview})}),o?e.jsx(l,{children:e.jsx(y,{href:route("course.player",{type:o.current_watching_type,watch_history:o.id,lesson_id:o.current_watching_id}),children:c.course_player})}):p?e.jsx(l,{onClick:()=>N.post(route("player.init.watch-history"),{course_id:i.id}),children:c.course_player}):e.jsx(l,{disabled:!0,children:c.course_player}),e.jsx(l,{className:A("capitalize",i.status==="approved"?"bg-green-500":i.status==="rejected"?"bg-red-500":"bg-gray-500"),disabled:!0,children:i.status}),p?H.role==="instructor"?i.status!=="approved"&&i.status!=="pending"&&e.jsx(l,{onClick:()=>N.put(route("course.status",{id:i.id}),{status:"pending"}),children:c.submit_for_approval}):e.jsxs(S,{open:r,onOpenChange:s,children:[e.jsx(w,{asChild:!0,children:e.jsx(l,{className:"capitalize",children:c.approval_status})}),e.jsx(k,{children:e.jsxs("form",{onSubmit:I,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(z,{children:x.status}),e.jsxs(G,{required:!0,value:m.status,onValueChange:a=>j("status",a),children:[e.jsx(Q,{className:"capitalize",children:e.jsx(W,{placeholder:x.select_the_approval_status})}),e.jsx(Y,{children:O.map(a=>e.jsx(Z,{value:a,className:"cursor-pointer capitalize",children:a},a))})]}),e.jsx(C,{message:g.status})]}),e.jsxs("div",{className:"pb-6",children:[e.jsxs(z,{children:[u.feedback," ","(Optional)"]}),e.jsx(se,{ssr:!0,output:"html",placeholder:{paragraph:u.description_placeholder,imageCaption:u.image_url_placeholder},contentMinHeight:256,contentMaxHeight:640,initialContent:m.feedback,onContentChange:a=>j(h=>b(v({},h),{feedback:a}))}),e.jsx(C,{message:g.feedback})]}),e.jsx(X,{loading:B,className:"w-full",children:c.submit})]})})]}):e.jsxs(S,{open:r,onOpenChange:s,children:[e.jsx(w,{children:e.jsx(l,{children:c.submit_for_approval})}),e.jsxs(k,{children:[e.jsx($,{children:e.jsx(ee,{children:n.course_approval_status})}),p?e.jsx("div",{className:"text-green-600",children:n.course_ready_approval}):e.jsxs("div",{className:"text-red-600",children:[e.jsx("h3",{children:n.course_needs_attention}),e.jsx("ul",{className:"list-disc pl-5",children:T.map((a,h)=>e.jsx("li",{children:a},h))})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:n.course_content_summary}),e.jsxs("p",{children:[n.sections,": ",d.sections_count]}),e.jsxs("p",{children:[n.lessons,": ",d.lessons_count]}),e.jsxs("p",{children:[n.quizzes,": ",d.quizzes_count]}),e.jsxs("p",{className:"font-medium",children:[n.total_content_items,": ",d.total_content_count]})]})]})]})]})};export{ue as default};
