1import{a as O}from"./chunk-JVMOADGD.js";import"./chunk-BSJVWSZ5.js";import{D as j}from"./chunk-4M6DCBQZ.js";import{h as F,k as U,r as N}from"./chunk-DXVQJAHD.js";import"./chunk-C6XWWCUT.js";import"./chunk-DEYJRJKY.js";import{y as D}from"./chunk-EK2LUO54.js";import"./chunk-JQPFVPBT.js";import{$b as l,Ac as p,Bc as L,Nb as T,Pb as g,Qb as b,Tb as V,Ub as I,Zb as t,_b as i,cb as a,fc as k,gc as y,ha as _,kc as C,lc as c,oa as h,pa as E,qa as u,ra as f,s as v,ub as S,xa as m,yc as w,zc as s}from"./chunk-UBTXYZ6Y.js";import{a as P,b as M,i as x}from"./chunk-RKIXE2YC.js";var H=(n,r)=>r.key;function B(n,r){n&1&&(t(0,"div",7)(1,"div",11),l(2,"div",12),t(3,"p",13),s(4,"Loading your preferences..."),i()()())}function G(n,r){if(n&1&&(t(0,"div",8),u(),t(1,"svg",14),l(2,"path",15),i(),f(),t(3,"h2",16),s(4,"Unable to Load Preferences"),i(),t(5,"p",17),s(6),i(),t(7,"p",18),s(8," The link may have expired or is invalid. Please use the link from your most recent email. "),i()()),n&2){let e=c();a(6),p(e.errorMessage())}}function Y(n,r){n&1&&(t(0,"span",23),l(1,"span",24),s(2," Updating... "),i())}function $(n,r){n&1&&s(0," Re-subscribe to Emails ")}function q(n,r){if(n&1){let e=k();t(0,"div",8),u(),t(1,"svg",19),l(2,"path",20),i(),f(),t(3,"h2",16),s(4,"You Are Unsubscribed"),i(),t(5,"p",21),s(6),i(),t(7,"button",22),C("click",function(){h(e);let d=c();return E(d.resubscribeAll())}),g(8,Y,3,0,"span",23)(9,$,1,0),i()()}if(n&2){let e=c();a(6),L(" ",e.email()," is currently unsubscribed from all emails. "),a(),y("disabled",e.saving()),a(),b(e.saving()?8:9)}}function z(n,r){if(n&1){let e=k();t(0,"div",29)(1,"div",36)(2,"p",37),s(3),i(),t(4,"p",38),s(5),i()(),t(6,"button",39),C("click",function(){let d=h(e).$implicit,R=c(2);return E(R.togglePreference(d.key))}),l(7,"span",40),i()()}if(n&2){let e=r.$implicit,o=c(2);a(3),p(e.label),a(2),p(e.description),a(),w(o.preferences()[e.key]?"bg-indigo-600":"bg-surface-secondary"),T("aria-checked",o.preferences()[e.key]),a(),w(o.preferences()[e.key]?"translate-x-5":"translate-x-0")}}function J(n,r){n&1&&(t(0,"span",32),l(1,"span",24),s(2," Saving... "),i())}function K(n,r){n&1&&s(0," Save Preferences ")}function Q(n,r){if(n&1&&(t(0,"div",34),u(),t(1,"svg",41),l(2,"path",42),i(),f(),t(3,"p",43),s(4),i()()),n&2){let e=c(2);a(4),p(e.successMessage())}}function W(n,r){if(n&1&&(t(0,"div",35),u(),t(1,"svg",44),l(2,"path",45),i(),f(),t(3,"p",46),s(4),i()()),n&2){let e=c(2);a(4),p(e.saveErrorMessage())}}function X(n,r){if(n&1){let e=k();t(0,"div",25)(1,"div",26)(2,"p",13),s(3,"Managing preferences for"),i(),t(4,"p",27),s(5),i()(),t(6,"div",28),V(7,z,8,7,"div",29,H),i(),t(9,"div",30)(10,"button",31),C("click",function(){h(e);let d=c();return E(d.savePreferences())}),g(11,J,3,0,"span",32)(12,K,1,0),i(),t(13,"button",33),C("click",function(){h(e);let d=c();return E(d.unsubscribeFromAll())}),s(14," Unsubscribe from All "),i()()(),g(15,Q,5,1,"div",34),g(16,W,5,1,"div",35)}if(n&2){let e=c();a(5),p(e.email()),a(2),I(e.categories),a(3),y("disabled",e.saving()),a(),b(e.saving()?11:12),a(2),y("disabled",e.saving()),a(2),b(e.successMessage()?15:-1),a(),b(e.saveErrorMessage()?16:-1)}}var A=class n{prefSvc=_(O);route=_(F);router=_(U);loading=m(!0);saving=m(!1);errorMessage=m(null);successMessage=m(null);saveErrorMessage=m(null);email=m("");globalUnsubscribed=m(!1);preferences=m({marketing:!0,product_updates:!0,newsletters:!0,promotions:!0});token="";categories=[{key:"marketing",label:"Marketing Emails",description:"Campaigns, announcements, and special offers"},{key:"product_updates",label:"Product Updates",description:"New features, improvements, and release notes"},{key:"newsletters",label:"Newsletters",description:"Regular updates, industry insights, and curated content"},{key:"promotions",label:"Promotions",description:"Discounts, deals, and limited-time offers"}];ngOnInit(){if(this.token=this.route.snapshot.queryParamMap.get("token")??"",!this.token){this.errorMessage.set("No preference token provided. Please use the link from your email."),this.loading.set(!1);return}this.loadPreferences()}loadPreferences(){return x(this,null,function*(){this.loading.set(!0),this.errorMessage.set(null);try{let r=yield v(this.prefSvc.getPreferenceCenter({token:this.token}
1));this.email.set(r.email);let e={marketing:!0,product_updates:!0,newsletters:!0,promotions:!0};for(let d of r.preferences)d.category in e&&(e[d.category]=d.isOptedIn);this.preferences.set(e);let o=r.preferences.length>0&&r.preferences.every(d=>!d.isOptedIn);this.globalUnsubscribed.set(o)}catch(r){let e=r?.error?.message??"Failed to load preferences";this.errorMessage.set(e)}finally{this.loading.set(!1)}})}togglePreference(r){let e=this.preferences();this.preferences.set(M(P({},e),{[r]:!e[r]})),this.successMessage.set(null),this.saveErrorMessage.set(null)}savePreferences(){return x(this,null,function*(){this.saving.set(!0),this.successMessage.set(null),this.saveErrorMessage.set(null);let r=this.preferences(),e={token:this.token,preferences:Object.keys(r).map(o=>({category:o,isOptedIn:r[o]}))};try{yield v(this.prefSvc.updatePreferencesFromCenter(e)),this.successMessage.set("Your email preferences have been updated.")}catch(o){let d=o?.error?.message??"Failed to save preferences";this.saveErrorMessage.set(d)}finally{this.saving.set(!1)}})}unsubscribeFromAll(){return x(this,null,function*(){this.saving.set(!0),this.successMessage.set(null),this.saveErrorMessage.set(null);let r={token:this.token,preferences:this.categories.map(e=>({category:e.key,isOptedIn:!1}))};try{yield v(this.prefSvc.updatePreferencesFromCenter(r)),this.router.navigate(["/unsubscribed"],{queryParams:{token:this.token}})}catch(e){let o=e?.error?.message??"Failed to unsubscribe";this.saveErrorMessage.set(o)}finally{this.saving.set(!1)}})}resubscribeAll(){return x(this,null,function*(){this.saving.set(!0),this.successMessage.set(null),this.saveErrorMessage.set(null);let r={token:this.token,preferences:this.categories.map(e=>({category:e.key,isOptedIn:!0}))};try{yield v(this.prefSvc.updatePreferencesFromCenter(r)),this.globalUnsubscribed.set(!1),this.preferences.set({marketing:!0,product_updates:!0,newsletters:!0,promotions:!0}),this.successMessage.set("You have been re-subscribed to all emails.")}catch(e){let o=e?.error?.message??"Failed to re-subscribe";this.saveErrorMessage.set(o)}finally{this.saving.set(!1)}})}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=S({type:n,selectors:[["app-preference-center"]],decls:17,vars:1,consts:[[1,"min-h-screen","bg-surface-secondary","flex","items-start","justify-center","px-4","py-12","sm:py-20"],[1,"w-full","max-w-lg"],[1,"text-center","mb-8"],[1,"inline-flex","items-center","justify-center","w-14","h-14","rounded-xl","bg-indigo-600","text-white","mb-4"],["fill","none","stroke","currentColor","viewBox","0 0 24 24",1,"w-7","h-7"],["stroke-linecap","round","stroke-linejoin","round","stroke-width","2","d","M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"],[1,"text-2xl","font-bold","text-text","dark:text-white"],[1,"bg-surface","rounded-xl","shadow-sm","border","border-border","p-12"],[1,"bg-surface","rounded-xl","shadow-sm","border","border-border","p-8","text-center"],[1,"mt-8","text-center"],[1,"text-xs","text-tertiary"],[1,"flex","flex-col","items-center","justify-center","gap-3"],[1,"w-8","h-8","border-2","border-indigo-600","border-t-transparent","rounded-full","animate-spin"],[1,"text-sm","text-tertiary"],["fill","none","stroke","currentColor","viewBox","0 0 24 24",1,"w-12","h-12","mx-auto","text-red-400","mb-4"],["stroke-linecap","round","stroke-linejoin","round","stroke-width","2","d","M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"],[1,"text-lg","font-semibold","text-text","dark:text-white","mb-2"],[1,"text-tertiary","text-sm"],[1,"text-tertiary","text-xs","mt-3"],["fill","none","stroke","currentColor","viewBox","0 0 24 24",1,"w-12","h-12","mx-auto","text-amber-400","mb-4"],["stroke-linecap","round","stroke-linejoin","round","stroke-width","2","d","M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"],[1,"text-tertiary","text-sm","mb-6"],[1,"px-6","py-2.5","text-sm","font-medium","text-white","bg-indigo-600","hover:bg-indigo-700","rounded-lg","shadow-sm","transition-colors","disabled:opacity-50","disabled:cursor-not-allowed",3,"click","disabled"],[1,"flex","items-center","gap-2"],[1,"w-4","h-4","border-2","border-white","border-t-transparent","rounded-full","animate-spin"],[1,"bg-surface","rounded-xl","shadow-sm","border","border-border"],[1,"px-6","py-5","border-b","border-border"],[1,"text-base","font-semibold","text-text","dark:text-white","mt-0.5"],[1,"divi
1de-y","divide-border"],[1,"px-6","py-4","flex","items-center","justify-between"],[1,"px-6","py-5","border-t","border-border","flex","flex-col","sm:flex-row","items-center","gap-3"],[1,"w-full","sm:w-auto","px-6","py-2.5","text-sm","font-medium","text-white","bg-indigo-600","hover:bg-indigo-700","rounded-lg","shadow-sm","transition-colors","disabled:opacity-50","disabled:cursor-not-allowed",3,"click","disabled"],[1,"flex","items-center","justify-center","gap-2"],[1,"w-full","sm:w-auto","px-6","py-2.5","text-sm","font-medium","text-red-700","dark:text-red-300","bg-red-50","dark:bg-red-900/20","border","border-red-200","dark:border-red-800","hover:bg-red-100","dark:hover:bg-red-900/30","rounded-lg","transition-colors","disabled:opacity-50","disabled:cursor-not-allowed",3,"click","disabled"],[1,"mt-4","bg-green-50","dark:bg-green-900/20","border","border-green-200","dark:border-green-800","rounded-lg","p-4","flex","items-center","gap-3"],[1,"mt-4","bg-red-50","dark:bg-red-900/20","border","border-red-200","dark:border-red-800","rounded-lg","p-4","flex","items-center","gap-3"],[1,"pr-4"],[1,"text-sm","font-medium","text-text","dark:text-white"],[1,"text-xs","text-tertiary","mt-0.5"],["type","button","role","switch",1,"relative","inline-flex","h-6","w-11","shrink-0","cursor-pointer","rounded-full","border-2","border-transparent","transition-colors","duration-200","ease-in-out","focus:outline-none","focus:ring-2","focus:ring-indigo-500","focus:ring-offset-2",3,"click"],[1,"pointer-events-none","inline-block","h-5","w-5","transform","rounded-full","bg-surface","shadow","ring-0","transition","duration-200","ease-in-out"],["fill","none","stroke","currentColor","viewBox","0 0 24 24",1,"w-5","h-5","text-green-600","dark:text-green-400","shrink-0"],["stroke-linecap","round","stroke-linejoin","round","stroke-width","2","d","M5 13l4 4L19 7"],[1,"text-sm","text-green-700","dark:text-green-300"],["fill","none","stroke","currentColor","viewBox","0 0 24 24",1,"w-5","h-5","text-red-600","dark:text-red-400","shrink-0"],["stroke-linecap","round","stroke-linejoin","round","stroke-width","2","d","M6 18L18 6M6 6l12 12"],[1,"text-sm","text-red-700","dark:text-red-300"]],template:function(e,o){e&1&&(t(0,"div",0)(1,"div",1)(2,"div",2)(3,"div",3),u(),t(4,"svg",4),l(5,"path",5),i()(),f(),t(6,"h1",6),s(7,"Email Preferences"),i()(),g(8,B,5,0,"div",7)(9,G,9,1,"div",8)(10,q,10,3,"div",8)(11,X,17,6),t(12,"div",9)(13,"p",10),s(14," You received this email because you signed up for our service. "),l(15,"br"),s(16," If you believe this was sent in error, please contact support. "),i()()()()),e&2&&(a(8),b(o.loading()?8:o.errorMessage()?9:o.globalUnsubscribed()?10:11))},dependencies:[D,j,N],encapsulation:2})};export{A as PreferenceCenterComponent};
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.