@zydon/common 2.8.1 → 2.8.3

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.
Files changed (33) hide show
  1. package/dist/{chunk-E4HIWMGS.js → chunk-BJ5IDN65.js} +2 -2
  2. package/dist/chunk-KYV74QIT.js +8 -0
  3. package/dist/chunk-KYV74QIT.js.map +1 -0
  4. package/dist/chunk-QSHKTHGM.js +16 -0
  5. package/dist/chunk-QSHKTHGM.js.map +1 -0
  6. package/dist/{chunk-GEEFHX4U.js → chunk-WRGRGZEM.js} +2 -2
  7. package/dist/components/AvatarButton/index.js +3 -3
  8. package/dist/components/ColorPickerInput/index.js +1 -1
  9. package/dist/components/Common/index.js +3 -3
  10. package/dist/components/DynamicDataView/index.js.map +1 -1
  11. package/dist/components/FrameSkeleton/index.js.map +1 -1
  12. package/dist/components/SeoPreview/index.js +2 -2
  13. package/dist/components/SeoPreview/index.js.map +1 -1
  14. package/dist/components/ToggleTheme/index.js +3 -3
  15. package/dist/components/form/ColorPicker/index.js +1 -1
  16. package/dist/contexts/PushNotifications/index.js +2 -2
  17. package/dist/contexts/PushNotifications/index.js.map +1 -1
  18. package/dist/hooks/useIsVisible.d.ts +1 -1
  19. package/dist/hooks/useIsVisible.js +3 -3
  20. package/dist/hooks/useIsVisible.js.map +1 -1
  21. package/dist/hooks/useThemeToggle.js +3 -3
  22. package/dist/index.js +3 -3
  23. package/dist/theme/theme-provider.js +3 -3
  24. package/dist/theme/with-settings/index.js +2 -2
  25. package/dist/utils/color.d.ts +2 -1
  26. package/dist/utils/color.js +1 -1
  27. package/package.json +1 -1
  28. package/dist/chunk-E3TW4QI3.js +0 -16
  29. package/dist/chunk-E3TW4QI3.js.map +0 -1
  30. package/dist/chunk-TWOLB4FN.js +0 -8
  31. package/dist/chunk-TWOLB4FN.js.map +0 -1
  32. /package/dist/{chunk-E4HIWMGS.js.map → chunk-BJ5IDN65.js.map} +0 -0
  33. /package/dist/{chunk-GEEFHX4U.js.map → chunk-WRGRGZEM.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/FrameSkeleton/index.tsx","../../../src/components/FrameSkeleton/styles.ts"],"names":["IconButton","Stack","Typography","Button","styled","Sidebar","theme","SidebarContent","Nav","Content","TopBox","SectionLink","HeaderContent","Children","Section","SectionContent","Panel_default","SectionTitle","SectionSubtitle","jsx","jsxs","FrameSkeleton","title","subtitle","children","sections","headerLeftContent","headerRightContent","showLeftContent","onClickBack","useCollapseSidebarOnMount_default","Scrollbar_default","section","Icon_default","index","id","titleId","FrameSkeleton_default"],"mappings":"gXAAA,OAAOA,MAAgB,2BACvB,OAAOC,MAAW,sBAClB,OAAOC,MAAgB,2BCFvB,OAAOC,MAAY,uBACnB,OAAOF,MAAW,sBAClB,OAAS,UAAAG,MAAc,uBACvB,OAAOF,MAAqC,2BAIrC,IAAMG,EAAUD,EAAO,OAAO,EAAE,CAAC,CAAE,MAAAE,CAAM,KAAO,CACrD,gBAAiBA,EAAM,QAAQ,WAAW,MAC1C,SAAU,IACV,KAAM,EACN,YAAa,aAAaA,EAAM,QAAQ,UAExC,CAACA,EAAM,YAAY,KAAK,IAAI,CAAC,EAAG,CAC9B,QAAS,MACX,CACF,EAAE,EAEWC,EAAiBH,EAAOH,CAAK,EAAE,CAC1C,SAAU,SACV,IAAK,0CACL,OAAQ,iDACV,CAAC,EAEYO,EAAMJ,EAAO,KAAK,EAAE,CAC/B,QAAS,OACT,cAAe,QACjB,CAAC,EAEYK,EAAUL,EAAO,MAAM,EAAE,CAAC,CAAE,MAAAE,CAAM,KAAO,CACpD,KAAM,EACN,MAAO,OACP,SAAU,OAEV,CAACA,EAAM,YAAY,GAAG,IAAI,CAAC,EAAG,CAC5B,kBAAmB,CAAE,SAAU,oBAAqB,CACtD,CACF,EAAE,EAEWI,EAASN,EAAOH,CAAK,EAAE,CAAC,CAAE,MAAAK,CAAM,KAAO,CAClD,SAAU,SACV,IAAK,oCACL,cAAe,MACf,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KAAK,SAAS,kBAAiBC,EACvE,UAAAJ,EAAQ,OACPb,EAACF,EAAA,CACC,UAAU,KACV,GAAImB,EACJ,IAAKJ,EAAQ,IAEZ,SAAAA,EAAQ,MACX,EAEDA,EAAQ,UACPb,EAACD,EAAA,CAAiB,SAAAc,EAAQ,SAAS,EAGrCb,EAACJ,EAAA,CAAgB,GAAGiB,EAAQ,oBACzB,SAAAA,EAAQ,MACX,IAhBYA,EAAQ,OAASG,CAiB/B,CAEJ,CAAC,GACH,GACF,GACF,GAIGE,EAAQhB","sourcesContent":["import IconButton from '@mui/material/IconButton';\nimport Stack from '@mui/material/Stack';\nimport Typography from '@mui/material/Typography';\n\nimport Icon from 'components/Icon';\nimport Scrollbar from 'components/Scrollbar';\nimport useCollapseSidebarOnMount from 'hooks/useCollapseSidebarOnMount';\n\nimport { FrameSkeletonProps } from './props';\nimport {\n Children,\n Content,\n HeaderContent,\n Nav,\n Section,\n SectionContent,\n SectionLink,\n SectionSubtitle,\n SectionTitle,\n Sidebar,\n SidebarContent,\n TopBox,\n} from './styles';\n\nconst FrameSkeleton = ({\n title,\n subtitle,\n children,\n sections,\n headerLeftContent,\n headerRightContent,\n showLeftContent = true,\n onClickBack,\n}: FrameSkeletonProps) => {\n useCollapseSidebarOnMount(true);\n return (\n <Stack direction=\"row\" flex={1}>\n {showLeftContent && (\n <Sidebar id=\"frame-skeleton-left-box\">\n <SidebarContent>\n <Scrollbar fillContent aria-label=\"Acesso rápido\">\n <Stack gap={1.5}>\n <Typography\n variant=\"overline\"\n color=\"text.disabled\"\n fontWeight={700}\n pt={3}\n px={4}\n pb={0}\n >\n Acesso rápido\n </Typography>\n\n <Nav>\n {sections.map(section => (\n <SectionLink\n key={section.title}\n onClick={() => {\n if (section.ref.current)\n section.ref.current.scrollIntoView({\n block: 'center',\n behavior: 'smooth',\n });\n }}\n >\n {section.title}\n {section.isRequired && (\n <span className=\"required\" aria-label=\"Seção obrigatória\">*</span>\n )}\n </SectionLink>\n ))}\n </Nav>\n </Stack>\n </Scrollbar>\n </SidebarContent>\n </Sidebar>\n )}\n\n <Content className={showLeftContent ? 'with-left-box' : ''}>\n <TopBox>\n <IconButton\n color=\"inherit\"\n onClick={() => onClickBack()}\n data-testid=\"backToPreviousPage\"\n aria-label=\"Voltar\"\n >\n <Icon icon=\"CHEVRON_LEFT\" />\n </IconButton>\n\n <Stack overflow=\"hidden\">\n <Typography variant=\"subtitle1\" noWrap component=\"h1\">\n {title}\n </Typography>\n {subtitle && (\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n noWrap\n component=\"div\"\n >\n {subtitle}\n </Typography>\n )}\n </Stack>\n\n <HeaderContent className=\"header-left-content\">\n {headerLeftContent}\n </HeaderContent>\n\n <HeaderContent justifyContent=\"flex-end\" color=\"text.secondary\">\n {headerRightContent}\n </HeaderContent>\n </TopBox>\n\n <Children>\n <Section>{children}</Section>\n\n {sections.map((section, index) => {\n const id = section.id || `section-${index}`;\n const titleId = `${id}-title`;\n return (\n <Section key={section.title || id} id={id} role=\"region\" aria-labelledby={titleId}>\n {section.title && (\n <SectionTitle\n component=\"h2\"\n id={titleId}\n ref={section.ref as React.RefObject<HTMLDivElement>}\n >\n {section.title}\n </SectionTitle>\n )}\n {section.subTitle && (\n <SectionSubtitle>{section.subTitle}</SectionSubtitle>\n )}\n\n <SectionContent {...section.sectionContentProps}>\n {section.child}\n </SectionContent>\n </Section>\n );\n })}\n </Children>\n </Content>\n </Stack>\n );\n};\n\nexport default FrameSkeleton;\n","import Button from '@mui/material/Button';\nimport Stack from '@mui/material/Stack';\nimport { styled } from '@mui/material/styles';\nimport Typography, { TypographyProps } from '@mui/material/Typography';\n\nimport Panel from 'components/Panel';\n\nexport const Sidebar = styled('aside')(({ theme }) => ({\n backgroundColor: theme.palette.background.paper,\n maxWidth: 300,\n flex: 1,\n borderRight: `1px solid ${theme.palette.divider}`,\n\n [theme.breakpoints.down('md')]: {\n display: 'none',\n },\n}));\n\nexport const SidebarContent = styled(Stack)({\n position: 'sticky',\n top: 'calc(var(--sticky-header-height, 64px))',\n height: 'calc(100vh - var(--sticky-header-height, 64px))',\n});\n\nexport const Nav = styled('nav')({\n display: 'flex',\n flexDirection: 'column',\n});\n\nexport const Content = styled('main')(({ theme }) => ({\n flex: 1,\n width: '100%',\n maxWidth: '100%',\n\n [theme.breakpoints.up('md')]: {\n '&.with-left-box': { maxWidth: 'calc(100% - 300px)' },\n },\n}));\n\nexport const TopBox = styled(Stack)(({ theme }) => ({\n position: 'sticky',\n top: 'var(--sticky-header-height, 64px)',\n flexDirection: 'row',\n alignItems: 'center',\n backgroundColor: theme.palette.background.paper,\n zIndex: theme.zIndex.appBar,\n width: '100%',\n padding: '12px 24px',\n height: 64,\n gap: 12,\n\n [theme.breakpoints.down('md')]: {\n padding: '14px 16px',\n gap: 6,\n },\n borderBottom: `1px solid ${theme.palette.divider}`,\n}));\n\nexport const SectionLink = styled(Button)(({ theme }) => ({\n height: 50,\n background: 'none',\n fontSize: 13,\n fontWeight: 400,\n justifyContent: 'flex-start',\n padding: theme.spacing(1, 4),\n color: theme.palette.text.secondary,\n borderRadius: 0,\n gap: 4,\n\n '&:hover': {\n backgroundColor: 'transparent',\n },\n\n '& .required': {\n color: theme.palette.error.main,\n },\n\n '&:before': {\n content: '\"\"',\n position: 'absolute',\n top: 0,\n left: theme.spacing(2),\n height: 0,\n width: `calc(100% - ${theme.spacing(4)})`,\n borderBottom: `1px dashed ${theme.palette.divider}`,\n },\n}));\n\nexport const HeaderContent = styled(Stack)(({ theme }) => ({\n flex: 1,\n flexDirection: 'row',\n alignItems: 'center',\n gap: 24,\n\n '&.header-left-content': {\n justifyContent: 'flex-start',\n marginLeft: 12,\n },\n\n [theme.breakpoints.down('md')]: {\n gap: 8,\n flex: 'initial',\n\n '& button, & a': {\n display: 'flex',\n textIndent: '-9999em',\n fontSize: 0,\n minWidth: 36,\n maxWidth: 36,\n height: 36,\n width: 36,\n overflow: 'hidden',\n\n '& .MuiButton-icon': {\n margin: 'auto',\n },\n },\n\n '&.header-left-content': {\n justifyContent: 'flex-end',\n marginLeft: 'auto',\n marginRight: -6,\n\n '& label': {\n marginRight: 0,\n },\n\n '& .MuiTypography-root': {\n display: 'none',\n },\n },\n },\n}));\n\nexport const Children = styled(Stack)(({ theme }) => ({\n flex: 1,\n width: '100%',\n padding: 24,\n gap: 24,\n alignItems: 'center',\n overflow: 'hidden',\n\n [theme.breakpoints.down('md')]: {\n padding: '24px 16px',\n },\n}));\n\nexport const Section = styled('section')(({ theme }) => ({\n alignItems: 'start',\n width: '100%',\n maxWidth: 900,\n\n [theme.breakpoints.down('md')]: {\n maxWidth: '100%',\n },\n}));\n\nexport const SectionContent = styled(Panel)(({ theme }) => ({\n width: '100%',\n borderRadius: 12,\n gap: 12,\n\n [theme.breakpoints.down('md')]: {\n padding: '24px 16px',\n },\n}));\n\nexport const SectionTitle = styled(Typography)<TypographyProps>(({ theme }) => ({\n color: theme.palette.text.primary,\n fontSize: 18,\n fontWeight: 900,\n fontFamily: theme.typography.fontFamily,\n margin: 0,\n lineHeight: 1.5,\n}));\n\nexport const SectionSubtitle = styled(Typography)(({ theme }) => ({\n color: theme.palette.text.secondary,\n fontSize: 14,\n fontWeight: 400,\n paddingBottom: 24,\n}));\n"]}
1
+ {"version":3,"sources":["../../../src/components/FrameSkeleton/index.tsx","../../../src/components/FrameSkeleton/styles.ts"],"names":["IconButton","Stack","Typography","Button","styled","Sidebar","theme","SidebarContent","Nav","Content","TopBox","SectionLink","HeaderContent","Children","Section","SectionContent","Panel_default","SectionTitle","SectionSubtitle","jsx","jsxs","FrameSkeleton","title","subtitle","children","sections","headerLeftContent","headerRightContent","showLeftContent","onClickBack","useCollapseSidebarOnMount_default","Scrollbar_default","section","Icon_default","index","id","titleId","FrameSkeleton_default"],"mappings":"gXAAA,OAAOA,MAAgB,2BACvB,OAAOC,MAAW,sBAClB,OAAOC,MAAgB,2BCFvB,OAAOC,MAAY,uBACnB,OAAOF,MAAW,sBAClB,OAAS,UAAAG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B,gBAAkB,GACtD,UAAAR,EAACV,EAAA,CACC,UAAAS,EAACnB,EAAA,CACC,MAAM,UACN,QAAS,IAAM6B,EAAY,EAC3B,cAAY,qBACZ,aAAW,SAEX,SAAAV,EAACc,EAAA,CAAK,KAAK,eAAe,EAC5B,EAEAb,EAACnB,EAAA,CAAM,SAAS,SACd,UAAAkB,EAACjB,EAAA,CAAW,QAAQ,YAAY,OAAM,GAAC,UAAU,KAC9C,SAAAoB,EACH,EACCC,GACCJ,EAACjB,EAAA,CACC,QAAQ,UACR,MAAM,iBACN,OAAM,GACN,UAAU,MAET,SAAAqB,EACH,GAEJ,EAEAJ,EAACP,EAAA,CAAc,UAAU,sBACtB,SAAAc,EACH,EAEAP,EAACP,EAAA,CAAc,eAAe,WAAW,MAAM,iBAC5C,SAAAe,EACH,GACF,EAEAP,EAACP,EAAA,CACC,UAAAM,EAACL,EAAA,CAAS,SAAAU,EAAS,EAElBC,EAAS,IAAI,CAACO,EAASE,IAAU,CAChC,IAAMC,EAAKH,EAAQ,IAAM,WAAWE,IAC9BE,EAAU,GAAGD,UACnB,OACEf,EAACN,EAAA,CAEC,GAAIqB,EACJ,KAAK,SACL,kBAAiBC,EAEhB,UAAAJ,EAAQ,OACPb,EAACF,EAAA,CACC,UAAU,KACV,GAAImB,EACJ,IAAKJ,EAAQ,IAEZ,SAAAA,EAAQ,MACX,EAEDA,EAAQ,UACPb,EAACD,EAAA,CAAiB,SAAAc,EAAQ,SAAS,EAGrCb,EAACJ,EAAA,CAAgB,GAAGiB,EAAQ,oBACzB,SAAAA,EAAQ,MACX,IApBKA,EAAQ,OAASG,CAqBxB,CAEJ,CAAC,GACH,GACF,GACF,GAIGE,EAAQhB","sourcesContent":["import IconButton from '@mui/material/IconButton';\nimport Stack from '@mui/material/Stack';\nimport Typography from '@mui/material/Typography';\n\nimport Icon from 'components/Icon';\nimport Scrollbar from 'components/Scrollbar';\nimport useCollapseSidebarOnMount from 'hooks/useCollapseSidebarOnMount';\n\nimport { FrameSkeletonProps } from './props';\nimport {\n Children,\n Content,\n HeaderContent,\n Nav,\n Section,\n SectionContent,\n SectionLink,\n SectionSubtitle,\n SectionTitle,\n Sidebar,\n SidebarContent,\n TopBox,\n} from './styles';\n\nconst FrameSkeleton = ({\n title,\n subtitle,\n children,\n sections,\n headerLeftContent,\n headerRightContent,\n showLeftContent = true,\n onClickBack,\n}: FrameSkeletonProps) => {\n useCollapseSidebarOnMount(true);\n return (\n <Stack direction=\"row\" flex={1}>\n {showLeftContent && (\n <Sidebar id=\"frame-skeleton-left-box\">\n <SidebarContent>\n <Scrollbar fillContent aria-label=\"Acesso rápido\">\n <Stack gap={1.5}>\n <Typography\n variant=\"overline\"\n color=\"text.disabled\"\n fontWeight={700}\n pt={3}\n px={4}\n pb={0}\n >\n Acesso rápido\n </Typography>\n\n <Nav>\n {sections.map(section => (\n <SectionLink\n key={section.title}\n onClick={() => {\n if (section.ref.current)\n section.ref.current.scrollIntoView({\n block: 'center',\n behavior: 'smooth',\n });\n }}\n >\n {section.title}\n {section.isRequired && (\n <span\n className=\"required\"\n aria-label=\"Seção obrigatória\"\n >\n *\n </span>\n )}\n </SectionLink>\n ))}\n </Nav>\n </Stack>\n </Scrollbar>\n </SidebarContent>\n </Sidebar>\n )}\n\n <Content className={showLeftContent ? 'with-left-box' : ''}>\n <TopBox>\n <IconButton\n color=\"inherit\"\n onClick={() => onClickBack()}\n data-testid=\"backToPreviousPage\"\n aria-label=\"Voltar\"\n >\n <Icon icon=\"CHEVRON_LEFT\" />\n </IconButton>\n\n <Stack overflow=\"hidden\">\n <Typography variant=\"subtitle1\" noWrap component=\"h1\">\n {title}\n </Typography>\n {subtitle && (\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n noWrap\n component=\"div\"\n >\n {subtitle}\n </Typography>\n )}\n </Stack>\n\n <HeaderContent className=\"header-left-content\">\n {headerLeftContent}\n </HeaderContent>\n\n <HeaderContent justifyContent=\"flex-end\" color=\"text.secondary\">\n {headerRightContent}\n </HeaderContent>\n </TopBox>\n\n <Children>\n <Section>{children}</Section>\n\n {sections.map((section, index) => {\n const id = section.id || `section-${index}`;\n const titleId = `${id}-title`;\n return (\n <Section\n key={section.title || id}\n id={id}\n role=\"region\"\n aria-labelledby={titleId}\n >\n {section.title && (\n <SectionTitle\n component=\"h2\"\n id={titleId}\n ref={section.ref as React.RefObject<HTMLDivElement>}\n >\n {section.title}\n </SectionTitle>\n )}\n {section.subTitle && (\n <SectionSubtitle>{section.subTitle}</SectionSubtitle>\n )}\n\n <SectionContent {...section.sectionContentProps}>\n {section.child}\n </SectionContent>\n </Section>\n );\n })}\n </Children>\n </Content>\n </Stack>\n );\n};\n\nexport default FrameSkeleton;\n","import Button from '@mui/material/Button';\nimport Stack from '@mui/material/Stack';\nimport { styled } from '@mui/material/styles';\nimport Typography, { TypographyProps } from '@mui/material/Typography';\n\nimport Panel from 'components/Panel';\n\nexport const Sidebar = styled('aside')(({ theme }) => ({\n backgroundColor: theme.palette.background.paper,\n maxWidth: 300,\n flex: 1,\n borderRight: `1px solid ${theme.palette.divider}`,\n\n [theme.breakpoints.down('md')]: {\n display: 'none',\n },\n}));\n\nexport const SidebarContent = styled(Stack)({\n position: 'sticky',\n top: 'calc(var(--sticky-header-height, 64px))',\n height: 'calc(100vh - var(--sticky-header-height, 64px))',\n});\n\nexport const Nav = styled('nav')({\n display: 'flex',\n flexDirection: 'column',\n});\n\nexport const Content = styled('main')(({ theme }) => ({\n flex: 1,\n width: '100%',\n maxWidth: '100%',\n\n [theme.breakpoints.up('md')]: {\n '&.with-left-box': { maxWidth: 'calc(100% - 300px)' },\n },\n}));\n\nexport const TopBox = styled(Stack)(({ theme }) => ({\n position: 'sticky',\n top: 'var(--sticky-header-height, 64px)',\n flexDirection: 'row',\n alignItems: 'center',\n backgroundColor: theme.palette.background.paper,\n zIndex: theme.zIndex.appBar,\n width: '100%',\n padding: '12px 24px',\n height: 64,\n gap: 12,\n\n [theme.breakpoints.down('md')]: {\n padding: '14px 16px',\n gap: 6,\n },\n borderBottom: `1px solid ${theme.palette.divider}`,\n}));\n\nexport const SectionLink = styled(Button)(({ theme }) => ({\n height: 50,\n background: 'none',\n fontSize: 13,\n fontWeight: 400,\n justifyContent: 'flex-start',\n padding: theme.spacing(1, 4),\n color: theme.palette.text.secondary,\n borderRadius: 0,\n gap: 4,\n\n '&:hover': {\n backgroundColor: 'transparent',\n },\n\n '& .required': {\n color: theme.palette.error.main,\n },\n\n '&:before': {\n content: '\"\"',\n position: 'absolute',\n top: 0,\n left: theme.spacing(2),\n height: 0,\n width: `calc(100% - ${theme.spacing(4)})`,\n borderBottom: `1px dashed ${theme.palette.divider}`,\n },\n}));\n\nexport const HeaderContent = styled(Stack)(({ theme }) => ({\n flex: 1,\n flexDirection: 'row',\n alignItems: 'center',\n gap: 24,\n\n '&.header-left-content': {\n justifyContent: 'flex-start',\n marginLeft: 12,\n },\n\n [theme.breakpoints.down('md')]: {\n gap: 8,\n flex: 'initial',\n\n '& button, & a': {\n display: 'flex',\n textIndent: '-9999em',\n fontSize: 0,\n minWidth: 36,\n maxWidth: 36,\n height: 36,\n width: 36,\n overflow: 'hidden',\n\n '& .MuiButton-icon': {\n margin: 'auto',\n },\n },\n\n '&.header-left-content': {\n justifyContent: 'flex-end',\n marginLeft: 'auto',\n marginRight: -6,\n\n '& label': {\n marginRight: 0,\n },\n\n '& .MuiTypography-root': {\n display: 'none',\n },\n },\n },\n}));\n\nexport const Children = styled(Stack)(({ theme }) => ({\n flex: 1,\n width: '100%',\n padding: 24,\n gap: 24,\n alignItems: 'center',\n overflow: 'hidden',\n\n [theme.breakpoints.down('md')]: {\n padding: '24px 16px',\n },\n}));\n\nexport const Section = styled('section')(({ theme }) => ({\n alignItems: 'start',\n width: '100%',\n maxWidth: 900,\n\n [theme.breakpoints.down('md')]: {\n maxWidth: '100%',\n },\n}));\n\nexport const SectionContent = styled(Panel)(({ theme }) => ({\n width: '100%',\n borderRadius: 12,\n gap: 12,\n\n [theme.breakpoints.down('md')]: {\n padding: '24px 16px',\n },\n}));\n\nexport const SectionTitle = styled(Typography)<TypographyProps>(\n ({ theme }) => ({\n color: theme.palette.text.primary,\n fontSize: 18,\n fontWeight: 900,\n fontFamily: theme.typography.fontFamily,\n margin: 0,\n lineHeight: 1.5,\n }),\n);\n\nexport const SectionSubtitle = styled(Typography)(({ theme }) => ({\n color: theme.palette.text.secondary,\n fontSize: 14,\n fontWeight: 400,\n paddingBottom: 24,\n}));\n"]}
@@ -8,8 +8,8 @@ import r from '@mui/material/Typography';
8
8
  import { styled } from '@mui/material/styles';
9
9
  import { jsx, jsxs } from 'react/jsx-runtime';
10
10
 
11
- var k=styled(p)(({theme:a})=>({padding:24,borderRadius:8,height:"auto",maxWidth:800,backgroundColor:a.palette.background.default,border:`1px solid ${a.palette.grey[300]}`})),P=styled(o)(({theme:a})=>({minHeight:180,maxWidth:700,border:`4px dotted ${a.palette.grey[300]}`,borderRadius:8,backgroundColor:a.palette.background.paper,padding:24})),I=styled(p)(()=>({maxWidth:70,maxHeight:40,alignItems:"center","&, img":{flex:1,display:"flex",objectFit:"cover",borderRadius:8}})),S=styled(p)(({theme:a})=>({backgroundColor:a.palette.background.default,maxWidth:90,maxHeight:80,alignItems:"center","&, img":{flex:1,display:"flex",objectFit:"cover",borderRadius:8}})),v=styled(o)(({theme:a})=>({border:`4px dotted ${a.palette.grey[300]}`,borderRadius:8,backgroundColor:"#fff"})),B=styled(p)(({theme:a})=>({width:"100%",aspectRatio:16/9,overflow:"hidden",padding:2,borderBottom:`4px dotted ${a.palette.grey[300]}`}));var R=({titlePreview:a$2,logoImage:g,brandingName:L,url:m,title:x,description:h,keyWords:w,customTitles:y,productImage:b,child:C,previewLinkImage:u,hasPreviewLink:T})=>jsx(k,{children:jsxs(o,{gap:3,display:"flex",flex:1,children:[jsx(r,{variant:"overline",color:"text.disabled",children:a$2??"PR\xC9-VISUALIZA\xC7\xC3O"}),jsxs(P,{children:[jsxs(o,{direction:"row",pb:3,gap:.5,children:[jsx(p,{height:0,width:10,children:jsx(a,{icon:"CIRCLE",width:30,color:"error.main"})}),jsx(p,{height:0,width:10,children:jsx(a,{icon:"CIRCLE",width:30,color:"warning.main"})}),jsx(p,{height:0,width:10,children:jsx(a,{icon:"CIRCLE",width:30,color:"success.main"})})]}),jsxs(o,{flexDirection:"row",gap:2,justifyContent:"space-between",children:[jsxs(o,{gap:1,width:"100%",children:[jsxs(o,{direction:"row",gap:1.5,pb:.5,children:[g&&jsx(I,{children:jsx("img",{alt:"Logo",src:g})}),jsxs(o,{children:[jsx(r,{variant:"overline",color:"grey.600",pb:.5,children:L??"SUAEMPRESA"}),jsxs(o,{direction:"row",gap:2,children:[jsx(r,{variant:"caption",color:"grey.600",children:m??"https://www.exemplo.com"}),jsx(a,{icon:"MORE_OPTIONS_VERTICAL",width:15,color:"grey.500"})]})]})]}),jsx(a$1,{variant:"subtitle1",color:"#4E5BEC",overflow:"hidden",textOverflow:"ellipsis",line:5,children:x??"Suampresa | P\xE1scoa 2024: Ovos de chocolate? Que nada! Descontos em tecnologia!"}),jsx(a$1,{variant:"caption",color:"text.disabled",overflow:"hidden",textOverflow:"ellipsis",line:5,children:h??"A P\xE1scoa chegou e a Sua Empresa est\xE1 com ofertas chocantes em tecnologia! Descontos de at\xE9 50% em notebooks, smartphones, tablets e muito mais!"}),w&&jsx(o,{direction:"row",gap:1,alignItems:"center",children:w.map((s,d)=>jsxs(o,{direction:"row",gap:1,alignItems:"center",children:[jsx(r,{variant:"caption",color:"text.disabled",children:s}),d<w.length-1&&jsx(p,{width:4,height:16,children:jsx(a,{icon:"CIRCLE",color:"text.disabled",width:10})})]},`keyword-${d}`))}),y&&jsx(o,{pt:2,children:y.map((s,d)=>jsxs(o,{gap:1,children:[jsx(r,{variant:"subtitle1",color:"#4E5BEC",children:s.title}),jsx(a$1,{variant:"caption",color:"text.disabled",overflow:"hidden",textOverflow:"ellipsis",line:1,children:s.description??"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys stansince the 1500"})]},d))}),C]}),b&&jsx(S,{children:jsx("img",{alt:"ProductImage",src:b})})]})]}),T&&jsxs(o,{gap:3,display:"flex",flex:1,width:"100%",children:[jsx(r,{variant:"overline",color:"text.disabled",children:"pr\xE9-visualiza\xE7\xE3o link de compartilhamento".toUpperCase()}),jsxs(v,{children:[u&&jsx(B,{children:jsx("img",{alt:"PreviewLinkImage",src:u,style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:8}})}),jsxs(o,{gap:.2,p:2,width:"100%",children:[jsx(r,{variant:"caption",children:x??"Suampresa | P\xE1scoa 2024: Ovos de chocolate? Que nada! Descontos em tecnologia!"}),jsx(r,{variant:"caption",color:"grey.600",children:h??"A P\xE1scoa chegou e a Sua Empresa est\xE1 com ofertas chocantes em tecnologia! Descontos de at\xE9 50% em notebooks, smartphones, tablets e muito mais!"}),jsx(r,{variant:"caption",color:"grey.500",children:m??"https://www.exemplo.com"})]})]}),jsx(v,{children:jsxs(o,{direction:"row",gap:1,alignItems:"center",children:[jsx(p,{width:100,height:95,bgcolor:"grey.100",p:.5,alignItems:"center",children:jsx("img",{alt:"Logo",src:g,style:{width:"100%",height:"100%",objectFit:"contain",borderRadius:8}})}),jsxs(o,{padding:1,gap:.2,width:"80%",children:[jsx(a$1,{variant:"caption",children:x??"Suampresa | P\xE1scoa 2024: Ovos de chocolate? Que nada! Descontos em tecnologia!"}),jsx(a$1,{variant:"caption",color:"grey.600",children:h??"A P\xE1scoa chegou e a Sua Empresa est\xE1 com ofertas chocantes em tecnologia! Descontos de at\xE9 50% em notebooks, smartphones, tablets e muito mais!"}),jsx(a$1,{variant:"caption",color:"grey.500",line:1,children:m??"https://www.exemplo.com"})]})]})})]})]})}),U=R;
11
+ var k=styled(p)(({theme:a})=>({padding:24,borderRadius:8,height:"auto",maxWidth:800,backgroundColor:a.palette.background.default,border:`1px solid ${a.palette.grey[300]}`})),P=styled(o)(({theme:a})=>({minHeight:180,maxWidth:700,border:`4px dotted ${a.palette.grey[300]}`,borderRadius:8,backgroundColor:a.palette.background.paper,padding:24})),B=styled(p)(()=>({maxWidth:70,maxHeight:40,alignItems:"center","&, img":{flex:1,display:"flex",objectFit:"cover",borderRadius:8}})),I=styled(p)(({theme:a})=>({backgroundColor:a.palette.background.default,maxWidth:90,maxHeight:80,alignItems:"center","&, img":{flex:1,display:"flex",objectFit:"cover",borderRadius:8}})),v=styled(o)(({theme:a})=>({border:`4px dotted ${a.palette.grey[300]}`,borderRadius:8,backgroundColor:"#fff"})),S=styled(p)(({theme:a})=>({width:"100%",aspectRatio:16/9,overflow:"hidden",padding:2,borderBottom:`4px dotted ${a.palette.grey[300]}`}));var E=({titlePreview:a$2,logoImage:g,brandingName:L,url:m,title:x,description:h,keyWords:w,customTitles:y,productImage:u,child:C,previewLinkImage:b,hasPreviewLink:T})=>jsx(k,{children:jsxs(o,{gap:3,display:"flex",flex:1,children:[jsx(r,{variant:"overline",color:"text.disabled",children:a$2??"Pr\xE9-visualiza\xE7\xE3o"}),jsxs(P,{children:[jsxs(o,{direction:"row",pb:3,gap:.5,children:[jsx(p,{height:0,width:10,children:jsx(a,{icon:"CIRCLE",width:30,color:"error.main"})}),jsx(p,{height:0,width:10,children:jsx(a,{icon:"CIRCLE",width:30,color:"warning.main"})}),jsx(p,{height:0,width:10,children:jsx(a,{icon:"CIRCLE",width:30,color:"success.main"})})]}),jsxs(o,{flexDirection:"row",gap:2,justifyContent:"space-between",children:[jsxs(o,{gap:1,width:"100%",children:[jsxs(o,{direction:"row",gap:1.5,pb:.5,children:[g&&jsx(B,{children:jsx("img",{alt:"Logo",src:g})}),jsxs(o,{children:[jsx(r,{variant:"overline",color:"grey.600",pb:.5,children:L??"SUAEMPRESA"}),jsxs(o,{direction:"row",gap:2,children:[jsx(r,{variant:"caption",color:"grey.600",children:m??"https://www.exemplo.com"}),jsx(a,{icon:"MORE_OPTIONS_VERTICAL",width:15,color:"grey.500"})]})]})]}),jsx(a$1,{variant:"subtitle1",color:"#4E5BEC",overflow:"hidden",textOverflow:"ellipsis",line:5,children:x??"Suampresa | P\xE1scoa 2024: Ovos de chocolate? Que nada! Descontos em tecnologia!"}),jsx(a$1,{variant:"caption",color:"text.disabled",overflow:"hidden",textOverflow:"ellipsis",line:5,children:h??"A P\xE1scoa chegou e a Sua Empresa est\xE1 com ofertas chocantes em tecnologia! Descontos de at\xE9 50% em notebooks, smartphones, tablets e muito mais!"}),w&&jsx(o,{direction:"row",gap:1,alignItems:"center",children:w.map((s,d)=>jsxs(o,{direction:"row",gap:1,alignItems:"center",children:[jsx(r,{variant:"caption",color:"text.disabled",children:s}),d<w.length-1&&jsx(p,{width:4,height:16,children:jsx(a,{icon:"CIRCLE",color:"text.disabled",width:10})})]},`keyword-${d}`))}),y&&jsx(o,{pt:2,children:y.map((s,d)=>jsxs(o,{gap:1,children:[jsx(r,{variant:"subtitle1",color:"#4E5BEC",children:s.title}),jsx(a$1,{variant:"caption",color:"text.disabled",overflow:"hidden",textOverflow:"ellipsis",line:1,children:s.description??"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys stansince the 1500"})]},d))}),C]}),u&&jsx(I,{children:jsx("img",{alt:"ProductImage",src:u})})]})]}),T&&jsxs(o,{gap:3,display:"flex",flex:1,width:"100%",children:[jsx(r,{variant:"overline",color:"text.disabled",children:"pr\xE9-visualiza\xE7\xE3o link de compartilhamento".toUpperCase()}),jsxs(v,{children:[b&&jsx(S,{children:jsx("img",{alt:"PreviewLinkImage",src:b,style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:8}})}),jsxs(o,{gap:.2,p:2,width:"100%",children:[jsx(r,{variant:"caption",children:x??"Suampresa | P\xE1scoa 2024: Ovos de chocolate? Que nada! Descontos em tecnologia!"}),jsx(r,{variant:"caption",color:"grey.600",children:h??"A P\xE1scoa chegou e a Sua Empresa est\xE1 com ofertas chocantes em tecnologia! Descontos de at\xE9 50% em notebooks, smartphones, tablets e muito mais!"}),jsx(r,{variant:"caption",color:"grey.500",children:m??"https://www.exemplo.com"})]})]}),jsx(v,{children:jsxs(o,{direction:"row",gap:1,alignItems:"center",children:[jsx(p,{width:100,height:95,bgcolor:"grey.100",p:.5,alignItems:"center",children:jsx("img",{alt:"Logo",src:g,style:{width:"100%",height:"100%",objectFit:"contain",borderRadius:8}})}),jsxs(o,{padding:1,gap:.2,width:"80%",children:[jsx(a$1,{variant:"caption",children:x??"Suampresa | P\xE1scoa 2024: Ovos de chocolate? Que nada! Descontos em tecnologia!"}),jsx(a$1,{variant:"caption",color:"grey.600",children:h??"A P\xE1scoa chegou e a Sua Empresa est\xE1 com ofertas chocantes em tecnologia! Descontos de at\xE9 50% em notebooks, smartphones, tablets e muito mais!"}),jsx(a$1,{variant:"caption",color:"grey.500",line:1,children:m??"https://www.exemplo.com"})]})]})})]})]})}),z=E;
12
12
 
