import{$ as C,q as f,_ as w,r as a,o,a as n,e as t,f as d,k as p,w as N,g as l,t as g,d as _,x as b,y as L,F as B,j as T}from"./_plugin-vue_export-helper-DfQgE-tC.js";import{B as S}from"./BackendResponse-9vt7nNmn.js";import I from"./Avatar-gjRASNeR.js";import{F as U}from"./InputModelBase-CeuTljlj.js";import{F as A}from"./FormError-s39Y7_4b.js";import{F as q}from"./FormFooter-BIXY-K-U.js";import{I as z}from"./InputTextarea-D-_ql-5p.js";import{S as x}from"./SuccessMessage-Dc-q-6eb.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./InputButton-DNVNN41X.js";function K(e){const s={header:{type:"buchhalterComments",action:"getComments",accessToken:agenda.wUserCur.accessToken},form:{guid:{value:e}}};return C.ajax({url:agenda.request.url,method:"POST",data:s})}function j(e){const s={header:{type:"buchhalterComments",action:"saveComment",accessToken:agenda.wUserCur.accessToken},form:e};return C.ajax({url:agenda.request.url,method:"POST",data:s})}function O(e){$(e).wAccordion()}const H=f({components:{Avatar:I,FormError:A,FormFooter:q,InputTextarea:z,SuccessMessage:x},props:{guid:String},mounted(){O(".commentFormAccordion"),agenda.wUserCur.vorname&&(this.account.fullName=agenda.wUserCur.vorname+" "),agenda.wUserCur.nachname&&(this.account.fullName+=agenda.wUserCur.nachname)},data:()=>({account:{avatar:agenda.wUserCur.avatar,fullName:"",isLoggedIn:agenda.wUserCur.isLoggedIn},frageId:0,user:{comment:new U("Kommentar")},loginCall:"/login?referer="+window.location.pathname,showError:!1,showSuccess:!1,showLoading:!1}),methods:{submitComment(){this.showLoading=!0,this.showError=!1,this.showSuccess=!1;let e=window.location.pathname.replace("/buchhalterseite2022",""),s={guid:{value:this.guid},path:{value:e},comment:{value:this.user.comment.value}};j(s).then(u=>{let h=new S(u);this.showLoading=!1,h.err.code===-1?(this.showError=!1,this.showSuccess=!0,this.user.comment.value="",this.$emit("loadComments")):(this.showError=!0,this.showSuccess=!1)}).catch(()=>{this.showLoading=!1,this.showError=!0,this.showSuccess=!1})}},emits:["loadComments"]}),i=e=>(b("data-v-b213cdef"),e=e(),L(),e),V={id:"elementAccordion_comments4711",class:"elementAccordion elementAccordion_var0 isLightBackground iconsDefault"},D={id:"accordion_comments4711",class:"commentFormAccordion","data-initopen":"false","data-collapsible":"1","data-multiple":"1"},M=i(()=>t("p",{class:"accordionHeader h3"},[d(" Kommentar hinterlassen "),t("span",{class:"accordionHeaderOpener"})],-1)),R={class:"accordionContent accordionContentHidden"},P={key:0},W=i(()=>t("a",{target:"_blank",href:"/wissen/netiquette.php"},"Netiquette",-1)),G={key:1,class:"not-logged-in"},J=i(()=>t("br",null,null,-1)),Q=i(()=>t("br",null,null,-1)),X=i(()=>t("a",{href:"/register",aga:"",category:"button",label:"zur_registrierung",action:"geklickt"}," Jetzt registrieren ",-1)),Y=["href"],Z={class:"comment-author"},ee={class:"profile-img"},te={class:"profile-fullname"},oe={class:"h4"},se=i(()=>t("div",{class:"clear"},null,-1));function ne(e,s,u,h,v,k){const c=a("success-message"),r=a("avatar"),m=a("input-textarea"),F=a("form-footer"),E=a("form-error");return o(),n("div",null,[t("div",V,[t("div",D,[M,t("div",R,[t("div",null,[e.account.isLoggedIn?(o(),n("p",P,[d(" Gestalten Sie als Leser den Dialog aktiv mit. Wir freuen uns über Ihre konstruktiven Kommentare. Achten Sie bitte auf die gängigen Verhaltensregeln aus der "),W,d(". ")])):(o(),n("p",G,[d(" Dieser Artikel ist nur für registrierte Nutzer kommentierbar. Wenn Sie den Artikel kommentieren möchten, registrieren Sie sich kostenlos in unserem Netzwerk oder melden Sie sich mit Ihren Benutzerdaten an."),J,Q,X,d("   "),t("a",{href:e.loginCall},"Login",8,Y)])),e.showSuccess?(o(),p(c,{key:2,title:"Ihr Kommentar wurde erfolgreich übermittelt."})):e.account.isLoggedIn?(o(),n("form",{key:3,onSubmit:s[0]||(s[0]=N(ve=>e.submitComment(),["prevent"]))},[t("div",Z,[t("div",ee,[l(r,{avatar:e.account.avatar},null,8,["avatar"])]),t("div",te,[t("p",oe,g(e.account.fullName),1)]),se]),l(m,{class:"ainput",model:e.user.comment},null,8,["model"]),l(F,{"button-text":"Absenden","show-button":!e.showLoading,"show-loading":e.showLoading,alignment:"left"},null,8,["show-button","show-loading"]),e.showError?(o(),p(E,{key:0,"show-default-title":"Fehler beim Speichern des neuen Kommentars!"})):_("",!0)],32)):_("",!0)])])])])])}const ae=w(H,[["render",ne],["__scopeId","data-v-b213cdef"]]),re=f({components:{Avatar:I},props:{comments:{type:Array,required:!0}},data:()=>({isLoggedIn:agenda.wUserCur.isLoggedIn}),methods:{resizedAvatar(e){return this.isLoggedIn?!e.is_moderator&&e.avatar.length>4&&e.avatar.indexOf("/buchhalterseite2022-wAssets")===-1?e.avatar+"_image_scaler_168xauto.jpg":e.avatar:""}}}),y=e=>(b("data-v-adaf98be"),e=e(),L(),e),ie=y(()=>t("div",{class:"kommentar-liste-header"},[t("p",{class:"h4"},"Kommentare")],-1)),ce={class:"kommentar-liste"},me={class:"kommentar-avatar-holder"},de={class:"kommentar-datum"},le={key:0,class:"h4 kommentar-autor"},ue={key:1,class:"h4 kommentar-autor"},he=["innerHTML"],pe=y(()=>t("div",{class:"clearBoth"},null,-1));function _e(e,s,u,h,v,k){const c=a("avatar");return o(),n("div",null,[ie,t("ul",ce,[(o(!0),n(B,null,T(e.comments,(r,m)=>(o(),n("li",{key:m},[t("div",me,[l(c,{avatar:e.resizedAvatar(r),size:50},null,8,["avatar"])]),t("p",de,g(r.date),1),e.isLoggedIn?(o(),n("p",le,g(r.author),1)):(o(),n("p",ue,"Registrierter User")),t("div",{class:"kommentar-text",innerHTML:r.text},null,8,he),pe]))),128))])])}const ge=w(re,[["render",_e],["__scopeId","data-v-adaf98be"]]),fe=f({components:{CommentForm:ae,CommentList:ge,FormError:A},props:{guid:{type:String,required:!0}},data:()=>({comments:[],showError:!1}),mounted(){this.loadComments()},methods:{loadComments(){this.showError=!1,K(this.guid).then(e=>{let s=new S(e);s.err.code===-1?this.comments=s.tab:this.showError=!0}).catch(()=>{this.showError=!0})}}});function we(e,s,u,h,v,k){const c=a("comment-form"),r=a("comment-list"),m=a("form-error");return o(),n("div",null,[l(c,{guid:e.guid,onLoadComments:e.loadComments},null,8,["guid","onLoadComments"]),e.comments.length>0?(o(),p(r,{key:0,comments:e.comments},null,8,["comments"])):_("",!0),e.showError?(o(),p(m,{key:1,"show-default-text":!1,"show-default-title":"Beim Laden der Kommentare ist ein Fehler aufgetreten."})):_("",!0)])}const Ee=w(fe,[["render",we]]);export{Ee as default};