{"version":3,"sources":["components/PodcastSubscription/validation.ts","components/PodcastSubscription/StyledPodcastSubscription.ts","components/PodcastSubscription/Platform.tsx","components/PodcastSubscription/index.tsx"],"names":["isValidPodcast","item","icon","link","title","normalizeJssFields","value","href","src","PodcastSubscriptionValidators","field","errorMessage","required","minLength","allowRenderOnError","validators","Container","styled","div","theme","colors","ui","defaultBorderColor","spacing","pt","pb","px","mb","hideOnPrint","background","darkBlue","text","neutral","tint1","contrast","isHideByConditions","mq","podcastSeriesCardsNum","podcastRelatedCardsNum","css","totalNum","Heading","textBody1","PlatformWrapper","Figure","figure","mr","Image","SCImage","PlatformLink","Link","xs","md","ml","compose","withDigitalDataContext","withEditMode","digitalData","setDigitalData","defaultImageSize","getImageAttrsByRatio","ImageSize","MW_24","ImageRatio","Ratio_1By1","linkProps","jss","target","childrenOnly","fallbackTitle","hideExternalIcon","linkTheme","onClick","canUseDOM","setObjectData","podcastPlatform","emitTrackEvent","handleClick","className","draggable","imagePlaceholderSrc","alt","convertSrcJss","withSitecoreContext","withDataSourceValidation","withCoveoNoIndexTags","rendering","sitecoreContext","useContext","SitecoreContextReactContext","pageMainComponents","context","route","placeholders","podcastSeriesCardsInfo","find","componentName","podcastRelatedCardsInfo","fields","data","cards","seriesCards","length","items","podcastcards","datasource","sources","podcastSubscriptionSources","targetItems","normalizedFields","heading","description","headingLevel","params","uid","backgroundTheme","validSources","filter","source","id","HeadingWithDescription","descriptionField","headingField","platforms","map","platform","key"],"mappings":"mMAKO,MAAMA,EACXC,IACI,IAAD,IACH,IAAKA,EACH,OAAO,EAET,MAAM,KACJC,EADI,KAEJC,EAFI,MAGJC,GACEC,YAAmBJ,GAEvB,SAASG,aAAD,EAACA,EAAOE,WAAWH,SAAD,UAACA,EAAMG,aAAP,aAAC,EAAaC,UAAUL,SAAD,UAACA,EAAMI,aAAP,aAAC,EAAaE,MAGpDC,EAA0D,CACrE,CACEC,MAAO,mCACPC,aAAc,gCAEhB,CACED,MAAO,mDACPC,aAAc,6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GAAUD,SAAA,UAAAA,EAAYE,kCAAZ,eAAwCC,cAAe,GACjEC,EAAmBxG,YAAmBoG,GACtCK,EAAUD,aAAH,EAAGA,EAAkBC,QAC5B1G,EAAQyG,aAAH,EAAGA,EAAkBzG,MAC1B2G,EAAcF,aAAH,EAAGA,EAAkBE,YAChCC,GAAe1B,SAAA,UAAAA,EAAW2B,cAAX,eAAmBD,eAAgB,KAClDE,EAAM5B,aAAH,EAAGA,EAAW4B,IACjBC,EAAkBN,aAAH,EAAGA,EAAkBM,gBACpChF,GAAoB0E,SAAA,UAAAA,EAAkB1E,0BAAlB,eAAsC7B,SAAS,EAGnE8G,EAAeV,EAAQW,QAAOC,GAAUtH,EAAesH,KACvDxC,EAAU,yBAA0BqC,aAA1B,EAA0BA,EAAiB7G,OAE3D,OACE,kBAACU,EAAD,CACE8D,UAAWA,EACX,oBACAyC,GAAIL,EACJ/E,mBAAoBA,EACpBE,sBAAuBA,EACvBC,uBAAwBA,GAExB,kBAACkF,EAAA,EAAD,CACEC,iBAAkBV,EAClBW,aAActH,EACd4G,aAAcA,IAEhB,kBAACvE,EAAD,KAAUqE,aAAV,EAAUA,EAASxG,OACnB,kBAACqC,EAAD,KAtDiCgF,OAAdA,EAuDAP,QAvDD,EAAeO,EAAWC,KAAKC,GACrD,kBAAC,EAAD,iBACMA,EADN,CAEEC,IAAKD,aAAF,EAAEA,EAAUN,UAHMI","file":"static/js/PodcastSubscription.9fb24436.chunk.js","sourcesContent":["import { normalizeJssFields } from '_utils/helpers/jss';\r\nimport { SitecoreFieldValidator } from '_utils/validationChecks/definitions';\r\n\r\nimport { PodcastProps } from './definitions';\r\n\r\nexport const isValidPodcast = (\r\n item: PodcastProps,\r\n) => {\r\n if (!item) {\r\n return false;\r\n }\r\n const {\r\n icon,\r\n link,\r\n title,\r\n } = normalizeJssFields(item);\r\n\r\n return !!title?.value && !!link?.value?.href && !!icon?.value?.src;\r\n};\r\n\r\nexport const PodcastSubscriptionValidators: SitecoreFieldValidator[] = [\r\n {\r\n field: 'rendering.fields.data.datasource',\r\n errorMessage: 'Component has no data source',\r\n },\r\n {\r\n field: 'rendering.fields.data.datasource.title.jss.value',\r\n errorMessage: 'Component missing: \"title\"',\r\n required: true\r\n },\r\n {\r\n field: 'rendering.fields.data.datasource.heading.jss.value',\r\n errorMessage: 'Component missing: \"heading\"',\r\n required: true\r\n },\r\n {\r\n field: 'rendering.fields.data.datasource.description.jss.value',\r\n errorMessage: 'Component missing: \"description\"',\r\n required: true\r\n },\r\n {\r\n field: 'rendering.fields.data.datasource.podcastSubscriptionSources.targetItems',\r\n errorMessage: 'Component missing: \"podcast Subscription Sources\".',\r\n minLength: 1,\r\n },\r\n {\r\n field: 'rendering.fields.data.datasource.podcastSubscriptionSources.targetItems',\r\n errorMessage: 'Component has an invalid platform and will not be displayed.',\r\n allowRenderOnError: true,\r\n validators: [\r\n (field) => isValidPodcast(field),\r\n ],\r\n }\r\n];\r\n","import { Image as SCImage } from '@sitecore-jss/sitecore-jss-react';\r\nimport styled, { css } from 'styled-components';\r\n\r\nimport { Link } from '_utils/components';\r\nimport { spacing } from '_utils/props';\r\nimport {\r\n hideOnPrint,\r\n mq,\r\n textBody1,\r\n} from '_utils/styles';\r\n\r\nexport const Container = styled.div`\r\n border: 1px solid ${({ theme }) => theme.colors.ui.defaultBorderColor};\r\n border-radius: 8px;\r\n ${({ theme }) => spacing({ theme, pt:3 , pb: 3, px: 3 })}\r\n\r\n // override default bottom margin\r\n h4 {\r\n ${({ theme }) => spacing({ theme, mb: 1 })}\r\n }\r\n\r\n ${hideOnPrint}\r\n \r\n &.dark {\r\n background-color: ${({ theme }) => theme.colors.background.darkBlue};\r\n color: ${({ theme }) => theme.colors.text.neutral} !important;\r\n }\r\n \r\n &.light {\r\n background-color: ${({ theme }) => theme.colors.background.tint1};\r\n color: ${({ theme }) => theme.colors.text.contrast} !important;\r\n }\r\n\r\n &.dark h4 {\r\n color: ${({ theme }) => theme.colors.text.neutral} !important;\r\n }\r\n\r\n &.light h4 {\r\n color: ${({ theme }) => theme.colors.text.contrast} !important;\r\n }\r\n\r\n margin-top: ${({ isHideByConditions }) => isHideByConditions ? '0px' : '80px' };\r\n margin-bottom: 120px;\r\n\r\n // The below is to control two Subscription on the same page\r\n ${mq('xs')} {\r\n ${({ isHideByConditions, podcastSeriesCardsNum , podcastRelatedCardsNum }) => {\r\n if(isHideByConditions) {\r\n const totalNum = podcastSeriesCardsNum + podcastRelatedCardsNum\r\n if(totalNum < 3 ) {\r\n return css`display: none;`\r\n }\r\n }\r\n }\r\n }\r\n\r\n ${mq('md')} {\r\n ${({ isHideByConditions, podcastSeriesCardsNum , podcastRelatedCardsNum }) => {\r\n if(isHideByConditions) {\r\n const totalNum = podcastSeriesCardsNum + podcastRelatedCardsNum\r\n if(podcastSeriesCardsNum === 2 && podcastRelatedCardsNum === 2 ) {\r\n return `display: none;`\r\n }\r\n\r\n if(totalNum < 4) {\r\n return css`display: none;`\r\n }\r\n }\r\n }\r\n }\r\n\r\n ${mq('lg')} {\r\n ${({ isHideByConditions, podcastSeriesCardsNum , podcastRelatedCardsNum }) => {\r\n if(isHideByConditions) {\r\n const totalNum = podcastSeriesCardsNum + podcastRelatedCardsNum\r\n if(podcastSeriesCardsNum < 3 && podcastSeriesCardsNum > 0 && podcastRelatedCardsNum > 3 ) {\r\n return css`display: block;`\r\n }\r\n\r\n if(podcastRelatedCardsNum < 3 && podcastRelatedCardsNum > 0 && podcastSeriesCardsNum > 3 ) {\r\n return css`display: block;`\r\n }\r\n\r\n if(totalNum < 7) {\r\n return css`display: none;`\r\n }\r\n }\r\n }\r\n }\r\n`;\r\n\r\nexport const Heading = styled.div`\r\n ${textBody1};\r\n font-weight: bold;\r\n ${mq('md')} {\r\n float: left;\r\n }\r\n\r\n ${({ theme }) => spacing(\r\n {\r\n theme,\r\n mb: '10px',\r\n })}\r\n`;\r\n\r\nexport const PlatformWrapper = styled.div`\r\n display: flex;\r\n flex-direction: column;\r\n\r\n ${mq('md')} {\r\n flex-direction: row;\r\n flex-wrap: wrap;\r\n }\r\n`;\r\n\r\nexport const Figure = styled.figure`\r\n display: block;\r\n height: 24px;\r\n margin: 0;\r\n position: relative;\r\n width: 24px;\r\n\r\n ${mq('md')} {\r\n height: 28px; // align with line-height\r\n }\r\n\r\n ${({ theme }) => spacing({ theme, mr: 1 })}\r\n`;\r\n\r\nexport const Image = styled(SCImage)`\r\n width: 100%;\r\n`;\r\n\r\nexport const PlatformLink = styled(Link)`\r\n\r\n a {\r\n display: flex;\r\n flex: 0 1 auto;\r\n }\r\n\r\n ${({ theme }) => spacing(\r\n {\r\n theme,\r\n mb: { xs: 1, md: 0 },\r\n ml: { md: 3 },\r\n })}\r\n\r\n a span {\r\n align-items: center;\r\n display: flex;\r\n flex: 0 1 auto;\r\n flex-direction: row;\r\n font-weight: bold;\r\n text-decoration: underline;\r\n white-space: nowrap;\r\n\r\n .dark &{\r\n color: ${({ theme }) => theme.colors.text.neutral} !important;\r\n }\r\n\r\n .light & {\r\n color: ${({ theme }) => theme.colors.text.contrast} !important;\r\n }\r\n }\r\n`;\r\n","import { canUseDOM } from 'exenv';\r\nimport { compose } from 'ramda';\r\nimport React, { FC } from 'react';\r\n\r\nimport {\r\n withEditMode\r\n} from '_containers/BaseComponent';\r\nimport { withDigitalDataContext } from '_containers/DigitalDataContext';\r\n\r\nimport { imagePlaceholderSrc } from '_utils/styles';\r\nimport { ImageRatio, ImageSize } from '_utils/types/enums';\r\nimport { emitTrackEvent, setObjectData } from '_utils/helpers/analytics';\r\nimport { PodcastProps } from './definitions';\r\n\r\nimport {\r\n Figure,\r\n Image,\r\n PlatformLink,\r\n} from './StyledPodcastSubscription';\r\nimport { convertSrcJss } from '_utils/media';\r\nimport { getImageAttrsByRatio } from '_utils/helpers/image';\r\n\r\nconst Platform: FC = ({\r\n digitalData,\r\n icon,\r\n link,\r\n setDigitalData,\r\n title,\r\n}) => {\r\n\r\n const handleClick = (title: string) => {\r\n if (!canUseDOM) {\r\n return;\r\n }\r\n\r\n if (typeof setDigitalData === 'function') {\r\n setDigitalData(\r\n setObjectData(\r\n ['podcast'],\r\n {\r\n podcastPlatform: title\r\n },\r\n digitalData\r\n )\r\n );\r\n\r\n emitTrackEvent('podcastSubscribe');\r\n }\r\n }\r\n\r\n const defaultImageSize = getImageAttrsByRatio(ImageSize.MW_24, ImageRatio.Ratio_1By1);\r\n const linkProps = { ...link?.jss?.value, target: '_blank' }\r\n\r\n return (\r\n handleClick(title?.jss?.value)}\r\n >\r\n
\r\n \r\n
\r\n {title?.jss?.value}\r\n \r\n )\r\n};\r\n\r\nexport default compose(\r\n withDigitalDataContext,\r\n withEditMode,\r\n)(Platform);\r\n","import { compose } from 'ramda';\r\nimport React, { useContext } from 'react';\r\nimport { SitecoreContextReactContext } from '@sitecore-jss/sitecore-jss-react';\r\n\r\nimport {\r\n withDataSourceValidation,\r\n withEditMode,\r\n withCoveoNoIndexTags,\r\n withSitecoreContext,\r\n} from '_containers/BaseComponent';\r\n\r\nimport { withDigitalDataContext } from '_containers/DigitalDataContext';\r\n\r\nimport HeadingWithDescription from '_utils/components/HeadingWithDescription';\r\nimport { normalizeJssFields } from '_utils/helpers/jss';\r\n\r\nimport { PodcastSubscriptionProps } from './definitions';\r\n\r\nimport {\r\n isValidPodcast,\r\n PodcastSubscriptionValidators,\r\n} from './validation';\r\n\r\nimport Platform from './Platform';\r\n\r\nimport {\r\n Container,\r\n Heading,\r\n PlatformWrapper,\r\n} from './StyledPodcastSubscription'\r\n\r\nconst renderPlatforms = (platforms) => platforms?.map((platform) => (\r\n \r\n));\r\n\r\nconst PodcastSubscription: React.FC = (\r\n {\r\n rendering\r\n }) => {\r\n\r\n // Below are code for specific requirements\r\n const sitecoreContext: any = useContext(SitecoreContextReactContext);\r\n const pageMainPlaceholders = sitecoreContext?.context?.route?.placeholders?.['jss-content-main'] || []\r\n const pageMainComponents = pageMainPlaceholders[0]?.placeholders?.['jss-components-single-column'] || []\r\n const podcastSeriesCardsInfo = pageMainComponents.find(item => item.componentName === 'PodcastSeriesCards')\r\n const podcastRelatedCardsInfo = pageMainComponents.find(item => item.componentName === 'PodcastRelatedCards')\r\n\r\n const podcastSeriesCards = podcastSeriesCardsInfo?.fields?.data?.cards?.seriesCards || []\r\n const podcastSeriesCardsNum = podcastSeriesCards.length\r\n\r\n const podcastRelatedCards = podcastRelatedCardsInfo?.fields?.data?.cards?.items || []\r\n const podcastRelatedCardsNum = podcastRelatedCards[0]?.podcastcards?.length || 0\r\n\r\n const datasource = rendering?.fields?.data?.datasource || {};\r\n const sources = datasource?.podcastSubscriptionSources?.targetItems || [];\r\n const normalizedFields = normalizeJssFields(datasource);\r\n const heading = normalizedFields?.heading;\r\n const title = normalizedFields?.title;\r\n const description = normalizedFields?.description;\r\n const headingLevel = rendering?.params?.headingLevel || 'h4';\r\n const uid = rendering?.uid;\r\n const backgroundTheme = normalizedFields?.backgroundTheme;\r\n const isHideByConditions= normalizedFields?.isHideByConditions?.value || false\r\n\r\n // ensure only valid sources are display, validation allows for rendering if error\r\n const validSources = sources.filter(source => isValidPodcast(source));\r\n const className=\"podcast-subscription \" + backgroundTheme?.value;\r\n\r\n return (\r\n \r\n \r\n {heading?.value}\r\n \r\n {renderPlatforms(validSources)}\r\n \r\n \r\n );\r\n};\r\n\r\nexport default compose(\r\n withDigitalDataContext,\r\n withEditMode,\r\n withSitecoreContext(),\r\n withDataSourceValidation(PodcastSubscriptionValidators),\r\n withCoveoNoIndexTags)(PodcastSubscription);\r\n"],"sourceRoot":""}