{"version":3,"file":"contact-form.8e983a7f.js","sources":["../../src/components/contact-form.ts"],"sourcesContent":["import { defineComponent } from \"vue\";\r\nimport common from \"../core/core\";\r\n\r\nimport { VueAutoHeight } from \"@/core/vue-auto-height.component\";\r\nimport type { ContactFormResponse } from \"@/services/wordpress/ContactFormResponse\";\r\n\r\nimport * as Sentry from \"@sentry/vue\";\r\n\r\nexport default defineComponent({\r\n components: {\r\n VueAutoHeight,\r\n },\r\n data() {\r\n return {\r\n contactForm: {\r\n name: \"\",\r\n email: \"\",\r\n message: \"\",\r\n recaptcha: \"\",\r\n },\r\n contactFormErrors: {\r\n name: null,\r\n email: null,\r\n message: null,\r\n recaptcha: null,\r\n },\r\n isSubmitPending: false,\r\n isSubmitOk: false,\r\n isSubmitFailed: false,\r\n };\r\n },\r\n computed: {},\r\n methods: {\r\n submitContactForm(e: Event) {\r\n e.preventDefault();\r\n this.validateContactForm();\r\n },\r\n clearValidate(field: \"name\" | \"email\" | \"message\") {\r\n this.contactFormErrors[field] = null;\r\n },\r\n validateField(field: \"name\" | \"email\" | \"message\", required = false) {\r\n const getErrorText = (attrKey: string) => {\r\n const validateDataEl: any = this.$refs.validateData;\r\n return validateDataEl.getAttribute(attrKey);\r\n };\r\n const validateEmail = (email: string) => {\r\n return String(email)\r\n .toLowerCase()\r\n .match(\r\n /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/\r\n );\r\n };\r\n switch (field) {\r\n case \"name\":\r\n this.contactFormErrors.name = null;\r\n if (!this.contactForm.name && required) {\r\n this.contactFormErrors.name = getErrorText(\"data-name-required\");\r\n }\r\n if (this.contactForm.name) {\r\n this.contactFormErrors.name = false;\r\n }\r\n break;\r\n case \"email\":\r\n this.contactFormErrors.email = null;\r\n if (!this.contactForm.email && required) {\r\n this.contactFormErrors.email = getErrorText(\"data-email-required\");\r\n }\r\n if (this.contactForm.email && !validateEmail(this.contactForm.email)) {\r\n this.contactFormErrors.email = getErrorText(\"data-email-email\");\r\n }\r\n if (this.contactForm.email && validateEmail(this.contactForm.email)) {\r\n this.contactFormErrors.email = false;\r\n }\r\n break;\r\n case \"message\":\r\n this.contactFormErrors.message = null;\r\n if (!this.contactForm.message && required) {\r\n this.contactFormErrors.message = getErrorText(\"data-message-required\");\r\n }\r\n if (this.contactForm.message) {\r\n this.contactFormErrors.message = false;\r\n }\r\n break;\r\n }\r\n },\r\n validateContactForm() {\r\n this.validateField(\"name\", true);\r\n this.validateField(\"email\", true);\r\n this.validateField(\"message\", true);\r\n\r\n if (!this.contactFormErrors.name && !this.contactFormErrors.email && !this.contactFormErrors.message) {\r\n this.formRequest();\r\n }\r\n },\r\n formRequest() {\r\n this.isSubmitPending = true;\r\n this.isSubmitOk = false;\r\n this.isSubmitFailed = false;\r\n\r\n this.$store.direct.getters.recaptchaService\r\n .getToken(\"contact_us_form\")\r\n .then((captchaToken) => {\r\n this.$store.direct.getters.contactFormService\r\n .submitClientContactForm({\r\n name: this.contactForm.name,\r\n email: this.contactForm.email,\r\n message: this.contactForm.message,\r\n captcha: captchaToken,\r\n postId: window.postId,\r\n })\r\n .then((response: ContactFormResponse) => {\r\n this.isSubmitPending = false;\r\n if (response.success && response.success === true) {\r\n this.isSubmitOk = true;\r\n\r\n this.$store.direct.getters.exponeaService.trackOncePerSession(\"contact_form_submit\", {\r\n name: this.contactForm.name,\r\n email: this.contactForm.email,\r\n message: this.contactForm.message,\r\n });\r\n } else {\r\n this.isSubmitFailed = true;\r\n }\r\n })\r\n .catch((error) => {\r\n // WP BE form handling failed\r\n this.isSubmitPending = false;\r\n this.isSubmitFailed = true;\r\n Sentry.captureException(error);\r\n });\r\n })\r\n .catch((error) => {\r\n // Captcha failed\r\n this.isSubmitPending = false;\r\n this.isSubmitFailed = true;\r\n Sentry.captureException(error);\r\n });\r\n },\r\n },\r\n mixins: [common],\r\n});\r\n"],"names":["contactForm","defineComponent","VueAutoHeight","e","field","required","getErrorText","attrKey","validateEmail","email","captchaToken","response","error","Sentry.captureException","common"],"mappings":"wcAQA,MAAAA,EAAeC,EAAgB,CAC7B,WAAY,CACV,cAAAC,CACF,EACA,MAAO,CACE,MAAA,CACL,YAAa,CACX,KAAM,GACN,MAAO,GACP,QAAS,GACT,UAAW,EACb,EACA,kBAAmB,CACjB,KAAM,KACN,MAAO,KACP,QAAS,KACT,UAAW,IACb,EACA,gBAAiB,GACjB,WAAY,GACZ,eAAgB,EAAA,CAEpB,EACA,SAAU,CAAC,EACX,QAAS,CACP,kBAAkBC,EAAU,CAC1BA,EAAE,eAAe,EACjB,KAAK,oBAAoB,CAC3B,EACA,cAAcC,EAAqC,CACjD,KAAK,kBAAkBA,GAAS,IAClC,EACA,cAAcA,EAAqCC,EAAW,GAAO,CAC7D,MAAAC,EAAgBC,GACQ,KAAK,MAAM,aACjB,aAAaA,CAAO,EAEtCC,EAAiBC,GACd,OAAOA,CAAK,EAChB,YACA,EAAA,MACC,sJAAA,EAGE,OAAAL,OACD,OACH,KAAK,kBAAkB,KAAO,KAC1B,CAAC,KAAK,YAAY,MAAQC,IACvB,KAAA,kBAAkB,KAAOC,EAAa,oBAAoB,GAE7D,KAAK,YAAY,OACnB,KAAK,kBAAkB,KAAO,IAEhC,UACG,QACH,KAAK,kBAAkB,MAAQ,KAC3B,CAAC,KAAK,YAAY,OAASD,IACxB,KAAA,kBAAkB,MAAQC,EAAa,qBAAqB,GAE/D,KAAK,YAAY,OAAS,CAACE,EAAc,KAAK,YAAY,KAAK,IAC5D,KAAA,kBAAkB,MAAQF,EAAa,kBAAkB,GAE5D,KAAK,YAAY,OAASE,EAAc,KAAK,YAAY,KAAK,IAChE,KAAK,kBAAkB,MAAQ,IAEjC,UACG,UACH,KAAK,kBAAkB,QAAU,KAC7B,CAAC,KAAK,YAAY,SAAWH,I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