import{_ as D}from"./Cd5yfd14.js";import{d as F,G as E,r as h,v,l as I,m as L,s as N,c as i,f as R,e as t,h as a,t as c,z as B,C as V,D as x,H as z,F as O,p as U,b as m,_ as W}from"./tpFEFzWU.js";import{d as j}from"./C0Rlrcoy.js";import{u as G}from"./jiBgvKN8.js";import{u as J}from"./BGpVLUX4.js";import{u as y}from"./Grz13CMP.js";import{u as P}from"./B-hNDTeU.js";import"./DM9QX0ua.js";const Y={class:"issue-comments-page"},q={class:"comments-content card"},K=["placeholder"],Q=["disabled"],X={key:0,class:"loading"},Z={key:1,class:"empty"},ee={key:2,class:"comments-list"},te={class:"comment-header"},se={class:"comment-author"},oe={class:"comment-date"},ae=["innerHTML"],ne=F({__name:"comments",async setup(re){let s,l;const b=E(),{success:g,error:w}=G(),{getErrorMessage:C}=J(),u=b.params.id,o=h(""),d=h(!1),{data:n}=([s,l]=v(()=>y(`/api/issues/${u}`,"$sHdW2Rruhz")),s=await s,l(),s),$=I(()=>{if(!n.value)return null;const e={id:n.value.key,title:n.value.title,column:n.value.column_slug};return n.value.priority&&(e.priority=n.value.priority),e}),{data:p,status:k,refresh:_}=([s,l]=v(()=>y(`/api/issues/${u}/comments`,"$2TYRtwuSoA")),s=await s,l(),s),{lastMessage:S}=P();L(S,e=>{e?.type==="comment"&&e.issueId===u&&_()});const H=e=>new Date(e).toLocaleString(),M=e=>j(e),T=async()=>{if(o.value.trim()){d.value=!0;try{await fetch(`/api/issues/${u}/comments`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:o.value})}),o.value="",g("Comment added"),_()}catch(e){w(C(e,"Failed to add comment"))}finally{d.value=!1}}};return N({title:`Comments - ${u} - AutoCode`}),(e,f)=>{const A=D;return m(),i("div",Y,[R(A,{issue:a($),"active-tab":"comments"},null,8,["issue"]),t("div",q,[t("h2",null,c(e.$t("issue.comments")),1),t("form",{class:"comment-form",onSubmit:B(T,["prevent"])},[V(t("textarea",{"onUpdate:modelValue":f[0]||(f[0]=r=>z(o)?o.value=r:null),class:"form-input comment-input",placeholder:e.$t("issue.addComment"),rows:"3"},null,8,K),[[x,a(o)]]),t("button",{type:"submit",class:"btn btn-primary",disabled:!a(o).trim()||a(d)},c(e.$t("form.save")),9,Q)],32),a(k)==="pending"?(m(),i("div",X,c(e.$t("app.loading")),1)):a(p)?.length?(m(),i("ul",ee,[(m(!0),i(O,null,U(a(p),r=>(m(),i("li",{key:r.id,class:"comment"},[t("div",te,[t("span",se,c(r.author||"User"),1),t("time",oe,c(H(r.createdAt)),1)]),t("div",{class:"comment-body",innerHTML:M(r.content)},null,8,ae)]))),128))])):(m(),i("div",Z,c(e.$t("issue.noComments")),1))])])}}}),fe=W(ne,[["__scopeId","data-v-b988772a"]]);export{fe as default};
