import{a as u}from"./axios-dd1c8fc2.js";import{q as d,u as i,v as s,x as c,_ as m,J as b,K as f,G as h,D as g}from"./vue-0d7ee8e8.js";import{_ as k}from"./_plugin-vue_export-helper-b15b4a05.js";const _={data(){return{showForm:!1,msg:"",msgLength:0}},computed:{showFeedback(){return this.$page.props.layoutData.showFeedback},feedback(){return this.$page.props.layoutData.feedback},termsAsSearchQuery(){return this.$page.props.termsAsSearchQuery}},mounted(){document.querySelector(".close-feedback-alert")!=null&&document.querySelector(".close-feedback-alert").addEventListener("click",function(r){r.target.parentNode.parentNode.remove()},!1)},methods:{getFullUrl(){return this.termsAsSearchQuery?window.location.href+this.termsAsSearchQuery:window.location.href},submit(){var r=this;if(document.querySelector(".feedback_error").classList.add("hidden"),this.msg!==""){var t=/<s*a[^>]*>(.*?)<s*\/s*a>/ig,a=this.msg.match(t),o=this.msg.indexOf("https")!==-1||this.msg.indexOf("http")!==-1;if(a===null&&!o){var n=document.getElementById("feedbackForm"),e=new FormData(n);u.post(n.getAttribute("action"),this.serialize(e)).then(l=>{l.data.feedback&&(document.querySelector("main").insertAdjacentHTML("afterbegin",`<div class="py-2 px-2">
                        <div id="feedbackSuccess" class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative"
                             role="alert">
                            <strong class="font-bold">${l.data.message}</strong>
                            <span class="close-feedback-alert absolute top-0 bottom-0 right-0 px-4 py-3">
                        <svg class="fill-current h-6 w-6 text-green-500"
                             role="button"
                             xmlns="http://www.w3.org/2000/svg"
                             viewBox="0 0 20 20"><title>Close</title><path d="M14.348 14.849a1.2 1.2 0 0 1-1.697 0L10 11.819l-2.651 3.029a1.2 1.2 0 1 1-1.697-1.697l2.758-3.15-2.759-3.152a1.2 1.2 0 1 1 1.697-1.697L10 8.183l2.651-3.031a1.2 1.2 0 1 1 1.697 1.697l-2.758 3.152 2.758 3.15a1.2 1.2 0 0 1 0 1.698z"/></svg>
                    </span>
                        </div>
                    </div>`),r.toggleShowForm(),r.closeListener(),document.querySelector("body").classList.toggle("overflow-hidden"),window.scroll({top:0,left:0,behavior:"smooth"}))}).catch(l=>{r.toggleShowForm()})}else a!==null&&(document.querySelector(".feedback_error").innerHTML=this.feedback["urls-not-allowed-in-feedback-warning"]),o&&(document.querySelector(".feedback_error").innerHTML=this.feedback["http/https-not-allowed-in-feedback-warning"]),document.querySelector(".feedback_error").classList.remove("hidden")}},toggleShowForm(r=null){r===!0?(this.showForm=!0,document.querySelector("body").classList.toggle("overflow-hidden")):r===!1?(this.showForm=!1,document.querySelector("body").classList.toggle("overflow-hidden")):this.showForm=!this.showForm},msgInput(){this.msgLength=this.msg.length},serialize(r){let t={};for(let[a,o]of r)t[a]!==void 0?(Array.isArray(t[a])||(t[a]=[t[a]]),t[a].push(o)):t[a]=o;return t},closeListener(){var r=document.querySelector("#feedbackSuccess"),t=document.querySelector(".close-feedback-alert");t.addEventListener("click",function(a){r.remove()})}}},p={class:"border border-black px-4"},v={class:"font-bold text-xl pb-3"},w=["aria-label","innerHTML"],y={key:0,id:"feedback",class:"feedback"},x={class:"feedback__content"},S={class:"font-bold text-2xl pb-3"},L={class:"pb-3"},F=["action"],q={class:"relative flex flex-col"},M={class:"absolute bottom-0 left-0 ml-3"},T=["innerHTML"],H={class:"absolute bottom-0 right-0 mr-3"},A=["placeholder"],B=["placeholder"],D=s("p",{class:"feedback_error hidden text-red-500 mt-2"},null,-1),I=["value"],N={class:"feedback__btn-group pt-3"},C=["aria-label","innerHTML"],Q=["aria-label","innerHTML"];function V(r,t,a,o,n,e){return d(),i("div",p,[s("h1",v,c(e.feedback.title),1),s("div",null,c(e.feedback.text),1),s("button",{id:"feedbackBtn",onClick:t[0]||(t[0]=l=>e.toggleShowForm(!0)),class:"button my-3","aria-label":e.feedback.button,innerHTML:e.feedback.button},null,8,w),this.showForm?(d(),i("div",y,[s("div",x,[s("h1",S,c(e.feedback.title),1),s("div",L,c(e.feedback.text),1),s("form",{id:"feedbackForm",action:r.route("feedback"),method:"POST",onSubmit:t[4]||(t[4]=m((...l)=>e.submit&&e.submit(...l),["prevent"]))},[s("div",q,[b(s("textarea",{name:"text",class:"feedback-message",cols:"30",rows:"5",maxlength:"1200","onUpdate:modelValue":t[1]||(t[1]=l=>n.msg=l),onInput:t[2]||(t[2]=(...l)=>e.msgInput&&e.msgInput(...l)),required:""},null,544),[[f,n.msg]]),s("small",M,[s("span",{class:"feedback-amount-of-letters",innerHTML:n.msgLength},null,8,T),h(" "+c(e.feedback["feedback-current-number-of-characters"]),1)]),s("small",H,c(e.feedback["feedback-max-number-of-characters"]),1)]),s("input",{name:"name",type:"text",class:"mt-3",placeholder:e.feedback["feedback-name-placeholder"]},null,8,A),s("input",{name:"email",type:"email",class:"mt-3",placeholder:e.feedback["feedback-email-placeholder"]},null,8,B),D,s("input",{type:"hidden",name:"url",value:e.getFullUrl()},null,8,I),s("div",N,[s("button",{id:"feedbackFormSubmitBtn",type:"submit",class:"button","aria-label":e.feedback.send,innerHTML:e.feedback.send},null,8,C),s("button",{type:"reset",onClick:t[3]||(t[3]=l=>e.toggleShowForm(!1)),class:"button btn__cancel","aria-label":e.feedback.cancel,innerHTML:e.feedback.cancel},null,8,Q)])],40,F)])])):g("",!0)])}const U=k(_,[["render",V]]);export{U as F};