{"version":3,"names":["createUniqueId","useContext","readOption","Menu","MenuRootContext","createContextMenu","ContextMenuRootContext","ContextMenuRoot","props","parentContextMenu","nestedInsideContextMenu","contextMenuPrimitive","open","defaultOpen","disabled","onOpenChange","next","details","anchor","setAnchor","actionsRef","current","positionerRef","backdropRef","internalBackdropRef","allowMouseUpTriggerRef","initialCursorPointRef","rootId","contextValue","loopFocus","highlightItemOnHover","setOpen","onOpenChangeComplete","orientation","children"],"sources":["context-menu-root.tsx"],"sourcesContent":["import type { JSX } from \"@solidjs/web\";\n/**\n * `<ContextMenu.Root>` — Solid 2 port of Base UI React's `ContextMenuRoot`.\n *\n * React source: `packages/react/src/context-menu/root/ContextMenuRoot.tsx`.\n *\n * A thin wrapper around `<Menu.Root>` that supplies the virtual-anchor\n * plumbing: the trigger captures `(clientX, clientY)` on `contextmenu` (or\n * long press) and writes a `VirtualElement` into the root's `anchor` signal.\n * `<Menu.Root>` detects the parent `ContextMenuRootContext`, reads the\n * anchor, threads it into the floating-root context, and exposes an\n * imperative `setOpen` via `actionsRef` so the trigger can open the menu.\n *\n * Renders no DOM of its own — pure context provider chained around\n * `<Menu.Root>`.\n *\n * ### Port deviations\n *\n *  - Nested `<ContextMenu.Root>` is detected via an optional outer\n *    `ContextMenuRootContext` read; the inner root exposes\n *    `nestedInsideContextMenu` so the inner `<Menu.Root>` routes its\n *    parent-type to `'nested-context-menu'`.\n *  - Long-press touch gesture is ported (matches React's 500ms delay +\n *    10px move threshold) with unit coverage for the timer state\n *    machine + move-threshold cancellation. Full `pointercancel` path\n *    needs browser coverage.\n */\n\nimport { createUniqueId, useContext } from \"solid-js\";\nimport type { MutableRef } from \"../../internals/floating-ui/types\";\nimport { type MaybeAccessor, readOption } from \"../../internals/maybe-accessor\";\nimport { Menu } from \"../../menu\";\nimport type {\n\tMenuRootChangeEventDetails,\n\tMenuRootChangeEventReason,\n} from \"../../menu/root/menu-root-context\";\nimport { MenuRootContext } from \"../../menu/root/menu-root-context\";\nimport { createContextMenu } from \"../create-context-menu\";\nimport {\n\tContextMenuRootContext,\n\ttype ContextMenuRootContextValue,\n} from \"./context-menu-root-context\";\n\nexport type ContextMenuRootChangeEventReason = MenuRootChangeEventReason;\nexport type ContextMenuRootChangeEventDetails = MenuRootChangeEventDetails;\nexport type ContextMenuRootState = Record<string, never>;\n\n// biome-ignore lint/correctness/noUnusedVariables: Payload is part of the public generic surface (parity with <Menu.Root<Payload>>).\nexport interface ContextMenuRootProps<Payload = unknown> {\n\t/**\n\t * Controlled open state. When provided (resolved value not\n\t * `undefined`), the consumer owns the state — pair with\n\t * {@link onOpenChange}. When omitted, the context menu manages its own\n\t * open state (seeded from {@link defaultOpen}) and the right-click /\n\t * long-press gesture opens it with zero wiring.\n\t */\n\topen?: MaybeAccessor<boolean | undefined>;\n\t/**\n\t * Initial open state when uncontrolled. Read once at mount.\n\t * @default false\n\t */\n\tdefaultOpen?: MaybeAccessor<boolean | undefined>;\n\t/** Whether arrow keys loop at the ends. @default true */\n\tloopFocus?: boolean | undefined;\n\t/** Highlight items on hover. @default true */\n\thighlightItemOnHover?: boolean | undefined;\n\t/** Called when the menu opens or closes. */\n\tonOpenChange?:\n\t\t| ((open: boolean, eventDetails: ContextMenuRootChangeEventDetails) => void)\n\t\t| undefined;\n\t/** Called after any animations complete when the menu is closed. */\n\tonOpenChangeComplete?: ((open: boolean) => void) | undefined;\n\t/** Whether the menu ignores user interaction. @default false */\n\tdisabled?: MaybeAccessor<boolean | undefined>;\n\t/** Visual/keyboard orientation. @default \"vertical\" */\n\torientation?: \"horizontal\" | \"vertical\" | undefined;\n\t/**\n\t * Children. May be a regular node or a render function that receives the\n\t * active trigger's payload.\n\t */\n\tchildren?: JSX.Element;\n}\n\n/**\n * Creates a context menu activated by right-click or long-press.\n * Doesn't render its own HTML element — pure context provider chained\n * around `<Menu.Root>`.\n */\nexport function ContextMenuRoot<Payload = unknown>(\n\tprops: ContextMenuRootProps<Payload>,\n): JSX.Element {\n\t// Detect when this `<ContextMenu.Root>` is itself nested\n\t// inside another `<ContextMenu.Root>`. The inner root still owns its\n\t// own anchor + actionsRef; the flag is read downstream by the inner\n\t// `<Menu.Root>` to route its parent-type to `'nested-context-menu'`.\n\tconst parentContextMenu = useContext(ContextMenuRootContext);\n\tconst nestedInsideContextMenu = parentContextMenu != null;\n\n\t// Compose the headless ContextMenu primitive — owns open (gesture-driven\n\t// internal signal + consumer override), disabled, and anchor. The wrapper\n\t// layers virtual-anchor threading, actionsRef wiring, and context provision.\n\tconst contextMenuPrimitive = createContextMenu({\n\t\topen: () => readOption(props.open),\n\t\tdefaultOpen: () => readOption(props.defaultOpen),\n\t\tdisabled: () => readOption(props.disabled) ?? false,\n\t\tonOpenChange: (next, details) => {\n\t\t\tprops.onOpenChange?.(next, details);\n\t\t},\n\t});\n\n\tconst open = contextMenuPrimitive.open;\n\tconst anchor = contextMenuPrimitive.anchor;\n\tconst setAnchor = contextMenuPrimitive.setAnchor;\n\n\tconst actionsRef: MutableRef<{\n\t\tsetOpen: (\n\t\t\tnextOpen: boolean,\n\t\t\teventDetails: MenuRootChangeEventDetails,\n\t\t) => void;\n\t} | null> = { current: null };\n\tconst positionerRef: MutableRef<HTMLElement | null> = { current: null };\n\tconst backdropRef: MutableRef<HTMLDivElement | null> = { current: null };\n\tconst internalBackdropRef: MutableRef<HTMLDivElement | null> = {\n\t\tcurrent: null,\n\t};\n\tconst allowMouseUpTriggerRef: MutableRef<boolean> = { current: true };\n\tconst initialCursorPointRef: MutableRef<{ x: number; y: number } | null> = {\n\t\tcurrent: null,\n\t};\n\tconst rootId = createUniqueId();\n\n\tconst contextValue: ContextMenuRootContextValue = {\n\t\tanchor,\n\t\tsetAnchor,\n\t\tactionsRef,\n\t\tbackdropRef,\n\t\tinternalBackdropRef,\n\t\tpositionerRef,\n\t\tallowMouseUpTriggerRef,\n\t\tinitialCursorPointRef,\n\t\trootId,\n\t\tnestedInsideContextMenu,\n\t};\n\n\t// Chain the providers around `<Menu.Root>`. Per P4, evaluating children\n\t// eagerly at parent JSX would mask the ContextMenu context from the\n\t// inner `<Menu.Root>`'s own render — but here the provider IS the\n\t// parent, and `<Menu.Root>` evaluates within this tree, so the\n\t// straightforward `<Provider>{children}</Provider>` shape is safe.\n\t//\n\t// The inner `<MenuRootContext value={null}>` is React-parity: it\n\t// prevents a nested `<Menu.Root>` from inheriting an outer menu's\n\t// context when `<ContextMenu.Root>` itself is mounted inside another\n\t// menu. This is what lets `<Menu.Root>` identify the context-menu\n\t// parent by reading \"no menu parent but yes context-menu parent\".\n\treturn (\n\t\t<ContextMenuRootContext value={contextValue}>\n\t\t\t<MenuRootContext value={null}>\n\t\t\t\t<Menu.Root<Payload>\n\t\t\t\t\tloopFocus={props.loopFocus}\n\t\t\t\t\thighlightItemOnHover={props.highlightItemOnHover}\n\t\t\t\t\tonOpenChange={(next, details) => {\n\t\t\t\t\t\t// Route through the primitive so the gesture-driven internal\n\t\t\t\t\t\t// open signal stays in sync and onOpenChange fires once.\n\t\t\t\t\t\tcontextMenuPrimitive.setOpen(next, details);\n\t\t\t\t\t}}\n\t\t\t\t\tonOpenChangeComplete={props.onOpenChangeComplete}\n\t\t\t\t\topen={open()}\n\t\t\t\t\tdisabled={readOption(props.disabled)}\n\t\t\t\t\torientation={props.orientation}\n\t\t\t\t\tmodal\n\t\t\t\t>\n\t\t\t\t\t{props.children}\n\t\t\t\t</Menu.Root>\n\t\t\t</MenuRootContext>\n\t\t</ContextMenuRootContext>\n\t);\n}\n"],"mappings":"AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,cAAc,EAAEC,UAAU,QAAQ,UAAU;AAErD,SAA6BC,UAAU,QAAQ,gCAAgC;AAC/E,SAASC,IAAI,QAAQ,YAAY;AAKjC,SAASC,eAAe,QAAQ,mCAAmC;AACnE,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1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