{"version":3,"file":"WindowProvider.mjs","sources":["../../../../src/components/WindowProvider/WindowProvider.tsx"],"sourcesContent":["'use client'\n\nimport { useMemo } from 'react'\n\nimport { createContext } from '~/src/utils/react'\n\nimport {\n  type WindowContextValue,\n  type WindowProviderProps,\n} from './WindowProvider.types'\n\nconst [WindowContextProvider, useWindowContext] =\n  createContext<WindowContextValue | null>(null, 'WindowProvider')\n\n/**\n * Custom hook to access the window context.\n */\nexport function useWindow() {\n  return useWindowContext('useWindow')\n}\n\n/**\n * Custom hook to access the root element from the window context.\n */\nexport function useRootElement() {\n  return useWindowContext('useRootElement').rootElement\n}\n\n/**\n * Component provider for the window context.\n * This component wraps its children in the WindowContextProvider, supplying\n * the window object and its root element to the context for consumption\n */\nexport function WindowProvider({ window, children }: WindowProviderProps) {\n  return (\n    <WindowContextProvider\n      value={useMemo(\n        () => ({\n          window,\n          document: window.document,\n          rootElement: window.document.body,\n        }),\n        [window]\n      )}\n    >\n      {children}\n    </WindowContextProvider>\n  )\n}\n"],"names":["WindowContextProvider","useWindowContext","createContext","useWindow","useRootElement","rootElement","WindowProvider","window","children","_jsx","value","useMemo","document","body"],"mappings":";;;;AAWA,MAAM,CAACA,qBAAqB,EAAEC,gBAAgB,CAAC,GAC7CC,aAAa,CAA4B,IAAI,EAAE,gBAAgB,CAAC;;AAElE;AACA;AACA;AACO,SAASC,SAASA,GAAG;EAC1B,OAAOF,gBAAgB,CAAC,WAAW,CAAC;AACtC;;AAEA;AACA;AACA;AACO,SAASG,cAAcA,GAAG;AAC/B,EAAA,OAAOH,gBAAgB,CAAC,gBAAgB,CAAC,CAACI,WAAW;AACvD;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAAC;EAAEC,MAAM;AAAEC,EAAAA;AAA8B,CAAC,EAAE;EACxE,oBACEC,GAAA,CAACT,qBAAqB,EAAA;IACpBU,KAAK,EAAEC,OAAO,CACZ,OAAO;MACLJ,MAAM;MACNK,QAAQ,EAAEL,MAAM,CAACK,QAAQ;AACzBP,MAAAA,WAAW,EAAEE,MAAM,CAACK,QAAQ,CAACC;AAC/B,KAAC,CAAC,EACF,CAACN,MAAM,CACT,CAAE;AAAAC,IAAAA,QAAA,EAEDA;AAAQ,GACY,CAAC;AAE5B;;;;"}