@washingtonpost/subs-de-inputs 1.0.0-react18.12g → 1.0.0-react18.2

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.
@@ -4,7 +4,7 @@ interface DESelectProps {
4
4
  source: string;
5
5
  fieldName: string;
6
6
  label?: string;
7
- dataDictionaryConfig?: Attribute | Readonly<Attribute>;
7
+ dataDictionaryConfig?: Attribute;
8
8
  defaultValue?: string;
9
9
  disabled?: boolean;
10
10
  submit: boolean;
package/dist/index.d.ts CHANGED
@@ -4,4 +4,3 @@ export * from './utils/hasRequiredPrivacyCookies';
4
4
  export * from './utils/push';
5
5
  export * from './services/getAttributes';
6
6
  export * from './components/DESelect';
7
- export * from './components/DEDisclosure';
@@ -13,12 +13,12 @@ export type Attribute = {
13
13
  name: string;
14
14
  approved_for_use?: boolean;
15
15
  collection_behavior?: (typeof CollectionBehaviors)[keyof typeof CollectionBehaviors];
16
- datatype: string;
16
+ datatype: 'string';
17
17
  explicit: boolean;
18
18
  multiple_value: boolean;
19
19
  last_modified_date: Number;
20
20
  date_created: Number;
21
- values: AttributeValue[] | Readonly<AttributeValue[]>;
21
+ values: Array<AttributeValue>;
22
22
  };
23
23
  export declare const AttributesState: {
24
24
  readonly SUCCESS: "100";
@@ -1,4 +1,4 @@
1
- import type { ResponseStatusType } from '@washingtonpost/subs-sdk';
1
+ import { ResponseStatus } from '@washingtonpost/subs-sdk';
2
2
  import { IngestResponseState, IngestType } from '../interfaces';
3
3
  export declare const ingest: IngestType;
4
4
  type IngestType = ({ submitData: { fieldName, value }, source, }: {
@@ -8,7 +8,7 @@ type IngestType = ({ submitData: { fieldName, value }, source, }: {
8
8
  };
9
9
  source: string;
10
10
  }) => Promise<{
11
- status: ResponseStatusType;
11
+ status: ResponseStatus;
12
12
  state: (typeof IngestResponseState)[keyof typeof IngestResponseState];
13
13
  } | null>;
14
14
  export {};
@@ -33,45 +33,14 @@ const IngestResponseState = {
33
33
  DO_NOT_COLLECT: '110'
34
34
  };
35
35
 
36
- const COOKIE$2 = 'OptanonConsent';
37
- /**
38
- * Checks the users OptanonConsent cookie to determine if the user has allowed targeting.
39
- * Returns true or false if the flag is found in the cookie, null otherwise.
40
- * @returns {boolean | null}
41
- */
42
- const checkConsentCookieForAllowTargeting = () => {
43
- const value = subsSdk.getCookie(COOKIE$2) || '';
44
- return value.includes('C0004%3A1') ? true : value.includes('C0004%3A0') ? false : null;
45
- };
46
-
47
- const COOKIE$1 = 'OptanonAlertBoxClosed';
48
- const checkCookie = () => {
49
- const value = subsSdk.getCookie(COOKIE$1) || '';
50
- // Wed May 15 2024 06:29:23 GMT-0500 (Central Daylight Time)
51
- // "Invalid date" is 12 characters long
52
- return value.length > 12;
53
- };
54
-
55
36
  const hasRequiredPrivacyCookies = () => {
37
+ var _WPGeo;
56
38
  if (typeof window === 'undefined') {
57
39
  return false;
58
40
  }
59
- const {
60
- intl_region,
61
- country_code: countryCode
62
- } = subsSdk.WPGeo();
63
- if (countryCode === 'US') {
64
- return !!subsSdk.getCookie('wp_usp');
65
- }
66
- const gdprAllowTargarting = checkConsentCookieForAllowTargeting();
67
- if (typeof gdprAllowTargarting === 'boolean' && checkCookie()) {
68
- return gdprAllowTargarting;
69
- }
70
- // Downstream systems
71
- if (intl_region === 'EEA') {
72
- return true;
73
- }
74
- return false;
41
+ const wp_usp = subsSdk.getCookie('wp_usp');
42
+ const countryCode = (_WPGeo = subsSdk.WPGeo()) === null || _WPGeo === void 0 ? void 0 : _WPGeo.country_code;
43
+ return !!(wp_usp && countryCode === 'US');
75
44
  };
76
45
 
77
46
  const base$1 = `${subsSdk.ENDPOINTS.base}/de/v1`;
@@ -176,14 +145,6 @@ const ingest = async ({
176
145
  }
177
146
  };
178
147
 
179
- const isAnonymousWebview = () => {
180
- if (typeof window === 'undefined') {
181
- return false;
182
- }
183
- const wp_wv = subsSdk.getCookie('wp_wv');
184
- return !!(wp_wv && !subsSdk.isLoggedIn());
185
- };
186
-
187
148
  const push = async ({
188
149
  submitData,
189
150
  source
@@ -191,9 +152,6 @@ const push = async ({
191
152
  if (!hasRequiredPrivacyCookies()) {
192
153
  throw new Error('does not satisfy cookie check');
193
154
  }
194
- if (isAnonymousWebview()) {
195
- throw new Error('does not satisfy cookie check');
196
- }
197
155
  const {
198
156
  fieldName
199
157
  } = submitData;
@@ -423,8 +381,7 @@ const DESelect = ({
423
381
  disabled: true
424
382
  } : {};
425
383
  // sort and filter out archived values
426
- // Note: config.values may be readonly
427
- const values = config ? [...config.values].sort((a, b) => a.order - b.order).filter(value => value.archived !== true).filter(valuesFilter) : [];
384
+ const values = config ? config.values.sort((a, b) => a.order - b.order).filter(value => value.archived !== true).filter(valuesFilter) : [];
428
385
  return React.createElement(SelectWrapper, null, children && React.createElement(wpdsUiKit.Select.Root, {
429
386
  onValueChange: e => {
430
387
  setSelected(e);
@@ -466,184 +423,8 @@ const SelectWrapper = /*#__PURE__*/wpdsUiKit.styled('div', {
466
423
  }
467
424
  });
468
425
 
469
- const configSrc = `${subsSdk.ENDPOINTS.base === 'https://subscribe.washingtonpost.com' ? 'https://www.washingtonpost.com/subscribe' : subsSdk.ENDPOINTS.base}/config/de/disclosure.json`;
470
- const getConfig = async () => {
471
- let myConfig = undefined;
472
- // step 1: fetch config
473
- const response = await fetch(configSrc);
474
- const remoteConfig = await response.json();
475
- // step 2: figure out which part of the config to use
476
- // if country- or region-specific config found, use that
477
- const {
478
- country_code,
479
- intl_region
480
- } = subsSdk.WPGeo();
481
- Object.keys(remoteConfig).forEach(configKey => {
482
- if (country_code && configKey.split('|').includes(country_code.toLowerCase())) {
483
- myConfig = remoteConfig[configKey];
484
- } else if (intl_region === 'EEA' && configKey === 'eea') {
485
- myConfig = remoteConfig[configKey];
486
- }
487
- });
488
- // TODO: Check for billing country also
489
- // else if no country-specific config, use the default config
490
- if (typeof myConfig === 'undefined' && remoteConfig['_']) {
491
- myConfig = remoteConfig['_'];
492
- }
493
- return myConfig;
494
- };
495
-
496
- const hydrateLinks = str => {
497
- const array = str.split(/({{PRIVACY_POLICY}})/g);
498
- const chunks = array.map(str => {
499
- if (str === '{{PRIVACY_POLICY}}') {
500
- return React.createElement("a", {
501
- target: "_blank",
502
- style: {
503
- color: 'inherit'
504
- },
505
- className: "underline",
506
- href: "https://www.washingtonpost.com/privacy-policy/"
507
- }, "Privacy Policy");
508
- }
509
- return str;
510
- });
511
- const toReturn = chunks.reduce((prev, current) => React.createElement(React.Fragment, null, prev, current), React.createElement(React.Fragment, null));
512
- return toReturn;
513
- };
514
-
515
- const COOKIE = 'OptanonAlertBoxClosed';
516
- const useOneTrustAlertBoxClosed = ({
517
- allowCookieStore
518
- }) => {
519
- const [alertBoxClosed, setAlertBoxClosed] = React.useState();
520
- const [listenToCookieStore, setListenToCookieStore] = React.useState(false);
521
- const [listenToTcfApi, setListenToTcfApi] = React.useState(false);
522
- React.useEffect(() => {
523
- var _window;
524
- if (checkCookie()) {
525
- setAlertBoxClosed(true);
526
- return;
527
- }
528
- if (!window.__tcfapi) {
529
- console.warn('warning: __tcfapi not found');
530
- }
531
- if ((_window = window) !== null && _window !== void 0 && _window.cookieStore && allowCookieStore) {
532
- setListenToCookieStore(true);
533
- } else if (window.__tcfapi) {
534
- setListenToTcfApi(true);
535
- } else {
536
- console.warn('warning: neither cookieStore nor __tcfapi found');
537
- }
538
- }, []);
539
- React.useEffect(() => {
540
- let cleanupFn = () => {};
541
- if (listenToCookieStore && window.cookieStore) {
542
- cleanupFn = subsSdk.listenToCookieStore(COOKIE, () => {
543
- if (checkCookie()) {
544
- setAlertBoxClosed(true);
545
- } else {
546
- setAlertBoxClosed(false);
547
- }
548
- });
549
- }
550
- return cleanupFn || (() => {});
551
- }, [listenToCookieStore]);
552
- React.useEffect(() => {
553
- let listenerId;
554
- if (listenToTcfApi && window.__tcfapi) {
555
- const callback = (_tcData, success) => {
556
- if (success) {
557
- listenerId = _tcData.listenerId;
558
- // tcData.eventStatus can be:
559
- // tcloaded means user has made a choice and we’re ready to check it
560
- // cmpuishown means the banner is shown
561
- // useractioncomplete means the user has interacted with the banner
562
- // but actually if the result for any of these is true, we just use the value of the cookie
563
- if (checkCookie()) {
564
- setAlertBoxClosed(true);
565
- }
566
- }
567
- };
568
- window.__tcfapi('addEventListener', 2, callback);
569
- }
570
- // cleanup fn
571
- return () => {
572
- if (window.__tcfapi && listenerId) window.__tcfapi('removeEventListener', 2, success => {
573
- console.debug(success);
574
- }, listenerId);
575
- };
576
- }, [listenToTcfApi]);
577
- return {
578
- alertBoxClosed,
579
- listenToCookieStore,
580
- listenToTcfApi
581
- };
582
- };
583
-
584
- const DEDisclosure = ({
585
- onFinished = () => {},
586
- allowCookieStore = true
587
- }) => {
588
- const [disclosure, setDisclosure] = React.useState(null);
589
- const [disclosureRendering, setDisclosureRendering] = React.useState(null);
590
- const [myConfig, setMyConfig] = React.useState();
591
- const {
592
- alertBoxClosed
593
- } = useOneTrustAlertBoxClosed({
594
- allowCookieStore
595
- });
596
- React.useEffect(() => {
597
- (async () => {
598
- const config = await getConfig();
599
- setMyConfig(config);
600
- if (!config) {
601
- console.error('No config found');
602
- }
603
- })();
604
- }, []);
605
- React.useEffect(() => {
606
- if (myConfig) {
607
- // step 3: set disclosure based on config
608
- // if config says to check onetrust, check onetrust
609
- if ('checkBannerStatus' in myConfig && myConfig.checkBannerStatus) {
610
- // check if onetrust is closed
611
- // if it is, show the after banner disclosure
612
- // if it is not, show the before banner disclosure
613
- if (alertBoxClosed) {
614
- setDisclosure(myConfig.disclosure_afterbanner);
615
- } else {
616
- setDisclosure(myConfig.disclosure_beforebanner);
617
- }
618
- } else if ('disclosure' in myConfig) {
619
- setDisclosure(myConfig.disclosure);
620
- } else {
621
- console.error('Invalid config');
622
- }
623
- }
624
- }, [myConfig, alertBoxClosed]);
625
- React.useEffect(() => {
626
- if (disclosure && Array.isArray(disclosure)) {
627
- setDisclosureRendering(disclosure.reduce((prev, current) => {
628
- return React.createElement(React.Fragment, null, prev, React.createElement("p", null, hydrateLinks(current)));
629
- }, React.createElement(React.Fragment, null)));
630
- // Is it ok to fire `onFinished` if still waiting for onetrust to load on the page?
631
- onFinished({
632
- isFinished: true,
633
- isError: false
634
- });
635
- }
636
- }, [disclosure]);
637
- return disclosure === null ? React.createElement("div", {
638
- "data-test-id": "de-disclosure-loading"
639
- }) : React.createElement("div", {
640
- "data-test-id": "de-disclosure"
641
- }, disclosureRendering);
642
- };
643
-
644
426
  exports.AttributesState = AttributesState;
645
427
  exports.CollectionBehaviors = CollectionBehaviors;
646
- exports.DEDisclosure = DEDisclosure;
647
428
  exports.DESelect = DESelect;
648
429
  exports.IngestResponseState = IngestResponseState;
649
430
  exports.IngestType = IngestType;
@@ -1 +1 @@
1
- {"version":3,"file":"subs-de-inputs.cjs.development.js","sources":["../src/interfaces/index.ts","../src/utils/checkConsentCookieForAllowTargeting.ts","../src/components/DEDisclosure/utils/checkCookie.ts","../src/utils/hasRequiredPrivacyCookies.ts","../src/services/getAttributes.ts","../src/services/sendToGA.ts","../src/services/ingest.ts","../src/utils/isAnonymousWebview.ts","../src/utils/push.ts","../src/components/DESelect/Dropdown.tsx","../src/components/DESelect/index.tsx","../src/components/DEDisclosure/utils/getConfig.ts","../src/components/DEDisclosure/utils/hydrateLinks.tsx","../src/components/DEDisclosure/hooks/useOnetrustAlertBoxClosedPromise.ts","../src/components/DEDisclosure/index.tsx"],"sourcesContent":["export type AttributeValue = {\n name: string;\n date_created: Number;\n last_modified_date: Number;\n archived: boolean;\n order: number;\n};\n\nexport const CollectionBehaviors = {\n COLLECT: 'COLLECT',\n DO_NOT_COLLECT: 'DO_NOT_COLLECT',\n} as const;\n\nexport type Attribute = {\n name: string;\n approved_for_use?: boolean;\n collection_behavior?: (typeof CollectionBehaviors)[keyof typeof CollectionBehaviors];\n datatype: string;\n explicit: boolean;\n multiple_value: boolean;\n last_modified_date: Number;\n date_created: Number;\n values: AttributeValue[] | Readonly<AttributeValue[]>;\n};\n\nexport const AttributesState = {\n SUCCESS: '100',\n} as const;\n\nexport const IngestType = {\n EXPLICIT: 'explicit',\n IMPLICIT: 'implicit',\n} as const;\n\nexport const IngestResponseState = {\n SUCCESS: '100',\n SYSTEM_ERROR: '101',\n INVALID_TYPE: '102',\n INVALID_IDENTIFIER: '103',\n INVALID_DATA: '104',\n INVALID_ATTRIBUTE_DEFINITION: '105',\n INVALID_META_DEFINITION: '106',\n UNAUTHENTICATED: '107',\n MISMATCHED_IDENTIFIER: '108',\n DISABLED_ATTRIBUTE_DEFINITION: '109',\n DO_NOT_COLLECT: '110',\n} as const;\n","import { getCookie } from '@washingtonpost/subs-sdk';\n\nconst COOKIE = 'OptanonConsent';\n\n/**\n * Checks the users OptanonConsent cookie to determine if the user has allowed targeting.\n * Returns true or false if the flag is found in the cookie, null otherwise.\n * @returns {boolean | null}\n */\nexport const checkConsentCookieForAllowTargeting = () => {\n const value = getCookie(COOKIE) || '';\n return value.includes('C0004%3A1')\n ? true\n : value.includes('C0004%3A0')\n ? false\n : null;\n};\n","import { getCookie } from '@washingtonpost/subs-sdk';\n\nconst COOKIE = 'OptanonAlertBoxClosed';\n\nexport const checkCookie = () => {\n const value = getCookie(COOKIE) || '';\n // Wed May 15 2024 06:29:23 GMT-0500 (Central Daylight Time)\n // \"Invalid date\" is 12 characters long\n return value.length > 12;\n};\n","import { WPGeo, getCookie } from '@washingtonpost/subs-sdk';\nimport { checkConsentCookieForAllowTargeting } from './checkConsentCookieForAllowTargeting';\nimport { checkCookie } from '../components/DEDisclosure/utils/checkCookie';\n\nexport const hasRequiredPrivacyCookies = () => {\n if (typeof window === 'undefined') {\n return false;\n }\n\n const { intl_region, country_code: countryCode } = WPGeo();\n\n if (countryCode === 'US') {\n return !!getCookie('wp_usp');\n }\n\n const gdprAllowTargarting = checkConsentCookieForAllowTargeting();\n if (typeof gdprAllowTargarting === 'boolean' && checkCookie()) {\n return gdprAllowTargarting;\n }\n\n // Downstream systems\n if (intl_region === 'EEA') {\n return true;\n }\n\n return false;\n};\n","import {\n ENDPOINTS,\n ResponseStatus,\n JSON_HEADERS,\n} from '@washingtonpost/subs-sdk';\nimport { Attribute } from '../interfaces';\n\nconst base = `${ENDPOINTS.base}/de/v1`;\n\nconst attributesCache: Record<string, any> = {};\nexport const getAttributes: GetAttributesType = async ({\n fieldName,\n}: {\n fieldName: string;\n}) => {\n if (attributesCache[fieldName]) {\n return attributesCache[fieldName];\n }\n\n const fieldNames = [fieldName];\n\n try {\n const url = new URL(`${base}/attributes`);\n url.searchParams.set('attributes', fieldNames.join(','));\n\n const data = await fetch(url.toString(), {\n credentials: 'include',\n headers: JSON_HEADERS,\n });\n const json = await data.json();\n\n if (data.ok && json.status === ResponseStatus.SUCCESS) {\n const attributes = json.attributes || [];\n attributesCache[fieldName] = attributes;\n return attributes;\n } else {\n return [];\n }\n } catch (e) {\n console.debug(e);\n return [];\n }\n};\n\ntype GetAttributesType = ({\n fieldName,\n}: {\n fieldName: string;\n}) => Promise<Attribute[]>;\n","const sendGAEvent = (props: {\n event: string;\n category: string;\n action: string;\n label: string;\n 'de-label': string;\n [key: string]: undefined | string | string[];\n}): void => {\n if (typeof window === 'undefined') {\n if (__DEV__) console.warn('NO WINDOW');\n return;\n }\n // Initialize dataLayer if needed\n window.dataLayer = window.dataLayer || [];\n\n const eventData: Record<string, any> = {\n ...props,\n };\n window.dataLayer.push(eventData);\n};\n\nexport const sendToGA: SendToGaType = async ({\n submitData: { fieldName, value },\n source,\n}) => {\n sendGAEvent({\n event: 'site-onpage-click',\n action: 'site-onpage-click',\n category: 'profile',\n\n label: fieldName,\n 'de-label': fieldName,\n [fieldName]: value,\n\n section: 'profile',\n subsection: source,\n });\n\n return true;\n};\n\ntype SendToGaType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<true>;\n","import {\n ENDPOINTS,\n JSON_HEADERS,\n getCookie,\n} from '@washingtonpost/subs-sdk';\nimport type { ResponseStatusType } from '@washingtonpost/subs-sdk';\nimport { IngestResponseState, IngestType } from '../interfaces';\n\nconst base = `${ENDPOINTS.base}/de/v1`;\n\nexport const ingest: IngestType = async ({\n submitData: { fieldName, value },\n source,\n}) => {\n const url = `${base}/ingest`;\n\n const wapo_login_id = getCookie('wapo_login_id');\n\n const jucid = localStorage.getItem('uuid');\n const ga = getCookie('_ga');\n\n const payload = {\n jucid,\n ga,\n type: IngestType.EXPLICIT,\n wapo_login_id, // TODO: move this to BE to read from cookie headers\n data: {\n [fieldName]: [value],\n },\n metadata: { source },\n };\n\n try {\n const response = await fetch(url, {\n method: 'POST',\n credentials: 'include',\n headers: JSON_HEADERS,\n body: JSON.stringify(payload),\n });\n\n const json = await response.json();\n\n return json;\n } catch (e) {\n console.debug(e);\n return null;\n }\n};\n\ntype IngestType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<{\n status: ResponseStatusType;\n state: (typeof IngestResponseState)[keyof typeof IngestResponseState];\n} | null>;\n","import { getCookie, isLoggedIn } from '@washingtonpost/subs-sdk';\n\nexport const isAnonymousWebview = () => {\n if (typeof window === 'undefined') {\n return false;\n }\n\n const wp_wv = getCookie('wp_wv');\n\n return !!(wp_wv && !isLoggedIn());\n};\n","import type { ResponseStatusType } from '@washingtonpost/subs-sdk';\nimport {\n CollectionBehaviors,\n IngestType,\n} from '../interfaces';\nimport type { IngestResponseState } from '../interfaces';\nimport { getAttributes } from '../services/getAttributes';\nimport { sendToGA } from '../services/sendToGA';\nimport { hasRequiredPrivacyCookies } from './hasRequiredPrivacyCookies';\nimport { ingest } from '../services/ingest';\nimport { isAnonymousWebview } from './isAnonymousWebview';\n\ntype PushType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<\n | {\n status: ResponseStatusType;\n state: (typeof IngestResponseState)[keyof typeof IngestResponseState];\n }\n | null\n | true\n>;\n\n\nexport const push: PushType = async ({ submitData, source }) => {\n if (!hasRequiredPrivacyCookies()) {\n throw new Error('does not satisfy cookie check');\n }\n\n if (isAnonymousWebview()) {\n throw new Error('does not satisfy cookie check');\n }\n\n const { fieldName } = submitData;\n\n const attributeInfo = await getAttributes({\n fieldName,\n });\n\n if (\n attributeInfo[0] &&\n attributeInfo[0].name === fieldName &&\n attributeInfo[0].collection_behavior === CollectionBehaviors.DO_NOT_COLLECT\n ) {\n throw new Error('do not collect');\n }\n\n const type =\n attributeInfo[0] && attributeInfo[0].explicit === true\n ? IngestType.EXPLICIT\n : IngestType.IMPLICIT;\n\n if (!attributeInfo[0] && __DEV__) {\n console.warn(`no attribute info found for ${fieldName}, assuming implicit`);\n }\n\n if (type === IngestType.EXPLICIT) {\n return ingest({ submitData, source });\n } else {\n return sendToGA({ submitData, source });\n }\n};\n","import React, { useEffect, useState } from 'react';\nimport { Icon, Select, styled, theme } from '@washingtonpost/wpds-ui-kit';\nimport { useWindowSize } from '@washingtonpost/subs-hooks';\nimport { ChevronDown } from '@washingtonpost/wpds-assets';\n\ninterface IDropdownProps {\n id: string;\n label: string;\n values: Array<string>;\n required?: boolean;\n defaultValue?: string;\n onChange?: (value: string) => void;\n disabled?: boolean;\n}\n\nconst StyledMobileSelect = styled('select', {\n padding: '12px 16px 12px 6px',\n display: 'flex',\n justifyContent: 'space-between',\n width: '100%',\n backgroundColor: '$secondary',\n color: '$primary',\n fontFamily: '$meta',\n fontSize: '$100',\n fontWeight: '$light',\n lineHeight: '$125',\n paddingBlockRight: '$125',\n textOverflow: 'ellipsis',\n position: 'relative',\n borderColor: 'transparent',\n borderRightWidth: '10px',\n borderRightColor: 'transparent',\n appearance: 'none',\n '-webkit-appearance': 'none',\n '&:disabled': {\n backgroundColor: theme.colors.disabled,\n borderColor: theme.colors.disabled,\n color: theme.colors.onDisabled,\n cursor: 'not-allowed',\n },\n});\n\nconst StyledSelectWrapper = styled('div', {\n width: '100%',\n maxWidth: '380px',\n borderRadius: '$012',\n borderColor: '$subtle',\n borderStyle: 'solid',\n borderWidth: '1px',\n backgroundColor: '$secondary',\n position: 'relative',\n});\n\nconst StyledMobileOption = styled('option', {\n fontFamily: 'inherit',\n fontSize: 'inherit',\n color: 'inherit',\n});\n\n/**\n * Dropdown component. Uses wpds-ui-kit on desktop and native select on mobile.\n * @param {IDropdownProps} props The props.\n * @returns {React.ReactElement} The dropdown.\n */\nexport const Dropdown = ({\n id,\n label,\n values,\n required = false,\n defaultValue,\n onChange = () => {},\n disabled = false,\n}: IDropdownProps) => {\n const [answer, setAnswer] = useState<string>();\n const { isMobileSize } = useWindowSize();\n\n useEffect(() => {\n if (answer) onChange(answer);\n }, [answer]);\n\n const disabledProp = disabled ? { disabled: true } : {};\n\n // helps maintain state between WPDS and native dropdowns\n const defaultValueProp = answer\n ? { defaultValue: answer }\n : defaultValue\n ? { defaultValue }\n : {};\n\n const defaultValuePropMobile = (value: string) => {\n if (answer) {\n return value === answer ? { selected: true } : {};\n }\n return value === defaultValue ? { selected: true } : {};\n };\n\n return isMobileSize ? (\n <StyledSelectWrapper>\n <StyledMobileSelect\n id=\"\"\n required={required}\n onChange={(e) => setAnswer(e.target.value)}\n {...disabledProp}\n >\n <label>{label}</label>\n <StyledMobileOption\n value=\"\"\n disabled\n selected\n style={{ color: '#666666' }}\n >\n {label}\n </StyledMobileOption>\n {values.map((value) => (\n <StyledMobileOption\n value={value}\n key={value}\n {...defaultValuePropMobile(value)}\n >\n {value}\n </StyledMobileOption>\n ))}\n </StyledMobileSelect>\n <Icon\n label=\"\"\n size=\"100\"\n fill={theme.colors.gray80}\n style={{\n pointerEvents: 'none',\n position: 'absolute',\n right: '10px',\n top: '50%',\n transform: 'translateY(-50%)',\n }}\n >\n <ChevronDown style={{ position: 'absolute', right: '10px' }} />\n </Icon>\n </StyledSelectWrapper>\n ) : (\n <Select.Root\n onValueChange={(e) => setAnswer(e)}\n required={required}\n {...defaultValueProp}\n {...disabledProp}\n >\n <Select.Trigger data-test-id={`${id}-select-trigger`}>\n <Select.Label>{label}</Select.Label>\n <Select.Value />\n </Select.Trigger>\n <Select.Content\n css={{ zIndex: theme.zIndices.page }}\n data-test-id={`${id}-select-content`}\n >\n {values.map((value) => (\n <Select.Item value={value} key={value}>\n {value}\n </Select.Item>\n ))}\n </Select.Content>\n </Select.Root>\n );\n};\n","import React, { useState, useEffect } from 'react';\nimport { Select, styled } from '@washingtonpost/wpds-ui-kit';\nimport { ENDPOINTS, ResponseStatus } from '@washingtonpost/subs-sdk';\nimport { useScript, ScriptStatus } from '@washingtonpost/subs-hooks';\nimport { Attribute, AttributeValue } from '../../interfaces';\nimport { Dropdown } from './Dropdown';\n\ninterface DESelectProps {\n source: string;\n fieldName: string;\n label?: string;\n dataDictionaryConfig?: Attribute | Readonly<Attribute>;\n defaultValue?: string;\n disabled?: boolean;\n submit: boolean;\n onChange?: ({ value }: { value: string }) => void;\n onFinished?: ({\n isFinished,\n isError,\n }: {\n isFinished: boolean;\n isError: boolean;\n }) => void;\n valuesFilter?: (value: AttributeValue) => boolean;\n selectProps?: {\n root?: any;\n trigger?: any;\n label?: any;\n value?: any;\n content?: any;\n item?: any;\n };\n children?: React.ReactNode;\n}\n\nconst scriptSrc = `${\n ENDPOINTS.staticAssets === 'https://subscribe.washingtonpost.com/static'\n ? 'https://www.washingtonpost.com/subscribe/static/'\n : ENDPOINTS.staticAssets\n}/de-utils/twpdeu.min.js`;\n\nexport const DESelect: React.FC<DESelectProps> = ({\n source,\n fieldName,\n label,\n dataDictionaryConfig,\n defaultValue,\n disabled,\n submit,\n onChange = () => {},\n onFinished = () => {},\n valuesFilter = () => true,\n children,\n}) => {\n const [config, setConfig] = useState(dataDictionaryConfig);\n\n const [selected, setSelected] = useState('');\n\n const scriptStatus = useScript(scriptSrc);\n\n useEffect(() => {\n const fetchConfig = async () => {\n try {\n const config = await window?.__twpdeu?.getFieldConfigs({ fieldName });\n if (config) {\n setConfig(config[0]);\n } else {\n console.error('unable to get config', fieldName);\n }\n } catch (e) {\n console.warn('unable to get config', fieldName, e);\n }\n };\n\n if (scriptStatus === ScriptStatus.READY && !(children || config)) {\n fetchConfig();\n }\n }, [scriptStatus]);\n\n useEffect(() => {\n const submitSelected = async () => {\n try {\n const result = await window?.__twpdeu?.push({\n submitData: { fieldName, value: selected },\n source,\n });\n\n const isError =\n result === true\n ? false\n : result\n ? result.status !== ResponseStatus.SUCCESS\n : true;\n\n onFinished({\n isFinished: true,\n isError,\n });\n } catch (e) {\n onFinished({\n isFinished: false,\n isError: true,\n });\n }\n };\n\n if (scriptStatus === ScriptStatus.READY && submit && selected) {\n submitSelected();\n }\n }, [scriptStatus, submit]);\n\n const defaultValueProp = defaultValue && config ? { defaultValue } : {};\n\n const isLoading = !(children || config);\n\n const disabledProp = disabled || isLoading ? { disabled: true } : {};\n\n // sort and filter out archived values\n // Note: config.values may be readonly\n const values = config\n ? [...config.values]\n .sort((a, b) => a.order - b.order)\n .filter((value) => value.archived !== true)\n .filter(valuesFilter)\n : [];\n\n return (\n <SelectWrapper>\n {children && (\n <Select.Root\n onValueChange={(e) => {\n setSelected(e);\n onChange({ value: e });\n }}\n {...defaultValueProp}\n {...disabledProp}\n >\n {children}\n </Select.Root>\n )}\n {!children && !config && (\n <Dropdown\n id={'loading'}\n label={'Loading...'}\n values={[]}\n disabled={true}\n />\n )}\n {!children && config && (\n <Dropdown\n id={config.name}\n label={label || config.name}\n onChange={(e) => {\n setSelected(e);\n onChange({ value: e });\n }}\n values={values.map((value) => value.name)}\n defaultValue={defaultValue}\n disabled={disabled}\n />\n )}\n </SelectWrapper>\n );\n};\n\nconst SelectWrapper = styled('div', {\n boxSizing: 'border-box',\n display: 'flex',\n marginBottom: '$100',\n flexDirection: 'column',\n '& button': {\n padding: '1px 6px',\n },\n '& *': { boxSizing: 'border-box' },\n});\n","import { ENDPOINTS, WPGeo } from '@washingtonpost/subs-sdk';\nimport {\n DisclosureConfig,\n DisclosureConfigValue,\n} from '../../../interfaces/disclosure';\n\nconst configSrc = `${\n ENDPOINTS.base === 'https://subscribe.washingtonpost.com'\n ? 'https://www.washingtonpost.com/subscribe'\n : ENDPOINTS.base\n}/config/de/disclosure.json`;\n\nexport const getConfig = async () => {\n let myConfig: DisclosureConfigValue | undefined = undefined;\n\n // step 1: fetch config\n const response = await fetch(configSrc);\n const remoteConfig: DisclosureConfig = await response.json();\n\n // step 2: figure out which part of the config to use\n\n // if country- or region-specific config found, use that\n const { country_code, intl_region } = WPGeo();\n Object.keys(remoteConfig).forEach((configKey) => {\n if (\n country_code &&\n configKey.split('|').includes(country_code.toLowerCase())\n ) {\n myConfig = remoteConfig[configKey];\n } else if (intl_region === 'EEA' && configKey === 'eea') {\n myConfig = remoteConfig[configKey];\n }\n });\n\n // TODO: Check for billing country also\n\n // else if no country-specific config, use the default config\n if (typeof myConfig === 'undefined' && remoteConfig['_']) {\n myConfig = remoteConfig['_'];\n }\n\n return myConfig;\n};\n","import React from 'react';\n\ntype hydrateLinksType = (str: string) => string | JSX.Element;\n\nexport const hydrateLinks: hydrateLinksType = (str: string) => {\n const array = str.split(/({{PRIVACY_POLICY}})/g);\n const chunks = array.map((str) => {\n if (str === '{{PRIVACY_POLICY}}') {\n return (\n <a\n target=\"_blank\"\n style={{ color: 'inherit' }}\n className=\"underline\"\n href=\"https://www.washingtonpost.com/privacy-policy/\"\n >\n Privacy Policy\n </a>\n );\n }\n return str;\n });\n\n const toReturn = chunks.reduce(\n (prev, current) => (\n <>\n {prev}\n {current}\n </>\n ),\n <></>\n );\n\n return toReturn;\n};\n","import { useState, useEffect } from 'react';\nimport {\n listenToCookieStore as listenToCookieStoreUtil,\n ICookieStore,\n} from '@washingtonpost/subs-sdk';\nimport { checkCookie } from '../utils/checkCookie';\n\nconst COOKIE = 'OptanonAlertBoxClosed';\n\ninterface TCData {\n eventStatus: 'tcloaded' | 'cmpuishown' | 'useractioncomplete';\n listenerId: number;\n [key: string]: any;\n}\n\ntype TCFAPIAddListener = (\n command: 'addEventListener',\n version: number,\n callback: (tcData: TCData, success: boolean) => void\n) => void;\n\ntype TCFAPIRmListener = (\n command: 'removeEventListener',\n version: number,\n callback: (success: boolean) => void,\n listenerId: number\n) => void;\n\ntype TCFAPIPing = (\n command: 'ping',\n version: number,\n callback: (pingReturn: any, success: boolean) => void\n) => void;\n\ndeclare global {\n interface Window {\n cookieStore?: ICookieStore;\n __tcfapi?: TCFAPIAddListener & TCFAPIRmListener & TCFAPIPing;\n }\n}\n\nexport const useOneTrustAlertBoxClosed = ({\n allowCookieStore,\n}: {\n allowCookieStore: boolean;\n}) => {\n const [alertBoxClosed, setAlertBoxClosed] = useState<boolean | undefined>();\n\n const [listenToCookieStore, setListenToCookieStore] = useState(false);\n const [listenToTcfApi, setListenToTcfApi] = useState(false);\n\n useEffect(() => {\n if (checkCookie()) {\n setAlertBoxClosed(true);\n return;\n }\n\n if (!window.__tcfapi) {\n console.warn('warning: __tcfapi not found');\n }\n\n if (window?.cookieStore && allowCookieStore) {\n setListenToCookieStore(true);\n } else if (window.__tcfapi) {\n setListenToTcfApi(true);\n } else {\n console.warn('warning: neither cookieStore nor __tcfapi found');\n }\n }, []);\n\n useEffect(() => {\n let cleanupFn: (() => void) | null = () => {};\n if (listenToCookieStore && window.cookieStore) {\n cleanupFn = listenToCookieStoreUtil(COOKIE, () => {\n if (checkCookie()) {\n setAlertBoxClosed(true);\n } else {\n setAlertBoxClosed(false);\n }\n });\n }\n return cleanupFn || (() => {});\n }, [listenToCookieStore]);\n\n useEffect(() => {\n let listenerId: number;\n if (listenToTcfApi && window.__tcfapi) {\n const callback = (_tcData: TCData, success: boolean) => {\n if (success) {\n listenerId = _tcData.listenerId;\n\n // tcData.eventStatus can be:\n // tcloaded means user has made a choice and we’re ready to check it\n // cmpuishown means the banner is shown\n // useractioncomplete means the user has interacted with the banner\n\n // but actually if the result for any of these is true, we just use the value of the cookie\n if (checkCookie()) {\n setAlertBoxClosed(true);\n }\n }\n };\n\n window.__tcfapi('addEventListener', 2, callback);\n }\n\n // cleanup fn\n return () => {\n if (window.__tcfapi && listenerId)\n window.__tcfapi(\n 'removeEventListener',\n 2,\n (success) => {\n console.debug(success);\n },\n listenerId\n );\n };\n }, [listenToTcfApi]);\n\n return { alertBoxClosed, listenToCookieStore, listenToTcfApi };\n};\n","import React, { useState, useEffect } from 'react';\nimport { DisclosureConfigValue } from '../../interfaces/disclosure';\nimport { getConfig } from './utils/getConfig';\nimport { hydrateLinks } from './utils/hydrateLinks';\nimport { useOneTrustAlertBoxClosed } from './hooks/useOnetrustAlertBoxClosedPromise';\n\ninterface DisclosureProps {\n /** callback function to be called when the disclosure is finished loading */\n onFinished?: ({\n isFinished,\n isError,\n }: {\n isFinished: boolean;\n isError: boolean;\n }) => void;\n\n /** ability to turn off cookiestore listener, primarily for testing purposes */\n allowCookieStore?: boolean;\n}\n\nexport const DEDisclosure: React.FC<DisclosureProps> = ({\n onFinished = () => {},\n allowCookieStore = true,\n}) => {\n const [disclosure, setDisclosure] = useState<string[] | null>(null);\n const [disclosureRendering, setDisclosureRendering] =\n useState<JSX.Element | null>(null);\n const [myConfig, setMyConfig] = useState<DisclosureConfigValue>();\n const { alertBoxClosed } = useOneTrustAlertBoxClosed({ allowCookieStore });\n\n useEffect(() => {\n (async () => {\n const config = await getConfig();\n setMyConfig(config);\n\n if (!config) {\n console.error('No config found');\n }\n })();\n }, []);\n\n useEffect(() => {\n if (myConfig) {\n // step 3: set disclosure based on config\n\n // if config says to check onetrust, check onetrust\n if ('checkBannerStatus' in myConfig && myConfig.checkBannerStatus) {\n // check if onetrust is closed\n // if it is, show the after banner disclosure\n // if it is not, show the before banner disclosure\n if (alertBoxClosed) {\n setDisclosure(myConfig.disclosure_afterbanner);\n } else {\n setDisclosure(myConfig.disclosure_beforebanner);\n }\n } else if ('disclosure' in myConfig) {\n setDisclosure(myConfig.disclosure);\n } else {\n console.error('Invalid config');\n }\n }\n }, [myConfig, alertBoxClosed]);\n\n useEffect(() => {\n if (disclosure && Array.isArray(disclosure)) {\n setDisclosureRendering(\n disclosure.reduce((prev, current) => {\n return (\n <>\n {prev}\n <p>{hydrateLinks(current)}</p>\n </>\n );\n }, <></>)\n );\n\n // Is it ok to fire `onFinished` if still waiting for onetrust to load on the page?\n onFinished({\n isFinished: true,\n isError: false,\n });\n }\n }, [disclosure]);\n\n return disclosure === null ? (\n <div data-test-id=\"de-disclosure-loading\"></div>\n ) : (\n <div data-test-id=\"de-disclosure\">{disclosureRendering}</div>\n );\n};\n"],"names":["CollectionBehaviors","COLLECT","DO_NOT_COLLECT","AttributesState","SUCCESS","IngestType","EXPLICIT","IMPLICIT","IngestResponseState","SYSTEM_ERROR","INVALID_TYPE","INVALID_IDENTIFIER","INVALID_DATA","INVALID_ATTRIBUTE_DEFINITION","INVALID_META_DEFINITION","UNAUTHENTICATED","MISMATCHED_IDENTIFIER","DISABLED_ATTRIBUTE_DEFINITION","COOKIE","checkConsentCookieForAllowTargeting","value","getCookie","includes","checkCookie","length","hasRequiredPrivacyCookies","window","intl_region","country_code","countryCode","WPGeo","gdprAllowTargarting","base","ENDPOINTS","attributesCache","getAttributes","fieldName","fieldNames","url","URL","searchParams","set","join","data","fetch","toString","credentials","headers","JSON_HEADERS","json","ok","status","ResponseStatus","attributes","e","console","debug","sendGAEvent","props","warn","dataLayer","eventData","push","sendToGA","submitData","source","event","action","category","label","section","subsection","ingest","wapo_login_id","jucid","localStorage","getItem","ga","payload","type","metadata","response","method","body","JSON","stringify","isAnonymousWebview","wp_wv","isLoggedIn","Error","attributeInfo","name","collection_behavior","explicit","process","StyledMobileSelect","styled","padding","display","justifyContent","width","backgroundColor","color","fontFamily","fontSize","fontWeight","lineHeight","paddingBlockRight","textOverflow","position","borderColor","borderRightWidth","borderRightColor","appearance","theme","colors","disabled","onDisabled","cursor","StyledSelectWrapper","maxWidth","borderRadius","borderStyle","borderWidth","StyledMobileOption","Dropdown","id","values","required","defaultValue","onChange","answer","setAnswer","useState","isMobileSize","useWindowSize","useEffect","disabledProp","defaultValueProp","defaultValuePropMobile","selected","React","createElement","target","style","map","key","Icon","size","fill","gray80","pointerEvents","right","top","transform","ChevronDown","Select","Root","onValueChange","Trigger","Label","Value","Content","css","zIndex","zIndices","page","Item","scriptSrc","staticAssets","DESelect","dataDictionaryConfig","submit","onFinished","valuesFilter","children","config","setConfig","setSelected","scriptStatus","useScript","fetchConfig","_window","__twpdeu","getFieldConfigs","error","ScriptStatus","READY","submitSelected","_window2","result","isError","isFinished","isLoading","sort","a","b","order","filter","archived","SelectWrapper","boxSizing","marginBottom","flexDirection","configSrc","getConfig","myConfig","undefined","remoteConfig","Object","keys","forEach","configKey","split","toLowerCase","hydrateLinks","str","array","chunks","className","href","toReturn","reduce","prev","current","Fragment","useOneTrustAlertBoxClosed","allowCookieStore","alertBoxClosed","setAlertBoxClosed","listenToCookieStore","setListenToCookieStore","listenToTcfApi","setListenToTcfApi","__tcfapi","cookieStore","cleanupFn","listenToCookieStoreUtil","listenerId","callback","_tcData","success","DEDisclosure","disclosure","setDisclosure","disclosureRendering","setDisclosureRendering","setMyConfig","checkBannerStatus","disclosure_afterbanner","disclosure_beforebanner","Array","isArray"],"mappings":";;;;;;;;;;AAQO,MAAMA,mBAAmB,GAAG;AACjCC,EAAAA,OAAO,EAAE,SAAS;AAClBC,EAAAA,cAAc,EAAE,gBAAA;EACR;AAcH,MAAMC,eAAe,GAAG;AAC7BC,EAAAA,OAAO,EAAE,KAAA;EACD;AAEH,MAAMC,UAAU,GAAG;AACxBC,EAAAA,QAAQ,EAAE,UAAU;AACpBC,EAAAA,QAAQ,EAAE,UAAA;EACF;AAEH,MAAMC,mBAAmB,GAAG;AACjCJ,EAAAA,OAAO,EAAE,KAAK;AACdK,EAAAA,YAAY,EAAE,KAAK;AACnBC,EAAAA,YAAY,EAAE,KAAK;AACnBC,EAAAA,kBAAkB,EAAE,KAAK;AACzBC,EAAAA,YAAY,EAAE,KAAK;AACnBC,EAAAA,4BAA4B,EAAE,KAAK;AACnCC,EAAAA,uBAAuB,EAAE,KAAK;AAC9BC,EAAAA,eAAe,EAAE,KAAK;AACtBC,EAA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ACV,CAAA;AAED;AACApD,MAAAA,UAAU,CAAC;AACTmB,QAAAA,UAAU,EAAE,IAAI;AAChBD,QAAAA,OAAO,EAAE,KAAA;AACV,OAAA,CAAC,CAAA;AACJ,KAAA;AACF,GAAC,EAAE,CAACoD,UAAU,CAAC,CAAC,CAAA;EAEhB,OAAOA,UAAU,KAAK,IAAI,GACxBtG;oBAAkB,uBAAA;AAAuB,GAAA,CAAO,GAEhDA,KAAA,CAAAC,aAAA,CAAA,KAAA,EAAA;AAAA,IAAA,cAAA,EAAkB,eAAA;GAAiB,EAAAuG,mBAAmB,CACvD,CAAA;AACH;;;;;;;;;;;;"}
1
+ {"version":3,"file":"subs-de-inputs.cjs.development.js","sources":["../src/interfaces/index.ts","../src/utils/hasRequiredPrivacyCookies.ts","../src/services/getAttributes.ts","../src/services/sendToGA.ts","../src/services/ingest.ts","../src/utils/push.ts","../src/components/DESelect/Dropdown.tsx","../src/components/DESelect/index.tsx"],"sourcesContent":["export type AttributeValue = {\n name: string;\n date_created: Number;\n last_modified_date: Number;\n archived: boolean;\n order: number;\n};\n\nexport const CollectionBehaviors = {\n COLLECT: 'COLLECT',\n DO_NOT_COLLECT: 'DO_NOT_COLLECT',\n} as const;\n\nexport type Attribute = {\n name: string;\n approved_for_use?: boolean;\n collection_behavior?: (typeof CollectionBehaviors)[keyof typeof CollectionBehaviors];\n datatype: 'string';\n explicit: boolean;\n multiple_value: boolean;\n last_modified_date: Number;\n date_created: Number;\n values: Array<AttributeValue>;\n};\n\nexport const AttributesState = {\n SUCCESS: '100',\n} as const;\n\nexport const IngestType = {\n EXPLICIT: 'explicit',\n IMPLICIT: 'implicit',\n} as const;\n\nexport const IngestResponseState = {\n SUCCESS: '100',\n SYSTEM_ERROR: '101',\n INVALID_TYPE: '102',\n INVALID_IDENTIFIER: '103',\n INVALID_DATA: '104',\n INVALID_ATTRIBUTE_DEFINITION: '105',\n INVALID_META_DEFINITION: '106',\n UNAUTHENTICATED: '107',\n MISMATCHED_IDENTIFIER: '108',\n DISABLED_ATTRIBUTE_DEFINITION: '109',\n DO_NOT_COLLECT: '110',\n} as const;\n","import { WPGeo, getCookie } from '@washingtonpost/subs-sdk';\n\nexport const hasRequiredPrivacyCookies = () => {\n if (typeof window === 'undefined') {\n return false;\n }\n\n const wp_usp = getCookie('wp_usp');\n\n const countryCode = WPGeo()?.country_code;\n\n return !!(wp_usp && countryCode === 'US');\n};\n","import {\n ENDPOINTS,\n ResponseStatus,\n JSON_HEADERS,\n} from '@washingtonpost/subs-sdk';\nimport { Attribute } from '../interfaces';\n\nconst base = `${ENDPOINTS.base}/de/v1`;\n\nconst attributesCache: Record<string, any> = {};\nexport const getAttributes: GetAttributesType = async ({\n fieldName,\n}: {\n fieldName: string;\n}) => {\n if (attributesCache[fieldName]) {\n return attributesCache[fieldName];\n }\n\n const fieldNames = [fieldName];\n\n try {\n const url = new URL(`${base}/attributes`);\n url.searchParams.set('attributes', fieldNames.join(','));\n\n const data = await fetch(url.toString(), {\n credentials: 'include',\n headers: JSON_HEADERS,\n });\n const json = await data.json();\n\n if (data.ok && json.status === ResponseStatus.SUCCESS) {\n const attributes = json.attributes || [];\n attributesCache[fieldName] = attributes;\n return attributes;\n } else {\n return [];\n }\n } catch (e) {\n console.debug(e);\n return [];\n }\n};\n\ntype GetAttributesType = ({\n fieldName,\n}: {\n fieldName: string;\n}) => Promise<Attribute[]>;\n","const sendGAEvent = (props: {\n event: string;\n category: string;\n action: string;\n label: string;\n 'de-label': string;\n [key: string]: undefined | string | string[];\n}): void => {\n if (typeof window === 'undefined') {\n if (__DEV__) console.warn('NO WINDOW');\n return;\n }\n // Initialize dataLayer if needed\n window.dataLayer = window.dataLayer || [];\n\n const eventData: Record<string, any> = {\n ...props,\n };\n window.dataLayer.push(eventData);\n};\n\nexport const sendToGA: SendToGaType = async ({\n submitData: { fieldName, value },\n source,\n}) => {\n sendGAEvent({\n event: 'site-onpage-click',\n action: 'site-onpage-click',\n category: 'profile',\n\n label: fieldName,\n 'de-label': fieldName,\n [fieldName]: value,\n\n section: 'profile',\n subsection: source,\n });\n\n return true;\n};\n\ntype SendToGaType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<true>;\n","import {\n ENDPOINTS,\n ResponseStatus,\n JSON_HEADERS,\n getCookie,\n} from '@washingtonpost/subs-sdk';\nimport { IngestResponseState, IngestType } from '../interfaces';\n\nconst base = `${ENDPOINTS.base}/de/v1`;\n\nexport const ingest: IngestType = async ({\n submitData: { fieldName, value },\n source,\n}) => {\n const url = `${base}/ingest`;\n\n const wapo_login_id = getCookie('wapo_login_id');\n\n const jucid = localStorage.getItem('uuid');\n const ga = getCookie('_ga');\n\n const payload = {\n jucid,\n ga,\n type: IngestType.EXPLICIT,\n wapo_login_id, // TODO: move this to BE to read from cookie headers\n data: {\n [fieldName]: [value],\n },\n metadata: { source },\n };\n\n try {\n const response = await fetch(url, {\n method: 'POST',\n credentials: 'include',\n headers: JSON_HEADERS,\n body: JSON.stringify(payload),\n });\n\n const json = await response.json();\n\n return json;\n } catch (e) {\n console.debug(e);\n return null;\n }\n};\n\ntype IngestType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<{\n status: ResponseStatus;\n state: (typeof IngestResponseState)[keyof typeof IngestResponseState];\n} | null>;\n","import {\n CollectionBehaviors,\n IngestResponseState,\n IngestType,\n} from '../interfaces';\nimport { getAttributes } from '../services/getAttributes';\nimport { sendToGA } from '../services/sendToGA';\nimport { hasRequiredPrivacyCookies } from './hasRequiredPrivacyCookies';\nimport { ResponseStatus } from '@washingtonpost/subs-sdk';\nimport { ingest } from '../services/ingest';\n\nexport const push: PushType = async ({ submitData, source }) => {\n if (!hasRequiredPrivacyCookies()) {\n throw new Error('does not satisfy cookie check');\n }\n\n const { fieldName } = submitData;\n\n const attributeInfo = await getAttributes({\n fieldName,\n });\n\n if (\n attributeInfo[0] &&\n attributeInfo[0].name === fieldName &&\n attributeInfo[0].collection_behavior === CollectionBehaviors.DO_NOT_COLLECT\n ) {\n throw new Error('do not collect');\n }\n\n const type =\n attributeInfo[0] && attributeInfo[0].explicit === true\n ? IngestType.EXPLICIT\n : IngestType.IMPLICIT;\n\n if (!attributeInfo[0] && __DEV__) {\n console.warn(`no attribute info found for ${fieldName}, assuming implicit`);\n }\n\n if (type === IngestType.EXPLICIT) {\n return ingest({ submitData, source });\n } else {\n return sendToGA({ submitData, source });\n }\n};\n\ntype PushType = ({\n submitData: { fieldName, value },\n source,\n}: {\n submitData: {\n fieldName: string;\n value: string;\n };\n source: string;\n}) => Promise<\n | {\n status: ResponseStatus;\n state: (typeof IngestResponseState)[keyof typeof IngestResponseState];\n }\n | null\n | true\n>;\n","import React, { useEffect, useState } from 'react';\nimport { Icon, Select, styled, theme } from '@washingtonpost/wpds-ui-kit';\nimport { useWindowSize } from '@washingtonpost/subs-hooks';\nimport { ChevronDown } from '@washingtonpost/wpds-assets';\n\ninterface IDropdownProps {\n id: string;\n label: string;\n values: Array<string>;\n required?: boolean;\n defaultValue?: string;\n onChange?: (value: string) => void;\n disabled?: boolean;\n}\n\nconst StyledMobileSelect = styled('select', {\n padding: '12px 16px 12px 6px',\n display: 'flex',\n justifyContent: 'space-between',\n width: '100%',\n backgroundColor: '$secondary',\n color: '$primary',\n fontFamily: '$meta',\n fontSize: '$100',\n fontWeight: '$light',\n lineHeight: '$125',\n paddingBlockRight: '$125',\n textOverflow: 'ellipsis',\n position: 'relative',\n borderColor: 'transparent',\n borderRightWidth: '10px',\n borderRightColor: 'transparent',\n appearance: 'none',\n '-webkit-appearance': 'none',\n '&:disabled': {\n backgroundColor: theme.colors.disabled,\n borderColor: theme.colors.disabled,\n color: theme.colors.onDisabled,\n cursor: 'not-allowed',\n },\n});\n\nconst StyledSelectWrapper = styled('div', {\n width: '100%',\n maxWidth: '380px',\n borderRadius: '$012',\n borderColor: '$subtle',\n borderStyle: 'solid',\n borderWidth: '1px',\n backgroundColor: '$secondary',\n position: 'relative',\n});\n\nconst StyledMobileOption = styled('option', {\n fontFamily: 'inherit',\n fontSize: 'inherit',\n color: 'inherit',\n});\n\n/**\n * Dropdown component. Uses wpds-ui-kit on desktop and native select on mobile.\n * @param {IDropdownProps} props The props.\n * @returns {React.ReactElement} The dropdown.\n */\nexport const Dropdown = ({\n id,\n label,\n values,\n required = false,\n defaultValue,\n onChange = () => {},\n disabled = false,\n}: IDropdownProps) => {\n const [answer, setAnswer] = useState<string>();\n const { isMobileSize } = useWindowSize();\n\n useEffect(() => {\n if (answer) onChange(answer);\n }, [answer]);\n\n const disabledProp = disabled ? { disabled: true } : {};\n\n // helps maintain state between WPDS and native dropdowns\n const defaultValueProp = answer\n ? { defaultValue: answer }\n : defaultValue\n ? { defaultValue }\n : {};\n\n const defaultValuePropMobile = (value: string) => {\n if (answer) {\n return value === answer ? { selected: true } : {};\n }\n return value === defaultValue ? { selected: true } : {};\n };\n\n return isMobileSize ? (\n <StyledSelectWrapper>\n <StyledMobileSelect\n id=\"\"\n required={required}\n onChange={(e) => setAnswer(e.target.value)}\n {...disabledProp}\n >\n <label>{label}</label>\n <StyledMobileOption\n value=\"\"\n disabled\n selected\n style={{ color: '#666666' }}\n >\n {label}\n </StyledMobileOption>\n {values.map((value) => (\n <StyledMobileOption\n value={value}\n key={value}\n {...defaultValuePropMobile(value)}\n >\n {value}\n </StyledMobileOption>\n ))}\n </StyledMobileSelect>\n <Icon\n label=\"\"\n size=\"100\"\n fill={theme.colors.gray80}\n style={{\n pointerEvents: 'none',\n position: 'absolute',\n right: '10px',\n top: '50%',\n transform: 'translateY(-50%)',\n }}\n >\n <ChevronDown style={{ position: 'absolute', right: '10px' }} />\n </Icon>\n </StyledSelectWrapper>\n ) : (\n <Select.Root\n onValueChange={(e) => setAnswer(e)}\n required={required}\n {...defaultValueProp}\n {...disabledProp}\n >\n <Select.Trigger data-test-id={`${id}-select-trigger`}>\n <Select.Label>{label}</Select.Label>\n <Select.Value />\n </Select.Trigger>\n <Select.Content\n css={{ zIndex: theme.zIndices.page }}\n data-test-id={`${id}-select-content`}\n >\n {values.map((value) => (\n <Select.Item value={value} key={value}>\n {value}\n </Select.Item>\n ))}\n </Select.Content>\n </Select.Root>\n );\n};\n","import React, { useState, useEffect } from 'react';\nimport { Select, styled } from '@washingtonpost/wpds-ui-kit';\nimport { ENDPOINTS, ResponseStatus } from '@washingtonpost/subs-sdk';\nimport { useScript, ScriptStatus } from '@washingtonpost/subs-hooks';\nimport { Attribute, AttributeValue } from '../../interfaces';\nimport { Dropdown } from './Dropdown';\n\ninterface DESelectProps {\n source: string;\n fieldName: string;\n label?: string;\n dataDictionaryConfig?: Attribute;\n defaultValue?: string;\n disabled?: boolean;\n submit: boolean;\n onChange?: ({ value }: { value: string }) => void;\n onFinished?: ({\n isFinished,\n isError,\n }: {\n isFinished: boolean;\n isError: boolean;\n }) => void;\n valuesFilter?: (value: AttributeValue) => boolean;\n selectProps?: {\n root?: any;\n trigger?: any;\n label?: any;\n value?: any;\n content?: any;\n item?: any;\n };\n children?: React.ReactNode;\n}\n\nconst scriptSrc = `${\n ENDPOINTS.staticAssets === 'https://subscribe.washingtonpost.com/static'\n ? 'https://www.washingtonpost.com/subscribe/static/'\n : ENDPOINTS.staticAssets\n}/de-utils/twpdeu.min.js`;\n\nexport const DESelect: React.FC<DESelectProps> = ({\n source,\n fieldName,\n label,\n dataDictionaryConfig,\n defaultValue,\n disabled,\n submit,\n onChange = () => {},\n onFinished = () => {},\n valuesFilter = () => true,\n children,\n}) => {\n const [config, setConfig] = useState(dataDictionaryConfig);\n\n const [selected, setSelected] = useState('');\n\n const scriptStatus = useScript(scriptSrc);\n\n useEffect(() => {\n const fetchConfig = async () => {\n try {\n const config = await window?.__twpdeu?.getFieldConfigs({ fieldName });\n if (config) {\n setConfig(config[0]);\n } else {\n console.error('unable to get config', fieldName);\n }\n } catch (e) {\n console.warn('unable to get config', fieldName, e);\n }\n };\n\n if (scriptStatus === ScriptStatus.READY && !(children || config)) {\n fetchConfig();\n }\n }, [scriptStatus]);\n\n useEffect(() => {\n const submitSelected = async () => {\n try {\n const result = await window?.__twpdeu?.push({\n submitData: { fieldName, value: selected },\n source,\n });\n\n const isError =\n result === true\n ? false\n : result\n ? result.status !== ResponseStatus.SUCCESS\n : true;\n\n onFinished({\n isFinished: true,\n isError,\n });\n } catch (e) {\n onFinished({\n isFinished: false,\n isError: true,\n });\n }\n };\n\n if (scriptStatus === ScriptStatus.READY && submit && selected) {\n submitSelected();\n }\n }, [scriptStatus, submit]);\n\n const defaultValueProp = defaultValue && config ? { defaultValue } : {};\n\n const isLoading = !(children || config);\n\n const disabledProp = disabled || isLoading ? { disabled: true } : {};\n\n // sort and filter out archived values\n const values = config\n ? config.values\n .sort((a, b) => a.order - b.order)\n .filter((value) => value.archived !== true)\n .filter(valuesFilter)\n : [];\n\n return (\n <SelectWrapper>\n {children && (\n <Select.Root\n onValueChange={(e) => {\n setSelected(e);\n onChange({ value: e });\n }}\n {...defaultValueProp}\n {...disabledProp}\n >\n {children}\n </Select.Root>\n )}\n {!children && !config && (\n <Dropdown\n id={'loading'}\n label={'Loading...'}\n values={[]}\n disabled={true}\n />\n )}\n {!children && config && (\n <Dropdown\n id={config.name}\n label={label || config.name}\n onChange={(e) => {\n setSelected(e);\n onChange({ value: e });\n }}\n values={values.map((value) => value.name)}\n defaultValue={defaultValue}\n disabled={disabled}\n />\n )}\n </SelectWrapper>\n );\n};\n\nconst SelectWrapper = styled('div', {\n boxSizing: 'border-box',\n display: 'flex',\n marginBottom: '$100',\n flexDirection: 'column',\n '& button': {\n padding: '1px 6px',\n },\n '& *': { boxSizing: 'border-box' },\n});\n"],"names":["CollectionBehaviors","COLLECT","DO_NOT_COLLECT","AttributesState","SUCCESS","IngestType","EXPLICIT","IMPLICIT","IngestResponseState","SYSTEM_ERROR","INVALID_TYPE","INVALID_IDENTIFIER","INVALID_DATA","INVALID_ATTRIBUTE_DEFINITION","INVALID_META_DEFINITION","UNAUTHENTICATED","MISMATCHED_IDENTIFIER","DISABLED_ATTRIBUTE_DEFINITION","hasRequiredPrivacyCookies","_WPGeo","window","wp_usp","getCookie","countryCode","WPGeo","country_code","base","ENDPOINTS","attributesCache","getAttributes","fieldName","fieldNames","url","URL","searchParams","set","join","data","fetch","toString","credentials","headers","JSON_HEADERS","json","ok","status","ResponseStatus","attributes","e","console","debug","sendGAEvent","props","warn","dataLayer","eventData","push","sendToGA","submitData","value","source","event","action","category","label","section","subsection","ingest","wapo_login_id","jucid","localStorage","getItem","ga","payload","type","metadata","response","method","body","JSON","stringify","Error","attributeInfo","name","collection_behavior","explicit","process","StyledMobileSelect","styled","padding","display","justifyContent","width","backgroundColor","color","fontFamily","fontSize","fontWeight","lineHeight","paddingBlockRight","textOverflow","position","borderColor","borderRightWidth","borderRightColor","appearance","theme","colors","disabled","onDisabled","cursor","StyledSelectWrapper","maxWidth","borderRadius","borderStyle","borderWidth","StyledMobileOption","Dropdown","id","values","required","defaultValue","onChange","answer","setAnswer","useState","isMobileSize","useWindowSize","useEffect","disabledProp","defaultValueProp","defaultValuePropMobile","selected","React","createElement","target","style","map","key","Icon","size","fill","gray80","pointerEvents","right","top","transform","ChevronDown","Select","Root","onValueChange","Trigger","Label","Value","Content","css","zIndex","zIndices","page","Item","scriptSrc","staticAssets","DESelect","dataDictionaryConfig","submit","onFinished","valuesFilter","children","config","setConfig","setSelected","scriptStatus","useScript","fetchConfig","_window","__twpdeu","getFieldConfigs","error","ScriptStatus","READY","submitSelected","_window2","result","isError","isFinished","isLoading","sort","a","b","order","filter","archived","SelectWrapper","boxSizing","marginBottom","flexDirection"],"mappings":";;;;;;;;;;AAQO,MAAMA,mBAAmB,GAAG;AACjCC,EAAAA,OAAO,EAAE,SAAS;AAClBC,EAAAA,cAAc,EAAE,gBAAA;EACR;AAcH,MAAMC,eAAe,GAAG;AAC7BC,EAAAA,OAAO,EAAE,KAAA;EACD;AAEH,MAAMC,UAAU,GAAG;AACxBC,EAAAA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A,QAAAA;AACV,GAAA,CACH,CACa,CAAA;AAEpB,EAAC;AAED,MAAMoF,aAAa,gBAAGxG,gBAAM,CAAC,KAAK,EAAE;AAClCyG,EAAAA,SAAS,EAAE,YAAY;AACvBvG,EAAAA,OAAO,EAAE,MAAM;AACfwG,EAAAA,YAAY,EAAE,MAAM;AACpBC,EAAAA,aAAa,EAAE,QAAQ;AACvB,EAAA,UAAU,EAAE;AACV1G,IAAAA,OAAO,EAAE,SAAA;GACV;AACD,EAAA,KAAK,EAAE;AAAEwG,IAAAA,SAAS,EAAE,YAAA;AAAc,GAAA;AACnC,CAAA,CAAC;;;;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@washingtonpost/subs-sdk"),t=require("react"),o=require("@washingtonpost/wpds-ui-kit"),n=require("@washingtonpost/subs-hooks"),a=require("@washingtonpost/wpds-assets");const i={COLLECT:"COLLECT",DO_NOT_COLLECT:"DO_NOT_COLLECT"},s={EXPLICIT:"explicit",IMPLICIT:"implicit"},r=()=>(e.getCookie("OptanonAlertBoxClosed")||"").length>12,l=()=>{if("undefined"==typeof window)return!1;const{intl_region:t,country_code:o}=e.WPGeo();if("US"===o)return!!e.getCookie("wp_usp");const n=(()=>{const t=e.getCookie("OptanonConsent")||"";return!!t.includes("C0004%3A1")||!t.includes("C0004%3A0")&&null})();return"boolean"==typeof n&&r()?n:"EEA"===t},c=`${e.ENDPOINTS.base}/de/v1`,d={},u=async({fieldName:t})=>{if(d[t])return d[t];const o=[t];try{const n=new URL(`${c}/attributes`);n.searchParams.set("attributes",o.join(","));const a=await fetch(n.toString(),{credentials:"include",headers:e.JSON_HEADERS}),i=await a.json();if(a.ok&&i.status===e.ResponseStatus.SUCCESS){const e=i.attributes||[];return d[t]=e,e}return[]}catch(e){return console.debug(e),[]}},p=`${e.ENDPOINTS.base}/de/v1`,w=o.styled("select",{padding:"12px 16px 12px 6px",display:"flex",justifyContent:"space-between",width:"100%",backgroundColor:"$secondary",color:"$primary",fontFamily:"$meta",fontSize:"$100",fontWeight:"$light",lineHeight:"$125",paddingBlockRight:"$125",textOverflow:"ellipsis",position:"relative",borderColor:"transparent",borderRightWidth:"10px",borderRightColor:"transparent",appearance:"none","-webkit-appearance":"none","&:disabled":{backgroundColor:o.theme.colors.disabled,borderColor:o.theme.colors.disabled,color:o.theme.colors.onDisabled,cursor:"not-allowed"}}),f=o.styled("div",{width:"100%",maxWidth:"380px",borderRadius:"$012",borderColor:"$subtle",borderStyle:"solid",borderWidth:"1px",backgroundColor:"$secondary",position:"relative"}),E=o.styled("option",{fontFamily:"inherit",fontSize:"inherit",color:"inherit"}),g=({id:e,label:i,values:s,required:r=!1,defaultValue:l,onChange:c=(()=>{}),disabled:d=!1})=>{const[u,p]=t.useState(),{isMobileSize:g}=n.useWindowSize();t.useEffect((()=>{u&&c(u)}),[u]);const b=d?{disabled:!0}:{},m=u?{defaultValue:u}:l?{defaultValue:l}:{},h=e=>u?e===u?{selected:!0}:{}:e===l?{selected:!0}:{};return g?t.createElement(f,null,t.createElement(w,{id:"",required:r,onChange:e=>p(e.target.value),...b},t.createElement("label",null,i),t.createElement(E,{value:"",disabled:!0,selected:!0,style:{color:"#666666"}},i),s.map((e=>t.createElement(E,{value:e,key:e,...h(e)},e)))),t.createElement(o.Icon,{label:"",size:"100",fill:o.theme.colors.gray80,style:{pointerEvents:"none",position:"absolute",right:"10px",top:"50%",transform:"translateY(-50%)"}},t.createElement(a.ChevronDown,{style:{position:"absolute",right:"10px"}}))):t.createElement(o.Select.Root,{onValueChange:e=>p(e),required:r,...m,...b},t.createElement(o.Select.Trigger,{"data-test-id":`${e}-select-trigger`},t.createElement(o.Select.Label,null,i),t.createElement(o.Select.Value,null)),t.createElement(o.Select.Content,{css:{zIndex:o.theme.zIndices.page},"data-test-id":`${e}-select-content`},s.map((e=>t.createElement(o.Select.Item,{value:e,key:e},e)))))},b=`${"https://subscribe.washingtonpost.com/static"===e.ENDPOINTS.staticAssets?"https://www.washingtonpost.com/subscribe/static/":e.ENDPOINTS.staticAssets}/de-utils/twpdeu.min.js`,m=o.styled("div",{boxSizing:"border-box",display:"flex",marginBottom:"$100",flexDirection:"column","& button":{padding:"1px 6px"},"& *":{boxSizing:"border-box"}}),h=`${"https://subscribe.washingtonpost.com"===e.ENDPOINTS.base?"https://www.washingtonpost.com/subscribe":e.ENDPOINTS.base}/config/de/disclosure.json`;exports.AttributesState={SUCCESS:"100"},exports.CollectionBehaviors=i,exports.DEDisclosure=({onFinished:o=(()=>{}),allowCookieStore:n=!0})=>{const[a,i]=t.useState(null),[s,l]=t.useState(null),[c,d]=t.useState(),{alertBoxClosed:u}=(({allowCookieStore:o})=>{const[n,a]=t.useState(),[i,s]=t.useState(!1),[l,c]=t.useState(!1);return t.useEffect((()=>{var e;r()?a(!0):(window.__tcfapi||console.warn("warning: __tcfapi not found"),null!==(e=window)&&void 0!==e&&e.cookieStore&&o?s(!0):window.__tcfapi?c(!0):console.warn("warning: neither cookieStore nor __tcfapi found"))}),[]),t.useEffect((()=>{let t=()=>{};return i&&window.cookieStore&&(t=e.listenToCookieStore("OptanonAlertBoxClosed",(()=>{r()?a(!0):a(!1)}))),t||(()=>{})}),[i]),t.useEffect((()=>{let e;return l&&window.__tcfapi&&window.__tcfapi("addEventListener",2,((t,o)=>{o&&(e=t.listenerId,r()&&a(!0))})),()=>{window.__tcfapi&&e&&window.__tcfapi("removeEventListener",2,(e=>{console.debug(e)}),e)}}),[l]),{alertBoxClosed:n,listenToCookieStore:i,listenToTcfApi:l}})({allowCookieStore:n});return t.useEffect((()=>{(async()=>{const t=await(async()=>{let t;const o=await fetch(h),n=await o.json(),{country_code:a,intl_region:i}=e.WPGeo();return Object.keys(n).forEach((e=>{(a&&e.split("|").includes(a.toLowerCase())||"EEA"===i&&"eea"===e)&&(t=n[e])})),void 0===t&&n._&&(t=n._),t})();d(t),t||console.error("No config found")})()}),[]),t.useEffect((()=>{c&&("checkBannerStatus"in c&&c.checkBannerStatus?i(u?c.disclosure_afterbanner:c.disclosure_beforebanner):"disclosure"in c?i(c.disclosure):console.error("Invalid config"))}),[c,u]),t.useEffect((()=>{a&&Array.isArray(a)&&(l(a.reduce(((e,o)=>t.createElement(t.Fragment,null,e,t.createElement("p",null,o.split(/({{PRIVACY_POLICY}})/g).map((e=>"{{PRIVACY_POLICY}}"===e?t.createElement("a",{target:"_blank",style:{color:"inherit"},className:"underline",href:"https://www.washingtonpost.com/privacy-policy/"},"Privacy Policy"):e)).reduce(((e,o)=>t.createElement(t.Fragment,null,e,o)),t.createElement(t.Fragment,null))))),t.createElement(t.Fragment,null))),o({isFinished:!0,isError:!1}))}),[a]),null===a?t.createElement("div",{"data-test-id":"de-disclosure-loading"}):t.createElement("div",{"data-test-id":"de-disclosure"},s)},exports.DESelect=({source:a,fieldName:i,label:s,dataDictionaryConfig:r,defaultValue:l,disabled:c,submit:d,onChange:u=(()=>{}),onFinished:p=(()=>{}),valuesFilter:w=(()=>!0),children:f})=>{const[E,h]=t.useState(r),[S,C]=t.useState(""),I=n.useScript(b);t.useEffect((()=>{I!==n.ScriptStatus.READY||f||E||(async()=>{try{var e;const t=await(null===(e=window)||void 0===e||null===(e=e.__twpdeu)||void 0===e?void 0:e.getFieldConfigs({fieldName:i}));t?h(t[0]):console.error("unable to get config",i)}catch(e){console.warn("unable to get config",i,e)}})()}),[I]),t.useEffect((()=>{I===n.ScriptStatus.READY&&d&&S&&(async()=>{try{var t;const o=await(null===(t=window)||void 0===t||null===(t=t.__twpdeu)||void 0===t?void 0:t.push({submitData:{fieldName:i,value:S},source:a}));p({isFinished:!0,isError:!0!==o&&(!o||o.status!==e.ResponseStatus.SUCCESS)})}catch(e){p({isFinished:!1,isError:!0})}})()}),[I,d]);const _=l&&E?{defaultValue:l}:{},y=c||!f&&!E?{disabled:!0}:{},v=E?[...E.values].sort(((e,t)=>e.order-t.order)).filter((e=>!0!==e.archived)).filter(w):[];return t.createElement(m,null,f&&t.createElement(o.Select.Root,{onValueChange:e=>{C(e),u({value:e})},..._,...y},f),!f&&!E&&t.createElement(g,{id:"loading",label:"Loading...",values:[],disabled:!0}),!f&&E&&t.createElement(g,{id:E.name,label:s||E.name,onChange:e=>{C(e),u({value:e})},values:v.map((e=>e.name)),defaultValue:l,disabled:c}))},exports.IngestResponseState={SUCCESS:"100",SYSTEM_ERROR:"101",INVALID_TYPE:"102",INVALID_IDENTIFIER:"103",INVALID_DATA:"104",INVALID_ATTRIBUTE_DEFINITION:"105",INVALID_META_DEFINITION:"106",UNAUTHENTICATED:"107",MISMATCHED_IDENTIFIER:"108",DISABLED_ATTRIBUTE_DEFINITION:"109",DO_NOT_COLLECT:"110"},exports.IngestType=s,exports.getAttributes=u,exports.hasRequiredPrivacyCookies=l,exports.push=async({submitData:t,source:o})=>{if(!l())throw new Error("does not satisfy cookie check");if("undefined"!=typeof window&&e.getCookie("wp_wv")&&!e.isLoggedIn())throw new Error("does not satisfy cookie check");const{fieldName:n}=t,a=await u({fieldName:n});if(a[0]&&a[0].name===n&&a[0].collection_behavior===i.DO_NOT_COLLECT)throw new Error("do not collect");return(a[0]&&!0===a[0].explicit?s.EXPLICIT:s.IMPLICIT)===s.EXPLICIT?(async({submitData:{fieldName:t,value:o},source:n})=>{const a=`${p}/ingest`,i=e.getCookie("wapo_login_id"),r={jucid:localStorage.getItem("uuid"),ga:e.getCookie("_ga"),type:s.EXPLICIT,wapo_login_id:i,data:{[t]:[o]},metadata:{source:n}};try{const t=await fetch(a,{method:"POST",credentials:"include",headers:e.JSON_HEADERS,body:JSON.stringify(r)});return await t.json()}catch(e){return console.debug(e),null}})({submitData:t,source:o}):(async({submitData:{fieldName:e,value:t},source:o})=>((e=>{if("undefined"==typeof window)return;window.dataLayer=window.dataLayer||[];const t={...e};window.dataLayer.push(t)})({event:"site-onpage-click",action:"site-onpage-click",category:"profile",label:e,"de-label":e,[e]:t,section:"profile",subsection:o}),!0))({submitData:t,source:o})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@washingtonpost/subs-sdk"),t=require("react"),o=require("@washingtonpost/wpds-ui-kit"),a=require("@washingtonpost/subs-hooks"),i=require("@washingtonpost/wpds-assets");const s={COLLECT:"COLLECT",DO_NOT_COLLECT:"DO_NOT_COLLECT"},r={EXPLICIT:"explicit",IMPLICIT:"implicit"},n=()=>{var t;if("undefined"==typeof window)return!1;const o=e.getCookie("wp_usp"),a=null===(t=e.WPGeo())||void 0===t?void 0:t.country_code;return!(!o||"US"!==a)},l=`${e.ENDPOINTS.base}/de/v1`,d={},c=async({fieldName:t})=>{if(d[t])return d[t];const o=[t];try{const a=new URL(`${l}/attributes`);a.searchParams.set("attributes",o.join(","));const i=await fetch(a.toString(),{credentials:"include",headers:e.JSON_HEADERS}),s=await i.json();if(i.ok&&s.status===e.ResponseStatus.SUCCESS){const e=s.attributes||[];return d[t]=e,e}return[]}catch(e){return console.debug(e),[]}},u=`${e.ENDPOINTS.base}/de/v1`,p=o.styled("select",{padding:"12px 16px 12px 6px",display:"flex",justifyContent:"space-between",width:"100%",backgroundColor:"$secondary",color:"$primary",fontFamily:"$meta",fontSize:"$100",fontWeight:"$light",lineHeight:"$125",paddingBlockRight:"$125",textOverflow:"ellipsis",position:"relative",borderColor:"transparent",borderRightWidth:"10px",borderRightColor:"transparent",appearance:"none","-webkit-appearance":"none","&:disabled":{backgroundColor:o.theme.colors.disabled,borderColor:o.theme.colors.disabled,color:o.theme.colors.onDisabled,cursor:"not-allowed"}}),b=o.styled("div",{width:"100%",maxWidth:"380px",borderRadius:"$012",borderColor:"$subtle",borderStyle:"solid",borderWidth:"1px",backgroundColor:"$secondary",position:"relative"}),E=o.styled("option",{fontFamily:"inherit",fontSize:"inherit",color:"inherit"}),g=({id:e,label:s,values:r,required:n=!1,defaultValue:l,onChange:d=(()=>{}),disabled:c=!1})=>{const[u,g]=t.useState(),{isMobileSize:m}=a.useWindowSize();t.useEffect((()=>{u&&d(u)}),[u]);const h=c?{disabled:!0}:{},S=u?{defaultValue:u}:l?{defaultValue:l}:{},f=e=>u?e===u?{selected:!0}:{}:e===l?{selected:!0}:{};return m?t.createElement(b,null,t.createElement(p,{id:"",required:n,onChange:e=>g(e.target.value),...h},t.createElement("label",null,s),t.createElement(E,{value:"",disabled:!0,selected:!0,style:{color:"#666666"}},s),r.map((e=>t.createElement(E,{value:e,key:e,...f(e)},e)))),t.createElement(o.Icon,{label:"",size:"100",fill:o.theme.colors.gray80,style:{pointerEvents:"none",position:"absolute",right:"10px",top:"50%",transform:"translateY(-50%)"}},t.createElement(i.ChevronDown,{style:{position:"absolute",right:"10px"}}))):t.createElement(o.Select.Root,{onValueChange:e=>g(e),required:n,...S,...h},t.createElement(o.Select.Trigger,{"data-test-id":`${e}-select-trigger`},t.createElement(o.Select.Label,null,s),t.createElement(o.Select.Value,null)),t.createElement(o.Select.Content,{css:{zIndex:o.theme.zIndices.page},"data-test-id":`${e}-select-content`},r.map((e=>t.createElement(o.Select.Item,{value:e,key:e},e)))))},m=`${"https://subscribe.washingtonpost.com/static"===e.ENDPOINTS.staticAssets?"https://www.washingtonpost.com/subscribe/static/":e.ENDPOINTS.staticAssets}/de-utils/twpdeu.min.js`,h=o.styled("div",{boxSizing:"border-box",display:"flex",marginBottom:"$100",flexDirection:"column","& button":{padding:"1px 6px"},"& *":{boxSizing:"border-box"}});exports.AttributesState={SUCCESS:"100"},exports.CollectionBehaviors=s,exports.DESelect=({source:i,fieldName:s,label:r,dataDictionaryConfig:n,defaultValue:l,disabled:d,submit:c,onChange:u=(()=>{}),onFinished:p=(()=>{}),valuesFilter:b=(()=>!0),children:E})=>{const[S,f]=t.useState(n),[I,w]=t.useState(""),C=a.useScript(m);t.useEffect((()=>{C!==a.ScriptStatus.READY||E||S||(async()=>{try{var e;const t=await(null===(e=window)||void 0===e||null===(e=e.__twpdeu)||void 0===e?void 0:e.getFieldConfigs({fieldName:s}));t?f(t[0]):console.error("unable to get config",s)}catch(e){console.warn("unable to get config",s,e)}})()}),[C]),t.useEffect((()=>{C===a.ScriptStatus.READY&&c&&I&&(async()=>{try{var t;const o=await(null===(t=window)||void 0===t||null===(t=t.__twpdeu)||void 0===t?void 0:t.push({submitData:{fieldName:s,value:I},source:i}));p({isFinished:!0,isError:!0!==o&&(!o||o.status!==e.ResponseStatus.SUCCESS)})}catch(e){p({isFinished:!1,isError:!0})}})()}),[C,c]);const y=l&&S?{defaultValue:l}:{},T=d||!E&&!S?{disabled:!0}:{},v=S?S.values.sort(((e,t)=>e.order-t.order)).filter((e=>!0!==e.archived)).filter(b):[];return t.createElement(h,null,E&&t.createElement(o.Select.Root,{onValueChange:e=>{w(e),u({value:e})},...y,...T},E),!E&&!S&&t.createElement(g,{id:"loading",label:"Loading...",values:[],disabled:!0}),!E&&S&&t.createElement(g,{id:S.name,label:r||S.name,onChange:e=>{w(e),u({value:e})},values:v.map((e=>e.name)),defaultValue:l,disabled:d}))},exports.IngestResponseState={SUCCESS:"100",SYSTEM_ERROR:"101",INVALID_TYPE:"102",INVALID_IDENTIFIER:"103",INVALID_DATA:"104",INVALID_ATTRIBUTE_DEFINITION:"105",INVALID_META_DEFINITION:"106",UNAUTHENTICATED:"107",MISMATCHED_IDENTIFIER:"108",DISABLED_ATTRIBUTE_DEFINITION:"109",DO_NOT_COLLECT:"110"},exports.IngestType=r,exports.getAttributes=c,exports.hasRequiredPrivacyCookies=n,exports.push=async({submitData:t,source:o})=>{if(!n())throw new Error("does not satisfy cookie check");const{fieldName:a}=t,i=await c({fieldName:a});if(i[0]&&i[0].name===a&&i[0].collection_behavior===s.DO_NOT_COLLECT)throw new Error("do not collect");return(i[0]&&!0===i[0].explicit?r.EXPLICIT:r.IMPLICIT)===r.EXPLICIT?(async({submitData:{fieldName:t,value:o},source:a})=>{const i=`${u}/ingest`,s=e.getCookie("wapo_login_id"),n={jucid:localStorage.getItem("uuid"),ga:e.getCookie("_ga"),type:r.EXPLICIT,wapo_login_id:s,data:{[t]:[o]},metadata:{source:a}};try{const t=await fetch(i,{method:"POST",credentials:"include",headers:e.JSON_HEADERS,body:JSON.stringify(n)});return await t.json()}catch(e){return console.debug(e),null}})({submitData:t,source:o}):(async({submitData:{fieldName:e,value:t},source:o})=>((e=>{if("undefined"==typeof window)return;window.dataLayer=window.dataLayer||[];const t={...e};window.dataLayer.push(t)})({event:"site-onpage-click",action:"site-onpage-click",category:"profile",label:e,"de-label":e,[e]:t,section:"profile",subsection:o}),!0))({submitData:t,source:o})};
2
2
  //# sourceMappingURL=subs-de-inputs.cjs.production.min.js.map