13
- export { U as default };
13
+ export { z as default };
14
14
  //# sourceMappingURL=out.js.map
15
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/SeoPreview/index.tsx","../../../src/components/SeoPreview/styles.ts"],"names":["Box","Stack","Typography","styled","PreviewBox","theme","InterBoxPreview","LogoImageBox","ProductImageBox","InterBoxPreviewLink","ImageBoxPreviewLink","jsx","jsxs","SeoPreview","titlePreview","logoImage","brandingName","url","title","description","keyWords","customTitles","productImage","child","previewLinkImage","hasPreviewLink","Icon_default","TextMaxLine_default","keyWord","index","customTitle","SeoPreview_default"],"mappings":"wJAAA,OAAOA,MAAS,oBAChB,OAAOC,MAAW,sBAClB,OAAOC,MAAgB,2BCFvB,OAAOF,MAAS,oBAChB,OAAOC,MAAW,sBAClB,OAAS,UAAAE,MAAc,uBAEhB,IAAMC,EAAaD,EAAOH,CAAG,EAAE,CAAC,CAAE,MAAAK,CAAM,KAAO,CACpD,QAAS,GACT,aAAc,EACd,OAAQ,OACR,SAAU,IACV,gBAAiBA,EAAM,QAAQ,WAAW,QAC1C,OAAQ,aAAaA,EAAM,QAAQ,KAAK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ACT,EAAA,CAAW,QAAQ,UACjB,SAAAgB,GACC,oFACJ,EAEAP,EAACT,EAAA,CAAW,QAAQ,UAAU,MAAO,WAClC,SAAAiB,GACC,2JACJ,EAEAR,EAACT,EAAA,CAAW,QAAQ,UAAU,MAAO,WAClC,SAAAe,GAAO,0BACV,GACF,GACF,EAEAN,EAACF,EAAA,CACC,SAAAG,EAACX,EAAA,CAAM,UAAU,MAAM,IAAK,EAAG,WAAW,SACxC,UAAAU,EAACX,EAAA,CACC,MAAO,IACP,OAAQ,GACR,QAAQ,WACR,EAAG,GACH,WAAW,SAEX,SAAAW,EAAC,OACC,IAAI,OACJ,IAAKI,EACL,MAAO,CACL,MAAO,OACP,OAAQ,OACR,UAAW,UACX,aAAc,CAChB,EACF,EACF,EAEAH,EAACX,EAAA,CAAM,QAAS,EAAG,IAAK,GAAK,MAAM,MACjC,UAAAU,EAACgB,EAAA,CAAY,QAAQ,UAClB,SAAAT,GACC,oFACJ,EAEAP,EAACgB,EAAA,CAAY,QAAQ,UAAU,MAAO,WACnC,SAAAR,GACC,2JACJ,EAEAR,EAACgB,EAAA,CAAY,QAAQ,UAAU,MAAO,WAAY,KAAM,EACrD,SAAAV,GAAO,0BACV,GACF,GACF,EACF,GACF,GAEJ,EACF,EAIGc,EAAQlB","sourcesContent":["import Box from '@mui/material/Box';\nimport Stack from '@mui/material/Stack';\nimport Typography from '@mui/material/Typography';\n\nimport Icon from '../Icon';\nimport TextMaxLine from '../TextMaxLine';\n\nimport { SeoPreviewProps } from './props';\nimport {\n ImageBoxPreviewLink,\n InterBoxPreview,\n InterBoxPreviewLink,\n LogoImageBox,\n PreviewBox,\n ProductImageBox,\n} from './styles';\n\nconst SeoPreview = ({\n titlePreview,\n logoImage,\n brandingName,\n url,\n title,\n description,\n keyWords,\n customTitles,\n productImage,\n child,\n previewLinkImage,\n hasPreviewLink,\n}: SeoPreviewProps) => {\n return (\n <PreviewBox>\n <Stack gap={3} display=\"flex\" flex={1}>\n <Typography variant=\"overline\" color=\"text.disabled\">\n {titlePreview ?? 'PRÉ-VISUALIZAÇÃO'}\n </Typography>\n\n <InterBoxPreview>\n <Stack direction=\"row\" pb={3} gap={0.5}>\n <Box height={0} width={10}>\n <Icon icon=\"CIRCLE\" width={30} color=\"error.main\" />\n </Box>\n <Box height={0} width={10}>\n <Icon icon=\"CIRCLE\" width={30} color=\"warning.main\" />\n </Box>\n <Box height={0} width={10}>\n <Icon icon=\"CIRCLE\" width={30} color=\"success.main\" />\n </Box>\n </Stack>\n\n <Stack flexDirection=\"row\" gap={2} justifyContent=\"space-between\">\n <Stack gap={1} width=\"100%\">\n <Stack direction=\"row\" gap={1.5} pb={0.5}>\n {logoImage && (\n <LogoImageBox>\n <img alt=\"Logo\" src={logoImage} />\n </LogoImageBox>\n )}\n <Stack>\n <Typography variant=\"overline\" color=\"grey.600\" pb={0.5}>\n {brandingName ?? 'SUAEMPRESA'}\n </Typography>\n\n <Stack direction=\"row\" gap={2}>\n <Typography variant=\"caption\" color=\"grey.600\">\n {url ?? 'https://www.exemplo.com'}\n </Typography>\n\n <Icon\n icon=\"MORE_OPTIONS_VERTICAL\"\n width={15}\n color={'grey.500'}\n />\n </Stack>\n </Stack>\n </Stack>\n\n <TextMaxLine\n variant=\"subtitle1\"\n color=\"#4E5BEC\"\n overflow=\"hidden\"\n textOverflow=\"ellipsis\"\n line={5}\n >\n {title ??\n 'Suampresa | Páscoa 2024: Ovos de chocolate? Que nada! Descontos em tecnologia!'}\n </TextMaxLine>\n\n <TextMaxLine\n variant=\"caption\"\n color=\"text.disabled\"\n overflow=\"hidden\"\n textOverflow=\"ellipsis\"\n line={5}\n >\n {description ??\n 'A Páscoa chegou e a Sua Empresa está com ofertas chocantes em tecnologia! Descontos de até 50% em notebooks, smartphones, tablets e muito mais!'}\n </TextMaxLine>\n\n {keyWords && (\n <Stack direction=\"row\" gap={1} alignItems=\"center\">\n {keyWords.map((keyWord, index) => (\n <Stack\n key={`keyword-${index}`}\n direction=\"row\"\n gap={1}\n alignItems=\"center\"\n >\n <Typography variant=\"caption\" color=\"text.disabled\">\n {keyWord}\n </Typography>\n\n {index < keyWords.length - 1 && (\n <Box width={4} height={16}>\n <Icon\n icon=\"CIRCLE\"\n color=\"text.disabled\"\n width={10}\n />\n </Box>\n )}\n </Stack>\n ))}\n </Stack>\n )}\n\n {customTitles && (\n <Stack pt={2}>\n {customTitles.map((customTitle, index) => (\n <Stack key={index} gap={1}>\n <Typography variant=\"subtitle1\" color=\"#4E5BEC\">\n {customTitle.title}\n </Typography>\n <TextMaxLine\n variant=\"caption\"\n color=\"text.disabled\"\n overflow=\"hidden\"\n textOverflow=\"ellipsis\"\n line={1}\n >\n {customTitle.description ??\n 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys stansince the 1500'}\n </TextMaxLine>\n </Stack>\n ))}\n </Stack>\n )}\n {child}\n </Stack>\n\n {productImage && (\n <ProductImageBox>\n <img alt=\"ProductImage\" src={productImage} />\n </ProductImageBox>\n )}\n </Stack>\n </InterBoxPreview>\n {hasPreviewLink && (\n <Stack gap={3} display=\"flex\" flex={1} width=\"100%\">\n <Typography variant=\"overline\" color=\"text.disabled\">\n {'pré-visualização link de compartilhamento'.toUpperCase()}\n </Typography>\n\n <InterBoxPreviewLink>\n {previewLinkImage && (\n <ImageBoxPreviewLink>\n <img\n alt=\"PreviewLinkImage\"\n src={previewLinkImage}\n style={{\n width: '100%',\n height: '100%',\n objectFit: 'cover',\n borderRadius: 8,\n }}\n />\n </ImageBoxPreviewLink>\n )}\n\n <Stack gap={0.2} p={2} width=\"100%\">\n <Typography variant=\"caption\">\n {title ??\n 'Suampresa | Páscoa 2024: Ovos de chocolate? Que nada! Descontos em tecnologia!'}\n </Typography>\n\n <Typography variant=\"caption\" color={'grey.600'}>\n {description ??\n 'A Páscoa chegou e a Sua Empresa está com ofertas chocantes em tecnologia! Descontos de até 50% em notebooks, smartphones, tablets e muito mais!'}\n </Typography>\n\n <Typography variant=\"caption\" color={'grey.500'}>\n {url ?? 'https://www.exemplo.com'}\n </Typography>\n </Stack>\n </InterBoxPreviewLink>\n\n <InterBoxPreviewLink>\n <Stack direction=\"row\" gap={1} alignItems=\"center\">\n <Box\n width={100}\n height={95}\n bgcolor=\"grey.100\"\n p={0.5}\n alignItems=\"center\"\n >\n <img\n alt=\"Logo\"\n src={logoImage}\n style={{\n width: '100%',\n height: '100%',\n objectFit: 'contain',\n borderRadius: 8,\n }}\n />\n </Box>\n\n <Stack padding={1} gap={0.2} width=\"80%\">\n <TextMaxLine variant=\"caption\">\n {title ??\n 'Suampresa | Páscoa 2024: Ovos de chocolate? Que nada! Descontos em tecnologia!'}\n </TextMaxLine>\n\n <TextMaxLine variant=\"caption\" color={'grey.600'}>\n {description ??\n 'A Páscoa chegou e a Sua Empresa está com ofertas chocantes em tecnologia! Descontos de até 50% em notebooks, smartphones, tablets e muito mais!'}\n </TextMaxLine>\n\n <TextMaxLine variant=\"caption\" color={'grey.500'} line={1}>\n {url ?? 'https://www.exemplo.com'}\n </TextMaxLine>\n </Stack>\n </Stack>\n </InterBoxPreviewLink>\n </Stack>\n )}\n </Stack>\n </PreviewBox>\n );\n};\n\nexport default SeoPreview;\n","import Box from '@mui/material/Box';\nimport Stack from '@mui/material/Stack';\nimport { styled } from '@mui/material/styles';\n\nexport const PreviewBox = styled(Box)(({ theme }) => ({\n padding: 24,\n borderRadius: 8,\n height: 'auto',\n maxWidth: 800,\n backgroundColor: theme.palette.background.default,\n border: `1px solid ${theme.palette.grey[300]}`,\n}));\n\nexport const InterBoxPreview = styled(Stack)(({ theme }) => ({\n minHeight: 180,\n maxWidth: 700,\n border: `4px dotted ${theme.palette.grey[300]}`,\n borderRadius: 8,\n backgroundColor: theme.palette.background.paper,\n padding: 24,\n}));\n\nexport const LogoImageBox = styled(Box)(() => ({\n maxWidth: 70,\n maxHeight: 40,\n alignItems: 'center',\n\n '&, img': {\n flex: 1,\n display: 'flex',\n objectFit: 'cover',\n borderRadius: 8,\n },\n}));\n\nexport const ProductImageBox = styled(Box)(({ theme }) => ({\n backgroundColor: theme.palette.background.default,\n maxWidth: 90,\n maxHeight: 80,\n alignItems: 'center',\n\n '&, img': {\n flex: 1,\n display: 'flex',\n objectFit: 'cover',\n borderRadius: 8,\n },\n}));\n\nexport const InterBoxPreviewLink = styled(Stack)(({ theme }) => ({\n border: `4px dotted ${theme.palette.grey[300]}`,\n borderRadius: 8,\n backgroundColor: '#fff',\n}));\n\nexport const ImageBoxPreviewLink = styled(Box)(({ theme }) => ({\n width: '100%',\n aspectRatio: 16 / 9,\n overflow: 'hidden',\n padding: 2,\n borderBottom: `4px dotted ${theme.palette.grey[300]}`,\n}));\n"]}
1
+ {"version":3,"sources":["../../../src/components/SeoPreview/index.tsx","../../../src/components/SeoPreview/styles.ts"],"names":["Box","Stack","Typography","styled","PreviewBox","theme","InterBoxPreview","LogoImageBox","ProductImageBox","InterBoxPreviewLink","ImageBoxPreviewLink","jsx","jsxs","SeoPreview","titlePreview","logoImage","brandingName","url","title","description","keyWords","customTitles","productImage","child","previewLinkImage","hasPreviewLink","Icon_default","TextMaxLine_default","keyWord","index","customTitle","SeoPreview_default"],"mappings":"wJAAA,OAAOA,MAAS,oBAChB,OAAOC,MAAW,sBAClB,OAAOC,MAAgB,2BCFvB,OAAOF,MAAS,oBAChB,OAAOC,MAAW,sBAClB,OAAS,UAAAE,MAAc,uBAEhB,IAAMC,EAAaD,EAAOH,CAAG,EAAE,CAAC,CAAE,MAAAK,CAAM,KAAO,CACpD,QAAS,GACT,aAAc,EACd,OAAQ,OACR,SAAU,IACV,gBAAiBA,EAAM,QAAQ,WAAW,QAC1C,OAAQ,aAAaA,EAAM,QAAQ,KAAK,GAAG,GAC7C,EAAE,EAEWC,EAAkBH,EAAOF,CAAK,EAAE,CAAC,CAAE,MAAAI,CAAM,KAAO,CAC3D,UAAW,IACX,SAAU,IACV,OAAQ,cAAcA,EAAM,QAAQ,KAAK,GAAG,IAC5C,aAAc,EACd,gBAAiBA,E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0BACV,GACF,GACF,EAEAN,EAACF,EAAA,CACC,SAAAG,EAACX,EAAA,CAAM,UAAU,MAAM,IAAK,EAAG,WAAW,SACxC,UAAAU,EAACX,EAAA,CACC,MAAO,IACP,OAAQ,GACR,QAAQ,WACR,EAAG,GACH,WAAW,SAEX,SAAAW,EAAC,OACC,IAAI,OACJ,IAAKI,EACL,MAAO,CACL,MAAO,OACP,OAAQ,OACR,UAAW,UACX,aAAc,CAChB,EACF,EACF,EAEAH,EAACX,EAAA,CAAM,QAAS,EAAG,IAAK,GAAK,MAAM,MACjC,UAAAU,EAACgB,EAAA,CAAY,QAAQ,UAClB,SAAAT,GACC,oFACJ,EAEAP,EAACgB,EAAA,CAAY,QAAQ,UAAU,MAAO,WACnC,SAAAR,GACC,2JACJ,EAEAR,EAACgB,EAAA,CAAY,QAAQ,UAAU,MAAO,WAAY,KAAM,EACrD,SAAAV,GAAO,0BACV,GACF,GACF,EACF,GACF,GAEJ,EACF,EAIGc,EAAQlB","sourcesContent":["import Box from '@mui/material/Box';\nimport Stack from '@mui/material/Stack';\nimport Typography from '@mui/material/Typography';\n\nimport Icon from '../Icon';\nimport TextMaxLine from '../TextMaxLine';\n\nimport { SeoPreviewProps } from './props';\nimport {\n ImageBoxPreviewLink,\n InterBoxPreview,\n InterBoxPreviewLink,\n LogoImageBox,\n PreviewBox,\n ProductImageBox,\n} from './styles';\n\nconst SeoPreview = ({\n titlePreview,\n logoImage,\n brandingName,\n url,\n title,\n description,\n keyWords,\n customTitles,\n productImage,\n child,\n previewLinkImage,\n hasPreviewLink,\n}: SeoPreviewProps) => {\n return (\n <PreviewBox>\n <Stack gap={3} display=\"flex\" flex={1}>\n <Typography variant=\"overline\" color=\"text.disabled\">\n {titlePreview ?? 'Pré-visualização'}\n </Typography>\n\n <InterBoxPreview>\n <Stack direction=\"row\" pb={3} gap={0.5}>\n <Box height={0} width={10}>\n <Icon icon=\"CIRCLE\" width={30} color=\"error.main\" />\n </Box>\n <Box height={0} width={10}>\n <Icon icon=\"CIRCLE\" width={30} color=\"warning.main\" />\n </Box>\n <Box height={0} width={10}>\n <Icon icon=\"CIRCLE\" width={30} color=\"success.main\" />\n </Box>\n </Stack>\n\n <Stack flexDirection=\"row\" gap={2} justifyContent=\"space-between\">\n <Stack gap={1} width=\"100%\">\n <Stack direction=\"row\" gap={1.5} pb={0.5}>\n {logoImage && (\n <LogoImageBox>\n <img alt=\"Logo\" src={logoImage} />\n </LogoImageBox>\n )}\n <Stack>\n <Typography variant=\"overline\" color=\"grey.600\" pb={0.5}>\n {brandingName ?? 'SUAEMPRESA'}\n </Typography>\n\n <Stack direction=\"row\" gap={2}>\n <Typography variant=\"caption\" color=\"grey.600\">\n {url ?? 'https://www.exemplo.com'}\n </Typography>\n\n <Icon\n icon=\"MORE_OPTIONS_VERTICAL\"\n width={15}\n color={'grey.500'}\n />\n </Stack>\n </Stack>\n </Stack>\n\n <TextMaxLine\n variant=\"subtitle1\"\n color=\"#4E5BEC\"\n overflow=\"hidden\"\n textOverflow=\"ellipsis\"\n line={5}\n >\n {title ??\n 'Suampresa | Páscoa 2024: Ovos de chocolate? Que nada! Descontos em tecnologia!'}\n </TextMaxLine>\n\n <TextMaxLine\n variant=\"caption\"\n color=\"text.disabled\"\n overflow=\"hidden\"\n textOverflow=\"ellipsis\"\n line={5}\n >\n {description ??\n 'A Páscoa chegou e a Sua Empresa está com ofertas chocantes em tecnologia! Descontos de até 50% em notebooks, smartphones, tablets e muito mais!'}\n </TextMaxLine>\n\n {keyWords && (\n <Stack direction=\"row\" gap={1} alignItems=\"center\">\n {keyWords.map((keyWord, index) => (\n <Stack\n key={`keyword-${index}`}\n direction=\"row\"\n gap={1}\n alignItems=\"center\"\n >\n <Typography variant=\"caption\" color=\"text.disabled\">\n {keyWord}\n </Typography>\n\n {index < keyWords.length - 1 && (\n <Box width={4} height={16}>\n <Icon\n icon=\"CIRCLE\"\n color=\"text.disabled\"\n width={10}\n />\n </Box>\n )}\n </Stack>\n ))}\n </Stack>\n )}\n\n {customTitles && (\n <Stack pt={2}>\n {customTitles.map((customTitle, index) => (\n <Stack key={index} gap={1}>\n <Typography variant=\"subtitle1\" color=\"#4E5BEC\">\n {customTitle.title}\n </Typography>\n <TextMaxLine\n variant=\"caption\"\n color=\"text.disabled\"\n overflow=\"hidden\"\n textOverflow=\"ellipsis\"\n line={1}\n >\n {customTitle.description ??\n 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys stansince the 1500'}\n </TextMaxLine>\n </Stack>\n ))}\n </Stack>\n )}\n {child}\n </Stack>\n\n {productImage && (\n <ProductImageBox>\n <img alt=\"ProductImage\" src={productImage} />\n </ProductImageBox>\n )}\n </Stack>\n </InterBoxPreview>\n {hasPreviewLink && (\n <Stack gap={3} display=\"flex\" flex={1} width=\"100%\">\n <Typography variant=\"overline\" color=\"text.disabled\">\n {'pré-visualização link de compartilhamento'.toUpperCase()}\n </Typography>\n\n <InterBoxPreviewLink>\n {previewLinkImage && (\n <ImageBoxPreviewLink>\n <img\n alt=\"PreviewLinkImage\"\n src={previewLinkImage}\n style={{\n width: '100%',\n height: '100%',\n objectFit: 'cover',\n borderRadius: 8,\n }}\n />\n </ImageBoxPreviewLink>\n )}\n\n <Stack gap={0.2} p={2} width=\"100%\">\n <Typography variant=\"caption\">\n {title ??\n 'Suampresa | Páscoa 2024: Ovos de chocolate? Que nada! Descontos em tecnologia!'}\n </Typography>\n\n <Typography variant=\"caption\" color={'grey.600'}>\n {description ??\n 'A Páscoa chegou e a Sua Empresa está com ofertas chocantes em tecnologia! Descontos de até 50% em notebooks, smartphones, tablets e muito mais!'}\n </Typography>\n\n <Typography variant=\"caption\" color={'grey.500'}>\n {url ?? 'https://www.exemplo.com'}\n </Typography>\n </Stack>\n </InterBoxPreviewLink>\n\n <InterBoxPreviewLink>\n <Stack direction=\"row\" gap={1} alignItems=\"center\">\n <Box\n width={100}\n height={95}\n bgcolor=\"grey.100\"\n p={0.5}\n alignItems=\"center\"\n >\n <img\n alt=\"Logo\"\n src={logoImage}\n style={{\n width: '100%',\n height: '100%',\n objectFit: 'contain',\n borderRadius: 8,\n }}\n />\n </Box>\n\n <Stack padding={1} gap={0.2} width=\"80%\">\n <TextMaxLine variant=\"caption\">\n {title ??\n 'Suampresa | Páscoa 2024: Ovos de chocolate? Que nada! Descontos em tecnologia!'}\n </TextMaxLine>\n\n <TextMaxLine variant=\"caption\" color={'grey.600'}>\n {description ??\n 'A Páscoa chegou e a Sua Empresa está com ofertas chocantes em tecnologia! Descontos de até 50% em notebooks, smartphones, tablets e muito mais!'}\n </TextMaxLine>\n\n <TextMaxLine variant=\"caption\" color={'grey.500'} line={1}>\n {url ?? 'https://www.exemplo.com'}\n </TextMaxLine>\n </Stack>\n </Stack>\n </InterBoxPreviewLink>\n </Stack>\n )}\n </Stack>\n </PreviewBox>\n );\n};\n\nexport default SeoPreview;\n","import Box from '@mui/material/Box';\nimport Stack from '@mui/material/Stack';\nimport { styled } from '@mui/material/styles';\n\nexport const PreviewBox = styled(Box)(({ theme }) => ({\n padding: 24,\n borderRadius: 8,\n height: 'auto',\n maxWidth: 800,\n backgroundColor: theme.palette.background.default,\n border: `1px solid ${theme.palette.grey[300]}`,\n}));\n\nexport const InterBoxPreview = styled(Stack)(({ theme }) => ({\n minHeight: 180,\n maxWidth: 700,\n border: `4px dotted ${theme.palette.grey[300]}`,\n borderRadius: 8,\n backgroundColor: theme.palette.background.paper,\n padding: 24,\n}));\n\nexport const LogoImageBox = styled(Box)(() => ({\n maxWidth: 70,\n maxHeight: 40,\n alignItems: 'center',\n\n '&, img': {\n flex: 1,\n display: 'flex',\n objectFit: 'cover',\n borderRadius: 8,\n },\n}));\n\nexport const ProductImageBox = styled(Box)(({ theme }) => ({\n backgroundColor: theme.palette.background.default,\n maxWidth: 90,\n maxHeight: 80,\n alignItems: 'center',\n\n '&, img': {\n flex: 1,\n display: 'flex',\n objectFit: 'cover',\n borderRadius: 8,\n },\n}));\n\nexport const InterBoxPreviewLink = styled(Stack)(({ theme }) => ({\n border: `4px dotted ${theme.palette.grey[300]}`,\n borderRadius: 8,\n backgroundColor: '#fff',\n}));\n\nexport const ImageBoxPreviewLink = styled(Box)(({ theme }) => ({\n width: '100%',\n aspectRatio: 16 / 9,\n overflow: 'hidden',\n padding: 2,\n borderBottom: `4px dotted ${theme.palette.grey[300]}`,\n}));\n"]}
@@ -1,10 +1,10 @@
1
1
  export { a as default } from '../../chunk-NB6Z5G2Q.js';
