import{_ as z}from"./D4cd7EFQ.js";import{d as C,a,c as B,b as d,w as u,K as D,L as w,t as r,o as s,z as F,k as I,r as v,f as n,e as x,u as t,aA as N,m as P,j as V}from"./m2W8DxR4.js";import{u as E,t as O,o as q,s as A,a as H,F as U,_ as K,b as L,c as R,d as G}from"./56PacuBL.js";import{u as J}from"./Wxbikq7x.js";const Q=C({__name:"Title",props:{title:{},description:{default:""},buttonText:{default:"اشترك الآن"},showButton:{type:Boolean,default:!1},customStyle:{default:""},titleHeading:{default:"h1"},descriptionCustomStyle:{default:""}},setup(S){const e=S;return(m,k)=>{const b=z;return s(),a("div",{class:w(["flex flex-col justify-center gap-10 px-4",m.customStyle])},[e.title?(s(),B(D(e.titleHeading),{key:0,class:"dark-text-gradient mx-auto max-w-[735px] text-center text-2xl leading-10 font-semibold md:text-4xl md:leading-14 2xl:text-5xl 2xl:leading-16"},{default:u(()=>[F(r(e.title),1)]),_:1})):d("",!0),e.description?(s(),a("p",{key:1,class:w(["dark-text-gradient text-center",m.descriptionCustomStyle])},r(e.description),3)):d("",!0),e.showButton?(s(),B(b,{key:2,class:"mx-auto cursor-pointer",variant:"wsDefault",size:"wsDefault"},{default:u(()=>[F(r(e.buttonText),1)]),_:1})):d("",!0)],2)}}}),W={id:"subscribe",class:"bg-surface-background container mx-auto flex flex-col items-center justify-center rounded-lg px-4 py-12 text-center"},X={class:"flex w-full flex-col items-stretch overflow-hidden rounded-md sm:flex-row"},Y=["disabled"],Z={key:0,class:"animate-spin-loader"},ee={key:1},te={class:"text-destructive mt-1 min-h-[20px] text-center text-base"},se={key:0,class:"mt-2 text-center text-base text-green-600"},oe={key:1,class:"mt-2 text-center text-base text-red-600"},ae=C({__name:"SubscribeSection",setup(S){const{t:e}=I(),{getUTMPayload:m}=E(),k=O(q({email:A({required_error:e("schemaErrors.email_required_error")}).email(e("schemaErrors.email_invalid_error"))})),{handleSubmit:b,resetForm:M}=H({validationSchema:k,validateOnMount:!1}),l=v(!1),i=v(""),c=v(""),T=b(async g=>{var _,f;const{post:p}=J();try{l.value=!0,c.value="",i.value="";const o={...g,utm:m()};await p("news-letter",o),i.value=e("success_message"),M(),setTimeout(()=>{i.value=""},3e3)}catch(o){const y=((f=(_=o==null?void 0:o.response)==null?void 0:_.data)==null?void 0:f.message)||e("error_message");c.value=y,setTimeout(()=>{c.value=""},3e3)}finally{l.value=!1}});return(g,p)=>{const _=Q,f=R,o=L,y=G,$=K,j=U;return s(),a("section",W,[n(_,{title:t(e)("subscriptionSection.title"),description:t(e)("subscriptionSection.description"),"custom-style":"!gap-1 text-[32px] md:text-[40px] font-bold","title-heading":"h2","description-custom-style":"text-base md:text-lg font-normal"},null,8,["title","description"]),x("form",{class:"mt-6 w-full max-w-[600px]",onSubmit:p[0]||(p[0]=N((...h)=>t(T)&&t(T)(...h),["prevent"]))},[n(j,{name:"email","validate-on-blur":!0,"validate-on-input":!1},{default:u(({componentField:h})=>[n($,null,{default:u(()=>[x("div",X,[n(o,null,{default:u(()=>[n(f,P({class:"bg-input placeholder:text-primary relative h-[50px] w-full rounded-none border-none px-4 text-sm focus:ring-0 focus:outline-none focus-visible:ring-0",placeholder:t(e)("placeholders.email")},h),null,16,["placeholder"])]),_:2},1024),x("button",{type:"submit",disabled:t(l),class:w(["ws-gradient-border border-input-border text-primary borderRedius absolute bottom-1 w-full cursor-pointer !rounded-t-none border-t px-4 py-2 text-lg font-medium sm:bottom-0 sm:w-[34%] sm:!rounded-t-md sm:!rounded-l-none sm:border-t-0 sm:border-r sm:border-l-0 rtl:!rounded-l-md rtl:sm:!rounded-r-none",[g.$i18n.locale==="ar"?"left-0 sm:left-1":"right-0 sm:right-1",{"cursor-not-allowed opacity-50":t(l)}]])},[t(l)?(s(),a("span",Z)):(s(),a("span",ee,r(t(e)("buttons.subscribe_button")),1))],10,Y)]),x("div",te,[n(y)])]),_:2},1024)]),_:1})],32),t(i)?(s(),a("p",se,r(t(i)),1)):d("",!0),t(c)?(s(),a("p",oe,r(t(c)),1)):d("",!0)])}}}),ne=V(ae,[["__scopeId","data-v-42fed81c"]]),de=Object.freeze(Object.defineProperty({__proto__:null,default:ne},Symbol.toStringTag,{value:"Module"}));export{de as S,ne as _,Q as a};
