"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["app/aha"],{2394:(e,t,s)=>{s.r(t),s.d(t,{default:()=>o});var i=s(89);class n extends i.Popup{_initConfiguration(e){this.setLocale(i.Locale.getSection("components.aha")),super._initConfiguration({id:"aha-dialog",title:this.lmsg("voteTitle"),closeButtonEnabled:!0,hideOnEscape:!0,content:`<div class="form-box form--vertical"><div class="box-area"><div class="content"><div class="content-area"><div class="nps-survey"><p class="nps-survey__question">${this.lmsg("voteQuestion")}</p><div class="nps-survey__container"><div id="aha-rating" class="nps-survey__scores"></div><div class="nps-survey__legend"><div class="nps-survey__legend-left">${this.lmsg("voteLegendBad")}</div><div class="nps-survey__legend-right">${this.lmsg("voteLegendGood")}</div></div></div></div><hr/><div class="form-row"><div class="field-name">${this.lmsg("voteGoodHint")}</div><div class="field-value"><textarea id="aha-good" class="f-max-size" maxlength="1000"></textarea></div></div><div class="form-row"><div class="field-name">${this.lmsg("voteBetterHint")}</div><div class="field-value"><textarea id="aha-better" class="f-max-size" maxlength="1000"></textarea></div></div></div></div></div></div>`,buttons:[{title:this.lmsg("voteButtonOk"),id:"aha-vote-button-ok",class:"action",handler:this.handleVoteButton.bind(this)},{title:i.Locale.getSection("components.buttons").lmsg("cancel"),id:"aha-vote-button-cancel",handler(e,t){t.hide()}}],...e})}_initComponentElement(){super._initComponentElement(),(0,i.render)(this._componentElement.querySelector("#aha-rating"),[0,1,2,3,4,5,6,7,8,9,10].map((e=>(0,i.createElement)("label",{class:`nps-survey__score nps-survey__score--${e}`,onclick:this.checkPossibleSendVote.bind(this)},[(0,i.createElement)("input",{type:"radio",name:"nps-survey-option",value:e}),(0,i.createElement)("span",{class:"nps-survey__score-label"})]))))}hide(){super.hide(),this.voted||(this.checkPossibleSendVote()||this.getFeedbackGood()||this.getFeedbackBetter()?this.sendVote():this.sendHide())}handleVoteButton(){this.checkPossibleSendVote()&&(this.voted=!0,this.sendVote(),this.hide(),new a)}checkPossibleSendVote(){const e=this._componentElement.querySelector(".nps-survey"),t=this.getRate();if(t){e.classList.remove("error");const t=e.querySelector(".field-errors");t&&t.parentNode.removeChild(t)}else{e.classList.add("error");e.querySelector(".field-errors")||(0,i.render)(e,`<span class="field-errors"><span class="error-hint">${this.lmsg("voteRequire")}</span></span>`)}return t}sendVote(){i.api.post((0,i.prepareUrl)("/admin/aha/vote"),{voted:this.voted||!1,rate:this.getRate(),feedbackGood:this.getFeedbackGood(),feedbackBetter:this.getFeedbackBetter(),dialogAtPage:window.location.pathname})}sendHide(){i.api.post((0,i.prepareUrl)("/admin/aha/hide"))}getRate(){const e=this._componentElement.querySelector(`#${this.getId()}-form input[name=nps-survey-option]:checked`);return e?e.value:""}getFeedbackGood(){return this._componentElement.querySelector("#aha-good").value.trim()}getFeedbackBetter(){return this._componentElement.querySelector("#aha-better").value.trim()}}class a extends i.Popup{_initConfiguration(e){this.setLocale(i.Locale.getSection("components.aha"));const t=[{title:this.lmsg("thankButtonClose"),class:"action",handler(e,t){t.hide()}}],s=`<p>${this.lmsg("thankHint")}</p>`;super._initConfiguration({id:"thank-dialog",title:this.lmsg("thankTitle"),closeButtonEnabled:!0,hideOnEscape:!0,content:s,buttons:t,...e})}}const o=e=>new n(e)}}]);
//# sourceMappingURL=aha.js.map?715b3360414e153e968b