// Slot mechanics for the binding's plain-`.ts` hooks. Octane injects a // per-call-site Symbol into calls made by compiled components; the binding // forwards that symbol and derives a distinct sub-slot for each hook it // composes. const subSlotCache = new Map>() const bareTagCache = new Map() export function subSlot(slot: symbol | undefined, tag: string): symbol { if (slot === undefined) { let bare = bareTagCache.get(tag) if (bare === undefined) { bare = Symbol.for(`@tanstack/octane-store:${tag}`) bareTagCache.set(tag, bare) } return bare } let byTag = subSlotCache.get(slot) if (byTag === undefined) { byTag = new Map() subSlotCache.set(slot, byTag) } let child = byTag.get(tag) if (child === undefined) { child = Symbol.for(`${slot.description ?? ''}:${tag}`) byTag.set(tag, child) } return child } export function splitSlot( args: Array, ): [Array, symbol | undefined] { const tail = args[args.length - 1] const slot = typeof tail === 'symbol' ? tail : undefined return [slot === undefined ? args : args.slice(0, -1), slot] }