{"version":3,"file":"installPortals.cjs","names":["currentIdCache","currentPortalsCache","PORTALS_CONTEXT_KEY","PORTAL_ANCHORS_CONTEXT_KEY"],"sources":["../../../src/portals/installPortals/installPortals.ts"],"sourcesContent":["import {\n  anchorsSetup,\n  currentIdCache,\n  currentPortalsCache,\n  PORTALS_CONTEXT_KEY,\n  PORTAL_ANCHORS_CONTEXT_KEY,\n} from '@pastweb/tools';\nimport type { Installer } from '../../GlobalContext';\nimport type { PortalsOptions } from './types';\n\n/**\n * Creates a {@link GlobalContext} installer for the React portal helpers.\n *\n * The installer exposes the portal descriptor and the anchor ids created by\n * `@pastweb/tools`. Components can then read them with {@link usePortals},\n * {@link usePortalAnchors}, and {@link Portal}.\n *\n * @param options - Portal anchors, entry factory, and optional caches.\n * @returns An installer accepted by `GlobalContext` through its `use` prop.\n *\n * @example\n * ```tsx\n * const installPortalContext = installPortals({\n *   anchorsIds: { modal: 'modal-root' },\n *   getEntry: (props, component) => createEntry({ entry: () => component }),\n * });\n *\n * <GlobalContext use={installPortalContext}>\n *   <App />\n * </GlobalContext>\n * ```\n */\nexport function installPortals(options: PortalsOptions): Installer {\n  const {\n    anchorsIds,\n    getEntry,\n    idChahe = currentIdCache,\n    portalsCache = currentPortalsCache,\n  } = options;\n\n  const portals = anchorsSetup(getEntry, anchorsIds, idChahe, portalsCache);\n\n  return () => ({\n    [PORTALS_CONTEXT_KEY]: portals,\n    [PORTAL_ANCHORS_CONTEXT_KEY]: anchorsIds,\n  });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAgB,eAAe,SAAoC;CACjE,MAAM,EACJ,YACA,UACA,UAAUA,eAAAA,gBACV,eAAeC,eAAAA,wBACb;CAEJ,MAAM,WAAA,GAAA,eAAA,aAAA,CAAuB,UAAU,YAAY,SAAS,YAAY;CAExE,cAAc;GACXC,eAAAA,sBAAsB;GACtBC,eAAAA,6BAA6B;CAChC;AACF"}