import{I as B,C as G,p as u,B as x,A as Z,l as z}from"./bdrFovXZ.js";import{u as K}from"./BSlRQa63.js";import{u as H}from"./qItW-S8A.js";import{t as W}from"./B2nxMZj2.js";import{e as ,ドルu as _}from"./CwlgAo9k.js";import{S as j}from"./B1jCwLPL.js";import{A as J}from"./Byq2Dwpd.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalthis:typeof self<"u"?self:{};e.sentry_release={id:"dcd43fef1e4af7f7614a43abf36301348c5fce67"}}catch{}})();try{(function(){var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalthis:typeof self<"u"?self:{},c=new e.Error().stack;c&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[c]="1bdb5baa-c33c-4b20-975a-e6c7639f76d7",e._sentryDebugIdIdentifier="sentry-dbid-1bdb5baa-c33c-4b20-975a-e6c7639f76d7")})()}catch{}const Q={email:3,optin:31,subscribeSource:15048,marketingEmailSubscriber:11198,country:15049,language:15199,contactListId:713034644,doubleOptInFlag:12776},X={email:3,optin:31,subscribeSource:15044,marketingEmailSubscriber:9270,country:15046,language:15198,contactListId:1623765360,doubleOptInFlag:12161},ee={lv:1,lt:2,et:3,fi:4,no:5,se:6,ru:7,de:8,other:9,en:10},re={LV:95,EE:57,LT:101,AT:10,BE:17,CZ:47,DK:48,FI:60,FR:61,GB:184,GE:64,DE:65,GR:67,IL:82,IT:83,NL:124,NO:129,PL:139,PT:140,ES:162,SE:167,CH:168,TR:178,UA:182,AE:183,UK:184,ZZ:null},ce=e=>{const o=z().public.env==="production"?Q:X,A=B(),R=K(),w=H(),{t:i}=G(),f=u(!1),g=u(!1),n=u(),b=u(),m=u(),{errors:h,values:M,validate:T,resetForm:V}=$({validationSchema:W(j)}),{value:p}=_("emailAddress"),{value:y,errorMessage:P,setErrors:D}=_("privacyPolicyAccepted",{initialValue:!1});x(p,(r,a)=>{r!==a&&(n.value=void 0)});const F=Z(()=>({emailAddress:h.value.emailAddress??void 0,country:b.value,language:m.value,privacyPolicyAccepted:e.requirePrivacyPolicy&&P.value?P.value:void 0})),U=()=>{f.value=!1},v=()=>{b.value=void 0},E=()=>{m.value=void 0},q=()=>!e.requirePrivacyPolicy||y.value?!0:(D([i("forms.global.error.required")]),!1),N=r=>{if(!e.requireCountryValidation)return!0;const a=r==null?void 0:r.trim().toUpperCase(),t=R.sortedCountriesWithPopularFirst.map(l=>l.id.toUpperCase());return(a?t.includes(a):!1)?(v(),!0):(b.value="forms.global.error.required",!1)},O=r=>{if(!e.requireLanguageValidation)return!0;const a=r==null?void 0:r.trim().toLowerCase(),t=w.newsletterLanguages.map(l=>l.id.toLowerCase());return(a?t.includes(a):!1)?(E(),!0):(m.value="forms.global.error.required",!1)};return{emailAddress:p,privacyPolicyAccepted:y,displayErrors:F,responseError:n,isValid:g,isConfirmationModalOpen:f,closeConfirmationModal:U,clearCountryError:v,clearLanguageError:E,onSubmit:async(r={})=>{var C,L,I;n.value=void 0,v(),E();const a=r.selectedCountry??A.selectedCountry,t=r.selectedLanguage??A.selectedLanguage,{valid:S}=await T(),l=q(),Y=N(a),k=O(t);if(g.value=S&&l&&Y&&k,!!g.value)try{const s=await $fetch("/api/emarsys/subscribe",{method:"PUT",body:{key_id:3,contact_list_id:o.contactListId,...e.createIfNotExist?{create_if_not_exist:1}:{},contacts:[{[o.email]:M.emailAddress,[o.optin]:1,[o.subscribeSource]:e.subscribeSource,[o.marketingEmailSubscriber]:3,[o.country]:re[a==null?void 0:a.toUpperCase()]??null,[o.language]:ee[t]??9,[o.doubleOptInFlag]:1}]}});if(s.status==="error"){const d=s.data&&"code"in s.data&&s.data.code===J?i("forms.subscribe.alreadySubscribed"):i("global.error.serverError");n.value=d,(C=e.onError)==null||C.call(e,d);return}f.value=!0,V(),e.requirePrivacyPolicy&&(y.value=!1),(L=e.onSuccess)==null||L.call(e)}catch(s){const d=s instanceof Error?s.message:i("global.error.serverError");n.value=i("global.error.serverError"),(I=e.onError)==null||I.call(e,d)}}}};export{ce as u}; //# sourceMappingURL=Cgoes26R.js.map

AltStyle によって変換されたページ (->オリジナル) /