import{aT as E,aU as H,j as s,bd as x,bl as h,bi as j,a_ as L,bk as B}from"./react-vendor-xYZnmIII.js";import{D as u}from"./delete-modal-h3jQBOO6.js";import{I as p}from"./input-error-_LAmvivg.js";import{L as T}from"./loading-button-D7aXR3K4.js";import{L as g,I as k,j as N,A as v,h as f,i as w,V as b,W as y,B as r,X as C,Y as l}from"./ui-components-CQM92IK3.js";import{o as q}from"./inertia-FIn3q7f1.js";import{j as R,P as M}from"./richtor-BECSBxkh.js";import V from"./forum-edit-Ca9njr--.js";import _ from"./forum-reply-Dvj7N6up.js";import"./inertia-vendor-cBbDTmhJ.js";import"./ui-vendor-Ds9iwIxa.js";import"./interactive-vendor-B1OgcAgP.js";const es=()=>{const{props:t,url:n}=E(),{translate:D}=t,{button:c,input:i,frontend:z}=D,A=t.watching,{data:o,setData:d,post:I,errors:m,processing:P,reset:F}=H({url:n,title:"",description:"",user_id:t.auth.user.id,course_id:t.course.id,section_lesson_id:t.watching.id}),S=e=>{e.preventDefault(),I(route("course-forums.store"),{onSuccess:()=>{F()}})};return s.jsxs("div",{children:[s.jsxs("form",{onSubmit:S,className:"space-y-4 p-0.5",children:[s.jsxs("div",{children:[s.jsx(g,{children:i.title}),s.jsx(k,{required:!0,type:"text",name:"title",value:o.title,placeholder:i.title_placeholder,onChange:e=>q(e,d)}),s.jsx(p,{message:m.title})]}),s.jsxs("div",{children:[s.jsx(g,{children:i.description}),s.jsx(R,{ssr:!0,output:"html",placeholder:{paragraph:i.description,imageCaption:i.image_url_placeholder},contentMinHeight:160,contentMaxHeight:400,initialContent:o.description,onContentChange:e=>d("description",e)}),s.jsx(p,{message:m.description})]}),s.jsx(T,{loading:P,children:c.submit})]}),s.jsx(N,{className:"my-6"}),A.forums.map(e=>s.jsxs("div",{className:"space-y-4 rounded-lg border p-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(v,{className:"h-8 w-8",children:[s.jsx(f,{src:e.user.photo||"",alt:e.user.name,className:"object-cover"}),s.jsx(w,{children:e.user.name.charAt(0)})]}),s.jsxs("div",{children:[s.jsx("p",{className:"font-semibold",children:e.user.name}),s.jsx("p",{className:"text-muted-foreground text-xs",children:x(new Date(e.created_at),"MMM d, yyyy h:mm a")})]})]}),e.user_id===t.auth.user.id&&s.jsxs(b,{children:[s.jsx(y,{children:s.jsx(r,{variant:"secondary",size:"icon",className:"size-8",children:s.jsx(h,{})})}),s.jsxs(C,{align:"end",children:[s.jsx(l,{asChild:!0,children:s.jsx(V,{url:n,forum:e})}),s.jsx(l,{asChild:!0,children:s.jsx(u,{routePath:route("course-forums.destroy",e.id),actionComponent:s.jsxs(r,{size:"sm",variant:"ghost",className:"w-full cursor-pointer justify-start px-2",children:[s.jsx(j,{className:"h-4 w-4"}),s.jsx("span",{children:c.delete})]})})})]})]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-lg font-medium",children:e.title}),s.jsx(M,{value:e.description})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(_,{url:n,forum:e,user:t.auth.user,actionComponent:s.jsxs(r,{variant:"outline",size:"sm",className:"flex items-center gap-2 shadow-none",children:[s.jsx(L,{className:"h-4 w-4"}),s.jsx("span",{children:c.reply})]})}),s.jsxs("p",{className:"text-muted-foreground text-xs",children:[e.replies.length," ",z.replies]})]}),s.jsx(N,{className:"my-6"}),s.jsx("div",{className:"space-y-8 pl-6",children:e.replies.map(a=>s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(v,{className:"h-8 w-8",children:[s.jsx(f,{src:a.user.photo||"",alt:a.user.name,className:"object-cover"}),s.jsx(w,{children:a.user.name.charAt(0)})]}),s.jsxs("div",{children:[s.jsx("p",{className:"font-semibold",children:a.user.name}),s.jsx("p",{className:"text-muted-foreground text-xs",children:x(new Date(a.created_at),"MMM d, yyyy h:mm a")})]})]}),a.user_id===t.auth.user.id&&s.jsxs(b,{children:[s.jsx(y,{children:s.jsx(r,{variant:"secondary",size:"icon",className:"size-8",children:s.jsx(h,{})})}),s.jsxs(C,{align:"end",children:[s.jsx(l,{asChild:!0,children:s.jsx(_,{url:n,forum:e,reply:a,user:t.auth.user,actionComponent:s.jsxs(r,{size:"sm",variant:"ghost",className:"w-full cursor-pointer justify-start px-2",children:[s.jsx(B,{className:"h-4 w-4"}),s.jsx("span",{children:c.edit})]})})}),s.jsx(l,{asChild:!0,children:s.jsx(u,{routePath:route("course-forum-replies.destroy",a.id),actionComponent:s.jsxs(r,{size:"sm",variant:"ghost",className:"w-full cursor-pointer justify-start px-2",children:[s.jsx(j,{className:"h-4 w-4"}),s.jsx("span",{children:"Delete"})]})})})]})]})]}),s.jsx(M,{value:a.description})]},a.id))})]},e.id))]})};export{es as default};
