1"use strict";(self.webpackChunkaccount_settings=self.webpackChunkaccount_settings||[]).push([[2072],{10802:(S,u,f)=>{function l(){return o=>0!==("string"==typeof o.value?o.value:"").trim().length?null:{whitespace:!0}}f.d(u,{o:()=>l})},2072:(S,u,f)=>{f.r(u),f.d(u,{EmailPreferencesModule:()=>oe});var l=f(96814),o=f(40285),_=f(20434),p=f(3609),e=f(19212),h=f(39346),k=f(69862);let g=(()=>{class n{constructor(t,s){this.ConfigManagerService=t,this.Http=s,this.serverlessEndpoints=this.ConfigManagerService.getConfig("serverless_endpoints")}getEmailPreferences(t){const s=this.ConfigManagerService.getConfig("app"),i=this.ConfigManagerService.getConfig("customer");return this.Http.post(s.submodule_api_url+i.get_customer_email_preferences,t,{withCredentials:!0})}getCommunicationPreferences(t){return this.Http.post(this.serverlessEndpoints.communication_preferences,t,{withCredentials:!0})}updateEmailPreferences(t){const s=this.ConfigManagerService.getConfig("app"),i=this.ConfigManagerService.getConfig("customer");return this.Http.put(s.submodule_api_url+i.get_customer_email_preferences+"/"+t.email,t,{withCredentials:!0})}updateCommunicationPreferences(t){return this.Http.put(this.serverlessEndpoints.communication_preferences,t,{withCredentials:!0})}updateEmailPreference(t){return this.Http.put(this.serverlessEndpoints.email_preferences,t)}getEmailPreference(){return this.Http.get(this.serverlessEndpoints.email_preferences)}prepareAndSortMessagingPreferences(t){const s=[];for(const i in t)if(Object.keys(t[i].Preferences).length>0){const r=this.sortMessagingPreferences(t[i].Preferences);t[i].ItemsSelected=r.ItemsSelected,t[i].Preferences=r.Preferences,t[i].ItemsLength=r.ItemsLength,s[t[i].SortOrder]=t[i]}return s}sortMessagingPreferences(t){const s=[];
1s.Preferences=[];let i=0,r=0;for(let c=0;c<t.length;c++)s.Preferences[t[c].SortOrder]=t[c];for(let c=0;c<s.Preferences.length;c++)s.Preferences[c]&&(s.Preferences[c].IsPreferenceOptOut||i++,r++);return s.ItemsSelected=i,s.ItemsLength=r,s}static{this.\u0275fac=function(s){return new(s||n)(e.LFG(h.Q),e.LFG(k.eN))}}static{this.\u0275prov=e.Yz7({token:n,factory:n.\u0275fac})}}return n})();var v=f(72026),d=f(66677),Z=f(74420),E=f(10802),P=f(98152);let C=(()=>{class n{constructor(){this.preferenceGroups=new P.xQ,this.preferenceGroups$=this.preferenceGroups.asObservable(),this.timeZones=new P.xQ,this.timeZones$=this.timeZones.asObservable()}setPreferenceGroups(t){this.preferenceGroups.next(t)}setAvailableTimeZones(t){this.timeZones.next(t)}static{this.\u0275fac=function(s){return new(s||n)}}static{this.\u0275prov=e.Yz7({token:n,factory:n.\u0275fac})}}return n})();var T=f(70923);function I(n,a){if(1&n&&(e.TgZ(0,"div",1)(1,"div",2)(2,"div",3),e._uU(3),e.qZA()()()),2&n){const t=e.oxw();e.xp6(3),e.Oqu(t.errorMsg)}}let x=(()=>{class n{constructor(t){this.csrfTokenService=t,this.isUnauthorized=!1,this.isUnauthorizedFormName=null,this.errorMsg="This session has expired. Please refresh and try again.",this.formName=null}ngOnInit(){this.csrfTokenService.isUnauthorized$.subscribe(t=>{"boolean"==typeof t?this.isUnauthorized=t:"object"==typeof t&&t&&(this.isUnauthorized=t.isUnauthorized,this.isUnauthorizedFormName=t.isUnauthorizedFormName)})}static{this.\u0275fac=function(s){return new(s||n)(e.Y36(d.A))}}static{this.\u0275cmp=e.Xpm({type:n,selectors:[["csrf-error-message"]],inputs:{errorMsg:"errorMsg",formName:"formName"},decls:1,vars:1,consts:[["class","csrf-error-message-container site-alert-danger alert alert-info","role","alert",4,"ngIf"],["role","alert",1,"csrf-error-message-container","site-alert-danger","alert","alert-info"],[1,"alert-content"],[1,"alert-description"]],template:function(s,i){1&s&&e.YNc(0,I,4,1,"div",0),2&s&&e.Q6J("ngIf",i.isUnauthorized&&!i.formName||i.isUnauthorized&&i.formName&&i.formName==i.isUnauthorizedFormName)},dependencies:[l.O5],encapsulation:2})}}return n})();function O(n,a){if(1&n&&(e.TgZ(0,"h2",13),e._uU(1),e.qZA()),2&n){const t=e.oxw(2);e.xp6(),e.Oqu(t.heading)}}function F(n,a){if(1&n&&(e.TgZ(0,"p",14),e._uU(1),e.qZA()),2&n){const t=e.oxw(2);e.xp6(),e.Oqu(t.description)}}function w(n,a){if(1&n){const t=e.EpF();e.TgZ(0,"label",29)(1,"input",30),e.NdJ("change",function(i){e.CHM(t);const r=e.oxw(2).index,c=e.oxw(3).index,m=e.oxw(2);return e.KtG(m.updatePreference(i,c,r))}),e.qZA(),e._UZ(2,"span",20),e.TgZ(3,"div",21)(4,"span",22),e._uU(5),e.qZA(),e.TgZ(6,"span",23),e._uU(7),e.qZA()()()}if(2&n){const t=e.oxw(2).$implicit;e.xp6(),e.Q6J("name",t.MessagingPreferenceId)("checked",!t.IsPreferenceOptOut)("formControlName",t.MessagingPreferenceId),e.xp6(4),e.hij(" ",t.MessagingPreferenceDescription," "),e.xp6(2),e.hij(" ",t.MessagingPreferenceSubtitle," ")}}function y(n,a){if(1&n&&(e.TgZ(0,"div",27),e.YNc(1,w,8,5,"label",28),e.qZA()),2&n){const t=e.oxw().$implicit;e.xp6(),e.Q6J("ngIf",t)}}function A(n,a){if(1&n&&(e.ynx(0),e.YNc(1,y,2,1,"div",26),e.BQk()),2&n){const t=a.$implicit;e.xp6(),e.Q6J("ngIf",t)}}function U(n,a){if(1&n&&(e.TgZ(0,"div",25),e.YNc(1,A,2,1,"ng-container",7),e.qZA()),2&n){const t=e.oxw(2).$implicit;e.xp6(),e.Q6J("ngForOf",t.Preferences)}}const N=n=>({"with-child":n}),G=n=>({"some-are-selected":n});function M(n,a){if(1&n){const t=e.EpF();e.TgZ(0,"div",16)(1,"div",17)(2,"label",18)(3,"input",19),e.NdJ("change",function(i){e.CHM(t);const r=e.oxw().index,c=e.oxw(2);return e.KtG(c.updatePreferenceGroup(i,r))}),e.qZA(),e._UZ(4,"span",20),e.TgZ(5,"div",21)(6,"span",22),e._uU(7),e.qZA(),e.TgZ(8,"span",23),e._uU(9),e.qZA()()()(),e.YNc(10,U,2,1,"div",24),e.qZA()}if(2&n){const t=e.oxw().$implicit,s=e.oxw(2);e.Q6J("ngClass",e.VKq(7,N,t.ItemsLength>1)),e.xp6(2),e.Q6J("ngClass",e.VKq(9,G,t.ItemsSelected>0&&t.ItemsSelected<t.ItemsLength)),e.xp6(),e.s9C("name","prefGroup"+t.MessagingPreferenceGroupId),e.Q6J("checked",t.ItemsLength==t.ItemsSelected&&!s.isGlobalOptOutFlag),e.xp6(4),e.hij(" ",t.PreferenceGroupName," "),e.xp6(2),e.hij(" ",t.MessagingPreferenceGroupSubtitle," "),e.xp6(),e.Q6J("ngIf",t.ItemsLength>1)}}function D(n,a){if(1&n&&(e.ynx(0),e.YNc(1,M,11,11,"div",15),e.BQk()),2&n){const t=a.$implicit;e.xp6(),e.Q6J("ngIf",t&&t.ItemsLength>0)}}function J(n,a){if(1&n&&(e.ynx(0),e.TgZ(1,"option",36),e._uU(2),e.qZA(),e.BQk()),2&n){const t=a.$implicit,s=e.oxw(3);e.xp6(),e.Q6J("value",t)("selected",s.recipient.TimeZone==t),e.xp6(),e.hij(" ",t," ")}}function L(n,a){if(1&n&&(e.TgZ(0,"div",31)(1,"label",32),e._uU(2,"Choose Your Preferred Time Zone "),e.qZA(),e.TgZ(3,"div",33)(4,"select",34),e.YNc(5,J,3,3,"ng-container",7),e.qZA(),e._UZ(6,"span",35),e.qZA()()),2&n){const t=e.oxw(2);e.xp6(5),e.Q6J("ngForOf",t.timeZones)}}function Q(n,a){1&n&&e._UZ(0,"i",37)}function Y(n,a){if(1&n){const t=e.EpF();e.TgZ(0,"div",2),e.YNc(1,O,2,1,"h2",3)(2,F,2,1,"p",4),e.TgZ(3,"form",5),e.NdJ("ngSubmit",function(){e.CHM(t);const i=e.oxw();return e.KtG(i.onSubmit())}),e._UZ(4,"csrf-error-message"),e.TgZ(5,"div",6),e.YNc(6,D,2,1,"ng-container",7),e.qZA(),e.YNc(7,L,7,1,"div",8),e.TgZ(8,"div",9)(9,"button",10),e._uU(10),e.YNc(11,Q,1,0,"i",11),e.qZA()(),e.TgZ(12,"div",12)(13,"p"),e._uU(14),e.qZA()()()()}if(2&n){const t=e.oxw();e.xp6(),e.Q6J("ngIf",t.heading),e.xp6(),e.Q6J("ngIf",t.description),e.xp6(),e.Q6J("formGroup",t.emailPreferencesForm),e.xp6(3),e.Q6J("ngForOf",t.messagingPreferenceGroups),e.xp6(),e.Q6J("ngIf",t.timeZones.length>1),e.xp6(2),e.Q6J("disabled",t.isSubmitBtnLoading),e.xp6(),e.hij(" ",t.buttonText," "),e.xp6(),e.Q6J("ngIf",t.isSubmitBtnLoading),e.xp6(),e.Q6J("ngClass",t.responseMessage.type),e.xp6(2),e.Oqu(t.responseMessage.message)}}function R(n,a){1&n&&(e.TgZ(0,"div",38)(1,"div",39),e._UZ(2,"i",40),e.qZA()())}let z=(()=>{class n{constructor(t,s,i,r,c,m,ce,ae,fe){if(this.fb=t,this.PreferencesModel=s,this.Router=i,this.route=r,this.EmailPreferencesService=c,this.ConfigManagerService=m,this.AuthService=ce,this.csrfTokenService=ae,this.DataLayerService=fe,this.enableRedirect=!1,this.buttonText="UPDATE PREFERENCES",this.isPreferencesLoaded=!1,this.isSubmitBtnLoading=!1,this.responseMessage={type:"",message:""},this.isGlobalOptOutFlag=!1,this.csrfToken=null,this.csrfTokenFormName="settings-comm-pref",this.siteConfig=this.ConfigManagerService.getConfig("site"),this.appConfig=this.ConfigManagerService.getConfig("app"),this.customerConfig=this.ConfigManagerService.getConfig("customer"),this.PreferencesModel.timeZones$.subscribe(b=>{this.timeZones=b}),this.AuthService.parseAccessTokenData()){const b=this.AuthService.parseAccessTokenData();this.customerInfo=b.data}}ngOnInit(){this.communicationPreferencesResponse?this.applyCommunicationPreferencesResponse(this.communicationPreferencesResponse):(this.csrfTokenService.emitUnauthorized(!1),this.csrfTokenService.getToken(this.csrfTokenFormName).subscribe(t=>{this.csrfToken=t}))}ngOnChanges(t){t.communicationPreferencesResponse&&this.applyCommunicationPreferencesResponse(t.communicationPreferencesResponse.currentValue)}applyCommunicationPreferencesResponse(t){if(t){if(!t.success&&this.enableRedirect)return this.Router.navigate(["page-not-found"]),!1;if(this.recipient=t.recipient,this.enableRedirect&&this.recipient&&!this.recipient.Destinations)return this.Router.navigate(["page-not-found"]),!1;t.success&&this.recipient&&this.recipient.Destinations&&this.recipient.Destinations[0]&&(this.email=this.recipient.Destinations[0].Destination,this.isGlobalOptOutFlag=this.recipient.Destinations[0].IsDestinationGlobalOptOutFlag,this.messagingPreferenceGroups=this.EmailPreferencesService.prepareAndSortMessagingPreferences(this.recipient.Destinations[0].PreferenceGroups),this.PreferencesModel.setPreferenceGroups(this.messagingPreferenceGroups),this.PreferencesModel.setAvailableTimeZones(t.timeZones),this.initializeForm())}}initializeForm(){const t=this.loadPreferencesFields();this.emailPreferencesForm=this.fb.group({email:[this.email,[o.kI.required,(0,Z.L)(),(0,E.o)()]],timezone:[this.recipient.TimeZone?this.recipient.TimeZone:"US/Pacific",o.kI.required],global_opt_out:[t.globalOptOut,o.kI.required],preferences:t.preferences}),this.isPreferencesLoaded=!0}loadPreferencesFields(){const t=this.fb.group({});let s=!0;return this.messagingPreferenceGroups.forEach(i=>
1{i.Preferences.forEach(r=>{this.isGlobalOptOutFlag&&(r.IsPreferenceOptOut=!0),t.addControl(r.MessagingPreferenceId,new o.NI(!r.IsPreferenceOptOut,o.kI.required)),r.IsPreferenceOptOut||(s=!1)})}),this.isGlobalOptOutFlag&&(s=!0),{preferences:t,globalOptOut:s}}onSubmit(){if(this.isSubmitBtnLoading=!0,this.emailPreferencesForm.valid){if(this.csrfTokenService.emitUnauthorized(!1),!this.csrfToken)return this.csrfTokenService.emitUnauthorized(!0),!1;const t={...this.emailPreferencesForm.value,csrfToken:this.csrfToken,csrfTokenFormName:this.csrfTokenFormName};this.DataLayerService.logDataLayerEvent({event:"Update_preferences_initiated",event_category:"Update_preferences",event_action:"Update_preferences",event_label:"Email Preference"}),this.EmailPreferencesService.updateCommunicationPreferences(t).subscribe(s=>{s.success?(this.responseMessage.type="success",this.responseMessage.message="Settings Saved!",this.DataLayerService.logDataLayerEvent({event:"Update_preferences_completed",event_category:"Update_preferences",event_action:"Update_preferences_completed",event_label:"Email Preference"})):(this.responseMessage.type="error",this.responseMessage.message="An Error Occured, Please try again or call "+this.siteConfig.phone_no),this.isSubmitBtnLoading=!1},s=>{403==s.status&&this.csrfTokenService.emitUnauthorized(!0)})}}updatePreference(t,s,i){const r=t.target.checked;r?(this.messagingPreferenceGroups[s].ItemsSelected++,this.emailPreferencesForm.get("global_opt_out").patchValue(!1)):this.messagingPreferenceGroups[s].ItemsSelected--,this.messagingPreferenceGroups[s].Preferences[i].IsPreferenceOptOut=!r,this.PreferencesModel.setPreferenceGroups(this.messagingPreferenceGroups),r||this.updateGlobalOptOut()}updatePreferenceGroup(t,s){this.updatePreferencePerGroup(t.target.checked,s)}updateAllPreferences(){const t=!this.emailPreferencesForm.get("global_opt_out").value;this.isGlobalOptOutFlag=!t,Object.keys(this.messagingPreferenceGroups).forEach(s=>{this.updatePreferencePerGroup(t,s)})}updatePreferencePerGroup(t,s){const i=this.messagingPreferenceGroups[s];i.Preferences.forEach(r=>{r&&(r.IsPreferenceOptOut=!t,this.emailPreferencesForm.get("preferences").patchValue({[r.MessagingPreferenceId]:t}))}),t?(i.ItemsSelected=i.ItemsLength,this.emailPreferencesForm.get("global_opt_out").patchValue(!1)):i.ItemsSelected=0,this.messagingPreferenceGroups[s]=i,this.PreferencesModel.setPreferenceGroups(this.messagingPreferenceGroups),t||this.updateGlobalOptOut()}updateGlobalOptOut(){let t=!0;this.messagingPreferenceGroups.forEach(s=>{s.Preferences.forEach(i=>{i.IsPreferenceOptOut||(t=!1)})}),t&&this.emailPreferencesForm.get("global_opt_out").patchValue(!0)}static{this.\u0275fac=function(s){return new(s||n)(e.Y36(o.QS),e.Y36(C),e.Y36(p.F0),e.Y36(p.gz),e.Y36(g),e.Y36(h.Q),e.Y36(v.e),e.Y36(d.A),e.Y36(T.n))}}static{this.\u0275cmp=e.Xpm({type:n,selectors:[["communication-preferences"]],inputs:{heading:"heading",description:"description",enableRedirect:"enableRedirect",buttonText:"buttonText",communicationPreferencesResponse:"communicationPreferencesResponse"},features:[e.TTD],decls:3,vars:2,consts:[["class","comp-communication-preferences-container",4,"ngIf","ngIfElse"],["loading",""],[1,"comp-communication-preferences-container"],["tabindex","0",4,"ngIf"],["class","subtitle","tabindex","0",4,"ngIf"],["role","form","novalidate","","autocomplete","off",1,"email-preferences-form",3,"formGroup","ngSubmit"],["formGroupName","preferences",1,"preference-groups-container"],[4,"ngFor","ngForOf"],["class","timezone-container",4,"ngIf"],[1,"button-container"],["type","submit",1,"submit-btn",3,"disabled"],["class","fa fa-spinner fa-spin fa-fw",4,"ngIf"],["tabindex","0",1,"message-container",3,"ngClass"],["tabindex","0"],["tabindex","0",1,"subtitle"],["class","preference-group-container",3,"ngClass",4,"ngIf"],[1,"preference-group-container",3,"ngClass"],[1,"parent-section"],[1,"site-custom-checkbox","checkbox-label-wrapper",3,"ngClass"],["type","checkbox",3,"name","checked","change"],[1,"checkbox-icon-override"],[1,"text-container"],[1,"title"],[1,"subtitle"],["class","items-section",4,"ngIf"],[1,"items-section"],["class","pref-item",4,"ngIf"],[1,"pref-item"],["class","site-custom-c
1heckbox checkbox-label-wrapper",4,"ngIf"],[1,"site-custom-checkbox","checkbox-label-wrapper"],["type","checkbox",3,"name","checked","formControlName","change"],[1,"timezone-container"],["for","timezone",1,"label-timezone"],[1,"site-custom-select"],["name","timezone","formControlName","timezone",1,"select-input"],[1,"select-icon","fa","fa-angle-down"],[3,"value","selected"],[1,"fa","fa-spinner","fa-spin","fa-fw"],[1,"page-loader-container","text-center","site-page-loader"],[1,"page-loader"],[1,"loader-icon","fa","fa-spinner","fa-spin"]],template:function(s,i){if(1&s&&e.YNc(0,Y,15,10,"div",0)(1,R,3,0,"ng-template",null,1,e.W1O),2&s){const r=e.MAs(2);e.Q6J("ngIf",i.isPreferencesLoaded)("ngIfElse",r)}},dependencies:[l.mk,l.sg,l.O5,o._Y,o.YN,o.Kr,o.Wl,o.EJ,o.JJ,o.JL,o.sg,o.u,o.x0,x],encapsulation:2})}}return n})();var q=f(22567);function B(n,a){1&n&&(e.TgZ(0,"div",10)(1,"p",11)(2,"strong"),e._uU(3,"We hate seeing you go!"),e.qZA(),e._uU(4," Please let us know what makes you unsubscribe from our emails and all promos, offers, sales, deals, tips, coupons and other ways to Save! "),e.qZA(),e.TgZ(5,"div",12),e._UZ(6,"textarea",13),e.qZA(),e.TgZ(7,"p",14),e._uU(8," Please allow up to 10 business days to process this unsubscribe request. "),e.qZA()())}function j(n,a){1&n&&(e.TgZ(0,"i",17),e._UZ(1,"span",18),e.qZA())}function W(n,a){if(1&n&&(e.TgZ(0,"button",15),e._uU(1),e.YNc(2,j,2,0,"i",16),e.qZA()),2&n){const t=e.oxw();e.Q6J("disabled",t.isLoading),e.xp6(),e.hij(" ",t.submitBtnLabel.toUpperCase()," "),e.xp6(),e.Q6J("ngIf",t.isLoading)}}function V(n,a){1&n&&(e.TgZ(0,"span",19),e._uU(1,"Updated!"),e.qZA())}let H=(()=>{class n{constructor(t,s,i,r,c){this.ConfigManagerService=t,this.CrossStorageClientService=s,this.EmailPreferencesService=i,this.csrfTokenService=r,this.DataLayerService=c,this.isSuccess=!1,this.showTextArea=!1,this.showButton=!1,this.submitBtnLabel="Update",this.isLoading=!1,this.isSubscribe=!1,this.csrfToken=null,this.csrfTokenFormName="settings-email-pref",this.enabledCompref=!1}ngOnInit(){this.settingsConfig=this.ConfigManagerService.getConfig("settings"),this.emailPreferencesLabel=this.settingsConfig.email_preferences.label,this.siteName=this.ConfigManagerService.getConfig("app").site_name,this.buildForm(),this.getEmailPreference(),window.addEventListener("newsletter-change",()=>{this.getEmailPreference()}),this.csrfTokenService.emitUnauthorized(!1),this.csrfTokenService.getToken(this.csrfTokenFormName).subscribe(t=>{this.csrfToken=t})}buildForm(){this.emailPreferencesForm=new o.cw({subscription:new o.NI(""),newsletter_id:new o.NI(""),unsubscribed_reason:new o.NI(""),email:new o.NI("")})}getEmailPreference(){if(this.isLoading=!0,this.enabledCompref){const t=this.communicationPreferencesResponse?.recipient?.Destinations?.[0]?.De
1stination||"";t&&(this.isSubscribe=!this.communicationPreferencesResponse.recipient.Destinations[0].IsDestinationGlobalOptOutFlag,this.emailPreferencesForm.patchValue({email:t,subscription:this.isSubscribe})),this.isLoading=!1}else this.EmailPreferencesService.getEmailPreference().subscribe(t=>{t.success&&(this.isSubscribe="n"==t.data.unsubscribed_flag,this.setUnsubscribedFlag(t.data.unsubscribed_flag),this.emailPreferencesForm.patchValue({subscription:this.isSubscribe,newsletter_id:t.data.newsletterId,email:t.data.email})),this.isLoading=!1},()=>{this.isLoading=!1})}updateEmailPreferences(){if(this.isSuccess=!1,this.isLoading=!0,this.csrfTokenService.emitUnauthorized(!1),!this.csrfToken)return this.csrfTokenService.emitUnauthorized(!0),!1;const t={...this.emailPreferencesForm.value,csrfToken:this.csrfToken,csrfTokenFormName:this.csrfTokenFormName};this.DataLayerService.logDataLayerEvent({event:"Update_preferences_initiated",event_category:"Update_preferences",event_action:"Update_preferences",event_label:"Email Preference"}),this.enabledCompref?this.EmailPreferencesService.updateCommunicationPreferences(t).subscribe(s=>{this.handleEmailResponse(s,t)},s=>{403==s.status&&this.csrfTokenService.emitUnauthorized(!0)}):this.EmailPreferencesService.updateEmailPreference(t).subscribe(s=>{this.handleEmailResponse(s,t)},s=>{403==s.status&&this.csrfTokenService.emitUnauthorized(!0)})}handleEmailResponse(t,s){if(t.success){this.isSuccess=!0,this.showButton=!1,this.showTextArea=!1,this.enabledCompref&&(this.communicationPreferencesResponse.recipient.Destinations[0].IsDestinationGlobalOptOutFlag=t.recipient.Destinations[0].IsDestinationGlobalOptOutFlag),this.getEmailPreference();const i=new CustomEvent("email-pref-change",{detail:{subscription:s.subscription}});window.dispatchEvent(i),this.DataLayerService.logDataLayerEvent({event:"Update_preferences_completed",event_category:"Update_preferences",event_action:"Update_preferences_completed",event_label:"Email Preference"})}this.isLoading=!1}setUnsubscribedFlag(t){const s=this.ConfigManagerService.getConfig("customer").customer_data_field,i=this.ConfigManagerService.getConfig("cross_storage");this.CrossStorageClientService.onInit(i.hub_url,i.hub_opt),this.CrossStorageClientService.getData(s).then(r=>{if(r){const c=JSON.parse(r);if(typeof c.unsubscribed_flag<"u"){c.unsubscribed_flag=t;const m=JSON.stringify(c);this.CrossStorageClientService.setData(s,m)}}})}toggleForm(t){this.showButton=!!t.target.checked,this.showTextArea=!t.target.checked,!this.isSubscribe&&t.target.checked&&(this.submitBtnLabel="Update"),this.isSubscribe&&(this.showButton=!t.target.checked,this.emailPreferencesForm.get("unsubscribed_reason").patchValue(""),this.submitBtnLabel=this.settingsConfig.email_preferences.unsubscribe_btn_label)}static{this.\u0275fac=function(s){return new(s||n)(e.Y36(h.Q),e.Y36(q.T),e.Y36(g),e.Y36(d.A),e.Y36(T.n))}}static{this.\u0275cmp=e.Xpm({type:n,selectors:[["email-pref"]],inputs:{enabledCompref:"enabledCompref",communicationPreferencesResponse:"communicationPreferencesResponse"},decls:13,vars:6,consts:[[1,"comp-email-pref-container"],["tabindex","0",1,"email-preferences-label","first-focus-element"],["autocomplete","off",1,"email-preferences-form",3,"formGroup","submit"],[1,"account-checkbox","checkbox-label-wrapper","accessibility-focus-within"],["type","checkbox","formControlName","subscription","name","subscription","data-qaid","emailSubscriptionCheckbox","value","0",1,"checkbox-input","checkbox-subscription-input",3,"change"],[1,"checkbox-toggle","checkbox-icon-override"],[1,"checkbox-subscription-label"],["class","unsubscribe-container",4,"ngIf"],["type","submit","class","account-btn-primary email-pref-submit-btn",3,"disabled",4,"ngIf"],["class","email-pref-success-message","role","alert",4,"ngIf"],[1,"unsubscribe-container"],["tabindex","0",1,"unsubscribe-msg"],[1,"account-input"],["tabindex","0","name","unsubscribed_reason","maxlength","300","formControlName","unsubscribed_reason","cols","3","rows","5",1,"unsubscribed-reason"],["tabindex","0",1,"unsubscribe-caption"],["type","submit",1,"account-btn-primary","email-pref-submit-btn",3,"disabled"],["class","fa fa-spinner fa-spin fa-fw",4,"ngIf"],[1,"fa","fa-spinner","fa-spin","fa-fw"],["role","alert",1,"accessibility-hidden"],["role","alert",1,"email-pref-success-message"]],template:function(s,i){1&s&&(e.TgZ(0,"div",0)(1,"h3",1),e._uU(2),e.qZA(),e.TgZ(3,"form",2),e.NdJ("submit",function(){return i.updateEmailPreferences()}),e._UZ(4,"csrf-error-message"),e.TgZ(5,"label",3)(6,"input",4),e.NdJ("change",function(c){return i.toggleForm(c)}),e.qZA(),e._UZ(7,"span",5),e.TgZ(8,"span",6),e._uU(9),e.qZA()(),e.YNc(10,B,9,0,"div",7)(11,W,3,3,"button",8)(12,V,2,0,"span",9),e.qZA()()),2&s&&(e.xp6(2),e.Oqu(i.emailPreferencesLabel),e.xp6(),e.Q6J("formGroup",i.emailPreferencesForm),e.xp6(6),e.hij("Receive special offers & promos from ",i.siteName,""),e.xp6(),e.Q6J("ngIf",i.showTextArea&&i.isSubscribe),e.xp6(),e.Q6J("ngIf",i.showButton),e.xp6(),e.Q6J("ngIf",i.isSuccess))},dependencies:[l.O5,o._Y,o.Fj,o.Wl,o.JJ,o.JL,o.nD,o.sg,o.u,x],encapsulation:2})}}return n})();function $(n,a){if(1&n&&(e.ynx(0),e._UZ(1,"email-pref",4),e.BQk()),2&n){const t=e.oxw(2);e.xp6(),e.Q6J("enabledCompref",!0)("communicationPreferencesResponse",t.communicationPreferencesResponse)}}function X(n,a){if(1&n&&e._UZ(0,"communication-preferences",5),2&n){const t=e.oxw(2);e.Q6J("heading","Email Preferences")("description","We love providing customization options for our customers. Help us tailor your email experience.")("communicationPreferencesResponse",t.communicationPreferencesResponse)}}function K(n,a){if(1&n&&(e.ynx(0),e.YNc(1,$,2,2,"ng-container",1)(2,X,1,3,"ng-template",null,3,e.W1O),e.BQk()),2&n){const t=e.MAs(3),s=e.oxw();e.xp6(),e.Q6J("ngIf",s.singleOption)("ngIfElse",t)}}function ee(n,a){1&n&&e._UZ(0,"email-pref",6),2&n&&e.Q6J("enabledCompref",!1)}let te=(()=>{class n{constructor(t,s,i,r,c){this.EmailPreferencesService=t,this.route=s,this.Router=i,this.AuthService=r,this.csrfTokenService=c,this.onGetDataError=ne
1w e.vpe,this.singleOption=!1,this.enableRedirect=!1,this.csrfToken=null,this.csrfTokenFormName="email-comm-pref-token"}ngOnInit(){this.dbDrivenConfig=JSON.parse(window.siteConfig),this.isComprefEnabled=this.dbDrivenConfig?.db_driven_config?.site?.enable_email_preferences,this.isComprefEnabled&&(this.csrfTokenService.emitUnauthorized(!1),this.csrfTokenService.getToken(this.csrfTokenFormName).subscribe(t=>{this.csrfToken=t,this.route.queryParams.subscribe(s=>{let i=null,r=!1;if(s.email&&!this.AuthService.parseAccessTokenData()){if(this.enableRedirect=!0,!this.ensureCsrfToken())return!1;i={email:s.email,resubscribe:!1,csrfToken:this.csrfToken,csrfTokenFormName:this.csrfTokenFormName},r=!0}else{if(this.AuthService.parseAccessTokenData()){const c=this.AuthService.parseAccessTokenData();this.customerInfo=c.data}if(i=s,!this.enableRedirect){if(!this.customerInfo||!this.customerInfo.email||!this.ensureCsrfToken())return!1;i={email:this.customerInfo.email,resubscribe:!0,csrfToken:this.csrfToken,csrfTokenFormName:this.csrfTokenFormName}}if(this.enableRedirect&&this.csrfToken&&(i={...i,csrfToken:this.csrfToken,csrfTokenFormName:this.csrfTokenFormName}),!this.ensureCsrfToken())return!1}this.EmailPreferencesService.getCommunicationPreferences(i).subscribe(c=>{if(r&&!c.success)return this.onGetDataError.emit(!0),!1;this.communicationPreferencesResponse=c;const m=c?.recipient?.Destinations?.[0]?.PreferenceGroups;this.singleOption=!m||0===m.length})})}))}ensureCsrfToken(){return!!this.csrfToken||(this.csrfTokenService.emitUnauthorized(!0),!1)}static{this.\u0275fac=function(s){return new(s||n)(e.Y36(g),e.Y36(p.gz),e.Y36(p.F0),e.Y36(v.e),e.Y36(d.A))}}static{this.\u0275cmp=e.Xpm({type:n,selectors:[["email-preferences-wrapper"]],outputs:{onGetDataError:"onGetDataError"},decls:4,vars:2,consts:[[1,"email-preferences-wrapper-container"],[4,"ngIf","ngIfElse"],["newsletterTpl",""],["multiOptions",""],[3,"enabledCompref","communicationPreferencesResponse"],[3,"heading","description","communicationPreferencesResponse"],[3,"enabledCompref"]],template:function(s,i){if(1&s&&(e.TgZ(0,"div",0),e.YNc(1,K,4,2,"ng-container",1)(2,ee,1,1,"ng-template",null,2,e.W1O),e.qZA()),2&s){const r=e.MAs(3);e.xp6(),e.Q6J("ngIf",i.isComprefEnabled)("ngIfElse",r)}},dependencies:[l.O5,z,H],encapsulation:2})}}return n})();const ne=[{path:"",component:(()=>{class n{static{this.\u0275fac=function(s){return new(s||n)}}static{this.\u0275cmp=e.Xpm({type:n,selectors:[["app-email-preferences"]],decls:2,vars:0,consts:[[1,"page-email-preferences-container"]],template:function(s,i){1&s&&(e.TgZ(0,"div",0),e._UZ(1,"email-preferences-wrapper"),e.qZA())},dependencies:[te],encapsulation:2})}}return n})()}];let se=(()=>{class n{static{this.\u0275fac=function(s){return new(s||n)}}static{this.\u0275mod=e.oAB({type:n})}static{this.\u0275inj=e.cJS({imports:[p.Bz.forChild(ne),p.Bz]})}}return n})(),ie=(()=>{class n{static{this.\u0275fac=function(s){return new(s||n)}}static{this.\u0275mod=e.oAB({type:n})}static{this.\u0275inj=e.cJS({providers:[h.Q,g,C],imports:[l.ez,o.u5,o.UX,_.b]})}}return n})();var re=f(38168);let oe=(()=>{class n{static{this.\u0275fac=function(s){return new(s||n)}}static{this.\u0275mod=e.oAB({type:n})}static{this.\u0275inj=e.cJS({imports:[l.ez,se,o.u5,o.UX,_.b,ie,re.r]})}}return n})()}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.