2
2
  import '../../chunk-EDWQYAWG.js';
3
- import '../../chunk-E4HIWMGS.js';
3
+ import '../../chunk-BJ5IDN65.js';
4
4
  import '../../chunk-373WGZZL.js';
5
5
  import '../../chunk-FTYHXGXC.js';
6
- import '../../chunk-GEEFHX4U.js';
7
- import '../../chunk-TWOLB4FN.js';
6
+ import '../../chunk-WRGRGZEM.js';
7
+ import '../../chunk-KYV74QIT.js';
8
8
  import '../../chunk-LRSF3YE6.js';
9
9
  import '../../chunk-HBOBTNB5.js';
10
10
  import '../../chunk-WUFEPE2G.js';
@@ -1,4 +1,4 @@
1
- import { a } from '../../../chunk-E3TW4QI3.js';
1
+ import { a } from '../../../chunk-QSHKTHGM.js';
2
2
  import '../../../chunk-LQRRMVFN.js';
3
3
  import { useFormContext, Controller } from 'react-hook-form';
4
4
  import { jsx } from 'react/jsx-runtime';
@@ -5,8 +5,8 @@ import '../../chunk-TVKBRJHF.js';
5
5
  import { createContext, useState, useRef, useMemo, useEffect, useCallback, useContext } from 'react';
