@jenesei-software/jenesei-kit-react 2.3.3 → 2.3.4

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 (104) hide show
  1. package/build/area-preview.cjs.js +1 -1
  2. package/build/area-preview.es.js +1 -1
  3. package/build/button-Cl4532xK.cjs +3 -0
  4. package/build/button-Cl4532xK.cjs.map +1 -0
  5. package/build/button-ygPLb-n_.js +118 -0
  6. package/build/button-ygPLb-n_.js.map +1 -0
  7. package/build/{checkbox-9ue4f3-6.cjs → checkbox-B_eE5eQs.cjs} +2 -2
  8. package/build/{checkbox-9ue4f3-6.cjs.map → checkbox-B_eE5eQs.cjs.map} +1 -1
  9. package/build/{checkbox-TW5VSNui.js → checkbox-CLGIqCRV.js} +2 -2
  10. package/build/{checkbox-TW5VSNui.js.map → checkbox-CLGIqCRV.js.map} +1 -1
  11. package/build/component-button.cjs.js +1 -1
  12. package/build/component-button.es.js +1 -1
  13. package/build/component-checkbox.cjs.js +1 -1
  14. package/build/component-checkbox.es.js +1 -1
  15. package/build/component-date-picker.cjs.js +1 -1
  16. package/build/component-date-picker.es.js +1 -1
  17. package/build/component-icon.cjs.js +1 -1
  18. package/build/component-icon.es.js +1 -1
  19. package/build/component-pagination.cjs.js +1 -1
  20. package/build/component-pagination.es.js +1 -1
  21. package/build/component-select.cjs.js +1 -1
  22. package/build/component-select.es.js +1 -1
  23. package/build/components/button/component.d.ts +1 -2
  24. package/build/components/icon/component.d.ts +1 -1
  25. package/build/components/icon/component.hooks.d.ts +3 -1
  26. package/build/{context-app-CxNgCfd2.js → context-app-DhxAgIBE.js} +2 -2
  27. package/build/{context-app-CxNgCfd2.js.map → context-app-DhxAgIBE.js.map} +1 -1
  28. package/build/{context-app-29ajupjq.cjs → context-app-v8y-IIxP.cjs} +2 -2
  29. package/build/{context-app-29ajupjq.cjs.map → context-app-v8y-IIxP.cjs.map} +1 -1
  30. package/build/context-app.cjs.js +1 -1
  31. package/build/context-app.es.js +1 -1
  32. package/build/{context-cookie-Daq2MZo3.js → context-cookie-DRPslhxf.js} +2 -2
  33. package/build/{context-cookie-Daq2MZo3.js.map → context-cookie-DRPslhxf.js.map} +1 -1
  34. package/build/{context-cookie-DFgWWGA9.cjs → context-cookie-qk-RTVhn.cjs} +2 -2
  35. package/build/{context-cookie-DFgWWGA9.cjs.map → context-cookie-qk-RTVhn.cjs.map} +1 -1
  36. package/build/context-cookie.cjs.js +1 -1
  37. package/build/context-cookie.es.js +1 -1
  38. package/build/{context-geolocation-B_KYGlfQ.js → context-geolocation-6vk3sckx.js} +2 -2
  39. package/build/{context-geolocation-B_KYGlfQ.js.map → context-geolocation-6vk3sckx.js.map} +1 -1
  40. package/build/{context-geolocation-bP0_455H.cjs → context-geolocation-DlHZrmaf.cjs} +2 -2
  41. package/build/{context-geolocation-bP0_455H.cjs.map → context-geolocation-DlHZrmaf.cjs.map} +1 -1
  42. package/build/context-geolocation.cjs.js +1 -1
  43. package/build/context-geolocation.es.js +1 -1
  44. package/build/{context-local-storage-DA_whw_k.js → context-local-storage-CknlDupP.js} +2 -2
  45. package/build/{context-local-storage-DA_whw_k.js.map → context-local-storage-CknlDupP.js.map} +1 -1
  46. package/build/{context-local-storage-D_x8dwxM.cjs → context-local-storage-DK4zzbkX.cjs} +2 -2
  47. package/build/{context-local-storage-D_x8dwxM.cjs.map → context-local-storage-DK4zzbkX.cjs.map} +1 -1
  48. package/build/context-local-storage.cjs.js +1 -1
  49. package/build/context-local-storage.es.js +1 -1
  50. package/build/{context-permission-Cj70kL4A.js → context-permission-C5L4I8X3.js} +2 -2
  51. package/build/{context-permission-Cj70kL4A.js.map → context-permission-C5L4I8X3.js.map} +1 -1
  52. package/build/{context-permission-BP9hPUcR.cjs → context-permission-qp3vUfoA.cjs} +2 -2
  53. package/build/{context-permission-BP9hPUcR.cjs.map → context-permission-qp3vUfoA.cjs.map} +1 -1
  54. package/build/context-permission.cjs.js +1 -1
  55. package/build/context-permission.es.js +1 -1
  56. package/build/{context-sonner-DNJWVKTw.js → context-sonner-BB7C6Wsf.js} +3 -3
  57. package/build/{context-sonner-DNJWVKTw.js.map → context-sonner-BB7C6Wsf.js.map} +1 -1
  58. package/build/{context-sonner-C8aMJPWz.cjs → context-sonner-BGpNwV_S.cjs} +2 -2
  59. package/build/{context-sonner-C8aMJPWz.cjs.map → context-sonner-BGpNwV_S.cjs.map} +1 -1
  60. package/build/context-sonner.cjs.js +1 -1
  61. package/build/context-sonner.es.js +1 -1
  62. package/build/{date-picker-DRXvfRZx.cjs → date-picker-CexAqJgp.cjs} +2 -2
  63. package/build/{date-picker-DRXvfRZx.cjs.map → date-picker-CexAqJgp.cjs.map} +1 -1
  64. package/build/{date-picker-Sw6n-RRw.js → date-picker-WGlcoobG.js} +3 -3
  65. package/build/{date-picker-Sw6n-RRw.js.map → date-picker-WGlcoobG.js.map} +1 -1
  66. package/build/hooks-use-deep-compare-memoize.cjs.js +1 -1
  67. package/build/hooks-use-deep-compare-memoize.es.js +1 -1
  68. package/build/hooks-use-deep-memo.cjs.js +1 -1
  69. package/build/hooks-use-deep-memo.es.js +1 -1
  70. package/build/icon-B6PvcNvO.cjs +3 -0
  71. package/build/icon-B6PvcNvO.cjs.map +1 -0
  72. package/build/icon-okw710zo.js +255 -0
  73. package/build/icon-okw710zo.js.map +1 -0
  74. package/build/index.cjs.js +1 -1
  75. package/build/index.es.js +13 -13
  76. package/build/{isEqual-BHn_Fkkw.js → isEqual-BF-XUq17.js} +1 -1
  77. package/build/{isEqual-BHn_Fkkw.js.map → isEqual-BF-XUq17.js.map} +1 -1
  78. package/build/{isEqual-Q-mEN2md.cjs → isEqual-DJD8QXYf.cjs} +1 -1
  79. package/build/{isEqual-Q-mEN2md.cjs.map → isEqual-DJD8QXYf.cjs.map} +1 -1
  80. package/build/{logger-QC3A33gh.js → logger-D-UddU9-.js} +1 -1
  81. package/build/{logger-QC3A33gh.js.map → logger-D-UddU9-.js.map} +1 -1
  82. package/build/{logger-D3Xu5ef3.cjs → logger-GLARTxbP.cjs} +1 -1
  83. package/build/{logger-D3Xu5ef3.cjs.map → logger-GLARTxbP.cjs.map} +1 -1
  84. package/build/{pagination-CzmrFLcs.cjs → pagination-ClW-z5EV.cjs} +2 -2
  85. package/build/{pagination-CzmrFLcs.cjs.map → pagination-ClW-z5EV.cjs.map} +1 -1
  86. package/build/{pagination-DWlnuh1H.js → pagination-Dnl1v3VL.js} +2 -2
  87. package/build/{pagination-DWlnuh1H.js.map → pagination-Dnl1v3VL.js.map} +1 -1
  88. package/build/{preview-p2i9Ju3I.cjs → preview-DEFGRXfJ.cjs} +2 -2
  89. package/build/{preview-p2i9Ju3I.cjs.map → preview-DEFGRXfJ.cjs.map} +1 -1
  90. package/build/{preview-C-mtYSGG.js → preview-DVk-Ykii.js} +2 -2
  91. package/build/{preview-C-mtYSGG.js.map → preview-DVk-Ykii.js.map} +1 -1
  92. package/build/{select-Bn-24dwy.js → select-9C2iAXLx.js} +3 -3
  93. package/build/{select-Bn-24dwy.js.map → select-9C2iAXLx.js.map} +1 -1
  94. package/build/{select-DcgzvPvR.cjs → select-C2lLQlEy.cjs} +2 -2
  95. package/build/{select-DcgzvPvR.cjs.map → select-C2lLQlEy.cjs.map} +1 -1
  96. package/package.json +1 -1
  97. package/build/button-9k2nzpqW.js +0 -135
  98. package/build/button-9k2nzpqW.js.map +0 -1
  99. package/build/button-C1H35JQG.cjs +0 -3
  100. package/build/button-C1H35JQG.cjs.map +0 -1
  101. package/build/icon-DyjaxKWq.cjs +0 -3
  102. package/build/icon-DyjaxKWq.cjs.map +0 -1
  103. package/build/icon-Y-IZxLXB.js +0 -245
  104. package/build/icon-Y-IZxLXB.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"context-app-29ajupjq.cjs","names":[],"sources":["../src/contexts/context-app/context.styles.ts","../src/contexts/context-app/context.tsx","../src/contexts/context-app/context.hooks.ts"],"sourcesContent":["import { CSS_VARS, IThemePalette } from '@local/styles/utils';\n\nimport { CSSProperties } from 'react';\n\nimport { IAppProviderOutletStyled } from './context.types';\n\ntype IAppOutletParts = IAppProviderOutletStyled;\n\nconst toPx = (value?: number | string | null) => (typeof value === 'number' ? `${value}px` : (value ?? '0px'));\n\nconst generateGridTemplateAreas = (props: IAppOutletParts) => {\n return `\n \"notification notification notification\"\n \"${props.leftAside?.isTopHeader ? 'leftAside' : 'header'} header ${props.rightAside?.isTopHeader ? 'rightAside' : 'header'}\"\n \"${props.leftAside?.isTopHeader ? 'leftAside' : props.leftAside?.isTopNav ? 'leftAside' : 'nav'} nav ${props.rightAside?.isTopHeader ? 'rightAside' : props.rightAside?.isTopNav ? 'rightAside' : 'nav'}\"\n \"leftAside children rightAside\"\n \"${props.leftAside?.isTopFooter ? 'leftAside' : 'footer'} footer ${props.rightAside?.isTopFooter ? 'rightAside' : 'footer'}\"\n `;\n};\n\nexport const getProviderAppWrapperStyle = (bgColor: IThemePalette, bgImage: string | null): CSSProperties => ({\n backgroundColor: CSS_VARS.palette[bgColor],\n backgroundImage: bgImage ? `url(${bgImage})` : undefined,\n backgroundSize: 'cover',\n backgroundPosition: 'center',\n backgroundRepeat: 'no-repeat',\n});\n\nexport const getProviderAppOutletStyle = (props: IAppOutletParts): CSSProperties => ({\n gridTemplateAreas: generateGridTemplateAreas(props),\n gridTemplateColumns: `${toPx(props.leftAside?.length)} 1fr ${toPx(props.rightAside?.length)}`,\n gridTemplateRows: `${toPx(props.notification?.length)} ${toPx(props.header?.length)} ${toPx(props.nav?.length)} 1fr ${toPx(props.footer?.length)}`,\n});\n\nexport const getProviderAppOutletChildrenStyle = (props: IAppOutletParts): CSSProperties => ({\n zIndex: props.main?.zIndex ?? 'auto',\n overflow: props.isScrollOutlet ? 'auto' : 'visible',\n});\n\nexport const getProviderAppOutletNotificationStyle = (props: IAppOutletParts): CSSProperties => ({\n zIndex: props.notification?.zIndex ?? 'auto',\n});\n\nexport const getProviderAppOutletHeaderStyle = (props: IAppOutletParts): CSSProperties => ({\n zIndex: props.header?.zIndex ?? 'auto',\n});\n\nexport const getProviderAppOutletFooterStyle = (props: IAppOutletParts): CSSProperties => ({\n zIndex: props.footer?.zIndex ?? 'auto',\n});\n\nexport const getProviderAppOutletNavStyle = (props: IAppOutletParts): CSSProperties => ({\n zIndex: props.nav?.zIndex ?? 'auto',\n});\n\nexport const getProviderAppOutletLeftAsideStyle = (props: IAppOutletParts): CSSProperties => ({\n zIndex: props.leftAside?.zIndex ?? 'auto',\n});\n\nexport const getProviderAppOutletRightAsideStyle = (props: IAppOutletParts): CSSProperties => ({\n zIndex: props.rightAside?.zIndex ?? 'auto',\n});\n","import { IPreviewAdditional, Preview } from '@local/areas/preview';\nimport { useScreenWidth } from '@local/contexts/context-screen-width';\nimport { CSS_CLASS, CSS_VARS, IThemePalette } from '@local/styles/utils';\nimport { setClasses } from '@local/styles/utils/functions';\n\nimport { FC, useCallback, useEffect, useMemo, useState } from 'react';\nimport { createContext } from 'use-context-selector';\n\nimport {\n getProviderAppOutletChildrenStyle,\n getProviderAppOutletFooterStyle,\n getProviderAppOutletHeaderStyle,\n getProviderAppOutletLeftAsideStyle,\n getProviderAppOutletNavStyle,\n getProviderAppOutletNotificationStyle,\n getProviderAppOutletRightAsideStyle,\n getProviderAppOutletStyle,\n getProviderAppWrapperStyle,\n} from './context.styles';\nimport { IAppContext, IAppProvider, IAppProviderElement, IAppProviderOutletStyled } from './context.types';\n\nexport const AppContext = createContext<IAppContext | null>(null);\n\nexport const ProviderApp: FC<IAppProvider> = (props) => {\n const { bgColor, changeBgColor, historyBgColor, setDefaultBgColor } = useBgColor(props.defaultBgColor);\n const { statusBarColor, changeStatusBarColor, historyStatusBarColor, setDefaultStatusBarColor } = useStatusBarColor(\n props.defaultStatusBarColor,\n );\n const { bgImage, changeBgImage, historyBgImage, setDefaultBgImage } = useBgImage(props.defaultBgImage || null);\n const { title, changeTitle, setHistoryTitle, setDefaultTitle } = useTitle(props.defaultTitle || null);\n const { description, changeDescription, historyDescription, setDefaultDescription } = useDescription(\n props.defaultDescription,\n );\n const { changePreview, previewProps } = usePreview(props.defaultPreview);\n\n const { breakpoint, type, orientation } = useScreenWidth(['breakpoint', 'type', 'orientation']);\n\n const getValueByBreakpoint = useCallback(\n (lengthByBreakpoint: IAppProviderElement['length']) => {\n if (!lengthByBreakpoint) return null;\n if (type === 'orientation' && lengthByBreakpoint.orientation) {\n const value = lengthByBreakpoint.orientation?.[orientation];\n return value ?? null;\n }\n if (lengthByBreakpoint.breakpoint && lengthByBreakpoint.breakpoint) {\n if (breakpoint === 'default') return lengthByBreakpoint.default ?? null;\n const value = lengthByBreakpoint.breakpoint?.[breakpoint];\n return value ?? null;\n }\n },\n [breakpoint, orientation, type],\n );\n\n const outletStyledProps: IAppProviderOutletStyled = useMemo(\n () => ({\n isScrollOutlet: props.isScrollOutlet,\n main: props.main,\n notification: props.notification\n ? {\n component: props.notification.component,\n length: getValueByBreakpoint(props.notification.length),\n zIndex: props.notification.zIndex,\n }\n : undefined,\n header: props.header\n ? {\n component: props.header.component,\n length: getValueByBreakpoint(props.header.length),\n zIndex: props.header.zIndex,\n }\n : undefined,\n nav: props.nav\n ? {\n component: props.nav.component,\n length: getValueByBreakpoint(props.nav.length),\n zIndex: props.nav.zIndex,\n }\n : undefined,\n footer: props.footer\n ? {\n component: props.footer.component,\n length: getValueByBreakpoint(props.footer.length),\n zIndex: props.footer.zIndex,\n }\n : undefined,\n leftAside: props.leftAside\n ? {\n component: props.leftAside.component,\n length: getValueByBreakpoint(props.leftAside.length),\n zIndex: props.leftAside.zIndex,\n isTopHeader: props.leftAside.isTopHeader,\n isTopFooter: props.leftAside.isTopFooter,\n isTopNav: props.leftAside.isTopNav,\n }\n : undefined,\n rightAside: props.rightAside\n ? {\n component: props.rightAside.component,\n length: getValueByBreakpoint(props.rightAside.length),\n zIndex: props.rightAside.zIndex,\n isTopHeader: props.rightAside.isTopHeader,\n isTopFooter: props.rightAside.isTopFooter,\n isTopNav: props.rightAside.isTopNav,\n }\n : undefined,\n }),\n [\n props.footer,\n props.header,\n props.leftAside,\n props.main,\n props.nav,\n props.notification,\n props.rightAside,\n props.isScrollOutlet,\n getValueByBreakpoint,\n ],\n );\n\n return (\n <AppContext.Provider\n value={{\n changePreview,\n changeStatusBarColor,\n changeBgColor,\n changeBgImage,\n changeTitle,\n changeDescription,\n historyStatusBarColor,\n historyBgColor,\n historyBgImage,\n setHistoryTitle,\n historyDescription,\n setDefaultStatusBarColor,\n setDefaultBgColor,\n setDefaultBgImage,\n setDefaultTitle,\n setDefaultDescription,\n }}\n >\n <title>{title}</title>\n <meta name='description' content={description} />\n <meta name='theme-color' content={CSS_VARS.palette[statusBarColor]} />\n <meta name='apple-mobile-web-app-status-bar-style' content='default' />\n <meta name='mobile-web-app-capable' content='yes' />\n <Preview {...previewProps}>\n <div className={CSS_CLASS.context.app.wrapper} style={getProviderAppWrapperStyle(bgColor, bgImage)}>\n <div\n className={setClasses([CSS_CLASS.context.app.outlet, CSS_CLASS.transition.grid])}\n style={getProviderAppOutletStyle(outletStyledProps)}\n >\n {outletStyledProps.notification?.length ? (\n <section\n className={CSS_CLASS.context.app.outletNotification}\n style={getProviderAppOutletNotificationStyle(outletStyledProps)}\n >\n {props.notification?.component || null}\n </section>\n ) : null}\n\n {outletStyledProps.header?.length ? (\n <header\n className={CSS_CLASS.context.app.outletHeader}\n style={getProviderAppOutletHeaderStyle(outletStyledProps)}\n >\n {props.header?.component || null}\n </header>\n ) : null}\n\n {outletStyledProps.nav?.length ? (\n <nav className={CSS_CLASS.context.app.outletNav} style={getProviderAppOutletNavStyle(outletStyledProps)}>\n {props.nav?.component || null}\n </nav>\n ) : null}\n\n {outletStyledProps.leftAside?.length ? (\n <aside\n className={CSS_CLASS.context.app.outletLeftAside}\n style={getProviderAppOutletLeftAsideStyle(outletStyledProps)}\n >\n {props.leftAside?.component || null}\n </aside>\n ) : null}\n\n <main\n className={CSS_CLASS.context.app.outletChildren}\n style={getProviderAppOutletChildrenStyle(outletStyledProps)}\n >\n {props.children}\n </main>\n\n {outletStyledProps.rightAside?.length ? (\n <aside\n className={CSS_CLASS.context.app.outletRightAside}\n style={getProviderAppOutletRightAsideStyle(outletStyledProps)}\n >\n {props.rightAside?.component || null}\n </aside>\n ) : null}\n\n {outletStyledProps.footer?.length ? (\n <footer\n className={CSS_CLASS.context.app.outletFooter}\n style={getProviderAppOutletFooterStyle(outletStyledProps)}\n >\n {props.footer?.component || null}\n </footer>\n ) : null}\n </div>\n </div>\n </Preview>\n </AppContext.Provider>\n );\n};\n\n/**\n * Custom hook to manage preview properties.\n */\nconst usePreview = (defaultPreview: IAppProvider['defaultPreview']) => {\n const [previewProps, setIPreview] = useState(defaultPreview || { visible: true, defaultVisible: true });\n\n const changePreview = useCallback((newIPreview: IPreviewAdditional) => {\n setIPreview(newIPreview);\n }, []);\n\n useEffect(() => {\n if (defaultPreview) setIPreview(defaultPreview);\n }, [defaultPreview]);\n\n return { previewProps, changePreview };\n};\n\n/**\n * Custom hook to manage background color state with history tracking.\n */\ntype BgColorState = {\n bgColor: IThemePalette;\n bgColorHistory: IThemePalette[];\n bgColorIndex: number;\n};\n\nexport const useBgColor = (defaultColor: IThemePalette) => {\n const [state, setState] = useState<BgColorState>({\n bgColor: defaultColor,\n bgColorHistory: [defaultColor],\n bgColorIndex: 0,\n });\n\n const changeBgColor = useCallback((color: IThemePalette) => {\n setState((prev) => {\n const newHistory = [...prev.bgColorHistory.slice(0, prev.bgColorIndex + 1), color];\n return {\n bgColor: color,\n bgColorHistory: newHistory,\n bgColorIndex: newHistory.length - 1,\n };\n });\n }, []);\n\n const historyBgColor = useCallback((steps: number) => {\n setState((prev) => {\n const newIndex = prev.bgColorIndex + steps;\n if (newIndex >= 0 && newIndex < prev.bgColorHistory.length) {\n return {\n ...prev,\n bgColor: prev.bgColorHistory[newIndex],\n bgColorIndex: newIndex,\n };\n }\n return prev;\n });\n }, []);\n\n const setDefaultBgColor = useCallback(() => {\n setState({\n bgColor: defaultColor,\n bgColorHistory: [defaultColor],\n bgColorIndex: 0,\n });\n }, [defaultColor]);\n\n useEffect(() => {\n setState({\n bgColor: defaultColor,\n bgColorHistory: [defaultColor],\n bgColorIndex: 0,\n });\n }, [defaultColor]);\n\n return {\n bgColor: state.bgColor,\n changeBgColor,\n historyBgColor,\n setDefaultBgColor,\n bgColorIndex: state.bgColorIndex,\n };\n};\n\n/**\n * Custom hook to manage the status bar color with history tracking.\n */\ntype StatusBarColorState = {\n statusBarColor: IThemePalette;\n statusBarColorHistory: IThemePalette[];\n statusBarColorIndex: number;\n};\n\nexport const useStatusBarColor = (defaultColor: IThemePalette) => {\n const [state, setState] = useState<StatusBarColorState>({\n statusBarColor: defaultColor,\n statusBarColorHistory: [defaultColor],\n statusBarColorIndex: 0,\n });\n\n const changeStatusBarColor = useCallback((color: IThemePalette) => {\n setState((prev) => {\n const newHistory = [...prev.statusBarColorHistory.slice(0, prev.statusBarColorIndex + 1), color];\n return {\n statusBarColor: color,\n statusBarColorHistory: newHistory,\n statusBarColorIndex: newHistory.length - 1,\n };\n });\n }, []);\n\n const historyStatusBarColor = useCallback((steps: number) => {\n setState((prev) => {\n const newIndex = prev.statusBarColorIndex + steps;\n if (newIndex >= 0 && newIndex < prev.statusBarColorHistory.length) {\n return {\n ...prev,\n statusBarColor: prev.statusBarColorHistory[newIndex],\n statusBarColorIndex: newIndex,\n };\n }\n return prev;\n });\n }, []);\n\n const setDefaultStatusBarColor = useCallback(() => {\n setState({\n statusBarColor: defaultColor,\n statusBarColorHistory: [defaultColor],\n statusBarColorIndex: 0,\n });\n }, [defaultColor]);\n\n useEffect(() => {\n setState({\n statusBarColor: defaultColor,\n statusBarColorHistory: [defaultColor],\n statusBarColorIndex: 0,\n });\n }, [defaultColor]);\n\n return {\n statusBarColor: state.statusBarColor,\n changeStatusBarColor,\n historyStatusBarColor,\n setDefaultStatusBarColor,\n statusBarColorIndex: state.statusBarColorIndex,\n };\n};\n\n/**\n * Custom hook to manage background images with history.\n */\ntype BgImageState = {\n bgImage: string | null;\n bgImageHistory: (string | null)[];\n bgImageIndex: number;\n};\n\nexport const useBgImage = (defaultImage: string | null) => {\n const [state, setState] = useState<BgImageState>({\n bgImage: defaultImage,\n bgImageHistory: [defaultImage],\n bgImageIndex: 0,\n });\n\n const changeBgImage = useCallback((image: string | null) => {\n setState((prev) => {\n const newHistory = [...prev.bgImageHistory.slice(0, prev.bgImageIndex + 1), image];\n return {\n bgImage: image,\n bgImageHistory: newHistory,\n bgImageIndex: newHistory.length - 1,\n };\n });\n }, []);\n\n const historyBgImage = useCallback((steps: number) => {\n setState((prev) => {\n const newIndex = prev.bgImageIndex + steps;\n if (newIndex >= 0 && newIndex < prev.bgImageHistory.length) {\n return {\n ...prev,\n bgImage: prev.bgImageHistory[newIndex],\n bgImageIndex: newIndex,\n };\n }\n return prev;\n });\n }, []);\n\n const setDefaultBgImage = useCallback(() => {\n setState({\n bgImage: defaultImage,\n bgImageHistory: [defaultImage],\n bgImageIndex: 0,\n });\n }, [defaultImage]);\n\n useEffect(() => {\n setState({\n bgImage: defaultImage,\n bgImageHistory: [defaultImage],\n bgImageIndex: 0,\n });\n }, [defaultImage]);\n\n return {\n bgImage: state.bgImage,\n changeBgImage,\n historyBgImage,\n setDefaultBgImage,\n bgImageIndex: state.bgImageIndex,\n };\n};\n\ntype TitleState = {\n title: string | null;\n titleHistory: (string | null)[];\n titleIndex: number;\n};\n/**\n * Custom hook to manage the document title with history tracking.\n */\nconst useTitle = (defaultTitle: string | null) => {\n const [state, setState] = useState<TitleState>({\n title: defaultTitle,\n titleHistory: [defaultTitle],\n titleIndex: 0,\n });\n\n const changeTitle = useCallback((newTitle: string | null) => {\n setState((prev) => {\n const newHistory = [...prev.titleHistory.slice(0, prev.titleIndex + 1), newTitle];\n return {\n title: newTitle,\n titleHistory: newHistory,\n titleIndex: newHistory.length - 1,\n };\n });\n }, []);\n\n const setHistoryTitle = useCallback((steps: number) => {\n setState((prev) => {\n const newIndex = prev.titleIndex + steps;\n if (newIndex >= 0 && newIndex < prev.titleHistory.length) {\n return {\n ...prev,\n title: prev.titleHistory[newIndex],\n titleIndex: newIndex,\n };\n }\n return prev;\n });\n }, []);\n\n const setDefaultTitle = useCallback(() => {\n setState({\n title: defaultTitle,\n titleHistory: [defaultTitle],\n titleIndex: 0,\n });\n }, [defaultTitle]);\n\n useEffect(() => {\n setState({\n title: defaultTitle,\n titleHistory: [defaultTitle],\n titleIndex: 0,\n });\n }, [defaultTitle]);\n\n return {\n title: state.title,\n titleIndex: state.titleIndex,\n titleHistory: state.titleHistory,\n changeTitle,\n setHistoryTitle,\n setDefaultTitle,\n };\n};\n\n/**\n * Custom hook to manage a description with history tracking.\n */\ntype DescriptionState = {\n description: string;\n descriptionHistory: string[];\n descriptionIndex: number;\n};\n\nexport const useDescription = (defaultDescription: string) => {\n const [state, setState] = useState<DescriptionState>({\n description: defaultDescription,\n descriptionHistory: [defaultDescription],\n descriptionIndex: 0,\n });\n\n const changeDescription = useCallback((newDescription: string) => {\n setState((prev) => {\n const newHistory = [...prev.descriptionHistory.slice(0, prev.descriptionIndex + 1), newDescription];\n return {\n description: newDescription,\n descriptionHistory: newHistory,\n descriptionIndex: newHistory.length - 1,\n };\n });\n }, []);\n\n const historyDescription = useCallback((steps: number) => {\n setState((prev) => {\n const newIndex = prev.descriptionIndex + steps;\n if (newIndex >= 0 && newIndex < prev.descriptionHistory.length) {\n return {\n ...prev,\n description: prev.descriptionHistory[newIndex],\n descriptionIndex: newIndex,\n };\n }\n return prev;\n });\n }, []);\n\n const setDefaultDescription = useCallback(() => {\n setState({\n description: defaultDescription,\n descriptionHistory: [defaultDescription],\n descriptionIndex: 0,\n });\n }, [defaultDescription]);\n\n useEffect(() => {\n setState({\n description: defaultDescription,\n descriptionHistory: [defaultDescription],\n descriptionIndex: 0,\n });\n }, [defaultDescription]);\n\n return {\n description: state.description,\n changeDescription,\n historyDescription,\n setDefaultDescription,\n descriptionIndex: state.descriptionIndex,\n };\n};\n","import { useContextSelector } from 'use-context-selector';\n\nimport { AppContext } from './context';\nimport { IAppContext, IUseAppDependencies } from './context.types';\n\nexport const useApp = (props: IUseAppDependencies): IAppContext => {\n const context = useContextSelector(AppContext, (v) => {\n return v\n ? props.reduce((acc, prop) => {\n acc[prop] = v[prop];\n return acc;\n }, {} as any)\n : null;\n });\n if (!context) {\n throw new Error('useApp must be used within an AppContext');\n }\n return context;\n};\n"],"mappings":"6RAQA,IAAM,EAAQ,GAAoC,OAAO,GAAU,SAAW,GAAG,CAAA,KAAa,GAAS,MAEjG,EAA6B,GAC1B;AAAA;AAAA,OAEF,EAAM,WAAW,YAAc,YAAc,QAAA,WAAmB,EAAM,YAAY,YAAc,aAAe,QAAA;AAAA,OAC/G,EAAM,WAAW,aAA4B,EAAM,WAAW,SAA/B,YAAwD,KAAA,QAAa,EAAM,YAAY,aAA6B,EAAM,YAAY,SAAjC,aAA2D,KAAA;AAAA;AAAA,OAE/L,EAAM,WAAW,YAAc,YAAc,QAAA,WAAmB,EAAM,YAAY,YAAc,aAAe,QAAA;AAAA,IAIzG,EAAA,CAA8B,EAAwB,KAA2C,CAC5G,gBAAiB,EAAA,SAAS,QAAQ,CAAA,EAClC,gBAAiB,EAAU,OAAO,CAAA,IAAa,OAC/C,eAAgB,QAChB,mBAAoB,SACpB,iBAAkB,cAGP,EAA6B,IAA2C,CACnF,kBAAmB,EAA0B,CAAA,EAC7C,oBAAqB,GAAG,EAAK,EAAM,WAAW,MAAA,CAAO,QAAQ,EAAK,EAAM,YAAY,MAAA,CAAO,GAC3F,iBAAkB,GAAG,EAAK,EAAM,cAAc,MAAA,CAAO,IAAI,EAAK,EAAM,QAAQ,MAAA,CAAO,IAAI,EAAK,EAAM,KAAK,MAAA,CAAO,QAAQ,EAAK,EAAM,QAAQ,MAAA,CAAO,KAGrI,EAAqC,IAA2C,CAC3F,OAAQ,EAAM,MAAM,QAAU,OAC9B,SAAU,EAAM,eAAiB,OAAS,YAG/B,EAAyC,IAA2C,CAC/F,OAAQ,EAAM,cAAc,QAAU,MAAA,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kB,EACnB,GACA,CAAC,CAAA,CAAmB,EAEhB,CACL,YAAa,EAAM,YACnB,kBAAA,EACA,mBAAA,EACA,sBAAA,EACA,iBAAkB,EAAM,mBCziBf,GAAU,GAA4C,CACjE,MAAM,EAAU,EAAA,mBAAmB,EAAa,GACvC,EACH,EAAM,OAAA,CAAQ,EAAK,KACjB,EAAI,CAAA,EAAQ,EAAE,CAAA,EACP,GACN,CAAA,CAAE,EACL,MAEN,GAAI,CAAC,EACH,MAAM,IAAI,MAAM,0CAAA,EAElB,OAAO"}
