{"version":3,"sources":["../../../src/context/NovuUIContext.tsx"],"sourcesContent":["import type { NovuUI } from '@novu/js/ui';\nimport React from 'react';\nimport { assertContextExists, createContextAndHook } from '../utils/createContextAndHook';\nimport type { ReactAllIconOverrides } from '../utils/types';\nimport type { OutletStore } from './OutletStore';\n\ntype NovuUIContextValue = {\n  novuUI: NovuUI;\n  /** The host's own icon overrides, so host-native blocks render them without a trip through the bridge. */\n  icons: ReactAllIconOverrides;\n};\n\nconst [NovuUIContext, useNovuUIContext, useUnsafeNovuUIContext] =\n  createContextAndHook<NovuUIContextValue>('NovuUIContext');\n\nconst NovuUIProvider = (props: React.PropsWithChildren<{ value: NovuUIContextValue }>) => {\n  return <NovuUIContext.Provider value={{ value: props.value }}>{props.children}</NovuUIContext.Provider>;\n};\n\n/**\n * The outlet store of the nearest `OutletScope`; `NovuUI` renders the outermost one. React events from portal content\n * bubble along the React tree, so a render prop is adapted inside a scope whose host sits beneath whatever the host\n * app wraps around the component. There is no fallback.\n */\nconst OutletScopeContext = React.createContext<OutletStore | undefined>(undefined);\nOutletScopeContext.displayName = 'OutletScopeContext';\nconst OutletScopeProvider = OutletScopeContext.Provider;\n\n/** The nearest scope, or `undefined` outside any; for code that only registers with a scope when there is one. */\nconst useOutletScope = () => React.useContext(OutletScopeContext);\n\nconst useOutlets = () => {\n  const outlets = React.useContext(OutletScopeContext);\n  assertContextExists(\n    outlets,\n    'Render props must be adapted inside an OutletScope, so the component that owns them hosts their portals'\n  );\n\n  return outlets;\n};\n\nexport {\n  useNovuUIContext as useNovuUI,\n  useUnsafeNovuUIContext as useUnsafeNovuUI,\n  NovuUIProvider,\n  OutletScopeProvider,\n  useOutlets,\n  useOutletScope,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,kCAA0D;AAcjD;AAJT,IAAM,CAAC,eAAe,kBAAkB,sBAAsB,QAC5D,kDAAyC,eAAe;AAE1D,IAAM,iBAAiB,CAAC,UAAkE;AACxF,SAAO,4CAAC,cAAc,UAAd,EAAuB,OAAO,EAAE,OAAO,MAAM,MAAM,GAAI,gBAAM,UAAS;AAChF;AAOA,IAAM,qBAAqB,aAAAA,QAAM,cAAuC,MAAS;AACjF,mBAAmB,cAAc;AACjC,IAAM,sBAAsB,mBAAmB;AAG/C,IAAM,iBAAiB,MAAM,aAAAA,QAAM,WAAW,kBAAkB;AAEhE,IAAM,aAAa,MAAM;AACvB,QAAM,UAAU,aAAAA,QAAM,WAAW,kBAAkB;AACnD;AAAA,IACE;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;","names":["React"]}