@guardian/support-dotcom-components 3.2.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/dotcom/requests.d.ts +10 -9
- package/dist/dotcom/requests.d.ts.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/shared/types/abTests/banner.d.ts +23 -3
- package/dist/shared/types/abTests/banner.d.ts.map +1 -1
- package/dist/shared/types/abTests/epic.d.ts +23 -3
- package/dist/shared/types/abTests/epic.d.ts.map +1 -1
- package/dist/shared/types/abTests/gutter.d.ts +409 -0
- package/dist/shared/types/abTests/gutter.d.ts.map +1 -0
- package/dist/shared/types/abTests/header.d.ts +23 -3
- package/dist/shared/types/abTests/header.d.ts.map +1 -1
- package/dist/shared/types/abTests/index.d.ts +1 -0
- package/dist/shared/types/abTests/index.d.ts.map +1 -1
- package/dist/shared/types/abTests/shared.d.ts +39 -4
- package/dist/shared/types/abTests/shared.d.ts.map +1 -1
- package/dist/shared/types/props/gutter.d.ts +251 -0
- package/dist/shared/types/props/gutter.d.ts.map +1 -0
- package/dist/shared/types/props/index.d.ts +1 -0
- package/dist/shared/types/props/index.d.ts.map +1 -1
- package/dist/shared/types/targeting/epic.d.ts +2 -1
- package/dist/shared/types/targeting/epic.d.ts.map +1 -1
- package/dist/shared/types/targeting/gutter.d.ts +14 -0
- package/dist/shared/types/targeting/gutter.d.ts.map +1 -0
- package/dist/shared/types/targeting/index.d.ts +1 -0
- package/dist/shared/types/targeting/index.d.ts.map +1 -1
- package/package.json +25 -26
package/README.md
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
|
|
3
3
|
Consists of:
|
|
4
4
|
|
|
5
|
-
1. A Node.js server for serving marketing messages to theguardian.com ([dotcom-rendering](https://github.com/guardian/dotcom-rendering/)).
|
|
5
|
+
1. A Node.js server for serving marketing messages to theguardian.com ([dotcom-rendering](https://github.com/guardian/dotcom-rendering/)). Documentation can be found in the [./docs](./docs/) directory.
|
|
6
6
|
2. An npm package with types and logic for use by dotcom-rendering.
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { BannerPayload, EpicPayload, HeaderPayload } from '../shared/types';
|
|
1
|
+
import { BannerPayload, BannerProps, EpicPayload, EpicProps, HeaderPayload, HeaderProps, GutterPayload, GutterProps } from '../shared/types';
|
|
2
2
|
import { TestTracking } from '../shared/types/abTests/shared';
|
|
3
|
-
export interface ModuleData {
|
|
3
|
+
export interface ModuleData<PROPS> {
|
|
4
4
|
name: string;
|
|
5
|
-
props:
|
|
5
|
+
props: PROPS;
|
|
6
6
|
}
|
|
7
|
-
export interface ModuleDataResponse {
|
|
7
|
+
export interface ModuleDataResponse<PROPS> {
|
|
8
8
|
data?: {
|
|
9
|
-
module: ModuleData
|
|
9
|
+
module: ModuleData<PROPS>;
|
|
10
10
|
meta: TestTracking;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
export declare const getEpic: (baseUrl: string, payload: EpicPayload) => Promise<ModuleDataResponse
|
|
14
|
-
export declare const getLiveblogEpic: (baseUrl: string, payload: EpicPayload) => Promise<ModuleDataResponse
|
|
15
|
-
export declare const getBanner: (baseUrl: string, payload: BannerPayload) => Promise<ModuleDataResponse
|
|
16
|
-
export declare const
|
|
13
|
+
export declare const getEpic: (baseUrl: string, payload: EpicPayload) => Promise<ModuleDataResponse<EpicProps>>;
|
|
14
|
+
export declare const getLiveblogEpic: (baseUrl: string, payload: EpicPayload) => Promise<ModuleDataResponse<EpicProps>>;
|
|
15
|
+
export declare const getBanner: (baseUrl: string, payload: BannerPayload) => Promise<ModuleDataResponse<BannerProps>>;
|
|
16
|
+
export declare const getGutterLiveblog: (baseUrl: string, payload: GutterPayload) => Promise<ModuleDataResponse<GutterProps>>;
|
|
17
|
+
export declare const getHeader: (baseUrl: string, payload: HeaderPayload) => Promise<ModuleDataResponse<HeaderProps>>;
|
|
17
18
|
//# sourceMappingURL=requests.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../src/dotcom/requests.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"requests.d.ts","sourceRoot":"","sources":["../../src/dotcom/requests.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EACb,WAAW,EACX,WAAW,EACX,SAAS,EACT,aAAa,EACb,WAAW,EACX,aAAa,EACb,WAAW,EACd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE9D,MAAM,WAAW,UAAU,CAAC,KAAK;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB,CAAC,KAAK;IACrC,IAAI,CAAC,EAAE;QACH,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,EAAE,YAAY,CAAC;KACtB,CAAC;CACL;AA4CD,eAAO,MAAM,OAAO,YACP,MAAM,WACN,WAAW,KACrB,QAAQ,mBAAmB,SAAS,CAAC,CAA4C,CAAC;AAErF,eAAO,MAAM,eAAe,YACf,MAAM,WACN,WAAW,KACrB,QAAQ,mBAAmB,SAAS,CAAC,CAAqD,CAAC;AAE9F,eAAO,MAAM,SAAS,YACT,MAAM,WACN,aAAa,KACvB,QAAQ,mBAAmB,WAAW,CAAC,CAA8C,CAAC;AAEzF,eAAO,MAAM,iBAAiB,YACjB,MAAM,WACN,aAAa,KACvB,QAAQ,mBAAmB,WAAW,CAAC,CAAuD,CAAC;AAElG,eAAO,MAAM,SAAS,YACT,MAAM,WACN,aAAa,KACvB,QAAQ,mBAAmB,WAAW,CAAC,CAA8C,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as e}from"zod";const n="gu.contributions.views",t=e=>e.get(n)||void 0,a=e=>{const t=localStorage.getItem(n),a=t?JSON.parse(t).value:[];a.push({date:(new Date).getTime(),testId:e});const i={value:a.slice(-50)};localStorage.setItem(n,JSON.stringify(i))},i="gu.history.weeklyArticleCount",o="gu.history.articleCountsThisWeek",r=e=>{const n=e.getDay()||7;return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()-(n-1))/864e5},s=e=>e.get(i)||void 0,l=new Set(["environment/climate-change","environment/climate-crisis","environment/environment","science/science","politics/politics","us-news/us-politics","australia-news/australian-politics","world/world","world/europe-news","world/russia","books/books","culture/culture","world/coronavirus-outbreak","world/race","inequality/inequality","technology/technology","business/business","tone/recipes","sport/sport","football/football","sport/olympic-games","sport/olympic-games-2024","tracking/commissioningdesk/uk-investigations"]),u=(e,n={})=>(e.forEach((e=>{l.has(e)&&(n[e]=(n[e]??0)+1)})),n),c=(e,n,t)=>{const a=((e,n)=>{const t=r(new Date),a=e.get(o);if(a&&a.week===t){const i=a.articles[n]||0;return e.set(o,{week:t,articles:{...a.articles,[n]:i+1}}),i>0}return e.set(o,{week:t,articles:{[n]:1}}),!1})(e,n);if(!a){const n=r(new Date),a=e.get(i)||[],o=a[0];if(o&&o.week&&o.week===n)o.count+=1,o.tags=u(t,o.tags),e.set(i,a);else{a.unshift({week:n,count:1,tags:u(t,{})});const o=n-365,r=a.filter((e=>e.week>=o));e.set(i,r)}}},d=["GBPCountries","UnitedStates","AUDCountries","EURCountries","International","NZDCountries","Canada"],g=e.enum(d),m={GBPCountries:{name:"United Kingdom",currency:"GBP",countries:["GB","FK","GI","GG","IM","JE","SH"],supportRegionId:"UK"},UnitedStates:{name:"United States",currency:"USD",countries:["US"],supportRegionId:"US"},AUDCountries:{name:"Australia",currency:"AUD",countries:["AU","KI","NR","NF","TV"],supportRegionId:"AU"},EURCountries:{name:"Europe",currency:"EUR",countries:["AD","AL","AT","BA","BE","BG","BL","CH","CY","CZ","DE","DK","EE","ES","FI","FO","FR","GF","GL","GP","GR","HR","HU","IE","IT","LI","LT","LU","LV","MC","ME","MF","IS","MQ","MT","NL","NO","PF","PL","PM","PT","RE","RO","RS","SE","SI","SJ","SK","SM","TF","TR","WF","YT","VA","AX","AZ","AM","GE","BY","MD","UA","MK"],supportRegionId:"EU"},International:{name:"International",currency:"USD",countries:["AE","AF","AG","AI","AO","AQ","AR","AS","AW","BB","BD","BF","BH","BI","BJ","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BZ","CC","CD","CF","CG","CI","CL","CM","CN","CO","CR","CU","CV","CW","CX","DJ","DM","DO","DZ","EC","EG","EH","ER","ET","FJ","FM","GA","GD","GH","GM","GN","GQ","GS","GT","GU","GW","GY","HK","HM","HN","HT","ID","IL","IN","IO","IQ","IR","JM","JO","JP","KE","KG","KH","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LK","LR","LS","LY","MA","MG","MH","ML","MM","MN","MO","MP","MR","MS","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NG","NI","NP","NU","OM","PA","PE","PG","PH","PK","PN","PR","PS","PW","PY","QA","RU","RW","SA","SB","SC","SD","SG","SL","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TG","TH","TJ","TK","TL","TM","TN","TO","TT","TW","TZ","UG","UM","UY","UZ","VC","VE","VG","VI","VN","VU","WS","YE","ZA","ZM","ZW"],supportRegionId:"INT"},NZDCountries:{name:"New Zealand",currency:"NZD",countries:["NZ","CK"],supportRegionId:"NZ"},Canada:{name:"Canada",currency:"CAD",countries:["CA"],supportRegionId:"CA"}},p={AD:"Andorra",AE:"the UAE",AF:"Afghanistan",AG:"Antigua and Barbuda",AI:"Anguilla",AL:"Albania",AM:"Armenia",AO:"Angola",AR:"Argentina",AS:"the US",AT:"Austria",AU:"Australia",AW:"Aruba",AX:"Åland Islands",AZ:"Azerbaijan",BA:"Bosnia and Herzegovina",BB:"Barbados",BD:"Bangladesh",BE:"Belgium",BF:"Burkina Faso",BG:"Bulgaria",BH:"Bahrain",BI:"Burundi",BJ:"Benin",BL:"Saint Barthélemy",BM:"Bermuda",BN:"Brunei Darussalam",BO:"Bolivia",BQ:"Bonaire, Sint Eustatius and Saba",BR:"Brazil",BS:"the Bahamas",BT:"Bhutan",BV:"Bouvet Island",BW:"Botswana",BY:"Belarus",BZ:"Belize",CA:"Canada",CD:"the Democratic Republic of the Congo",CF:"the Central Africa Republic",CG:"the Congo",CH:"Switzerland",CI:"Côte d'Ivoire",CK:"the Cook Islands",CL:"Chile",CM:"Cameroon",CN:"China",CO:"Colombia",CR:"Costa Rica",CU:"Cuba",CV:"Cabo Verde",CW:"Curaçao",CX:"Christmas Island",CY:"Cyprus",CZ:"the Czech Republic",DE:"Germany",DJ:"Djibouti",DK:"Denmark",DM:"Dominica",DO:"the Dominican Republic",DZ:"Algeria",EC:"Ecuador",EE:"Estonia",EG:"Egypt",EH:"the Western Sahara",ER:"Eritrea",ES:"Spain",ET:"Ethiopia",FI:"Finland",FJ:"Fiji",FK:"the UK",FO:"the UK",FR:"France",GA:"Gabon",GB:"the UK",GD:"Grenada",GE:"Georgia",GF:"French Guiana",GG:"Guernsey",GH:"Ghana",GI:"Gibraltar",GL:"Greenland",GM:"the Gambia",GN:"Guinea",GP:"Guadeloupe",GQ:"Equatorial Guinea",GR:"Greece",GT:"Guatemala",GU:"Guam",GW:"Guinea-Bissau",GY:"Guyana",HK:"Hong Kong",HN:"Honduras",HR:"Croatia",HT:"Haiti",HU:"Hungary",ID:"Indonesia",IE:"Ireland",IM:"the Isle of Man",IN:"India",IQ:"Iraq",IR:"Iran",IS:"Iceland",IT:"Italy",JE:"Jersey",JM:"Jamaica",JO:"Jordan",JP:"Japan",KE:"Kenya",KG:"Kyrgyzstan",KH:"Cambodia",KI:"Kiribati",KN:"Saint Kitts and Nevis",KP:"Korea",KR:"Korea",KW:"Kuwait",KY:"the Cayman Ialnds",KZ:"Kazakhstan",LB:"Lebanon",LC:"Saint Lucia",LI:"Liechtenstein",LK:"Sri Lanka",LR:"Liberia",LS:"Lesotho",LT:"Lithuania",LU:"Luxembourg",LV:"Latvia",LY:"Libya",MA:"Morocco",MC:"Monaco",MD:"Moldova",ME:"Montenegro",MG:"Madagascar",MK:"the Republic of North Macedonia",ML:"Mali",MM:"Myanmar",MN:"Mongolia",MO:"Macao",MQ:"Martinique",MR:"Mauritania",MS:"Montserrat",MT:"Malta",MU:"Mauritius",MV:"Maldives",MW:"Malawi",MX:"Mexico",MY:"Malaysia",MZ:"Mozambique",NA:"Namibia",NC:"New Caledonia",NE:"Niger",NF:"Norfolk Island",NG:"Nigeria",NI:"Nicaragua",NL:"the Netherlands",NO:"Norway",NP:"Nepal",NR:"Nauru",NU:"Niue",NZ:"New Zealand",OM:"Oman",PA:"Panama",PE:"Peru",PF:"French Polynesia",PG:"Papua New Guinea",PH:"the Philippines",PK:"Pakistan",PL:"Poland",PM:"Saint Pierre and Miquelon",PN:"Pitcairn",PR:"Puerto Rico",PT:"Portugal",PW:"Palau",PY:"Paraguay",QA:"Qatar",RE:"Réunion",RO:"Romania",RU:"Russia",RW:"Rwanda",SA:"Saudi Arabia",SB:"Solomon Islands",SC:"Seychelles",SD:"Sudan",SE:"Sweden",SG:"Singapore",SH:"Saint Helena",SI:"Slovenia",SJ:"Svalbard and Jan Mayen",SK:"Slovakia",SL:"Sierra Leone",SM:"San Marino",SN:"Senegal",SO:"Somalia",SR:"Suriname",SS:"South Sudan",ST:"Sao Tome and Principe",SV:"El Salvador",SY:"Syrian Arab Republic",SZ:"Eswatini",TD:"Chad",TG:"Togo",TH:"Thailand",TJ:"Tajikistan",TK:"Tokelau",TL:"Timor-Leste",TM:"Turkmenistan",TN:"Tunisia",TO:"Tonga",TR:"Turkey",TT:"Trinidad and Tobago",TV:"Tuvalu",TW:"Taiwan",TZ:"Tanzania ",UG:"Uganda",US:"the US",UY:"Uruguay",UZ:"Uzbekistan",VC:"Saint Vincent and the Grenadines",VE:"Venezuela",VG:"the Virgin Islands",VI:"the Virgin Islands",VN:"Vietnam",VU:"Vanuatu",WF:"Wallis and Futuna",WS:"Samoa",YE:"Yemen",YT:"Mayotte",ZA:"South Africa",ZM:"Zambia",ZW:"Zimbabwe"},C={GBPCountries:"£",UnitedStates:"$",AUDCountries:"$",Canada:"CA$",EURCountries:"€",NZDCountries:"NZ$",International:"$"},b=e=>Object.keys(m).find((n=>m[n].countries.includes(e??"")))||"International",S=(e,n=[])=>0===n.length||!!e&&n.includes(b(e.toUpperCase())),h=e=>{if(e){const n=b(e);return C[n]}return"£"},y=e=>{if(e)return p[e]},A=e=>/subscribe\/weekly\/checkout/.test(e),T=(e,n)=>{if(n){const t=(e=>m[b(e)]?.supportRegionId)(n);if(t&&!A(e))return e.replace(/(support\.theguardian\.com)\/(contribute-in-epic|contribute|subscribe|checkout)/,((e,n,a)=>`${n}/${t.toLowerCase()}/${a}`))}return e},I=(e,n,t,a)=>{if(a){const i=a[b(t)];if(i){return`${h(t)}${i[e][n].price}`}}},N={CURRENCY_SYMBOL:({countryCode:e})=>h(e),COUNTRY_NAME:({countryCode:e})=>y(e),PRICE_DIGISUB_MONTHLY:({countryCode:e,prices:n})=>I("Digisub","Monthly",e,n),PRICE_DIGISUB_ANNUAL:({countryCode:e,prices:n})=>I("Digisub","Annual",e,n),PRICE_GUARDIANWEEKLY_MONTHLY:({countryCode:e,prices:n})=>I("GuardianWeekly","Monthly",e,n),PRICE_GUARDIANWEEKLY_ANNUAL:({countryCode:e,prices:n})=>I("GuardianWeekly","Annual",e,n),DAY_OF_THE_WEEK:()=>((e=new Date)=>e.toLocaleString("en-GB",{weekday:"long"}))(),DATE:()=>((e=new Date)=>e.toLocaleString("en-GB",{day:"numeric",month:"long",year:"numeric"}))()},M=(e,n,t)=>e?e.replace(E,(e=>{const a=e.substring(2,e.length-2),i=N[a];if(i){const e=i({countryCode:n,prices:t});if(e)return e}return e})):"",E=/%%.*?%%/g,G=e=>{const n=e.match(E)?.filter((e=>"%%ARTICLE_COUNT%%"!==e));return!!n&&n.length>0},U=e=>{const n=(e=>{const n=new Date(e,10,1).getDay();return new Date(e,10,22+(11-n)%7)})(e);return n.setDate(n.getDate()+5),n},B=(e=new Date)=>{const n=(e=>{const n=e.getDate()<20?1:2;return e.setMonth(e.getMonth()+n),e})(e),t=(n.getMonth()+1).toString().padStart(2,"0"),a=n.toLocaleString("default",{month:"long"}),i=n.getFullYear();return{reminderCta:`Remind me in ${a}`,reminderPeriod:`${i}-${t}-01`,reminderLabel:`${a} ${i}`}},R=new Date("2023-12-31"),P=e=>e>=(e=>new Date(e.getFullYear(),9,20))(e)&&e<U(e.getFullYear()),L=(e,n=new Date)=>{return"US"===e&&P(n)?{reminderCta:"Remind me on Giving Tuesday",reminderPeriod:`${t=n.getFullYear()}-${(U(t).getMonth()+1).toString().padStart(0,"2")}-01`,reminderLabel:"on Giving Tuesday",reminderOption:`giving-tuesday-${t}`}:"US"===e&&(e=>e>=U(e.getFullYear())&&e<R)(n)?(e=>({reminderCta:"Remind me on New Years Eve",reminderPeriod:`${e}-12-01`,reminderLabel:"on New Years Eve",reminderOption:`new-years-eve-${e}`}))(n.getFullYear()):B(n);var t},D=e.object({text:e.string(),baseUrl:e.string()});let w=function(e){return e.Custom="CustomSecondaryCta",e.ContributionsReminder="ContributionsReminderSecondaryCta",e}({});e.nativeEnum(w);const O=e.object({type:e.literal(w.Custom),cta:D}),k=e.object({type:e.literal(w.ContributionsReminder)}),f=e.discriminatedUnion("type",[O,k]);let K=function(e){return e.unlimited="unlimited",e.hardstop="hardstop",e}({});const F=e.nativeEnum(K);let v=function(e){return e.money="money",e}({});const j=e.nativeEnum(v),H=e.object({countLabel:e.string(),goalReachedPrimary:e.string().optional(),goalReachedSecondary:e.string().optional()}),Y=e.object({total:e.number(),goal:e.number()}),V=e.enum(["US","AU"]),W=e.object({endType:F,countType:j,currencySymbol:e.string(),copy:H,name:V,tickerData:Y.optional()}),Z=e.object({for52Weeks:e.number(),forTargetedWeeks:e.number()}),$=e.enum(["for52Weeks","forTargetedWeeks"]),x=e.object({type:e.literal("above"),copy:e.string().optional(),countType:$.optional()}),_=e.enum(["CONTRIBUTION","MEMBERSHIP_SUPPORTER","DIGITAL_SUBSCRIPTION","PRINT_SUBSCRIPTION"]),J=e.enum(["ACQUISITIONS_EPIC","ACQUISITIONS_ENGAGEMENT_BANNER","ACQUISITIONS_SUBSCRIPTIONS_BANNER","ACQUISITIONS_HEADER","ACQUISITIONS_OTHER"]),Q=e.object({abTestName:e.string(),abTestVariant:e.string(),campaignCode:e.string(),componentType:J,products:e.array(_).nullish(),labels:e.array(e.string()).nullish(),ophanPageId:e.string(),platformId:e.string(),referrerUrl:e.string(),clientName:e.string()}),z=e.object({mainUrl:e.string(),mobileUrl:e.string().optional(),tabletUrl:e.string().optional(),desktopUrl:e.string().optional(),leftColUrl:e.string().optional(),wideUrl:e.string().optional(),altText:e.string()}),q=e.object({name:e.string(),description:e.string().optional(),headshot:z.optional()}),X=/^[0-9A-F]{2}$/,ee=e.string().refine((e=>X.test(e)),(e=>({message:`"${e}" is not a valid hex value`}))),ne=e.object({r:ee,g:ee,b:ee,kind:e.literal("hex")}),te=e.object({mobileUrl:e.string(),tabletUrl:e.string(),desktopUrl:e.string(),altText:e.string(),kind:e.literal("Image")}),ae=e.object({buttonColour:ne.nullish(),buttonTextColour:ne.nullish(),buttonBorderColour:ne.nullish(),buttonSelectColour:ne.nullish(),buttonSelectTextColour:ne.nullish(),buttonSelectBorderColour:ne.nullish(),kind:e.literal("ChoiceCards")}),ie=e.discriminatedUnion("kind",[te,ae]),oe=e.object({visual:ie.nullish(),colours:e.object({basic:e.object({background:ne,bodyText:ne})})}),re=e=>`#${e.r}${e.g}${e.b}`,se=e.enum(["Contribution","SupporterPlus","GuardianWeekly","Paper"]),le=e.enum(["new","guest","current"]),ue=e.enum(["Epic","EpicAMP","EpicAppleNews","EpicLiveblog","Banner1","Banner2","Header"]),ce=e.enum(["Live","Draft","Archived"]),de=e.enum(["Mobile","Desktop","All","iOS","Android"]),ge=e.enum(["SignedIn","SignedOut","All"]),me=e.enum(["HasConsented","HasNotConsented","All"]),pe=e.object({name:e.literal("ABTest")}),Ce=e.object({name:e.literal("EpsilonGreedyBandit"),epsilon:e.number()}),be=e.intersection(e.discriminatedUnion("name",[pe,Ce]),e.object({testName:e.string().optional()})),Se=e.object({channel:ue,name:e.string(),status:ce,priority:e.number(),controlProportionSettings:e.object({proportion:e.number(),offset:e.number()}).optional(),deviceType:de.optional(),signedInStatus:ge.optional(),consentStatus:me.optional(),methodologies:be.array().optional()}),he=e.enum(["AllExistingSupporters","AllNonSupporters","Everyone","PostAskPauseSingleContributors"]),ye=e.object({minViews:e.number(),maxViews:e.number().optional(),periodInWeeks:e.number(),tagIds:e.array(e.string()).optional()});e.object({userType:e.array(le),product:e.array(se)}),e.object({tagIds:e.array(e.string()),sectionIds:e.array(e.string()),excludedTagIds:e.array(e.string()),excludedSectionIds:e.array(e.string())});const Ae=e.object({maxViewsCount:e.number(),maxViewsDays:e.number(),minDaysBetweenViews:e.number()}),Te=e.object({reminderCta:e.string(),reminderLabel:e.string(),reminderPeriod:e.string()}),Ie=e.enum(["ONE_OFF","MONTHLY","ANNUAL"]),Ne=e.object({testName:e.string(),variantName:e.string(),defaultContributionType:Ie,displayContributionType:Ie.array(),amountsCardData:e.object({ONE_OFF:e.object({amounts:e.array(e.number()),defaultAmount:e.number(),hideChooseYourAmount:e.boolean().optional()}),MONTHLY:e.object({amounts:e.array(e.number()),defaultAmount:e.number(),hideChooseYourAmount:e.boolean().optional()}),ANNUAL:e.object({amounts:e.array(e.number()),defaultAmount:e.number(),hideChooseYourAmount:e.boolean().optional()})})}),Me=e.object({newsletterId:e.string(),successDescription:e.string()}),Ee=e.object({name:e.string(),heading:e.string().optional(),paragraphs:e.array(e.string()),highlightedText:e.string().optional(),tickerSettings:W.optional(),cta:D.optional(),secondaryCta:f.optional(),newsletterSignup:Me.optional(),image:z.optional(),showReminderFields:Te.optional(),separateArticleCount:x.optional(),maxViews:Ae.optional(),showSignInLink:e.boolean().optional(),bylineWithImage:q.optional(),showChoiceCards:e.boolean().optional(),choiceCardAmounts:Ne.optional(),defaultChoiceCardFrequency:Ie.optional()}),Ge=e.object({variant:Ee,tracking:Q,countryCode:e.string().nullish(),articleCounts:Z,onReminderOpen:e.any().nullish(),fetchEmail:e.any().nullish(),submitComponentEvent:e.any().nullish(),openCmp:e.any().nullish(),hasConsentForArticleCount:e.boolean().nullish(),stage:e.string().nullish()}),Ue=e.enum(["contributions","subscriptions","signIn","abandonedBasket"]),Be=e.object({heading:e.string().optional(),messageText:e.string().optional(),paragraphs:e.array(e.string()).optional(),mobileMessageText:e.string().optional(),highlightedText:e.string().optional(),cta:D.optional(),secondaryCta:f.optional()}),Re=e.object({tracking:Q,bannerChannel:Ue,content:Be.nullish(),mobileContent:Be.nullish(),countryCode:e.string().nullish(),isSupporter:e.boolean().nullish(),tickerSettings:W.nullish(),submitComponentEvent:e.any(),articleCounts:Z,hasOptedOutOfArticleCount:e.boolean().nullish(),fetchEmail:e.any().nullish(),separateArticleCount:e.boolean().nullish(),design:oe.nullish()}),Pe=e.object({heading:e.string(),subheading:e.string(),primaryCta:D.optional(),secondaryCta:D.optional(),benefits:e.array(e.string()).optional()}),Le=e.object({content:Pe,tracking:Q,mobileContent:Pe.optional(),countryCode:e.string().optional(),submitComponentEvent:e.any(),numArticles:e.number().optional()}),De=e.object({maxViewsCount:e.number(),maxViewsDays:e.number(),minDaysBetweenViews:e.number()}),we=["ONE_OFF","MONTHLY","ANNUAL"];Se.extend({name:e.string(),status:ce,locations:e.array(g),tagIds:e.array(e.string()),sections:e.array(e.string()),excludedTagIds:e.array(e.string()),excludedSections:e.array(e.string()),alwaysAsk:e.boolean(),maxViews:De.optional(),userCohort:he,hasCountryName:e.boolean(),highPriority:e.boolean(),useLocalViewLog:e.boolean(),articlesViewedSettings:ye.optional(),priority:e.number(),variants:Ee.array()});const Oe=e.object({amount:e.union([e.number(),e.literal("other")]),billingPeriod:e.union([e.literal("ONE_OFF"),e.literal("MONTHLY"),e.literal("ANNUAL")]),product:e.union([e.literal("Contribution"),e.literal("SupporterPlus"),e.literal("PremiumTier"),e.literal("DailyEdition"),e.literal("GuardianWeekly"),e.literal("Paper"),e.literal("PaperAndDigital")]),region:e.union([e.literal("uk"),e.literal("us"),e.literal("au"),e.literal("eu"),e.literal("int"),e.literal("nz"),e.literal("ca")])}),ke=(e,n,t)=>{const a=(e=>{if(URLSearchParams){const n=new URLSearchParams(window.location.search).get(`force-${e}`);if(n)return n}return null})(e);return fetch(`${n}/${e}${a?`?force=${a}`:""}`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then((n=>{if(!n.ok)throw Error(n.statusText||`Supporter Revenue ${e} | Api call returned HTTP status ${n.status}`);return n})).then((e=>e.json()))},fe=(e,n)=>ke("epic",e,n),Ke=(e,n)=>ke("liveblog-epic",e,n),Fe=(e,n)=>ke("banner",e,n),ve=(e,n)=>ke("header",e,n);export{d as CountryGroupId,w as SecondaryCtaType,v as TickerCountType,K as TickerEndType,Oe as abandonedBasketSchema,T as addRegionIdToSupportUrl,Re as bannerSchema,B as buildReminderFields,G as containsNonArticleCountPlaceholder,we as contributionTabFrequencies,b as countryCodeToCountryGroupId,g as countryGroupIdSchema,Ge as epicPropsSchema,Fe as getBanner,y as getCountryName,fe as getEpic,t as getEpicViewLog,ve as getHeader,Ke as getLiveblogEpic,h as getLocalCurrencySymbol,L as getReminderFields,s as getWeeklyArticleHistory,Le as headerPropsSchema,re as hexColourToString,S as inCountryGroups,c as incrementWeeklyArticleCount,A as isGWCheckoutUrl,a as logEpicView,M as replaceNonArticleCountPlaceholders};
|
|
1
|
+
import{z as e}from"zod";const n="gu.contributions.views",t=e=>e.get(n)||void 0,a=e=>{const t=localStorage.getItem(n),a=t?JSON.parse(t).value:[];a.push({date:(new Date).getTime(),testId:e});const i={value:a.slice(-50)};localStorage.setItem(n,JSON.stringify(i))},i="gu.history.weeklyArticleCount",o="gu.history.articleCountsThisWeek",r=e=>{const n=e.getDay()||7;return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()-(n-1))/864e5},s=e=>e.get(i)||void 0,l=new Set(["environment/climate-change","environment/climate-crisis","environment/environment","science/science","politics/politics","us-news/us-politics","australia-news/australian-politics","world/world","world/europe-news","world/russia","books/books","culture/culture","world/coronavirus-outbreak","world/race","inequality/inequality","technology/technology","business/business","tone/recipes","sport/sport","football/football","sport/olympic-games","sport/olympic-games-2024","tracking/commissioningdesk/uk-investigations"]),u=(e,n={})=>(e.forEach((e=>{l.has(e)&&(n[e]=(n[e]??0)+1)})),n),c=(e,n,t)=>{const a=((e,n)=>{const t=r(new Date),a=e.get(o);if(a&&a.week===t){const i=a.articles[n]||0;return e.set(o,{week:t,articles:{...a.articles,[n]:i+1}}),i>0}return e.set(o,{week:t,articles:{[n]:1}}),!1})(e,n);if(!a){const n=r(new Date),a=e.get(i)||[],o=a[0];if(o&&o.week&&o.week===n)o.count+=1,o.tags=u(t,o.tags),e.set(i,a);else{a.unshift({week:n,count:1,tags:u(t,{})});const o=n-365,r=a.filter((e=>e.week>=o));e.set(i,r)}}},d=["GBPCountries","UnitedStates","AUDCountries","EURCountries","International","NZDCountries","Canada"],g=e.enum(d),m={GBPCountries:{name:"United Kingdom",currency:"GBP",countries:["GB","FK","GI","GG","IM","JE","SH"],supportRegionId:"UK"},UnitedStates:{name:"United States",currency:"USD",countries:["US"],supportRegionId:"US"},AUDCountries:{name:"Australia",currency:"AUD",countries:["AU","KI","NR","NF","TV"],supportRegionId:"AU"},EURCountries:{name:"Europe",currency:"EUR",countries:["AD","AL","AT","BA","BE","BG","BL","CH","CY","CZ","DE","DK","EE","ES","FI","FO","FR","GF","GL","GP","GR","HR","HU","IE","IT","LI","LT","LU","LV","MC","ME","MF","IS","MQ","MT","NL","NO","PF","PL","PM","PT","RE","RO","RS","SE","SI","SJ","SK","SM","TF","TR","WF","YT","VA","AX","AZ","AM","GE","BY","MD","UA","MK"],supportRegionId:"EU"},International:{name:"International",currency:"USD",countries:["AE","AF","AG","AI","AO","AQ","AR","AS","AW","BB","BD","BF","BH","BI","BJ","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BZ","CC","CD","CF","CG","CI","CL","CM","CN","CO","CR","CU","CV","CW","CX","DJ","DM","DO","DZ","EC","EG","EH","ER","ET","FJ","FM","GA","GD","GH","GM","GN","GQ","GS","GT","GU","GW","GY","HK","HM","HN","HT","ID","IL","IN","IO","IQ","IR","JM","JO","JP","KE","KG","KH","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LK","LR","LS","LY","MA","MG","MH","ML","MM","MN","MO","MP","MR","MS","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NG","NI","NP","NU","OM","PA","PE","PG","PH","PK","PN","PR","PS","PW","PY","QA","RU","RW","SA","SB","SC","SD","SG","SL","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TG","TH","TJ","TK","TL","TM","TN","TO","TT","TW","TZ","UG","UM","UY","UZ","VC","VE","VG","VI","VN","VU","WS","YE","ZA","ZM","ZW"],supportRegionId:"INT"},NZDCountries:{name:"New Zealand",currency:"NZD",countries:["NZ","CK"],supportRegionId:"NZ"},Canada:{name:"Canada",currency:"CAD",countries:["CA"],supportRegionId:"CA"}},p={AD:"Andorra",AE:"the UAE",AF:"Afghanistan",AG:"Antigua and Barbuda",AI:"Anguilla",AL:"Albania",AM:"Armenia",AO:"Angola",AR:"Argentina",AS:"the US",AT:"Austria",AU:"Australia",AW:"Aruba",AX:"Åland Islands",AZ:"Azerbaijan",BA:"Bosnia and Herzegovina",BB:"Barbados",BD:"Bangladesh",BE:"Belgium",BF:"Burkina Faso",BG:"Bulgaria",BH:"Bahrain",BI:"Burundi",BJ:"Benin",BL:"Saint Barthélemy",BM:"Bermuda",BN:"Brunei Darussalam",BO:"Bolivia",BQ:"Bonaire, Sint Eustatius and Saba",BR:"Brazil",BS:"the Bahamas",BT:"Bhutan",BV:"Bouvet Island",BW:"Botswana",BY:"Belarus",BZ:"Belize",CA:"Canada",CD:"the Democratic Republic of the Congo",CF:"the Central Africa Republic",CG:"the Congo",CH:"Switzerland",CI:"Côte d'Ivoire",CK:"the Cook Islands",CL:"Chile",CM:"Cameroon",CN:"China",CO:"Colombia",CR:"Costa Rica",CU:"Cuba",CV:"Cabo Verde",CW:"Curaçao",CX:"Christmas Island",CY:"Cyprus",CZ:"the Czech Republic",DE:"Germany",DJ:"Djibouti",DK:"Denmark",DM:"Dominica",DO:"the Dominican Republic",DZ:"Algeria",EC:"Ecuador",EE:"Estonia",EG:"Egypt",EH:"the Western Sahara",ER:"Eritrea",ES:"Spain",ET:"Ethiopia",FI:"Finland",FJ:"Fiji",FK:"the UK",FO:"the UK",FR:"France",GA:"Gabon",GB:"the UK",GD:"Grenada",GE:"Georgia",GF:"French Guiana",GG:"Guernsey",GH:"Ghana",GI:"Gibraltar",GL:"Greenland",GM:"the Gambia",GN:"Guinea",GP:"Guadeloupe",GQ:"Equatorial Guinea",GR:"Greece",GT:"Guatemala",GU:"Guam",GW:"Guinea-Bissau",GY:"Guyana",HK:"Hong Kong",HN:"Honduras",HR:"Croatia",HT:"Haiti",HU:"Hungary",ID:"Indonesia",IE:"Ireland",IM:"the Isle of Man",IN:"India",IQ:"Iraq",IR:"Iran",IS:"Iceland",IT:"Italy",JE:"Jersey",JM:"Jamaica",JO:"Jordan",JP:"Japan",KE:"Kenya",KG:"Kyrgyzstan",KH:"Cambodia",KI:"Kiribati",KN:"Saint Kitts and Nevis",KP:"Korea",KR:"Korea",KW:"Kuwait",KY:"the Cayman Ialnds",KZ:"Kazakhstan",LB:"Lebanon",LC:"Saint Lucia",LI:"Liechtenstein",LK:"Sri Lanka",LR:"Liberia",LS:"Lesotho",LT:"Lithuania",LU:"Luxembourg",LV:"Latvia",LY:"Libya",MA:"Morocco",MC:"Monaco",MD:"Moldova",ME:"Montenegro",MG:"Madagascar",MK:"the Republic of North Macedonia",ML:"Mali",MM:"Myanmar",MN:"Mongolia",MO:"Macao",MQ:"Martinique",MR:"Mauritania",MS:"Montserrat",MT:"Malta",MU:"Mauritius",MV:"Maldives",MW:"Malawi",MX:"Mexico",MY:"Malaysia",MZ:"Mozambique",NA:"Namibia",NC:"New Caledonia",NE:"Niger",NF:"Norfolk Island",NG:"Nigeria",NI:"Nicaragua",NL:"the Netherlands",NO:"Norway",NP:"Nepal",NR:"Nauru",NU:"Niue",NZ:"New Zealand",OM:"Oman",PA:"Panama",PE:"Peru",PF:"French Polynesia",PG:"Papua New Guinea",PH:"the Philippines",PK:"Pakistan",PL:"Poland",PM:"Saint Pierre and Miquelon",PN:"Pitcairn",PR:"Puerto Rico",PT:"Portugal",PW:"Palau",PY:"Paraguay",QA:"Qatar",RE:"Réunion",RO:"Romania",RU:"Russia",RW:"Rwanda",SA:"Saudi Arabia",SB:"Solomon Islands",SC:"Seychelles",SD:"Sudan",SE:"Sweden",SG:"Singapore",SH:"Saint Helena",SI:"Slovenia",SJ:"Svalbard and Jan Mayen",SK:"Slovakia",SL:"Sierra Leone",SM:"San Marino",SN:"Senegal",SO:"Somalia",SR:"Suriname",SS:"South Sudan",ST:"Sao Tome and Principe",SV:"El Salvador",SY:"Syrian Arab Republic",SZ:"Eswatini",TD:"Chad",TG:"Togo",TH:"Thailand",TJ:"Tajikistan",TK:"Tokelau",TL:"Timor-Leste",TM:"Turkmenistan",TN:"Tunisia",TO:"Tonga",TR:"Turkey",TT:"Trinidad and Tobago",TV:"Tuvalu",TW:"Taiwan",TZ:"Tanzania ",UG:"Uganda",US:"the US",UY:"Uruguay",UZ:"Uzbekistan",VC:"Saint Vincent and the Grenadines",VE:"Venezuela",VG:"the Virgin Islands",VI:"the Virgin Islands",VN:"Vietnam",VU:"Vanuatu",WF:"Wallis and Futuna",WS:"Samoa",YE:"Yemen",YT:"Mayotte",ZA:"South Africa",ZM:"Zambia",ZW:"Zimbabwe"},b={GBPCountries:"£",UnitedStates:"$",AUDCountries:"$",Canada:"CA$",EURCountries:"€",NZDCountries:"NZ$",International:"$"},C=e=>Object.keys(m).find((n=>m[n].countries.includes(e??"")))||"International",S=(e,n=[])=>0===n.length||!!e&&n.includes(C(e.toUpperCase())),h=e=>{if(e){const n=C(e);return b[n]}return"£"},y=e=>{if(e)return p[e]},A=e=>/subscribe\/weekly\/checkout/.test(e),T=(e,n)=>{if(n){const t=(e=>m[C(e)]?.supportRegionId)(n);if(t&&!A(e))return e.replace(/(support\.theguardian\.com)\/(contribute-in-epic|contribute|subscribe|checkout)/,((e,n,a)=>`${n}/${t.toLowerCase()}/${a}`))}return e},I=(e,n,t,a)=>{if(a){const i=a[C(t)];if(i){return`${h(t)}${i[e][n].price}`}}},N={CURRENCY_SYMBOL:({countryCode:e})=>h(e),COUNTRY_NAME:({countryCode:e})=>y(e),PRICE_DIGISUB_MONTHLY:({countryCode:e,prices:n})=>I("Digisub","Monthly",e,n),PRICE_DIGISUB_ANNUAL:({countryCode:e,prices:n})=>I("Digisub","Annual",e,n),PRICE_GUARDIANWEEKLY_MONTHLY:({countryCode:e,prices:n})=>I("GuardianWeekly","Monthly",e,n),PRICE_GUARDIANWEEKLY_ANNUAL:({countryCode:e,prices:n})=>I("GuardianWeekly","Annual",e,n),DAY_OF_THE_WEEK:()=>((e=new Date)=>e.toLocaleString("en-GB",{weekday:"long"}))(),DATE:()=>((e=new Date)=>e.toLocaleString("en-GB",{day:"numeric",month:"long",year:"numeric"}))()},M=(e,n,t)=>e?e.replace(E,(e=>{const a=e.substring(2,e.length-2),i=N[a];if(i){const e=i({countryCode:n,prices:t});if(e)return e}return e})):"",E=/%%.*?%%/g,G=e=>{const n=e.match(E)?.filter((e=>"%%ARTICLE_COUNT%%"!==e));return!!n&&n.length>0},U=e=>{const n=(e=>{const n=new Date(e,10,1).getDay();return new Date(e,10,22+(11-n)%7)})(e);return n.setDate(n.getDate()+5),n},R=(e=new Date)=>{const n=(e=>{const n=e.getDate()<20?1:2;return e.setMonth(e.getMonth()+n),e})(e),t=(n.getMonth()+1).toString().padStart(2,"0"),a=n.toLocaleString("default",{month:"long"}),i=n.getFullYear();return{reminderCta:`Remind me in ${a}`,reminderPeriod:`${i}-${t}-01`,reminderLabel:`${a} ${i}`}},B=new Date("2023-12-31"),P=e=>e>=(e=>new Date(e.getFullYear(),9,20))(e)&&e<U(e.getFullYear()),L=(e,n=new Date)=>{return"US"===e&&P(n)?{reminderCta:"Remind me on Giving Tuesday",reminderPeriod:`${t=n.getFullYear()}-${(U(t).getMonth()+1).toString().padStart(0,"2")}-01`,reminderLabel:"on Giving Tuesday",reminderOption:`giving-tuesday-${t}`}:"US"===e&&(e=>e>=U(e.getFullYear())&&e<B)(n)?(e=>({reminderCta:"Remind me on New Years Eve",reminderPeriod:`${e}-12-01`,reminderLabel:"on New Years Eve",reminderOption:`new-years-eve-${e}`}))(n.getFullYear()):R(n);var t},D=e.object({text:e.string(),baseUrl:e.string()});let w=function(e){return e.Custom="CustomSecondaryCta",e.ContributionsReminder="ContributionsReminderSecondaryCta",e}({});e.nativeEnum(w);const O=e.object({type:e.literal(w.Custom),cta:D}),k=e.object({type:e.literal(w.ContributionsReminder)}),f=e.discriminatedUnion("type",[O,k]);let K=function(e){return e.unlimited="unlimited",e.hardstop="hardstop",e}({});const v=e.nativeEnum(K);let F=function(e){return e.money="money",e}({});const j=e.nativeEnum(F),H=e.object({countLabel:e.string(),goalReachedPrimary:e.string().optional(),goalReachedSecondary:e.string().optional()}),Y=e.object({total:e.number(),goal:e.number()}),V=e.enum(["US","AU"]),W=e.object({endType:v,countType:j,currencySymbol:e.string(),copy:H,name:V,tickerData:Y.optional()}),Z=e.object({for52Weeks:e.number(),forTargetedWeeks:e.number()}),$=e.enum(["for52Weeks","forTargetedWeeks"]),x=e.object({type:e.literal("above"),copy:e.string().optional(),countType:$.optional()}),_=e.enum(["CONTRIBUTION","MEMBERSHIP_SUPPORTER","DIGITAL_SUBSCRIPTION","PRINT_SUBSCRIPTION"]),J=e.enum(["ACQUISITIONS_EPIC","ACQUISITIONS_ENGAGEMENT_BANNER","ACQUISITIONS_SUBSCRIPTIONS_BANNER","ACQUISITIONS_HEADER","ACQUISITIONS_OTHER"]),Q=e.object({abTestName:e.string(),abTestVariant:e.string(),campaignCode:e.string(),componentType:J,products:e.array(_).nullish(),labels:e.array(e.string()).nullish(),ophanPageId:e.string(),platformId:e.string(),referrerUrl:e.string(),clientName:e.string()}),z=e.object({mainUrl:e.string(),mobileUrl:e.string().optional(),tabletUrl:e.string().optional(),desktopUrl:e.string().optional(),leftColUrl:e.string().optional(),wideUrl:e.string().optional(),altText:e.string()}),q=e.object({name:e.string(),description:e.string().optional(),headshot:z.optional()}),X=/^[0-9A-F]{2}$/,ee=e.string().refine((e=>X.test(e)),(e=>({message:`"${e}" is not a valid hex value`}))),ne=e.object({r:ee,g:ee,b:ee,kind:e.literal("hex")}),te=e.object({mobileUrl:e.string(),tabletUrl:e.string(),desktopUrl:e.string(),altText:e.string(),kind:e.literal("Image")}),ae=e.object({buttonColour:ne.nullish(),buttonTextColour:ne.nullish(),buttonBorderColour:ne.nullish(),buttonSelectColour:ne.nullish(),buttonSelectTextColour:ne.nullish(),buttonSelectBorderColour:ne.nullish(),kind:e.literal("ChoiceCards")}),ie=e.discriminatedUnion("kind",[te,ae]),oe=e.object({visual:ie.nullish(),colours:e.object({basic:e.object({background:ne,bodyText:ne})})}),re=e=>`#${e.r}${e.g}${e.b}`,se=e.enum(["Contribution","SupporterPlus","GuardianWeekly","Paper"]),le=e.enum(["new","guest","current"]),ue=e.enum(["Epic","EpicAMP","EpicAppleNews","EpicLiveblog","Banner1","Banner2","Header","GutterLiveblog"]),ce=e.enum(["Live","Draft","Archived"]),de=e.enum(["Mobile","Desktop","All","iOS","Android"]),ge=e.enum(["SignedIn","SignedOut","All"]),me=e.enum(["HasConsented","HasNotConsented","All"]),pe=e.object({name:e.literal("ABTest")}),be=e.object({name:e.literal("EpsilonGreedyBandit"),epsilon:e.number(),sampleCount:e.number().optional()}),Ce=e.object({name:e.literal("Roulette"),sampleCount:e.number().optional()}),Se=e.intersection(e.discriminatedUnion("name",[pe,be,Ce]),e.object({testName:e.string().optional()})),he=e.object({channel:ue,name:e.string(),status:ce,priority:e.number(),controlProportionSettings:e.object({proportion:e.number(),offset:e.number()}).optional(),deviceType:de.optional(),signedInStatus:ge.optional(),consentStatus:me.optional(),methodologies:Se.array().optional()}),ye=e.enum(["AllExistingSupporters","AllNonSupporters","Everyone","PostAskPauseSingleContributors"]),Ae=e.object({minViews:e.number(),maxViews:e.number().optional(),periodInWeeks:e.number(),tagIds:e.array(e.string()).optional()});e.object({userType:e.array(le),product:e.array(se)}),e.object({tagIds:e.array(e.string()),sectionIds:e.array(e.string()),excludedTagIds:e.array(e.string()),excludedSectionIds:e.array(e.string())});const Te=e.object({maxViewsCount:e.number(),maxViewsDays:e.number(),minDaysBetweenViews:e.number()}),Ie=e.object({reminderCta:e.string(),reminderLabel:e.string(),reminderPeriod:e.string()}),Ne=e.enum(["ONE_OFF","MONTHLY","ANNUAL"]),Me=e.object({testName:e.string(),variantName:e.string(),defaultContributionType:Ne,displayContributionType:Ne.array(),amountsCardData:e.object({ONE_OFF:e.object({amounts:e.array(e.number()),defaultAmount:e.number(),hideChooseYourAmount:e.boolean().optional()}),MONTHLY:e.object({amounts:e.array(e.number()),defaultAmount:e.number(),hideChooseYourAmount:e.boolean().optional()}),ANNUAL:e.object({amounts:e.array(e.number()),defaultAmount:e.number(),hideChooseYourAmount:e.boolean().optional()})})}),Ee=e.object({newsletterId:e.string(),successDescription:e.string()}),Ge=e.object({name:e.string(),heading:e.string().optional(),paragraphs:e.array(e.string()),highlightedText:e.string().optional(),tickerSettings:W.optional(),cta:D.optional(),secondaryCta:f.optional(),newsletterSignup:Ee.optional(),image:z.optional(),showReminderFields:Ie.optional(),separateArticleCount:x.optional(),maxViews:Te.optional(),showSignInLink:e.boolean().optional(),bylineWithImage:q.optional(),showChoiceCards:e.boolean().optional(),choiceCardAmounts:Me.optional(),defaultChoiceCardFrequency:Ne.optional()}),Ue=e.object({variant:Ge,tracking:Q,countryCode:e.string().nullish(),articleCounts:Z,onReminderOpen:e.any().nullish(),fetchEmail:e.any().nullish(),submitComponentEvent:e.any().nullish(),openCmp:e.any().nullish(),hasConsentForArticleCount:e.boolean().nullish(),stage:e.string().nullish()}),Re=e.enum(["contributions","subscriptions","signIn","abandonedBasket"]),Be=e.object({heading:e.string().optional(),messageText:e.string().optional(),paragraphs:e.array(e.string()).optional(),mobileMessageText:e.string().optional(),highlightedText:e.string().optional(),cta:D.optional(),secondaryCta:f.optional()}),Pe=e.object({tracking:Q,bannerChannel:Re,content:Be.nullish(),mobileContent:Be.nullish(),countryCode:e.string().nullish(),isSupporter:e.boolean().nullish(),tickerSettings:W.nullish(),submitComponentEvent:e.any(),articleCounts:Z,hasOptedOutOfArticleCount:e.boolean().nullish(),fetchEmail:e.any().nullish(),separateArticleCount:e.boolean().nullish(),design:oe.nullish()}),Le=e.object({heading:e.string(),subheading:e.string(),primaryCta:D.optional(),secondaryCta:D.optional(),benefits:e.array(e.string()).optional()}),De=e.object({content:Le,tracking:Q,mobileContent:Le.optional(),countryCode:e.string().optional(),submitComponentEvent:e.any(),numArticles:e.number().optional()}),we=e.object({image:z,bodyCopy:e.array(e.string()),cta:D.optional()});e.object({content:we,tracking:Q,countryCode:e.string().optional(),submitComponentEvent:e.any()});const Oe=e.object({maxViewsCount:e.number(),maxViewsDays:e.number(),minDaysBetweenViews:e.number()}),ke=["ONE_OFF","MONTHLY","ANNUAL"];he.extend({name:e.string(),status:ce,locations:e.array(g),tagIds:e.array(e.string()),sections:e.array(e.string()),excludedTagIds:e.array(e.string()),excludedSections:e.array(e.string()),alwaysAsk:e.boolean(),maxViews:Oe.optional(),userCohort:ye,hasCountryName:e.boolean(),highPriority:e.boolean(),useLocalViewLog:e.boolean(),articlesViewedSettings:Ae.optional(),priority:e.number(),variants:Ge.array()});const fe=e.object({amount:e.union([e.number(),e.literal("other")]),billingPeriod:e.union([e.literal("ONE_OFF"),e.literal("MONTHLY"),e.literal("ANNUAL")]),product:e.union([e.literal("Contribution"),e.literal("SupporterPlus"),e.literal("PremiumTier"),e.literal("DailyEdition"),e.literal("GuardianWeekly"),e.literal("Paper"),e.literal("PaperAndDigital")]),region:e.union([e.literal("uk"),e.literal("us"),e.literal("au"),e.literal("eu"),e.literal("int"),e.literal("nz"),e.literal("ca")])}),Ke=(e,n,t)=>{const a=(e=>{if(URLSearchParams){const n=new URLSearchParams(window.location.search).get(`force-${e}`);if(n)return n}return null})(e);return fetch(`${n}/${e}${a?`?force=${a}`:""}`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then((n=>{if(!n.ok)throw Error(n.statusText||`Supporter Revenue ${e} | Api call returned HTTP status ${n.status}`);return n})).then((e=>e.json()))},ve=(e,n)=>Ke("epic",e,n),Fe=(e,n)=>Ke("liveblog-epic",e,n),je=(e,n)=>Ke("banner",e,n),He=(e,n)=>Ke("gutter-liveblog",e,n),Ye=(e,n)=>Ke("header",e,n);export{d as CountryGroupId,w as SecondaryCtaType,F as TickerCountType,K as TickerEndType,fe as abandonedBasketSchema,T as addRegionIdToSupportUrl,Pe as bannerSchema,R as buildReminderFields,G as containsNonArticleCountPlaceholder,ke as contributionTabFrequencies,C as countryCodeToCountryGroupId,g as countryGroupIdSchema,Ue as epicPropsSchema,je as getBanner,y as getCountryName,ve as getEpic,t as getEpicViewLog,He as getGutterLiveblog,Ye as getHeader,Fe as getLiveblogEpic,h as getLocalCurrencySymbol,L as getReminderFields,s as getWeeklyArticleHistory,De as headerPropsSchema,re as hexColourToString,S as inCountryGroups,c as incrementWeeklyArticleCount,A as isGWCheckoutUrl,a as logEpicView,M as replaceNonArticleCountPlaceholders};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("zod");const n="gu.contributions.views",t="gu.history.weeklyArticleCount",a="gu.history.articleCountsThisWeek",o=e=>{const n=e.getDay()||7;return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()-(n-1))/864e5},r=new Set(["environment/climate-change","environment/climate-crisis","environment/environment","science/science","politics/politics","us-news/us-politics","australia-news/australian-politics","world/world","world/europe-news","world/russia","books/books","culture/culture","world/coronavirus-outbreak","world/race","inequality/inequality","technology/technology","business/business","tone/recipes","sport/sport","football/football","sport/olympic-games","sport/olympic-games-2024","tracking/commissioningdesk/uk-investigations"]),i=(e,n={})=>(e.forEach((e=>{r.has(e)&&(n[e]=(n[e]??0)+1)})),n),s=["GBPCountries","UnitedStates","AUDCountries","EURCountries","International","NZDCountries","Canada"],l=e.z.enum(s),u={GBPCountries:{name:"United Kingdom",currency:"GBP",countries:["GB","FK","GI","GG","IM","JE","SH"],supportRegionId:"UK"},UnitedStates:{name:"United States",currency:"USD",countries:["US"],supportRegionId:"US"},AUDCountries:{name:"Australia",currency:"AUD",countries:["AU","KI","NR","NF","TV"],supportRegionId:"AU"},EURCountries:{name:"Europe",currency:"EUR",countries:["AD","AL","AT","BA","BE","BG","BL","CH","CY","CZ","DE","DK","EE","ES","FI","FO","FR","GF","GL","GP","GR","HR","HU","IE","IT","LI","LT","LU","LV","MC","ME","MF","IS","MQ","MT","NL","NO","PF","PL","PM","PT","RE","RO","RS","SE","SI","SJ","SK","SM","TF","TR","WF","YT","VA","AX","AZ","AM","GE","BY","MD","UA","MK"],supportRegionId:"EU"},International:{name:"International",currency:"USD",countries:["AE","AF","AG","AI","AO","AQ","AR","AS","AW","BB","BD","BF","BH","BI","BJ","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BZ","CC","CD","CF","CG","CI","CL","CM","CN","CO","CR","CU","CV","CW","CX","DJ","DM","DO","DZ","EC","EG","EH","ER","ET","FJ","FM","GA","GD","GH","GM","GN","GQ","GS","GT","GU","GW","GY","HK","HM","HN","HT","ID","IL","IN","IO","IQ","IR","JM","JO","JP","KE","KG","KH","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LK","LR","LS","LY","MA","MG","MH","ML","MM","MN","MO","MP","MR","MS","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NG","NI","NP","NU","OM","PA","PE","PG","PH","PK","PN","PR","PS","PW","PY","QA","RU","RW","SA","SB","SC","SD","SG","SL","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TG","TH","TJ","TK","TL","TM","TN","TO","TT","TW","TZ","UG","UM","UY","UZ","VC","VE","VG","VI","VN","VU","WS","YE","ZA","ZM","ZW"],supportRegionId:"INT"},NZDCountries:{name:"New Zealand",currency:"NZD",countries:["NZ","CK"],supportRegionId:"NZ"},Canada:{name:"Canada",currency:"CAD",countries:["CA"],supportRegionId:"CA"}},c={AD:"Andorra",AE:"the UAE",AF:"Afghanistan",AG:"Antigua and Barbuda",AI:"Anguilla",AL:"Albania",AM:"Armenia",AO:"Angola",AR:"Argentina",AS:"the US",AT:"Austria",AU:"Australia",AW:"Aruba",AX:"Åland Islands",AZ:"Azerbaijan",BA:"Bosnia and Herzegovina",BB:"Barbados",BD:"Bangladesh",BE:"Belgium",BF:"Burkina Faso",BG:"Bulgaria",BH:"Bahrain",BI:"Burundi",BJ:"Benin",BL:"Saint Barthélemy",BM:"Bermuda",BN:"Brunei Darussalam",BO:"Bolivia",BQ:"Bonaire, Sint Eustatius and Saba",BR:"Brazil",BS:"the Bahamas",BT:"Bhutan",BV:"Bouvet Island",BW:"Botswana",BY:"Belarus",BZ:"Belize",CA:"Canada",CD:"the Democratic Republic of the Congo",CF:"the Central Africa Republic",CG:"the Congo",CH:"Switzerland",CI:"Côte d'Ivoire",CK:"the Cook Islands",CL:"Chile",CM:"Cameroon",CN:"China",CO:"Colombia",CR:"Costa Rica",CU:"Cuba",CV:"Cabo Verde",CW:"Curaçao",CX:"Christmas Island",CY:"Cyprus",CZ:"the Czech Republic",DE:"Germany",DJ:"Djibouti",DK:"Denmark",DM:"Dominica",DO:"the Dominican Republic",DZ:"Algeria",EC:"Ecuador",EE:"Estonia",EG:"Egypt",EH:"the Western Sahara",ER:"Eritrea",ES:"Spain",ET:"Ethiopia",FI:"Finland",FJ:"Fiji",FK:"the UK",FO:"the UK",FR:"France",GA:"Gabon",GB:"the UK",GD:"Grenada",GE:"Georgia",GF:"French Guiana",GG:"Guernsey",GH:"Ghana",GI:"Gibraltar",GL:"Greenland",GM:"the Gambia",GN:"Guinea",GP:"Guadeloupe",GQ:"Equatorial Guinea",GR:"Greece",GT:"Guatemala",GU:"Guam",GW:"Guinea-Bissau",GY:"Guyana",HK:"Hong Kong",HN:"Honduras",HR:"Croatia",HT:"Haiti",HU:"Hungary",ID:"Indonesia",IE:"Ireland",IM:"the Isle of Man",IN:"India",IQ:"Iraq",IR:"Iran",IS:"Iceland",IT:"Italy",JE:"Jersey",JM:"Jamaica",JO:"Jordan",JP:"Japan",KE:"Kenya",KG:"Kyrgyzstan",KH:"Cambodia",KI:"Kiribati",KN:"Saint Kitts and Nevis",KP:"Korea",KR:"Korea",KW:"Kuwait",KY:"the Cayman Ialnds",KZ:"Kazakhstan",LB:"Lebanon",LC:"Saint Lucia",LI:"Liechtenstein",LK:"Sri Lanka",LR:"Liberia",LS:"Lesotho",LT:"Lithuania",LU:"Luxembourg",LV:"Latvia",LY:"Libya",MA:"Morocco",MC:"Monaco",MD:"Moldova",ME:"Montenegro",MG:"Madagascar",MK:"the Republic of North Macedonia",ML:"Mali",MM:"Myanmar",MN:"Mongolia",MO:"Macao",MQ:"Martinique",MR:"Mauritania",MS:"Montserrat",MT:"Malta",MU:"Mauritius",MV:"Maldives",MW:"Malawi",MX:"Mexico",MY:"Malaysia",MZ:"Mozambique",NA:"Namibia",NC:"New Caledonia",NE:"Niger",NF:"Norfolk Island",NG:"Nigeria",NI:"Nicaragua",NL:"the Netherlands",NO:"Norway",NP:"Nepal",NR:"Nauru",NU:"Niue",NZ:"New Zealand",OM:"Oman",PA:"Panama",PE:"Peru",PF:"French Polynesia",PG:"Papua New Guinea",PH:"the Philippines",PK:"Pakistan",PL:"Poland",PM:"Saint Pierre and Miquelon",PN:"Pitcairn",PR:"Puerto Rico",PT:"Portugal",PW:"Palau",PY:"Paraguay",QA:"Qatar",RE:"Réunion",RO:"Romania",RU:"Russia",RW:"Rwanda",SA:"Saudi Arabia",SB:"Solomon Islands",SC:"Seychelles",SD:"Sudan",SE:"Sweden",SG:"Singapore",SH:"Saint Helena",SI:"Slovenia",SJ:"Svalbard and Jan Mayen",SK:"Slovakia",SL:"Sierra Leone",SM:"San Marino",SN:"Senegal",SO:"Somalia",SR:"Suriname",SS:"South Sudan",ST:"Sao Tome and Principe",SV:"El Salvador",SY:"Syrian Arab Republic",SZ:"Eswatini",TD:"Chad",TG:"Togo",TH:"Thailand",TJ:"Tajikistan",TK:"Tokelau",TL:"Timor-Leste",TM:"Turkmenistan",TN:"Tunisia",TO:"Tonga",TR:"Turkey",TT:"Trinidad and Tobago",TV:"Tuvalu",TW:"Taiwan",TZ:"Tanzania ",UG:"Uganda",US:"the US",UY:"Uruguay",UZ:"Uzbekistan",VC:"Saint Vincent and the Grenadines",VE:"Venezuela",VG:"the Virgin Islands",VI:"the Virgin Islands",VN:"Vietnam",VU:"Vanuatu",WF:"Wallis and Futuna",WS:"Samoa",YE:"Yemen",YT:"Mayotte",ZA:"South Africa",ZM:"Zambia",ZW:"Zimbabwe"},d={GBPCountries:"£",UnitedStates:"$",AUDCountries:"$",Canada:"CA$",EURCountries:"€",NZDCountries:"NZ$",International:"$"},p=e=>Object.keys(u).find((n=>u[n].countries.includes(e??"")))||"International",g=e=>{if(e){const n=p(e);return d[n]}return"£"},z=e=>{if(e)return c[e]},m=e=>/subscribe\/weekly\/checkout/.test(e),C=(e,n,t,a)=>{if(a){const o=a[p(t)];if(o){return`${g(t)}${o[e][n].price}`}}},b={CURRENCY_SYMBOL:({countryCode:e})=>g(e),COUNTRY_NAME:({countryCode:e})=>z(e),PRICE_DIGISUB_MONTHLY:({countryCode:e,prices:n})=>C("Digisub","Monthly",e,n),PRICE_DIGISUB_ANNUAL:({countryCode:e,prices:n})=>C("Digisub","Annual",e,n),PRICE_GUARDIANWEEKLY_MONTHLY:({countryCode:e,prices:n})=>C("GuardianWeekly","Monthly",e,n),PRICE_GUARDIANWEEKLY_ANNUAL:({countryCode:e,prices:n})=>C("GuardianWeekly","Annual",e,n),DAY_OF_THE_WEEK:()=>((e=new Date)=>e.toLocaleString("en-GB",{weekday:"long"}))(),DATE:()=>((e=new Date)=>e.toLocaleString("en-GB",{day:"numeric",month:"long",year:"numeric"}))()},S=/%%.*?%%/g,h=e=>{const n=(e=>{const n=new Date(e,10,1).getDay();return new Date(e,10,22+(11-n)%7)})(e);return n.setDate(n.getDate()+5),n},y=(e=new Date)=>{const n=(e=>{const n=e.getDate()<20?1:2;return e.setMonth(e.getMonth()+n),e})(e),t=(n.getMonth()+1).toString().padStart(2,"0"),a=n.toLocaleString("default",{month:"long"}),o=n.getFullYear();return{reminderCta:`Remind me in ${a}`,reminderPeriod:`${o}-${t}-01`,reminderLabel:`${a} ${o}`}},A=new Date("2023-12-31"),T=e=>e>=(e=>new Date(e.getFullYear(),9,20))(e)&&e<h(e.getFullYear()),I=e.z.object({text:e.z.string(),baseUrl:e.z.string()});let N=function(e){return e.Custom="CustomSecondaryCta",e.ContributionsReminder="ContributionsReminderSecondaryCta",e}({});e.z.nativeEnum(N);const M=e.z.object({type:e.z.literal(N.Custom),cta:I}),E=e.z.object({type:e.z.literal(N.ContributionsReminder)}),G=e.z.discriminatedUnion("type",[M,E]);let U=function(e){return e.unlimited="unlimited",e.hardstop="hardstop",e}({});const R=e.z.nativeEnum(U);let B=function(e){return e.money="money",e}({});const P=e.z.nativeEnum(B),L=e.z.object({countLabel:e.z.string(),goalReachedPrimary:e.z.string().optional(),goalReachedSecondary:e.z.string().optional()}),D=e.z.object({total:e.z.number(),goal:e.z.number()}),w=e.z.enum(["US","AU"]),O=e.z.object({endType:R,countType:P,currencySymbol:e.z.string(),copy:L,name:w,tickerData:D.optional()}),k=e.z.object({for52Weeks:e.z.number(),forTargetedWeeks:e.z.number()}),x=e.z.enum(["for52Weeks","forTargetedWeeks"]),f=e.z.object({type:e.z.literal("above"),copy:e.z.string().optional(),countType:x.optional()}),F=e.z.enum(["CONTRIBUTION","MEMBERSHIP_SUPPORTER","DIGITAL_SUBSCRIPTION","PRINT_SUBSCRIPTION"]),K=e.z.enum(["ACQUISITIONS_EPIC","ACQUISITIONS_ENGAGEMENT_BANNER","ACQUISITIONS_SUBSCRIPTIONS_BANNER","ACQUISITIONS_HEADER","ACQUISITIONS_OTHER"]),v=e.z.object({abTestName:e.z.string(),abTestVariant:e.z.string(),campaignCode:e.z.string(),componentType:K,products:e.z.array(F).nullish(),labels:e.z.array(e.z.string()).nullish(),ophanPageId:e.z.string(),platformId:e.z.string(),referrerUrl:e.z.string(),clientName:e.z.string()}),H=e.z.object({mainUrl:e.z.string(),mobileUrl:e.z.string().optional(),tabletUrl:e.z.string().optional(),desktopUrl:e.z.string().optional(),leftColUrl:e.z.string().optional(),wideUrl:e.z.string().optional(),altText:e.z.string()}),j=e.z.object({name:e.z.string(),description:e.z.string().optional(),headshot:H.optional()}),V=/^[0-9A-F]{2}$/,Y=e.z.string().refine((e=>V.test(e)),(e=>({message:`"${e}" is not a valid hex value`}))),W=e.z.object({r:Y,g:Y,b:Y,kind:e.z.literal("hex")}),Z=e.z.object({mobileUrl:e.z.string(),tabletUrl:e.z.string(),desktopUrl:e.z.string(),altText:e.z.string(),kind:e.z.literal("Image")}),$=e.z.object({buttonColour:W.nullish(),buttonTextColour:W.nullish(),buttonBorderColour:W.nullish(),buttonSelectColour:W.nullish(),buttonSelectTextColour:W.nullish(),buttonSelectBorderColour:W.nullish(),kind:e.z.literal("ChoiceCards")}),_=e.z.discriminatedUnion("kind",[Z,$]),J=e.z.object({visual:_.nullish(),colours:e.z.object({basic:e.z.object({background:W,bodyText:W})})}),Q=e.z.enum(["Contribution","SupporterPlus","GuardianWeekly","Paper"]),q=e.z.enum(["new","guest","current"]),X=e.z.enum(["Epic","EpicAMP","EpicAppleNews","EpicLiveblog","Banner1","Banner2","Header"]),ee=e.z.enum(["Live","Draft","Archived"]),ne=e.z.enum(["Mobile","Desktop","All","iOS","Android"]),te=e.z.enum(["SignedIn","SignedOut","All"]),ae=e.z.enum(["HasConsented","HasNotConsented","All"]),oe=e.z.object({name:e.z.literal("ABTest")}),re=e.z.object({name:e.z.literal("EpsilonGreedyBandit"),epsilon:e.z.number()}),ie=e.z.intersection(e.z.discriminatedUnion("name",[oe,re]),e.z.object({testName:e.z.string().optional()})),se=e.z.object({channel:X,name:e.z.string(),status:ee,priority:e.z.number(),controlProportionSettings:e.z.object({proportion:e.z.number(),offset:e.z.number()}).optional(),deviceType:ne.optional(),signedInStatus:te.optional(),consentStatus:ae.optional(),methodologies:ie.array().optional()}),le=e.z.enum(["AllExistingSupporters","AllNonSupporters","Everyone","PostAskPauseSingleContributors"]),ue=e.z.object({minViews:e.z.number(),maxViews:e.z.number().optional(),periodInWeeks:e.z.number(),tagIds:e.z.array(e.z.string()).optional()});e.z.object({userType:e.z.array(q),product:e.z.array(Q)}),e.z.object({tagIds:e.z.array(e.z.string()),sectionIds:e.z.array(e.z.string()),excludedTagIds:e.z.array(e.z.string()),excludedSectionIds:e.z.array(e.z.string())});const ce=e.z.object({maxViewsCount:e.z.number(),maxViewsDays:e.z.number(),minDaysBetweenViews:e.z.number()}),de=e.z.object({reminderCta:e.z.string(),reminderLabel:e.z.string(),reminderPeriod:e.z.string()}),pe=e.z.enum(["ONE_OFF","MONTHLY","ANNUAL"]),ge=e.z.object({testName:e.z.string(),variantName:e.z.string(),defaultContributionType:pe,displayContributionType:pe.array(),amountsCardData:e.z.object({ONE_OFF:e.z.object({amounts:e.z.array(e.z.number()),defaultAmount:e.z.number(),hideChooseYourAmount:e.z.boolean().optional()}),MONTHLY:e.z.object({amounts:e.z.array(e.z.number()),defaultAmount:e.z.number(),hideChooseYourAmount:e.z.boolean().optional()}),ANNUAL:e.z.object({amounts:e.z.array(e.z.number()),defaultAmount:e.z.number(),hideChooseYourAmount:e.z.boolean().optional()})})}),ze=e.z.object({newsletterId:e.z.string(),successDescription:e.z.string()}),me=e.z.object({name:e.z.string(),heading:e.z.string().optional(),paragraphs:e.z.array(e.z.string()),highlightedText:e.z.string().optional(),tickerSettings:O.optional(),cta:I.optional(),secondaryCta:G.optional(),newsletterSignup:ze.optional(),image:H.optional(),showReminderFields:de.optional(),separateArticleCount:f.optional(),maxViews:ce.optional(),showSignInLink:e.z.boolean().optional(),bylineWithImage:j.optional(),showChoiceCards:e.z.boolean().optional(),choiceCardAmounts:ge.optional(),defaultChoiceCardFrequency:pe.optional()}),Ce=e.z.object({variant:me,tracking:v,countryCode:e.z.string().nullish(),articleCounts:k,onReminderOpen:e.z.any().nullish(),fetchEmail:e.z.any().nullish(),submitComponentEvent:e.z.any().nullish(),openCmp:e.z.any().nullish(),hasConsentForArticleCount:e.z.boolean().nullish(),stage:e.z.string().nullish()}),be=e.z.enum(["contributions","subscriptions","signIn","abandonedBasket"]),Se=e.z.object({heading:e.z.string().optional(),messageText:e.z.string().optional(),paragraphs:e.z.array(e.z.string()).optional(),mobileMessageText:e.z.string().optional(),highlightedText:e.z.string().optional(),cta:I.optional(),secondaryCta:G.optional()}),he=e.z.object({tracking:v,bannerChannel:be,content:Se.nullish(),mobileContent:Se.nullish(),countryCode:e.z.string().nullish(),isSupporter:e.z.boolean().nullish(),tickerSettings:O.nullish(),submitComponentEvent:e.z.any(),articleCounts:k,hasOptedOutOfArticleCount:e.z.boolean().nullish(),fetchEmail:e.z.any().nullish(),separateArticleCount:e.z.boolean().nullish(),design:J.nullish()}),ye=e.z.object({heading:e.z.string(),subheading:e.z.string(),primaryCta:I.optional(),secondaryCta:I.optional(),benefits:e.z.array(e.z.string()).optional()}),Ae=e.z.object({content:ye,tracking:v,mobileContent:ye.optional(),countryCode:e.z.string().optional(),submitComponentEvent:e.z.any(),numArticles:e.z.number().optional()}),Te=e.z.object({maxViewsCount:e.z.number(),maxViewsDays:e.z.number(),minDaysBetweenViews:e.z.number()});se.extend({name:e.z.string(),status:ee,locations:e.z.array(l),tagIds:e.z.array(e.z.string()),sections:e.z.array(e.z.string()),excludedTagIds:e.z.array(e.z.string()),excludedSections:e.z.array(e.z.string()),alwaysAsk:e.z.boolean(),maxViews:Te.optional(),userCohort:le,hasCountryName:e.z.boolean(),highPriority:e.z.boolean(),useLocalViewLog:e.z.boolean(),articlesViewedSettings:ue.optional(),priority:e.z.number(),variants:me.array()});const Ie=e.z.object({amount:e.z.union([e.z.number(),e.z.literal("other")]),billingPeriod:e.z.union([e.z.literal("ONE_OFF"),e.z.literal("MONTHLY"),e.z.literal("ANNUAL")]),product:e.z.union([e.z.literal("Contribution"),e.z.literal("SupporterPlus"),e.z.literal("PremiumTier"),e.z.literal("DailyEdition"),e.z.literal("GuardianWeekly"),e.z.literal("Paper"),e.z.literal("PaperAndDigital")]),region:e.z.union([e.z.literal("uk"),e.z.literal("us"),e.z.literal("au"),e.z.literal("eu"),e.z.literal("int"),e.z.literal("nz"),e.z.literal("ca")])}),Ne=(e,n,t)=>{const a=(e=>{if(URLSearchParams){const n=new URLSearchParams(window.location.search).get(`force-${e}`);if(n)return n}return null})(e);return fetch(`${n}/${e}${a?`?force=${a}`:""}`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then((n=>{if(!n.ok)throw Error(n.statusText||`Supporter Revenue ${e} | Api call returned HTTP status ${n.status}`);return n})).then((e=>e.json()))};exports.CountryGroupId=s,exports.SecondaryCtaType=N,exports.TickerCountType=B,exports.TickerEndType=U,exports.abandonedBasketSchema=Ie,exports.addRegionIdToSupportUrl=(e,n)=>{if(n){const t=(e=>u[p(e)]?.supportRegionId)(n);if(t&&!m(e))return e.replace(/(support\.theguardian\.com)\/(contribute-in-epic|contribute|subscribe|checkout)/,((e,n,a)=>`${n}/${t.toLowerCase()}/${a}`))}return e},exports.bannerSchema=he,exports.buildReminderFields=y,exports.containsNonArticleCountPlaceholder=e=>{const n=e.match(S)?.filter((e=>"%%ARTICLE_COUNT%%"!==e));return!!n&&n.length>0},exports.contributionTabFrequencies=["ONE_OFF","MONTHLY","ANNUAL"],exports.countryCodeToCountryGroupId=p,exports.countryGroupIdSchema=l,exports.epicPropsSchema=Ce,exports.getBanner=(e,n)=>Ne("banner",e,n),exports.getCountryName=z,exports.getEpic=(e,n)=>Ne("epic",e,n),exports.getEpicViewLog=e=>e.get(n)||void 0,exports.getHeader=(e,n)=>Ne("header",e,n),exports.getLiveblogEpic=(e,n)=>Ne("liveblog-epic",e,n),exports.getLocalCurrencySymbol=g,exports.getReminderFields=(e,n=new Date)=>{return"US"===e&&T(n)?{reminderCta:"Remind me on Giving Tuesday",reminderPeriod:`${t=n.getFullYear()}-${(h(t).getMonth()+1).toString().padStart(0,"2")}-01`,reminderLabel:"on Giving Tuesday",reminderOption:`giving-tuesday-${t}`}:"US"===e&&(e=>e>=h(e.getFullYear())&&e<A)(n)?(e=>({reminderCta:"Remind me on New Years Eve",reminderPeriod:`${e}-12-01`,reminderLabel:"on New Years Eve",reminderOption:`new-years-eve-${e}`}))(n.getFullYear()):y(n);var t},exports.getWeeklyArticleHistory=e=>e.get(t)||void 0,exports.headerPropsSchema=Ae,exports.hexColourToString=e=>`#${e.r}${e.g}${e.b}`,exports.inCountryGroups=(e,n=[])=>0===n.length||!!e&&n.includes(p(e.toUpperCase())),exports.incrementWeeklyArticleCount=(e,n,r)=>{const s=((e,n)=>{const t=o(new Date),r=e.get(a);if(r&&r.week===t){const o=r.articles[n]||0;return e.set(a,{week:t,articles:{...r.articles,[n]:o+1}}),o>0}return e.set(a,{week:t,articles:{[n]:1}}),!1})(e,n);if(!s){const n=o(new Date),a=e.get(t)||[],s=a[0];if(s&&s.week&&s.week===n)s.count+=1,s.tags=i(r,s.tags),e.set(t,a);else{a.unshift({week:n,count:1,tags:i(r,{})});const o=n-365,s=a.filter((e=>e.week>=o));e.set(t,s)}}},exports.isGWCheckoutUrl=m,exports.logEpicView=e=>{const t=localStorage.getItem(n),a=t?JSON.parse(t).value:[];a.push({date:(new Date).getTime(),testId:e});const o={value:a.slice(-50)};localStorage.setItem(n,JSON.stringify(o))},exports.replaceNonArticleCountPlaceholders=(e,n,t)=>e?e.replace(S,(e=>{const a=e.substring(2,e.length-2),o=b[a];if(o){const e=o({countryCode:n,prices:t});if(e)return e}return e})):"";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("zod");const t="gu.contributions.views",n="gu.history.weeklyArticleCount",a="gu.history.articleCountsThisWeek",o=e=>{const t=e.getDay()||7;return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()-(t-1))/864e5},r=new Set(["environment/climate-change","environment/climate-crisis","environment/environment","science/science","politics/politics","us-news/us-politics","australia-news/australian-politics","world/world","world/europe-news","world/russia","books/books","culture/culture","world/coronavirus-outbreak","world/race","inequality/inequality","technology/technology","business/business","tone/recipes","sport/sport","football/football","sport/olympic-games","sport/olympic-games-2024","tracking/commissioningdesk/uk-investigations"]),i=(e,t={})=>(e.forEach((e=>{r.has(e)&&(t[e]=(t[e]??0)+1)})),t),s=["GBPCountries","UnitedStates","AUDCountries","EURCountries","International","NZDCountries","Canada"],l=e.z.enum(s),u={GBPCountries:{name:"United Kingdom",currency:"GBP",countries:["GB","FK","GI","GG","IM","JE","SH"],supportRegionId:"UK"},UnitedStates:{name:"United States",currency:"USD",countries:["US"],supportRegionId:"US"},AUDCountries:{name:"Australia",currency:"AUD",countries:["AU","KI","NR","NF","TV"],supportRegionId:"AU"},EURCountries:{name:"Europe",currency:"EUR",countries:["AD","AL","AT","BA","BE","BG","BL","CH","CY","CZ","DE","DK","EE","ES","FI","FO","FR","GF","GL","GP","GR","HR","HU","IE","IT","LI","LT","LU","LV","MC","ME","MF","IS","MQ","MT","NL","NO","PF","PL","PM","PT","RE","RO","RS","SE","SI","SJ","SK","SM","TF","TR","WF","YT","VA","AX","AZ","AM","GE","BY","MD","UA","MK"],supportRegionId:"EU"},International:{name:"International",currency:"USD",countries:["AE","AF","AG","AI","AO","AQ","AR","AS","AW","BB","BD","BF","BH","BI","BJ","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BZ","CC","CD","CF","CG","CI","CL","CM","CN","CO","CR","CU","CV","CW","CX","DJ","DM","DO","DZ","EC","EG","EH","ER","ET","FJ","FM","GA","GD","GH","GM","GN","GQ","GS","GT","GU","GW","GY","HK","HM","HN","HT","ID","IL","IN","IO","IQ","IR","JM","JO","JP","KE","KG","KH","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LK","LR","LS","LY","MA","MG","MH","ML","MM","MN","MO","MP","MR","MS","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NG","NI","NP","NU","OM","PA","PE","PG","PH","PK","PN","PR","PS","PW","PY","QA","RU","RW","SA","SB","SC","SD","SG","SL","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TG","TH","TJ","TK","TL","TM","TN","TO","TT","TW","TZ","UG","UM","UY","UZ","VC","VE","VG","VI","VN","VU","WS","YE","ZA","ZM","ZW"],supportRegionId:"INT"},NZDCountries:{name:"New Zealand",currency:"NZD",countries:["NZ","CK"],supportRegionId:"NZ"},Canada:{name:"Canada",currency:"CAD",countries:["CA"],supportRegionId:"CA"}},c={AD:"Andorra",AE:"the UAE",AF:"Afghanistan",AG:"Antigua and Barbuda",AI:"Anguilla",AL:"Albania",AM:"Armenia",AO:"Angola",AR:"Argentina",AS:"the US",AT:"Austria",AU:"Australia",AW:"Aruba",AX:"Åland Islands",AZ:"Azerbaijan",BA:"Bosnia and Herzegovina",BB:"Barbados",BD:"Bangladesh",BE:"Belgium",BF:"Burkina Faso",BG:"Bulgaria",BH:"Bahrain",BI:"Burundi",BJ:"Benin",BL:"Saint Barthélemy",BM:"Bermuda",BN:"Brunei Darussalam",BO:"Bolivia",BQ:"Bonaire, Sint Eustatius and Saba",BR:"Brazil",BS:"the Bahamas",BT:"Bhutan",BV:"Bouvet Island",BW:"Botswana",BY:"Belarus",BZ:"Belize",CA:"Canada",CD:"the Democratic Republic of the Congo",CF:"the Central Africa Republic",CG:"the Congo",CH:"Switzerland",CI:"Côte d'Ivoire",CK:"the Cook Islands",CL:"Chile",CM:"Cameroon",CN:"China",CO:"Colombia",CR:"Costa Rica",CU:"Cuba",CV:"Cabo Verde",CW:"Curaçao",CX:"Christmas Island",CY:"Cyprus",CZ:"the Czech Republic",DE:"Germany",DJ:"Djibouti",DK:"Denmark",DM:"Dominica",DO:"the Dominican Republic",DZ:"Algeria",EC:"Ecuador",EE:"Estonia",EG:"Egypt",EH:"the Western Sahara",ER:"Eritrea",ES:"Spain",ET:"Ethiopia",FI:"Finland",FJ:"Fiji",FK:"the UK",FO:"the UK",FR:"France",GA:"Gabon",GB:"the UK",GD:"Grenada",GE:"Georgia",GF:"French Guiana",GG:"Guernsey",GH:"Ghana",GI:"Gibraltar",GL:"Greenland",GM:"the Gambia",GN:"Guinea",GP:"Guadeloupe",GQ:"Equatorial Guinea",GR:"Greece",GT:"Guatemala",GU:"Guam",GW:"Guinea-Bissau",GY:"Guyana",HK:"Hong Kong",HN:"Honduras",HR:"Croatia",HT:"Haiti",HU:"Hungary",ID:"Indonesia",IE:"Ireland",IM:"the Isle of Man",IN:"India",IQ:"Iraq",IR:"Iran",IS:"Iceland",IT:"Italy",JE:"Jersey",JM:"Jamaica",JO:"Jordan",JP:"Japan",KE:"Kenya",KG:"Kyrgyzstan",KH:"Cambodia",KI:"Kiribati",KN:"Saint Kitts and Nevis",KP:"Korea",KR:"Korea",KW:"Kuwait",KY:"the Cayman Ialnds",KZ:"Kazakhstan",LB:"Lebanon",LC:"Saint Lucia",LI:"Liechtenstein",LK:"Sri Lanka",LR:"Liberia",LS:"Lesotho",LT:"Lithuania",LU:"Luxembourg",LV:"Latvia",LY:"Libya",MA:"Morocco",MC:"Monaco",MD:"Moldova",ME:"Montenegro",MG:"Madagascar",MK:"the Republic of North Macedonia",ML:"Mali",MM:"Myanmar",MN:"Mongolia",MO:"Macao",MQ:"Martinique",MR:"Mauritania",MS:"Montserrat",MT:"Malta",MU:"Mauritius",MV:"Maldives",MW:"Malawi",MX:"Mexico",MY:"Malaysia",MZ:"Mozambique",NA:"Namibia",NC:"New Caledonia",NE:"Niger",NF:"Norfolk Island",NG:"Nigeria",NI:"Nicaragua",NL:"the Netherlands",NO:"Norway",NP:"Nepal",NR:"Nauru",NU:"Niue",NZ:"New Zealand",OM:"Oman",PA:"Panama",PE:"Peru",PF:"French Polynesia",PG:"Papua New Guinea",PH:"the Philippines",PK:"Pakistan",PL:"Poland",PM:"Saint Pierre and Miquelon",PN:"Pitcairn",PR:"Puerto Rico",PT:"Portugal",PW:"Palau",PY:"Paraguay",QA:"Qatar",RE:"Réunion",RO:"Romania",RU:"Russia",RW:"Rwanda",SA:"Saudi Arabia",SB:"Solomon Islands",SC:"Seychelles",SD:"Sudan",SE:"Sweden",SG:"Singapore",SH:"Saint Helena",SI:"Slovenia",SJ:"Svalbard and Jan Mayen",SK:"Slovakia",SL:"Sierra Leone",SM:"San Marino",SN:"Senegal",SO:"Somalia",SR:"Suriname",SS:"South Sudan",ST:"Sao Tome and Principe",SV:"El Salvador",SY:"Syrian Arab Republic",SZ:"Eswatini",TD:"Chad",TG:"Togo",TH:"Thailand",TJ:"Tajikistan",TK:"Tokelau",TL:"Timor-Leste",TM:"Turkmenistan",TN:"Tunisia",TO:"Tonga",TR:"Turkey",TT:"Trinidad and Tobago",TV:"Tuvalu",TW:"Taiwan",TZ:"Tanzania ",UG:"Uganda",US:"the US",UY:"Uruguay",UZ:"Uzbekistan",VC:"Saint Vincent and the Grenadines",VE:"Venezuela",VG:"the Virgin Islands",VI:"the Virgin Islands",VN:"Vietnam",VU:"Vanuatu",WF:"Wallis and Futuna",WS:"Samoa",YE:"Yemen",YT:"Mayotte",ZA:"South Africa",ZM:"Zambia",ZW:"Zimbabwe"},d={GBPCountries:"£",UnitedStates:"$",AUDCountries:"$",Canada:"CA$",EURCountries:"€",NZDCountries:"NZ$",International:"$"},p=e=>Object.keys(u).find((t=>u[t].countries.includes(e??"")))||"International",g=e=>{if(e){const t=p(e);return d[t]}return"£"},z=e=>{if(e)return c[e]},m=e=>/subscribe\/weekly\/checkout/.test(e),C=(e,t,n,a)=>{if(a){const o=a[p(n)];if(o){return`${g(n)}${o[e][t].price}`}}},b={CURRENCY_SYMBOL:({countryCode:e})=>g(e),COUNTRY_NAME:({countryCode:e})=>z(e),PRICE_DIGISUB_MONTHLY:({countryCode:e,prices:t})=>C("Digisub","Monthly",e,t),PRICE_DIGISUB_ANNUAL:({countryCode:e,prices:t})=>C("Digisub","Annual",e,t),PRICE_GUARDIANWEEKLY_MONTHLY:({countryCode:e,prices:t})=>C("GuardianWeekly","Monthly",e,t),PRICE_GUARDIANWEEKLY_ANNUAL:({countryCode:e,prices:t})=>C("GuardianWeekly","Annual",e,t),DAY_OF_THE_WEEK:()=>((e=new Date)=>e.toLocaleString("en-GB",{weekday:"long"}))(),DATE:()=>((e=new Date)=>e.toLocaleString("en-GB",{day:"numeric",month:"long",year:"numeric"}))()},S=/%%.*?%%/g,h=e=>{const t=(e=>{const t=new Date(e,10,1).getDay();return new Date(e,10,22+(11-t)%7)})(e);return t.setDate(t.getDate()+5),t},y=(e=new Date)=>{const t=(e=>{const t=e.getDate()<20?1:2;return e.setMonth(e.getMonth()+t),e})(e),n=(t.getMonth()+1).toString().padStart(2,"0"),a=t.toLocaleString("default",{month:"long"}),o=t.getFullYear();return{reminderCta:`Remind me in ${a}`,reminderPeriod:`${o}-${n}-01`,reminderLabel:`${a} ${o}`}},A=new Date("2023-12-31"),T=e=>e>=(e=>new Date(e.getFullYear(),9,20))(e)&&e<h(e.getFullYear()),I=e.z.object({text:e.z.string(),baseUrl:e.z.string()});let N=function(e){return e.Custom="CustomSecondaryCta",e.ContributionsReminder="ContributionsReminderSecondaryCta",e}({});e.z.nativeEnum(N);const M=e.z.object({type:e.z.literal(N.Custom),cta:I}),E=e.z.object({type:e.z.literal(N.ContributionsReminder)}),G=e.z.discriminatedUnion("type",[M,E]);let U=function(e){return e.unlimited="unlimited",e.hardstop="hardstop",e}({});const R=e.z.nativeEnum(U);let B=function(e){return e.money="money",e}({});const P=e.z.nativeEnum(B),L=e.z.object({countLabel:e.z.string(),goalReachedPrimary:e.z.string().optional(),goalReachedSecondary:e.z.string().optional()}),D=e.z.object({total:e.z.number(),goal:e.z.number()}),w=e.z.enum(["US","AU"]),k=e.z.object({endType:R,countType:P,currencySymbol:e.z.string(),copy:L,name:w,tickerData:D.optional()}),O=e.z.object({for52Weeks:e.z.number(),forTargetedWeeks:e.z.number()}),x=e.z.enum(["for52Weeks","forTargetedWeeks"]),f=e.z.object({type:e.z.literal("above"),copy:e.z.string().optional(),countType:x.optional()}),v=e.z.enum(["CONTRIBUTION","MEMBERSHIP_SUPPORTER","DIGITAL_SUBSCRIPTION","PRINT_SUBSCRIPTION"]),F=e.z.enum(["ACQUISITIONS_EPIC","ACQUISITIONS_ENGAGEMENT_BANNER","ACQUISITIONS_SUBSCRIPTIONS_BANNER","ACQUISITIONS_HEADER","ACQUISITIONS_OTHER"]),K=e.z.object({abTestName:e.z.string(),abTestVariant:e.z.string(),campaignCode:e.z.string(),componentType:F,products:e.z.array(v).nullish(),labels:e.z.array(e.z.string()).nullish(),ophanPageId:e.z.string(),platformId:e.z.string(),referrerUrl:e.z.string(),clientName:e.z.string()}),j=e.z.object({mainUrl:e.z.string(),mobileUrl:e.z.string().optional(),tabletUrl:e.z.string().optional(),desktopUrl:e.z.string().optional(),leftColUrl:e.z.string().optional(),wideUrl:e.z.string().optional(),altText:e.z.string()}),H=e.z.object({name:e.z.string(),description:e.z.string().optional(),headshot:j.optional()}),V=/^[0-9A-F]{2}$/,Y=e.z.string().refine((e=>V.test(e)),(e=>({message:`"${e}" is not a valid hex value`}))),W=e.z.object({r:Y,g:Y,b:Y,kind:e.z.literal("hex")}),Z=e.z.object({mobileUrl:e.z.string(),tabletUrl:e.z.string(),desktopUrl:e.z.string(),altText:e.z.string(),kind:e.z.literal("Image")}),$=e.z.object({buttonColour:W.nullish(),buttonTextColour:W.nullish(),buttonBorderColour:W.nullish(),buttonSelectColour:W.nullish(),buttonSelectTextColour:W.nullish(),buttonSelectBorderColour:W.nullish(),kind:e.z.literal("ChoiceCards")}),_=e.z.discriminatedUnion("kind",[Z,$]),J=e.z.object({visual:_.nullish(),colours:e.z.object({basic:e.z.object({background:W,bodyText:W})})}),Q=e.z.enum(["Contribution","SupporterPlus","GuardianWeekly","Paper"]),q=e.z.enum(["new","guest","current"]),X=e.z.enum(["Epic","EpicAMP","EpicAppleNews","EpicLiveblog","Banner1","Banner2","Header","GutterLiveblog"]),ee=e.z.enum(["Live","Draft","Archived"]),te=e.z.enum(["Mobile","Desktop","All","iOS","Android"]),ne=e.z.enum(["SignedIn","SignedOut","All"]),ae=e.z.enum(["HasConsented","HasNotConsented","All"]),oe=e.z.object({name:e.z.literal("ABTest")}),re=e.z.object({name:e.z.literal("EpsilonGreedyBandit"),epsilon:e.z.number(),sampleCount:e.z.number().optional()}),ie=e.z.object({name:e.z.literal("Roulette"),sampleCount:e.z.number().optional()}),se=e.z.intersection(e.z.discriminatedUnion("name",[oe,re,ie]),e.z.object({testName:e.z.string().optional()})),le=e.z.object({channel:X,name:e.z.string(),status:ee,priority:e.z.number(),controlProportionSettings:e.z.object({proportion:e.z.number(),offset:e.z.number()}).optional(),deviceType:te.optional(),signedInStatus:ne.optional(),consentStatus:ae.optional(),methodologies:se.array().optional()}),ue=e.z.enum(["AllExistingSupporters","AllNonSupporters","Everyone","PostAskPauseSingleContributors"]),ce=e.z.object({minViews:e.z.number(),maxViews:e.z.number().optional(),periodInWeeks:e.z.number(),tagIds:e.z.array(e.z.string()).optional()});e.z.object({userType:e.z.array(q),product:e.z.array(Q)}),e.z.object({tagIds:e.z.array(e.z.string()),sectionIds:e.z.array(e.z.string()),excludedTagIds:e.z.array(e.z.string()),excludedSectionIds:e.z.array(e.z.string())});const de=e.z.object({maxViewsCount:e.z.number(),maxViewsDays:e.z.number(),minDaysBetweenViews:e.z.number()}),pe=e.z.object({reminderCta:e.z.string(),reminderLabel:e.z.string(),reminderPeriod:e.z.string()}),ge=e.z.enum(["ONE_OFF","MONTHLY","ANNUAL"]),ze=e.z.object({testName:e.z.string(),variantName:e.z.string(),defaultContributionType:ge,displayContributionType:ge.array(),amountsCardData:e.z.object({ONE_OFF:e.z.object({amounts:e.z.array(e.z.number()),defaultAmount:e.z.number(),hideChooseYourAmount:e.z.boolean().optional()}),MONTHLY:e.z.object({amounts:e.z.array(e.z.number()),defaultAmount:e.z.number(),hideChooseYourAmount:e.z.boolean().optional()}),ANNUAL:e.z.object({amounts:e.z.array(e.z.number()),defaultAmount:e.z.number(),hideChooseYourAmount:e.z.boolean().optional()})})}),me=e.z.object({newsletterId:e.z.string(),successDescription:e.z.string()}),Ce=e.z.object({name:e.z.string(),heading:e.z.string().optional(),paragraphs:e.z.array(e.z.string()),highlightedText:e.z.string().optional(),tickerSettings:k.optional(),cta:I.optional(),secondaryCta:G.optional(),newsletterSignup:me.optional(),image:j.optional(),showReminderFields:pe.optional(),separateArticleCount:f.optional(),maxViews:de.optional(),showSignInLink:e.z.boolean().optional(),bylineWithImage:H.optional(),showChoiceCards:e.z.boolean().optional(),choiceCardAmounts:ze.optional(),defaultChoiceCardFrequency:ge.optional()}),be=e.z.object({variant:Ce,tracking:K,countryCode:e.z.string().nullish(),articleCounts:O,onReminderOpen:e.z.any().nullish(),fetchEmail:e.z.any().nullish(),submitComponentEvent:e.z.any().nullish(),openCmp:e.z.any().nullish(),hasConsentForArticleCount:e.z.boolean().nullish(),stage:e.z.string().nullish()}),Se=e.z.enum(["contributions","subscriptions","signIn","abandonedBasket"]),he=e.z.object({heading:e.z.string().optional(),messageText:e.z.string().optional(),paragraphs:e.z.array(e.z.string()).optional(),mobileMessageText:e.z.string().optional(),highlightedText:e.z.string().optional(),cta:I.optional(),secondaryCta:G.optional()}),ye=e.z.object({tracking:K,bannerChannel:Se,content:he.nullish(),mobileContent:he.nullish(),countryCode:e.z.string().nullish(),isSupporter:e.z.boolean().nullish(),tickerSettings:k.nullish(),submitComponentEvent:e.z.any(),articleCounts:O,hasOptedOutOfArticleCount:e.z.boolean().nullish(),fetchEmail:e.z.any().nullish(),separateArticleCount:e.z.boolean().nullish(),design:J.nullish()}),Ae=e.z.object({heading:e.z.string(),subheading:e.z.string(),primaryCta:I.optional(),secondaryCta:I.optional(),benefits:e.z.array(e.z.string()).optional()}),Te=e.z.object({content:Ae,tracking:K,mobileContent:Ae.optional(),countryCode:e.z.string().optional(),submitComponentEvent:e.z.any(),numArticles:e.z.number().optional()}),Ie=e.z.object({image:j,bodyCopy:e.z.array(e.z.string()),cta:I.optional()});e.z.object({content:Ie,tracking:K,countryCode:e.z.string().optional(),submitComponentEvent:e.z.any()});const Ne=e.z.object({maxViewsCount:e.z.number(),maxViewsDays:e.z.number(),minDaysBetweenViews:e.z.number()});le.extend({name:e.z.string(),status:ee,locations:e.z.array(l),tagIds:e.z.array(e.z.string()),sections:e.z.array(e.z.string()),excludedTagIds:e.z.array(e.z.string()),excludedSections:e.z.array(e.z.string()),alwaysAsk:e.z.boolean(),maxViews:Ne.optional(),userCohort:ue,hasCountryName:e.z.boolean(),highPriority:e.z.boolean(),useLocalViewLog:e.z.boolean(),articlesViewedSettings:ce.optional(),priority:e.z.number(),variants:Ce.array()});const Me=e.z.object({amount:e.z.union([e.z.number(),e.z.literal("other")]),billingPeriod:e.z.union([e.z.literal("ONE_OFF"),e.z.literal("MONTHLY"),e.z.literal("ANNUAL")]),product:e.z.union([e.z.literal("Contribution"),e.z.literal("SupporterPlus"),e.z.literal("PremiumTier"),e.z.literal("DailyEdition"),e.z.literal("GuardianWeekly"),e.z.literal("Paper"),e.z.literal("PaperAndDigital")]),region:e.z.union([e.z.literal("uk"),e.z.literal("us"),e.z.literal("au"),e.z.literal("eu"),e.z.literal("int"),e.z.literal("nz"),e.z.literal("ca")])}),Ee=(e,t,n)=>{const a=(e=>{if(URLSearchParams){const t=new URLSearchParams(window.location.search).get(`force-${e}`);if(t)return t}return null})(e);return fetch(`${t}/${e}${a?`?force=${a}`:""}`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}).then((t=>{if(!t.ok)throw Error(t.statusText||`Supporter Revenue ${e} | Api call returned HTTP status ${t.status}`);return t})).then((e=>e.json()))};exports.CountryGroupId=s,exports.SecondaryCtaType=N,exports.TickerCountType=B,exports.TickerEndType=U,exports.abandonedBasketSchema=Me,exports.addRegionIdToSupportUrl=(e,t)=>{if(t){const n=(e=>u[p(e)]?.supportRegionId)(t);if(n&&!m(e))return e.replace(/(support\.theguardian\.com)\/(contribute-in-epic|contribute|subscribe|checkout)/,((e,t,a)=>`${t}/${n.toLowerCase()}/${a}`))}return e},exports.bannerSchema=ye,exports.buildReminderFields=y,exports.containsNonArticleCountPlaceholder=e=>{const t=e.match(S)?.filter((e=>"%%ARTICLE_COUNT%%"!==e));return!!t&&t.length>0},exports.contributionTabFrequencies=["ONE_OFF","MONTHLY","ANNUAL"],exports.countryCodeToCountryGroupId=p,exports.countryGroupIdSchema=l,exports.epicPropsSchema=be,exports.getBanner=(e,t)=>Ee("banner",e,t),exports.getCountryName=z,exports.getEpic=(e,t)=>Ee("epic",e,t),exports.getEpicViewLog=e=>e.get(t)||void 0,exports.getGutterLiveblog=(e,t)=>Ee("gutter-liveblog",e,t),exports.getHeader=(e,t)=>Ee("header",e,t),exports.getLiveblogEpic=(e,t)=>Ee("liveblog-epic",e,t),exports.getLocalCurrencySymbol=g,exports.getReminderFields=(e,t=new Date)=>{return"US"===e&&T(t)?{reminderCta:"Remind me on Giving Tuesday",reminderPeriod:`${n=t.getFullYear()}-${(h(n).getMonth()+1).toString().padStart(0,"2")}-01`,reminderLabel:"on Giving Tuesday",reminderOption:`giving-tuesday-${n}`}:"US"===e&&(e=>e>=h(e.getFullYear())&&e<A)(t)?(e=>({reminderCta:"Remind me on New Years Eve",reminderPeriod:`${e}-12-01`,reminderLabel:"on New Years Eve",reminderOption:`new-years-eve-${e}`}))(t.getFullYear()):y(t);var n},exports.getWeeklyArticleHistory=e=>e.get(n)||void 0,exports.headerPropsSchema=Te,exports.hexColourToString=e=>`#${e.r}${e.g}${e.b}`,exports.inCountryGroups=(e,t=[])=>0===t.length||!!e&&t.includes(p(e.toUpperCase())),exports.incrementWeeklyArticleCount=(e,t,r)=>{const s=((e,t)=>{const n=o(new Date),r=e.get(a);if(r&&r.week===n){const o=r.articles[t]||0;return e.set(a,{week:n,articles:{...r.articles,[t]:o+1}}),o>0}return e.set(a,{week:n,articles:{[t]:1}}),!1})(e,t);if(!s){const t=o(new Date),a=e.get(n)||[],s=a[0];if(s&&s.week&&s.week===t)s.count+=1,s.tags=i(r,s.tags),e.set(n,a);else{a.unshift({week:t,count:1,tags:i(r,{})});const o=t-365,s=a.filter((e=>e.week>=o));e.set(n,s)}}},exports.isGWCheckoutUrl=m,exports.logEpicView=e=>{const n=localStorage.getItem(t),a=n?JSON.parse(n).value:[];a.push({date:(new Date).getTime(),testId:e});const o={value:a.slice(-50)};localStorage.setItem(t,JSON.stringify(o))},exports.replaceNonArticleCountPlaceholders=(e,t,n)=>e?e.replace(S,(e=>{const a=e.substring(2,e.length-2),o=b[a];if(o){const e=o({countryCode:t,prices:n});if(e)return e}return e})):"";
|
|
@@ -432,7 +432,7 @@ export interface BannerTest extends BannerTestFromTool {
|
|
|
432
432
|
variants: BannerVariant[];
|
|
433
433
|
}
|
|
434
434
|
export declare const bannerTestFromToolSchema: z.ZodObject<{
|
|
435
|
-
channel: z.ZodEnum<["Epic", "EpicAMP", "EpicAppleNews", "EpicLiveblog", "Banner1", "Banner2", "Header"]>;
|
|
435
|
+
channel: z.ZodEnum<["Epic", "EpicAMP", "EpicAppleNews", "EpicLiveblog", "Banner1", "Banner2", "Header", "GutterLiveblog"]>;
|
|
436
436
|
priority: z.ZodNumber;
|
|
437
437
|
name: z.ZodString;
|
|
438
438
|
status: z.ZodEnum<["Live", "Draft", "Archived"]>;
|
|
@@ -458,12 +458,24 @@ export declare const bannerTestFromToolSchema: z.ZodObject<{
|
|
|
458
458
|
}>, z.ZodObject<{
|
|
459
459
|
name: z.ZodLiteral<"EpsilonGreedyBandit">;
|
|
460
460
|
epsilon: z.ZodNumber;
|
|
461
|
+
sampleCount: z.ZodOptional<z.ZodNumber>;
|
|
461
462
|
}, "strip", z.ZodTypeAny, {
|
|
462
463
|
name: "EpsilonGreedyBandit";
|
|
463
464
|
epsilon: number;
|
|
465
|
+
sampleCount?: number | undefined;
|
|
464
466
|
}, {
|
|
465
467
|
name: "EpsilonGreedyBandit";
|
|
466
468
|
epsilon: number;
|
|
469
|
+
sampleCount?: number | undefined;
|
|
470
|
+
}>, z.ZodObject<{
|
|
471
|
+
name: z.ZodLiteral<"Roulette">;
|
|
472
|
+
sampleCount: z.ZodOptional<z.ZodNumber>;
|
|
473
|
+
}, "strip", z.ZodTypeAny, {
|
|
474
|
+
name: "Roulette";
|
|
475
|
+
sampleCount?: number | undefined;
|
|
476
|
+
}, {
|
|
477
|
+
name: "Roulette";
|
|
478
|
+
sampleCount?: number | undefined;
|
|
467
479
|
}>]>, z.ZodObject<{
|
|
468
480
|
testName: z.ZodOptional<z.ZodString>;
|
|
469
481
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -902,7 +914,7 @@ export declare const bannerTestFromToolSchema: z.ZodObject<{
|
|
|
902
914
|
daysBetween: number;
|
|
903
915
|
}>>;
|
|
904
916
|
}, "strip", z.ZodTypeAny, {
|
|
905
|
-
channel: "Epic" | "EpicAMP" | "EpicAppleNews" | "EpicLiveblog" | "Banner1" | "Banner2" | "Header";
|
|
917
|
+
channel: "Epic" | "EpicAMP" | "EpicAppleNews" | "EpicLiveblog" | "Banner1" | "Banner2" | "Header" | "GutterLiveblog";
|
|
906
918
|
priority: number;
|
|
907
919
|
name: string;
|
|
908
920
|
status: "Live" | "Draft" | "Archived";
|
|
@@ -995,6 +1007,10 @@ export declare const bannerTestFromToolSchema: z.ZodObject<{
|
|
|
995
1007
|
} | {
|
|
996
1008
|
name: "EpsilonGreedyBandit";
|
|
997
1009
|
epsilon: number;
|
|
1010
|
+
sampleCount?: number | undefined;
|
|
1011
|
+
} | {
|
|
1012
|
+
name: "Roulette";
|
|
1013
|
+
sampleCount?: number | undefined;
|
|
998
1014
|
}) & {
|
|
999
1015
|
testName?: string | undefined;
|
|
1000
1016
|
})[] | undefined;
|
|
@@ -1008,7 +1024,7 @@ export declare const bannerTestFromToolSchema: z.ZodObject<{
|
|
|
1008
1024
|
daysBetween: number;
|
|
1009
1025
|
} | undefined;
|
|
1010
1026
|
}, {
|
|
1011
|
-
channel: "Epic" | "EpicAMP" | "EpicAppleNews" | "EpicLiveblog" | "Banner1" | "Banner2" | "Header";
|
|
1027
|
+
channel: "Epic" | "EpicAMP" | "EpicAppleNews" | "EpicLiveblog" | "Banner1" | "Banner2" | "Header" | "GutterLiveblog";
|
|
1012
1028
|
priority: number;
|
|
1013
1029
|
name: string;
|
|
1014
1030
|
status: "Live" | "Draft" | "Archived";
|
|
@@ -1101,6 +1117,10 @@ export declare const bannerTestFromToolSchema: z.ZodObject<{
|
|
|
1101
1117
|
} | {
|
|
1102
1118
|
name: "EpsilonGreedyBandit";
|
|
1103
1119
|
epsilon: number;
|
|
1120
|
+
sampleCount?: number | undefined;
|
|
1121
|
+
} | {
|
|
1122
|
+
name: "Roulette";
|
|
1123
|
+
sampleCount?: number | undefined;
|
|
1104
1124
|
}) & {
|
|
1105
1125
|
testName?: string | undefined;
|
|
1106
1126
|
})[] | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner.d.ts","sourceRoot":"","sources":["../../../../src/shared/types/abTests/banner.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,aAAa,EAEb,kBAAkB,EAGrB,MAAM,UAAU,CAAC;AAClB,OAAO,EAGH,eAAe,EAGlB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWnC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,MAAM,MAAM,oBAAoB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,kBAAkB,CAAC"}
|
|
@@ -70,7 +70,7 @@ export interface EpicTest extends EpicTestFromTool {
|
|
|
70
70
|
expiry?: string;
|
|
71
71
|
}
|
|
72
72
|
export declare const epicTestFromToolSchema: z.ZodObject<{
|
|
73
|
-
channel: z.ZodEnum<["Epic", "EpicAMP", "EpicAppleNews", "EpicLiveblog", "Banner1", "Banner2", "Header"]>;
|
|
73
|
+
channel: z.ZodEnum<["Epic", "EpicAMP", "EpicAppleNews", "EpicLiveblog", "Banner1", "Banner2", "Header", "GutterLiveblog"]>;
|
|
74
74
|
controlProportionSettings: z.ZodOptional<z.ZodObject<{
|
|
75
75
|
proportion: z.ZodNumber;
|
|
76
76
|
offset: z.ZodNumber;
|
|
@@ -93,12 +93,24 @@ export declare const epicTestFromToolSchema: z.ZodObject<{
|
|
|
93
93
|
}>, z.ZodObject<{
|
|
94
94
|
name: z.ZodLiteral<"EpsilonGreedyBandit">;
|
|
95
95
|
epsilon: z.ZodNumber;
|
|
96
|
+
sampleCount: z.ZodOptional<z.ZodNumber>;
|
|
96
97
|
}, "strip", z.ZodTypeAny, {
|
|
97
98
|
name: "EpsilonGreedyBandit";
|
|
98
99
|
epsilon: number;
|
|
100
|
+
sampleCount?: number | undefined;
|
|
99
101
|
}, {
|
|
100
102
|
name: "EpsilonGreedyBandit";
|
|
101
103
|
epsilon: number;
|
|
104
|
+
sampleCount?: number | undefined;
|
|
105
|
+
}>, z.ZodObject<{
|
|
106
|
+
name: z.ZodLiteral<"Roulette">;
|
|
107
|
+
sampleCount: z.ZodOptional<z.ZodNumber>;
|
|
108
|
+
}, "strip", z.ZodTypeAny, {
|
|
109
|
+
name: "Roulette";
|
|
110
|
+
sampleCount?: number | undefined;
|
|
111
|
+
}, {
|
|
112
|
+
name: "Roulette";
|
|
113
|
+
sampleCount?: number | undefined;
|
|
102
114
|
}>]>, z.ZodObject<{
|
|
103
115
|
testName: z.ZodOptional<z.ZodString>;
|
|
104
116
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -706,7 +718,7 @@ export declare const epicTestFromToolSchema: z.ZodObject<{
|
|
|
706
718
|
defaultChoiceCardFrequency?: "ONE_OFF" | "MONTHLY" | "ANNUAL" | undefined;
|
|
707
719
|
}>, "many">;
|
|
708
720
|
}, "strip", z.ZodTypeAny, {
|
|
709
|
-
channel: "Epic" | "EpicAMP" | "EpicAppleNews" | "EpicLiveblog" | "Banner1" | "Banner2" | "Header";
|
|
721
|
+
channel: "Epic" | "EpicAMP" | "EpicAppleNews" | "EpicLiveblog" | "Banner1" | "Banner2" | "Header" | "GutterLiveblog";
|
|
710
722
|
priority: number;
|
|
711
723
|
name: string;
|
|
712
724
|
status: "Live" | "Draft" | "Archived";
|
|
@@ -833,6 +845,10 @@ export declare const epicTestFromToolSchema: z.ZodObject<{
|
|
|
833
845
|
} | {
|
|
834
846
|
name: "EpsilonGreedyBandit";
|
|
835
847
|
epsilon: number;
|
|
848
|
+
sampleCount?: number | undefined;
|
|
849
|
+
} | {
|
|
850
|
+
name: "Roulette";
|
|
851
|
+
sampleCount?: number | undefined;
|
|
836
852
|
}) & {
|
|
837
853
|
testName?: string | undefined;
|
|
838
854
|
})[] | undefined;
|
|
@@ -848,7 +864,7 @@ export declare const epicTestFromToolSchema: z.ZodObject<{
|
|
|
848
864
|
tagIds?: string[] | undefined;
|
|
849
865
|
} | undefined;
|
|
850
866
|
}, {
|
|
851
|
-
channel: "Epic" | "EpicAMP" | "EpicAppleNews" | "EpicLiveblog" | "Banner1" | "Banner2" | "Header";
|
|
867
|
+
channel: "Epic" | "EpicAMP" | "EpicAppleNews" | "EpicLiveblog" | "Banner1" | "Banner2" | "Header" | "GutterLiveblog";
|
|
852
868
|
priority: number;
|
|
853
869
|
name: string;
|
|
854
870
|
status: "Live" | "Draft" | "Archived";
|
|
@@ -975,6 +991,10 @@ export declare const epicTestFromToolSchema: z.ZodObject<{
|
|
|
975
991
|
} | {
|
|
976
992
|
name: "EpsilonGreedyBandit";
|
|
977
993
|
epsilon: number;
|
|
994
|
+
sampleCount?: number | undefined;
|
|
995
|
+
} | {
|
|
996
|
+
name: "Roulette";
|
|
997
|
+
sampleCount?: number | undefined;
|
|
978
998
|
}) & {
|
|
979
999
|
testName?: string | undefined;
|
|
980
1000
|
})[] | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epic.d.ts","sourceRoot":"","sources":["../../../../src/shared/types/abTests/epic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAwB,MAAM,WAAW,CAAC;AAOjE,OAAO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