6
6
  import { jsx } from 'react/jsx-runtime';
7
7
 
8
- var Z=createContext(void 0),le=({children:p,originId:C,originType:V,bearerToken:G,vapidKey:H,serviceWorkerPath:k="/",serviceWorkerFile:x="service-worker.js",pollingInterval:W=1e3,apiAdapters:r,onMessageReceived:h,onError:o})=>{let[s,v]=useState(null),[A,R]=useState(0),[B,L]=useState(!1),[y,w]=useState(!1),[N,f]=useState(!1),[P,ee]=useState(!1),[m,te]=useState({subscriptions:[]}),[z,F]=useState(!1),[D]=useState(new Set),E=useRef(new Map),_=useMemo(()=>!s||z,[s,z]);useEffect(()=>{if(!y||!N||!s||!r.fetchMessages||m.subscriptions.length===0)return;let e=setInterval(async()=>{try{let a$1=((await r.fetchMessages(s))?.messages??[]).filter(i=>!(!i?.payload||D.has(i.id)));if(a$1.length===0)return;a$1.forEach(i=>{D.add(i.id),h?.(i.payload,i.topic);}),R(i=>i+a$1.length);try{(await Promise.allSettled(a$1.map(u=>r.updateMessageStatus(u.id,{status:"DELIVERED"})))).forEach(u=>{u.status==="rejected"&&a({type:"ERROR",environment:["development","homologation"],message:"Erro ao marcar mensagem como entregue:",data:u.reason});});}finally{new Set(a$1.map(g=>g.topic).filter(Boolean)).forEach(g=>{E.current.get(g)?.stopPollingOnFirstMessage&&E.current.delete(g);}),m.subscriptions.length>0||(w(!1),f(!1));}}catch(t){a({type:"ERROR",environment:["development","homologation"],message:"Erro ao buscar mensagens:",data:t});}},W);return ()=>clearInterval(e)},[y,N,s,W,r,h,D,m.subscriptions.length]);let b=useCallback(async(e,t)=>{try{let c=e?.toJSON().keys,a={origin_type:V,origin_id:C,...t&&e?{endpoint:e.endpoint,auth:c?.auth,p256dh:c?.p256dh}:{}},i=await r.registerClient(a);return v(i.id),L(!1),ee(t),t||f(!0),i.id}catch(c){return a({type:"ERROR",environment:["development","homologation"],message:"Erro ao registrar cliente:",data:c}),L(!0),o?.(c),null}},[r,C,V,o]);useEffect(()=>{let e=!0,t=null;async function c(){if(!("serviceWorker"in navigator)||!("PushManager"in window)){a({type:"WARN",environment:["development","homologation"],message:"Push notifications n\xE3o suportadas, criando cliente ativo com polling"});try{let a=await b(null,!1);e&&a&&(v(a),f(!0));}catch(a$1){a({type:"ERROR",environment:["development","homologation"],message:"Erro ao registrar cliente ativo:",data:a$1}),o?.(a$1);}return}try{let a$2=await Notification.requestPermission(),i=null,u=!1;if(a$2==="granted")try{let M=await navigator.serviceWorker.register(`${k}${x}`);if(!e||(await navigator.serviceWorker.ready,!e))return;i=await M.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:a$1(H)}),t=async I=>{let K=I.data?.payload,Q=I.data?.id;if(K&&(R(T=>T+1),h?.(K,I.data?.topic)),Q)try{await r.updateMessageStatus(Q,{status:"DELIVERED"});}catch(T){a({type:"ERROR",environment:["development","homologation"],message:"Erro ao atualizar status da mensagem:",data:T}),L(!0),o?.(T);}},navigator.serviceWorker.addEventListener("message",t),u=!0,a({type:"LOG",environment:["development","homologation"],message:"Permiss\xE3o concedida, criando cliente passivo (aguarda webpush)"});}catch(M){a({type:"WARN",environment:["development","homologation"],message:"Falha ao configurar push subscription, criando cliente ativo:",data:M}),u=!1;}else a({type:"WARN",environment:["development","homologation"],message:"Permiss\xE3o de notifica\xE7\xE3o negada, criando cliente ativo com polling"}),u=!1;let g=await b(i,u);e&&g&&(v(g),u||f(!0));}catch(a$1){a({type:"ERROR",environment:["development","homologation"],message:"Erro ao inicializar notifica\xE7\xF5es:",data:a$1}),o?.(a$1);try{let i=await b(null,!1);e&&i&&(v(i),f(!0));}catch(i){a({type:"ERROR",environment:["development","homologation"],message:"Erro ao criar cliente ativo como fallback:",data:i});}}}return G&&c(),()=>{e=!1,t&&"serviceWorker"in navigator&&navigator.serviceWorker.removeEventListener("message",t);}},[G,b,r,H,k,x,h,o]);let l=useCallback(async()=>{if(s){F(!0);try{let e=await r.listSubscriptions(s);te(e);}catch(e){a({type:"ERROR",environment:["development","homologation"],message:"Erro ao listar inscri\xE7\xF5es:",data:e}),o?.(e);}finally{F(!1);}}},[s,r,o]);useEffect(()=>{s&&l();},[s]);let $=useCallback(async(e,t)=>{if(!s){a({type:"WARN",environment:["development","homologation"],message:"Cliente n\xE3o registrado"});return}try{t&&E.current.set(e,t),await r.subscribeTopic(s,e),await l(),!P&&(!y||!N)&&(w(!0),f(!0));}catch(c){a({type:"ERROR",environment:["development","homologation"],message:"Erro ao inscrever no t\xF3pico:",data:c}),o?.(c);}},[s,r,l,o,y,N,P]),j=useCallback(async e=>{if(!s){a({type:"WARN",environment:["development","homologation"],message:"Cliente n\xE3o registrado"});return}try{E.current.delete(e),await r.unsubscribeTopic(s,e),await l();}catch(t){a({type:"ERROR",environment:["development","homologation"],message:"Erro ao desinscrever do t\xF3pico:",data:t}),o?.(t);}},[s,r,l,o]),q=useCallback(async e=>{if(!(!s||e.length===0))try{e.forEach(t=>{E.current.has(t)||E.current.set(t,{});}),await r.subscribeTopicsBatch(s,e),await l(),P||(w(!0),f(!0));}catch(t){a({type:"ERROR",environment:["development","homologation"],message:"Erro ao inscrever em t\xF3picos:",data:t}),o?.(t);}},[s,r,l,o,P]),J=useCallback(async e=>{if(!(!s||e.length===0))try{e.forEach(t=>E.current.delete(t)),await r.unsubscribeTopicsBatch(s,e),await l();}catch(t){a({type:"ERROR",environment:["development","homologation"],message:"Erro ao desinscrever de t\xF3picos:",data:t}),o?.(t);}},[s,r,l,o]),U=useCallback(()=>{R(0);},[]),se=useMemo(()=>({clientId:s,subscribedTopics:m,isLoading:_,newMessageCount:A,isRegisterError:B,subscribeToTopic:$,unsubscribeFromTopic:j,subscribeTopicsBatch:q,unsubscribeTopicsBatch:J,resetMessageCount:U}),[s,m,_,A,B,$,j,q,J,U]);return jsx(Z.Provider,{value:se,children:p})};function Oe(){let p=useContext(Z);if(!p)throw new Error("usePushNotifications precisa estar dentro de PushNotificationProvider");return p}
8
+ var te=createContext(void 0),fe=({children:p,originId:C,originType:V,bearerToken:G,vapidKey:H,serviceWorkerPath:k="/",serviceWorkerFile:x="service-worker.js",pollingInterval:W=1e3,apiAdapters:r,onMessageReceived:h,onError:o})=>{let[s,v]=useState(null),[A,B]=useState(!1),[z,R]=useState(!1),[y,se]=useState(!1),[F,L]=useState(0),[w]=useState(new Set),[m,ie]=useState({subscriptions:[]}),[_,$]=useState(!1),[N,D]=useState(!1),[P,f]=useState(!1),E=useRef(new Map),j=useMemo(()=>!s||_||A,[s,_,A]);useEffect(()=>{if(!N||!P||!s||!r.fetchMessages||m.subscriptions.length===0)return;let e=setInterval(async()=>{try{let a$1=((await r.fetchMessages(s))?.messages??[]).filter(i=>!(!i?.payload||w.has(i.id)));if(a$1.length===0)return;a$1.forEach(i=>{w.add(i.id),h?.(i.payload,i.topic);}),L(i=>i+a$1.length);try{(await Promise.allSettled(a$1.map(u=>r.updateMessageStatus(u.id,{status:"DELIVERED"})))).forEach(u=>{u.status==="rejected"&&a({type:"ERROR",environment:["development","homologation"],message:"Erro ao marcar mensagem como entregue:",data:u.reason});});}finally{new Set(a$1.map(g=>g.topic).filter(Boolean)).forEach(g=>{E.current.get(g)?.stopPollingOnFirstMessage&&E.current.delete(g);}),m.subscriptions.length>0||(D(!1),f(!1));}}catch(t){a({type:"ERROR",environment:["development","homologation"],message:"Erro ao buscar mensagens:",data:t});}},W);return ()=>clearInterval(e)},[r,s,h,N,W,w,P,m.subscriptions.length]);let b=useCallback(async(e,t)=>{B(!0);try{let c=e?.toJSON().keys,a={origin_type:V,origin_id:C,...t&&e?{endpoint:e.endpoint,auth:c?.auth,p256dh:c?.p256dh}:{}},i=await r.registerClient(a);return v(i.id),R(!1),se(t),t||f(!0),i.id}catch(c){return a({type:"ERROR",environment:["development","homologation"],message:"Erro ao registrar cliente:",data:c}),R(!0),o?.(c),null}finally{B(!1);}},[r,o,C,V]);useEffect(()=>{let e=!0,t=null;async function c(){if(!("serviceWorker"in navigator)||!("PushManager"in window)){a({type:"WARN",environment:["development","homologation"],message:"Push notifications n\xE3o suportadas, criando cliente ativo com polling"});try{let a=await b(null,!1);e&&a&&(v(a),f(!0));}catch(a$1){a({type:"ERROR",environment:["development","homologation"],message:"Erro ao registrar cliente ativo:",data:a$1}),o?.(a$1);}return}try{let a$2=await Notification.requestPermission(),i=null,u=!1;if(a$2==="granted")try{let M=await navigator.serviceWorker.register(`${k}${x}`);if(!e||(await navigator.serviceWorker.ready,!e))return;i=await M.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:a$1(H)}),t=async I=>{let X=I.data?.payload,Y=I.data?.id;if(X&&(L(T=>T+1),h?.(X,I.data?.topic)),Y)try{await r.updateMessageStatus(Y,{status:"DELIVERED"});}catch(T){a({type:"ERROR",environment:["development","homologation"],message:"Erro ao atualizar status da mensagem:",data:T}),R(!0),o?.(T);}},navigator.serviceWorker.addEventListener("message",t),u=!0,a({type:"LOG",environment:["development","homologation"],message:"Permiss\xE3o concedida, criando cliente passivo (aguarda webpush)"});}catch(M){a({type:"WARN",environment:["development","homologation"],message:"Falha ao configurar push subscription, criando cliente ativo:",data:M}),u=!1;}else a({type:"WARN",environment:["development","homologation"],message:"Permiss\xE3o de notifica\xE7\xE3o negada, criando cliente ativo com polling"}),u=!1;let g=await b(i,u);e&&g&&(v(g),u||f(!0));}catch(a$1){a({type:"ERROR",environment:["development","homologation"],message:"Erro ao inicializar notifica\xE7\xF5es:",data:a$1}),o?.(a$1);try{let i=await b(null,!1);e&&i&&(v(i),f(!0));}catch(i){a({type:"ERROR",environment:["development","homologation"],message:"Erro ao criar cliente ativo como fallback:",data:i});}}}return G&&c(),()=>{e=!1,t&&"serviceWorker"in navigator&&navigator.serviceWorker.removeEventListener("message",t);}},[r,G,o,h,b,x,k,H]);let O=useCallback(async()=>{if(s){$(!0);try{let e=await r.listSubscriptions(s);ie(e);}catch(e){a({type:"ERROR",environment:["development","homologation"],message:"Erro ao listar inscri\xE7\xF5es:",data:e}),o?.(e);}finally{$(!1);}}},[r,s,o]);useEffect(()=>{s&&O();},[s]);let q=useCallback(async(e,t)=>{if(!s){a({type:"WARN",environment:["development","homologation"],message:"Cliente n\xE3o registrado"});return}try{t&&E.current.set(e,t),await r.subscribeTopic(s,e),await O(),!y&&(!N||!P)&&(D(!0),f(!0));}catch(c){a({type:"ERROR",environment:["development","homologation"],message:"Erro ao inscrever no t\xF3pico:",data:c}),o?.(c);}},[r,s,y,o,N,O,P]),J=useCallback(async e=>{if(!s){a({type:"WARN",environment:["development","homologation"],message:"Cliente n\xE3o registrado"});return}try{E.current.delete(e),await r.unsubscribeTopic(s,e),await O();}catch(t){a({type:"ERROR",environment:["development","homologation"],message:"Erro ao desinscrever do t\xF3pico:",data:t}),o?.(t);}},[r,s,o,O]),U=useCallback(async e=>{if(!(!s||e.length===0))try{e.forEach(t=>{E.current.has(t)||E.current.set(t,{});}),await r.subscribeTopicsBatch(s,e),await O(),y||(D(!0),f(!0));}catch(t){a({type:"ERROR",environment:["development","homologation"],message:"Erro ao inscrever em t\xF3picos:",data:t}),o?.(t);}},[r,s,y,o,O]),K=useCallback(async e=>{if(!(!s||e.length===0))try{e.forEach(t=>E.current.delete(t)),await r.unsubscribeTopicsBatch(s,e),await O();}catch(t){a({type:"ERROR",environment:["development","homologation"],message:"Erro ao desinscrever de t\xF3picos:",data:t}),o?.(t);}},[r,s,o,O]),Q=useCallback(()=>{L(0);},[]),ne=useMemo(()=>({clientId:s,subscribedTopics:m,isLoading:j,newMessageCount:F,isRegisterError:z,subscribeToTopic:q,unsubscribeFromTopic:J,subscribeTopicsBatch:U,unsubscribeTopicsBatch:K,resetMessageCount:Q}),[s,j,z,F,Q,m,q,U,J,K]);return jsx(te.Provider,{value:ne,children:p})};function Ee(){let p=useContext(te);if(!p)throw new Error("usePushNotifications precisa estar dentro de PushNotificationProvider");return p}
9
9
 
