1"use strict";(self.webpackChunkng_up=self.webpackChunkng_up||[]).push([["default-src_app_web-app_services_post-trial-experiment_service_ts"],{87421:(V,O,r)=>{r.r(O),r.d(O,{PostTrialExperimentService:()=>R});var s=r(34929),g=r(36362),c=r(49312),E=r(38102),P=r(15527),M=r(40619),A=r(67274),L=r(15741),U=r(76317),F=r(98977),a=r(60116),d=r(87580),o=r(10745),T=r(59295),D=r(32673),m=r(53158),N=r(62566),_=r(3184),h=r(14045),f=r(1146),l=r(98476),I=r(43525),v=r(41752),C=r(1734),S=r(12379);let R=(()=>{class n{constructor(t,e,i,u,p,y,x,B){this._store=t,this._accountService=e,this._celebrationService=i,this._bigQueryService=u,this._subscriptionService=p,this._envService=y,this._router=x,this.baseHref=B,this._postTrialPaymentExperimentValue=null,this.trialPostSignUpTrait=null,this._showTrialPostSignUpDialogOnLoad=new U.X(!1),this.showTrialPostSignUpDialogOnLoad$=this._showTrialPostSignUpDialogOnLoad.asObservable(),this._blockedCountries=["IN","KR"],this.countryCode="",this.countryCodeFromApi=null}get postTrialPaymentExperimentValue(){return this._postTrialPaymentExperimentValue}set postTrialPaymentExperimentValue(t){this._postTrialPaymentExperimentValue=t}isExperimentValueLoaded(){return null!==this._postTrialPaymentExperimentValue}getExperimentDataForPostTrialPayment(t=!1){return new Promise(e=>{this.postTrialPaymentExperimentValue?e({trialPostSignupValue:this.postTrialPaymentExperimentValue}):this.validateCountryAndGetExperimentData(t).subscribe({next:i=>{e(i)},error:i=>{e(!1)}})})}processFlagsmithExperimentData(t,e){return(0,s.mG)(this,void 0,void 0,function*(){if("boolean"==typeof t)return t;if(!(null==t?void 0:t.flagsmithData))return!1;if(this.isEmailInPostSignupWhitelist(t.flagsmithData))return this.postTrialPaymentExperimentValue=n.EXPERIMENT_CONFIG.WHITELIST_TRIAL_POST_SIGNUP_VALUE,this.getTrialPostSignUpTrait(),{trialPostSignupValue:this.postTrialPaymentExperimentValue};const i=t.flagsmithData[E.H.TRIAL_POST_SIGNUP];return(null==i?void 0:i.enabled)?(this.postTrialPaymentExperimentValue=(null==i?void 0:i.value)||E.l.TRIAL_POST_SIGNUP_CONTROL,this.getTrialPostSignUpTrait(),e&&this.sendBigQueryLogs(),{trialPostSignupValue:this.postTrialPaymentExperimentValue}):(this.setExperimentValueToControl(),!1)})}isEmailInPostSignupWhitelist(t){const e=this._accountService.email;if(!e)return!1;const i=t[E.H.TRIAL_POST_SIGNUP_WHITELIST];if(!(null==i?void 0:i.enabled)||!(null==i?void 0:i.value))return!1;const p=String(i.value).split(",").map(y=>y.trim().toLowerCase()).filter(Boolean).includes(e.trim().toLowerCase());
1return p&&console.log("[PostTrialExperiment] whitelist hit, forcing variant:",n.EXPERIMENT_CONFIG.WHITELIST_TRIAL_POST_SIGNUP_VALUE,"email:",e),p}getFlagsmithExperimentData(t){return this._store.select(A.mn).pipe((0,F.x)((e,i)=>this.createFlagsmithStateKey(e)===this.createFlagsmithStateKey(i)),(0,a.h)(e=>this.isFlagsmithStateValid(e)),(0,d.V)({each:n.EXPERIMENT_CONFIG.FLAGSMITH_TIMEOUT_MS,with:()=>(this.setExperimentValueToControl(),(0,o.of)(!1))}),(0,T.q)(1),(0,D.w)(e=>(0,s.mG)(this,void 0,void 0,function*(){return this.processFlagsmithExperimentData(e,t)})),(0,m.K)(e=>this.handleFlagsmithError(e)))}validateCountryAndGetExperimentData(t){return this.getCountryCode().pipe((0,D.w)(e=>(this.countryCode=this.getNormalizedCountryCode(null!=e?e:null),this.countryCodeFromApi=e,this.isCountryAllowedForExperiment(null!=e?e:null)?this.getFlagsmithExperimentData(t):(this.setExperimentValueToControl(),(0,o.of)(!1)))),(0,m.K)(e=>this.handleFlagsmithError(e)))}setExperimentValueToControl(){this.postTrialPaymentExperimentValue=E.l.TRIAL_POST_SIGNUP_CONTROL}resetExperimentValue(){this.postTrialPaymentExperimentValue=null,this.trialPostSignUpTrait=null}checkIfRequiredDaysPastForExperiment(){const t=this._accountService.dateCreated;if(t){const e=Number(this.postTrialPaymentExperimentValue);if(e&&e>n.EXPERIMENT_CONFIG.MIN_POSITIVE_VALUE){const i=new Date(t),u=new Date(i);return u.setDate(i.getDate()+e),new Date>=u}}return!1}checkIfAccountCreatedWithinRequiredDays(t){const e=this._accountService.dateCreated;if(e){const i=new Date(e),u=new Date(i);return u.setDate(i.getDate()+t),new Date<=u}return!1}isPostTrialPaymentEligible(){return this.isPostTrialPaymentVariantUser()}isPostTrialPaymentVariantUser(){var t;const e=this.postTrialPaymentExperimentValue!==E.l.TRIAL_POST_SIGNUP_CONTROL,i=(null===(t=this.postTrialPaymentExperimentValue)||void 0===t?void 0:t.toString())!==E.l.TRIAL_POST_SIGNUP_VARIANT_A,u=Number(this.postTrialPaymentExperimentValue)>n.EXPERIMENT_CONFIG.MIN_POSITIVE_VALUE;return e&&i&&u}isEligibleAsBasicUser(){const t=this.trialPostSignUpTrait;return!!t&&Number(t)>0&&this.isAccountStatusFirstTimeBasicUser()}isEligibleForPremiumExperienceFreeTrial(){const t=this.trialPostSignUpTrait;return!!t&&Number(t)>0&&this.isAccountStatusFirstTimeFreetrialUser()}isAccountStandardAndFirstTime(){return this._accountService.isStandard()&&!this._accountService.productId}isAccountStatusFirstTimeBasicUser(){return this._accountService.realSubscriptionStatus===c.qq.BASIC&&this.isAccountStandardAndFirstTime()}isAccountStatusFirstTimeFreetrialUser(){return this._accountService.realSubscriptionStatus===c.qq.FREE_TRIAL&&this.isAccountStandardAndFirstTime()}proceedWithPriceCardClickFlow(t){return(0,s.mG)(this,void 0,void 0,function*(){const e=yield this.getAndValidateProfileData(t);if(!this.isNufCompleteFinished(e))return this.isNufCompletePending(e)?yield this.handleNufCompletePending():void 0;this.handleNufCompleteFinished()})}getAndValidateProfileData(t){return(0,s.mG)(this,void 0,void 0,function*(){return yield t.getCurrentProfileData()})}isNufCompleteFinished(t){return t.nufComplete===n.EXPERIMENT_CONFIG.NUF_COMPLETE_FINISHED}isNufCompletePending(t){return t.nufComplete===n.EXPERIMENT_CONFIG.NUF_COMPLETE_PENDING}handleNufCompleteFinished(){this.reloadProfileSelect()}handleNufCompletePending(){return(0,s.mG)(this,void 0,void 0,function*(){return yield this.getExperimentDataForPostTrialPayment(),this.isPostTrialPaymentEligible()?this.handleExperimentEligibleFlow():this.handleExperimentNotEligibleFlow()})}handleExperimentEligibleFlow(){if(this.isAccountStatusFirstTimeBasicUser())return this._router.navigate([`${P.FW}/${P.Pm.COMPARE}`]),"route-compare";this.isAccountStatusFirstTimeFreetrialUser()&&this.reloadProfileSelect()}handleExperimentNotEligibleFlow(){const t=this._accountService.realSubscriptionStatus;if(t===c.qq.BASIC)return"show-dialog";this.isSubscriptionStatusEligibleForReload(t)&&this.reloadProfileSelect()}isSubscriptionStatusEligibleForReload(t){return t===c.qq.FREE_TRIAL||t===c.qq.SUBSCRIBED}showCelebrationAndStartProfileCreate(t){return(0,s.mG)(this,void 0,void 0,function*(){let e=M.P.NOTHING_TO_UNLIMITED;yield this._celebrationService.openAccountCelebrationFlow({source:n.EXPERIMENT_CONFIG.CELEBRATION_
1SOURCE,onCloseFunction:t,featureSetVersion:e})})}reloadProfileSelect(){return(0,s.mG)(this,void 0,void 0,function*(){const t=new URL(`${this.baseHref}${P.FW}/${P.Pm.PROFILE_SELECT}`,this._envService.url);window.location.href=t.href})}showTrialPostSignUpDialogOnLoad(){this._showTrialPostSignUpDialogOnLoad.next(!0)}setTrialPostSignUpTraitByAPI(){return(0,s.mG)(this,void 0,void 0,function*(){this._accountService.id&&this.postTrialPaymentExperimentValue&&(yield this._accountService.setAccountFreeTrialVariant(this.postTrialPaymentExperimentValue))&&(this.trialPostSignUpTrait=Number(this.postTrialPaymentExperimentValue),this._accountService.trialPostSignup=Number(this.postTrialPaymentExperimentValue))})}getTrialPostSignUpTrait(){return(0,s.mG)(this,void 0,void 0,function*(){return this._accountService.trialPostSignup&&(this.trialPostSignUpTrait=this._accountService.trialPostSignup),this._accountService.trialPostSignup})}refreshSubscriptionStatus(t=!1){return(0,s.mG)(this,void 0,void 0,function*(){t?yield this._subscriptionService.getSubscriptionStatusAndRedirectIfInvalid(!0):this._subscriptionService.getSubscriptionStatusAndRedirectIfInvalid(!0)})}getCountryCode(){return this._store.select(L.GP).pipe((0,a.h)(t=>Boolean(t)),(0,N.o)(t=>!("string"==typeof t&&t.trim().length>n.EXPERIMENT_CONFIG.MIN_COUNTRY_CODE_LENGTH),!0),(0,m.K)(t=>(0,o.of)(null)))}getNormalizedCountryCode(t){return t&&!this._blockedCountries.includes(t)?"US":null!=t?t:""}isCountryAllowedForExperiment(t){if(!t)return!1;const e=this._blockedCountries.map(u=>u.toLowerCase()),i=t.toLowerCase();return!e.includes(i)}createFlagsmithStateKey(t){return`${null==t?void 0:t.userBucketingMode}-${!!(null==t?void 0:t.flagsmithData)}`}isFlagsmithStateValid(t){return"ACCOUNT_ID"===(null==t?void 0:t.userBucketingMode)}handleFlagsmithError(t){return this.setExperimentValueToControl(),(0,o.of)(!1)}sendBigQueryLogs(){var t;const e=null===(t=this.postTrialPaymentExperimentValue)||void 0===t?void 0:t.toString();let i;i="NA"===e?"trial_post_signup_control":"-1"===e?"trial_post_signup_variant_value_negative_1":e&&Number(e)>n.EXPERIMENT_CONFIG.MIN_POSITIVE_VALUE?`trial_post_signup_variant_value_${e}`:"trial_post_signup_control",this._bigQueryService.log("trial_post_signup",{variant:i,value:e,country_code:this.countryCodeFromApi})}}return n.EXPERIMENT_CONFIG={FLAGSMITH_TIMEOUT_MS:1e4,MIN_COUNTRY_CODE_LENGTH:0,MIN_POSITIVE_VALUE:0,CELEBRATION_SOURCE:0,NUF_COMPLETE_FINISHED:1,NUF_COMPLETE_PENDING:0,WHITELIST_TRIAL_POST_SIGNUP_VALUE:"7"},n.\u0275fac=function(t){return new(t||n)(_.LFG(h.yh),_.LFG(f.B),_.LFG(C.CelebrationService),_.LFG(l.p),_.LFG(I.F),_.LFG(v.DJ),_.LFG(S.F0),_.LFG(g.mr))},n.\u0275prov=_.Yz7({token:n,factory:n.\u0275fac,providedIn:"root"}),n})()},87580:(V,O,r)=>{r.d(O,{V:()=>U});var s=r(96936),g=r(97885),c=r(41944),E=r(54987),P=r(27543),M=r(93945),A=r(1817);const L=(0,P.d)(a=>function(o=null){a(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=o});function U(a,d){const{first:o,each:T,with:D=F,scheduler:m=(null!=d?d:s.z),meta:N=null}=(0,g.q)(a)?{first:a}:"number"==typeof a?{each:a}:a;if(null==o&&null==T)throw new TypeError("No timeout provided.");return(0,c.e)((_,h)=>{let f,l,I=null,v=0;const C=S=>{l=(0,A.f)(h,m,()=>{try{f.unsubscribe(),(0,E.Xf)(D({meta:N,lastValue:I,seen:v})).subscribe(h)}catch(R){h.error(R)}},S)};f=_.subscribe((0,M.x)(h,S=>{null==l||l.unsubscribe(),v++,h.next(I=S),T>0&&C(T)},void 0,void 0,()=>{(null==l?void 0:l.closed)||null==l||l.unsubscribe(),I=null})),!v&&C(null!=o?"number"==typeof o?o:+o-m.now():T)})}function F(a){throw new L(a)}}}]);
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.