{"version":3,"names":["createChangeEventDetails","REASONS","PopupTriggerMap","PopoverStore","_setOpen","_open","constructor","context","triggerElements","attachSetOpen","fn","setOpenMirror","next","setOpen","details","isOpen","PopoverHandle","store","open","triggerId","triggerElement","getById","Error","imperativeAction","undefined","close","createPopoverHandle"],"sources":["popover-store.ts"],"sourcesContent":["/**\n * PopoverStore — thin Solid 2 port of Base UI React's `PopoverStore`\n * (`packages/react/src/popover/store/PopoverStore.ts`).\n *\n * The React store carries the full popover state machine (open, modal,\n * mounted, transition, floating root context, trigger map, title id,\n * description id, stick-if-open timer, nested flag, etc.) and exposes it\n * through a selector API consumed by every sub-part. The Solid port uses\n * the `<Popover.Root>`'s local signals as the source of truth for\n * open/mount/transition-status; this store is a _thin_ imperative-API\n * wrapper that multiplies the minimal subset the handle exposes\n * (`open` / `close` / `isOpen` / trigger registry).\n *\n * Concretely:\n *\n *  - Holds a `PopupTriggerMap` so `<Popover.Trigger id=\"...\">` can register\n *    itself and `PopoverHandle.open(id)` can resolve the correct trigger.\n *  - Holds the current `activeTriggerId` / `activeTriggerElement` so the\n *    implicit-active-trigger logic behaves across multi-trigger setups.\n *  - Exposes `setOpen(next, details)` which is the writer the `<Popover.Root>`\n *    binds via `actionsRef` / `PopoverHandle`.\n */\n\nimport {\n\tcreateChangeEventDetails,\n\tREASONS,\n} from \"../../internals/change-event-details\";\nimport { PopupTriggerMap } from \"../../internals/floating-ui/popup-trigger-map\";\nimport type {\n\tPopoverRootChangeEventDetails,\n\tPopoverRootChangeEventReason,\n} from \"../popover-root-context\";\n\n/**\n * Writer signature for `setOpen`. Matches the Solid root's internal\n * `setOpen(next, details)` callback.\n */\nexport type PopoverStoreSetOpen = (\n\tnext: boolean,\n\tdetails: PopoverRootChangeEventDetails,\n) => void;\n\n/**\n * Minimal store shape consumed by the handle + imperative callers.\n *\n * Matches how the React source's `PopoverStore` is consumed — only\n * `.context.triggerElements` and `.setOpen` are read externally through\n * the handle.\n */\nexport class PopoverStore<_Payload = unknown> {\n\t/**\n\t * Registry of triggers keyed by id. `<Popover.Trigger id={...}>` adds\n\t * itself here on mount, and `PopoverHandle.open(id)` /\n\t * the implicit-active-trigger logic looks up elements out of it.\n\t */\n\tpublic readonly context: { triggerElements: PopupTriggerMap };\n\n\t/**\n\t * Internal setOpen slot. `<Popover.Root>` binds this during setup via\n\t * {@link attachSetOpen} so the handle's `open()` / `close()` calls\n\t * reach the root's writer.\n\t */\n\tprivate _setOpen: PopoverStoreSetOpen | null = null;\n\n\t/**\n\t * Last-seen reactive open flag. Used by `PopoverHandle.isOpen` so the\n\t * caller can read synchronously without needing a subscription hook.\n\t */\n\tprivate _open = false;\n\n\tconstructor() {\n\t\tthis.context = {\n\t\t\ttriggerElements: new PopupTriggerMap(),\n\t\t};\n\t}\n\n\t/**\n\t * Bind the root's `setOpen` writer. Called by `<Popover.Root>` during\n\t * setup; clears on teardown.\n\t *\n\t * @internal\n\t */\n\tattachSetOpen(fn: PopoverStoreSetOpen | null): void {\n\t\tthis._setOpen = fn;\n\t}\n\n\t/**\n\t * Mirror the root's current open flag. Called by `<Popover.Root>`'s\n\t * effect so `handle.isOpen` returns the latest value synchronously.\n\t *\n\t * @internal\n\t */\n\tsetOpenMirror(next: boolean): void {\n\t\tthis._open = next;\n\t}\n\n\t/**\n\t * Imperative open-state writer. Mirrors React's `PopoverStore.setOpen`.\n\t *\n\t * If the root is not currently mounted (handle was constructed but\n\t * never used inside a live `<Popover.Root>`), this is a no-op.\n\t */\n\tsetOpen(next: boolean, details: PopoverRootChangeEventDetails): void {\n\t\tthis._setOpen?.(next, details);\n\t}\n\n\t/**\n\t * Synchronous snapshot of the current open state — does NOT subscribe\n\t * to Solid's reactive graph. For reactive reads, consumers use the\n\t * root context's `open()` accessor.\n\t */\n\tget isOpen(): boolean {\n\t\treturn this._open;\n\t}\n}\n\n/**\n * `PopoverHandle` — imperative + cross-root trigger-association surface.\n * Matches Base UI React's `PopoverHandle` 1:1 on the public methods\n * (`open(triggerId)` / `close()` / `isOpen`) and carries an internal\n * store reference that `<Popover.Root handle={...}>` adopts.\n */\nexport class PopoverHandle<Payload = unknown> {\n\t/**\n\t * Internal store holding the popover's state.\n\t * @internal\n\t */\n\tpublic readonly store: PopoverStore<Payload>;\n\n\tconstructor() {\n\t\tthis.store = new PopoverStore<Payload>();\n\t}\n\n\t/**\n\t * Opens the popover, associating it with the trigger registered under\n\t * `triggerId`. Throws if no trigger with that id is registered.\n\t */\n\topen(triggerId: string): void {\n\t\tconst triggerElement = this.store.context.triggerElements.getById(\n\t\t\ttriggerId,\n\t\t) as HTMLElement | undefined;\n\n\t\tif (!triggerElement) {\n\t\t\tthrow new Error(\n\t\t\t\t`Base UI: PopoverHandle.open: No trigger found with id \"${triggerId}\".`,\n\t\t\t);\n\t\t}\n\n\t\tthis.store.setOpen(\n\t\t\ttrue,\n\t\t\tcreateChangeEventDetails<PopoverRootChangeEventReason>(\n\t\t\t\tREASONS.imperativeAction as PopoverRootChangeEventReason,\n\t\t\t\tundefined,\n\t\t\t\ttriggerElement,\n\t\t\t) as PopoverRootChangeEventDetails,\n\t\t);\n\t}\n\n\t/**\n\t * Closes the popover.\n\t */\n\tclose(): void {\n\t\tthis.store.setOpen(\n\t\t\tfalse,\n\t\t\tcreateChangeEventDetails<PopoverRootChangeEventReason>(\n\t\t\t\tREASONS.imperativeAction as PopoverRootChangeEventReason,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t) as PopoverRootChangeEventDetails,\n\t\t);\n\t}\n\n\t/**\n\t * Whether the popover is currently open. Synchronous — mirrors the\n\t * root's most recent open-state write.\n\t */\n\tget isOpen(): boolean {\n\t\treturn this.store.isOpen;\n\t}\n}\n\n/**\n * Factory for `PopoverHandle` — matches React's `createPopoverHandle()`.\n */\nexport function createPopoverHandle<\n\tPayload = unknown,\n>(): PopoverHandle<Payload> {\n\treturn new PopoverHandle<Payload>();\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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