10
- export { le as PushNotificationProvider, Oe as usePushNotifications };
10
+ export { fe as PushNotificationProvider, Ee as usePushNotifications };
11
11
  //# sourceMappingURL=out.js.map
12
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/contexts/PushNotifications/index.tsx"],"names":["createContext","useCallback","useContext","useEffect","useMemo","useRef","useState","jsx","PushNotificationContext","PushNotificationProvider","children","originId","originType","bearerToken","vapidKey","serviceWorkerPath","serviceWorkerFile","pollingInterval","apiAdapters","onMessageReceived","onError","clientId","setClientId","newMessageCount","setNewMessageCount","isRegisterError","setIsRegisterError","pollingEnabled","setPollingEnabled","shouldPoll","setShouldPoll","isPassiveClient","setIsPassiveClient","subscribedTopics","setSubscribedTopics","isLoadingSubscriptions","setIsLoadingSubscriptions","processedMessageIds","topicOptionsRef","isLoading","interval","deliverables","m","prev","consoleLog","topic","error","performClientRegistration","subscription","isPassive","keys","payload","response","mounted","messageHandler","initSwAndRegister","id","err","permission","registration","urlBase64ToUint8Array","e","message","deliveredId","fallbackErr","refetchSubscriptions","data","subscribeToTopic","options","unsubscribeFromTopic","subscribeTopicsBatch","topics","unsubscribeTopicsBatch","resetMessageCount","value","usePushNotifications","context"],"mappings":"wJAAA,OACE,iBAAAA,GACA,eAAAC,EACA,cAAAC,GACA,aAAAC,EACA,WAAAC,EACA,UAAAC,GACA,YAAAC,MACK,QA0hBH,cAAAC,OAAA,oBA5gBJ,IAAMC,EAA0BR,GAE9B,MAAS,EAEES,GAA2B,CAAsB,CAC5D,SAAAC,EACA,SAAAC,EACA,WAAAC,EACA,YAAAC,EACA,SAAAC,EACA,kBAAAC,EAAoB,IACpB,kBAAAC,EAAoB,oBACpB,gBAAAC,EAAkB,IAClB,YAAAC,EACA,kBAAAC,EACA,QAAAC,CACF,IAA+C,CAC7C,GAAM,CAACC,EAAUC,CAAW,EAAIhB,EAAwB,IAAI,EACtD,CAACiB,EAAiBC,CAAkB,EAAIlB,EAAiB,CAAC,EAC1D,CAACmB,EAAiBC,CAAkB,EAAIpB,EAAkB,EAAK,EAC/D,CAACqB,EAAgBC,CAAiB,EAAItB,EAAkB,EAAK,EAC7D,CAACuB,EAAYC,CAAa,EAAIxB,EAAkB,EAAK,EACrD,CAACyB,EAAiBC,EAAkB,EAAI1B,EAAkB,EAAK,EAC/D,CAAC2B,EAAkBC,EAAmB,EAAI5B,EAA4B,CAC1E,cAAe,CAAC,CAClB,CAAC,EACK,CAAC6B,EAAwBC,CAAyB,EACtD9B,EAAkB,EAAK,EACnB,CAAC+B,CAAmB,EAAI/B,EAAsB,IAAI,GAAK,EACvDgC,EAAkBjC,GACtB,IAAI,GACN,EAEMkC,EAAYnC,EAChB,IAAM,CAACiB,GAAYc,EACnB,CAACd,EAAUc,CAAsB,CACnC,EAEAhC,EA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,EACDrC,IAAUqC,CAAY,CACxB,CACF,EACA,CAACpC,EAAUH,EAAa+C,EAAsB7C,CAAO,CACvD,EAEMqD,EAAoBxE,EAAY,IAAM,CAC1CuB,EAAmB,CAAC,CACtB,EAAG,CAAC,CAAC,EAECkD,GAAqCtE,EACzC,KAAO,CACL,SAAAiB,EACA,iBAAAY,EACA,UAAAM,EACA,gBAAAhB,EACA,gBAAAE,EACA,iBAAA0C,EACA,qBAAAE,EACA,qBAAAC,EACA,uBAAAE,EACA,kBAAAC,CACF,GACA,CACEpD,EACAY,EACAM,EACAhB,EACAE,EACA0C,EACAE,EACAC,EACAE,EACAC,CACF,CACF,EAEA,OACElE,GAACC,EAAwB,SAAxB,CAAiC,MAAOkE,GACtC,SAAAhE,EACH,CAEJ,EAEO,SAASiE,IAAoD,CAClE,IAAMC,EAAU1E,GAAWM,CAAuB,EAElD,GAAI,CAACoE,EACH,MAAM,IAAI,MACR,uEACF,EAGF,OAAOA,CACT","sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { ConsoleType, Environment } from 'types/consoleLog';\nimport {\n type ClientRegistrationPayload,\n MessageStatus,\n type PushNotificationContextData,\n type PushNotificationProviderProps,\n type SubscriptionsData,\n type TopicSubscriptionOptions,\n} from 'types/pushNotifications';\nimport { consoleLog } from 'utils/consoleLog';\nimport { urlBase64ToUint8Array } from 'utils/urlBase64ToUint8Array';\n\nconst PushNotificationContext = createContext<\n PushNotificationContextData | undefined\n>(undefined);\n\nexport const PushNotificationProvider = <TMessage = unknown,>({\n children,\n originId,\n originType,\n bearerToken,\n vapidKey,\n serviceWorkerPath = '/',\n serviceWorkerFile = 'service-worker.js',\n pollingInterval = 1000,\n apiAdapters,\n onMessageReceived,\n onError,\n}: PushNotificationProviderProps<TMessage>) => {\n const [clientId, setClientId] = useState<string | null>(null);\n const [newMessageCount, setNewMessageCount] = useState<number>(0);\n const [isRegisterError, setIsRegisterError] = useState<boolean>(false);\n const [pollingEnabled, setPollingEnabled] = useState<boolean>(false);\n const [shouldPoll, setShouldPoll] = useState<boolean>(false);\n const [isPassiveClient, setIsPassiveClient] = useState<boolean>(false);\n const [subscribedTopics, setSubscribedTopics] = useState<SubscriptionsData>({\n subscriptions: [],\n });\n const [isLoadingSubscriptions, setIsLoadingSubscriptions] =\n useState<boolean>(false);\n const [processedMessageIds] = useState<Set<string>>(new Set());\n const topicOptionsRef = useRef<Map<string, TopicSubscriptionOptions>>(\n new Map(),\n );\n\n const isLoading = useMemo(\n () => !clientId || isLoadingSubscriptions,\n [clientId, isLoadingSubscriptions],\n );\n\n useEffect(() => {\n if (\n !pollingEnabled ||\n !shouldPoll ||\n !clientId ||\n !apiAdapters.fetchMessages ||\n subscribedTopics.subscriptions.length === 0\n )\n return;\n\n const interval = setInterval(async () => {\n try {\n const result = await apiAdapters.fetchMessages!(clientId);\n const messages = result?.messages ?? [];\n const deliverables = messages.filter(m => {\n if (!m?.payload) return false;\n if (processedMessageIds.has(m.id)) return false;\n return true;\n });\n\n if (deliverables.length === 0) return;\n\n deliverables.forEach(m => {\n processedMessageIds.add(m.id);\n onMessageReceived?.(m.payload, m.topic);\n });\n setNewMessageCount(prev => prev + deliverables.length);\n\n try {\n const updates = await Promise.allSettled(\n deliverables.map(m =>\n apiAdapters.updateMessageStatus(m.id, {\n status: MessageStatus.DELIVERED,\n }),\n ),\n );\n updates.forEach(u => {\n if (u.status === 'rejected') {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [\n Environment.DEVELOPMENT,\n Environment.HOMOLOGATION,\n ],\n message: 'Erro ao marcar mensagem como entregue:',\n data: u.reason,\n });\n }\n });\n } finally {\n const topicsProcessed = new Set(\n deliverables.map(m => m.topic).filter(Boolean) as string[],\n );\n topicsProcessed.forEach(topic => {\n const topicOptions = topicOptionsRef.current.get(topic);\n if (topicOptions?.stopPollingOnFirstMessage) {\n topicOptionsRef.current.delete(topic);\n }\n });\n const hasSubscriptions = subscribedTopics.subscriptions.length > 0;\n if (!hasSubscriptions) {\n setPollingEnabled(false);\n setShouldPoll(false);\n }\n }\n } catch (error) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Erro ao buscar mensagens:',\n data: error,\n });\n }\n }, pollingInterval);\n\n return () => clearInterval(interval);\n }, [\n pollingEnabled,\n shouldPoll,\n clientId,\n pollingInterval,\n apiAdapters,\n onMessageReceived,\n processedMessageIds,\n subscribedTopics.subscriptions.length,\n ]);\n\n const performClientRegistration = useCallback(\n async (subscription: PushSubscription | null, isPassive: boolean) => {\n try {\n const keys = subscription?.toJSON().keys;\n const payload: ClientRegistrationPayload = {\n origin_type: originType,\n origin_id: originId,\n ...(isPassive && subscription\n ? {\n endpoint: subscription.endpoint,\n auth: keys?.auth,\n p256dh: keys?.p256dh,\n }\n : {}),\n };\n\n const response = await apiAdapters.registerClient(payload);\n setClientId(response.id);\n setIsRegisterError(false);\n setIsPassiveClient(isPassive);\n\n if (!isPassive) {\n setShouldPoll(true);\n }\n\n return response.id;\n } catch (error) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Erro ao registrar cliente:',\n data: error,\n });\n setIsRegisterError(true);\n onError?.(error as Error);\n return null;\n }\n },\n [apiAdapters, originId, originType, onError],\n );\n\n useEffect(() => {\n let mounted = true;\n let messageHandler: ((e: MessageEvent) => void) | null = null;\n\n async function initSwAndRegister() {\n if (!('serviceWorker' in navigator) || !('PushManager' in window)) {\n consoleLog({\n type: ConsoleType.WARN,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message:\n 'Push notifications não suportadas, criando cliente ativo com polling',\n });\n\n try {\n const id = await performClientRegistration(null, false);\n if (mounted && id) {\n setClientId(id);\n setShouldPoll(true);\n }\n } catch (err) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Erro ao registrar cliente ativo:',\n data: err,\n });\n onError?.(err as Error);\n }\n return;\n }\n\n try {\n const permission = await Notification.requestPermission();\n\n let subscription: PushSubscription | null = null;\n let isPassiveClient = false;\n\n if (permission === 'granted') {\n try {\n const registration = await navigator.serviceWorker.register(\n `${serviceWorkerPath}${serviceWorkerFile}`,\n );\n\n if (!mounted) return;\n\n await navigator.serviceWorker.ready;\n\n if (!mounted) return;\n\n subscription = await registration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: urlBase64ToUint8Array(\n vapidKey,\n ) as BufferSource,\n });\n\n messageHandler = async (e: MessageEvent) => {\n const message = e.data?.payload;\n const deliveredId = e.data?.id;\n\n if (message) {\n setNewMessageCount(prev => prev + 1);\n onMessageReceived?.(message, e.data?.topic);\n }\n\n if (deliveredId) {\n try {\n await apiAdapters.updateMessageStatus(deliveredId, {\n status: MessageStatus.DELIVERED,\n });\n } catch (err) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [\n Environment.DEVELOPMENT,\n Environment.HOMOLOGATION,\n ],\n message: 'Erro ao atualizar status da mensagem:',\n data: err,\n });\n setIsRegisterError(true);\n onError?.(err as Error);\n }\n }\n };\n\n navigator.serviceWorker.addEventListener('message', messageHandler);\n\n isPassiveClient = true;\n consoleLog({\n type: ConsoleType.LOG,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message:\n 'Permissão concedida, criando cliente passivo (aguarda webpush)',\n });\n } catch (err) {\n consoleLog({\n type: ConsoleType.WARN,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message:\n 'Falha ao configurar push subscription, criando cliente ativo:',\n data: err,\n });\n isPassiveClient = false;\n }\n } else {\n consoleLog({\n type: ConsoleType.WARN,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message:\n 'Permissão de notificação negada, criando cliente ativo com polling',\n });\n isPassiveClient = false;\n }\n\n const id = await performClientRegistration(\n subscription,\n isPassiveClient,\n );\n if (mounted && id) {\n setClientId(id);\n\n if (!isPassiveClient) {\n setShouldPoll(true);\n }\n }\n } catch (err) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Erro ao inicializar notificações:',\n data: err,\n });\n onError?.(err as Error);\n\n try {\n const id = await performClientRegistration(null, false);\n if (mounted && id) {\n setClientId(id);\n setShouldPoll(true);\n }\n } catch (fallbackErr) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Erro ao criar cliente ativo como fallback:',\n data: fallbackErr,\n });\n }\n }\n }\n\n if (bearerToken) {\n void initSwAndRegister();\n }\n\n return () => {\n mounted = false;\n if (messageHandler && 'serviceWorker' in navigator) {\n navigator.serviceWorker.removeEventListener('message', messageHandler);\n }\n };\n }, [\n bearerToken,\n performClientRegistration,\n apiAdapters,\n vapidKey,\n serviceWorkerPath,\n serviceWorkerFile,\n onMessageReceived,\n onError,\n ]);\n\n const refetchSubscriptions = useCallback(async () => {\n if (!clientId) return;\n\n setIsLoadingSubscriptions(true);\n try {\n const data = await apiAdapters.listSubscriptions(clientId);\n setSubscribedTopics(data);\n } catch (error) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Erro ao listar inscrições:',\n data: error,\n });\n onError?.(error as Error);\n } finally {\n setIsLoadingSubscriptions(false);\n }\n }, [clientId, apiAdapters, onError]);\n\n useEffect(() => {\n if (clientId) {\n void refetchSubscriptions();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [clientId]);\n\n const subscribeToTopic = useCallback(\n async (topic: string, options?: TopicSubscriptionOptions) => {\n if (!clientId) {\n consoleLog({\n type: ConsoleType.WARN,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Cliente não registrado',\n });\n return;\n }\n\n try {\n if (options) {\n topicOptionsRef.current.set(topic, options);\n }\n\n await apiAdapters.subscribeTopic(clientId, topic);\n await refetchSubscriptions();\n\n if (!isPassiveClient && (!pollingEnabled || !shouldPoll)) {\n setPollingEnabled(true);\n setShouldPoll(true);\n }\n } catch (error) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Erro ao inscrever no tópico:',\n data: error,\n });\n onError?.(error as Error);\n }\n },\n [\n clientId,\n apiAdapters,\n refetchSubscriptions,\n onError,\n pollingEnabled,\n shouldPoll,\n isPassiveClient,\n ],\n );\n\n const unsubscribeFromTopic = useCallback(\n async (topic: string) => {\n if (!clientId) {\n consoleLog({\n type: ConsoleType.WARN,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Cliente não registrado',\n });\n return;\n }\n\n try {\n topicOptionsRef.current.delete(topic);\n\n await apiAdapters.unsubscribeTopic(clientId, topic);\n await refetchSubscriptions();\n } catch (error) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Erro ao desinscrever do tópico:',\n data: error,\n });\n onError?.(error as Error);\n }\n },\n [clientId, apiAdapters, refetchSubscriptions, onError],\n );\n\n const subscribeTopicsBatch = useCallback(\n async (topics: string[]): Promise<void> => {\n if (!clientId || topics.length === 0) return;\n\n try {\n topics.forEach(topic => {\n if (!topicOptionsRef.current.has(topic)) {\n topicOptionsRef.current.set(topic, {});\n }\n });\n\n await apiAdapters.subscribeTopicsBatch(clientId, topics);\n await refetchSubscriptions();\n\n if (!isPassiveClient) {\n setPollingEnabled(true);\n setShouldPoll(true);\n }\n } catch (err) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Erro ao inscrever em tópicos:',\n data: err,\n });\n onError?.(err as Error);\n }\n },\n [clientId, apiAdapters, refetchSubscriptions, onError, isPassiveClient],\n );\n\n const unsubscribeTopicsBatch = useCallback(\n async (topics: string[]): Promise<void> => {\n if (!clientId || topics.length === 0) return;\n\n try {\n topics.forEach(topic => topicOptionsRef.current.delete(topic));\n\n await apiAdapters.unsubscribeTopicsBatch(clientId, topics);\n await refetchSubscriptions();\n } catch (err) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Erro ao desinscrever de tópicos:',\n data: err,\n });\n onError?.(err as Error);\n }\n },\n [clientId, apiAdapters, refetchSubscriptions, onError],\n );\n\n const resetMessageCount = useCallback(() => {\n setNewMessageCount(0);\n }, []);\n\n const value: PushNotificationContextData = useMemo(\n () => ({\n clientId,\n subscribedTopics,\n isLoading,\n newMessageCount,\n isRegisterError,\n subscribeToTopic,\n unsubscribeFromTopic,\n subscribeTopicsBatch,\n unsubscribeTopicsBatch,\n resetMessageCount,\n }),\n [\n clientId,\n subscribedTopics,\n isLoading,\n newMessageCount,\n isRegisterError,\n subscribeToTopic,\n unsubscribeFromTopic,\n subscribeTopicsBatch,\n unsubscribeTopicsBatch,\n resetMessageCount,\n ],\n );\n\n return (\n <PushNotificationContext.Provider value={value}>\n {children}\n </PushNotificationContext.Provider>\n );\n};\n\nexport function usePushNotifications(): PushNotificationContextData {\n const context = useContext(PushNotificationContext);\n\n if (!context) {\n throw new Error(\n 'usePushNotifications precisa estar dentro de PushNotificationProvider',\n );\n }\n\n return context;\n}\n"]}
1
+ {"version":3,"sources":["../../../src/contexts/PushNotifications/index.tsx"],"names":["createContext","useCallback","useContext","useEffect","useMemo","useRef","useState","jsx","PushNotificationContext","PushNotificationProvider","children","originId","originType","bearerToken","vapidKey","serviceWorkerPath","serviceWorkerFile","pollingInterval","apiAdapters","onMessageReceived","onError","clientId","setClientId","isRegistering","setIsRegistering","isRegisterError","setIsRegisterError","isPassiveClient","setIsPassiveClient","newMessageCount","setNewMessageCount","processedMessageIds","subscribedTopics","setSubscribedTopics","isLoadingSubscriptions","setIsLoadingSubscriptions","pollingEnabled","setPollingEnabled","shouldPoll","setShouldPoll","topicOptionsRef","isLoading","interval","deliverables","m","prev","consoleLog","topic","error","performClientRegistration","subscription","isPassive","keys","payload","response","mounted","messageHandler","initSwAndRegister","id","err","permission","registration","urlBase64ToUint8Array","e","message","deliveredId","fallbackErr","refetchSubscriptions","data","subscribeToTopic","options","unsubscribeFromTopic","subscribeTopicsBatch","topics","unsubscribeTopicsBatch","resetMessageCount","value","usePushNotifications","context"],"mappings":"wJAAA,OACE,iBAAAA,GACA,eAAAC,EACA,cAAAC,GACA,aAAAC,EACA,WAAAC,GACA,UAAAC,GACA,YAAAC,MACK,QAsjBH,cAAAC,OAAA,oBAxiBJ,IAAMC,GAA0BR,GAE9B,MAAS,EAEES,GAA2B,CAAsB,CAC5D,SAAAC,EACA,SAAAC,EACA,WAAAC,EACA,YAAAC,EACA,SAAAC,EACA,kBAAAC,EAAoB,IACpB,kBAAAC,EAAoB,oBACpB,gBAAAC,EAAkB,IAClB,YAAAC,EACA,kBAAAC,EACA,QAAAC,CACF,IAA+C,CAC7C,GAAM,CAACC,EAAUC,CAAW,EAAIhB,EAAwB,IAAI,EACtD,CAACiB,EAAeC,CAAgB,EAAIlB,EAAkB,EAAK,EAC3D,CAACmB,EAAiBC,CAAkB,EAAIpB,EAAkB,EAAK,EAC/D,CAACqB,EAAiBC,EAAkB,EAAItB,EAAkB,EAAK,EAC/D,CAACuB,EAAiBC,CAAkB,EAAIxB,EAAiB,CAAC,EAC1D,CAACyB,CAAmB,EAAIzB,EAAsB,IAAI,GAAK,EAEvD,CAAC0B,EAAkBC,EAAmB,EAAI3B,EAA4B,CAC1E,cAAe,CAAC,CAClB,CAAC,EACK,CAAC4B,EAAwBC,CAAyB,EACtD7B,EAAkB,EAAK,EAEnB,CAAC8B,EAAgBC,CAAiB,EAAI/B,EAAkB,EAAK,EAC7D,CAACgC,EAAYC,CAAa,EAAIjC,EAAkB,EAAK,EAErDkC,EAAkBnC,GACtB,IAAI,GACN,EAEMoC,EAAYrC,GAChB,I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BAAuBG,EAAUoD,CAAM,EACzD,MAAMN,EAAqB,CAC7B,OAASR,EAAP,CACAb,EAAW,CACT,aACA,YAAa,6BAAkD,EAC/D,QAAS,sCACT,KAAMa,CACR,CAAC,EAEDvC,IAAUuC,CAAY,CACxB,CACF,EACA,CAACzC,EAAaG,EAAUD,EAAS+C,CAAoB,CACvD,EAEMQ,EAAoB1E,EAAY,IAAM,CAC1C6B,EAAmB,CAAC,CACtB,EAAG,CAAC,CAAC,EAEC8C,GAAqCxE,GACzC,KAAO,CACL,SAAAiB,EACA,iBAAAW,EACA,UAAAS,EACA,gBAAAZ,EACA,gBAAAJ,EACA,iBAAA4C,EACA,qBAAAE,EACA,qBAAAC,EACA,uBAAAE,EACA,kBAAAC,CACF,GACA,CACEtD,EACAoB,EACAhB,EACAI,EACA8C,EACA3C,EACAqC,EACAG,EACAD,EACAG,CACF,CACF,EAEA,OACEnE,GAACC,GAAwB,SAAxB,CAAiC,MAAOoE,GACtC,SAAAlE,EACH,CAEJ,EAEO,SAASmE,IAAoD,CAClE,IAAMC,EAAU5E,GAAWM,EAAuB,EAElD,GAAI,CAACsE,EACH,MAAM,IAAI,MACR,uEACF,EAGF,OAAOA,CACT","sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { ConsoleType, Environment } from 'types/consoleLog';\nimport {\n type ClientRegistrationPayload,\n MessageStatus,\n type PushNotificationContextData,\n type PushNotificationProviderProps,\n type SubscriptionsData,\n type TopicSubscriptionOptions,\n} from 'types/pushNotifications';\nimport { consoleLog } from 'utils/consoleLog';\nimport { urlBase64ToUint8Array } from 'utils/urlBase64ToUint8Array';\n\nconst PushNotificationContext = createContext<\n PushNotificationContextData | undefined\n>(undefined);\n\nexport const PushNotificationProvider = <TMessage = unknown,>({\n children,\n originId,\n originType,\n bearerToken,\n vapidKey,\n serviceWorkerPath = '/',\n serviceWorkerFile = 'service-worker.js',\n pollingInterval = 1000,\n apiAdapters,\n onMessageReceived,\n onError,\n}: PushNotificationProviderProps<TMessage>) => {\n const [clientId, setClientId] = useState<string | null>(null);\n const [isRegistering, setIsRegistering] = useState<boolean>(false);\n const [isRegisterError, setIsRegisterError] = useState<boolean>(false);\n const [isPassiveClient, setIsPassiveClient] = useState<boolean>(false);\n const [newMessageCount, setNewMessageCount] = useState<number>(0);\n const [processedMessageIds] = useState<Set<string>>(new Set());\n\n const [subscribedTopics, setSubscribedTopics] = useState<SubscriptionsData>({\n subscriptions: [],\n });\n const [isLoadingSubscriptions, setIsLoadingSubscriptions] =\n useState<boolean>(false);\n\n const [pollingEnabled, setPollingEnabled] = useState<boolean>(false);\n const [shouldPoll, setShouldPoll] = useState<boolean>(false);\n\n const topicOptionsRef = useRef<Map<string, TopicSubscriptionOptions>>(\n new Map(),\n );\n\n const isLoading = useMemo(\n () => !clientId || isLoadingSubscriptions || isRegistering,\n [clientId, isLoadingSubscriptions, isRegistering],\n );\n\n useEffect(() => {\n if (\n !pollingEnabled ||\n !shouldPoll ||\n !clientId ||\n !apiAdapters.fetchMessages ||\n subscribedTopics.subscriptions.length === 0\n )\n return;\n\n const interval = setInterval(async () => {\n try {\n const result = await apiAdapters.fetchMessages!(clientId);\n const messages = result?.messages ?? [];\n\n const deliverables = messages.filter(m => {\n if (!m?.payload) return false;\n if (processedMessageIds.has(m.id)) return false;\n\n return true;\n });\n\n if (deliverables.length === 0) return;\n\n deliverables.forEach(m => {\n processedMessageIds.add(m.id);\n onMessageReceived?.(m.payload, m.topic);\n });\n\n setNewMessageCount(prev => prev + deliverables.length);\n\n try {\n const updates = await Promise.allSettled(\n deliverables.map(m =>\n apiAdapters.updateMessageStatus(m.id, {\n status: MessageStatus.DELIVERED,\n }),\n ),\n );\n\n updates.forEach(u => {\n if (u.status === 'rejected') {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [\n Environment.DEVELOPMENT,\n Environment.HOMOLOGATION,\n ],\n message: 'Erro ao marcar mensagem como entregue:',\n data: u.reason,\n });\n }\n });\n } finally {\n const topicsProcessed = new Set(\n deliverables.map(m => m.topic).filter(Boolean) as string[],\n );\n\n topicsProcessed.forEach(topic => {\n const topicOptions = topicOptionsRef.current.get(topic);\n\n if (topicOptions?.stopPollingOnFirstMessage) {\n topicOptionsRef.current.delete(topic);\n }\n });\n\n const hasSubscriptions = subscribedTopics.subscriptions.length > 0;\n\n if (!hasSubscriptions) {\n setPollingEnabled(false);\n setShouldPoll(false);\n }\n }\n } catch (error) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Erro ao buscar mensagens:',\n data: error,\n });\n }\n }, pollingInterval);\n\n return () => clearInterval(interval);\n }, [\n apiAdapters,\n clientId,\n onMessageReceived,\n pollingEnabled,\n pollingInterval,\n processedMessageIds,\n shouldPoll,\n subscribedTopics.subscriptions.length,\n ]);\n\n const performClientRegistration = useCallback(\n async (subscription: PushSubscription | null, isPassive: boolean) => {\n setIsRegistering(true);\n\n try {\n const keys = subscription?.toJSON().keys;\n const payload: ClientRegistrationPayload = {\n origin_type: originType,\n origin_id: originId,\n ...(isPassive && subscription\n ? {\n endpoint: subscription.endpoint,\n auth: keys?.auth,\n p256dh: keys?.p256dh,\n }\n : {}),\n };\n\n const response = await apiAdapters.registerClient(payload);\n\n setClientId(response.id);\n setIsRegisterError(false);\n setIsPassiveClient(isPassive);\n\n if (!isPassive) {\n setShouldPoll(true);\n }\n\n return response.id;\n } catch (error) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Erro ao registrar cliente:',\n data: error,\n });\n\n setIsRegisterError(true);\n onError?.(error as Error);\n\n return null;\n } finally {\n setIsRegistering(false);\n }\n },\n [apiAdapters, onError, originId, originType],\n );\n\n useEffect(() => {\n let mounted = true;\n let messageHandler: ((e: MessageEvent) => void) | null = null;\n\n async function initSwAndRegister() {\n if (!('serviceWorker' in navigator) || !('PushManager' in window)) {\n consoleLog({\n type: ConsoleType.WARN,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message:\n 'Push notifications não suportadas, criando cliente ativo com polling',\n });\n\n try {\n const id = await performClientRegistration(null, false);\n if (mounted && id) {\n setClientId(id);\n setShouldPoll(true);\n }\n } catch (err) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Erro ao registrar cliente ativo:',\n data: err,\n });\n onError?.(err as Error);\n }\n return;\n }\n\n try {\n const permission = await Notification.requestPermission();\n\n let subscription: PushSubscription | null = null;\n let isPassiveClient = false;\n\n if (permission === 'granted') {\n try {\n const registration = await navigator.serviceWorker.register(\n `${serviceWorkerPath}${serviceWorkerFile}`,\n );\n\n if (!mounted) return;\n\n await navigator.serviceWorker.ready;\n\n if (!mounted) return;\n\n subscription = await registration.pushManager.subscribe({\n userVisibleOnly: true,\n applicationServerKey: urlBase64ToUint8Array(\n vapidKey,\n ) as BufferSource,\n });\n\n messageHandler = async (e: MessageEvent) => {\n const message = e.data?.payload;\n const deliveredId = e.data?.id;\n\n if (message) {\n setNewMessageCount(prev => prev + 1);\n onMessageReceived?.(message, e.data?.topic);\n }\n\n if (deliveredId) {\n try {\n await apiAdapters.updateMessageStatus(deliveredId, {\n status: MessageStatus.DELIVERED,\n });\n } catch (err) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [\n Environment.DEVELOPMENT,\n Environment.HOMOLOGATION,\n ],\n message: 'Erro ao atualizar status da mensagem:',\n data: err,\n });\n setIsRegisterError(true);\n onError?.(err as Error);\n }\n }\n };\n\n navigator.serviceWorker.addEventListener('message', messageHandler);\n\n isPassiveClient = true;\n consoleLog({\n type: ConsoleType.LOG,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message:\n 'Permissão concedida, criando cliente passivo (aguarda webpush)',\n });\n } catch (err) {\n consoleLog({\n type: ConsoleType.WARN,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message:\n 'Falha ao configurar push subscription, criando cliente ativo:',\n data: err,\n });\n isPassiveClient = false;\n }\n } else {\n consoleLog({\n type: ConsoleType.WARN,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message:\n 'Permissão de notificação negada, criando cliente ativo com polling',\n });\n isPassiveClient = false;\n }\n\n const id = await performClientRegistration(\n subscription,\n isPassiveClient,\n );\n if (mounted && id) {\n setClientId(id);\n\n if (!isPassiveClient) {\n setShouldPoll(true);\n }\n }\n } catch (err) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Erro ao inicializar notificações:',\n data: err,\n });\n onError?.(err as Error);\n\n try {\n const id = await performClientRegistration(null, false);\n if (mounted && id) {\n setClientId(id);\n setShouldPoll(true);\n }\n } catch (fallbackErr) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Erro ao criar cliente ativo como fallback:',\n data: fallbackErr,\n });\n }\n }\n }\n\n if (bearerToken) {\n void initSwAndRegister();\n }\n\n return () => {\n mounted = false;\n if (messageHandler && 'serviceWorker' in navigator) {\n navigator.serviceWorker.removeEventListener('message', messageHandler);\n }\n };\n }, [\n apiAdapters,\n bearerToken,\n onError,\n onMessageReceived,\n performClientRegistration,\n serviceWorkerFile,\n serviceWorkerPath,\n vapidKey,\n ]);\n\n const refetchSubscriptions = useCallback(async () => {\n if (!clientId) return;\n\n setIsLoadingSubscriptions(true);\n\n try {\n const data = await apiAdapters.listSubscriptions(clientId);\n\n setSubscribedTopics(data);\n } catch (error) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Erro ao listar inscrições:',\n data: error,\n });\n\n onError?.(error as Error);\n } finally {\n setIsLoadingSubscriptions(false);\n }\n }, [apiAdapters, clientId, onError]);\n\n useEffect(() => {\n if (clientId) {\n void refetchSubscriptions();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [clientId]);\n\n const subscribeToTopic = useCallback(\n async (topic: string, options?: TopicSubscriptionOptions) => {\n if (!clientId) {\n consoleLog({\n type: ConsoleType.WARN,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Cliente não registrado',\n });\n\n return;\n }\n\n try {\n if (options) {\n topicOptionsRef.current.set(topic, options);\n }\n\n await apiAdapters.subscribeTopic(clientId, topic);\n await refetchSubscriptions();\n\n if (!isPassiveClient && (!pollingEnabled || !shouldPoll)) {\n setPollingEnabled(true);\n setShouldPoll(true);\n }\n } catch (error) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Erro ao inscrever no tópico:',\n data: error,\n });\n\n onError?.(error as Error);\n }\n },\n [\n apiAdapters,\n clientId,\n isPassiveClient,\n onError,\n pollingEnabled,\n refetchSubscriptions,\n shouldPoll,\n ],\n );\n\n const unsubscribeFromTopic = useCallback(\n async (topic: string) => {\n if (!clientId) {\n consoleLog({\n type: ConsoleType.WARN,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Cliente não registrado',\n });\n\n return;\n }\n\n try {\n topicOptionsRef.current.delete(topic);\n\n await apiAdapters.unsubscribeTopic(clientId, topic);\n await refetchSubscriptions();\n } catch (error) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Erro ao desinscrever do tópico:',\n data: error,\n });\n\n onError?.(error as Error);\n }\n },\n [apiAdapters, clientId, onError, refetchSubscriptions],\n );\n\n const subscribeTopicsBatch = useCallback(\n async (topics: string[]): Promise<void> => {\n if (!clientId || topics.length === 0) return;\n\n try {\n topics.forEach(topic => {\n if (!topicOptionsRef.current.has(topic)) {\n topicOptionsRef.current.set(topic, {});\n }\n });\n\n await apiAdapters.subscribeTopicsBatch(clientId, topics);\n await refetchSubscriptions();\n\n if (!isPassiveClient) {\n setPollingEnabled(true);\n setShouldPoll(true);\n }\n } catch (err) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Erro ao inscrever em tópicos:',\n data: err,\n });\n\n onError?.(err as Error);\n }\n },\n [apiAdapters, clientId, isPassiveClient, onError, refetchSubscriptions],\n );\n\n const unsubscribeTopicsBatch = useCallback(\n async (topics: string[]): Promise<void> => {\n if (!clientId || topics.length === 0) return;\n\n try {\n topics.forEach(topic => topicOptionsRef.current.delete(topic));\n\n await apiAdapters.unsubscribeTopicsBatch(clientId, topics);\n await refetchSubscriptions();\n } catch (err) {\n consoleLog({\n type: ConsoleType.ERROR,\n environment: [Environment.DEVELOPMENT, Environment.HOMOLOGATION],\n message: 'Erro ao desinscrever de tópicos:',\n data: err,\n });\n\n onError?.(err as Error);\n }\n },\n [apiAdapters, clientId, onError, refetchSubscriptions],\n );\n\n const resetMessageCount = useCallback(() => {\n setNewMessageCount(0);\n }, []);\n\n const value: PushNotificationContextData = useMemo(\n () => ({\n clientId,\n subscribedTopics,\n isLoading,\n newMessageCount,\n isRegisterError,\n subscribeToTopic,\n unsubscribeFromTopic,\n subscribeTopicsBatch,\n unsubscribeTopicsBatch,\n resetMessageCount,\n }),\n [\n clientId,\n isLoading,\n isRegisterError,\n newMessageCount,\n resetMessageCount,\n subscribedTopics,\n subscribeToTopic,\n subscribeTopicsBatch,\n unsubscribeFromTopic,\n unsubscribeTopicsBatch,\n ],\n );\n\n return (\n <PushNotificationContext.Provider value={value}>\n {children}\n </PushNotificationContext.Provider>\n );\n};\n\nexport function usePushNotifications(): PushNotificationContextData {\n const context = useContext(PushNotificationContext);\n\n if (!context) {\n throw new Error(\n 'usePushNotifications precisa estar dentro de PushNotificationProvider',\n );\n }\n\n return context;\n}\n"]}
@@ -1,3 +1,3 @@
1
- declare const useIsVisible: <T extends Element>(threshold?: number, rootMargin?: string) => [(node: T | null) => void, boolean];
1
+ declare function useIsVisible<T extends Element>(threshold?: number, rootMargin?: string, keepAlive?: boolean): [React.RefObject<T>, boolean];
2
2
 
