"use strict";(self.webpackChunkaem_maven_archetype=self.webpackChunkaem_maven_archetype||[]).push([[49116,3022,81227],{43167:function(e,n,t){t.r(n),t.d(n,{default:function(){return j}});var o=t(11527),i=t(45889),s=t(44530),c=t(50959),a=t(19719);const r=()=>({type:a.th}),l=()=>({type:a.AM});var d=t(27789),u=t(75936),v=t(31477),m=t(396),h=function(e,n,t,o){return new(t||(t=Promise))((function(i,s){function c(e){try{r(o.next(e))}catch(e){s(e)}}function a(e){try{r(o.throw(e))}catch(e){s(e)}}function r(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(c,a)}r((o=o.apply(e,n||[])).next())}))};var f=t(49995),g=function(e,n,t,o){return new(t||(t=Promise))((function(i,s){function c(e){try{r(o.next(e))}catch(e){s(e)}}function a(e){try{r(o.throw(e))}catch(e){s(e)}}function r(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(c,a)}r((o=o.apply(e,n||[])).next())}))};const p=(e,n)=>g(void 0,void 0,void 0,(function*(){try{const t=null==n?void 0:n.map((e=>({consentId:e.consentId,consentCategory:e.consentCategory}))),o=yield((e,n)=>h(void 0,void 0,void 0,(function*(){try{const t=yield(0,m.J6)("POST","/api/v2/consent-read",{mobileNo:e,consentInfo:n});if(90!==t.statusCode)throw new Error(null==t?void 0:t.message);return t}catch(e){throw new Error(`Error in login consent-read API: ${e}`)}})))(e,t);let i=[];return n.forEach((e=>{var n;const t=null===(n=(null==o?void 0:o.data).consentResponseInfo)||void 0===n?void 0:n.find((n=>n.partnerDisplayName===e.consentId));t&&"Y"!==t.isConsentAvailable&&(i=[...i,Object.assign(Object.assign({},t),{isRequired:e.isRequired,consentId:e.consentId,consentCategory:e.consentCategory,errorMessage:e.errorMessage,description:e.description})])})),i}catch(e){throw new Error(`Error in login consent-read API: ${e}`)}})),b=(e,n)=>g(void 0,void 0,void 0,(function*(){var t;try{const o=null===(t=null==n?void 0:n.filter((e=>e.isChecked)))||void 0===t?void 0:t.map((e=>e.consentId)),i="Y";(null==o?void 0:o.length)&&(yield((e,n,t)=>h(void 0,void 0,void 0,(function*(){try{const o=yield(0,m.J6)("POST","/api/v2/consent-insert",{mobileNo:e,consentIdList:n,consentStatus:t,firstName:"",lastName:""});if(90!==o.statusCode)throw new Error(null==o?void 0:o.message);return o}catch(e){throw new Error(`Error in login consent-insert API: ${e}`)}})))(e,o,i))}catch(e){throw new Error(`Error in login consent-insert API: ${e}`)}})),y=({element:e,event:n,eventType:t,ctaText:o,sectionTitle:i})=>{(0,f.Z)({component:"consent login modal",element:e,event:n,event_type:t,cta_text:o,sec_title:i})};var _=function(e,n,t,o){return new(t||(t=Promise))((function(i,s){function c(e){try{r(o.next(e))}catch(e){s(e)}}function a(e){try{r(o.throw(e))}catch(e){s(e)}}function r(e){var n;e.done?i(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(c,a)}r((o=o.apply(e,n||[])).next())}))};var C=e=>{const[n,t]=(0,c.useState)(!1),[o,i]=(0,c.useState)(!1),[s,a]=(0,c.useState)([]),m=(0,d.T)(),h=(0,d.C)((e=>e.consentLoginModalReducer)),f=()=>{n&&(0,v.ej)("accessToken")&&m(l())};return(0,c.useEffect)((()=>{if("show"===h.status){(()=>_(void 0,void 0,void 0,(function*(){try{const n=yield p(null==h?void 0:h.mobileNo,Object.values(e.consentList||{}));(null==n?void 0:n.length)?(a(n),t(!0)):m(r())}catch(e){(0,u.ie)(e,{errorType:"Error in Consent login read api",componentName:"ConsentLoginModal"}),m(l())}})))()}else t(!1)}),[h]),(0,c.useEffect)((()=>(n&&window.addEventListener("beforeunload",f),()=>{window.removeEventListener("beforeunload",f)})),[n]),{isModalOpen:n,isBtnDisabled:o,consentList:s,handleConsentSubmit:()=>{let n=!0;const o=s.map((e=>(0,v.hb)(e.isRequired)&&!e.isChecked?(n=!1,Object.assign(Object.assign({},e),{isChecked:!1})):e));n?(i(!0),b(h.mobileNo,s).then((()=>{t(!1),m(r())})).catch((e=>{(0,u.ie)(e,{errorType:"Error in Consent login insert api",componentName:"ConsentLoginModal"}),m(l())})).finally((()=>{i(!1)}))):a(o),y({element:"consent_login_modal_submit_cta",event:"click",eventType:"button click",ctaText:e.primaryCtaText,sectionTitle:e.heading})},handleConsentChange:n=>{const t=n.target.name;let o="";const i=s.map((e=>e.consentCategory===t?(o=e.description,Object.assign(Object.assign({},e),{isChecked:!e.isChecked})):e));a(i),y({element:"consent_login_modal_tnc_click",event:"click",eventType:"checkbox_click",ctaText:o,sectionTitle:e.heading})},handleConsentLoginModalClose:(n=!0)=>{y({element:n?"consent_login_modal_close_icon":"consent_login_modal_skip_cta",event:"click",eventType:n?"icon click":"button_click",ctaText:n?"close_icon":e.secondaryCtaText,sectionTitle:e.heading});s.some((e=>(0,v.hb)(e.isRequired)))?f():(t(!1),m(r()))}}};var j=(0,s.default)((e=>{const{isModalOpen:n,isBtnDisabled:t,consentList:s,handleConsentSubmit:c,handleConsentChange:a,handleConsentLoginModalClose:r}=C(e);return(0,i.default)(n),n?(0,o.jsx)("div",Object.assign({className:"modal modal--show consent-login-modal",onClick:()=>r(!0)},{children:(0,o.jsx)("div",Object.assign({className:"modal__dialog modal__dialog--center flex-jc-center",role:"document"},{children:(0,o.jsxs)("div",Object.assign({className:"modal__content consent-login-modal flex-column-center",onClick:e=>e.stopPropagation()},{children:[(0,o.jsx)("span",{className:"bf-icon-close",onClick:()=>r(!0)},void 0),(0,o.jsx)("h2",Object.assign({className:"consent-login-modal__heading flex-jc-center"},{children:e.heading}),void 0),(0,o.jsx)("div",{className:"consent-login-modal__description",dangerouslySetInnerHTML:{__html:e.description}},void 0),s.map((e=>(0,o.jsxs)("div",Object.assign({className:"consent-login-modal__consent-item"},{children:[(0,o.jsxs)("div",Object.assign({className:"flex-row-center "+(!1===e.isChecked&&(0,v.hb)(e.isRequired)?"consent-login-modal__consent-item__error":"")},{children:[(0,o.jsx)("input",{type:"checkbox",checked:Boolean(e.isChecked),name:e.consentCategory,onChange:a},void 0),(0,o.jsx)("div",{className:"consent-login-modal__consent-item__description",dangerouslySetInnerHTML:{__html:e.description}},void 0)]}),void 0),!1===e.isChecked&&(0,v.hb)(e.isRequired)?(0,o.jsxs)("p",Object.assign({className:"consent-login-modal__consent-item__error__msg d-flex"},{children:[(0,o.jsx)("i",{className:"bf-icon-info-icon-fill"},void 0)," ",e.errorMessage]}),void 0):null]}),e.consentId))),(0,o.jsxs)("div",Object.assign({className:"consent-login-modal__cta flex"},{children:[(0,o.jsx)("button",Object.assign({type:"button",className:"btn btn--white-primary",onClick:()=>r(!1)},{children:e.secondaryCtaText}),void 0),(0,o.jsx)("button",Object.assign({type:"button",className:"btn btn--white-primary",onClick:c,disabled:t},{children:e.primaryCtaText}),void 0)]}),void 0)]}),void 0)}),void 0)}),void 0):null}))},45889:function(e,n,t){t.r(n);var o=t(50959),i=t(2463);n.default=e=>{(0,o.useEffect)((()=>{e?!document.body.classList.contains("disable-scroll")&&document.body.classList.add("disable-scroll"):!e&&document.body.classList.contains("disable-scroll")&&(document.body.classList.remove("disable-scroll"),i.au&&window.scrollTo(0,0))}),[e])}},44530:function(e,n,t){t.r(n);var o=t(11527),i=function(e,n){var t={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);in=>{var{componentData:t}=n,s=i(n,["componentData"]);let c;return c=t?JSON.parse(t):Object.assign({},s),(0,o.jsx)(e,Object.assign({},c),void 0)}},27789:function(e,n,t){t.d(n,{C:function(){return s},T:function(){return i}});var o=t(89406);const i=()=>(0,o.I0)(),s=o.v9}}]);