"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9790],{41811:function(e,a,r){r.d(a,{Z:function(){return b}});var i=r(57437),s=r(9772),t=r.n(s),l=r(95127),n=r(36291),d=r(2265),c=r(39343),o=r(35161),h=r(92682),u=r(31841),m=r(22062),p=r(79525),x=function(e){let{id:a,type:r="text",name:s,value:d,label:c,placeholder:o,description:h,watch:m,register:x,required:f,pattern:j,errors:b,errorMessage:v,isHidden:y=!1,staticLabel:g=!1,hideLabel:w=!1,className:_,style:T,...N}=e;return(0,i.jsxs)("div",{className:t()("field",_,{"has-error":b&&b[s],"is-required":b[s]&&"required"===b[s].type,"is-placeholder-hidden":!("textarea"==r||g),"is-hidden":y,"f-h f-j-s":"checkbox"==r||"radio"==r}),style:T,"data-lenis-prevent":!0,children:[("textarea"==r||g)&&(0,i.jsx)("label",{className:t()("user-select-disable w-4",{"screen-reader-only":w}),htmlFor:a||null,dangerouslySetInnerHTML:{__html:(0,u.A$)("".concat(c).concat(!("checkbox"==r||"radio"==r)&&f?"*":""))}}),h&&(0,i.jsx)("p",{className:"field__description w-4 t-l-3",dangerouslySetInnerHTML:{__html:(0,u.A$)(h)}}),"textarea"==r?(0,i.jsx)("textarea",{id:a||null,value:d,placeholder:o,className:t()({"has-value":m[s]}),...x(s,{required:f&&v?v:f,pattern:j}),...N}):(0,i.jsx)("input",{id:a||null,type:y?"hidden":r,value:d,placeholder:"checkbox"==r||"radio"==r?"":o,className:t()({"has-value":m[s]}),...x(s,{required:f&&v?v:f,pattern:j}),...N}),!("textarea"==r||g)&&(0,i.jsx)("label",{className:t()("user-select-disable w-4",{"screen-reader-only":w}),htmlFor:a||null,dangerouslySetInnerHTML:{__html:(0,u.A$)("".concat(c).concat(!("checkbox"==r||"radio"==r)&&f?"*":""))}}),!("checkbox"==r||"radio"==r)&&(0,i.jsx)(l.M,{children:b&&b[s]&&(0,i.jsx)(n.E.p,{initial:"hide",animate:"show",exit:"hide",variants:p.Tj,className:"field__error t-l-3",children:b[s].message})})]})};let f=e=>(0,i.jsx)(o.c.DropdownIndicator,{...e,children:(0,i.jsx)(m.Z,{type:"triangle-bottom"})}),j=e=>{var a,r;let{data:s={},className:o,register:m,watch:p,errors:b,control:v,getValue:y,...g}=e,[w,_]=(0,d.useState)(null);if((0,d.useEffect)(()=>{Array.isArray(y)?_(y.join(";")):"object"==typeof y?_(y.value):_(y)},[y]),s.enabled)return(0,i.jsxs)(i.Fragment,{children:[(0,u.Bk)(s.options)?(0,i.jsxs)(i.Fragment,{children:[("checkbox"===s.fieldType||"radio"===s.fieldType)&&(0,i.jsxs)("fieldset",{className:t()("field-group",o,{"is-hidden":s.hidden,"has-error":b&&b[s.name]}),children:[s.label&&(0,i.jsx)("legend",{dangerouslySetInnerHTML:{__html:(0,u.A$)("".concat(s.label).concat(s.required?" *":""))}}),s.options.map((e,a)=>{var r;return(0,i.jsx)(x,{id:e.label,type:s.fieldType,name:[s.name,s.objectTypeId].join("###"),label:e.label,value:e.value,required:s.required,isHidden:s.hidden,register:m,watch:p(),errors:b,errorMessage:"Required",defaultChecked:null===(r=s.selectedOptions)||void 0===r?void 0:r.includes(e.value),...g},a)}),(0,i.jsx)(l.M,{children:b&&b[s.name]&&(0,i.jsx)(n.E.p,{initial:"hide",animate:"show",exit:"hide",variants:fadeAnim,className:"field__error t-l-3",children:b[s.name].message})})]}),"select"===s.fieldType&&(0,i.jsx)(c.Qr,{name:[s.name,s.objectTypeId].join("###"),control:v,rules:{required:s.required||!1},defaultValue:null===(a=s.options)||void 0===a?void 0:a.filter(e=>e.value===s.selectedOptions[0])[0],render:e=>{let{field:a}=e;return(0,i.jsxs)("div",{className:t()("field is-select",o,{"has-error":b&&b[a.name],"is-hidden":s.hidden}),style:{"--border-color":"rgba(225, 225, 225, 0.3)"},"data-lenis-prevent":!0,children:[(0,i.jsxs)("label",{htmlFor:s.name,children:[s.label,s.required?" *":""]}),(0,i.jsx)(h.ZP,{options:(0,u.Yz)(s.options),isSearchable:!0,placeholder:s.placeholder||"Please Select",classNamePrefix:"react-select",className:"react-select",components:{DropdownIndicator:f},...a}),(0,i.jsx)(l.M,{children:b&&b[s.name]&&(0,i.jsx)(n.E.p,{initial:"hide",animate:"show",exit:"hide",variants:fadeAnim,className:"field__error t-l-3",children:"Answering the question is required"})})]})}})]}):(0,i.jsx)(x,{id:s.name,type:s.fieldType,name:[s.name,s.objectTypeId].join("###"),label:s.label,placeholder:s.placeholder,description:s.description,staticLabel:s.description,required:s.required,isHidden:s.hidden,register:m,watch:p(),errors:b,errorMessage:"Required",pattern:"email"===s.fieldType||s.name.includes("email")?{value:/\S+@\S+\.\S+/,message:"Entered value does not match email format"}:null,style:{"--border-color":"rgba(225, 225, 225, 0.3)"},className:o,...g}),null===(r=s.dependentFieldFilters)||void 0===r?void 0:r.map((e,a)=>(0,u.yT)(e.filters.operator,e.filters.strValue||e.filters.strValues,w)&&(0,i.jsx)(j,{data:e.dependentFormField,register:m,watch:p,errors:b,control:v},a))]})};var b=j},59790:function(e,a,r){var i=r(57437),s=r(9772),t=r.n(s),l=r(16463),n=r(95127),d=r(36291),c=r(2265),o=r(39343),h=r(31841),u=r(22062),m=r(96415),p=r(41811),x=r(79525);a.default=e=>{let{data:a={},className:r,fallBackFormId:s,errorPosition:f="bottom"}=e,{hubspotFormId:j,successMessage:b,errorMessage:v}=a,[y,g]=(0,c.useState)(null),[w,_]=(0,c.useState)([]),[T,N]=(0,c.useState)(!1),[S,E]=(0,c.useState)(null),[k,q]=(0,c.useState)(!1),[I,M]=(0,c.useState)(!1),F=(0,l.usePathname)(),{watch:A,register:Z,handleSubmit:H,reset:L,control:P,getValues:C,formState:{errors:O}}=(0,o.cI)(),V=async(e,a)=>{a.preventDefault(),q(!0);let r=(0,h.ex)(y,e);try{fetch("/api/hubspot/submit-form",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).then(e=>{e.ok&&(q(!1),M(!0))})}catch(e){console.log("error",e)}};return(0,c.useEffect)(()=>{j||s?(async()=>{N(!0);try{let e=await fetch("/api/hubspot/get-form?formId=".concat(j||s));if(!e.ok)throw Error("HTTP error! status: ".concat(e.status));let a=await e.json();g(a)}catch(e){E(v||"Something went wrong")}finally{N(!1)}})():E(v||"Something went wrong")},[j]),(0,c.useEffect)(()=>{y&&_((0,h.Sb)(y))},[y]),(0,c.useEffect)(()=>{M(!1),L()},[F]),(0,i.jsx)("div",{className:t()("c-email-capture f-h f-a-c",r),children:(0,i.jsxs)(n.M,{mode:"wait",children:[T&&(0,i.jsx)(d.E.div,{exit:"hide",variants:x.Tj,className:"c-email-capture__loader",children:(0,i.jsx)(m.Z,{})},"loader"),(0,h.Bk)(w)&&!I&&(0,i.jsxs)(d.E.form,{initial:"hide",animate:"show",exit:"hide",variants:x.Tj,name:y.name||"Email Capture Form",className:"c-email-capture__form",onSubmit:H(V),"data-error-position":f,children:[w.map(e=>(0,h.Bk)(e.fields)&&e.fields.map((e,a)=>(0,i.jsx)(p.Z,{data:e,register:Z,watch:A,errors:O,control:P,staticLabel:!0,hideLabel:!0,getValue:C([e.name,e.objectTypeId].join("###"))},a))),(0,i.jsx)("button",{type:"submit",className:"c-email-capture__submit f-h f-a-c f-j-c","aria-label":"Submit newsletter form",children:(0,i.jsxs)(n.M,{initial:!1,mode:"wait",children:[!k&&(0,i.jsx)(d.E.span,{initial:"hide",animate:"show",exit:"hide",variants:x.Tj,children:(0,i.jsx)(u.Z,{type:"triangle-right"})},"form-submit"),k&&(0,i.jsx)(d.E.span,{initial:"hide",animate:"show",exit:"hide",variants:x.Tj,children:(0,i.jsx)(m.Z,{})},"form-loading")]})})]},"form"),I&&(0,i.jsx)(d.E.div,{initial:"hide",animate:"show",exit:"hide",variants:x.Tj,className:"c-email-capture__success w-3",children:(0,i.jsx)("p",{className:"t-l-2",children:b||"Thank you for subscribing."})},"success"),S&&(0,i.jsx)(d.E.div,{initial:"hide",animate:"show",exit:"hide",variants:x.Tj,className:"c-email-capture__error w-3",children:(0,i.jsx)("p",{className:"t-l-2 cr-red",children:S})},"error")]})})}},96415:function(e,a,r){var i=r(57437),s=r(9772),t=r.n(s);r(2265),a.Z=e=>{let{width:a=20,color:r,className:s}=e;return(0,i.jsxs)("div",{className:t()("c-spinner-loader",s),style:{"--cr-spinner":r,"--s-spinner":"".concat(a,"px"),"--s-spinner-item":"".concat(.8*a,"px"),"--s-spinner-border":"".concat(.1*a,"px")},children:[(0,i.jsx)("span",{}),(0,i.jsx)("span",{}),(0,i.jsx)("span",{}),(0,i.jsx)("span",{})]})}}}]);