3
3
  export { useIsVisible as default };
@@ -1,7 +1,7 @@
1
- import { useState, useRef, useCallback, useEffect } from 'react';
1
+ import { useRef, useState, useEffect } from 'react';
2
2
 
3
- var v=(n=0,s)=>{let[c,i]=useState(!1),e=useRef(null),l=useCallback(t=>{if(e.current?.disconnect(),e.current=null,!t||typeof IntersectionObserver>"u")return;let r=new IntersectionObserver(([u])=>{i(u.isIntersecting);},{threshold:n,rootMargin:s});r.observe(t),e.current=r;},[s,n]);return useEffect(()=>()=>e.current?.disconnect(),[]),[l,c]},a=v;
3
+ function d(t=0,s="50px",r=!1){let c=useRef(null),[l,f]=useState(!1),e=useRef(null);return useEffect(()=>{let i=c.current;if(!i||typeof IntersectionObserver>"u")return;e.current?.disconnect();let n=new IntersectionObserver(([u])=>{f(u.isIntersecting),r&&u.isIntersecting&&(n.disconnect(),e.current=null);},{threshold:t,rootMargin:s});return n.observe(i),e.current=n,()=>{e.current?.disconnect(),e.current=null;}},[t,s,r]),[c,l]}var m=d;
4
4
 