1
+ {"version":3,"file":"context-app-v8y-IIxP.cjs","names":[],"sources":["../src/contexts/context-app/context.styles.ts","../src/contexts/context-app/context.tsx","../src/contexts/context-app/context.hooks.ts"],"sourcesContent":["import { CSS_VARS, IThemePalette } from '@local/styles/utils';\n\nimport { CSSProperties } from 'react';\n\nimport { IAppProviderOutletStyled } from './context.types';\n\ntype IAppOutletParts = IAppProviderOutletStyled;\n\nconst toPx = (value?: number | string | null) => (typeof value === 'number' ? `${value}px` : (value ?? '0px'));\n\nconst generateGridTemplateAreas = (props: IAppOutletParts) => {\n return `\n \"notification notification notification\"\n \"${props.leftAside?.isTopHeader ? 'leftAside' : 'header'} header ${props.rightAside?.isTopHeader ? 'rightAside' : 'header'}\"\n \"${props.leftAside?.isTopHeader ? 'leftAside' : props.leftAside?.isTopNav ? 'leftAside' : 'nav'} nav ${props.rightAside?.isTopHeader ? 'rightAside' : props.rightAside?.isTopNav ? 'rightAside' : 'nav'}\"\n \"leftAside children rightAside\"\n \"${props.leftAside?.isTopFooter ? 'leftAside' : 'footer'} footer ${props.rightAside?.isTopFooter ? 'rightAside' : 'footer'}\"\n `;\n};\n\nexport const getProviderAppWrapperStyle = (bgColor: IThemePalette, bgImage: string | null): CSSProperties => ({\n backgroundColor: CSS_VARS.palette[bgColor],\n backgroundImage: bgImage ? `url(${bgImage})` : undefined,\n backgroundSize: 'cover',\n backgroundPosition: 'center',\n backgroundRepeat: 'no-repeat',\n});\n\nexport const getProviderAppOutletStyle = (props: IAppOutletParts): CSSProperties => ({\n gridTemplateAreas: generateGridTemplateAreas(props),\n gridTemplateColumns: `${toPx(props.leftAside?.length)} 1fr ${toPx(props.rightAside?.length)}`,\n gridTemplateRows: `${toPx(props.notification?.length)} ${toPx(props.header?.length)} ${toPx(props.nav?.length)} 1fr ${toPx(props.footer?.length)}`,\n});\n\nexport const getProviderAppOutletChildrenStyle = (props: IAppOutletParts): CSSProperties => ({\n zIndex: props.main?.zIndex ?? 'auto',\n overflow: props.isScrollOutlet ? 'auto' : 'visible',\n});\n\nexport const getProviderAppOutletNotificationStyle = (props: IAppOutletParts): CSSProperties => ({\n zIndex: props.notification?.zIndex ?? 'auto',\n});\n\nexport const getProviderAppOutletHeaderStyle = (props: IAppOutletParts): CSSProperties => ({\n zIndex: props.header?.zIndex ?? 'auto',\n});\n\nexport const getProviderAppOutletFooterStyle = (props: IAppOutletParts): CSSProperties => ({\n zIndex: props.footer?.zIndex ?? 'auto',\n});\n\nexport const getProviderAppOutletNavStyle = (props: IAppOutletParts): CSSProperties => ({\n zIndex: props.nav?.zIndex ?? 'auto',\n});\n\nexport const getProviderAppOutletLeftAsideStyle = (props: IAppOutletParts): CSSProperties => ({\n zIndex: props.leftAside?.zIndex ?? 'auto',\n});\n\nexport const getProviderAppOutletRightAsideStyle = (props: IAppOutletParts): CSSProperties => ({\n zIndex: props.rightAside?.zIndex ?? 'auto',\n});\n","import { IPreviewAdditional, Preview } from '@local/areas/preview';\nimport { useScreenWidth } from '@local/contexts/context-screen-width';\nimport { CSS_CLASS, CSS_VARS, IThemePalette } from '@local/styles/utils';\nimport { setClasses } from '@local/styles/utils/functions';\n\nimport { FC, useCallback, useEffect, useMemo, useState } from 'react';\nimport { createContext } from 'use-context-selector';\n\nimport {\n getProviderAppOutletChildrenStyle,\n getProviderAppOutletFooterStyle,\n getProviderAppOutletHeaderStyle,\n getProviderAppOutletLeftAsideStyle,\n getProviderAppOutletNavStyle,\n getProviderAppOutletNotificationStyle,\n getProviderAppOutletRightAsideStyle,\n getProviderAppOutletStyle,\n getProviderAppWrapperStyle,\n} from './context.styles';\nimport { IAppContext, IAppProvider, IAppProviderElement, IAppProviderOutletStyled } from './context.types';\n\nexport const AppContext = createContext<IAppContext | null>(null);\n\nexport const ProviderApp: FC<IAppProvider> = (props) => {\n const { bgColor, changeBgColor, historyBgColor, setDefaultBgColor } = useBgColor(props.defaultBgColor);\n const { statusBarColor, changeStatusBarColor, historyStatusBarColor, setDefaultStatusBarColor } = useStatusBarColor(\n props.defaultStatusBarColor,\n );\n const { bgImage, changeBgImage, historyBgImage, setDefaultBgImage } = useBgImage(props.defaultBgImage || null);\n const { title, changeTitle, setHistoryTitle, setDefaultTitle } = useTitle(props.defaultTitle || null);\n const { description, changeDescription, historyDescription, setDefaultDescription } = useDescription(\n props.defaultDescription,\n );\n const { changePreview, previewProps } = usePreview(props.defaultPreview);\n\n const { breakpoint, type, orientation } = useScreenWidth(['breakpoint', 'type', 'orientation']);\n\n const getValueByBreakpoint = useCallback(\n (lengthByBreakpoint: IAppProviderElement['length']) => {\n if (!lengthByBreakpoint) return null;\n if (type === 'orientation' && lengthByBreakpoint.orientation) {\n const value = lengthByBreakpoint.orientation?.[orientation];\n return value ?? null;\n }\n if (lengthByBreakpoint.breakpoint && lengthByBreakpoint.breakpoint) {\n if (breakpoint === 'default') return lengthByBreakpoint.default ?? null;\n const value = lengthByBreakpoint.breakpoint?.[breakpoint];\n return value ?? null;\n }\n },\n [breakpoint, orientation, type],\n );\n\n const outletStyledProps: IAppProviderOutletStyled = useMemo(\n () => ({\n isScrollOutlet: props.isScrollOutlet,\n main: props.main,\n notification: props.notification\n ? {\n component: props.notification.component,\n length: getValueByBreakpoint(props.notification.length),\n zIndex: props.notification.zIndex,\n }\n : undefined,\n header: props.header\n ? {\n component: props.header.component,\n length: getValueByBreakpoint(props.header.length),\n zIndex: props.header.zIndex,\n }\n : undefined,\n nav: props.nav\n ? {\n component: props.nav.component,\n length: getValueByBreakpoint(props.nav.length),\n zIndex: props.nav.zIndex,\n }\n : undefined,\n footer: props.footer\n ? {\n component: props.footer.component,\n length: getValueByBreakpoint(props.footer.length),\n zIndex: props.footer.zIndex,\n }\n : undefined,\n leftAside: props.leftAside\n ? {\n component: props.leftAside.component,\n length: getValueByBreakpoint(props.leftAside.length),\n zIndex: props.leftAside.zIndex,\n isTopHeader: props.leftAside.isTopHeader,\n isTopFooter: props.leftAside.isTopFooter,\n isTopNav: props.leftAside.isTopNav,\n }\n : undefined,\n rightAside: props.rightAside\n ? {\n component: props.rightAside.component,\n length: getValueByBreakpoint(props.rightAside.length),\n zIndex: props.rightAside.zIndex,\n isTopHeader: props.rightAside.isTopHeader,\n isTopFooter: props.rightAside.isTopFooter,\n isTopNav: props.rightAside.isTopNav,\n }\n : undefined,\n }),\n [\n props.footer,\n props.header,\n props.leftAside,\n props.main,\n props.nav,\n props.notification,\n props.rightAside,\n props.isScrollOutlet,\n getValueByBreakpoint,\n ],\n );\n\n return (\n <AppContext.Provider\n value={{\n changePreview,\n changeStatusBarColor,\n changeBgColor,\n changeBgImage,\n changeTitle,\n changeDescription,\n historyStatusBarColor,\n historyBgColor,\n historyBgImage,\n setHistoryTitle,\n historyDescription,\n setDefaultStatusBarColor,\n setDefaultBgColor,\n setDefaultBgImage,\n setDefaultTitle,\n setDefaultDescription,\n }}\n >\n <title>{title}</title>\n <meta name='description' content={description} />\n <meta name='theme-color' content={CSS_VARS.palette[statusBarColor]} />\n <meta name='apple-mobile-web-app-status-bar-style' content='default' />\n <meta name='mobile-web-app-capable' content='yes' />\n <Preview {...previewProps}>\n <div className={CSS_CLASS.context.app.wrapper} style={getProviderAppWrapperStyle(bgColor, bgImage)}>\n <div\n className={setClasses([CSS_CLASS.context.app.outlet, CSS_CLASS.transition.grid])}\n style={getProviderAppOutletStyle(outletStyledProps)}\n >\n {outletStyledProps.notification?.length ? (\n <section\n className={CSS_CLASS.context.app.outletNotification}\n style={getProviderAppOutletNotificationStyle(outletStyledProps)}\n >\n {props.notification?.component || null}\n </section>\n ) : null}\n\n {outletStyledProps.header?.length ? (\n <header\n className={CSS_CLASS.context.app.outletHeader}\n style={getProviderAppOutletHeaderStyle(outletStyledProps)}\n >\n {props.header?.component || null}\n </header>\n ) : null}\n\n {outletStyledProps.nav?.length ? (\n <nav className={CSS_CLASS.context.app.outletNav} style={getProviderAppOutletNavStyle(outletStyledProps)}>\n {props.nav?.component || null}\n </nav>\n ) : null}\n\n {outletStyledProps.leftAside?.length ? (\n <aside\n className={CSS_CLASS.context.app.outletLeftAside}\n style={getProviderAppOutletLeftAsideStyle(outletStyledProps)}\n >\n {props.leftAside?.component || null}\n </aside>\n ) : null}\n\n <main\n className={CSS_CLASS.context.app.outletChildren}\n style={getProviderAppOutletChildrenStyle(outletStyledProps)}\n >\n {props.children}\n </main>\n\n {outletStyledProps.rightAside?.length ? (\n <aside\n className={CSS_CLASS.context.app.outletRightAside}\n style={getProviderAppOutletRightAsideStyle(outletStyledProps)}\n >\n {props.rightAside?.component || null}\n </aside>\n ) : null}\n\n {outletStyledProps.footer?.length ? (\n <footer\n className={CSS_CLASS.context.app.outletFooter}\n style={getProviderAppOutletFooterStyle(outletStyledProps)}\n >\n {props.footer?.component || null}\n </footer>\n ) : null}\n </div>\n </div>\n </Preview>\n </AppContext.Provider>\n );\n};\n\n/**\n * Custom hook to manage preview properties.\n */\nconst usePreview = (defaultPreview: IAppProvider['defaultPreview']) => {\n const [previewProps, setIPreview] = useState(defaultPreview || { visible: true, defaultVisible: true });\n\n const changePreview = useCallback((newIPreview: IPreviewAdditional) => {\n setIPreview(newIPreview);\n }, []);\n\n useEffect(() => {\n if (defaultPreview) setIPreview(defaultPreview);\n }, [defaultPreview]);\n\n return { previewProps, changePreview };\n};\n\n/**\n * Custom hook to manage background color state with history tracking.\n */\ntype BgColorState = {\n bgColor: IThemePalette;\n bgColorHistory: IThemePalette[];\n bgColorIndex: number;\n};\n\nexport const useBgColor = (defaultColor: IThemePalette) => {\n const [state, setState] = useState<BgColorState>({\n bgColor: defaultColor,\n bgColorHistory: [defaultColor],\n bgColorIndex: 0,\n });\n\n const changeBgColor = useCallback((color: IThemePalette) => {\n setState((prev) => {\n const newHistory = [...prev.bgColorHistory.slice(0, prev.bgColorIndex + 1), color];\n return {\n bgColor: color,\n bgColorHistory: newHistory,\n bgColorIndex: newHistory.length - 1,\n };\n });\n }, []);\n\n const historyBgColor = useCallback((steps: number) => {\n setState((prev) => {\n const newIndex = prev.bgColorIndex + steps;\n if (newIndex >= 0 && newIndex < prev.bgColorHistory.length) {\n return {\n ...prev,\n bgColor: prev.bgColorHistory[newIndex],\n bgColorIndex: newIndex,\n };\n }\n return prev;\n });\n }, []);\n\n const setDefaultBgColor = useCallback(() => {\n setState({\n bgColor: defaultColor,\n bgColorHistory: [defaultColor],\n bgColorIndex: 0,\n });\n }, [defaultColor]);\n\n useEffect(() => {\n setState({\n bgColor: defaultColor,\n bgColorHistory: [defaultColor],\n bgColorIndex: 0,\n });\n }, [defaultColor]);\n\n return {\n bgColor: state.bgColor,\n changeBgColor,\n historyBgColor,\n setDefaultBgColor,\n bgColorIndex: state.bgColorIndex,\n };\n};\n\n/**\n * Custom hook to manage the status bar color with history tracking.\n */\ntype StatusBarColorState = {\n statusBarColor: IThemePalette;\n statusBarColorHistory: IThemePalette[];\n statusBarColorIndex: number;\n};\n\nexport const useStatusBarColor = (defaultColor: IThemePalette) => {\n const [state, setState] = useState<StatusBarColorState>({\n statusBarColor: defaultColor,\n statusBarColorHistory: [defaultColor],\n statusBarColorIndex: 0,\n });\n\n const changeStatusBarColor = useCallback((color: IThemePalette) => {\n setState((prev) => {\n const newHistory = [...prev.statusBarColorHistory.slice(0, prev.statusBarColorIndex + 1), color];\n return {\n statusBarColor: color,\n statusBarColorHistory: newHistory,\n statusBarColorIndex: newHistory.length - 1,\n };\n });\n }, []);\n\n const historyStatusBarColor = useCallback((steps: number) => {\n setState((prev) => {\n const newIndex = prev.statusBarColorIndex + steps;\n if (newIndex >= 0 && newIndex < prev.statusBarColorHistory.length) {\n return {\n ...prev,\n statusBarColor: prev.statusBarColorHistory[newIndex],\n statusBarColorIndex: newIndex,\n };\n }\n return prev;\n });\n }, []);\n\n const setDefaultStatusBarColor = useCallback(() => {\n setState({\n statusBarColor: defaultColor,\n statusBarColorHistory: [defaultColor],\n statusBarColorIndex: 0,\n });\n }, [defaultColor]);\n\n useEffect(() => {\n setState({\n statusBarColor: defaultColor,\n statusBarColorHistory: [defaultColor],\n statusBarColorIndex: 0,\n });\n }, [defaultColor]);\n\n return {\n statusBarColor: state.statusBarColor,\n changeStatusBarColor,\n historyStatusBarColor,\n setDefaultStatusBarColor,\n statusBarColorIndex: state.statusBarColorIndex,\n };\n};\n\n/**\n * Custom hook to manage background images with history.\n */\ntype BgImageState = {\n bgImage: string | null;\n bgImageHistory: (string | null)[];\n bgImageIndex: number;\n};\n\nexport const useBgImage = (defaultImage: string | null) => {\n const [state, setState] = useState<BgImageState>({\n bgImage: defaultImage,\n bgImageHistory: [defaultImage],\n bgImageIndex: 0,\n });\n\n const changeBgImage = useCallback((image: string | null) => {\n setState((prev) => {\n const newHistory = [...prev.bgImageHistory.slice(0, prev.bgImageIndex + 1), image];\n return {\n bgImage: image,\n bgImageHistory: newHistory,\n bgImageIndex: newHistory.length - 1,\n };\n });\n }, []);\n\n const historyBgImage = useCallback((steps: number) => {\n setState((prev) => {\n const newIndex = prev.bgImageIndex + steps;\n if (newIndex >= 0 && newIndex < prev.bgImageHistory.length) {\n return {\n ...prev,\n bgImage: prev.bgImageHistory[newIndex],\n bgImageIndex: newIndex,\n };\n }\n return prev;\n });\n }, []);\n\n const setDefaultBgImage = useCallback(() => {\n setState({\n bgImage: defaultImage,\n bgImageHistory: [defaultImage],\n bgImageIndex: 0,\n });\n }, [defaultImage]);\n\n useEffect(() => {\n setState({\n bgImage: defaultImage,\n bgImageHistory: [defaultImage],\n bgImageIndex: 0,\n });\n }, [defaultImage]);\n\n return {\n bgImage: state.bgImage,\n changeBgImage,\n historyBgImage,\n setDefaultBgImage,\n bgImageIndex: state.bgImageIndex,\n };\n};\n\ntype TitleState = {\n title: string | null;\n titleHistory: (string | null)[];\n titleIndex: number;\n};\n/**\n * Custom hook to manage the document title with history tracking.\n */\nconst useTitle = (defaultTitle: string | null) => {\n const [state, setState] = useState<TitleState>({\n title: defaultTitle,\n titleHistory: [defaultTitle],\n titleIndex: 0,\n });\n\n const changeTitle = useCallback((newTitle: string | null) => {\n setState((prev) => {\n const newHistory = [...prev.titleHistory.slice(0, prev.titleIndex + 1), newTitle];\n return {\n title: newTitle,\n titleHistory: newHistory,\n titleIndex: newHistory.length - 1,\n };\n });\n }, []);\n\n const setHistoryTitle = useCallback((steps: number) => {\n setState((prev) => {\n const newIndex = prev.titleIndex + steps;\n if (newIndex >= 0 && newIndex < prev.titleHistory.length) {\n return {\n ...prev,\n title: prev.titleHistory[newIndex],\n titleIndex: newIndex,\n };\n }\n return prev;\n });\n }, []);\n\n const setDefaultTitle = useCallback(() => {\n setState({\n title: defaultTitle,\n titleHistory: [defaultTitle],\n titleIndex: 0,\n });\n }, [defaultTitle]);\n\n useEffect(() => {\n setState({\n title: defaultTitle,\n titleHistory: [defaultTitle],\n titleIndex: 0,\n });\n }, [defaultTitle]);\n\n return {\n title: state.title,\n titleIndex: state.titleIndex,\n titleHistory: state.titleHistory,\n changeTitle,\n setHistoryTitle,\n setDefaultTitle,\n };\n};\n\n/**\n * Custom hook to manage a description with history tracking.\n */\ntype DescriptionState = {\n description: string;\n descriptionHistory: string[];\n descriptionIndex: number;\n};\n\nexport const useDescription = (defaultDescription: string) => {\n const [state, setState] = useState<DescriptionState>({\n description: defaultDescription,\n descriptionHistory: [defaultDescription],\n descriptionIndex: 0,\n });\n\n const changeDescription = useCallback((newDescription: string) => {\n setState((prev) => {\n const newHistory = [...prev.descriptionHistory.slice(0, prev.descriptionIndex + 1), newDescription];\n return {\n description: newDescription,\n descriptionHistory: newHistory,\n descriptionIndex: newHistory.length - 1,\n };\n });\n }, []);\n\n const historyDescription = useCallback((steps: number) => {\n setState((prev) => {\n const newIndex = prev.descriptionIndex + steps;\n if (newIndex >= 0 && newIndex < prev.descriptionHistory.length) {\n return {\n ...prev,\n description: prev.descriptionHistory[newIndex],\n descriptionIndex: newIndex,\n };\n }\n return prev;\n });\n }, []);\n\n const setDefaultDescription = useCallback(() => {\n setState({\n description: defaultDescription,\n descriptionHistory: [defaultDescription],\n descriptionIndex: 0,\n });\n }, [defaultDescription]);\n\n useEffect(() => {\n setState({\n description: defaultDescription,\n descriptionHistory: [defaultDescription],\n descriptionIndex: 0,\n });\n }, [defaultDescription]);\n\n return {\n description: state.description,\n changeDescription,\n historyDescription,\n setDefaultDescription,\n descriptionIndex: state.descriptionIndex,\n };\n};\n","import { useContextSelector } from 'use-context-selector';\n\nimport { AppContext } from './context';\nimport { IAppContext, IUseAppDependencies } from './context.types';\n\nexport const useApp = (props: IUseAppDependencies): IAppContext => {\n const context = useContextSelector(AppContext, (v) => {\n return v\n ? props.reduce((acc, prop) => {\n acc[prop] = v[prop];\n return acc;\n }, {} as any)\n : null;\n });\n if (!context) {\n throw new Error('useApp must be used within an AppContext');\n }\n return context;\n};\n"],"mappings":"6RAQA,IAAM,EAAQ,GAAoC,OAAO,GAAU,SAAW,GAAG,CAAA,KAAa,GAAS,MAEjG,EAA6B,GAC1B;AAAA;AAAA,OAEF,EAAM,WAAW,YAAc,YAAc,QAAA,WAAmB,EAAM,YAAY,YAAc,aAAe,QAAA;AAAA,OAC/G,EAAM,WAAW,aAA4B,EAAM,WAAW,SAA/B,YAAwD,KAAA,QAAa,EAAM,YAAY,aAA6B,EAAM,YAAY,SAAjC,aAA2D,KAAA;AAAA;AAAA,OAE/L,EAAM,WAAW,YAAc,YAAc,QAAA,WAAmB,EAAM,YAAY,YAAc,aAAe,QAAA;AAAA,IAIzG,EAAA,CAA8B,EAAwB,KAA2C,CAC5G,gBAAiB,EAAA,SAAS,QAAQ,CAAA,EAClC,gBAAiB,EAAU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ACpF,MAAO,CACL,YAAa,EACb,mBAAoB,EACpB,iBAAkB,EAAW,OAAS,MAGzC,CAAA,CAAE,EAEC,KAAA,EAAA,aAAkC,GAAkB,CACxD,EAAU,GAAS,CACjB,MAAM,EAAW,EAAK,iBAAmB,EACzC,OAAI,GAAY,GAAK,EAAW,EAAK,mBAAmB,OAC/C,CACL,GAAG,EACH,YAAa,EAAK,mBAAmB,CAAA,EACrC,iBAAkB,GAGf,KAER,CAAA,CAAE,EAEC,KAAA,EAAA,aAAA,IAA0C,CAC9C,EAAS,CACP,YAAa,EACb,mBAAoB,CAAC,CAAA,EACrB,iBAAkB,EACnB,GACA,CAAC,CAAA,CAAmB,EAEvB,SAAA,EAAA,WAAA,IAAgB,CACd,EAAS,CACP,YAAa,EACb,mBAAoB,CAAC,CAAA,EACrB,iBAAkB,EACnB,GACA,CAAC,CAAA,CAAmB,EAEhB,CACL,YAAa,EAAM,YACnB,kBAAA,EACA,mBAAA,EACA,sBAAA,EACA,iBAAkB,EAAM,mBCziBf,GAAU,GAA4C,CACjE,MAAM,EAAU,EAAA,mBAAmB,EAAa,GACvC,EACH,EAAM,OAAA,CAAQ,EAAK,KACjB,EAAI,CAAA,EAAQ,EAAE,CAAA,EACP,GACN,CAAA,CAAE,EACL,MAEN,GAAI,CAAC,EACH,MAAM,IAAI,MAAM,0CAAA,EAElB,OAAO"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./chunk-Dd8m0Ver.cjs"),e=require("./context-app-29ajupjq.cjs");exports.ProviderApp=e.ProviderApp;exports.useApp=e.useApp;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./chunk-Dd8m0Ver.cjs"),e=require("./context-app-v8y-IIxP.cjs");exports.ProviderApp=e.ProviderApp;exports.useApp=e.useApp;
@@ -1,4 +1,4 @@
1
- import { n as r, t as o } from "./context-app-CxNgCfd2.js";
1
+ import { n as r, t as o } from "./context-app-DhxAgIBE.js";
2
2
  export {
3
3
  r as ProviderApp,
4
4
  o as useApp
@@ -1,4 +1,4 @@
1
- import { t as u } from "./logger-QC3A33gh.js";
1
+ import { t as u } from "./logger-D-UddU9-.js";
2
2
  import { jsx as V } from "react/jsx-runtime";
3
3
  import { createContext as m, useCallback as v, useContext as S, useEffect as h, useState as x } from "react";
4
4
  function C(e) {
@@ -135,4 +135,4 @@ export {
135
135
  j as t
136
136
  };
137
137
 
138
- //# sourceMappingURL=context-cookie-Daq2MZo3.js.map
138
+ //# sourceMappingURL=context-cookie-DRPslhxf.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-cookie-Daq2MZo3.js","names":[],"sources":["../node_modules/js-cookie/dist/js.cookie.mjs","../src/contexts/context-cookie/context.tsx","../src/contexts/context-cookie/context.hooks.ts"],"sourcesContent":["/*! js-cookie v3.0.5 | MIT */\n/* eslint-disable no-var */\nfunction assign (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n target[key] = source[key];\n }\n }\n return target\n}\n/* eslint-enable no-var */\n\n/* eslint-disable no-var */\nvar defaultConverter = {\n read: function (value) {\n if (value[0] === '\"') {\n value = value.slice(1, -1);\n }\n return value.replace(/(%[\\dA-F]{2})+/gi, decodeURIComponent)\n },\n write: function (value) {\n return encodeURIComponent(value).replace(\n /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,\n decodeURIComponent\n )\n }\n};\n/* eslint-enable no-var */\n\n/* eslint-disable no-var */\n\nfunction init (converter, defaultAttributes) {\n function set (name, value, attributes) {\n if (typeof document === 'undefined') {\n return\n }\n\n attributes = assign({}, defaultAttributes, attributes);\n\n if (typeof attributes.expires === 'number') {\n attributes.expires = new Date(Date.now() + attributes.expires * 864e5);\n }\n if (attributes.expires) {\n attributes.expires = attributes.expires.toUTCString();\n }\n\n name = encodeURIComponent(name)\n .replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)\n .replace(/[()]/g, escape);\n\n var stringifiedAttributes = '';\n for (var attributeName in attributes) {\n if (!attributes[attributeName]) {\n continue\n }\n\n stringifiedAttributes += '; ' + attributeName;\n\n if (attributes[attributeName] === true) {\n continue\n }\n\n // Considers RFC 6265 section 5.2:\n // ...\n // 3. If the remaining unparsed-attributes contains a %x3B (\";\")\n // character:\n // Consume the characters of the unparsed-attributes up to,\n // not including, the first %x3B (\";\") character.\n // ...\n stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];\n }\n\n return (document.cookie =\n name + '=' + converter.write(value, name) + stringifiedAttributes)\n }\n\n function get (name) {\n if (typeof document === 'undefined' || (arguments.length && !name)) {\n return\n }\n\n // To prevent the for loop in the first place assign an empty array\n // in case there are no cookies at all.\n var cookies = document.cookie ? document.cookie.split('; ') : [];\n var jar = {};\n for (var i = 0; i < cookies.length; i++) {\n var parts = cookies[i].split('=');\n var value = parts.slice(1).join('=');\n\n try {\n var found = decodeURIComponent(parts[0]);\n jar[found] = converter.read(value, found);\n\n if (name === found) {\n break\n }\n } catch (e) {}\n }\n\n return name ? jar[name] : jar\n }\n\n return Object.create(\n {\n set,\n get,\n remove: function (name, attributes) {\n set(\n name,\n '',\n assign({}, attributes, {\n expires: -1\n })\n );\n },\n withAttributes: function (attributes) {\n return init(this.converter, assign({}, this.attributes, attributes))\n },\n withConverter: function (converter) {\n return init(assign({}, this.converter, converter), this.attributes)\n }\n },\n {\n attributes: { value: Object.freeze(defaultAttributes) },\n converter: { value: Object.freeze(converter) }\n }\n )\n}\n\nvar api = init(defaultConverter, { path: '/' });\n/* eslint-enable no-var */\n\nexport { api as default };\n","import { logger } from '@local/cores/logger';\n\nimport Cookies from 'js-cookie';\nimport { createContext, FC, useCallback, useEffect, useState } from 'react';\n\nimport { ICookieAttributes, ICookieContext, ICookieProvider, IValidCookieObject } from './context.types';\n\n/**\n * Context for managing cookies.\n */\nexport const CookieContext = createContext<ICookieContext | null>(null);\n\n/**\n * Provider component for managing cookies.\n *\n * @remarks\n * You should understand which cookies you are changing and whether you have access to them.\n *\n * @remarks\n * The local storage is typed using the `jenesei-kit-react.d.ts` file:\n *\n * ```typescript\n * import '@jenesei-software/jenesei-kit-react'\n *\n * declare module '@jenesei-software/jenesei-kit-react' {\n * export interface IValidCookieObject {\n * access_token: string\n * refresh_token: string\n * }\n * }\n * ```\n */\nexport const ProviderCookie: FC<ICookieProvider> = (props) => {\n const { getCookie, setCookie, removeCookieValue, removeCookieValues, checkCookie, cookieValues } =\n useProviderCookie(props);\n\n return (\n <CookieContext.Provider\n value={{\n getCookie,\n setCookie,\n removeCookieValue,\n removeCookieValues,\n checkCookie,\n cookieValues,\n }}\n >\n {props.children}\n </CookieContext.Provider>\n );\n};\n\nconst useProviderCookie = (props: ICookieProvider) => {\n const [cookieValues, setCookieValues] = useState<IValidCookieObject>();\n\n const getCookie = useCallback(<K extends keyof IValidCookieObject>(name: K): IValidCookieObject[K] | undefined => {\n const cookie = Cookies.get(String(name));\n setCookieValues((prevState) => ({\n ...prevState,\n [name]: cookie ? JSON.parse(cookie) : undefined,\n }));\n return cookie ? JSON.parse(cookie) : undefined;\n }, []);\n\n const changeCookie = useCallback(\n <K extends keyof IValidCookieObject>(name: K, value: IValidCookieObject[K], options?: ICookieAttributes) => {\n try {\n Cookies.set(String(name), JSON.stringify(value), options);\n setCookieValues((prevState) => ({ ...prevState, [name]: value }));\n } catch {\n logger.info(`Provider Cookie. ChangeCookie error - key:${name}, value:${value}.`);\n }\n },\n [],\n );\n\n const removeCookieValue = useCallback(<K extends keyof IValidCookieObject>(name: K, options?: ICookieAttributes) => {\n try {\n Cookies.remove(String(name), options);\n setCookieValues((prevState) => ({ ...prevState, [name]: undefined }));\n } catch {\n logger.info(`Provider Cookie. RemoveCookieValue error - key:${name}.`);\n }\n }, []);\n\n const removeCookieValues = useCallback(() => {\n if (props.validate?.validateKeys) {\n props.validate?.validateKeys.forEach((key) => {\n removeCookieValue(String(key) as never);\n });\n } else {\n logger.info('Provider Cookie. Validate is not defined.');\n }\n }, [props.validate, removeCookieValue]);\n\n const checkCookie = useCallback(() => {\n if (props.validate?.validateKeys && props.validate.getValidateCookieValue) {\n props.validate?.validateKeys.forEach((key) => {\n const cookieValue = Cookies.get(String(key));\n if (cookieValue) {\n try {\n const parsedValue = JSON.parse(cookieValue);\n if (!props.validate?.getValidateCookieValue(String(key) as never, parsedValue as never)) {\n removeCookieValue(String(key) as never);\n } else {\n setCookieValues((prevState) => ({\n ...prevState,\n [key]: parsedValue,\n }));\n }\n } catch {\n removeCookieValue(String(key) as never);\n }\n } else {\n removeCookieValue(String(key) as never);\n }\n });\n } else {\n logger.info('Provider Cookie. Validate is not defined.');\n }\n }, [props.validate, removeCookieValue]);\n\n useEffect(() => {\n checkCookie();\n }, [checkCookie]);\n\n useEffect(() => {\n return () => {\n setCookieValues(undefined);\n };\n }, []);\n return { getCookie, setCookie: changeCookie, removeCookieValue, removeCookieValues, checkCookie, cookieValues };\n};\n","import { useContext } from 'react';\n\nimport { CookieContext } from './context';\nimport { ICookieContext } from './context.types';\n\n/**\n * Custom hook to access the CookieContext.\n *\n * @remarks\n * You should understand which cookies you are changing and whether you have access to them.\n *\n */\nexport const useCookie = (): ICookieContext => {\n const context = useContext(CookieContext);\n if (!context) {\n throw new Error('useCookie must be used within an ProviderCookie');\n }\n return context;\n};\n"],"x_google_ignoreList":[0],"mappings":";;;AAEA,SAAS,EAAQ,GAAQ;AACvB,WAAS,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;AACzC,QAAI,IAAS,UAAU,CAAA;AACvB,aAAS,KAAO,EACd,CAAA,EAAO,CAAA,IAAO,EAAO,CAAA;AAAA;AAGzB,SAAO;;AAKT,IAAI,IAAmB;AAAA,EACrB,MAAM,SAAU,GAAO;AACrB,WAAI,EAAM,CAAA,MAAO,QACf,IAAQ,EAAM,MAAM,GAAG,EAAA,IAElB,EAAM,QAAQ,oBAAoB,kBAAA;AAAA;EAE3C,OAAO,SAAU,GAAO;AACtB,WAAO,mBAAmB,CAAA,EAAO,QAC/B,4CACA,kBAA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,EAAO,KAAK,2CAAA;AAAA,KAEb,CAAC,EAAM,UAAU,CAAA,CAAkB;AAEtC,SAAA,EAAA,MAAgB;AACd,IAAA,EAAA;AAAA,KACC,CAAC,CAAA,CAAY,GAEhB,EAAA,MACE,MAAa;AACX,IAAA,EAAgB,MAAA;AAAA,KAEjB,CAAA,CAAE,GACE;AAAA,IAAE,WAAA;AAAA,IAAW,WAAW;AAAA,IAAc,mBAAA;AAAA,IAAmB,oBAAA;AAAA,IAAoB,aAAA;AAAA,IAAa,cAAA;AAAA;GCvHtF,IAAA,MAAkC;AAC7C,QAAM,IAAU,EAAW,CAAA;AAC3B,MAAI,CAAC,EACH,OAAM,IAAI,MAAM,iDAAA;AAElB,SAAO"}
1
+ {"version":3,"file":"context-cookie-DRPslhxf.js","names":[],"sources":["../node_modules/js-cookie/dist/js.cookie.mjs","../src/contexts/context-cookie/context.tsx","../src/contexts/context-cookie/context.hooks.ts"],"sourcesContent":["/*! js-cookie v3.0.5 | MIT */\n/* eslint-disable no-var */\nfunction assign (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n target[key] = source[key];\n }\n }\n return target\n}\n/* eslint-enable no-var */\n\n/* eslint-disable no-var */\nvar defaultConverter = {\n read: function (value) {\n if (value[0] === '\"') {\n value = value.slice(1, -1);\n }\n return value.replace(/(%[\\dA-F]{2})+/gi, decodeURIComponent)\n },\n write: function (value) {\n return encodeURIComponent(value).replace(\n /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,\n decodeURIComponent\n )\n }\n};\n/* eslint-enable no-var */\n\n/* eslint-disable no-var */\n\nfunction init (converter, defaultAttributes) {\n function set (name, value, attributes) {\n if (typeof document === 'undefined') {\n return\n }\n\n attributes = assign({}, defaultAttributes, attributes);\n\n if (typeof attributes.expires === 'number') {\n attributes.expires = new Date(Date.now() + attributes.expires * 864e5);\n }\n if (attributes.expires) {\n attributes.expires = attributes.expires.toUTCString();\n }\n\n name = encodeURIComponent(name)\n .replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)\n .replace(/[()]/g, escape);\n\n var stringifiedAttributes = '';\n for (var attributeName in attributes) {\n if (!attributes[attributeName]) {\n continue\n }\n\n stringifiedAttributes += '; ' + attributeName;\n\n if (attributes[attributeName] === true) {\n continue\n }\n\n // Considers RFC 6265 section 5.2:\n // ...\n // 3. If the remaining unparsed-attributes contains a %x3B (\";\")\n // character:\n // Consume the characters of the unparsed-attributes up to,\n // not including, the first %x3B (\";\") character.\n // ...\n stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];\n }\n\n return (document.cookie =\n name + '=' + converter.write(value, name) + stringifiedAttributes)\n }\n\n function get (name) {\n if (typeof document === 'undefined' || (arguments.length && !name)) {\n return\n }\n\n // To prevent the for loop in the first place assign an empty array\n // in case there are no cookies at all.\n var cookies = document.cookie ? document.cookie.split('; ') : [];\n var jar = {};\n for (var i = 0; i < cookies.length; i++) {\n var parts = cookies[i].split('=');\n var value = parts.slice(1).join('=');\n\n try {\n var found = decodeURIComponent(parts[0]);\n jar[found] = converter.read(value, found);\n\n if (name === found) {\n break\n }\n } catch (e) {}\n }\n\n return name ? jar[name] : jar\n }\n\n return Object.create(\n {\n set,\n get,\n remove: function (name, attributes) {\n set(\n name,\n '',\n assign({}, attributes, {\n expires: -1\n })\n );\n },\n withAttributes: function (attributes) {\n return init(this.converter, assign({}, this.attributes, attributes))\n },\n withConverter: function (converter) {\n return init(assign({}, this.converter, converter), this.attributes)\n }\n },\n {\n attributes: { value: Object.freeze(defaultAttributes) },\n converter: { value: Object.freeze(converter) }\n }\n )\n}\n\nvar api = init(defaultConverter, { path: '/' });\n/* eslint-enable no-var */\n\nexport { api as default };\n","import { logger } from '@local/cores/logger';\n\nimport Cookies from 'js-cookie';\nimport { createContext, FC, useCallback, useEffect, useState } from 'react';\n\nimport { ICookieAttributes, ICookieContext, ICookieProvider, IValidCookieObject } from './context.types';\n\n/**\n * Context for managing cookies.\n */\nexport const CookieContext = createContext<ICookieContext | null>(null);\n\n/**\n * Provider component for managing cookies.\n *\n * @remarks\n * You should understand which cookies you are changing and whether you have access to them.\n *\n * @remarks\n * The local storage is typed using the `jenesei-kit-react.d.ts` file:\n *\n * ```typescript\n * import '@jenesei-software/jenesei-kit-react'\n *\n * declare module '@jenesei-software/jenesei-kit-react' {\n * export interface IValidCookieObject {\n * access_token: string\n * refresh_token: string\n * }\n * }\n * ```\n */\nexport const ProviderCookie: FC<ICookieProvider> = (props) => {\n const { getCookie, setCookie, removeCookieValue, removeCookieValues, checkCookie, cookieValues } =\n useProviderCookie(props);\n\n return (\n <CookieContext.Provider\n value={{\n getCookie,\n setCookie,\n removeCookieValue,\n removeCookieValues,\n checkCookie,\n cookieValues,\n }}\n >\n {props.children}\n </CookieContext.Provider>\n );\n};\n\nconst useProviderCookie = (props: ICookieProvider) => {\n const [cookieValues, setCookieValues] = useState<IValidCookieObject>();\n\n const getCookie = useCallback(<K extends keyof IValidCookieObject>(name: K): IValidCookieObject[K] | undefined => {\n const cookie = Cookies.get(String(name));\n setCookieValues((prevState) => ({\n ...prevState,\n [name]: cookie ? JSON.parse(cookie) : undefined,\n }));\n return cookie ? JSON.parse(cookie) : undefined;\n }, []);\n\n const changeCookie = useCallback(\n <K extends keyof IValidCookieObject>(name: K, value: IValidCookieObject[K], options?: ICookieAttributes) => {\n try {\n Cookies.set(String(name), JSON.stringify(value), options);\n setCookieValues((prevState) => ({ ...prevState, [name]: value }));\n } catch {\n logger.info(`Provider Cookie. ChangeCookie error - key:${name}, value:${value}.`);\n }\n },\n [],\n );\n\n const removeCookieValue = useCallback(<K extends keyof IValidCookieObject>(name: K, options?: ICookieAttributes) => {\n try {\n Cookies.remove(String(name), options);\n setCookieValues((prevState) => ({ ...prevState, [name]: undefined }));\n } catch {\n logger.info(`Provider Cookie. RemoveCookieValue error - key:${name}.`);\n }\n }, []);\n\n const removeCookieValues = useCallback(() => {\n if (props.validate?.validateKeys) {\n props.validate?.validateKeys.forEach((key) => {\n removeCookieValue(String(key) as never);\n });\n } else {\n logger.info('Provider Cookie. Validate is not defined.');\n }\n }, [props.validate, removeCookieValue]);\n\n const checkCookie = useCallback(() => {\n if (props.validate?.validateKeys && props.validate.getValidateCookieValue) {\n props.validate?.validateKeys.forEach((key) => {\n const cookieValue = Cookies.get(String(key));\n if (cookieValue) {\n try {\n const parsedValue = JSON.parse(cookieValue);\n if (!props.validate?.getValidateCookieValue(String(key) as never, parsedValue as never)) {\n removeCookieValue(String(key) as never);\n } else {\n setCookieValues((prevState) => ({\n ...prevState,\n [key]: parsedValue,\n }));\n }\n } catch {\n removeCookieValue(String(key) as never);\n }\n } else {\n removeCookieValue(String(key) as never);\n }\n });\n } else {\n logger.info('Provider Cookie. Validate is not defined.');\n }\n }, [props.validate, removeCookieValue]);\n\n useEffect(() => {\n checkCookie();\n }, [checkCookie]);\n\n useEffect(() => {\n return () => {\n setCookieValues(undefined);\n };\n }, []);\n return { getCookie, setCookie: changeCookie, removeCookieValue, removeCookieValues, checkCookie, cookieValues };\n};\n","import { useContext } from 'react';\n\nimport { CookieContext } from './context';\nimport { ICookieContext } from './context.types';\n\n/**\n * Custom hook to access the CookieContext.\n *\n * @remarks\n * You should understand which cookies you are changing and whether you have access to them.\n *\n */\nexport const useCookie = (): ICookieContext => {\n const context = useContext(CookieContext);\n if (!context) {\n throw new Error('useCookie must be used within an ProviderCookie');\n }\n return context;\n};\n"],"x_google_ignoreList":[0],"mappings":";;;AAEA,SAAS,EAAQ,GAAQ;AACvB,WAAS,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK;AACzC,QAAI,IAAS,UAAU,CAAA;AACvB,aAAS,KAAO,EACd,CAAA,EAAO,CAAA,IAAO,EAAO,CAAA;AAAA;AAGzB,SAAO;;AAKT,IAAI,IAAmB;AAAA,EACrB,MAAM,SAAU,GAAO;AACrB,WAAI,EAAM,CAAA,MAAO,QACf,IAAQ,EAAM,MAAM,GAAG,EAAA,IAElB,EAAM,QAAQ,oBAAoB,kBA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AA,EAAkB,OAAO,CAAA,CAAI;AAAA;UAG/B,CAAA,EAAkB,OAAO,CAAA,CAAI;AAAA,SAIjC,EAAO,KAAK,2CAAA;AAAA,KAEb,CAAC,EAAM,UAAU,CAAA,CAAkB;AAEtC,SAAA,EAAA,MAAgB;AACd,IAAA,EAAA;AAAA,KACC,CAAC,CAAA,CAAY,GAEhB,EAAA,MACE,MAAa;AACX,IAAA,EAAgB,MAAA;AAAA,KAEjB,CAAA,CAAE,GACE;AAAA,IAAE,WAAA;AAAA,IAAW,WAAW;AAAA,IAAc,mBAAA;AAAA,IAAmB,oBAAA;AAAA,IAAoB,aAAA;AAAA,IAAa,cAAA;AAAA;GCvHtF,IAAA,MAAkC;AAC7C,QAAM,IAAU,EAAW,CAAA;AAC3B,MAAI,CAAC,EACH,OAAM,IAAI,MAAM,iDAAA;AAElB,SAAO"}
@@ -1,3 +1,3 @@
1
- const P=require("./chunk-Dd8m0Ver.cjs"),f=require("./logger-D3Xu5ef3.cjs");let V=require("react/jsx-runtime"),s=require("react");function C(e){for(var l=1;l<arguments.length;l++){var c=arguments[l];for(var d in c)e[d]=c[d]}return e}var p={read:function(e){return e[0]==='"'&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function k(e,l){function c(i,t,r){if(!(typeof document>"u")){r=C({},l,r),typeof r.expires=="number"&&(r.expires=new Date(Date.now()+r.expires*864e5)),r.expires&&(r.expires=r.expires.toUTCString()),i=encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var u="";for(var o in r)r[o]&&(u+="; "+o,r[o]!==!0&&(u+="="+r[o].split(";")[0]));return document.cookie=i+"="+e.write(t,i)+u}}function d(i){if(!(typeof document>"u"||arguments.length&&!i)){for(var t=document.cookie?document.cookie.split("; "):[],r={},u=0;u<t.length;u++){var o=t[u].split("="),n=o.slice(1).join("=");try{var a=decodeURIComponent(o[0]);if(r[a]=e.read(n,a),i===a)break}catch{}}return i?r[i]:r}}return Object.create({set:c,get:d,remove:function(i,t){c(i,"",C({},t,{expires:-1}))},withAttributes:function(i){return k(this.converter,C({},this.attributes,i))},withConverter:function(i){return k(C({},this.converter,i),this.attributes)}},{attributes:{value:Object.freeze(l)},converter:{value:Object.freeze(e)}})}var g=k(p,{path:"/"}),h=(0,s.createContext)(null),S=e=>{const{getCookie:l,setCookie:c,removeCookieValue:d,removeCookieValues:i,checkCookie:t,cookieValues:r}=x(e);return(0,V.jsx)(h.Provider,{value:{getCookie:l,setCookie:c,removeCookieValue:d,removeCookieValues:i,checkCookie:t,cookieValues:r},children:e.children})},x=e=>{const[l,c]=(0,s.useState)(),d=(0,s.useCallback)(o=>{const n=g.get(String(o));return c(a=>({...a,[o]:n?JSON.parse(n):void 0})),n?JSON.parse(n):void 0},[]),i=(0,s.useCallback)((o,n,a)=>{try{g.set(String(o),JSON.stringify(n),a),c(v=>({...v,[o]:n}))}catch{f.logger.info(`Provider Cookie. ChangeCookie error - key:${o}, value:${n}.`)}},[]),t=(0,s.useCallback)((o,n)=>{try{g.remove(String(o),n),c(a=>({...a,[o]:void 0}))}catch{f.logger.info(`Provider Cookie. RemoveCookieValue error - key:${o}.`)}},[]),r=(0,s.useCallback)(()=>{e.validate?.validateKeys?e.validate?.validateKeys.forEach(o=>{t(String(o))}):f.logger.info("Provider Cookie. Validate is not defined.")},[e.validate,t]),u=(0,s.useCallback)(()=>{e.validate?.validateKeys&&e.validate.getValidateCookieValue?e.validate?.validateKeys.forEach(o=>{const n=g.get(String(o));if(n)try{const a=JSON.parse(n);e.validate?.getValidateCookieValue(String(o),a)?c(v=>({...v,[o]:a})):t(String(o))}catch{t(String(o))}else t(String(o))}):f.logger.info("Provider Cookie. Validate is not defined.")},[e.validate,t]);return(0,s.useEffect)(()=>{u()},[u]),(0,s.useEffect)(()=>()=>{c(void 0)},[]),{getCookie:d,setCookie:i,removeCookieValue:t,removeCookieValues:r,checkCookie:u,cookieValues:l}},m=()=>{const e=(0,s.useContext)(h);if(!e)throw new Error("useCookie must be used within an ProviderCookie");return e};Object.defineProperty(exports,"ProviderCookie",{enumerable:!0,get:function(){return S}});Object.defineProperty(exports,"useCookie",{enumerable:!0,get:function(){return m}});
1
+ const P=require("./chunk-Dd8m0Ver.cjs"),f=require("./logger-GLARTxbP.cjs");let V=require("react/jsx-runtime"),s=require("react");function C(e){for(var l=1;l<arguments.length;l++){var c=arguments[l];for(var d in c)e[d]=c[d]}return e}var p={read:function(e){return e[0]==='"'&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function k(e,l){function c(i,t,r){if(!(typeof document>"u")){r=C({},l,r),typeof r.expires=="number"&&(r.expires=new Date(Date.now()+r.expires*864e5)),r.expires&&(r.expires=r.expires.toUTCString()),i=encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var u="";for(var o in r)r[o]&&(u+="; "+o,r[o]!==!0&&(u+="="+r[o].split(";")[0]));return document.cookie=i+"="+e.write(t,i)+u}}function d(i){if(!(typeof document>"u"||arguments.length&&!i)){for(var t=document.cookie?document.cookie.split("; "):[],r={},u=0;u<t.length;u++){var o=t[u].split("="),n=o.slice(1).join("=");try{var a=decodeURIComponent(o[0]);if(r[a]=e.read(n,a),i===a)break}catch{}}return i?r[i]:r}}return Object.create({set:c,get:d,remove:function(i,t){c(i,"",C({},t,{expires:-1}))},withAttributes:function(i){return k(this.converter,C({},this.attributes,i))},withConverter:function(i){return k(C({},this.converter,i),this.attributes)}},{attributes:{value:Object.freeze(l)},converter:{value:Object.freeze(e)}})}var g=k(p,{path:"/"}),h=(0,s.createContext)(null),S=e=>{const{getCookie:l,setCookie:c,removeCookieValue:d,removeCookieValues:i,checkCookie:t,cookieValues:r}=x(e);return(0,V.jsx)(h.Provider,{value:{getCookie:l,setCookie:c,removeCookieValue:d,removeCookieValues:i,checkCookie:t,cookieValues:r},children:e.children})},x=e=>{const[l,c]=(0,s.useState)(),d=(0,s.useCallback)(o=>{const n=g.get(String(o));return c(a=>({...a,[o]:n?JSON.parse(n):void 0})),n?JSON.parse(n):void 0},[]),i=(0,s.useCallback)((o,n,a)=>{try{g.set(String(o),JSON.stringify(n),a),c(v=>({...v,[o]:n}))}catch{f.logger.info(`Provider Cookie. ChangeCookie error - key:${o}, value:${n}.`)}},[]),t=(0,s.useCallback)((o,n)=>{try{g.remove(String(o),n),c(a=>({...a,[o]:void 0}))}catch{f.logger.info(`Provider Cookie. RemoveCookieValue error - key:${o}.`)}},[]),r=(0,s.useCallback)(()=>{e.validate?.validateKeys?e.validate?.validateKeys.forEach(o=>{t(String(o))}):f.logger.info("Provider Cookie. Validate is not defined.")},[e.validate,t]),u=(0,s.useCallback)(()=>{e.validate?.validateKeys&&e.validate.getValidateCookieValue?e.validate?.validateKeys.forEach(o=>{const n=g.get(String(o));if(n)try{const a=JSON.parse(n);e.validate?.getValidateCookieValue(String(o),a)?c(v=>({...v,[o]:a})):t(String(o))}catch{t(String(o))}else t(String(o))}):f.logger.info("Provider Cookie. Validate is not defined.")},[e.validate,t]);return(0,s.useEffect)(()=>{u()},[u]),(0,s.useEffect)(()=>()=>{c(void 0)},[]),{getCookie:d,setCookie:i,removeCookieValue:t,removeCookieValues:r,checkCookie:u,cookieValues:l}},m=()=>{const e=(0,s.useContext)(h);if(!e)throw new Error("useCookie must be used within an ProviderCookie");return e};Object.defineProperty(exports,"ProviderCookie",{enumerable:!0,get:function(){return S}});Object.defineProperty(exports,"useCookie",{enumerable:!0,get:function(){return m}});
2
2
 
3
- //# sourceMappingURL=context-cookie-DFgWWGA9.cjs.map
3
+ //# sourceMappingURL=context-cookie-qk-RTVhn.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-cookie-DFgWWGA9.cjs","names":[],"sources":["../node_modules/js-cookie/dist/js.cookie.mjs","../src/contexts/context-cookie/context.tsx","../src/contexts/context-cookie/context.hooks.ts"],"sourcesContent":["/*! js-cookie v3.0.5 | MIT */\n/* eslint-disable no-var */\nfunction assign (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n target[key] = source[key];\n }\n }\n return target\n}\n/* eslint-enable no-var */\n\n/* eslint-disable no-var */\nvar defaultConverter = {\n read: function (value) {\n if (value[0] === '\"') {\n value = value.slice(1, -1);\n }\n return value.replace(/(%[\\dA-F]{2})+/gi, decodeURIComponent)\n },\n write: function (value) {\n return encodeURIComponent(value).replace(\n /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,\n decodeURIComponent\n )\n }\n};\n/* eslint-enable no-var */\n\n/* eslint-disable no-var */\n\nfunction init (converter, defaultAttributes) {\n function set (name, value, attributes) {\n if (typeof document === 'undefined') {\n return\n }\n\n attributes = assign({}, defaultAttributes, attributes);\n\n if (typeof attributes.expires === 'number') {\n attributes.expires = new Date(Date.now() + attributes.expires * 864e5);\n }\n if (attributes.expires) {\n attributes.expires = attributes.expires.toUTCString();\n }\n\n name = encodeURIComponent(name)\n .replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)\n .replace(/[()]/g, escape);\n\n var stringifiedAttributes = '';\n for (var attributeName in attributes) {\n if (!attributes[attributeName]) {\n continue\n }\n\n stringifiedAttributes += '; ' + attributeName;\n\n if (attributes[attributeName] === true) {\n continue\n }\n\n // Considers RFC 6265 section 5.2:\n // ...\n // 3. If the remaining unparsed-attributes contains a %x3B (\";\")\n // character:\n // Consume the characters of the unparsed-attributes up to,\n // not including, the first %x3B (\";\") character.\n // ...\n stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];\n }\n\n return (document.cookie =\n name + '=' + converter.write(value, name) + stringifiedAttributes)\n }\n\n function get (name) {\n if (typeof document === 'undefined' || (arguments.length && !name)) {\n return\n }\n\n // To prevent the for loop in the first place assign an empty array\n // in case there are no cookies at all.\n var cookies = document.cookie ? document.cookie.split('; ') : [];\n var jar = {};\n for (var i = 0; i < cookies.length; i++) {\n var parts = cookies[i].split('=');\n var value = parts.slice(1).join('=');\n\n try {\n var found = decodeURIComponent(parts[0]);\n jar[found] = converter.read(value, found);\n\n if (name === found) {\n break\n }\n } catch (e) {}\n }\n\n return name ? jar[name] : jar\n }\n\n return Object.create(\n {\n set,\n get,\n remove: function (name, attributes) {\n set(\n name,\n '',\n assign({}, attributes, {\n expires: -1\n })\n );\n },\n withAttributes: function (attributes) {\n return init(this.converter, assign({}, this.attributes, attributes))\n },\n withConverter: function (converter) {\n return init(assign({}, this.converter, converter), this.attributes)\n }\n },\n {\n attributes: { value: Object.freeze(defaultAttributes) },\n converter: { value: Object.freeze(converter) }\n }\n )\n}\n\nvar api = init(defaultConverter, { path: '/' });\n/* eslint-enable no-var */\n\nexport { api as default };\n","import { logger } from '@local/cores/logger';\n\nimport Cookies from 'js-cookie';\nimport { createContext, FC, useCallback, useEffect, useState } from 'react';\n\nimport { ICookieAttributes, ICookieContext, ICookieProvider, IValidCookieObject } from './context.types';\n\n/**\n * Context for managing cookies.\n */\nexport const CookieContext = createContext<ICookieContext | null>(null);\n\n/**\n * Provider component for managing cookies.\n *\n * @remarks\n * You should understand which cookies you are changing and whether you have access to them.\n *\n * @remarks\n * The local storage is typed using the `jenesei-kit-react.d.ts` file:\n *\n * ```typescript\n * import '@jenesei-software/jenesei-kit-react'\n *\n * declare module '@jenesei-software/jenesei-kit-react' {\n * export interface IValidCookieObject {\n * access_token: string\n * refresh_token: string\n * }\n * }\n * ```\n */\nexport const ProviderCookie: FC<ICookieProvider> = (props) => {\n const { getCookie, setCookie, removeCookieValue, removeCookieValues, checkCookie, cookieValues } =\n useProviderCookie(props);\n\n return (\n <CookieContext.Provider\n value={{\n getCookie,\n setCookie,\n removeCookieValue,\n removeCookieValues,\n checkCookie,\n cookieValues,\n }}\n >\n {props.children}\n </CookieContext.Provider>\n );\n};\n\nconst useProviderCookie = (props: ICookieProvider) => {\n const [cookieValues, setCookieValues] = useState<IValidCookieObject>();\n\n const getCookie = useCallback(<K extends keyof IValidCookieObject>(name: K): IValidCookieObject[K] | undefined => {\n const cookie = Cookies.get(String(name));\n setCookieValues((prevState) => ({\n ...prevState,\n [name]: cookie ? JSON.parse(cookie) : undefined,\n }));\n return cookie ? JSON.parse(cookie) : undefined;\n }, []);\n\n const changeCookie = useCallback(\n <K extends keyof IValidCookieObject>(name: K, value: IValidCookieObject[K], options?: ICookieAttributes) => {\n try {\n Cookies.set(String(name), JSON.stringify(value), options);\n setCookieValues((prevState) => ({ ...prevState, [name]: value }));\n } catch {\n logger.info(`Provider Cookie. ChangeCookie error - key:${name}, value:${value}.`);\n }\n },\n [],\n );\n\n const removeCookieValue = useCallback(<K extends keyof IValidCookieObject>(name: K, options?: ICookieAttributes) => {\n try {\n Cookies.remove(String(name), options);\n setCookieValues((prevState) => ({ ...prevState, [name]: undefined }));\n } catch {\n logger.info(`Provider Cookie. RemoveCookieValue error - key:${name}.`);\n }\n }, []);\n\n const removeCookieValues = useCallback(() => {\n if (props.validate?.validateKeys) {\n props.validate?.validateKeys.forEach((key) => {\n removeCookieValue(String(key) as never);\n });\n } else {\n logger.info('Provider Cookie. Validate is not defined.');\n }\n }, [props.validate, removeCookieValue]);\n\n const checkCookie = useCallback(() => {\n if (props.validate?.validateKeys && props.validate.getValidateCookieValue) {\n props.validate?.validateKeys.forEach((key) => {\n const cookieValue = Cookies.get(String(key));\n if (cookieValue) {\n try {\n const parsedValue = JSON.parse(cookieValue);\n if (!props.validate?.getValidateCookieValue(String(key) as never, parsedValue as never)) {\n removeCookieValue(String(key) as never);\n } else {\n setCookieValues((prevState) => ({\n ...prevState,\n [key]: parsedValue,\n }));\n }\n } catch {\n removeCookieValue(String(key) as never);\n }\n } else {\n removeCookieValue(String(key) as never);\n }\n });\n } else {\n logger.info('Provider Cookie. Validate is not defined.');\n }\n }, [props.validate, removeCookieValue]);\n\n useEffect(() => {\n checkCookie();\n }, [checkCookie]);\n\n useEffect(() => {\n return () => {\n setCookieValues(undefined);\n };\n }, []);\n return { getCookie, setCookie: changeCookie, removeCookieValue, removeCookieValues, checkCookie, cookieValues };\n};\n","import { useContext } from 'react';\n\nimport { CookieContext } from './context';\nimport { ICookieContext } from './context.types';\n\n/**\n * Custom hook to access the CookieContext.\n *\n * @remarks\n * You should understand which cookies you are changing and whether you have access to them.\n *\n */\nexport const useCookie = (): ICookieContext => {\n const context = useContext(CookieContext);\n if (!context) {\n throw new Error('useCookie must be used within an ProviderCookie');\n }\n return context;\n};\n"],"x_google_ignoreList":[0],"mappings":"iIAEA,SAAS,EAAQ,EAAQ,CACvB,QAAS,EAAI,EAAG,EAAI,UAAU,OAAQ,IAAK,CACzC,IAAI,EAAS,UAAU,CAAA,EACvB,QAAS,KAAO,EACd,EAAO,CAAA,EAAO,EAAO,CAAA,EAGzB,OAAO,EAKT,IAAI,EAAmB,CACrB,KAAM,SAAU,EAAO,CACrB,OAAI,EAAM,CAAA,IAAO,MACf,EAAQ,EAAM,MAAM,EAAG,EAAA,GAElB,EAAM,QAAQ,mBAAoB,kBAAA,GAE3C,MAAO,SAAU,EAAO,CACtB,OAAO,mBAAmB,CAAA,EAAO,QAC/B,2CACA,kBAAA,IAQN,SAAS,EAAM,EAAW,EAAmB,CAC3C,SAAS,EAAK,EAAM,EAAO,EAAY,CACrC,GAAI,SAAO,SAAa,KAIxB,CAAA,EAAa,EAAO,CAAA,EAAI,EAAmB,CAAA,EAEvC,OAAO,EAAW,SAAY,WAChC,EAAW,QAAU,IAAI,KAAK,KAAK,IAAA,EAAQ,EAAW,QAAU,KAAA,GAE9D,EAAW,UACb,EAAW,QAAU,EAAW,QAAQ,YAAA,GAG1C,EAAO,mBAAmB,CAAA,EACvB,QAAQ,uBAAwB,kBAAA,EAChC,QAAQ,QAAS,MAAA,EAEpB,IAAI,EAAwB,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CAAC,EAAM,SAAU,CAAA,CAAkB,EAEhC,KAAA,EAAA,aAAA,IAAgC,CAChC,EAAM,UAAU,cAAgB,EAAM,SAAS,uBACjD,EAAM,UAAU,aAAa,QAAS,GAAQ,CAC5C,MAAM,EAAc,EAAQ,IAAI,OAAO,CAAA,CAAI,EAC3C,GAAI,EACF,GAAI,CACF,MAAM,EAAc,KAAK,MAAM,CAAA,EAC1B,EAAM,UAAU,uBAAuB,OAAO,CAAA,EAAe,CAAA,EAGhE,EAAiB,IAAe,CAC9B,GAAG,GACF,CAAA,EAAM,GACR,EALD,EAAkB,OAAO,CAAA,CAAI,OAOzB,CACN,EAAkB,OAAO,CAAA,CAAI,OAG/B,EAAkB,OAAO,CAAA,CAAI,IAIjC,EAAA,OAAO,KAAK,2CAAA,GAEb,CAAC,EAAM,SAAU,CAAA,CAAkB,EAEtC,SAAA,EAAA,WAAA,IAAgB,CACd,EAAA,GACC,CAAC,CAAA,CAAY,KAEhB,EAAA,WAAA,IACE,IAAa,CACX,EAAgB,MAAA,GAEjB,CAAA,CAAE,EACE,CAAE,UAAA,EAAW,UAAW,EAAc,kBAAA,EAAmB,mBAAA,EAAoB,YAAA,EAAa,aAAA,ICvHtF,EAAA,IAAkC,CAC7C,MAAM,KAAA,EAAA,YAAqB,CAAA,EAC3B,GAAI,CAAC,EACH,MAAM,IAAI,MAAM,iDAAA,EAElB,OAAO"}
1
+ {"version":3,"file":"context-cookie-qk-RTVhn.cjs","names":[],"sources":["../node_modules/js-cookie/dist/js.cookie.mjs","../src/contexts/context-cookie/context.tsx","../src/contexts/context-cookie/context.hooks.ts"],"sourcesContent":["/*! js-cookie v3.0.5 | MIT */\n/* eslint-disable no-var */\nfunction assign (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n target[key] = source[key];\n }\n }\n return target\n}\n/* eslint-enable no-var */\n\n/* eslint-disable no-var */\nvar defaultConverter = {\n read: function (value) {\n if (value[0] === '\"') {\n value = value.slice(1, -1);\n }\n return value.replace(/(%[\\dA-F]{2})+/gi, decodeURIComponent)\n },\n write: function (value) {\n return encodeURIComponent(value).replace(\n /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,\n decodeURIComponent\n )\n }\n};\n/* eslint-enable no-var */\n\n/* eslint-disable no-var */\n\nfunction init (converter, defaultAttributes) {\n function set (name, value, attributes) {\n if (typeof document === 'undefined') {\n return\n }\n\n attributes = assign({}, defaultAttributes, attributes);\n\n if (typeof attributes.expires === 'number') {\n attributes.expires = new Date(Date.now() + attributes.expires * 864e5);\n }\n if (attributes.expires) {\n attributes.expires = attributes.expires.toUTCString();\n }\n\n name = encodeURIComponent(name)\n .replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)\n .replace(/[()]/g, escape);\n\n var stringifiedAttributes = '';\n for (var attributeName in attributes) {\n if (!attributes[attributeName]) {\n continue\n }\n\n stringifiedAttributes += '; ' + attributeName;\n\n if (attributes[attributeName] === true) {\n continue\n }\n\n // Considers RFC 6265 section 5.2:\n // ...\n // 3. If the remaining unparsed-attributes contains a %x3B (\";\")\n // character:\n // Consume the characters of the unparsed-attributes up to,\n // not including, the first %x3B (\";\") character.\n // ...\n stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];\n }\n\n return (document.cookie =\n name + '=' + converter.write(value, name) + stringifiedAttributes)\n }\n\n function get (name) {\n if (typeof document === 'undefined' || (arguments.length && !name)) {\n return\n }\n\n // To prevent the for loop in the first place assign an empty array\n // in case there are no cookies at all.\n var cookies = document.cookie ? document.cookie.split('; ') : [];\n var jar = {};\n for (var i = 0; i < cookies.length; i++) {\n var parts = cookies[i].split('=');\n var value = parts.slice(1).join('=');\n\n try {\n var found = decodeURIComponent(parts[0]);\n jar[found] = converter.read(value, found);\n\n if (name === found) {\n break\n }\n } catch (e) {}\n }\n\n return name ? jar[name] : jar\n }\n\n return Object.create(\n {\n set,\n get,\n remove: function (name, attributes) {\n set(\n name,\n '',\n assign({}, attributes, {\n expires: -1\n })\n );\n },\n withAttributes: function (attributes) {\n return init(this.converter, assign({}, this.attributes, attributes))\n },\n withConverter: function (converter) {\n return init(assign({}, this.converter, converter), this.attributes)\n }\n },\n {\n attributes: { value: Object.freeze(defaultAttributes) },\n converter: { value: Object.freeze(converter) }\n }\n )\n}\n\nvar api = init(defaultConverter, { path: '/' });\n/* eslint-enable no-var */\n\nexport { api as default };\n","import { logger } from '@local/cores/logger';\n\nimport Cookies from 'js-cookie';\nimport { createContext, FC, useCallback, useEffect, useState } from 'react';\n\nimport { ICookieAttributes, ICookieContext, ICookieProvider, IValidCookieObject } from './context.types';\n\n/**\n * Context for managing cookies.\n */\nexport const CookieContext = createContext<ICookieContext | null>(null);\n\n/**\n * Provider component for managing cookies.\n *\n * @remarks\n * You should understand which cookies you are changing and whether you have access to them.\n *\n * @remarks\n * The local storage is typed using the `jenesei-kit-react.d.ts` file:\n *\n * ```typescript\n * import '@jenesei-software/jenesei-kit-react'\n *\n * declare module '@jenesei-software/jenesei-kit-react' {\n * export interface IValidCookieObject {\n * access_token: string\n * refresh_token: string\n * }\n * }\n * ```\n */\nexport const ProviderCookie: FC<ICookieProvider> = (props) => {\n const { getCookie, setCookie, removeCookieValue, removeCookieValues, checkCookie, cookieValues } =\n useProviderCookie(props);\n\n return (\n <CookieContext.Provider\n value={{\n getCookie,\n setCookie,\n removeCookieValue,\n removeCookieValues,\n checkCookie,\n cookieValues,\n }}\n >\n {props.children}\n </CookieContext.Provider>\n );\n};\n\nconst useProviderCookie = (props: ICookieProvider) => {\n const [cookieValues, setCookieValues] = useState<IValidCookieObject>();\n\n const getCookie = useCallback(<K extends keyof IValidCookieObject>(name: K): IValidCookieObject[K] | undefined => {\n const cookie = Cookies.get(String(name));\n setCookieValues((prevState) => ({\n ...prevState,\n [name]: cookie ? JSON.parse(cookie) : undefined,\n }));\n return cookie ? JSON.parse(cookie) : undefined;\n }, []);\n\n const changeCookie = useCallback(\n <K extends keyof IValidCookieObject>(name: K, value: IValidCookieObject[K], options?: ICookieAttributes) => {\n try {\n Cookies.set(String(name), JSON.stringify(value), options);\n setCookieValues((prevState) => ({ ...prevState, [name]: value }));\n } catch {\n logger.info(`Provider Cookie. ChangeCookie error - key:${name}, value:${value}.`);\n }\n },\n [],\n );\n\n const removeCookieValue = useCallback(<K extends keyof IValidCookieObject>(name: K, options?: ICookieAttributes) => {\n try {\n Cookies.remove(String(name), options);\n setCookieValues((prevState) => ({ ...prevState, [name]: undefined }));\n } catch {\n logger.info(`Provider Cookie. RemoveCookieValue error - key:${name}.`);\n }\n }, []);\n\n const removeCookieValues = useCallback(() => {\n if (props.validate?.validateKeys) {\n props.validate?.validateKeys.forEach((key) => {\n removeCookieValue(String(key) as never);\n });\n } else {\n logger.info('Provider Cookie. Validate is not defined.');\n }\n }, [props.validate, removeCookieValue]);\n\n const checkCookie = useCallback(() => {\n if (props.validate?.validateKeys && props.validate.getValidateCookieValue) {\n props.validate?.validateKeys.forEach((key) => {\n const cookieValue = Cookies.get(String(key));\n if (cookieValue) {\n try {\n const parsedValue = JSON.parse(cookieValue);\n if (!props.validate?.getValidateCookieValue(String(key) as never, parsedValue as never)) {\n removeCookieValue(String(key) as never);\n } else {\n setCookieValues((prevState) => ({\n ...prevState,\n [key]: parsedValue,\n }));\n }\n } catch {\n removeCookieValue(String(key) as never);\n }\n } else {\n removeCookieValue(String(key) as never);\n }\n });\n } else {\n logger.info('Provider Cookie. Validate is not defined.');\n }\n }, [props.validate, removeCookieValue]);\n\n useEffect(() => {\n checkCookie();\n }, [checkCookie]);\n\n useEffect(() => {\n return () => {\n setCookieValues(undefined);\n };\n }, []);\n return { getCookie, setCookie: changeCookie, removeCookieValue, removeCookieValues, checkCookie, cookieValues };\n};\n","import { useContext } from 'react';\n\nimport { CookieContext } from './context';\nimport { ICookieContext } from './context.types';\n\n/**\n * Custom hook to access the CookieContext.\n *\n * @remarks\n * You should understand which cookies you are changing and whether you have access to them.\n *\n */\nexport const useCookie = (): ICookieContext => {\n const context = useContext(CookieCont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kB,OAAO,CAAA,CAAI,OAOzB,CACN,EAAkB,OAAO,CAAA,CAAI,OAG/B,EAAkB,OAAO,CAAA,CAAI,IAIjC,EAAA,OAAO,KAAK,2CAAA,GAEb,CAAC,EAAM,SAAU,CAAA,CAAkB,EAEtC,SAAA,EAAA,WAAA,IAAgB,CACd,EAAA,GACC,CAAC,CAAA,CAAY,KAEhB,EAAA,WAAA,IACE,IAAa,CACX,EAAgB,MAAA,GAEjB,CAAA,CAAE,EACE,CAAE,UAAA,EAAW,UAAW,EAAc,kBAAA,EAAmB,mBAAA,EAAoB,YAAA,EAAa,aAAA,ICvHtF,EAAA,IAAkC,CAC7C,MAAM,KAAA,EAAA,YAAqB,CAAA,EAC3B,GAAI,CAAC,EACH,MAAM,IAAI,MAAM,iDAAA,EAElB,OAAO"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunk-Dd8m0Ver.cjs"),e=require("./context-cookie-DFgWWGA9.cjs");exports.ProviderCookie=e.ProviderCookie;exports.useCookie=e.useCookie;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunk-Dd8m0Ver.cjs"),e=require("./context-cookie-qk-RTVhn.cjs");exports.ProviderCookie=e.ProviderCookie;exports.useCookie=e.useCookie;
@@ -1,4 +1,4 @@
1
- import { n as e, t as r } from "./context-cookie-Daq2MZo3.js";
1
+ import { n as e, t as r } from "./context-cookie-DRPslhxf.js";
2
2
  export {
3
3
  e as ProviderCookie,
4
4
  r as useCookie
@@ -1,4 +1,4 @@
1
- import { t as f } from "./context-permission-Cj70kL4A.js";
1
+ import { t as f } from "./context-permission-C5L4I8X3.js";
2
2
  import { jsx as v } from "react/jsx-runtime";
3
3
  import { createContext as E, useContext as P, useEffect as r, useState as i } from "react";
4
4
  var s = E(null), G = (o) => {
@@ -39,4 +39,4 @@ export {
39
39
  C as t
40
40
  };
41
41
 
42
- //# sourceMappingURL=context-geolocation-B_KYGlfQ.js.map
42
+ //# sourceMappingURL=context-geolocation-6vk3sckx.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-geolocation-B_KYGlfQ.js","names":[],"sources":["../src/contexts/context-geolocation/context.tsx","../src/contexts/context-geolocation/context.hooks.ts"],"sourcesContent":["import { usePermission } from '@local/contexts/context-permission';\n\nimport { createContext, FC, useEffect, useState } from 'react';\n\nimport { IGeolocationContext, IGeolocationProvider } from './context.types';\n\nexport const GeolocationContext = createContext<IGeolocationContext | null>(null);\n\nexport const ProviderGeolocation: FC<IGeolocationProvider> = (props) => {\n const { geolocationPermission, requestGeolocationPermission } = usePermission();\n\n const [location, setLocation] = useState<GeolocationPosition | null>(null);\n const [error, setError] = useState<GeolocationPositionError | null>(null);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>\n useEffect(() => {\n const handleSuccess = (position: GeolocationPosition) => {\n setLocation(position);\n };\n\n const handleError = (error: GeolocationPositionError) => {\n setError(error);\n };\n\n if (geolocationPermission === 'granted') {\n navigator.geolocation.getCurrentPosition(handleSuccess, handleError);\n }\n }, [geolocationPermission, props.isAskEntrance, requestGeolocationPermission]);\n\n useEffect(() => {\n if (props.isAskEntrance) {\n if (geolocationPermission !== 'granted') {\n requestGeolocationPermission();\n }\n }\n }, [geolocationPermission, props.isAskEntrance, requestGeolocationPermission]);\n return (\n <GeolocationContext.Provider\n value={{\n requestGeolocationPermission,\n geolocationPermission,\n location,\n error,\n }}\n >\n {props.children}\n </GeolocationContext.Provider>\n );\n};\n","import { useContext } from 'react';\n\nimport { GeolocationContext } from './context';\nimport { IGeolocationContext } from './context.types';\n\nexport const useGeolocation = (): IGeolocationContext => {\n const context = useContext(GeolocationContext);\n if (!context) {\n throw new Error('useGeolocation must be used within an ProviderGeolocation');\n }\n return context;\n};\n"],"mappings":";;;AAMA,IAAa,IAAqB,EAA0C,IAAA,GAE/D,IAAA,CAAiD,MAAU;AACtE,QAAM,EAAE,uBAAA,GAAuB,8BAAA,EAAA,IAAiC,EAAA,GAE1D,CAAC,GAAU,CAAA,IAAe,EAAqC,IAAA,GAC/D,CAAC,GAAO,CAAA,IAAY,EAA0C,IAAA;AAGpE,SAAA,EAAA,MAAgB;AACd,UAAM,IAAA,CAAiB,MAAkC;AACvD,MAAA,EAAY,CAAA;AAAA,OAGR,IAAA,CAAe,MAAoC;AACvD,MAAA,EAAS,CAAA;AAAA;AAGX,IAAI,MAA0B,aAC5B,UAAU,YAAY,mBAAmB,GAAe,CAAA;AAAA,KAEzD;AAAA,IAAC;AAAA,IAAuB,EAAM;AAAA,IAAe;AAAA,GAA6B,GAE7E,EAAA,MAAgB;AACd,IAAI,EAAM,iBACJ,MAA0B,aAC5B,EAAA;AAAA,KAGH;AAAA,IAAC;AAAA,IAAuB,EAAM;AAAA,IAAe;AAAA,GAA6B,GAE3E,gBAAA,EAAC,EAAmB,UAApB;AAAA,IACE,OAAO;AAAA,MACL,8BAAA;AAAA,MACA,uBAAA;AAAA,MACA,UAAA;AAAA,MACA,OAAA;AAAA;cAGD,EAAM;AAAA,GACqB;GCzCrB,IAAA,MAA4C;AACvD,QAAM,IAAU,EAAW,CAAA;AAC3B,MAAI,CAAC,EACH,OAAM,IAAI,MAAM,2DAAA;AAElB,SAAO"}
1
+ {"version":3,"file":"context-geolocation-6vk3sckx.js","names":[],"sources":["../src/contexts/context-geolocation/context.tsx","../src/contexts/context-geolocation/context.hooks.ts"],"sourcesContent":["import { usePermission } from '@local/contexts/context-permission';\n\nimport { createContext, FC, useEffect, useState } from 'react';\n\nimport { IGeolocationContext, IGeolocationProvider } from './context.types';\n\nexport const GeolocationContext = createContext<IGeolocationContext | null>(null);\n\nexport const ProviderGeolocation: FC<IGeolocationProvider> = (props) => {\n const { geolocationPermission, requestGeolocationPermission } = usePermission();\n\n const [location, setLocation] = useState<GeolocationPosition | null>(null);\n const [error, setError] = useState<GeolocationPositionError | null>(null);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>\n useEffect(() => {\n const handleSuccess = (position: GeolocationPosition) => {\n setLocation(position);\n };\n\n const handleError = (error: GeolocationPositionError) => {\n setError(error);\n };\n\n if (geolocationPermission === 'granted') {\n navigator.geolocation.getCurrentPosition(handleSuccess, handleError);\n }\n }, [geolocationPermission, props.isAskEntrance, requestGeolocationPermission]);\n\n useEffect(() => {\n if (props.isAskEntrance) {\n if (geolocationPermission !== 'granted') {\n requestGeolocationPermission();\n }\n }\n }, [geolocationPermission, props.isAskEntrance, requestGeolocationPermission]);\n return (\n <GeolocationContext.Provider\n value={{\n requestGeolocationPermission,\n geolocationPermission,\n location,\n error,\n }}\n >\n {props.children}\n </GeolocationContext.Provider>\n );\n};\n","import { useContext } from 'react';\n\nimport { GeolocationContext } from './context';\nimport { IGeolocationContext } from './context.types';\n\nexport const useGeolocation = (): IGeolocationContext => {\n const context = useContext(GeolocationContext);\n if (!context) {\n throw new Error('useGeolocation must be used within an ProviderGeolocation');\n }\n return context;\n};\n"],"mappings":";;;AAMA,IAAa,IAAqB,EAA0C,IAAA,GAE/D,IAAA,CAAiD,MAAU;AACtE,QAAM,EAAE,uBAAA,GAAuB,8BAAA,EAAA,IAAiC,EAAA,GAE1D,CAAC,GAAU,CAAA,IAAe,EAAqC,IAAA,GAC/D,CAAC,GAAO,CAAA,IAAY,EAA0C,IAAA;AAGpE,SAAA,EAAA,MAAgB;AACd,UAAM,IAAA,CAAiB,MAAkC;AACvD,MAAA,EAAY,CAAA;AAAA,OAGR,IAAA,CAAe,MAAoC;AACvD,MAAA,EAAS,CAAA;AAAA;AAGX,IAAI,MAA0B,aAC5B,UAAU,YAAY,mBAAmB,GAAe,CAAA;AAAA,KAEzD;AAAA,IAAC;AAAA,IAAuB,EAAM;AAAA,IAAe;AAAA,GAA6B,GAE7E,EAAA,MAAgB;AACd,IAAI,EAAM,iBACJ,MAA0B,aAC5B,EAAA;AAAA,KAGH;AAAA,IAAC;AAAA,IAAuB,EAAM;AAAA,IAAe;AAAA,GAA6B,GAE3E,gBAAA,EAAC,EAAmB,UAApB;AAAA,IACE,OAAO;AAAA,MACL,8BAAA;AAAA,MACA,uBAAA;AAAA,MACA,UAAA;AAAA,MACA,OAAA;AAAA;cAGD,EAAM;AAAA,GACqB;GCzCrB,IAAA,MAA4C;AACvD,QAAM,IAAU,EAAW,CAAA;AAC3B,MAAI,CAAC,EACH,OAAM,IAAI,MAAM,2DAAA;AAElB,SAAO"}
@@ -1,3 +1,3 @@
1
- const m=require("./chunk-Dd8m0Ver.cjs"),f=require("./context-permission-BP9hPUcR.cjs");let P=require("react/jsx-runtime"),t=require("react");var i=(0,t.createContext)(null),v=e=>{const{geolocationPermission:r,requestGeolocationPermission:n}=f.usePermission(),[c,s]=(0,t.useState)(null),[u,a]=(0,t.useState)(null);return(0,t.useEffect)(()=>{const l=o=>{s(o)},d=o=>{a(o)};r==="granted"&&navigator.geolocation.getCurrentPosition(l,d)},[r,e.isAskEntrance,n]),(0,t.useEffect)(()=>{e.isAskEntrance&&r!=="granted"&&n()},[r,e.isAskEntrance,n]),(0,P.jsx)(i.Provider,{value:{requestGeolocationPermission:n,geolocationPermission:r,location:c,error:u},children:e.children})},g=()=>{const e=(0,t.useContext)(i);if(!e)throw new Error("useGeolocation must be used within an ProviderGeolocation");return e};Object.defineProperty(exports,"ProviderGeolocation",{enumerable:!0,get:function(){return v}});Object.defineProperty(exports,"useGeolocation",{enumerable:!0,get:function(){return g}});
1
+ const m=require("./chunk-Dd8m0Ver.cjs"),f=require("./context-permission-qp3vUfoA.cjs");let P=require("react/jsx-runtime"),t=require("react");var i=(0,t.createContext)(null),v=e=>{const{geolocationPermission:r,requestGeolocationPermission:n}=f.usePermission(),[c,s]=(0,t.useState)(null),[u,a]=(0,t.useState)(null);return(0,t.useEffect)(()=>{const l=o=>{s(o)},d=o=>{a(o)};r==="granted"&&navigator.geolocation.getCurrentPosition(l,d)},[r,e.isAskEntrance,n]),(0,t.useEffect)(()=>{e.isAskEntrance&&r!=="granted"&&n()},[r,e.isAskEntrance,n]),(0,P.jsx)(i.Provider,{value:{requestGeolocationPermission:n,geolocationPermission:r,location:c,error:u},children:e.children})},g=()=>{const e=(0,t.useContext)(i);if(!e)throw new Error("useGeolocation must be used within an ProviderGeolocation");return e};Object.defineProperty(exports,"ProviderGeolocation",{enumerable:!0,get:function(){return v}});Object.defineProperty(exports,"useGeolocation",{enumerable:!0,get:function(){return g}});
2
2
 
3
- //# sourceMappingURL=context-geolocation-bP0_455H.cjs.map
3
+ //# sourceMappingURL=context-geolocation-DlHZrmaf.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-geolocation-bP0_455H.cjs","names":[],"sources":["../src/contexts/context-geolocation/context.tsx","../src/contexts/context-geolocation/context.hooks.ts"],"sourcesContent":["import { usePermission } from '@local/contexts/context-permission';\n\nimport { createContext, FC, useEffect, useState } from 'react';\n\nimport { IGeolocationContext, IGeolocationProvider } from './context.types';\n\nexport const GeolocationContext = createContext<IGeolocationContext | null>(null);\n\nexport const ProviderGeolocation: FC<IGeolocationProvider> = (props) => {\n const { geolocationPermission, requestGeolocationPermission } = usePermission();\n\n const [location, setLocation] = useState<GeolocationPosition | null>(null);\n const [error, setError] = useState<GeolocationPositionError | null>(null);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>\n useEffect(() => {\n const handleSuccess = (position: GeolocationPosition) => {\n setLocation(position);\n };\n\n const handleError = (error: GeolocationPositionError) => {\n setError(error);\n };\n\n if (geolocationPermission === 'granted') {\n navigator.geolocation.getCurrentPosition(handleSuccess, handleError);\n }\n }, [geolocationPermission, props.isAskEntrance, requestGeolocationPermission]);\n\n useEffect(() => {\n if (props.isAskEntrance) {\n if (geolocationPermission !== 'granted') {\n requestGeolocationPermission();\n }\n }\n }, [geolocationPermission, props.isAskEntrance, requestGeolocationPermission]);\n return (\n <GeolocationContext.Provider\n value={{\n requestGeolocationPermission,\n geolocationPermission,\n location,\n error,\n }}\n >\n {props.children}\n </GeolocationContext.Provider>\n );\n};\n","import { useContext } from 'react';\n\nimport { GeolocationContext } from './context';\nimport { IGeolocationContext } from './context.types';\n\nexport const useGeolocation = (): IGeolocationContext => {\n const context = useContext(GeolocationContext);\n if (!context) {\n throw new Error('useGeolocation must be used within an ProviderGeolocation');\n }\n return context;\n};\n"],"mappings":"6IAMA,IAAa,KAAA,EAAA,eAA+D,IAAA,EAE/D,EAAiD,GAAU,CACtE,KAAM,CAAE,sBAAA,EAAuB,6BAAA,CAAA,EAAiC,EAAA,cAAA,EAE1D,CAAC,EAAU,CAAA,KAAA,EAAA,UAAoD,IAAA,EAC/D,CAAC,EAAO,CAAA,KAAA,EAAA,UAAsD,IAAA,EAGpE,SAAA,EAAA,WAAA,IAAgB,CACd,MAAM,EAAiB,GAAkC,CACvD,EAAY,CAAA,GAGR,EAAe,GAAoC,CACvD,EAAS,CAAA,GAGP,IAA0B,WAC5B,UAAU,YAAY,mBAAmB,EAAe,CAAA,GAEzD,CAAC,EAAuB,EAAM,cAAe,EAA6B,KAE7E,EAAA,WAAA,IAAgB,CACV,EAAM,eACJ,IAA0B,WAC5B,EAAA,GAGH,CAAC,EAAuB,EAAM,cAAe,EAA6B,KAE3E,EAAA,KAAC,EAAmB,SAApB,CACE,MAAO,CACL,6BAAA,EACA,sBAAA,EACA,SAAA,EACA,MAAA,YAGD,EAAM,SACqB,GCzCrB,EAAA,IAA4C,CACvD,MAAM,KAAA,EAAA,YAAqB,CAAA,EAC3B,GAAI,CAAC,EACH,MAAM,IAAI,MAAM,2DAAA,EAElB,OAAO"}
1
+ {"version":3,"file":"context-geolocation-DlHZrmaf.cjs","names":[],"sources":["../src/contexts/context-geolocation/context.tsx","../src/contexts/context-geolocation/context.hooks.ts"],"sourcesContent":["import { usePermission } from '@local/contexts/context-permission';\n\nimport { createContext, FC, useEffect, useState } from 'react';\n\nimport { IGeolocationContext, IGeolocationProvider } from './context.types';\n\nexport const GeolocationContext = createContext<IGeolocationContext | null>(null);\n\nexport const ProviderGeolocation: FC<IGeolocationProvider> = (props) => {\n const { geolocationPermission, requestGeolocationPermission } = usePermission();\n\n const [location, setLocation] = useState<GeolocationPosition | null>(null);\n const [error, setError] = useState<GeolocationPositionError | null>(null);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>\n useEffect(() => {\n const handleSuccess = (position: GeolocationPosition) => {\n setLocation(position);\n };\n\n const handleError = (error: GeolocationPositionError) => {\n setError(error);\n };\n\n if (geolocationPermission === 'granted') {\n navigator.geolocation.getCurrentPosition(handleSuccess, handleError);\n }\n }, [geolocationPermission, props.isAskEntrance, requestGeolocationPermission]);\n\n useEffect(() => {\n if (props.isAskEntrance) {\n if (geolocationPermission !== 'granted') {\n requestGeolocationPermission();\n }\n }\n }, [geolocationPermission, props.isAskEntrance, requestGeolocationPermission]);\n return (\n <GeolocationContext.Provider\n value={{\n requestGeolocationPermission,\n geolocationPermission,\n location,\n error,\n }}\n >\n {props.children}\n </GeolocationContext.Provider>\n );\n};\n","import { useContext } from 'react';\n\nimport { GeolocationContext } from './context';\nimport { IGeolocationContext } from './context.types';\n\nexport const useGeolocation = (): IGeolocationContext => {\n const context = useContext(GeolocationContext);\n if (!context) {\n throw new Error('useGeolocation must be used within an ProviderGeolocation');\n }\n return context;\n};\n"],"mappings":"6IAMA,IAAa,KAAA,EAAA,eAA+D,IAAA,EAE/D,EAAiD,GAAU,CACtE,KAAM,CAAE,sBAAA,EAAuB,6BAAA,CAAA,EAAiC,EAAA,cAAA,EAE1D,CAAC,EAAU,CAAA,KAAA,EAAA,UAAoD,IAAA,EAC/D,CAAC,EAAO,CAAA,KAAA,EAAA,UAAsD,IAAA,EAGpE,SAAA,EAAA,WAAA,IAAgB,CACd,MAAM,EAAiB,GAAkC,CACvD,EAAY,CAAA,GAGR,EAAe,GAAoC,CACvD,EAAS,CAAA,GAGP,IAA0B,WAC5B,UAAU,YAAY,mBAAmB,EAAe,CAAA,GAEzD,CAAC,EAAuB,EAAM,cAAe,EAA6B,KAE7E,EAAA,WAAA,IAAgB,CACV,EAAM,eACJ,IAA0B,WAC5B,EAAA,GAGH,CAAC,EAAuB,EAAM,cAAe,EAA6B,KAE3E,EAAA,KAAC,EAAmB,SAApB,CACE,MAAO,CACL,6BAAA,EACA,sBAAA,EACA,SAAA,EACA,MAAA,YAGD,EAAM,SACqB,GCzCrB,EAAA,IAA4C,CACvD,MAAM,KAAA,EAAA,YAAqB,CAAA,EAC3B,GAAI,CAAC,EACH,MAAM,IAAI,MAAM,2DAAA,EAElB,OAAO"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunk-Dd8m0Ver.cjs"),e=require("./context-geolocation-bP0_455H.cjs");exports.ProviderGeolocation=e.ProviderGeolocation;exports.useGeolocation=e.useGeolocation;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunk-Dd8m0Ver.cjs"),e=require("./context-geolocation-DlHZrmaf.cjs");exports.ProviderGeolocation=e.ProviderGeolocation;exports.useGeolocation=e.useGeolocation;
@@ -1,4 +1,4 @@
1
- import { n as e, t as r } from "./context-geolocation-B_KYGlfQ.js";
1
+ import { n as e, t as r } from "./context-geolocation-6vk3sckx.js";
2
2
  export {
3
3
  e as ProviderGeolocation,
4
4
  r as useGeolocation
@@ -1,4 +1,4 @@
1
- import { t as i } from "./logger-QC3A33gh.js";
1
+ import { t as i } from "./logger-D-UddU9-.js";
2
2
  import { jsx as f } from "react/jsx-runtime";
3
3
  import { createContext as V, useCallback as c, useContext as h, useEffect as d, useState as m } from "react";
4
4
  var u = V(null), E = (a) => {
@@ -80,4 +80,4 @@ export {
80
80
  I as t
81
81
  };
82
82
 
83
- //# sourceMappingURL=context-local-storage-DA_whw_k.js.map
83
+ //# sourceMappingURL=context-local-storage-CknlDupP.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-local-storage-DA_whw_k.js","names":[],"sources":["../src/contexts/context-local-storage/context.tsx","../src/contexts/context-local-storage/context.hooks.ts"],"sourcesContent":["import { logger } from '@local/cores/logger';\n\nimport { createContext, FC, useCallback, useEffect, useState } from 'react';\n\nimport { ILocalStorageContext, ILocalStorageProvider, IValidLocalStorageObject } from './context.types';\n\nexport const LocalStorageContext = createContext<ILocalStorageContext | null>(null);\n\n/**\n * Provider component for managing local storage.\n *\n * @remarks\n * The local storage is typed using the `jenesei-kit-react.d.ts` file:\n *\n * ```typescript\n * import '@jenesei-software/jenesei-kit-react'\n *\n * declare module '@jenesei-software/jenesei-kit-react' {\n * export interface IValidLocalStorageObject {\n * access_token: string\n * refresh_token: string\n * }\n * }\n * ```\n */\nexport const ProviderLocalStorage: FC<ILocalStorageProvider> = (props) => {\n const {\n getLocalStorage,\n setLocalStorage,\n removeLocalStorageValue,\n removeLocalStorageValues,\n checkLocalStorage,\n localStorageValues,\n } = useProviderLocalStorage(props);\n\n return (\n <LocalStorageContext.Provider\n value={{\n getLocalStorage,\n setLocalStorage,\n removeLocalStorageValue,\n removeLocalStorageValues,\n checkLocalStorage,\n localStorageValues,\n }}\n >\n {props.children}\n </LocalStorageContext.Provider>\n );\n};\n\nconst useProviderLocalStorage = (props: ILocalStorageProvider) => {\n const [localStorageValues, setLocalStorageValues] = useState<IValidLocalStorageObject>();\n\n const getLocalStorage = useCallback(\n <K extends keyof IValidLocalStorageObject>(name: K): IValidLocalStorageObject[K] | undefined => {\n const localStorageValue = localStorage.getItem(name);\n setLocalStorageValues((prevState) => ({\n ...prevState,\n [name]: localStorageValue ? JSON.parse(localStorageValue) : undefined,\n }));\n return localStorageValue ? JSON.parse(localStorageValue) : undefined;\n },\n [],\n );\n\n const changeLocalStorage = useCallback(\n <K extends keyof IValidLocalStorageObject>(name: K, value: IValidLocalStorageObject[K]) => {\n try {\n localStorage.setItem(String(name), JSON.stringify(value));\n setLocalStorageValues((prevState) => ({ ...prevState, [name]: value }));\n } catch {\n logger.info(`Provider LocalStorage. ChangeLocalStorage error - key:${name}, value:${value}.`);\n }\n },\n [],\n );\n\n const removeLocalStorageValue = useCallback(<K extends keyof IValidLocalStorageObject>(name: K) => {\n try {\n localStorage.removeItem(String(name));\n setLocalStorageValues((prevState) => ({\n ...prevState,\n [name]: undefined,\n }));\n } catch {\n logger.info(`Provider LocalStorage. RemoveLocalStorageValue error - key:${name}.`);\n }\n }, []);\n\n const removeLocalStorageValues = useCallback(() => {\n if (props.validate?.validateKeys) {\n props.validate?.validateKeys.forEach((key) => {\n removeLocalStorageValue(String(key) as never);\n });\n } else {\n logger.info('Provider LocalStorage. RemoveLocalStorageValues - validate is not defined.');\n }\n }, [props.validate, removeLocalStorageValue]);\n\n const checkLocalStorage = useCallback(() => {\n if (props.validate?.validateKeys && props.validate.getValidateLocalStorageValue) {\n props.validate?.validateKeys.forEach((key) => {\n const localStorageValue = localStorage.getItem(key);\n if (localStorageValue) {\n try {\n const parsedValue = JSON.parse(localStorageValue);\n if (!props.validate?.getValidateLocalStorageValue(String(key) as never, parsedValue as never)) {\n removeLocalStorageValue(String(key) as never);\n } else {\n setLocalStorageValues((prevState) => ({\n ...prevState,\n [key]: parsedValue,\n }));\n }\n } catch {\n removeLocalStorageValue(String(key) as never);\n }\n } else {\n removeLocalStorageValue(String(key) as never);\n }\n });\n } else {\n logger.info('Provider LocalStorage. CheckLocalStorage - validate is not defined.');\n }\n }, [props.validate, removeLocalStorageValue]);\n\n useEffect(() => {\n checkLocalStorage();\n }, [checkLocalStorage]);\n\n useEffect(() => {\n return () => {\n setLocalStorageValues(undefined);\n };\n }, []);\n\n return {\n getLocalStorage,\n setLocalStorage: changeLocalStorage,\n removeLocalStorageValue,\n removeLocalStorageValues,\n checkLocalStorage,\n localStorageValues,\n };\n};\n","import { useContext } from 'react';\n\nimport { LocalStorageContext } from './context';\nimport { ILocalStorageContext } from './context.types';\n\n/**\n * Custom hook to access the LocalStorageContext.\n */\nexport const useLocalStorage = (): ILocalStorageContext => {\n const context = useContext(LocalStorageContext);\n if (!context) {\n throw new Error('useLocalStorage must be used within an ProviderLocalStorage');\n }\n return context;\n};\n"],"mappings":";;;AAMA,IAAa,IAAsB,EAA2C,IAAA,GAmBjE,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M,UAAU,aAAa,QAAA,CAAS,MAAQ;AAC5C,MAAA,EAAwB,OAAO,CAAA,CAAI;AAAA,SAGrC,EAAO,KAAK,4EAAA;AAAA,KAEb,CAAC,EAAM,UAAU,CAAA,CAAwB,GAEtC,IAAoB,EAAA,MAAkB;AAC1C,IAAI,EAAM,UAAU,gBAAgB,EAAM,SAAS,+BACjD,EAAM,UAAU,aAAa,QAAA,CAAS,MAAQ;AAC5C,YAAM,IAAoB,aAAa,QAAQ,CAAA;AAC/C,UAAI,EACF,KAAI;AACF,cAAM,IAAc,KAAK,MAAM,CAAA;AAC/B,QAAK,EAAM,UAAU,6BAA6B,OAAO,CAAA,GAAe,CAAA,IAGtE,EAAA,CAAuB,OAAe;AAAA,UACpC,GAAG;AAAA,WACF,CAAA,GAAM;AAAA,UACR,IALD,EAAwB,OAAO,CAAA,CAAI;AAAA,cAO/B;AACN,QAAA,EAAwB,OAAO,CAAA,CAAI;AAAA;UAGrC,CAAA,EAAwB,OAAO,CAAA,CAAI;AAAA,SAIvC,EAAO,KAAK,qEAAA;AAAA,KAEb,CAAC,EAAM,UAAU,CAAA,CAAwB;AAE5C,SAAA,EAAA,MAAgB;AACd,IAAA,EAAA;AAAA,KACC,CAAC,CAAA,CAAkB,GAEtB,EAAA,MACE,MAAa;AACX,IAAA,EAAsB,MAAA;AAAA,KAEvB,CAAA,CAAE,GAEE;AAAA,IACL,iBAAA;AAAA,IACA,iBAAiB;AAAA,IACjB,yBAAA;AAAA,IACA,0BAAA;AAAA,IACA,mBAAA;AAAA,IACA,oBAAA;AAAA;GCvIS,IAAA,MAA8C;AACzD,QAAM,IAAU,EAAW,CAAA;AAC3B,MAAI,CAAC,EACH,OAAM,IAAI,MAAM,6DAAA;AAElB,SAAO"}
1
+ {"version":3,"file":"context-local-storage-CknlDupP.js","names":[],"sources":["../src/contexts/context-local-storage/context.tsx","../src/contexts/context-local-storage/context.hooks.ts"],"sourcesContent":["import { logger } from '@local/cores/logger';\n\nimport { createContext, FC, useCallback, useEffect, useState } from 'react';\n\nimport { ILocalStorageContext, ILocalStorageProvider, IValidLocalStorageObject } from './context.types';\n\nexport const LocalStorageContext = createContext<ILocalStorageContext | null>(null);\n\n/**\n * Provider component for managing local storage.\n *\n * @remarks\n * The local storage is typed using the `jenesei-kit-react.d.ts` file:\n *\n * ```typescript\n * import '@jenesei-software/jenesei-kit-react'\n *\n * declare module '@jenesei-software/jenesei-kit-react' {\n * export interface IValidLocalStorageObject {\n * access_token: string\n * refresh_token: string\n * }\n * }\n * ```\n */\nexport const ProviderLocalStorage: FC<ILocalStorageProvider> = (props) => {\n const {\n getLocalStorage,\n setLocalStorage,\n removeLocalStorageValue,\n removeLocalStorageValues,\n checkLocalStorage,\n localStorageValues,\n } = useProviderLocalStorage(props);\n\n return (\n <LocalStorageContext.Provider\n value={{\n getLocalStorage,\n setLocalStorage,\n removeLocalStorageValue,\n removeLocalStorageValues,\n checkLocalStorage,\n localStorageValues,\n }}\n >\n {props.children}\n </LocalStorageContext.Provider>\n );\n};\n\nconst useProviderLocalStorage = (props: ILocalStorageProvider) => {\n const [localStorageValues, setLocalStorageValues] = useState<IValidLocalStorageObject>();\n\n const getLocalStorage = useCallback(\n <K extends keyof IValidLocalStorageObject>(name: K): IValidLocalStorageObject[K] | undefined => {\n const localStorageValue = localStorage.getItem(name);\n setLocalStorageValues((prevState) => ({\n ...prevState,\n [name]: localStorageValue ? JSON.parse(localStorageValue) : undefined,\n }));\n return localStorageValue ? JSON.parse(localStorageValue) : undefined;\n },\n [],\n );\n\n const changeLocalStorage = useCallback(\n <K extends keyof IValidLocalStorageObject>(name: K, value: IValidLocalStorageObject[K]) => {\n try {\n localStorage.setItem(String(name), JSON.stringify(value));\n setLocalStorageValues((prevState) => ({ ...prevState, [name]: value }));\n } catch {\n logger.info(`Provider LocalStorage. ChangeLocalStorage error - key:${name}, value:${value}.`);\n }\n },\n [],\n );\n\n const removeLocalStorageValue = useCallback(<K extends keyof IValidLocalStorageObject>(name: K) => {\n try {\n localStorage.removeItem(String(name));\n setLocalStorageValues((prevState) => ({\n ...prevState,\n [name]: undefined,\n }));\n } catch {\n logger.info(`Provider LocalStorage. RemoveLocalStorageValue error - key:${name}.`);\n }\n }, []);\n\n const removeLocalStorageValues = useCallback(() => {\n if (props.validate?.validateKeys) {\n props.validate?.validateKeys.forEach((key) => {\n removeLocalStorageValue(String(key) as never);\n });\n } else {\n logger.info('Provider LocalStorage. RemoveLocalStorageValues - validate is not defined.');\n }\n }, [props.validate, removeLocalStorageValue]);\n\n const checkLocalStorage = useCallback(() => {\n if (props.validate?.validateKeys && props.validate.getValidateLocalStorageValue) {\n props.validate?.validateKeys.forEach((key) => {\n const localStorageValue = localStorage.getItem(key);\n if (localStorageValue) {\n try {\n const parsedValue = JSON.parse(localStorageValue);\n if (!props.validate?.getValidateLocalStorageValue(String(key) as never, parsedValue as never)) {\n removeLocalStorageValue(String(key) as never);\n } else {\n setLocalStorageValues((prevState) => ({\n ...prevState,\n [key]: parsedValue,\n }));\n }\n } catch {\n removeLocalStorageValue(String(key) as never);\n }\n } else {\n removeLocalStorageValue(String(key) as never);\n }\n });\n } else {\n logger.info('Provider LocalStorage. CheckLocalStorage - validate is not defined.');\n }\n }, [props.validate, removeLocalStorageValue]);\n\n useEffect(() => {\n checkLocalStorage();\n }, [checkLocalStorage]);\n\n useEffect(() => {\n return () => {\n setLocalStorageValues(undefined);\n };\n }, []);\n\n return {\n getLocalStorage,\n setLocalStorage: changeLocalStorage,\n removeLocalStorageValue,\n removeLocalStorageValues,\n checkLocalStorage,\n localStorageValues,\n };\n};\n","import { useContext } from 'react';\n\nimport { LocalStorageContext } from './context';\nimport { ILocalStorageContext } from './context.types';\n\n/**\n * Custom hook to access the LocalStorageContext.\n */\nexport const useLocalStorage = (): ILocalStorageContext => {\n const context = useContext(LocalStorageContext);\n if (!context) {\n throw new Error('useLocalStorage must be used within an ProviderLocalStorage');\n }\n return context;\n};\n"],"mappings":";;;AAMA,IAAa,IAAsB,EAA2C,IA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U,eAClB,EAAM,UAAU,aAAa,QAAA,CAAS,MAAQ;AAC5C,MAAA,EAAwB,OAAO,CAAA,CAAI;AAAA,SAGrC,EAAO,KAAK,4EAAA;AAAA,KAEb,CAAC,EAAM,UAAU,CAAA,CAAwB,GAEtC,IAAoB,EAAA,MAAkB;AAC1C,IAAI,EAAM,UAAU,gBAAgB,EAAM,SAAS,+BACjD,EAAM,UAAU,aAAa,QAAA,CAAS,MAAQ;AAC5C,YAAM,IAAoB,aAAa,QAAQ,CAAA;AAC/C,UAAI,EACF,KAAI;AACF,cAAM,IAAc,KAAK,MAAM,CAAA;AAC/B,QAAK,EAAM,UAAU,6BAA6B,OAAO,CAAA,GAAe,CAAA,IAGtE,EAAA,CAAuB,OAAe;AAAA,UACpC,GAAG;AAAA,WACF,CAAA,GAAM;AAAA,UACR,IALD,EAAwB,OAAO,CAAA,CAAI;AAAA,cAO/B;AACN,QAAA,EAAwB,OAAO,CAAA,CAAI;AAAA;UAGrC,CAAA,EAAwB,OAAO,CAAA,CAAI;AAAA,SAIvC,EAAO,KAAK,qEAAA;AAAA,KAEb,CAAC,EAAM,UAAU,CAAA,CAAwB;AAE5C,SAAA,EAAA,MAAgB;AACd,IAAA,EAAA;AAAA,KACC,CAAC,CAAA,CAAkB,GAEtB,EAAA,MACE,MAAa;AACX,IAAA,EAAsB,MAAA;AAAA,KAEvB,CAAA,CAAE,GAEE;AAAA,IACL,iBAAA;AAAA,IACA,iBAAiB;AAAA,IACjB,yBAAA;AAAA,IACA,0BAAA;AAAA,IACA,mBAAA;AAAA,IACA,oBAAA;AAAA;GCvIS,IAAA,MAA8C;AACzD,QAAM,IAAU,EAAW,CAAA;AAC3B,MAAI,CAAC,EACH,OAAM,IAAI,MAAM,6DAAA;AAElB,SAAO"}
@@ -1,3 +1,3 @@
1
- const P=require("./chunk-Dd8m0Ver.cjs"),g=require("./logger-D3Xu5ef3.cjs");let L=require("react/jsx-runtime"),r=require("react");var d=(0,r.createContext)(null),f=a=>{const{getLocalStorage:i,setLocalStorage:l,removeLocalStorageValue:n,removeLocalStorageValues:u,checkLocalStorage:o,localStorageValues:S}=V(a);return(0,L.jsx)(d.Provider,{value:{getLocalStorage:i,setLocalStorage:l,removeLocalStorageValue:n,removeLocalStorageValues:u,checkLocalStorage:o,localStorageValues:S},children:a.children})},V=a=>{const[i,l]=(0,r.useState)(),n=(0,r.useCallback)(e=>{const t=localStorage.getItem(e);return l(c=>({...c,[e]:t?JSON.parse(t):void 0})),t?JSON.parse(t):void 0},[]),u=(0,r.useCallback)((e,t)=>{try{localStorage.setItem(String(e),JSON.stringify(t)),l(c=>({...c,[e]:t}))}catch{g.logger.info(`Provider LocalStorage. ChangeLocalStorage error - key:${e}, value:${t}.`)}},[]),o=(0,r.useCallback)(e=>{try{localStorage.removeItem(String(e)),l(t=>({...t,[e]:void 0}))}catch{g.logger.info(`Provider LocalStorage. RemoveLocalStorageValue error - key:${e}.`)}},[]),S=(0,r.useCallback)(()=>{a.validate?.validateKeys?a.validate?.validateKeys.forEach(e=>{o(String(e))}):g.logger.info("Provider LocalStorage. RemoveLocalStorageValues - validate is not defined.")},[a.validate,o]),s=(0,r.useCallback)(()=>{a.validate?.validateKeys&&a.validate.getValidateLocalStorageValue?a.validate?.validateKeys.forEach(e=>{const t=localStorage.getItem(e);if(t)try{const c=JSON.parse(t);a.validate?.getValidateLocalStorageValue(String(e),c)?l(v=>({...v,[e]:c})):o(String(e))}catch{o(String(e))}else o(String(e))}):g.logger.info("Provider LocalStorage. CheckLocalStorage - validate is not defined.")},[a.validate,o]);return(0,r.useEffect)(()=>{s()},[s]),(0,r.useEffect)(()=>()=>{l(void 0)},[]),{getLocalStorage:n,setLocalStorage:u,removeLocalStorageValue:o,removeLocalStorageValues:S,checkLocalStorage:s,localStorageValues:i}},h=()=>{const a=(0,r.useContext)(d);if(!a)throw new Error("useLocalStorage must be used within an ProviderLocalStorage");return a};Object.defineProperty(exports,"ProviderLocalStorage",{enumerable:!0,get:function(){return f}});Object.defineProperty(exports,"useLocalStorage",{enumerable:!0,get:function(){return h}});
1
+ const P=require("./chunk-Dd8m0Ver.cjs"),g=require("./logger-GLARTxbP.cjs");let L=require("react/jsx-runtime"),r=require("react");var d=(0,r.createContext)(null),f=a=>{const{getLocalStorage:i,setLocalStorage:l,removeLocalStorageValue:n,removeLocalStorageValues:u,checkLocalStorage:o,localStorageValues:S}=V(a);return(0,L.jsx)(d.Provider,{value:{getLocalStorage:i,setLocalStorage:l,removeLocalStorageValue:n,removeLocalStorageValues:u,checkLocalStorage:o,localStorageValues:S},children:a.children})},V=a=>{const[i,l]=(0,r.useState)(),n=(0,r.useCallback)(e=>{const t=localStorage.getItem(e);return l(c=>({...c,[e]:t?JSON.parse(t):void 0})),t?JSON.parse(t):void 0},[]),u=(0,r.useCallback)((e,t)=>{try{localStorage.setItem(String(e),JSON.stringify(t)),l(c=>({...c,[e]:t}))}catch{g.logger.info(`Provider LocalStorage. ChangeLocalStorage error - key:${e}, value:${t}.`)}},[]),o=(0,r.useCallback)(e=>{try{localStorage.removeItem(String(e)),l(t=>({...t,[e]:void 0}))}catch{g.logger.info(`Provider LocalStorage. RemoveLocalStorageValue error - key:${e}.`)}},[]),S=(0,r.useCallback)(()=>{a.validate?.validateKeys?a.validate?.validateKeys.forEach(e=>{o(String(e))}):g.logger.info("Provider LocalStorage. RemoveLocalStorageValues - validate is not defined.")},[a.validate,o]),s=(0,r.useCallback)(()=>{a.validate?.validateKeys&&a.validate.getValidateLocalStorageValue?a.validate?.validateKeys.forEach(e=>{const t=localStorage.getItem(e);if(t)try{const c=JSON.parse(t);a.validate?.getValidateLocalStorageValue(String(e),c)?l(v=>({...v,[e]:c})):o(String(e))}catch{o(String(e))}else o(String(e))}):g.logger.info("Provider LocalStorage. CheckLocalStorage - validate is not defined.")},[a.validate,o]);return(0,r.useEffect)(()=>{s()},[s]),(0,r.useEffect)(()=>()=>{l(void 0)},[]),{getLocalStorage:n,setLocalStorage:u,removeLocalStorageValue:o,removeLocalStorageValues:S,checkLocalStorage:s,localStorageValues:i}},h=()=>{const a=(0,r.useContext)(d);if(!a)throw new Error("useLocalStorage must be used within an ProviderLocalStorage");return a};Object.defineProperty(exports,"ProviderLocalStorage",{enumerable:!0,get:function(){return f}});Object.defineProperty(exports,"useLocalStorage",{enumerable:!0,get:function(){return h}});
2
2
 
3
- //# sourceMappingURL=context-local-storage-D_x8dwxM.cjs.map
3
+ //# sourceMappingURL=context-local-storage-DK4zzbkX.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-local-storage-D_x8dwxM.cjs","names":[],"sources":["../src/contexts/context-local-storage/context.tsx","../src/contexts/context-local-storage/context.hooks.ts"],"sourcesContent":["import { logger } from '@local/cores/logger';\n\nimport { createContext, FC, useCallback, useEffect, useState } from 'react';\n\nimport { ILocalStorageContext, ILocalStorageProvider, IValidLocalStorageObject } from './context.types';\n\nexport const LocalStorageContext = createContext<ILocalStorageContext | null>(null);\n\n/**\n * Provider component for managing local storage.\n *\n * @remarks\n * The local storage is typed using the `jenesei-kit-react.d.ts` file:\n *\n * ```typescript\n * import '@jenesei-software/jenesei-kit-react'\n *\n * declare module '@jenesei-software/jenesei-kit-react' {\n * export interface IValidLocalStorageObject {\n * access_token: string\n * refresh_token: string\n * }\n * }\n * ```\n */\nexport const ProviderLocalStorage: FC<ILocalStorageProvider> = (props) => {\n const {\n getLocalStorage,\n setLocalStorage,\n removeLocalStorageValue,\n removeLocalStorageValues,\n checkLocalStorage,\n localStorageValues,\n } = useProviderLocalStorage(props);\n\n return (\n <LocalStorageContext.Provider\n value={{\n getLocalStorage,\n setLocalStorage,\n removeLocalStorageValue,\n removeLocalStorageValues,\n checkLocalStorage,\n localStorageValues,\n }}\n >\n {props.children}\n </LocalStorageContext.Provider>\n );\n};\n\nconst useProviderLocalStorage = (props: ILocalStorageProvider) => {\n const [localStorageValues, setLocalStorageValues] = useState<IValidLocalStorageObject>();\n\n const getLocalStorage = useCallback(\n <K extends keyof IValidLocalStorageObject>(name: K): IValidLocalStorageObject[K] | undefined => {\n const localStorageValue = localStorage.getItem(name);\n setLocalStorageValues((prevState) => ({\n ...prevState,\n [name]: localStorageValue ? JSON.parse(localStorageValue) : undefined,\n }));\n return localStorageValue ? JSON.parse(localStorageValue) : undefined;\n },\n [],\n );\n\n const changeLocalStorage = useCallback(\n <K extends keyof IValidLocalStorageObject>(name: K, value: IValidLocalStorageObject[K]) => {\n try {\n localStorage.setItem(String(name), JSON.stringify(value));\n setLocalStorageValues((prevState) => ({ ...prevState, [name]: value }));\n } catch {\n logger.info(`Provider LocalStorage. ChangeLocalStorage error - key:${name}, value:${value}.`);\n }\n },\n [],\n );\n\n const removeLocalStorageValue = useCallback(<K extends keyof IValidLocalStorageObject>(name: K) => {\n try {\n localStorage.removeItem(String(name));\n setLocalStorageValues((prevState) => ({\n ...prevState,\n [name]: undefined,\n }));\n } catch {\n logger.info(`Provider LocalStorage. RemoveLocalStorageValue error - key:${name}.`);\n }\n }, []);\n\n const removeLocalStorageValues = useCallback(() => {\n if (props.validate?.validateKeys) {\n props.validate?.validateKeys.forEach((key) => {\n removeLocalStorageValue(String(key) as never);\n });\n } else {\n logger.info('Provider LocalStorage. RemoveLocalStorageValues - validate is not defined.');\n }\n }, [props.validate, removeLocalStorageValue]);\n\n const checkLocalStorage = useCallback(() => {\n if (props.validate?.validateKeys && props.validate.getValidateLocalStorageValue) {\n props.validate?.validateKeys.forEach((key) => {\n const localStorageValue = localStorage.getItem(key);\n if (localStorageValue) {\n try {\n const parsedValue = JSON.parse(localStorageValue);\n if (!props.validate?.getValidateLocalStorageValue(String(key) as never, parsedValue as never)) {\n removeLocalStorageValue(String(key) as never);\n } else {\n setLocalStorageValues((prevState) => ({\n ...prevState,\n [key]: parsedValue,\n }));\n }\n } catch {\n removeLocalStorageValue(String(key) as never);\n }\n } else {\n removeLocalStorageValue(String(key) as never);\n }\n });\n } else {\n logger.info('Provider LocalStorage. CheckLocalStorage - validate is not defined.');\n }\n }, [props.validate, removeLocalStorageValue]);\n\n useEffect(() => {\n checkLocalStorage();\n }, [checkLocalStorage]);\n\n useEffect(() => {\n return () => {\n setLocalStorageValues(undefined);\n };\n }, []);\n\n return {\n getLocalStorage,\n setLocalStorage: changeLocalStorage,\n removeLocalStorageValue,\n removeLocalStorageValues,\n checkLocalStorage,\n localStorageValues,\n };\n};\n","import { useContext } from 'react';\n\nimport { LocalStorageContext } from './context';\nimport { ILocalStorageContext } from './context.types';\n\n/**\n * Custom hook to access the LocalStorageContext.\n */\nexport const useLocalStorage = (): ILocalStorageContext => {\n const context = useContext(LocalStorageContext);\n if (!context) {\n throw new Error('useLocalStorage must be used within an ProviderLocalStorage');\n }\n return context;\n};\n"],"mappings":"iIAMA,IAAa,KAAA,EAAA,eAAiE,IAAA,EAmBjE,EAAmD,GAAU,CACxE,KAAM,CACJ,gBAAA,EACA,gBAAA,EACA,wBAAA,EACA,yBAAA,EACA,kBAAA,EACA,mBAAA,CAAA,EACE,EAAwB,CAAA,EAE5B,SACE,EAAA,KAAC,EAAoB,SAArB,CACE,MAAO,CACL,gBAAA,EACA,gBAAA,EACA,wBAAA,EACA,yBAAA,EACA,kBAAA,EACA,mBAAA,YAGD,EAAM,SACsB,GAI7B,EAA2B,GAAiC,CAChE,KAAM,CAAC,EAAoB,CAAA,KAAA,EAAA,UAAA,EAErB,KAAA,EAAA,aACuC,GAAqD,CAC9F,MAAM,EAAoB,aAAa,QAAQ,CAAA,EAC/C,OAAA,EAAuB,IAAe,CACpC,GAAG,GACF,CAAA,EAAO,EAAoB,KAAK,MAAM,CAAA,EAAqB,QAC7D,EACM,EAAoB,KAAK,MAAM,CAAA,EAAqB,QAE7D,CAAA,CAAE,EAGE,KAAA,EAAA,aAAA,CACuC,EAAS,IAAuC,CACzF,GAAI,CACF,aAAa,QAAQ,OAAO,CAAA,EAAO,KAAK,UAAU,CAAA,CAAM,EACxD,EAAuB,IAAe,CAAE,GAAG,GAAY,CAAA,EAAO,GAAO,OAC/D,CACN,EAAA,OAAO,KAAK,yD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AM,6DAAA,EAElB,OAAO"}
1
+ {"version":3,"file":"context-local-storage-DK4zzbkX.cjs","names":[],"sources":["../src/contexts/context-local-storage/context.tsx","../src/contexts/context-local-storage/context.hooks.ts"],"sourcesContent":["import { logger } from '@local/cores/logger';\n\nimport { createContext, FC, useCallback, useEffect, useState } from 'react';\n\nimport { ILocalStorageContext, ILocalStorageProvider, IValidLocalStorageObject } from './context.types';\n\nexport const LocalStorageContext = createContext<ILocalStorageContext | null>(null);\n\n/**\n * Provider component for managing local storage.\n *\n * @remarks\n * The local storage is typed using the `jenesei-kit-react.d.ts` file:\n *\n * ```typescript\n * import '@jenesei-software/jenesei-kit-react'\n *\n * declare module '@jenesei-software/jenesei-kit-react' {\n * export interface IValidLocalStorageObject {\n * access_token: string\n * refresh_token: string\n * }\n * }\n * ```\n */\nexport const ProviderLocalStorage: FC<ILocalStorageProvider> = (props) => {\n const {\n getLocalStorage,\n setLocalStorage,\n removeLocalStorageValue,\n removeLocalStorageValues,\n checkLocalStorage,\n localStorageValues,\n } = useProviderLocalStorage(props);\n\n return (\n <LocalStorageContext.Provider\n value={{\n getLocalStorage,\n setLocalStorage,\n removeLocalStorageValue,\n removeLocalStorageValues,\n checkLocalStorage,\n localStorageValues,\n }}\n >\n {props.children}\n </LocalStorageContext.Provider>\n );\n};\n\nconst useProviderLocalStorage = (props: ILocalStorageProvider) => {\n const [localStorageValues, setLocalStorageValues] = useState<IValidLocalStorageObject>();\n\n const getLocalStorage = useCallback(\n <K extends keyof IValidLocalStorageObject>(name: K): IValidLocalStorageObject[K] | undefined => {\n const localStorageValue = localStorage.getItem(name);\n setLocalStorageValues((prevState) => ({\n ...prevState,\n [name]: localStorageValue ? JSON.parse(localStorageValue) : undefined,\n }));\n return localStorageValue ? JSON.parse(localStorageValue) : undefined;\n },\n [],\n );\n\n const changeLocalStorage = useCallback(\n <K extends keyof IValidLocalStorageObject>(name: K, value: IValidLocalStorageObject[K]) => {\n try {\n localStorage.setItem(String(name), JSON.stringify(value));\n setLocalStorageValues((prevState) => ({ ...prevState, [name]: value }));\n } catch {\n logger.info(`Provider LocalStorage. ChangeLocalStorage error - key:${name}, value:${value}.`);\n }\n },\n [],\n );\n\n const removeLocalStorageValue = useCallback(<K extends keyof IValidLocalStorageObject>(name: K) => {\n try {\n localStorage.removeItem(String(name));\n setLocalStorageValues((prevState) => ({\n ...prevState,\n [name]: undefined,\n }));\n } catch {\n logger.info(`Provider LocalStorage. RemoveLocalStorageValue error - key:${name}.`);\n }\n }, []);\n\n const removeLocalStorageValues = useCallback(() => {\n if (props.validate?.validateKeys) {\n props.validate?.validateKeys.forEach((key) => {\n removeLocalStorageValue(String(key) as never);\n });\n } else {\n logger.info('Provider LocalStorage. RemoveLocalStorageValues - validate is not defined.');\n }\n }, [props.validate, removeLocalStorageValue]);\n\n const checkLocalStorage = useCallback(() => {\n if (props.validate?.validateKeys && props.validate.getValidateLocalStorageValue) {\n props.validate?.validateKeys.forEach((key) => {\n const localStorageValue = localStorage.getItem(key);\n if (localStorageValue) {\n try {\n const parsedValue = JSON.parse(localStorageValue);\n if (!props.validate?.getValidateLocalStorageValue(String(key) as never, parsedValue as never)) {\n removeLocalStorageValue(String(key) as never);\n } else {\n setLocalStorageValues((prevState) => ({\n ...prevState,\n [key]: parsedValue,\n }));\n }\n } catch {\n removeLocalStorageValue(String(key) as never);\n }\n } else {\n removeLocalStorageValue(String(key) as never);\n }\n });\n } else {\n logger.info('Provider LocalStorage. CheckLocalStorage - validate is not defined.');\n }\n }, [props.validate, removeLocalStorageValue]);\n\n useEffect(() => {\n checkLocalStorage();\n }, [checkLocalStorage]);\n\n useEffect(() => {\n return () => {\n setLocalStorageValues(undefined);\n };\n }, []);\n\n return {\n getLocalStorage,\n setLocalStorage: changeLocalStorage,\n removeLocalStorageValue,\n removeLocalStorageValues,\n checkLocalStorage,\n localStorageValues,\n };\n};\n","import { useContext } from 'react';\n\nimport { LocalStorageContext } from './context';\nimport { ILocalStorageContext } from './context.types';\n\n/**\n * Custom hook to access the LocalStorageContext.\n */\nexport const useLocalStorage = (): ILocalStorageContext => {\n const context = useContext(LocalStorageContext);\n if (!context) {\n throw new Error('useLocalStorage must be used within an ProviderLocalStorage');\n }\n return context;\n};\n"],"mappings":"iIAMA,IAAa,KAAA,EAAA,eAAiE,IAAA,EAmBjE,EAAmD,GAAU,CACxE,KAAM,CACJ,gBAAA,EACA,gBAAA,EACA,wBAAA,EACA,yBAAA,EACA,kBAAA,EACA,mBAAA,CAAA,EACE,EAAwB,CAAA,EAE5B,SACE,EAAA,KAAC,EAAoB,SAArB,CACE,MAAO,CACL,gBAAA,EACA,gBAAA,EACA,wBAAA,EACA,yBAAA,EACA,kBAAA,EACA,mBAAA,YAGD,EAAM,SACsB,GAI7B,EAA2B,GAAiC,CAChE,KAAM,CAAC,EAAoB,CAAA,KAAA,EAAA,UAAA,EAErB,KAAA,EAAA,aACuC,GAAqD,CAC9F,MAAM,EAAoB,aAAa,QAAQ,CAAA,EAC/C,OAAA,EAAuB,IAAe,CACpC,GAAG,GACF,CAAA,EAAO,EAAoB,KAAK,MAAM,CAAA,EAAqB,QAC7D,EACM,EAAoB,KAAK,MAAM,CAAA,EAAqB,QAE7D,CAAA,CAAE,EAGE,KAAA,EAAA,aAAA,CACuC,EAAS,IAAuC,CACzF,GAAI,CACF,aAAa,QAAQ,OAAO,CAAA,EAAO,KAAK,UAAU,CAAA,CAAM,EACxD,EAAuB,IAAe,CAAE,GAAG,GAAY,CAAA,EAAO,GAAO,OAC/D,CACN,EAAA,OAAO,KAAK,yDAAyD,CAAA,WAAe,CAAA,GAAM,IAG9F,CAAA,CAAE,EAGE,KAAA,EAAA,aAAiF,GAAY,CACjG,GAAI,CACF,aAAa,WAAW,OAAO,CAAA,CAAK,EACpC,EAAuB,IAAe,CACpC,GAAG,GACF,CAAA,EAAO,QACT,OACK,CACN,EAAA,OAAO,KAAK,8DAA8D,CAAA,GAAK,IAEhF,CAAA,CAAE,EAEC,KAAA,EAAA,aAAA,IAA6C,CAC7C,EAAM,UAAU,aAClB,EAAM,UAAU,aAAa,QAAS,GAAQ,CAC5C,EAAwB,OAAO,CAAA,CAAI,IAGrC,EAAA,OAAO,KAAK,4EAAA,GAEb,CAAC,EAAM,SAAU,CAAA,CAAwB,EAEtC,KAAA,EAAA,aAAA,IAAsC,CACtC,EAAM,UAAU,cAAgB,EAAM,SAAS,6BACjD,EAAM,UAAU,aAAa,QAAS,GAAQ,CAC5C,MAAM,EAAoB,aAAa,QAAQ,CAAA,EAC/C,GAAI,EACF,GAAI,CACF,MAAM,EAAc,KAAK,MAAM,CAAA,EAC1B,EAAM,UAAU,6BAA6B,OAAO,CAAA,EAAe,CAAA,EAGtE,EAAuB,IAAe,CACpC,GAAG,GACF,CAAA,EAAM,GACR,EALD,EAAwB,OAAO,CAAA,CAAI,OAO/B,CACN,EAAwB,OAAO,CAAA,CAAI,OAGrC,EAAwB,OAAO,CAAA,CAAI,IAIvC,EAAA,OAAO,KAAK,qEAAA,GAEb,CAAC,EAAM,SAAU,CAAA,CAAwB,EAE5C,SAAA,EAAA,WAAA,IAAgB,CACd,EAAA,GACC,CAAC,CAAA,CAAkB,KAEtB,EAAA,WAAA,IACE,IAAa,CACX,EAAsB,MAAA,GAEvB,CAAA,CAAE,EAEE,CACL,gBAAA,EACA,gBAAiB,EACjB,wBAAA,EACA,yBAAA,EACA,kBAAA,EACA,mBAAA,ICvIS,EAAA,IAA8C,CACzD,MAAM,KAAA,EAAA,YAAqB,CAAA,EAC3B,GAAI,CAAC,EACH,MAAM,IAAI,MAAM,6DAAA,EAElB,OAAO"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./chunk-Dd8m0Ver.cjs"),e=require("./context-local-storage-D_x8dwxM.cjs");exports.ProviderLocalStorage=e.ProviderLocalStorage;exports.useLocalStorage=e.useLocalStorage;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./chunk-Dd8m0Ver.cjs"),e=require("./context-local-storage-DK4zzbkX.cjs");exports.ProviderLocalStorage=e.ProviderLocalStorage;exports.useLocalStorage=e.useLocalStorage;
@@ -1,4 +1,4 @@
1
- import { n as r, t as a } from "./context-local-storage-DA_whw_k.js";
1
+ import { n as r, t as a } from "./context-local-storage-CknlDupP.js";
2
2
  export {
3
3
  r as ProviderLocalStorage,
4
4
  a as useLocalStorage
@@ -1,4 +1,4 @@
1
- import { t as s } from "./logger-QC3A33gh.js";
1
+ import { t as s } from "./logger-D-UddU9-.js";
2
2
  import { jsx as d } from "react/jsx-runtime";
3
3
  import { createContext as P, useCallback as u, useContext as w, useEffect as a, useState as n } from "react";
4
4
  var l = P(null), C = (o) => {
@@ -74,4 +74,4 @@ export {
74
74
  q as t
75
75
  };
76
76
 
77
- //# sourceMappingURL=context-permission-Cj70kL4A.js.map
77
+ //# sourceMappingURL=context-permission-C5L4I8X3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-permission-Cj70kL4A.js","names":[],"sources":["../src/contexts/context-permission/context.tsx","../src/contexts/context-permission/context.hooks.ts"],"sourcesContent":["import { logger } from '@local/cores/logger';\n\nimport { createContext, useCallback, useEffect, useState } from 'react';\n\nimport { IPermissionContext, IPermissionProvider } from './context.types';\n\nexport const PermissionContext = createContext<IPermissionContext | null>(null);\n\nexport const ProviderPermission = (props: IPermissionProvider) => {\n const { pushNotificationSupported } = usePushNotificationSupported();\n const { isBiometricSupported } = useBiometricSupported();\n const { notificationPermission, requestNotificationPermission, isNotificationPermissionLoading } =\n useNotificationPermission();\n const { geolocationPermission, requestGeolocationPermission } = useGeolocationPermission();\n\n return (\n <PermissionContext.Provider\n value={{\n isBiometricSupported,\n geolocationPermission,\n pushNotificationSupported,\n requestGeolocationPermission,\n notificationPermission,\n requestNotificationPermission,\n isNotificationPermissionLoading,\n }}\n >\n {props.children}\n </PermissionContext.Provider>\n );\n};\n\nconst useBiometricSupported = () => {\n const [isBiometricSupported, setIsBiometricSupported] = useState(false);\n\n useEffect(() => {\n const checkBiometricAvailability = async () => {\n try {\n if (\n window.PublicKeyCredential &&\n typeof window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable === 'function'\n ) {\n const available = await window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable();\n setIsBiometricSupported(available);\n } else {\n setIsBiometricSupported(false);\n }\n } catch (error) {\n logger.error('Error checking biometric availability:', error);\n setIsBiometricSupported(false);\n }\n };\n\n checkBiometricAvailability();\n }, []);\n\n return { isBiometricSupported };\n};\n\nconst useGeolocationPermission = () => {\n // eslint-disable-next-line no-undef\n const [geolocationPermission, setGeolocationPermission] = useState<PermissionState | null>(null);\n\n useEffect(() => {\n if ('permissions' in window.navigator) {\n window.navigator.permissions.query({ name: 'geolocation' }).then((permissionStatus) => {\n setGeolocationPermission(permissionStatus.state);\n permissionStatus.onchange = () => {\n setGeolocationPermission(permissionStatus.state);\n };\n });\n }\n }, []);\n\n const requestGeolocationPermission = useCallback(() => {\n if ('geolocation' in window.navigator) {\n window.navigator.geolocation.getCurrentPosition(\n () => setGeolocationPermission('granted'),\n () => setGeolocationPermission('denied'),\n );\n } else {\n logger.warn('Provider Permission. Geolocation is not supported in this browser.');\n }\n }, []);\n\n return { geolocationPermission, requestGeolocationPermission };\n};\n\nconst useNotificationPermission = () => {\n // eslint-disable-next-line no-undef\n const [notificationPermission, setNotificationPermission] = useState<NotificationPermission | null>(null);\n const [isNotificationPermissionLoading, setIsNotificationPermissionLoading] = useState<boolean>(false);\n\n const requestNotificationPermission = useCallback(async () => {\n setIsNotificationPermissionLoading(true);\n if ('Notification' in window) {\n try {\n setIsNotificationPermissionLoading(true);\n const permission = await window.Notification.requestPermission();\n setNotificationPermission(permission);\n setIsNotificationPermissionLoading(false);\n return permission;\n } catch (error) {\n logger.error('Provider Permission. Failed to request notification permission:', error);\n }\n } else {\n logger.warn('Provider Permission. Notifications are not supported in this browser.');\n }\n setIsNotificationPermissionLoading(false);\n }, []);\n\n useEffect(() => {\n if ('Notification' in window) {\n setNotificationPermission(window.Notification.permission);\n }\n }, []);\n\n return { notificationPermission, requestNotificationPermission, isNotificationPermissionLoading };\n};\n\nconst usePushNotificationSupported = () => {\n const [pushNotificationSupported, setPushNotificationSupported] = useState<boolean>(false);\n\n useEffect(() => {\n if ('PushManager' in window) {\n setPushNotificationSupported(true);\n }\n }, []);\n\n return { pushNotificationSupported };\n};\n","import { useContext } from 'react';\n\nimport { PermissionContext } from './context';\nimport { IPermissionContext } from './context.types';\n\n/**\n * Custom hook to access the PermissionContext.\n */\nexport const usePermission = (): IPermissionContext => {\n const context = useContext(PermissionContext);\n if (!context) {\n throw new Error('usePermission must be used within an PermissionProvider');\n }\n return context;\n};\n"],"mappings":";;;AAMA,IAAa,IAAoB,EAAyC,IAAA,GAE7D,IAAA,CAAsB,MAA+B;AAChE,QAAM,EAAE,2BAAA,EAAA,IAA8B,EAAA,GAChC,EAAE,sBAAA,EAAA,IAAyB,EAAA,GAC3B,EAAE,wBAAA,GAAwB,+BAAA,GAA+B,iCAAA,EAAA,IAC7D,EAAA,GACI,EAAE,uBAAA,GAAuB,8BAAA,EAAA,IAAiC,EAAA;AAEhE,SACE,gBAAA,EAAC,EAAkB,UAAnB;AAAA,IACE,OAAO;AAAA,MACL,sBAAA;AAAA,MACA,uBAAA;AAAA,MACA,2BAAA;AAAA,MACA,8BAAA;AAAA,MACA,wBAAA;AAAA,MACA,+BAAA;AAAA,MACA,iCAAA;AAAA;cAGD,EAAM;AAAA,GACoB;GAI3B,IAAA,MAA8B;AAClC,QAAM,CAAC,GAAsB,CAAA,IAA2B,EAAS,EAAA;AAEjE,SAAA,EAAA,MAAgB;AAkBd,KAjBmC,YAAY;AAC7C,UAAI;AACF,QACE,OAAO,uBACP,OAAO,OAAO,oBAAoB,iDAAkD,aAGpF,EADkB,MAAM,OAAO,oBAAoB,8CAAA,CAA+C,IAGlG,EAAwB,EAAA;AAAA,eAEnB,GAAO;AACd,QAAA,EAAO,MAAM,0CAA0C,CAAA,GACvD,EAAwB,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A+B,iCAAA;AAAA;GAG5D,IAAA,MAAqC;AACzC,QAAM,CAAC,GAA2B,CAAA,IAAgC,EAAkB,EAAA;AAEpF,SAAA,EAAA,MAAgB;AACd,IAAI,iBAAiB,UACnB,EAA6B,EAAA;AAAA,KAE9B,CAAA,CAAE,GAEE,EAAE,2BAAA,EAAA;GCzHE,IAAA,MAA0C;AACrD,QAAM,IAAU,EAAW,CAAA;AAC3B,MAAI,CAAC,EACH,OAAM,IAAI,MAAM,yDAAA;AAElB,SAAO"}
1
+ {"version":3,"file":"context-permission-C5L4I8X3.js","names":[],"sources":["../src/contexts/context-permission/context.tsx","../src/contexts/context-permission/context.hooks.ts"],"sourcesContent":["import { logger } from '@local/cores/logger';\n\nimport { createContext, useCallback, useEffect, useState } from 'react';\n\nimport { IPermissionContext, IPermissionProvider } from './context.types';\n\nexport const PermissionContext = createContext<IPermissionContext | null>(null);\n\nexport const ProviderPermission = (props: IPermissionProvider) => {\n const { pushNotificationSupported } = usePushNotificationSupported();\n const { isBiometricSupported } = useBiometricSupported();\n const { notificationPermission, requestNotificationPermission, isNotificationPermissionLoading } =\n useNotificationPermission();\n const { geolocationPermission, requestGeolocationPermission } = useGeolocationPermission();\n\n return (\n <PermissionContext.Provider\n value={{\n isBiometricSupported,\n geolocationPermission,\n pushNotificationSupported,\n requestGeolocationPermission,\n notificationPermission,\n requestNotificationPermission,\n isNotificationPermissionLoading,\n }}\n >\n {props.children}\n </PermissionContext.Provider>\n );\n};\n\nconst useBiometricSupported = () => {\n const [isBiometricSupported, setIsBiometricSupported] = useState(false);\n\n useEffect(() => {\n const checkBiometricAvailability = async () => {\n try {\n if (\n window.PublicKeyCredential &&\n typeof window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable === 'function'\n ) {\n const available = await window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable();\n setIsBiometricSupported(available);\n } else {\n setIsBiometricSupported(false);\n }\n } catch (error) {\n logger.error('Error checking biometric availability:', error);\n setIsBiometricSupported(false);\n }\n };\n\n checkBiometricAvailability();\n }, []);\n\n return { isBiometricSupported };\n};\n\nconst useGeolocationPermission = () => {\n // eslint-disable-next-line no-undef\n const [geolocationPermission, setGeolocationPermission] = useState<PermissionState | null>(null);\n\n useEffect(() => {\n if ('permissions' in window.navigator) {\n window.navigator.permissions.query({ name: 'geolocation' }).then((permissionStatus) => {\n setGeolocationPermission(permissionStatus.state);\n permissionStatus.onchange = () => {\n setGeolocationPermission(permissionStatus.state);\n };\n });\n }\n }, []);\n\n const requestGeolocationPermission = useCallback(() => {\n if ('geolocation' in window.navigator) {\n window.navigator.geolocation.getCurrentPosition(\n () => setGeolocationPermission('granted'),\n () => setGeolocationPermission('denied'),\n );\n } else {\n logger.warn('Provider Permission. Geolocation is not supported in this browser.');\n }\n }, []);\n\n return { geolocationPermission, requestGeolocationPermission };\n};\n\nconst useNotificationPermission = () => {\n // eslint-disable-next-line no-undef\n const [notificationPermission, setNotificationPermission] = useState<NotificationPermission | null>(null);\n const [isNotificationPermissionLoading, setIsNotificationPermissionLoading] = useState<boolean>(false);\n\n const requestNotificationPermission = useCallback(async () => {\n setIsNotificationPermissionLoading(true);\n if ('Notification' in window) {\n try {\n setIsNotificationPermissionLoading(true);\n const permission = await window.Notification.requestPermission();\n setNotificationPermission(permission);\n setIsNotificationPermissionLoading(false);\n return permission;\n } catch (error) {\n logger.error('Provider Permission. Failed to request notification permission:', error);\n }\n } else {\n logger.warn('Provider Permission. Notifications are not supported in this browser.');\n }\n setIsNotificationPermissionLoading(false);\n }, []);\n\n useEffect(() => {\n if ('Notification' in window) {\n setNotificationPermission(window.Notification.permission);\n }\n }, []);\n\n return { notificationPermission, requestNotificationPermission, isNotificationPermissionLoading };\n};\n\nconst usePushNotificationSupported = () => {\n const [pushNotificationSupported, setPushNotificationSupported] = useState<boolean>(false);\n\n useEffect(() => {\n if ('PushManager' in window) {\n setPushNotificationSupported(true);\n }\n }, []);\n\n return { pushNotificationSupported };\n};\n","import { useContext } from 'react';\n\nimport { PermissionContext } from './context';\nimport { IPermissionContext } from './context.types';\n\n/**\n * Custom hook to access the PermissionContext.\n */\nexport const usePermission = (): IPermissionContext => {\n const context = useContext(PermissionContext);\n if (!context) {\n throw new Error('usePermission must be used within an PermissionProvider');\n }\n return context;\n};\n"],"mappings":";;;AAMA,IAAa,IAAoB,EAAyC,IAAA,GAE7D,IAAA,CAAsB,MAA+B;AAChE,QAAM,EAAE,2BAAA,EAAA,IAA8B,EAAA,GAChC,EAAE,sBAAA,EAAA,IAAyB,EAAA,GAC3B,EAAE,wBAAA,GAAwB,+BAAA,GAA+B,iCAAA,EAAA,IAC7D,EAAA,GACI,EAAE,uBAAA,GAAuB,8BAAA,EAAA,IAAiC,EAAA;AAEhE,SACE,gBAAA,EAAC,EAAkB,UAAnB;AAAA,IACE,OAAO;AAAA,MACL,sBAAA;AAAA,MACA,uBAAA;AAAA,MACA,2BAAA;AAAA,MACA,8BAAA;AAAA,MACA,wBAAA;AAAA,MACA,+BAAA;AAAA,MACA,iCAAA;AAAA;cAGD,EAAM;AAAA,GACoB;GAI3B,IAAA,MAA8B;AAClC,QAAM,CAAC,GAAsB,CAAA,IAA2B,EAAS,EAAA;AAEjE,SAAA,EAAA,MAAgB;AAkBd,KAjBmC,YAAY;AAC7C,UAAI;AACF,QACE,OAAO,uBACP,OAAO,OAAO,oBAAoB,iDAAkD,aAGpF,EADkB,MAAM,OAAO,oBAAoB,8CAAA,CAA+C,IAGlG,EAAwB,EAAA;AAAA,eAEnB,GAAO;AACd,QAAA,EAAO,MAAM,0CAA0C,CAAA,GACvD,EAAwB,EAAA;AAAA;OAI5B;AAAA,KACC,CAAA,CAAE,GAEE,EAAE,sBAAA,EAAA;GAGL,IAAA,MAAiC;AAErC,QAAM,CAAC,GAAuB,CAAA,IAA4B,EAAiC,IAAA;AAE3F,SAAA,EAAA,MAAgB;AACd,IAAI,iBAAiB,OAAO,aAC1B,OAAO,UAAU,YAAY,MAAM,EAAE,MAAM,cAAA,CAA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