{"version":3,"file":"ChatViewNavigationContext.mjs","names":[],"sources":["../../../../src/plugins/SlotLayout/ChatViewNavigationContext.tsx"],"sourcesContent":["import React, { createContext, useContext, useMemo } from 'react';\n\nimport { useStateStore } from '../../store';\nimport {\n  createChatViewSlotBinding,\n  getChatViewEntityBinding,\n  useChatViewContext,\n} from './ChatView';\nimport {\n  isPersistentSlotKind,\n  resolveSlotKindView,\n  useSlotRegistry,\n} from './slotRegistry';\n\nimport type { PropsWithChildren } from 'react';\nimport type {\n  LocalMessage,\n  Channel as StreamChannel,\n  StreamChat,\n  Thread as StreamThread,\n} from 'stream-chat';\nimport type {\n  ChatView,\n  ChatViewEntityBinding,\n  ResolveViewActionTargetSlotArgs,\n} from './ChatView';\nimport { getLayoutViewState, useLayoutViewState } from './hooks/useLayoutViewState';\nimport type {\n  ChatViewLayoutState,\n  ChatViewLayoutViewState,\n  LayoutSlotBinding,\n  OpenResult,\n  SlotName,\n} from './layoutController/layoutControllerTypes';\n\ntype ViewSlotRuntime = {\n  activeViewState: ChatViewLayoutViewState;\n  availableSlots: SlotName[];\n  orderedSlots: SlotName[];\n  slotBindings: Record<SlotName, LayoutSlotBinding | undefined>;\n  slotLayers: Record<SlotName, LayoutSlotBinding[] | undefined>;\n};\n\n// Picks the slot for a binding: the requested slot when available, one already holding the same\n// kind, the first free non-persistent slot, the first free slot, then the last non-persistent slot.\n// That last fallback skips persistent (list) slots, so when only persistent slots remain it returns\n// undefined and `open` rejects instead of evicting a list.\nconst resolveDefaultTargetSlot = ({\n  additive,\n  isPersistentSlot,\n  kind,\n  requestedSlot,\n  runtime,\n}: {\n  additive?: boolean;\n  isPersistentSlot: (slot: SlotName) => boolean;\n  kind: ChatViewEntityBinding['kind'];\n  requestedSlot?: SlotName;\n  runtime: ViewSlotRuntime;\n}): SlotName | undefined => {\n  if (requestedSlot && runtime.availableSlots.includes(requestedSlot)) {\n    return requestedSlot;\n  }\n\n  const readSlotKind = (slot: SlotName) =>\n    getChatViewEntityBinding(runtime.slotBindings[slot])?.kind;\n  // A slot is free only with neither a base binding nor a covering layer stack: binding into the\n  // base beneath a layer would render invisibly.\n  const isFree = (slot: SlotName) =>\n    !runtime.slotBindings[slot] && !runtime.slotLayers[slot]?.length;\n  const sameKind = runtime.availableSlots.find((slot) => readSlotKind(slot) === kind);\n  const firstFreeNonPersistent = runtime.availableSlots.find(\n    (slot) => isFree(slot) && !isPersistentSlot(slot),\n  );\n  const firstFree = runtime.availableSlots.find((slot) => isFree(slot));\n  // When every slot is occupied, target the last non-persistent slot rather than the first. Slots\n  // run primary to secondary and the first holds the anchor content (e.g. the main channel), so a\n  // new panel lands on the latest secondary panel rather than on the primary.\n  const lastNonPersistent = [...runtime.availableSlots]\n    .reverse()\n    .find((slot) => !isPersistentSlot(slot));\n\n  // `additive` opens beside existing content (ctrl/⌘-click): skip the same-kind slot, which would\n  // replace what it shows, and prefer a free or secondary slot. A single-slot layout falls\n  // through to that slot, so it opens normally.\n  if (additive) {\n    return firstFreeNonPersistent ?? firstFree ?? lastNonPersistent;\n  }\n\n  return sameKind ?? firstFreeNonPersistent ?? firstFree ?? lastNonPersistent;\n};\n\nexport type OpenThreadTarget =\n  | StreamThread\n  | { channel: StreamChannel; message: LocalMessage };\n\n/**\n * Builds the `thread` binding for a reply thread via `client.threads.ensure()`, ready for `open`.\n *\n * @param client - Client whose thread manager resolves the thread.\n * @param target - Channel and parent message of the thread.\n * @returns The thread entity binding, keyed by the thread ID.\n */\nexport const createThreadEntityBinding = (\n  client: StreamChat,\n  target: { channel: StreamChannel; message: LocalMessage },\n): ChatViewEntityBinding => {\n  // `ensure()` registers a thread it builds, so a thread opened beside another one stays live\n  // even though only the active slot's thread is activated.\n  const thread = client.threads.ensure({\n    channel: target.channel,\n    parentMessage: target.message,\n  });\n  return { key: thread.id ?? undefined, kind: 'thread', source: thread };\n};\n\n/** Options for {@link ChatViewNavigation.open}. */\nexport type ChatViewOpenOptions = {\n  /**\n   * Opens beside existing content instead of replacing it, e.g. ctrl/⌘-click a channel to open a\n   * second one side by side. The resolver skips the slot already holding the same kind and targets\n   * the first free non-persistent slot, then any free slot, then the last non-persistent slot. A\n   * single-slot layout has no secondary slot, so it opens normally. Does not affect slot choice\n   * when `slot` is set.\n   *\n   * @default false\n   */\n  additive?: boolean;\n  /**\n   * Pushes the binding as a layer over the target slot's current content instead of replacing it,\n   * without closing dependent slots; `close`/`popLayer` later reveals what was underneath. Combine\n   * with `additive` to stack onto the secondary slot, e.g. a channel over an open reply thread.\n   * `layer` chooses stack versus replace; `slot` and `additive` choose which slot.\n   *\n   * @default false\n   */\n  layer?: boolean;\n  /**\n   * Slot to bind into. Takes precedence over `additive` and the default kind-based resolution, and\n   * is ignored when the slot is not part of the target view's layout.\n   */\n  slot?: SlotName;\n};\n\nexport type ChatViewNavigation = {\n  /**\n   * Dismisses the top of `slot`: the topmost layer if there is one, otherwise the base binding.\n   * A persistent base binding is never released.\n   */\n  close: (slot: SlotName) => void;\n  /**\n   * Closes `slot` entirely: its base binding and every layer stacked on it. Unlike {@link close}\n   * it does not step back one layer. No-op for empty or persistent slots.\n   */\n  release: (slot: SlotName) => void;\n  /** Hides `slot` without releasing its binding; the subtree stays mounted. */\n  hide: (slot: SlotName) => void;\n  /**\n   * Pushes `binding` as a layer over `slot`'s current content, which stays mounted but hidden. Use\n   * it for transient overlays, e.g. a member profile over a thread. A covered layer keeps its\n   * state, but the base content remounts on the first push and the last pop. Layers are not\n   * serialized.\n   */\n  pushLayer: (slot: SlotName, binding: ChatViewEntityBinding) => void;\n  /** Pops `slot`'s top layer, revealing what is beneath. No-op when there are no layers. */\n  popLayer: (slot: SlotName) => void;\n  /**\n   * Binds `binding` into a resolved target slot, switching to the binding kind's view first (a\n   * `channel` binding activates the channels view). For channel and thread opens without\n   * `options.additive`, a matching `viewActionSlotResolvers` entry picks the slot first; otherwise\n   * slot resolution is, in order:\n   * 1. `options.slot`, if it exists in the target view's layout;\n   * 2. unless `options.additive` is set, the slot already holding this `kind` (replacing it);\n   * 3. the first free non-persistent slot;\n   * 4. the first free slot;\n   * 5. the last non-persistent slot, so a secondary panel is targeted before the primary one.\n   *\n   * On an occupied secondary slot the binding is pushed as a layer over the current content, unless\n   * the slot's base already holds this kind; a channel opened with `additive` is layered even then.\n   *\n   * @param binding - Entity to open.\n   * @param options - See {@link ChatViewOpenOptions}.\n   * @returns An {@link OpenResult}. When no slot resolves, the call is a rejected no-op: no view\n   * switch and no dependent-slot teardown.\n   */\n  open: (binding: ChatViewEntityBinding, options?: ChatViewOpenOptions) => OpenResult;\n  /**\n   * Switches the active view, passing `options.slot` to `layoutController.openView`; the default\n   * `LayoutController` ignores it.\n   */\n  openView: (view: ChatView, options?: { slot?: SlotName }) => void;\n  /** Reveals a previously hidden `slot`. */\n  unhide: (slot: SlotName) => void;\n};\n\nconst chatViewNavigationStateSelector = (state: ChatViewLayoutState) => ({\n  activeView: state.activeView,\n});\n\nconst ChatViewNavigationContext = createContext<ChatViewNavigation>({\n  close: () => undefined,\n  hide: () => undefined,\n  open: () => ({ reason: 'no-available-slot', status: 'rejected' }),\n  openView: () => undefined,\n  popLayer: () => undefined,\n  pushLayer: () => undefined,\n  release: () => undefined,\n  unhide: () => undefined,\n});\n\nexport const useChatViewNavigation = () => useContext(ChatViewNavigationContext);\n\n/** The slot (in the active view) currently holding a binding of `kind`, if any. */\nexport const useSlotForKind = (\n  kind: ChatViewEntityBinding['kind'],\n): SlotName | undefined => {\n  const { availableSlots, slotBindings } = useLayoutViewState();\n  return useMemo(\n    () =>\n      availableSlots.find(\n        (slot) => getChatViewEntityBinding(slotBindings[slot])?.kind === kind,\n      ),\n    [availableSlots, kind, slotBindings],\n  );\n};\n\n/** The slot (in the active view) whose binding carries entity `key`, if any. */\nexport const useSlotForKey = (key?: string): SlotName | undefined => {\n  const { availableSlots, slotBindings } = useLayoutViewState();\n  return useMemo(\n    () =>\n      key === undefined\n        ? undefined\n        : availableSlots.find(\n            (slot) => getChatViewEntityBinding(slotBindings[slot])?.key === key,\n          ),\n    [availableSlots, key, slotBindings],\n  );\n};\n\nexport const ChatViewNavigationProvider = ({ children }: PropsWithChildren) => {\n  const { layoutController, resolveActionTargetSlot } = useChatViewContext();\n  const registry = useSlotRegistry();\n  const { availableSlots, slotBindings, slotLayers } = useLayoutViewState();\n  const { activeView } =\n    useStateStore(layoutController.state, chatViewNavigationStateSelector) ??\n    chatViewNavigationStateSelector(layoutController.state.getLatestValue());\n\n  const value = useMemo<ChatViewNavigation>(() => {\n    const slotKind = (slot: SlotName) =>\n      getChatViewEntityBinding(slotBindings[slot])?.kind;\n\n    const buildRuntimeForView = (view: ChatView): ViewSlotRuntime => {\n      const state = layoutController.state.getLatestValue();\n      const viewState = getLayoutViewState(state, view);\n\n      return {\n        activeViewState: viewState,\n        availableSlots: viewState.availableSlots,\n        orderedSlots: viewState.slotNames?.length\n          ? viewState.slotNames\n          : viewState.availableSlots,\n        slotBindings: viewState.slotBindings,\n        slotLayers: viewState.slotLayers ?? {},\n      };\n    };\n\n    const makeIsPersistentSlot = (runtime: ViewSlotRuntime) => (slot: SlotName) =>\n      isPersistentSlotKind(\n        registry,\n        getChatViewEntityBinding(runtime.slotBindings[slot])?.kind,\n      );\n\n    const materializeTargetSlot = (runtime: ViewSlotRuntime, slot?: SlotName) => {\n      if (!slot) return undefined;\n      if (runtime.availableSlots.includes(slot)) return slot;\n      if (!runtime.orderedSlots.includes(slot)) return undefined;\n\n      const nextAvailableSlots = runtime.orderedSlots.filter(\n        (candidate) => runtime.availableSlots.includes(candidate) || candidate === slot,\n      );\n      layoutController.setAvailableSlots(nextAvailableSlots);\n      return slot;\n    };\n\n    const resolveTargetSlot = ({\n      additive,\n      kind,\n      requestedSlot,\n      runtime,\n      view,\n    }: {\n      additive?: boolean;\n      kind: ChatViewEntityBinding['kind'];\n      requestedSlot?: SlotName;\n      runtime: ViewSlotRuntime;\n      view: ChatView;\n    }) => {\n      // Per-view action resolvers (`viewActionSlotResolvers`) run first for channel and thread\n      // opens. `additive` skips them: the default resolver holds the \"prefer a free or secondary\n      // slot\" logic.\n      const action =\n        !additive && kind === 'channel'\n          ? 'openChannel'\n          : !additive && kind === 'thread'\n            ? 'openThread'\n            : undefined;\n      if (action) {\n        const args: ResolveViewActionTargetSlotArgs = {\n          action,\n          activeView: view,\n          availableSlots: runtime.availableSlots,\n          requestedSlot,\n          slotBindings: runtime.slotBindings,\n          slotNames: runtime.orderedSlots,\n        };\n        const customTargetSlot = resolveActionTargetSlot(view, args);\n        if (customTargetSlot) {\n          const materialized = materializeTargetSlot(runtime, customTargetSlot);\n          if (materialized) return materialized;\n        }\n      }\n\n      return materializeTargetSlot(\n        runtime,\n        resolveDefaultTargetSlot({\n          additive,\n          isPersistentSlot: makeIsPersistentSlot(runtime),\n          kind,\n          requestedSlot,\n          runtime,\n        }),\n      );\n    };\n\n    const openView: ChatViewNavigation['openView'] = (view, options) => {\n      layoutController.openView(view, { slot: options?.slot });\n    };\n\n    // Replacing a channel closes the reply threads opened from it. A thread slot is released, but\n    // content stacked over the thread (a channel opened beside it) stays, its top layer becoming\n    // the slot's base. A reply thread of `replacedChannel` stacked over another panel is popped,\n    // revealing that panel. With a known `replacedChannel`, threads of other channels stay; without\n    // one, every thread slot is released. A thread is matched by `cid`, its conversation.\n    const closeReplyThreads = (replacedChannel?: StreamChannel) => {\n      const isReplyThread = (entity: ReturnType<typeof getChatViewEntityBinding>) =>\n        entity?.kind === 'thread' &&\n        (!replacedChannel || entity.source.channel?.cid === replacedChannel.cid);\n\n      availableSlots.forEach((slot) => {\n        const layers = slotLayers?.[slot] ?? [];\n        const top = layers[layers.length - 1];\n        if (replacedChannel && isReplyThread(getChatViewEntityBinding(top))) {\n          layoutController.popLayer(slot);\n          return;\n        }\n        if (!isReplyThread(getChatViewEntityBinding(slotBindings[slot]))) return;\n        if (!top) {\n          layoutController.release(slot);\n          return;\n        }\n        layoutController.bind(slot, top);\n        layoutController.popLayer(slot);\n      });\n    };\n\n    const open: ChatViewNavigation['open'] = (binding, options) => {\n      // Resolve the target slot before any mutation, so a rejected open is a no-op: no view switch\n      // and no dependent-slot teardown.\n      const kindView = resolveSlotKindView(registry, binding.kind);\n      const targetView = kindView ?? activeView;\n      const runtime = buildRuntimeForView(targetView);\n      const targetSlot = resolveTargetSlot({\n        additive: options?.additive,\n        kind: binding.kind,\n        requestedSlot: options?.slot,\n        runtime,\n        view: targetView,\n      });\n\n      if (!targetSlot) {\n        return { reason: 'no-available-slot', status: 'rejected' };\n      }\n\n      // Kinds that declare a target view switch to it on open (e.g. channel ->\n      // channels); view-agnostic kinds (thread) open in the active view.\n      if (kindView) openView(targetView, options);\n\n      // Push a layer when `options.layer` asks for it, or when the target is an occupied secondary\n      // slot (a base binding or a covering layer) and this is not a same-kind replace. Otherwise\n      // the primary slot (first non-persistent) base-binds, so selecting a channel replaces it and\n      // single-slot layouts do not layer. A same-kind base (thread over thread in its own slot)\n      // replaces too, except a channel opened beside another (`additive`), which stacks so that\n      // stepping back returns to the previous channel.\n      const isPersistentSlot = makeIsPersistentSlot(runtime);\n      const anchorSlot = runtime.availableSlots.find((slot) => !isPersistentSlot(slot));\n      const targetBase = runtime.slotBindings[targetSlot];\n      const targetBaseKind = getChatViewEntityBinding(targetBase)?.kind;\n      const targetOccupied = !!targetBase || !!runtime.slotLayers[targetSlot]?.length;\n      const isSecondaryTarget = targetSlot !== anchorSlot;\n      // Opening beside what the target slot already shows on top changes nothing. Anything else (a\n      // channel lower in its stack, or open in another slot) is stacked on top so it is shown.\n      const shownInTarget = getChatViewEntityBinding(\n        runtime.slotLayers[targetSlot]?.at(-1) ?? targetBase,\n      );\n      if (\n        options?.additive &&\n        isSecondaryTarget &&\n        binding.key !== undefined &&\n        shownInTarget?.key === binding.key\n      ) {\n        return { slot: targetSlot, status: 'opened' };\n      }\n      const stacksBesideSameKind = !!options?.additive && binding.kind === 'channel';\n      const sameKindBaseReplace =\n        !!targetBase && targetBaseKind === binding.kind && !stacksBesideSameKind;\n\n      if (\n        options?.layer ||\n        (isSecondaryTarget && targetOccupied && !sameKindBaseReplace)\n      ) {\n        layoutController.pushLayer(targetSlot, createChatViewSlotBinding(binding));\n        return { slot: targetSlot, status: 'layered' };\n      }\n\n      // Replacing a channel closes the threads bound to the previous one. Layered opens returned\n      // above and skip this.\n      if (binding.kind === 'channel') {\n        const replaced = getChatViewEntityBinding(targetBase);\n        closeReplyThreads(replaced?.kind === 'channel' ? replaced.source : undefined);\n      }\n\n      return layoutController.openInLayout(createChatViewSlotBinding(binding), {\n        targetSlot,\n      });\n    };\n\n    const close: ChatViewNavigation['close'] = (slot) => {\n      if (!availableSlots.includes(slot)) return;\n      // Layers dismiss top-down: pop the topmost layer first and only release the base binding\n      // once no layers remain.\n      if (slotLayers?.[slot]?.length) {\n        layoutController.popLayer(slot);\n        return;\n      }\n      // Persistent kinds (nav-rail lists) are hide-only; close never releases them.\n      if (isPersistentSlotKind(registry, slotKind(slot))) return;\n      layoutController.release(slot);\n    };\n\n    const release: ChatViewNavigation['release'] = (slot) => {\n      if (!availableSlots.includes(slot)) return;\n      if (isPersistentSlotKind(registry, slotKind(slot))) return;\n      layoutController.release(slot);\n    };\n\n    const hide: ChatViewNavigation['hide'] = (slot) => {\n      if (availableSlots.includes(slot)) layoutController.hide(slot);\n    };\n\n    const pushLayer: ChatViewNavigation['pushLayer'] = (slot, binding) => {\n      if (!availableSlots.includes(slot)) return;\n      layoutController.pushLayer(slot, createChatViewSlotBinding(binding));\n    };\n\n    const popLayer: ChatViewNavigation['popLayer'] = (slot) => {\n      if (availableSlots.includes(slot)) layoutController.popLayer(slot);\n    };\n\n    const unhide: ChatViewNavigation['unhide'] = (slot) => {\n      if (availableSlots.includes(slot)) layoutController.unhide(slot);\n    };\n\n    return { close, hide, open, openView, popLayer, pushLayer, release, unhide };\n  }, [\n    activeView,\n    availableSlots,\n    layoutController,\n    registry,\n    resolveActionTargetSlot,\n    slotBindings,\n    slotLayers,\n  ]);\n\n  return (\n    <ChatViewNavigationContext.Provider value={value}>\n      {children}\n    </ChatView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