5
- export { a as default };
5
+ export { m as default };
6
6
  //# sourceMappingURL=out.js.map
7
7
  //# sourceMappingURL=useIsVisible.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/useIsVisible.ts"],"names":["useCallback","useEffect","useRef","useState","useIsVisible","threshold","rootMargin","isVisible","setIsVisible","observerRef","ref","node","io","entry","useIsVisible_default"],"mappings":"AAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,UAAAC,EAAQ,YAAAC,MAAgB,QAEzD,IAAMC,EAAe,CACnBC,EAAY,EACZC,IACwC,CACxC,GAAM,CAACC,EAAWC,CAAY,EAAIL,EAAS,EAAK,EAC1CM,EAAcP,EAAoC,IAAI,EAEtDQ,EAAMV,EACTW,GAAmB,CAGlB,GAFAF,EAAY,SAAS,WAAW,EAChCA,EAAY,QAAU,KAClB,CAACE,GAAQ,OAAO,qBAAyB,IAAa,OAE1D,IAAMC,EAAK,IAAI,qBACb,CAAC,CAACC,CAAK,IAAM,CACXL,EAAaK,EAAM,cAAc,CACnC,EACA,CAAE,UAAAR,EAAW,WAAAC,CAAW,CAC1B,EAEAM,EAAG,QAAQD,CAAI,EACfF,EAAY,QAAUG,CACxB,EACA,CAACN,EAAYD,CAAS,CACxB,EAEA,OAAAJ,EAAU,IAAM,IAAMQ,EAAY,SAAS,WAAW,EAAG,CAAC,CAAC,EAEpD,CAACC,EAAKH,CAAS,CACxB,EAEOO,EAAQV","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\n\nconst useIsVisible = <T extends Element>(\n threshold = 0,\n rootMargin?: string,\n): [(node: T | null) => void, boolean] => {\n const [isVisible, setIsVisible] = useState(false);\n const observerRef = useRef<IntersectionObserver | null>(null);\n\n const ref = useCallback(\n (node: T | null) => {\n observerRef.current?.disconnect();\n observerRef.current = null;\n if (!node || typeof IntersectionObserver === 'undefined') return;\n\n const io = new IntersectionObserver(\n ([entry]) => {\n setIsVisible(entry.isIntersecting);\n },\n { threshold, rootMargin },\n );\n\n io.observe(node);\n observerRef.current = io;\n },\n [rootMargin, threshold],\n );\n\n useEffect(() => () => observerRef.current?.disconnect(), []);\n\n return [ref, isVisible];\n};\n\nexport default useIsVisible;\n"]}
