{"version":3,"names":["createContext","useContext","ContextMenuRootContext","useContextMenuRootContext","optional","ctx","Error"],"sources":["context-menu-root-context.ts"],"sourcesContent":["/**\n * Context plumbing for `<ContextMenu.Root>` → `<Menu.Root>` and\n * `<ContextMenu.Trigger>`. Mirrors React's\n * `packages/react/src/context-menu/root/ContextMenuRootContext.ts`.\n *\n * The ContextMenu compound is a thin wrapper around `<Menu.Root>`: it\n * captures a `(clientX, clientY)` point on `contextmenu` (or long press),\n * threads a virtual anchor into the inner menu's floating-root context,\n * and calls `setOpen(true, …)` via an `actionsRef` populated by\n * `<Menu.Root>` once it detects the outer context-menu.\n *\n * Null-sentinel context (solidify P5) — `<ContextMenu.Trigger>`\n * requires the provider, but `<Menu.Root>` optionally reads it to detect\n * the context-menu interop path and tolerates `null`.\n */\nimport { type Accessor, createContext, useContext } from \"solid-js\";\nimport type { MutableRef } from \"../../internals/floating-ui/types\";\nimport type { MenuRootChangeEventDetails } from \"../../menu/root/menu-root-context\";\n\n/**\n * A virtual anchor element Floating UI can position against. Mirrors React's\n * `ContextMenuRootContext['anchor']` shape.\n */\nexport interface ContextMenuAnchor {\n\tgetBoundingClientRect: () => DOMRect;\n\tcontextElement?: Element;\n}\n\nexport interface ContextMenuRootContextValue {\n\t/** Current anchor element (virtual or real — usually virtual). */\n\tanchor: Accessor<ContextMenuAnchor>;\n\t/** Setter for the anchor — called by `<ContextMenu.Trigger>` on contextmenu/long-press. */\n\tsetAnchor: (anchor: ContextMenuAnchor) => void;\n\n\t/**\n\t * Populated by `<Menu.Root>` once it detects the context-menu parent.\n\t * The trigger calls `setOpen` to open the menu after updating the anchor.\n\t */\n\tactionsRef: MutableRef<{\n\t\tsetOpen: (\n\t\t\tnextOpen: boolean,\n\t\t\teventDetails: MenuRootChangeEventDetails,\n\t\t) => void;\n\t} | null>;\n\n\t/** Populated by `<Menu.Root>` from the inner positioner element. */\n\tpositionerRef: MutableRef<HTMLElement | null>;\n\t/** Populated when `<Menu.Backdrop>` mounts. */\n\tbackdropRef: MutableRef<HTMLDivElement | null>;\n\t/** Populated when an internal (modal-gating) backdrop mounts. */\n\tinternalBackdropRef: MutableRef<HTMLDivElement | null>;\n\n\t/**\n\t * Whether the trigger's pending mouseup can still open the menu\n\t * (long-press window). Shared with `<Menu.Root>` for outside-press dismissal.\n\t */\n\tallowMouseUpTriggerRef: MutableRef<boolean>;\n\t/** Point captured at contextmenu — retained across the open for inset positioning. */\n\tinitialCursorPointRef: MutableRef<{ x: number; y: number } | null>;\n\n\t/** Unique id for this context-menu root. Used by menu popup to tag `data-rootownerid`. */\n\trootId: string | undefined;\n\n\t/**\n\t * Whether this `<ContextMenu.Root>` is itself nested inside another\n\t * `<ContextMenu.Root>`. Matches React's `'nested-context-menu'`\n\t * parent-type gate (inner menu's `<Menu.Root>` reads this to route\n\t * dismissal / open-behavior like a regular submenu).\n\t */\n\tnestedInsideContextMenu: boolean;\n}\n\nexport const ContextMenuRootContext =\n\tcreateContext<ContextMenuRootContextValue | null>(null);\n\nexport function useContextMenuRootContext(): ContextMenuRootContextValue;\nexport function useContextMenuRootContext(\n\toptional: true,\n): ContextMenuRootContextValue | null;\nexport function useContextMenuRootContext(\n\toptional?: boolean,\n): ContextMenuRootContextValue | null {\n\tconst ctx = useContext(ContextMenuRootContext);\n\tif (ctx == null && !optional) {\n\t\tthrow new Error(\n\t\t\t\"Base UI: ContextMenuRootContext is missing. ContextMenu parts must be placed within <ContextMenu.Root>.\",\n\t\t);\n\t}\n\treturn ctx;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAwBA,aAAa,EAAEC,UAAU,QAAQ,UAAU;;AAInE;AACA;AACA;AACA;;AAkDA,OAAO,MAAMC,sBAAsB,GAClCF,aAAa,CAAqC,IAAI,CAAC;AAMxD,OAAO,SAASG,yBAAyBA,CACxCC,QAAkB,EACmB;EACrC,MAAMC,GAAG,GAAGJ,UAAU,CAACC,sBAAsB,CAAC;EAC9C,IAAIG,GAAG,IAAI,IAAI,IAAI,CAACD,QAAQ,EAAE;IAC7B,MAAM,IAAIE,KAAK,CACd,yGACD,CAAC;EACF;EACA,OAAOD,GAAG;AACX","ignoreList":[]}