{"version":3,"sources":["webpack:///./Avensia.Common/Features/Markets/MarketsPage.tsx"],"names":["Container","div","marginTop","StyledP","display","Item","li","padding","y","LogoWrap","marginBottom","Logo","width","height","CountrySelectionWrapper","marginRight","marginLeft","createList","list","bare","map","item","i","key","state","currentBreakpoint","props","page","items","concat","countryLinks","sort","a","b","englishName","halfListLength","Math","ceil","length","leftList","slice","rightList","isMobile","className","src","image","title","alt","ratio","OneToOne","fontSize","D32_M20","upperCase","header","labels","countryCode","suggestionText","matchingCountryLinkItem","find","createSuggestion","ipCountryCode","suggestion"],"mappings":"8NAyBMA,EAAY,IAAOC,IAAI,CAC3BC,UAAW,SAGPC,EAAU,YAAO,IAAW,CAChCC,QAAS,iBAGLC,EAAO,IAAOC,GAAG,CACrBC,QAAS,CAAEC,EAAG,SAGVC,EAAW,IAAOR,IAAI,CAC1BC,UAAW,OACXQ,aAAc,SAGVC,EAAO,YAAO,IAAS,CAC3BC,MAAO,OACPC,OAAQ,SAGJC,EAA0B,IAAOb,MAAG,GACxCc,YAAa,OACbC,WAAY,SACX,UAAY,KAAsB,CACjCd,UAAW,OACXa,YAAa,OACbC,WAAY,Q,IAIVC,EAAa,SAACC,GAClB,OACE,kBAAC,IAAE,CAACC,MAAI,GACLD,EAAKE,KAAI,SAACC,EAAqCC,GAC9C,OACE,kBAACjB,EAAI,CAACkB,IAAKD,GACT,kBAAC,UAAgB,eAAKD,UAmFnB,uBAAQ,SAAAG,GAAS,OAC9BC,kBAAmBD,EAAMC,qBADZ,EAvDf,SAAqBC,GACnB,IAAMC,EAAOD,EAAMC,KAGbC,EAAQ,GACXC,OAAO,YAAiBF,EAAKG,cAAcF,OAC3CG,MAAK,SAACC,EAAkCC,GACvC,OAAID,EAAEE,cAAgBD,EAAEC,YACf,EAEFF,EAAEE,YAAcD,EAAEC,YAAc,GAAK,KAG1CC,EAAiBC,KAAKC,KAAoB,GAAfT,EAAMU,QACjCC,EAAWX,EAAMY,MAAM,EAAGL,GAC1BM,EAAYb,EAAMY,MAAML,EAAgBP,EAAMU,QAC9CI,EAAW,YAAUhB,EAAMD,mBAEjC,OACE,kBAAC,IAAI,KACH,yBAAKkB,UAAU,QACb,kBAAClC,EAAQ,CAACkC,UAAW,YAAkB,GAAI,KACzC,kBAAChC,EAAI,QAEL+B,GACA,yBAAKC,UAAW,YAAkB,GAAI,IACpC,kBAAC,IAAK,CACJC,IAAK,YAAiBjB,EAAKkB,OAC3BC,MAAO,mBACPC,IAAK,mBACLC,MAAO,IAAWC,YAIxB,yBAAKN,UAAW,YAAkB,GAAI,IACpC,kBAAC7B,EAAuB,KACtB,kBAAC,IAAE,CAACoC,SAAU,IAAeC,QAASC,WAAW,GAC9C,YAAiBzB,EAAK0B,QAAU,YAAiB1B,EAAK0B,QAAU3B,EAAM4B,OAAOR,OAzDnE,SACvB5B,EACAqC,EACAC,GAEA,IAAMC,EAA0BvC,EAAKwC,MAAK,SAACrC,GAEzC,OADwBA,EACDkC,cAAgBA,KAEzC,GAAIE,EACF,OACE,kBAACzD,EAAS,KACR,kBAACG,EAAO,KAAEqD,E,MACV,kBAAC,UAAgB,eAAKC,KA8CjBE,CAAiB/B,EAAOF,EAAMkC,cAAelC,EAAM4B,OAAOO,YAC3D,kBAAC7D,EAAS,CAAC2C,UAAU,QACnB,yBAAKA,UAAW,YAAkB,GAAI,IACnC1B,EAAWsB,IAEd,yBAAKI,UAAW,YAAkB,GAAI,IACnC1B,EAAWwB","file":"assets/45.chunk.816af18af88cf531a95b.js","sourcesContent":["/**\r\n * @ComponentFor MarketsPageViewModel\r\n */\r\nimport connect from 'Shared/connect';\r\nimport React from 'react';\r\nimport BlockPropType from './MarketsPageViewModel.type';\r\nimport { styled } from '@glitz/react';\r\nimport * as style from 'Shared/Style';\r\nimport countryLinkBlockViewModelType from 'Shared/Blocks/CountryLink/CountryLinkBlockViewModel.type';\r\nimport CountryLinkBlock from 'Shared/Blocks/CountryLink/CountryLinkBlock';\r\nimport Ul from 'Shared/Generic/Ul';\r\nimport { H1, Paragraph, ResponsiveSize } from 'Shared/SharedComponents/atoms/Typography';\r\nimport { isCompact } from 'Shared/Viewport';\r\nimport Page from 'Shared/Page';\r\nimport Image, { Ratio as ImageRatio } from 'Shared/Image/Ratio';\r\nimport { epiPropertyValue } from '@polarnopyret/scope-episerver';\r\nimport { createGridClasses } from 'Shared/grid';\r\nimport { AltLogo } from 'Shared/Logotype';\r\n\r\ntype ConnectedProps = {\r\n  currentBreakpoint: number;\r\n};\r\n\r\ntype Props = BlockPropType & ConnectedProps;\r\n\r\nconst Container = styled.div({\r\n  marginTop: '16px',\r\n});\r\n\r\nconst StyledP = styled(Paragraph, {\r\n  display: 'inline-block',\r\n});\r\n\r\nconst Item = styled.li({\r\n  padding: { y: '3px' }\r\n});\r\n\r\nconst LogoWrap = styled.div({\r\n  marginTop: '48px',\r\n  marginBottom: '48px',\r\n})\r\n\r\nconst Logo = styled(AltLogo, {\r\n  width: 'auto',\r\n  height: '32px',\r\n});\r\n\r\nconst CountrySelectionWrapper = styled.div({\r\n  marginRight: '12px',\r\n  marginLeft: '12px',\r\n  ['@media ' + style.mediaMinLarge]: {\r\n    marginTop: '32px',\r\n    marginRight: '48px',\r\n    marginLeft: '48px',\r\n  },\r\n});\r\n\r\nconst createList = (list: any) => {\r\n  return (\r\n    <Ul bare>\r\n      {list.map((item: countryLinkBlockViewModelType, i: number) => {\r\n        return (\r\n          <Item key={i}>\r\n            <CountryLinkBlock {...item} />\r\n          </Item>\r\n        );\r\n      })}\r\n    </Ul>\r\n  );\r\n};\r\n\r\nconst createSuggestion = (\r\n  list: any[],\r\n  countryCode: string,\r\n  suggestionText: string,\r\n) => {\r\n  const matchingCountryLinkItem = list.find((item: any) => {\r\n    const countryLinkItem = item as countryLinkBlockViewModelType;\r\n    return countryLinkItem.countryCode === countryCode;\r\n  });\r\n  if (matchingCountryLinkItem) {\r\n    return (\r\n      <Container>\r\n        <StyledP>{suggestionText}: </StyledP>\r\n        <CountryLinkBlock {...matchingCountryLinkItem} />\r\n      </Container>\r\n    );\r\n  }\r\n  return undefined;\r\n};\r\n\r\nfunction MarketsPage(props: Props) {\r\n  const page = props.page;\r\n\r\n  // copy array and sort it\r\n  const items = []\r\n    .concat(epiPropertyValue(page.countryLinks).items)\r\n    .sort((a: countryLinkBlockViewModelType, b: countryLinkBlockViewModelType) => {\r\n      if (a.englishName === b.englishName) {\r\n        return 0;\r\n      }\r\n      return a.englishName > b.englishName ? 1 : -1;\r\n    });\r\n\r\n  const halfListLength = Math.ceil(items.length * 0.5);\r\n  const leftList = items.slice(0, halfListLength);\r\n  const rightList = items.slice(halfListLength, items.length);\r\n  const isMobile = isCompact(props.currentBreakpoint);\r\n\r\n  return (\r\n    <Page>\r\n      <div className='grid'>\r\n        <LogoWrap className={createGridClasses(12, 12)}>\r\n          <Logo />\r\n        </LogoWrap>\r\n        {!isMobile && (\r\n          <div className={createGridClasses(12, 6)}>\r\n            <Image\r\n              src={epiPropertyValue(page.image)}\r\n              title={'polarnopyret.com'}\r\n              alt={'polarnopyret.com'}\r\n              ratio={ImageRatio.OneToOne}\r\n            />\r\n          </div>\r\n        )}\r\n        <div className={createGridClasses(12, 6)}>\r\n          <CountrySelectionWrapper>\r\n            <H1 fontSize={ResponsiveSize.D32_M20} upperCase={false}>\r\n              {epiPropertyValue(page.header) ? epiPropertyValue(page.header) : props.labels.title}\r\n            </H1>\r\n            {createSuggestion(items, props.ipCountryCode, props.labels.suggestion)}\r\n            <Container className='grid'>\r\n              <div className={createGridClasses(12, 6)}>\r\n                {createList(leftList)}\r\n              </div>\r\n              <div className={createGridClasses(12, 6)}>\r\n                {createList(rightList)}\r\n              </div>\r\n            </Container>\r\n          </CountrySelectionWrapper>\r\n        </div>\r\n      </div>\r\n    </Page>\r\n  );\r\n}\r\n\r\nexport default connect(state => ({\r\n  currentBreakpoint: state.currentBreakpoint,\r\n}))(MarketsPage);\r\n"],"sourceRoot":""}