PageSourceSearch

https://www.getepic.com/default-src_app_core_services_limited-time-offer-promo_service_ts.746c253a494927fb.js

js getepic.com collected 2026-09-24 08:39:42 UTC 17,407 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkng_up=self.webpackChunkng_up||[]).push([["default-src_app_core_services_limited-time-offer-promo_service_ts"],{62410:(M,_,t)=>{t.d(_,{T:()=>l,y:()=>D});var D=(()=>{return(c=D||(D={})).KEEP_EPIC_UNLIMITED_CLICKED="FLAG_KEEP_EPIC_UNLIMITED_CLICKED",c.HAS_SEEN_FIRST_SESSION="HAS_SEEN_FIRST_SESSION",c.PROFILES_HAVE_SEEN_FIRST_SESSION="PROFILES_HAVE_SEEN_FIRST_SESSION",c.FFA_FIRST_BOOK_ID="FFA_FIRST_BOOK_ID",c.HAS_SEEN_FIRST_SESSION_EOB_UPSELL="HAS_SEEN_FIRST_SESSION_EOB_UPSELL",c.FLAG_HAS_SEEN_DEVICE_SETUP_DIALOG="FLAG_HAS_SEEN_DEVICE_SETUP_DIALOG",c.SHOW_FREE_TO_BASIC_TRANSITION_UPSELL="SHOW_FREE_TO_BASIC_TRANSITION_UPSELL",c.FLAG_HAS_ANSWERED_ASK_A_QUESTION_DIALOG="FLAG_HAS_ANSWERED_ASK_A_QUESTION_DIALOG",c.BUDDY_RECOMMENDED_BOOK_COUNT="BUDDY_RECOMMENDED_BOOK_COUNT",c.DATE_TRIGGERED_ONE_DOLLAR_PROMO="DATE_TRIGGERED_ONE_DOLLAR_PROMO",c.DATE_TRIGGERED_MARCH_PROMO="Date_6399_Promo_first_shown",c.DATE_TRIGGERED_BTS2022="DATE_TRIGGERED_BTS2022",c.HOLIDAY_12_DAYS_DATA="HOLIDAY_12_DAYS_DATA",c.WORD_OF_THE_WEEK="journal_word_of_week_",c.CLASS_LINKING_SKIP_COUNT="class_linking_skip_count",c.MONTHLY_SUB_RENEWAL_REMINDER_PREFERENCE="monthly_sub_renewal_reminder_preference",c.ANNUAL_UPSELL_ELIGIBILITY_LOGIN="annual_upsell_eligibility_login",D;var c})(),l=(()=>{return(c=l||(l={})).WEB="Stripe",c.ANDROID="Google Play",c.IOS="APPLE",l;var c})()},84762:(M,_,t)=>{t.d(_,{T:()=>N});var D=t(34929),l=t(62410),c=t(3184),A=t(65925);let N=(()=>{class E{constructor(e){this.dataService=e,this.flagsFromFFAToDisableForE2C=[l.y.HAS_SEEN_FIRST_SESSION,l.y.FLAG_HAS_SEEN_DEVICE_SETUP_DIALOG]}set(e,s){return this.dataService.post("WebAccount","setFlag",{flag:e,value:s}).then(S=>{})}setFlags(e){return this.dataService.post("WebAccount","setFlags",{flagsAndValues:JSON.stringify(e)}).then(s=>{})}get(e,s){return this.dataService.get("WebAccount","getFlag",{flag:e,defaultValue:s}).then(S=>S.result.value)}setKeepEpicUnlimitedClicked(){return this.set(l.y.KEEP_EPIC_UNLIMITED_CLICKED,1)}hasKeepEpicUnlimitedBeenClicked(){return this.get(l.y.KEEP_EPIC_UNLIMITED_CLICKED,0).then(e=>!!parseInt(e))}setHasSeenFirstSession(e=1){return this.set(l.y.HAS_SEEN_FIRST_SESSION,e)}getHasSeenFirstSession(){return this.get(l.y.HAS_SEEN_FIRST_SESSION,0).then(e=>parseInt(e))}_getProfilesHaveSeenFirstSession(){return(0,D.mG)(this,void 0,void 0,function*(){const e=yield this.get(l.y.PROFILES_HAVE_SEEN_FIRST_SESSION,0);return JSON.parse(e)})}getProfileHasSeenFirstSession(e){return(0,D.mG)(this,void 0,void 0,function*(){const s=yield this._getProfilesHaveSeenFirstSession();return(null==s?void 0:s[e.id])||0})}setProfileHasSeenFirstSession(e){return(0,D.mG)(this,void 0,void 0,function*(){let s=(yield this._getProfilesHaveSeenFirstSession())||{};s[e.id]=1,yield this.set(l.y.PROFILES_HAVE_SEEN_FIRST_SESSION,JSON.stringify(s))})}setFFAFlagsForE2C(){let e={};return this.flagsFromFFAToDisableForE2C.forEach(s=>{e[s]=1}),this.setFlags(e)}setFirstBookId(e){return this.set(l.y.FFA_FIRST_BOOK_ID,e)}getFirstBookId(){return this.get(l.y.FFA_FIRST_BOOK_ID).then(e=>e?parseInt(e):void 0)}getDateTriggeredLimitedTimeOfferPromo(e){return this.get(e).then(s=>s?parseInt(s):void 0)}setDateTriggeredLimitedTimeOfferPromo(e,s){return this.set(s,e)}getWordOfTheWeek(e){return this.get(`${l.y.WORD_OF_THE_WEEK}${e}`).then(S=>"undefined"!==S?JSON.parse(S):void 0)}setWordOfTheWeek(e,s,S,h){const C=JSON.stringify({dateGenerated:s,word:S,bookId:h}).trim();return this.set(`${l.y.WORD_OF_THE_WEEK}${e}`,C)}getClassLinkingSkipCount(){return this.get(l.y.CLASS_LINKING_SKIP_COUNT).then(e=>e?parseInt(e):0)}setClassLinkingSkipCount(e){this.set(l.y.CLASS_LINKING_SKIP_COUNT,e.toString())}getAnnualUpsellEligibility(){return this.get(l.y.ANNUAL_UPSELL_ELIGIBILITY_LOGIN).then(e=>"undefined"!==e?JSON.parse(e):void 0)}setAnnualUpsellEligibility(e){this.set(l.y.ANNUAL_UPSELL_ELIGIBILITY_LOGIN,JSON.stringify(e))}}return E.\u0275fac=function(e){return new(e||E)(c.LFG(A.D))},E.\u0275prov=c.Yz7({token:E,factory:E.\u0275fac,providedIn:"root"}),E})()},72045:(M,_,t)=>{t.d(_,{X:()=>Te,m:()=>T});var D=t(34929),l=t(54189),c=t(93395),A=t(76317),N=t(50253),E=t(17714),P=t(28653),e=t(62410),s=t(73398),S=t(26966),h=t(18325),G=t(78179),C=t(56610),y=t(15117),$=t(69360),v=t(31170),U=/(\w)\1*|''|'(''|[^'])+('|$)|./g,j=/^'([^]*?)'?$/,V=/''/g,w=/[a-zA-Z]/;function Z(a,m){(0,v.Z)(2,arguments);var r=String(m),o=(0,h.Z)(a);if(!(0,y.Z)(o))throw new RangeError("Invalid time value");var i=(0,C.Z)(o),n=(0,$.Z)(o,i),f=r.match(U).map(function(u){if("''"===u)return"'";var d=u[0];if("'"===d)return J(u);var g=G.Z[d];if(g)return g(n,u,null,{});
1if(d.match(w))throw new RangeError("Format string contains an unescaped latin alphabet character `"+d+"`");return u}).join("");return f}function J(a){return a.match(j)[1].replace(V,"'")}var b=t(69377);function z(a,m){(0,v.Z)(2,arguments);var r=(0,b.Z)(a),o=(0,b.Z)(m);return r.getTime()===o.getTime()}var I=t(67367),Q=t(79672),k=36e5,K=t(66579);function ee(a,m){(0,v.Z)(2,arguments);var r=(0,h.Z)(a),o=(0,h.Z)(m);return r.getFullYear()-o.getFullYear()}function te(a,m){(0,v.Z)(2,arguments);var r=(0,h.Z)(a),o=(0,h.Z)(m),i=(0,K.Z)(r,o),n=Math.abs(ee(r,o));r.setFullYear("1584"),o.setFullYear("1584");var f=(0,K.Z)(r,o)===-i,u=i*(n-f);return 0===u?0:u}var re=t(79001),ie=t(8210),oe=t(99805),ae=t(90371),se=t(77860),ne=t(20312);function B(a,m){(0,v.Z)(2,arguments);var r=(0,I.Z)(m);return(0,ne.Z)(a,-r)}var me=t(88053);function ce(a,m){(0,v.Z)(2,arguments);var r=(0,I.Z)(m);return(0,me.Z)(a,-r)}function R(a,m){if((0,v.Z)(2,arguments),!m||"object"!=typeof m)return new Date(NaN);var r="years"in m?(0,I.Z)(m.years):0,o="months"in m?(0,I.Z)(m.months):0,i="weeks"in m?(0,I.Z)(m.weeks):0,n="days"in m?(0,I.Z)(m.days):0,f="hours"in m?(0,I.Z)(m.hours):0,u="minutes"in m?(0,I.Z)(m.minutes):0,d="seconds"in m?(0,I.Z)(m.seconds):0,g=ce((0,h.Z)(a),o+12*r),L=B(g,n+7*i),F=u+60*f,x=d+60*F,Ee=1e3*x,Pe=new Date(L.getTime()-Ee);return Pe}function H(a){var m=a.start,r=a.end;(0,v.Z)(1,arguments);var o=(0,h.Z)(m),i=(0,h.Z)(r);if(!(0,y.Z)(o))throw new RangeError("Start Date is invalid");if(!(0,y.Z)(i))throw new RangeError("End Date is invalid");var n={years:0,months:0,days:0,hours:0,minutes:0,seconds:0},f=(0,K.Z)(o,i);n.years=Math.abs(te(o,i));var u=R(o,{years:f*n.years});n.months=Math.abs((0,re.Z)(u,i));var d=R(u,{months:f*n.months});n.days=Math.abs((0,ie.Z)(d,i));var g=R(d,{days:f*n.days});n.hours=Math.abs((0,oe.Z)(g,i));var L=R(g,{hours:f*n.hours});n.minutes=Math.abs((0,ae.Z)(L,i));var F=R(L,{minutes:f*n.minutes});return n.seconds=Math.abs((0,se.Z)(F,i)),n}var W=t(3560),Y=t(25431),p=t(46845),O=t(3184),de=t(77902),fe=t(64617),ue=t(84762),Se=t(43525),ge=t(11105),De=t(1146),he=t(41752),Oe=t(95862),ve=t(98476),T=(()=>{return(a=T||(T={})).CONTROL="CONTROL",a.ONE_DOLLAR="ONE_DOLLAR",a.NATIONAL_READING_MONTH="NATIONAL_READING_MONTH",a.BTS2022="BTS2022",T;var a})();let Te=(()=>{class a{constructor(r,o,i,n,f,u,d,g,L,F,x){this._sessionStorageService=r,this._localStorageService=o,this._accountFlagsService=i,this._subscriptionService=n,this._explorePageObstructionService=f,this._experienceService=u,this._accountService=d,this._envService=g,this._promoInitService=L,this._localeService=F,this._bq=x,this.limitedTimeOfferPromoInitialized$=new A.X(!1),this.shouldSeeLimitedTimeOfferPromo=!1,this.limitedTimeOfferPromoExpired$=new N.x,this.limitedTimeOfferPromoRemainingDuration$=new A.X({hours:0,minutes:0,seconds:0}),this.limitedTimeOfferPromoActive=T.CONTROL,this._nrmpParameterData={promoDays:3,minAccountAgeDays:7,accountFlagDateTriggered:e.y.DATE_TRIGGERED_MARCH_PROMO,minAccountCreateDate:new Date(2021,2,1),devToolsConsolePrefix:"[NRMP]",devToolsLocalStorageKey:this._sessionStorageService.KEYS.NRMP_DEV_TOOLS,exploreLastSeenLocalStorageKey:s.X5,obstructionName:c.m.NATIONAL_READING_MONTH,upsellPromoDialogName:s.rP.NATIONAL_READING_MONTH,audioVoiceoverTypeDialogName:l.Wj.NATIONAL_READING_MONTH_PROMO},this._odpParameterData={promoDays:3,minAccountAgeDays:14,accountFlagDateTriggered:e.y.DATE_TRIGGERED_ONE_DOLLAR_PROMO,minAccountCreateDate:new Date(2021,2,1),devToolsConsolePrefix:"[ODP]",devToolsLocalStorageKey:this._sessionStorageService.KEYS.ODP_DEV_TOOLS,exploreLastSeenLocalStorageKey:s.uG,obstructionName:c.m.ONE_DOLLAR_PROMO,upsellPromoDialogName:s.rP.ONE_DOLLAR_PROMO,audioVoiceoverTypeDialogName:l.Wj.ONE_DOLLAR_PROMO},this._bts2022ParameterData={minAccountAgeDays:0,accountFlagDateTriggered:e.y.DATE_TRIGGERED_BTS2022,devToolsConsolePrefix:"[BTS2022]",devToolsLocalStorageKey:this._sessionStorageService.KEYS.BTS2022_DEV_TOOLS,exploreLastSeenLocalStorageKey:s.Lw,obstructionName:c.m.BTS2022,upsellPromoDialogName:s.rP.BTS2022,audioVoiceoverTypeDialogName:l.Wj.BTS2022},this._defaultLimitedTimeOfferPromoFlagState={oneDollarPromoEnabled:!0,nationalReadingMonthPromoEnabled:!1,bts2022PromoEnabled:!1},this.limitedTimeOfferPromoParameterData=this._bts2022ParameterData,this._subscriptions=new E.w0}ngOnDestroy(){this._subscriptions.unsubscribe()}initLimitedTimeOfferPromoOffer(){return(0,D.mG)(this,void 0,void 0,function*(){const r=yield this._initPromoFeatureFlagStates();if(this.shouldSeeLimitedTimeOfferPromo=r&&(yield this._initShouldSeeLimitedTimeOfferPromo()),this.limitedTimeOfferPromoInitialized$.next(!0),!this.shouldSeeLimitedTimeOfferPromo)return void this.removeLimitedTimeOfferPromoModal();let o;this.limitedTimeOfferPromoParameterData.promoDays&&(o=yield this._limitedTimeOfferPromoCalculateTimeRemaining(this.limitedTimeOfferPromoParameterData.promoDays));const i=this._subscriptionService.subscriptionUpgraded$.subscribe(()=>{this._endPromo(o)});this._subscriptions.add(i);const n=this.limitedTimeOfferPromoExpired$.subscribe(()=>{this._endPromo(o)});this._subscriptions.add(n)})}removeLimitedTimeOfferPromoModal(){this._localStorageService.get(s.rg)===this.limitedTimeOfferPromoParameterData.upsellPromoDialogName&&this._localStorageService.remove(s.rg)}isOneDollarPromo(){return this.shouldSeeLimitedTimeOfferPromo&&this.limitedTimeOfferPromoActive===T.ONE_DOLLAR}isNationalReadingMonthPromo(){return this.shouldSeeLimitedTimeOfferPromo&&this.limitedTimeOfferPromoActive===T.NATIONAL_READING_MONTH}isBts2022Promo(){return this.shouldSeeLimitedTimeOfferPromo&&this.limitedTimeOfferPromoActive===T.BTS2022}_endPromo(r){this.removeLimitedTimeOfferPromoModal(),this.shouldSeeLimitedTimeOfferPromo=!1,null==r||r.unsubscribe()}_initShouldSeeLimitedTimeOfferPromo(){return(0,D.mG)(this,void 0,void 0,function*(){const i=(d,...g)=>{console.log(`${this.limitedTimeOfferPromoParameterData.devToolsConsolePrefix}: ${d}`,g)},n=(d,g="Failed to initialize promo!")=>{i(g,d)};if(this._localeService.isIndia())return n("Locale was India.","Did not initialize promo due to invali
1d locale!"),!1;if(!this._experienceService.isFFAFree()||!this._accountService.createdTS)return!1;let f=this._accountService.dateCreated;if(!this._envService.prodMode){const d=this._initLimitedTimeOfferPromoDevTools();f=d.accountCreateDate?new Date(d.accountCreateDate):f}const u=(0,S.j1)(new Date,f,S.a_.DAYS,!0);if(u<this.limitedTimeOfferPromoParameterData.minAccountAgeDays)return n(`Account age must be older than ${this.limitedTimeOfferPromoParameterData.minAccountAgeDays} days. Found: ${u}`),!1;if(this.limitedTimeOfferPromoParameterData.minAccountCreateDate&&f<this.limitedTimeOfferPromoParameterData.minAccountCreateDate)return n(`Account must have been created on or after ${Z(this.limitedTimeOfferPromoParameterData.minAccountCreateDate,"yyyy-MM-dd")}. Found: ${Z(f,"yyyy-MM-dd")}`),!1;if(i(`Not restricting promo by account create date. Account created on ${f}.`),this.limitedTimeOfferPromoParameterData.promoDays){const d=yield this._accountFlagsService.getDateTriggeredLimitedTimeOfferPromo(this.limitedTimeOfferPromoParameterData.accountFlagDateTriggered);if(d){const L=(0,S.j1)(new Date,new Date(d),S.a_.DAYS)>=this.limitedTimeOfferPromoParameterData.promoDays;return L&&n("Promo has ended"),!L}this._accountFlagsService.setDateTriggeredLimitedTimeOfferPromo(Date.now(),this.limitedTimeOfferPromoParameterData.accountFlagDateTriggered)}else i("Promo has no expiry after initial offer.");return!0})}setLimitedTimeOfferPromoPopupModal(){const r=this.limitedTimeOfferPromoParameterData.exploreLastSeenLocalStorageKey,o=this._accountService.getObfuscatedAccountId().toString(),i=this._localStorageService.get(r.concat(o));(function X(a){return(0,v.Z)(1,arguments),z(a,Date.now())})(new Date(i))||(this._explorePageObstructionService.addObstruction(this.limitedTimeOfferPromoParameterData.obstructionName),this._localStorageService.set(s.rg,this.limitedTimeOfferPromoParameterData.upsellPromoDialogName))}getPromoBqValue(){return this.isBts2022Promo()?p.mc:this.isNationalReadingMonthPromo()?p.Pc:this.isOneDollarPromo()?p.gf:p.w5}getAnnualBtsE2COrD2CProductId(r){return r?W.PRODUCT_IDS.YEARLY_INTRO_5999_RECURRING_7999_E2C:W.PRODUCT_IDS.YEARLY_INTRO_5999_RECURRING_7999_D2C}_limitedTimeOfferPromoCalculateTimeRemaining(r){return(0,D.mG)(this,void 0,void 0,function*(){let o=yield this._accountFlagsService.getDateTriggeredLimitedTimeOfferPromo(this.limitedTimeOfferPromoParameterData.accountFlagDateTriggered);o||(o=Date.now(),this._accountFlagsService.setDateTriggeredLimitedTimeOfferPromo(o,this.limitedTimeOfferPromoParameterData.accountFlagDateTriggered));const n=function q(a,m){(0,v.Z)(2,arguments);var r=(0,I.Z)(m);return(0,Q.Z)(a,r*k)}(new Date(o),24*r),f=H({start:new Date,end:n});this.limitedTimeOfferPromoRemainingDuration$.next(f);const u=(0,P.F)(1e3).subscribe(()=>{if(new Date>=n)return this.limitedTimeOfferPromoRemainingDuration$.next({hours:0,minutes:0,seconds:0}),this.limitedTimeOfferPromoExpired$.next(),void u.unsubscribe();const g=H({start:new Date,end:n});this.limitedTimeOfferPromoRemainingDuration$.next(g)});return this._subscriptions.add(u),u})}_initLimitedTimeOfferPromoDevTools(){let r=this._sessionStorageService.getSessionStorageWithKey(this.limitedTimeOfferPromoParameterData.devToolsLocalStorageKey);const o=(i,...n)=>{console.log(`${i}`,n)};if(r)try{r=JSON.parse(r)}catch(i){console.error(`Failed to parse ltopDevTools saved to session: ${r}`)}else r={};return window.LimitedTimeOfferPromo={setAccountCreateDate:i=>{r.accountCreateDate=new Date(i).toJSON(),this._sessionStorageService.setSessionStorageWithKey(this.limitedTimeOfferPromoParameterData.devToolsLocalStorageKey,JSON.stringify(r))},setTriggerDate:i=>(0,D.mG)(this,void 0,void 0,function*(){(function le(a){return(0,v.Z)(1,arguments),a instanceof Date||"object"==typeof a&&"[object Date]"===Object.prototype.toString.call(a)})(i)||(i=new Date(i)),o("Setting trigger date"),yield this._accountFlagsService.setDateTriggeredLimitedTimeOfferPromo(i.valueOf(),this.limitedTimeOfferPromoParameterData.accountFlagDateTriggered),o(`Trigger date set to ${i}`)}),getTriggerDate:()=>(0,D.mG)(this,void 0,void 0,function*(){o("Getting trigger date!"),o("Trigger date:",new Date(yield this._accountFlagsService.getDateTriggeredLimitedTimeOfferPromo(this.limitedTimeOfferPromoParameterData.accountFlagDateTriggered)))}),resetExploreModal:()=>{const i=this.limitedTimeOfferPromoParameterData.exploreLastSeenLocalStorageKey,n=this._accountService.getObfuscatedAccountId().toString();this._localStorageService.remove(i.concat(n))},help:`\n    [Promo Rules]\n        1. Account must be older than 14 days (7 for Reading Week)\n        2. Account create date must be at least Mar 1, 2021\n        3. Promo expires 72 hours after it is triggered (no expiry if no promoDays)\n\n    [Enable Promo]:\n        // Set accountCreateDate to date string that's > 14 days ago\n        LimitedTimeOfferPromo.setAccountCreateDate('2021-10-03')\n    \n    [Disable Promo]:\n        // Set accountCreateDate to date string that's <= 14 days ago\n        LimitedTimeOfferPromo.setAccountCreateDate('${Z(B(new Date,2),"yyyy-MM-dd")}')\n\n    [Change start date of promo]:\n        // Set trigger date to adjust when the promo started for this account\n        LimitedTimeOfferPromo.setTriggerDate('2021-10-18T14:33:07')\n\n    [Re-en
1able Explore modal]:\n        // Explore modal only shows once per day of the promo. Run to re-enable it for today\n        LimitedTimeOfferPromo.resetExploreModal()\n        `},r}_initPromoFeatureFlagStates(){var r;return(0,D.mG)(this,void 0,void 0,function*(){if(yield null===(r=this._promoInitService)||void 0===r?void 0:r.isPromoActive(Y.l.BTS_2022))return this.limitedTimeOfferPromoActive=T.BTS2022,this.limitedTimeOfferPromoParameterData=this._bts2022ParameterData,!0;try{if(this._defaultLimitedTimeOfferPromoFlagState.nationalReadingMonthPromoEnabled)return this.limitedTimeOfferPromoActive=T.NATIONAL_READING_MONTH,this.limitedTimeOfferPromoParameterData=this._nrmpParameterData,!0}catch(i){console.error(`Likely malformed JSON: ${i}`)}return this.limitedTimeOfferPromoActive=T.CONTROL,!1})}}return a.\u0275fac=function(r){return new(r||a)(O.LFG(de.u),O.LFG(fe.n),O.LFG(ue.T),O.LFG(Se.F),O.LFG(c.x),O.LFG(ge.DT),O.LFG(De.B),O.LFG(he.DJ),O.LFG(Y.O),O.LFG(Oe.O),O.LFG(ve.p))},a.\u0275prov=O.Yz7({token:a,factory:a.\u0275fac,providedIn:"root"}),a})()},88053:(M,_,t)=>{t.d(_,{Z:()=>A});var D=t(67367),l=t(18325),c=t(31170);function A(N,E){(0,c.Z)(2,arguments);var P=(0,l.Z)(N),e=(0,D.Z)(E);if(isNaN(e))return new Date(NaN);if(!e)return P;var s=P.getDate(),S=new Date(P.getTime());S.setMonth(P.getMonth()+e+1,0);var h=S.getDate();return s>=h?S:(P.setFullYear(S.getFullYear(),S.getMonth(),s),P)}}}]);

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.