import{o as h,f as g,_ as $,c as x,D as E,r as c,i as l,h as o,t as A,F as k,l as V}from"./index-m7Z9H1b_.js";import{b as F}from"./pageBase-C9DgPPt2.js";import B from"./ButtonElement-VEOfE7ak.js";import z from"./EmptyState-DILevNa0.js";import R from"./InputField-BigecOz2.js";import{S as P}from"./SelectInput-BxDTxO44.js";import{A as D}from"./AppFooter-D9cXY3cz.js";import{u as N}from"./index-DTqqY4nG.js";import{r as d,e as O}from"./index-Sfy-Y3uB.js";import"./LoadingState-BBqRo_4Z.js";import"./Dropdown-BZjyHqvW.js";const v="hcaptcha-api-script-id",b="_hcaptchaOnLoad";let f,y;const m=new Promise((t,e)=>{f=t,y=e});function U(t){if(window.hcaptcha)return f(),m;if(document.getElementById(v))return m;window[b]=f;const e=q(t),i=document.createElement("script");return i.id=v,i.src=e,i.async=!0,i.defer=!0,i.onerror=s=>{console.error("Failed to load api: "+e,s),y("Failed to load api.js")},document.head.appendChild(i),m}function q(t){let e=t.apiEndpoint;return e=a(e,"render","explicit"),e=a(e,"onload",b),e=a(e,"recaptchacompat",t.reCaptchaCompat===!1?"off":null),e=a(e,"hl",t.language),e=a(e,"sentry",t.sentry),e=a(e,"custom",t.custom),e=a(e,"endpoint",t.endpoint),e=a(e,"assethost",t.assethost),e=a(e,"imghost",t.imghost),e=a(e,"reportapi",t.reportapi),e}function a(t,e,i){if(i!=null){const s=t.includes("?")?"&":"?";return t+s+e+"="+encodeURIComponent(i)}return t}var L=(t,e)=>{for(const[i,s]of e)t[i]=s;return t};const j={name:"VueHcaptcha",props:{sitekey:{type:String,required:!0},theme:{type:String,default:void 0},size:{type:String,default:void 0},tabindex:{type:String,default:void 0},language:{type:String,default:void 0},reCaptchaCompat:{type:Boolean,default:!0},challengeContainer:{type:String,default:void 0},rqdata:{type:String,default:void 0},sentry:{type:Boolean,default:!0},custom:{type:Boolean,default:void 0},apiEndpoint:{type:String,default:"https://hcaptcha.com/1/api.js"},endpoint:{type:String,default:void 0},reportapi:{type:String,default:void 0},assethost:{type:String,default:void 0},imghost:{type:String,default:void 0}},data:()=>({widgetId:null,hcaptcha:null,renderedCb:null}),mounted(){return U(this.$props).then(this.onApiLoaded).catch(this.onError)},unmounted(){this.teardown()},destroyed(){this.teardown()},methods:{teardown(){this.widgetId&&(this.hcaptcha.reset(this.widgetId),this.hcaptcha.remove(this.widgetId))},onApiLoaded(){this.hcaptcha=window.hcaptcha;const t={sitekey:this.sitekey,theme:this.theme,size:this.size,tabindex:this.tabindex,callback:this.onVerify,"expired-callback":this.onExpired,"chalexpired-callback":this.onChallengeExpired,"error-callback":this.onError,"open-callback":this.onOpen,"close-callback":this.onClose};this.challengeContainer&&(t["challenge-container"]=this.challengeContainer),this.widgetId=this.hcaptcha.render(this.$el,t),this.rqdata&&this.hcaptcha.setData(this.widgetId,{rqdata:this.rqdata}),this.onRendered()},execute(){this.widgetId?(this.hcaptcha.execute(this.widgetId),this.onExecuted()):this.renderedCb=()=>{this.renderedCb=null,this.execute()}},executeAsync(){if(this.widgetId)return this.onExecuted(),this.hcaptcha.execute(this.widgetId,{async:!0});let t;const e=new Promise(i=>{t=i});return this.renderedCb=()=>{this.renderedCb=null,t()},e.then(this.executeAsync)},reset(){this.widgetId?(this.hcaptcha.reset(this.widgetId),this.onReset()):this.$emit("error","Element is not rendered yet and thus cannot reset it. Wait for `rendered` event to safely call reset.")},onRendered(){this.$emit("rendered"),this.renderedCb&&this.renderedCb()},onExecuted(){this.$emit("executed")},onReset(){this.$emit("reset")},onError(t){this.$emit("error",t),this.reset()},onVerify(){const t=this.hcaptcha.getResponse(this.widgetId),e=this.hcaptcha.getRespKey(this.widgetId);this.$emit("verify",t,e)},onExpired(){this.$emit("expired")},onChallengeExpired(){this.$emit("challengeExpired")},onOpen(){this.$emit("opened")},onClose(){this.$emit("closed")}}},H={id:"hcap-script"};function K(t,e,i,s,n,p){return h(),g("div",H)}var T=L(j,[["render",K]]);const W={name:"Contact",components:{VueHcaptcha:T,ButtonElement:B,InputField:R,SelectInput:P,AppFooter:D,EmptyState:z},extends:F,setup(){return{v$:N(),userStore:x(),hcaptchaKey:E.hcaptcha}},data(){return{selectOptions:[{value:0,label:"forms.general-questions"},{value:1,label:"forms.technical-support"},{value:2,label:"forms.sales"},{value:3,label:"forms.press"}],area:null,name:"",email:"",message:"",submitting:!1,success:!1}},computed:{loggedInAccount:({userStore:t})=>t.loggedInAccount},validations(){return{area:{required:d},name:{required:d},email:{required:d,email:O},message:{required:d}}},methods:{accountLoggedIn:function(){typeof this.loggedInAccount<"u"&&(this.name=this.loggedInAccount.fullName,this.email=this.loggedInAccount.email)},submit:function(){if(this.submitting=!0,this.loggedInAccount)return this.doSubmit();this.$refs.captcha.execute()},doSubmit:function(t){this.$muvacApi.post("/utils/contact-us",{area:parseInt(this.area),name:this.name,email:this.email,message:this.message,captcha:t},{headers:this.loggedInAccount!=null?{"x-access-token":this.loggedInAccount.authToken}:{}}).then(()=>{this.success=!0})}}},M={class:"spacingPublicPage"},Q={class:"container"},G={class:"row"},J={class:"col-12 col-lg-10 mx-auto"},X={class:"contentWrapper"},Y={class:"contentWrapper__header mb-4"},Z={class:"headline--md"},ee={class:"d-flex justify-content-end"};function te(t,e,i,s,n,p){const _=c("vue-hcaptcha"),I=c("SelectInput"),u=c("InputField"),S=c("ButtonElement"),w=c("EmptyState"),C=c("AppFooter");return h(),g("div",null,[l(_,{ref:"captcha",sitekey:s.hcaptchaKey,size:"invisible",onVerify:p.doSubmit},null,8,["sitekey","onVerify"]),o("section",M,[o("div",Q,[o("div",G,[o("div",J,[o("div",X,[o("div",Y,[o("h2",Z,A(t.$t("titles.contact-us")),1)]),n.success?(h(),V(w,{key:1,message:t.$t("messages.message-sent.title",{$capitalize:!0}),icon:["fal","thumbs-up"],"has-border":"","has-shadow":!1},null,8,["message"])):(h(),g(k,{key:0},[l(I,{modelValue:n.area,"onUpdate:modelValue":e[0]||(e[0]=r=>n.area=r),vertical:"",options:n.selectOptions,"option-value":"value","option-label":"label",label:t.$t("forms.area-of-interest",{$capitalize:!0}),v:s.v$.area},null,8,["modelValue","options","label","v"]),l(u,{modelValue:n.name,"onUpdate:modelValue":e[1]||(e[1]=r=>n.name=r),label:t.$t("forms.name",{$capitalize:!0}),vertical:"",v:s.v$.name},null,8,["modelValue","label","v"]),l(u,{modelValue:n.email,"onUpdate:modelValue":e[2]||(e[2]=r=>n.email=r),label:t.$t("forms.email",{$capitalize:!0}),vertical:"",v:s.v$.email},null,8,["modelValue","label","v"]),l(u,{modelValue:n.message,"onUpdate:modelValue":e[3]||(e[3]=r=>n.message=r),label:t.$t("forms.message",{$capitalize:!0}),vertical:"",long:"",v:s.v$.message},null,8,["modelValue","label","v"]),o("div",ee,[l(S,{disabled:s.v$.$invalid,submitting:n.submitting,margin:"mt-3",size:"lg",variant:"primary",action:p.submit,label:t.$t("actions.submit")},null,8,["disabled","submitting","action","label"])])],64))])])])])]),l(C)])}const ue=$(W,[["render",te]]);export{ue as default};