1
+ {"version":3,"sources":["../../src/hooks/useIsVisible.ts"],"names":["useEffect","useRef","useState","useIsVisible","threshold","rootMargin","keepAlive","ref","isVisible","setIsVisible","observerRef","element","io","entry","useIsVisible_default"],"mappings":"AAAA,OAAS,aAAAA,EAAW,UAAAC,EAAQ,YAAAC,MAAgB,QAyB5C,SAASC,EACPC,EAAY,EACZC,EAAa,OACbC,EAAY,GACmB,CAC/B,IAAMC,EAAMN,EAAU,IAAI,EACpB,CAACO,EAAWC,CAAY,EAAIP,EAAS,EAAK,EAC1CQ,EAAcT,EAAoC,IAAI,EAE5D,OAAAD,EAAU,IAAM,CACd,IAAMW,EAAUJ,EAAI,QACpB,GAAI,CAACI,GAAW,OAAO,qBAAyB,IAAa,OAE7DD,EAAY,SAAS,WAAW,EAEhC,IAAME,EAAK,IAAI,qBACb,CAAC,CAACC,CAAK,IAAM,CACXJ,EAAaI,EAAM,cAAc,EAC7BP,GAAaO,EAAM,iBACrBD,EAAG,WAAW,EACdF,EAAY,QAAU,KAE1B,EACA,CAAE,UAAAN,EAAW,WAAAC,CAAW,CAC1B,EAEA,OAAAO,EAAG,QAAQD,CAAO,EAClBD,EAAY,QAAUE,EAEf,IAAM,CACXF,EAAY,SAAS,WAAW,EAChCA,EAAY,QAAU,IACxB,CACF,EAAG,CAACN,EAAWC,EAAYC,CAAS,CAAC,EAE9B,CAACC,EAAKC,CAAS,CACxB,CAEA,IAAOM,EAAQX","sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\n/**\n * Hook para detectar quando um elemento está visível na viewport usando Intersection Observer\n *\n * @template T - Tipo do elemento HTML a ser observado\n * @param {number} [threshold=0] - Porcentagem do elemento que deve estar visível (0-1)\n * @param {string} [rootMargin='50px'] - Margem ao redor da viewport para pré-carregamento\n * @param {boolean} [keepAlive=false] - Se true, mantém isVisible=true após primeira visualização e desconecta observer\n * @returns {[React.RefObject<T>, boolean]} Array com [ref para anexar ao elemento, estado de visibilidade]\n *\n * @example\n * // Lazy load básico\n * const [ref, isVisible] = useIsVisible<HTMLDivElement>();\n * <div ref={ref}>{isVisible && <HeavyComponent />}</div>\n *\n * @example\n * // Com keepAlive para carregar uma vez e manter\n * const [ref, isVisible] = useIsVisible<HTMLDivElement>(0, '50px', true);\n * <div ref={ref}>{isVisible && <HeavyComponent />}</div>\n *\n * @example\n * // Threshold customizado (50% visível)\n * const [ref, isVisible] = useIsVisible<HTMLDivElement>(0.5, '100px');\n */\nfunction useIsVisible<T extends Element>(\n threshold = 0,\n rootMargin = '50px',\n keepAlive = false,\n): [React.RefObject<T>, boolean] {\n const ref = useRef<T>(null);\n const [isVisible, setIsVisible] = useState(false);\n const observerRef = useRef<IntersectionObserver | null>(null);\n\n useEffect(() => {\n const element = ref.current;\n if (!element || typeof IntersectionObserver === 'undefined') return;\n\n observerRef.current?.disconnect();\n\n const io = new IntersectionObserver(\n ([entry]) => {\n setIsVisible(entry.isIntersecting);\n if (keepAlive && entry.isIntersecting) {\n io.disconnect();\n observerRef.current = null;\n }\n },\n { threshold, rootMargin },\n );\n\n io.observe(element);\n observerRef.current = io;\n\n return () => {\n observerRef.current?.disconnect();\n observerRef.current = null;\n };\n }, [threshold, rootMargin, keepAlive]);\n\n return [ref, isVisible];\n}\n\nexport default useIsVisible;\n"]}
@@ -1,9 +1,9 @@
1
1
  export { a as useThemeToggle } from '../chunk-EDWQYAWG.js';
2
- import '../chunk-E4HIWMGS.js';
2
+ import '../chunk-BJ5IDN65.js';
3
3
  import '../chunk-373WGZZL.js';
4
4
  import '../chunk-FTYHXGXC.js';
5
- import '../chunk-GEEFHX4U.js';
6
- import '../chunk-TWOLB4FN.js';
5
+ import '../chunk-WRGRGZEM.js';
6
+ import '../chunk-KYV74QIT.js';
7
7
  import '../chunk-LRSF3YE6.js';
8
8
  import '../chunk-HBOBTNB5.js';
9
9
  import '../chunk-WUFEPE2G.js';
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export { a as useThemeToggle } from './chunk-EDWQYAWG.js';
2
- export { b as ThemeProvider, a as createTheme } from './chunk-E4HIWMGS.js';
2
+ export { b as ThemeProvider, a as createTheme } from './chunk-BJ5IDN65.js';
3
3
  import './chunk-373WGZZL.js';
4
4
  export { b as defaultFont, c as primaryFont, d as secondaryFont, a as shadows, e as typography } from './chunk-FTYHXGXC.js';
5
- import './chunk-GEEFHX4U.js';
6
- import './chunk-TWOLB4FN.js';
5
+ import './chunk-WRGRGZEM.js';
6
+ import './chunk-KYV74QIT.js';
7
7
  export { l as action, k as background, m as basePalette, p as colorSchemes, i as common, a as components, q as createShadowColor, r as customShadows, o as darkPalette, h as error, b as grey, e as info, n as lightPalette, c as primary, d as secondary, f as success, j as text, g as warning } from './chunk-LRSF3YE6.js';
8
8
  import './chunk-HBOBTNB5.js';
9
9
  import './chunk-WUFEPE2G.js';
@@ -1,8 +1,8 @@
1
- export { b as default } from '../chunk-E4HIWMGS.js';
1
+ export { b as default } from '../chunk-BJ5IDN65.js';
2
2
  import '../chunk-373WGZZL.js';
3
3
  import '../chunk-FTYHXGXC.js';
4
- import '../chunk-GEEFHX4U.js';
5
- import '../chunk-TWOLB4FN.js';
4
+ import '../chunk-WRGRGZEM.js';
5
+ import '../chunk-KYV74QIT.js';
6
6
  import '../chunk-LRSF3YE6.js';
7
7
  import '../chunk-HBOBTNB5.js';
8
8
  import '../chunk-WUFEPE2G.js';
@@ -1,5 +1,5 @@
1
- export { c as buildPrimaryColors, b as updateComponentsWithSettings, a as updateCoreWithSettings } from '../../chunk-GEEFHX4U.js';
2
- import '../../chunk-TWOLB4FN.js';
1
+ export { c as buildPrimaryColors, b as updateComponentsWithSettings, a as updateCoreWithSettings } from '../../chunk-WRGRGZEM.js';
2
+ import '../../chunk-KYV74QIT.js';
3
3
  import '../../chunk-LRSF3YE6.js';
4
4
  import '../../chunk-HBOBTNB5.js';
5
5
  import '../../chunk-GLRLKFPS.js';
@@ -1,4 +1,5 @@
1
1
  declare const getLuminosity: (color: string) => number;
2
2
  declare const getContrastTextColor: (color: string) => string;
3
+ declare const normalizeHexColor: (color: string) => string;
3
4
 
4
- export { getContrastTextColor, getLuminosity };
5
+ export { getContrastTextColor, getLuminosity, normalizeHexColor };
@@ -1,4 +1,4 @@
1
- export { b as getContrastTextColor, a as getLuminosity } from '../chunk-TWOLB4FN.js';
1
+ export { b as getContrastTextColor, a as getLuminosity, c as normalizeHexColor } from '../chunk-KYV74QIT.js';
2
2
  import '../chunk-HBOBTNB5.js';
3
3
  //# sourceMappingURL=out.js.map
4
4
  //# sourceMappingURL=color.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zydon/common",
3
- "version": "2.8.1",
3
+ "version": "2.8.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -1,16 +0,0 @@
1
- import { a } from './chunk-LQRRMVFN.js';
2
- import { useState } from 'react';
3
- import C from '@mui/material/Box';
4
- import k from '@mui/material/IconButton';
5
- import g from '@mui/material/InputAdornment';
6
- import x from '@mui/material/Popover';
7
- import I from '@mui/material/TextField';
8
- import { ChromePicker } from 'react-color';
9
- import { styled } from '@mui/material/styles';
10
- import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
11
-
12
- var p=styled(ChromePicker)({fontFamily:"inherit",boxShadow:"none"});var b=({value:l,tabIndex:s,onChangeColor:a$1,...t})=>{let[m,c]=useState(),n=m||l,r=n?"#"+n.replaceAll("#",""):"",e=a(),u=()=>{e.onClose(),a$1(r);};return jsxs(Fragment,{children:[jsx(I,{...t,value:r,InputProps:{...t.InputProps,startAdornment:jsx(g,{position:"start",sx:{ml:2},children:jsx(k,{edge:"start","aria-label":"Escolher cor",onClick:e.onOpen,children:jsx(C,{sx:{minWidth:24,minHeight:24,backgroundColor:r,borderRadius:.5}})})})},inputProps:{readOnly:!0,...t.inputProps,maxLength:7,tabIndex:s}}),jsx(x,{className:"popover-color-picker",open:!!e.open,anchorEl:e.open,onClose:u,anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"center",horizontal:"center"},slotProps:{paper:{style:{borderRadius:8}}},children:jsx(p,{color:r,onChange:({hex:d})=>c(d),styles:{default:{picker:{fontFamily:"inherit",boxShadow:"none"}}},disableAlpha:!0})})]})},L=b;
13
-
14
- export { L as a };
15
- //# sourceMappingURL=out.js.map
16
- //# sourceMappingURL=chunk-E3TW4QI3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/ColorPickerInput/index.tsx","../src/components/ColorPickerInput/styles.ts"],"names":["useState","Box","IconButton","InputAdornment","Popover","TextField","ChromePickerOrigin","styled","ChromePicker","Fragment","jsx","jsxs","ColorPickerInput","value","tabIndex","onChangeColor","other","color","setColor","currentColor","hexValue","popover","usePopover_default","handleCloseColorPicker","hex","ColorPickerInput_default"],"mappings":"wCAAA,OAAS,YAAAA,MAAgB,QACzB,OAAOC,MAAS,oBAChB,OAAOC,MAAgB,2BACvB,OAAOC,MAAoB,+BAC3B,OAAOC,MAAa,wBACpB,OAAOC,MAAe,0BCLtB,OAAS,gBAAgBC,MAA0B,cACnD,OAAS,UAAAC,MAAc,uBAEhB,IAAMC,EAAeD,EAAOD,CAAkB,EAAE,CACrD,WAAY,UACZ,UAAW,MACb,CAAC,EDwBG,mBAAAG,EAaY,OAAAC,EAbZ,QAAAC,MAAA,oBAlBJ,IAAMC,EAAmB,CAAC,CACxB,MAAAC,EACA,SAAAC,EACA,cAAAC,EACA,GAAGC,CACL,IAA6B,CAC3B,GAAM,CAACC,EAAOC,CAAQ,EAAIlB,EAAuB,EAC3CmB,EAAeF,GAASJ,EACxBO,EAAWD,EAAe,IAAMA,EAAa,WAAW,IAAK,EAAE,EAAI,GAEnEE,EAAUC,EAAW,EAErBC,EAAyB,IAAM,CACnCF,EAAQ,QAAQ,EAChBN,EAAcK,CAAQ,CACxB,EAEA,OACET,EAAAF,EAAA,CACE,UAAAC,EAACL,EAAA,CACE,GAAGW,EACJ,MAAOI,EACP,WAAY,CACV,GAAGJ,EAAM,WACT,eACEN,EAACP,EAAA,CAAe,SAAS,QAAQ,GAAI,CAAE,GAAI,CAAE,EAC3C,SAAAO,EAACR,EAAA,CACC,KAAK,QACL,aAAW,eACX,QAASmB,EAAQ,OAEjB,SAAAX,EAACT,EAAA,CACC,GAAI,CACF,SAAU,GACV,UAAW,GACX,gBAAiBmB,EACjB,aAAc,EAChB,EACF,EACF,EACF,CAEJ,EACA,WAAY,CACV,SAAU,GACV,GAAGJ,EAAM,WACT,UAAW,EACX,SAAAF,CACF,EACF,EACAJ,EAACN,EAAA,CACC,UAAU,uBACV,KAAM,EAAQiB,EAAQ,KACtB,SAAUA,EAAQ,KAClB,QAASE,EACT,aAAc,CACZ,SAAU,SACV,WAAY,QACd,EACA,gBAAiB,CACf,SAAU,SACV,WAAY,QACd,EACA,UAAW,CACT,MAAO,CACL,MAAO,CAAE,aAAc,CAAE,CAC3B,CACF,EAEA,SAAAb,EAACF,EAAA,CACC,MAAOY,EACP,SAAU,CAAC,CAAE,IAAAI,CAAI,IAAuBN,EAASM,CAAmB,EACpE,OAAQ,CACN,QAAS,CACP,OAAQ,CACN,WAAY,UACZ,UAAW,MACb,CACF,CACF,EACA,aAAY,GACd,EACF,GACF,CAEJ,EAEOC,EAAQb","sourcesContent":["import { useState } from 'react';\nimport Box from '@mui/material/Box';\nimport IconButton from '@mui/material/IconButton';\nimport InputAdornment from '@mui/material/InputAdornment';\nimport Popover from '@mui/material/Popover';\nimport TextField from '@mui/material/TextField';\n\nimport usePopover from 'hooks/usePopover';\n\nimport { ColorPickerInputProps } from './props';\nimport { ChromePicker } from './styles';\n\nconst ColorPickerInput = ({\n value,\n tabIndex,\n onChangeColor,\n ...other\n}: ColorPickerInputProps) => {\n const [color, setColor] = useState<`#${string}`>();\n const currentColor = color || value;\n const hexValue = currentColor ? '#' + currentColor.replaceAll('#', '') : '';\n\n const popover = usePopover();\n\n const handleCloseColorPicker = () => {\n popover.onClose();\n onChangeColor(hexValue);\n };\n\n return (\n <>\n <TextField\n {...other}\n value={hexValue}\n InputProps={{\n ...other.InputProps,\n startAdornment: (\n <InputAdornment position=\"start\" sx={{ ml: 2 }}>\n <IconButton\n edge=\"start\"\n aria-label=\"Escolher cor\"\n onClick={popover.onOpen}\n >\n <Box\n sx={{\n minWidth: 24,\n minHeight: 24,\n backgroundColor: hexValue,\n borderRadius: 0.5,\n }}\n />\n </IconButton>\n </InputAdornment>\n ),\n }}\n inputProps={{\n readOnly: true,\n ...other.inputProps,\n maxLength: 7,\n tabIndex,\n }}\n />\n <Popover\n className=\"popover-color-picker\"\n open={Boolean(popover.open)}\n anchorEl={popover.open}\n onClose={handleCloseColorPicker}\n anchorOrigin={{\n vertical: 'bottom',\n horizontal: 'center',\n }}\n transformOrigin={{\n vertical: 'center',\n horizontal: 'center',\n }}\n slotProps={{\n paper: {\n style: { borderRadius: 8 },\n },\n }}\n >\n <ChromePicker\n color={hexValue}\n onChange={({ hex }: { hex: string }) => setColor(hex as `#${string}`)}\n styles={{\n default: {\n picker: {\n fontFamily: 'inherit',\n boxShadow: 'none',\n },\n },\n }}\n disableAlpha\n />\n </Popover>\n </>\n );\n};\n\nexport default ColorPickerInput;\n","import { ChromePicker as ChromePickerOrigin } from 'react-color';\nimport { styled } from '@mui/material/styles';\n\nexport const ChromePicker = styled(ChromePickerOrigin)({\n fontFamily: 'inherit',\n boxShadow: 'none',\n});\n"]}
@@ -1,8 +0,0 @@
1
- import { a } from './chunk-HBOBTNB5.js';
2
- import r from 'color';
3
-
4
- var i=t=>r(t).luminosity(),e=t=>i(t)>.5?a.grey[800]:"#FFFFFF";
5
-
6
- export { i as a, e as b };
7
- //# sourceMappingURL=out.js.map
8
- //# sourceMappingURL=chunk-TWOLB4FN.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/color.ts"],"names":["Color","getLuminosity","color","getContrastTextColor","colors_default"],"mappings":"wCAAA,OAAOA,MAAW,QAIX,IAAMC,EAAiBC,GAAkBF,EAAME,CAAK,EAAE,WAAW,EAE3DC,EAAwBD,GAChBD,EAAcC,CAAK,EAElB,GAAME,EAAO,KAAK,GAAG,EAAI","sourcesContent":["import Color from 'color';\n\nimport COLORS from 'theme/core/colors.json';\n\nexport const getLuminosity = (color: string) => Color(color).luminosity();\n\nexport const getContrastTextColor = (color: string) => {\n const luminosity = getLuminosity(color);\n\n return luminosity > 0.5 ? COLORS.grey[800] : '#FFFFFF';\n};\n"]}