(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["app/newsletter-subscription"],{1104:(e,n,t)=>{"use strict";t.r(n);var s=t(155),r=t(154),o=t(261),i=t.n(o),l=t(144),c=t(1105),a=t.n(c),u=t(635);const p="send_announce",m="send_personalized_announce",d=l.Locale.getSection("components.newsletter-subscription"),f=l.Locale.getTranslate("components.newsletter-subscription"),v=({dialogShown:e,consents:n,email:t,reportConsent:o,onClose:i,privacyPolicyUrl:l,isOpen:c})=>{const[v,y]=(0,r.useState)(null),{addToast:g}=(0,u.useToaster)(),w=()=>d.lmsg(b()?"reconfirmConsent":"consent",{privacyPolicy:d.lmsg("privacyPolicy")}),b=()=>n.some((e=>e.enabled&&e.type===p))&&!n.some((e=>e.enabled&&e.type===m)),E=b();return(0,r.createElement)(s.Dialog,{isOpen:c,size:"sm",banner:a(),title:(0,r.createElement)(f,{content:E?"reconfirmTitle":"title"}),form:{state:v,onSubmit:async()=>{y("submit");const e=await o(t,m,w());y(null),g(e?{intent:"success",message:(0,r.createElement)(f,{content:"subscribeMessage"})}:{intent:"danger",message:(0,r.createElement)(f,{content:"errorMessage"})}),i(!!e||void 0)},submitButton:{children:(0,r.createElement)(f,{content:E?"reconfirmButton":"subscribeButton"})},cancelButton:{children:(0,r.createElement)(f,{content:"closeButton"})},hideRequiredLegend:!0},onClose:async()=>{if(v)return;const e=b();y("cancel");const n=await o(t,e?p:"none",w());y(null),n?e&&g({intent:"success",message:(0,r.createElement)(f,{content:"noReconfirmMessage"})}):g({intent:"danger",message:(0,r.createElement)(f,{content:"errorMessage"})}),i(!n&&void 0)}},!E&&(0,r.createElement)("p",null,(0,r.createElement)(f,{content:"text"})),b()?(0,r.createElement)(s.StatusMessage,{intent:"info"},(0,r.createElement)(f,{content:"consentGivenInfo"})):e&&!n.some((e=>e.enabled))?(0,r.createElement)(s.StatusMessage,{intent:"info"},(0,r.createElement)(f,{content:"consentNotGivenInfo"})):void 0,(0,r.createElement)("p",null,(0,r.createElement)(f,{content:E?"reconfirmConsent":"consent",params:{privacyPolicy:(0,r.createElement)("a",{href:l,target:"_blank",rel:"noopener noreferrer"},(0,r.createElement)(f,{content:"privacyPolicy"}))}})))};v.propTypes={isOpen:i().bool.isRequired,email:i().string.isRequired,reportConsent:i().func.isRequired,privacyPolicyUrl:i().string.isRequired,dialogShown:i().bool.isRequired,consents:i().array.isRequired,onClose:i().func.isRequired},n.default=v},1103:(e,n,t)=>{"use strict";t.r(n);var s=t(153),r=t.n(s),o=t(738),i=t.n(o),l=t(154),c=t(144),a=t(447),u=t(1104),p=t(261),m=t.n(p),d=t(405),f=t(302);function v(){const e=i()(["\n        {\n            viewer {\n                client {\n                    email\n                }\n            }\n            config {\n                product {\n                    privacyPolicyUrl\n                }\n            }\n        }\n    "]);return v=function(){return e},e}const y="plesk-newsletter-subscription-shown",g=async(e,n,t)=>{const s=new Date(Date.now()+864e5);a.default.set(y,1,s.toUTCString(),"/");try{const s=await c.api.post((0,c.prepareUrl)("/my-profile/report-consent"),{email:e,text:t,consent:n});return"error"!==s.status&&window.loadConsentStatus(),"error"!==s.status}catch(e){return!1}},w=({isShow:e,...n})=>{var t,s,o;const[i,p]=(0,l.useState)(null),m=(0,l.useRef)([]),{data:{viewer:w,config:b}={}}=(0,d.useQuery)((0,f.gql)(v())),E=async(e,n=c.emptyFn)=>{m.current.push(n),p(await(async e=>{const{consents:n=[]}=await c.api.get((0,c.prepareUrl)("/my-profile/get-consent"),{email:e});return n})(e))};return(0,l.useEffect)((()=>{var n;if(null!=w&&null!==(n=w.client)&&void 0!==n&&n.email){var t;if(e&&!a.default.get(y))E(null==w||null===(t=w.client)||void 0===t?void 0:t.email);return(0,c.namespace)("PleskExt.Advisor").showNewsletterSubscription=e=>{var n;E(null==w||null===(n=w.client)||void 0===n?void 0:n.email,e)},()=>{delete(0,c.namespace)("PleskExt.Advisor").showNewsletterSubscription}}}),[null==w||null===(t=w.client)||void 0===t?void 0:t.email]),(0,l.createElement)(u.default,r()({isOpen:null!==i,consents:i||[],reportConsent:g,onClose:e=>{p(null),void 0!==e&&m.current.forEach((n=>n(e))),m.current=[]},privacyPolicyUrl:null==b||null===(s=b.product)||void 0===s?void 0:s.privacyPolicyUrl,email:null==w||null===(o=w.client)||void 0===o?void 0:o.email},n))};w.propTypes={isShow:m().bool.isRequired},n.default=w},1105:e=>{e.exports=Jsw.skinUrl+"/images/newsletter-subscription.png?b1de5a7718f72cdae8b90e2f38d2b322"}}]);
//# sourceMappingURL=newsletter-subscription.js.map?bf5e7a14f59fe6f1b729