@cfxjs/sirius-next-common 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2112,7 +2112,7 @@ var Popover2 = ({
2112
2112
  ...rest,
2113
2113
  positioning: {
2114
2114
  ...positioning,
2115
- placement
2115
+ placement: placement === "auto" ? void 0 : placement
2116
2116
  },
2117
2117
  arrow,
2118
2118
  children: ({ contentProps }) => {
@@ -2146,4 +2146,4 @@ focus-trap/dist/focus-trap.esm.js:
2146
2146
  * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
2147
2147
  *)
2148
2148
  */
2149
- //# sourceMappingURL=chunk-3PF5QYAQ.js.map
2149
+ //# sourceMappingURL=chunk-WOX3LUVT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Popover/index.tsx","../../../node_modules/.pnpm/@cfx-kit+ui-components@0.0.18_@zag-js+accordion@0.19.1_@zag-js+checkbox@0.19.1_@zag-js+dialog_toqhwacqm4ck723ovqekq5mm7u/node_modules/@cfx-kit/ui-components/dist/Popover.js","../../../node_modules/.pnpm/@zag-js+tabbable@0.19.1/node_modules/@zag-js/tabbable/src/proxy-tab-focus.ts","../../../node_modules/.pnpm/@zag-js+tabbable@0.19.1/node_modules/@zag-js/tabbable/src/shared.ts","../../../node_modules/.pnpm/@zag-js+tabbable@0.19.1/node_modules/@zag-js/tabbable/src/focusable.ts","../../../node_modules/.pnpm/@zag-js+tabbable@0.19.1/node_modules/@zag-js/tabbable/src/tabbable.ts","../../../node_modules/.pnpm/@zag-js+aria-hidden@0.19.1/node_modules/@zag-js/aria-hidden/src/index.ts","../../../node_modules/.pnpm/@zag-js+interact-outside@0.19.1/node_modules/@zag-js/interact-outside/src/index.ts","../../../node_modules/.pnpm/@zag-js+interact-outside@0.19.1/node_modules/@zag-js/interact-outside/src/get-window-frames.ts","../../../node_modules/.pnpm/@zag-js+dismissable@0.19.1/node_modules/@zag-js/dismissable/src/dismissable-layer.ts","../../../node_modules/.pnpm/@zag-js+dismissable@0.19.1/node_modules/@zag-js/dismissable/src/escape-keydown.ts","../../../node_modules/.pnpm/@zag-js+dismissable@0.19.1/node_modules/@zag-js/dismissable/src/layer-stack.ts","../../../node_modules/.pnpm/@zag-js+dismissable@0.19.1/node_modules/@zag-js/dismissable/src/pointer-event-outside.ts","../../../node_modules/.pnpm/@zag-js+remove-scroll@0.19.1/node_modules/@zag-js/remove-scroll/src/index.ts","../../../node_modules/.pnpm/tabbable@6.2.0/node_modules/tabbable/src/index.js","../../../node_modules/.pnpm/focus-trap@7.5.2/node_modules/focus-trap/index.js","../../../node_modules/.pnpm/@zag-js+popover@0.19.1/node_modules/@zag-js/popover/src/popover.anatomy.ts","../../../node_modules/.pnpm/@zag-js+popover@0.19.1/node_modules/@zag-js/popover/src/popover.connect.ts","../../../node_modules/.pnpm/@zag-js+popover@0.19.1/node_modules/@zag-js/popover/src/popover.dom.ts","../../../node_modules/.pnpm/@zag-js+popover@0.19.1/node_modules/@zag-js/popover/src/popover.machine.ts"],"sourcesContent":["import React, { HTMLAttributes, ComponentProps, useRef } from 'react';\nimport _Popover, {\n PositioningOptions,\n} from '@cfx-kit/ui-components/dist/Popover';\nimport clsx from 'clsx';\nimport { cn } from 'src/utils';\n\nexport type PopoverProps = Omit<\n ComponentProps<typeof _Popover>,\n 'trigger' | 'positioning'\n> & {\n containerClassName?: string;\n content?: React.ReactNode;\n children?: React.ReactNode;\n triggerProps?: HTMLAttributes<HTMLElement>;\n className?: string;\n positioning?: Omit<PositioningOptions, 'placement'> & {\n placement?: PositioningOptions['placement'] | 'auto';\n };\n};\n\nexport const Popover: React.FC<PopoverProps> = ({\n content,\n children = null,\n positioning = {},\n className,\n containerClassName,\n arrow = true,\n ...rest\n}) => {\n const { placement = 'top' } = positioning;\n const triggerRef = useRef<HTMLSpanElement>(null);\n return (\n <_Popover\n trigger={({ triggerProps }) => {\n return (\n <span\n ref={triggerRef}\n {...(content ? triggerProps : {})}\n className={cn(\n 'sirius-popover-trigger',\n className,\n triggerProps.className,\n )}\n >\n {children}\n </span>\n );\n }}\n containerClassName={clsx(\n 'sirius-popover-container',\n 'text-#333 text-14px lh-[1.5715] font-400 ws-normal cursor-auto text-left select-text absolute top-0 left-0 z-1030 text-transform-none filter-drop-shadow',\n '[&>[data-part=arrow]]:[--arrow-size:12px] [&>[data-part=arrow]]:[--arrow-background:#fff] [&>[data-part=arrow]]:[--arrow-shadow-color:gray]',\n containerClassName,\n )}\n {...rest}\n positioning={{\n ...positioning,\n placement: placement === 'auto' ? undefined : placement,\n }}\n arrow={arrow}\n >\n {({ contentProps }) => {\n return (\n <div\n className=\"sirius-popover-content px-12px py-16px shadow decoration-none rounded-5px bg-#fff bg-clip-padding\"\n {...contentProps}\n >\n {content}\n </div>\n );\n }}\n </_Popover>\n );\n};\n","import {\n __objRest,\n __spreadProps,\n __spreadValues\n} from \"./chunk-W7QWXYJO.js\";\n\n// src/Popover/index.tsx\nimport { useEffect, useMemo, useId, isValidElement, cloneElement, Children, Fragment } from \"react\";\nimport { machine, connect } from \"@zag-js/popover\";\nimport { useMachine, normalizeProps, Portal } from \"@zag-js/react\";\nimport { Fragment as Fragment2, jsx, jsxs } from \"react/jsx-runtime\";\nvar Popover = (_a) => {\n var _b = _a, {\n id,\n open,\n closeOnEsc = true,\n closeOnInteractOutside = true,\n arrow = false,\n children,\n containerClassName,\n trigger\n } = _b, props = __objRest(_b, [\n \"id\",\n \"open\",\n \"closeOnEsc\",\n \"closeOnInteractOutside\",\n \"arrow\",\n \"children\",\n \"containerClassName\",\n \"trigger\"\n ]);\n const uniqueId = useId();\n const [state, send] = useMachine(machine(__spreadValues({ id: id != null ? id : uniqueId, closeOnEsc, closeOnInteractOutside }, props)));\n const api = connect(state, send, normalizeProps);\n const Wrapper = useMemo(() => api.portalled ? Portal : Fragment, [api.portalled]);\n useEffect(() => {\n if (open === true) {\n api.open();\n } else {\n api.close();\n }\n }, [open]);\n return /* @__PURE__ */ jsxs(Fragment2, { children: [\n typeof trigger === \"function\" ? trigger({ triggerProps: api.triggerProps, isOpen: api.isOpen }) : null,\n api.isOpen && /* @__PURE__ */ jsx(Wrapper, { children: /* @__PURE__ */ jsxs(\"div\", __spreadProps(__spreadValues({ className: `ui-popover${containerClassName ? ` ${containerClassName}` : \"\"}` }, api.positionerProps), { children: [\n arrow && /* @__PURE__ */ jsx(\"div\", __spreadProps(__spreadValues({}, api.arrowProps), { children: /* @__PURE__ */ jsx(\"div\", __spreadValues({}, api.arrowTipProps)) })),\n typeof children === \"function\" && children({ contentProps: api.contentProps, closeTriggerProps: api.closeTriggerProps, close: api.close }),\n typeof children !== \"function\" ? Children.count(children) === 1 && isValidElement(children) ? cloneElement(children, __spreadValues({}, api.contentProps)) : /* @__PURE__ */ jsx(\"div\", __spreadProps(__spreadValues({}, api.contentProps), { children })) : null\n ] })) })\n ] });\n};\nvar Popover_default = Popover;\nexport {\n Popover_default as default\n};\n","import { raf } from \"@zag-js/dom-query\"\nimport { getNextTabbable, getTabbableEdges } from \"./tabbable\"\n\ntype MaybeElement = HTMLElement | null\ntype NodeOrFn = MaybeElement | (() => MaybeElement)\n\ntype ProxyTabFocusOptions<T = MaybeElement> = {\n triggerElement?: T\n onFocus?: (elementToFocus: HTMLElement) => void\n defer?: boolean\n}\n\n/**\n * Proxies tab focus within a container to a reference element\n * when the container is rendered in a portal\n */\n\nfunction proxyTabFocusImpl(container: MaybeElement, options: ProxyTabFocusOptions = {}) {\n const { triggerElement, onFocus } = options\n\n const doc = container?.ownerDocument || document\n const body = doc.body\n\n function onKeyDown(event: KeyboardEvent) {\n if (event.key !== \"Tab\") return\n\n let elementToFocus: MaybeElement | undefined = null\n\n // get all tabbable elements within the container\n const [firstTabbable, lastTabbable] = getTabbableEdges(container, true)\n\n const noTabbableElements = !firstTabbable && !lastTabbable\n\n // if we're focused on the first tabbable element and the user tabs backwards\n // we want to focus the reference element\n if (event.shiftKey && (doc.activeElement === firstTabbable || noTabbableElements)) {\n elementToFocus = triggerElement\n } else if (!event.shiftKey && doc.activeElement === triggerElement) {\n // if we're focused on the reference element and the user tabs forwards\n // we want to focus the first tabbable element\n elementToFocus = firstTabbable\n } else if (!event.shiftKey && (doc.activeElement === lastTabbable || noTabbableElements)) {\n // if we're focused on the last tabbable element and the user tabs forwards\n // we want to focus the next tabbable element after the reference element\n elementToFocus = getNextTabbable(body, triggerElement)\n }\n\n if (!elementToFocus) return\n\n event.preventDefault()\n\n onFocus?.(elementToFocus) ?? elementToFocus.focus()\n }\n\n // listen for the tab key in the capture phase\n doc?.addEventListener(\"keydown\", onKeyDown, true)\n\n return () => {\n doc?.removeEventListener(\"keydown\", onKeyDown, true)\n }\n}\n\nexport function proxyTabFocus(container: NodeOrFn, options: ProxyTabFocusOptions<NodeOrFn>) {\n const { defer, triggerElement, ...restOptions } = options\n const func = defer ? raf : (v: any) => v()\n const cleanups: (VoidFunction | undefined)[] = []\n cleanups.push(\n func(() => {\n const node = typeof container === \"function\" ? container() : container\n const trigger = typeof triggerElement === \"function\" ? triggerElement() : triggerElement\n cleanups.push(proxyTabFocusImpl(node, { triggerElement: trigger, ...restOptions }))\n }),\n )\n return () => {\n cleanups.forEach((fn) => fn?.())\n }\n}\n","export const isHTMLElement = (element: any): element is HTMLElement =>\n typeof element === \"object\" && element !== null && element.nodeType === 1\n\nexport const isFrame = (element: any): element is HTMLIFrameElement =>\n isHTMLElement(element) && element.tagName === \"IFRAME\"\n\nexport function isVisible(el: any) {\n if (!isHTMLElement(el)) return false\n return el.offsetWidth > 0 || el.offsetHeight > 0 || el.getClientRects().length > 0\n}\n\nexport type IncludeContainerType = boolean | \"if-empty\"\n\nexport function hasNegativeTabIndex(element: Element) {\n const tabIndex = parseInt(element.getAttribute(\"tabindex\") || \"0\", 10)\n return tabIndex < 0\n}\n\nexport const focusableSelector =\n /*#__PURE__*/ \"input:not([type='hidden']):not([disabled]), select:not([disabled]), \" +\n \"textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], \" +\n \"iframe, object, embed, area[href], audio[controls], video[controls], \" +\n \"[contenteditable]:not([contenteditable='false']), details > summary:first-of-type\"\n","import { focusableSelector, isFrame, isHTMLElement, isVisible, type IncludeContainerType } from \"./shared\"\n\n/**\n * Returns the focusable elements within the element\n */\n\nexport const getFocusables = (\n container: Pick<HTMLElement, \"querySelectorAll\"> | null,\n includeContainer: IncludeContainerType = false,\n) => {\n if (!container) return []\n const elements = Array.from(container.querySelectorAll<HTMLElement>(focusableSelector))\n\n const include = includeContainer == true || (includeContainer == \"if-empty\" && elements.length === 0)\n if (include && isHTMLElement(container) && isFocusable(container)) {\n elements.unshift(container)\n }\n\n const focusableElements = elements.filter(isFocusable)\n\n focusableElements.forEach((element, i) => {\n if (isFrame(element) && element.contentDocument) {\n const frameBody = element.contentDocument.body\n focusableElements.splice(i, 1, ...getFocusables(frameBody))\n }\n })\n\n return focusableElements\n}\n/**\n * Whether this element is focusable\n */\n\nexport function isFocusable(element: HTMLElement | null): element is HTMLElement {\n if (!element || element.closest(\"[inert]\")) return false\n return element.matches(focusableSelector) && isVisible(element)\n}\n\nexport function getFirstFocusable(container: HTMLElement, includeContainer?: IncludeContainerType) {\n const [first] = getFocusables(container, includeContainer)\n return first || null\n}\n","import { isFocusable } from \"./focusable\"\nimport { focusableSelector, hasNegativeTabIndex, isFrame, type IncludeContainerType } from \"./shared\"\n\n/**\n * Returns the tabbable elements within the element\n */\nexport function getTabbables(container: HTMLElement | null, includeContainer?: IncludeContainerType) {\n if (!container) return []\n const elements = Array.from(container.querySelectorAll<HTMLElement>(focusableSelector))\n const tabbableElements = elements.filter(isTabbable)\n\n if (includeContainer && isTabbable(container)) {\n tabbableElements.unshift(container)\n }\n\n tabbableElements.forEach((element, i) => {\n if (isFrame(element) && element.contentDocument) {\n const frameBody = element.contentDocument.body\n const allFrameTabbable = getTabbables(frameBody)\n tabbableElements.splice(i, 1, ...allFrameTabbable)\n }\n })\n\n if (!tabbableElements.length && includeContainer) {\n return elements\n }\n\n return tabbableElements\n}\n\n/**\n * Whether this element is tabbable\n */\nexport function isTabbable(el: HTMLElement | null): el is HTMLElement {\n if (el != null && el.tabIndex > 0) return true\n return isFocusable(el) && !hasNegativeTabIndex(el)\n}\n\n/**\n * Returns the first focusable element within the element\n */\nexport function getFirstTabbable(container: HTMLElement | null, includeContainer?: IncludeContainerType) {\n const [first] = getTabbables(container, includeContainer)\n return first || null\n}\n\n/**\n * Returns the last focusable element within the element\n */\nexport function getLastTabbable(container: HTMLElement | null, includeContainer?: IncludeContainerType) {\n const elements = getTabbables(container, includeContainer)\n return elements[elements.length - 1] || null\n}\n\n/**\n * Returns the first and last focusable elements within the element\n */\nexport function getTabbableEdges(container: HTMLElement | null, includeContainer?: IncludeContainerType) {\n const elements = getTabbables(container, includeContainer)\n const first = elements[0] || null\n const last = elements[elements.length - 1] || null\n return [first, last]\n}\n\n/**\n * Returns the next tabbable element after the current element\n */\nexport function getNextTabbable(container: HTMLElement | null, current?: HTMLElement | null) {\n const tabbables = getTabbables(container)\n const doc = container?.ownerDocument || document\n const currentElement = current ?? (doc.activeElement as HTMLElement | null)\n if (!currentElement) return null\n const index = tabbables.indexOf(currentElement)\n return tabbables[index + 1] || null\n}\n","// Credits: https://github.com/adobe/react-spectrum/blob/main/packages/@react-aria/overlays/src/ariaHideOutside.ts\nimport { raf } from \"@zag-js/dom-query\"\n\nconst refCountMap = new WeakMap<Element, number>()\nconst observerStack: any[] = []\n\nexport type AriaHiddenOptions = {\n rootEl?: HTMLElement\n defer?: boolean\n}\n\ntype MaybeElement = HTMLElement | null\ntype Targets = Array<MaybeElement>\ntype TargetsOrFn = Targets | (() => Targets)\n\nfunction ariaHiddenImpl(targets: Targets, options: AriaHiddenOptions = {}) {\n const { rootEl } = options\n\n const exclude = targets.filter(Boolean) as HTMLElement[]\n if (exclude.length === 0) return\n\n const doc = exclude[0].ownerDocument || document\n const win = doc.defaultView ?? window\n\n const visibleNodes = new Set<Element>(exclude)\n const hiddenNodes = new Set<Element>()\n\n const root = rootEl ?? doc.body\n\n let walk = (root: Element) => {\n // Keep live announcer and top layer elements (e.g. toasts) visible.\n for (let element of root.querySelectorAll(\"[data-live-announcer], [data-zag-top-layer]\")) {\n visibleNodes.add(element)\n }\n\n let acceptNode = (node: Element) => {\n // Skip this node and its children if it is one of the target nodes, or a live announcer.\n // Also skip children of already hidden nodes, as aria-hidden is recursive. An exception is\n // made for elements with role=\"row\" since VoiceOver on iOS has issues hiding elements with role=\"row\".\n // For that case we want to hide the cells inside as well (https://bugs.webkit.org/show_bug.cgi?id=222623).\n if (\n visibleNodes.has(node) ||\n (hiddenNodes.has(node.parentElement!) && node.parentElement!.getAttribute(\"role\") !== \"row\")\n ) {\n return NodeFilter.FILTER_REJECT\n }\n\n // Skip this node but continue to children if one of the targets is inside the node.\n for (let target of visibleNodes) {\n if (node.contains(target)) {\n return NodeFilter.FILTER_SKIP\n }\n }\n\n return NodeFilter.FILTER_ACCEPT\n }\n\n let walker = doc.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, { acceptNode })\n\n // TreeWalker does not include the root.\n let acceptRoot = acceptNode(root)\n if (acceptRoot === NodeFilter.FILTER_ACCEPT) {\n hide(root)\n }\n\n if (acceptRoot !== NodeFilter.FILTER_REJECT) {\n let node = walker.nextNode() as Element\n while (node != null) {\n hide(node)\n node = walker.nextNode() as Element\n }\n }\n }\n\n let hide = (node: Element) => {\n let refCount = refCountMap.get(node) ?? 0\n\n // If already aria-hidden, and the ref count is zero, then this element\n // was already hidden and there's nothing for us to do.\n if (node.getAttribute(\"aria-hidden\") === \"true\" && refCount === 0) {\n return\n }\n\n if (refCount === 0) {\n node.setAttribute(\"aria-hidden\", \"true\")\n }\n\n hiddenNodes.add(node)\n refCountMap.set(node, refCount + 1)\n }\n\n if (observerStack.length) {\n observerStack[observerStack.length - 1].disconnect()\n }\n\n walk(root)\n\n const observer = new win.MutationObserver((changes) => {\n for (let change of changes) {\n if (change.type !== \"childList\" || change.addedNodes.length === 0) {\n continue\n }\n\n // If the parent element of the added nodes is not within one of the targets,\n // and not already inside a hidden node, hide all of the new children.\n if (![...visibleNodes, ...hiddenNodes].some((node) => node.contains(change.target))) {\n for (let node of change.removedNodes) {\n if (node instanceof win.Element) {\n visibleNodes.delete(node)\n hiddenNodes.delete(node)\n }\n }\n\n for (let node of change.addedNodes) {\n if (\n (node instanceof win.HTMLElement || node instanceof win.SVGElement) &&\n (node.dataset.liveAnnouncer === \"true\" || node.dataset.zagTopLayer === \"true\")\n ) {\n visibleNodes.add(node)\n } else if (node instanceof win.Element) {\n walk(node)\n }\n }\n }\n }\n })\n\n observer.observe(root, { childList: true, subtree: true })\n\n let observerWrapper = {\n observe() {\n observer.observe(root, { childList: true, subtree: true })\n },\n disconnect() {\n observer.disconnect()\n },\n }\n\n observerStack.push(observerWrapper)\n\n return () => {\n observer.disconnect()\n\n for (let node of hiddenNodes) {\n let count = refCountMap.get(node)\n if (count === 1) {\n node.removeAttribute(\"aria-hidden\")\n refCountMap.delete(node)\n } else {\n refCountMap.set(node, count! - 1)\n }\n }\n\n // Remove this observer from the stack, and start the previous one.\n if (observerWrapper === observerStack[observerStack.length - 1]) {\n observerStack.pop()\n if (observerStack.length) {\n observerStack[observerStack.length - 1].observe()\n }\n } else {\n observerStack.splice(observerStack.indexOf(observerWrapper), 1)\n }\n }\n}\n\nexport function ariaHidden(targetsOrFn: TargetsOrFn, options: AriaHiddenOptions = {}) {\n const { defer } = options\n const func = defer ? raf : (v: any) => v()\n const cleanups: (VoidFunction | undefined)[] = []\n cleanups.push(\n func(() => {\n const targets = typeof targetsOrFn === \"function\" ? targetsOrFn() : targetsOrFn\n cleanups.push(ariaHiddenImpl(targets, options))\n }),\n )\n return () => {\n cleanups.forEach((fn) => fn?.())\n }\n}\n","import { addDomEvent, fireCustomEvent, isContextMenuEvent } from \"@zag-js/dom-event\"\nimport { contains, getDocument, getEventTarget, getWindow, isHTMLElement, raf } from \"@zag-js/dom-query\"\nimport { isFocusable } from \"@zag-js/tabbable\"\nimport { callAll } from \"@zag-js/utils\"\nimport { getWindowFrames } from \"./get-window-frames\"\n\nexport type InteractOutsideHandlers = {\n onPointerDownOutside?: (event: PointerDownOutsideEvent) => void\n onFocusOutside?: (event: FocusOutsideEvent) => void\n onInteractOutside?: (event: InteractOutsideEvent) => void\n}\n\nexport type InteractOutsideOptions = InteractOutsideHandlers & {\n exclude?: (target: HTMLElement) => boolean\n defer?: boolean\n}\n\nexport type EventDetails<T> = {\n originalEvent: T\n contextmenu: boolean\n focusable: boolean\n}\n\nconst POINTER_OUTSIDE_EVENT = \"pointerdown.outside\"\nconst FOCUS_OUTSIDE_EVENT = \"focus.outside\"\n\nexport type PointerDownOutsideEvent = CustomEvent<EventDetails<PointerEvent>>\n\nexport type FocusOutsideEvent = CustomEvent<EventDetails<FocusEvent>>\n\nexport type InteractOutsideEvent = PointerDownOutsideEvent | FocusOutsideEvent\n\nexport type MaybeElement = HTMLElement | null | undefined\nexport type NodeOrFn = MaybeElement | (() => MaybeElement)\n\nfunction isComposedPathFocusable(event: Event) {\n const composedPath = event.composedPath() ?? [event.target as HTMLElement]\n for (const node of composedPath) {\n if (isHTMLElement(node) && isFocusable(node)) return true\n }\n return false\n}\n\nconst isPointerEvent = (event: Event): event is PointerEvent => \"clientY\" in event\n\nfunction isEventPointWithin(node: MaybeElement, event: Event) {\n if (!isPointerEvent(event) || !node) return false\n\n const rect = node.getBoundingClientRect()\n if (rect.width === 0 || rect.height === 0) return false\n\n return (\n rect.top <= event.clientY &&\n event.clientY <= rect.top + rect.height &&\n rect.left <= event.clientX &&\n event.clientX <= rect.left + rect.width\n )\n}\n\nfunction trackInteractOutsideImpl(node: MaybeElement, options: InteractOutsideOptions) {\n const { exclude, onFocusOutside, onPointerDownOutside, onInteractOutside } = options\n\n if (!node) return\n\n const doc = getDocument(node)\n const win = getWindow(node)\n const frames = getWindowFrames(win)\n\n function isEventOutside(event: Event): boolean {\n const target = getEventTarget(event)\n if (!isHTMLElement(target)) return false\n if (contains(node, target)) return false\n if (isEventPointWithin(node, event)) return false\n return !exclude?.(target)\n }\n\n let clickHandler: VoidFunction\n\n function onPointerDown(event: PointerEvent) {\n //\n function handler() {\n if (!node || !isEventOutside(event)) return\n\n if (onPointerDownOutside || onInteractOutside) {\n const handler = callAll(onPointerDownOutside, onInteractOutside) as EventListener\n node.addEventListener(POINTER_OUTSIDE_EVENT, handler, { once: true })\n }\n\n fireCustomEvent(node, POINTER_OUTSIDE_EVENT, {\n bubbles: false,\n cancelable: true,\n detail: {\n originalEvent: event,\n contextmenu: isContextMenuEvent(event),\n focusable: isComposedPathFocusable(event),\n },\n })\n }\n\n if (event.pointerType === \"touch\") {\n frames.removeEventListener(\"click\", handler)\n doc.removeEventListener(\"click\", handler)\n\n clickHandler = handler\n\n doc.addEventListener(\"click\", handler, { once: true })\n frames.addEventListener(\"click\", handler, { once: true })\n } else {\n handler()\n }\n }\n const cleanups = new Set<VoidFunction>()\n\n const timer = setTimeout(() => {\n cleanups.add(frames.addEventListener(\"pointerdown\", onPointerDown, true))\n cleanups.add(addDomEvent(doc, \"pointerdown\", onPointerDown, true))\n }, 0)\n\n function onFocusin(event: FocusEvent) {\n //\n if (!node || !isEventOutside(event)) return\n\n if (onFocusOutside || onInteractOutside) {\n const handler = callAll(onFocusOutside, onInteractOutside) as EventListener\n node.addEventListener(FOCUS_OUTSIDE_EVENT, handler, { once: true })\n }\n\n fireCustomEvent(node, FOCUS_OUTSIDE_EVENT, {\n bubbles: false,\n cancelable: true,\n detail: {\n originalEvent: event,\n contextmenu: false,\n focusable: isFocusable(getEventTarget(event)),\n },\n })\n }\n\n cleanups.add(addDomEvent(doc, \"focusin\", onFocusin, true))\n cleanups.add(frames.addEventListener(\"focusin\", onFocusin, true))\n\n return () => {\n clearTimeout(timer)\n if (clickHandler) {\n frames.removeEventListener(\"click\", clickHandler)\n doc.removeEventListener(\"click\", clickHandler)\n }\n cleanups.forEach((fn) => fn())\n }\n}\n\nexport function trackInteractOutside(nodeOrFn: NodeOrFn, options: InteractOutsideOptions) {\n const { defer } = options\n const func = defer ? raf : (v: any) => v()\n const cleanups: (VoidFunction | undefined)[] = []\n cleanups.push(\n func(() => {\n const node = typeof nodeOrFn === \"function\" ? nodeOrFn() : nodeOrFn\n cleanups.push(trackInteractOutsideImpl(node, options))\n }),\n )\n return () => {\n cleanups.forEach((fn) => fn?.())\n }\n}\n","export function getWindowFrames(win: Window) {\n const frames = {\n each(cb: (win: Window) => void) {\n for (let i = 0; i < win.frames?.length; i += 1) {\n const frame = win.frames[i]\n if (frame) cb(frame)\n }\n },\n addEventListener(event: string, listener: any, options?: any) {\n frames.each((frame) => {\n try {\n frame.document.addEventListener(event, listener, options)\n } catch (err) {\n console.warn(err)\n }\n })\n return () => {\n try {\n frames.removeEventListener(event, listener, options)\n } catch (err) {\n console.warn(err)\n }\n }\n },\n removeEventListener(event: string, listener: any, options?: any) {\n frames.each((frame) => {\n try {\n frame.document.removeEventListener(event, listener, options)\n } catch (err) {\n console.warn(err)\n }\n })\n },\n }\n return frames\n}\n","import { contains, getEventTarget, raf } from \"@zag-js/dom-query\"\nimport {\n trackInteractOutside,\n type FocusOutsideEvent,\n type InteractOutsideHandlers,\n type PointerDownOutsideEvent,\n} from \"@zag-js/interact-outside\"\nimport { warn } from \"@zag-js/utils\"\nimport { trackEscapeKeydown } from \"./escape-keydown\"\nimport { layerStack, type Layer } from \"./layer-stack\"\nimport { assignPointerEventToLayers, clearPointerEvent, disablePointerEventsOutside } from \"./pointer-event-outside\"\n\ntype MaybeElement = HTMLElement | null\ntype Container = MaybeElement | Array<MaybeElement>\ntype NodeOrFn = MaybeElement | (() => MaybeElement)\n\nexport type DismissableElementHandlers = InteractOutsideHandlers & {\n onEscapeKeyDown?: (event: KeyboardEvent) => void\n}\n\nexport type DismissableElementOptions = DismissableElementHandlers & {\n debug?: boolean\n pointerBlocking?: boolean\n onDismiss: () => void\n exclude?: Container | (() => Container)\n defer?: boolean\n}\n\nfunction trackDismissableElementImpl(node: MaybeElement, options: DismissableElementOptions) {\n if (!node) {\n warn(\"[@zag-js/dismissable] node is `null` or `undefined`\")\n return\n }\n\n const { onDismiss, pointerBlocking, exclude: excludeContainers, debug } = options\n\n const layer: Layer = { dismiss: onDismiss, node, pointerBlocking }\n\n layerStack.add(layer)\n assignPointerEventToLayers()\n\n function onPointerDownOutside(event: PointerDownOutsideEvent) {\n const target = getEventTarget(event.detail.originalEvent)\n if (layerStack.isBelowPointerBlockingLayer(node!) || layerStack.isInBranch(target)) return\n options.onPointerDownOutside?.(event)\n options.onInteractOutside?.(event)\n if (event.defaultPrevented) return\n if (debug) {\n console.log(\"onPointerDownOutside:\", event.detail.originalEvent)\n }\n onDismiss?.()\n }\n\n function onFocusOutside(event: FocusOutsideEvent) {\n const target = getEventTarget(event.detail.originalEvent)\n if (layerStack.isInBranch(target)) return\n options.onFocusOutside?.(event)\n options.onInteractOutside?.(event)\n if (event.defaultPrevented) return\n if (debug) {\n console.log(\"onFocusOutside:\", event.detail.originalEvent)\n }\n onDismiss?.()\n }\n\n function onEscapeKeyDown(event: KeyboardEvent) {\n if (!layerStack.isTopMost(node!)) return\n options.onEscapeKeyDown?.(event)\n if (!event.defaultPrevented && onDismiss) {\n event.preventDefault()\n onDismiss()\n }\n }\n\n function exclude(target: Element) {\n if (!node) return false\n const containers = typeof excludeContainers === \"function\" ? excludeContainers() : excludeContainers\n const _containers = Array.isArray(containers) ? containers : [containers]\n return _containers.some((node) => contains(node, target)) || layerStack.isInNestedLayer(node, target)\n }\n\n const cleanups = [\n pointerBlocking ? disablePointerEventsOutside(node) : undefined,\n trackEscapeKeydown(node, onEscapeKeyDown),\n trackInteractOutside(node, { exclude, onFocusOutside, onPointerDownOutside }),\n ]\n\n return () => {\n layerStack.remove(node!)\n // re-assign pointer event to remaining layers\n assignPointerEventToLayers()\n // remove pointer event from removed layer\n clearPointerEvent(node!)\n cleanups.forEach((fn) => fn?.())\n }\n}\n\nexport function trackDismissableElement(nodeOrFn: NodeOrFn, options: DismissableElementOptions) {\n const { defer } = options\n const func = defer ? raf : (v: any) => v()\n const cleanups: (VoidFunction | undefined)[] = []\n cleanups.push(\n func(() => {\n const node = typeof nodeOrFn === \"function\" ? nodeOrFn() : nodeOrFn\n cleanups.push(trackDismissableElementImpl(node, options))\n }),\n )\n return () => {\n cleanups.forEach((fn) => fn?.())\n }\n}\n","import { addDomEvent } from \"@zag-js/dom-event\"\nimport { getDocument } from \"@zag-js/dom-query\"\n\nexport function trackEscapeKeydown(node: HTMLElement, fn?: (event: KeyboardEvent) => void) {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") fn?.(event)\n }\n return addDomEvent(getDocument(node), \"keydown\", handleKeyDown)\n}\n","import { contains } from \"@zag-js/dom-query\"\n\nexport type Layer = {\n dismiss: VoidFunction\n node: HTMLElement\n pointerBlocking?: boolean\n}\n\nexport const layerStack = {\n layers: [] as Layer[],\n branches: [] as HTMLElement[],\n count(): number {\n return this.layers.length\n },\n pointerBlockingLayers(): Layer[] {\n return this.layers.filter((layer) => layer.pointerBlocking)\n },\n topMostPointerBlockingLayer(): Layer | undefined {\n return [...this.pointerBlockingLayers()].slice(-1)[0]\n },\n hasPointerBlockingLayer(): boolean {\n return this.pointerBlockingLayers().length > 0\n },\n isBelowPointerBlockingLayer(node: HTMLElement) {\n const index = this.indexOf(node)\n const highestBlockingIndex = this.topMostPointerBlockingLayer()\n ? this.indexOf(this.topMostPointerBlockingLayer()?.node)\n : -1\n return index < highestBlockingIndex\n },\n isTopMost(node: HTMLElement | null) {\n const layer = this.layers[this.count() - 1]\n return layer?.node === node\n },\n getNestedLayers(node: HTMLElement) {\n return Array.from(this.layers).slice(this.indexOf(node) + 1)\n },\n isInNestedLayer(node: HTMLElement, target: HTMLElement | EventTarget | null) {\n return this.getNestedLayers(node).some((layer) => contains(layer.node, target))\n },\n isInBranch(target: HTMLElement | EventTarget | null) {\n return Array.from(this.branches).some((branch) => contains(branch, target))\n },\n add(layer: Layer) {\n this.layers.push(layer)\n },\n addBranch(node: HTMLElement) {\n this.branches.push(node)\n },\n remove(node: HTMLElement) {\n const index = this.indexOf(node)\n if (index < 0) return\n\n // dismiss nested layers\n if (index < this.count() - 1) {\n const _layers = this.getNestedLayers(node)\n _layers.forEach((layer) => layer.dismiss())\n }\n // remove this layer\n this.layers.splice(index, 1)\n },\n removeBranch(node: HTMLElement) {\n const index = this.branches.indexOf(node)\n if (index >= 0) this.branches.splice(index, 1)\n },\n indexOf(node: HTMLElement | undefined) {\n return this.layers.findIndex((layer) => layer.node === node)\n },\n dismiss(node: HTMLElement) {\n this.layers[this.indexOf(node)]?.dismiss()\n },\n clear() {\n this.remove(this.layers[0].node)\n },\n}\n","import { getDocument } from \"@zag-js/dom-query\"\nimport { layerStack } from \"./layer-stack\"\n\nlet originalBodyPointerEvents: string\n\nexport function assignPointerEventToLayers() {\n layerStack.layers.forEach(({ node }) => {\n node.style.pointerEvents = layerStack.isBelowPointerBlockingLayer(node) ? \"none\" : \"auto\"\n })\n}\n\nexport function clearPointerEvent(node: HTMLElement) {\n node.style.pointerEvents = \"\"\n}\n\nconst DATA_ATTR = \"data-inert\"\n\nexport function disablePointerEventsOutside(node: HTMLElement) {\n const doc = getDocument(node)\n\n if (layerStack.hasPointerBlockingLayer() && !doc.body.hasAttribute(DATA_ATTR)) {\n originalBodyPointerEvents = document.body.style.pointerEvents\n doc.body.style.pointerEvents = \"none\"\n doc.body.setAttribute(DATA_ATTR, \"\")\n }\n\n return () => {\n if (layerStack.hasPointerBlockingLayer()) return\n doc.body.style.pointerEvents = originalBodyPointerEvents\n doc.body.removeAttribute(DATA_ATTR)\n if (doc.body.style.length === 0) doc.body.removeAttribute(\"style\")\n }\n}\n","import { isIos } from \"@zag-js/dom-query\"\n\nconst LOCK_CLASSNAME = \"data-zag-scroll-lock\"\n\nfunction assignStyle(el: HTMLElement | null | undefined, style: Partial<CSSStyleDeclaration>) {\n if (!el) return\n const previousStyle = el.style.cssText\n Object.assign(el.style, style)\n return () => {\n el.style.cssText = previousStyle\n }\n}\n\nfunction setCSSProperty(el: HTMLElement | null | undefined, property: string, value: string) {\n if (!el) return\n const previousValue = el.style.getPropertyValue(property)\n el.style.setProperty(property, value)\n return () => {\n if (previousValue) {\n el.style.setProperty(property, previousValue)\n } else {\n el.style.removeProperty(property)\n }\n }\n}\n\nfunction getPaddingProperty(documentElement: HTMLElement) {\n // RTL <body> scrollbar\n const documentLeft = documentElement.getBoundingClientRect().left\n const scrollbarX = Math.round(documentLeft) + documentElement.scrollLeft\n return scrollbarX ? \"paddingLeft\" : \"paddingRight\"\n}\n\nexport function preventBodyScroll(_document?: Document) {\n const doc = _document ?? document\n const win = doc.defaultView ?? window\n\n const { documentElement, body } = doc\n\n const locked = body.hasAttribute(LOCK_CLASSNAME)\n if (locked) return\n\n body.setAttribute(LOCK_CLASSNAME, \"\")\n\n const scrollbarWidth = win.innerWidth - documentElement.clientWidth\n const setScrollbarWidthProperty = () => setCSSProperty(documentElement, \"--scrollbar-width\", `${scrollbarWidth}px`)\n const paddingProperty = getPaddingProperty(documentElement)\n\n const setStyle = () =>\n assignStyle(body, {\n overflow: \"hidden\",\n [paddingProperty]: `${scrollbarWidth}px`,\n })\n\n // Only iOS doesn't respect `overflow: hidden` on document.body\n const setIOSStyle = () => {\n const { scrollX, scrollY, visualViewport } = win\n\n // iOS 12 does not support `visuaViewport`.\n const offsetLeft = visualViewport?.offsetLeft ?? 0\n const offsetTop = visualViewport?.offsetTop ?? 0\n\n const restoreStyle = assignStyle(body, {\n position: \"fixed\",\n overflow: \"hidden\",\n top: `${-(scrollY - Math.floor(offsetTop))}px`,\n left: `${-(scrollX - Math.floor(offsetLeft))}px`,\n right: \"0\",\n [paddingProperty]: `${scrollbarWidth}px`,\n })\n\n return () => {\n restoreStyle?.()\n win.scrollTo(scrollX, scrollY)\n }\n }\n\n const cleanups = [setScrollbarWidthProperty(), isIos() ? setIOSStyle() : setStyle()]\n\n return () => {\n cleanups.forEach((fn) => fn?.())\n body.removeAttribute(LOCK_CLASSNAME)\n }\n}\n","// NOTE: separate `:not()` selectors has broader browser support than the newer\n// `:not([inert], [inert] *)` (Feb 2023)\n// CAREFUL: JSDom does not support `:not([inert] *)` as a selector; using it causes\n// the entire query to fail, resulting in no nodes found, which will break a lot\n// of things... so we have to rely on JS to identify nodes inside an inert container\nconst candidateSelectors = [\n 'input:not([inert])',\n 'select:not([inert])',\n 'textarea:not([inert])',\n 'a[href]:not([inert])',\n 'button:not([inert])',\n '[tabindex]:not(slot):not([inert])',\n 'audio[controls]:not([inert])',\n 'video[controls]:not([inert])',\n '[contenteditable]:not([contenteditable=\"false\"]):not([inert])',\n 'details>summary:first-of-type:not([inert])',\n 'details:not([inert])',\n];\nconst candidateSelector = /* #__PURE__ */ candidateSelectors.join(',');\n\nconst NoElement = typeof Element === 'undefined';\n\nconst matches = NoElement\n ? function () {}\n : Element.prototype.matches ||\n Element.prototype.msMatchesSelector ||\n Element.prototype.webkitMatchesSelector;\n\nconst getRootNode =\n !NoElement && Element.prototype.getRootNode\n ? (element) => element?.getRootNode?.()\n : (element) => element?.ownerDocument;\n\n/**\n * Determines if a node is inert or in an inert ancestor.\n * @param {Element} [node]\n * @param {boolean} [lookUp] If true and `node` is not inert, looks up at ancestors to\n * see if any of them are inert. If false, only `node` itself is considered.\n * @returns {boolean} True if inert itself or by way of being in an inert ancestor.\n * False if `node` is falsy.\n */\nconst isInert = function (node, lookUp = true) {\n // CAREFUL: JSDom does not support inert at all, so we can't use the `HTMLElement.inert`\n // JS API property; we have to check the attribute, which can either be empty or 'true';\n // if it's `null` (not specified) or 'false', it's an active element\n const inertAtt = node?.getAttribute?.('inert');\n const inert = inertAtt === '' || inertAtt === 'true';\n\n // NOTE: this could also be handled with `node.matches('[inert], :is([inert] *)')`\n // if it weren't for `matches()` not being a function on shadow roots; the following\n // code works for any kind of node\n // CAREFUL: JSDom does not appear to support certain selectors like `:not([inert] *)`\n // so it likely would not support `:is([inert] *)` either...\n const result = inert || (lookUp && node && isInert(node.parentNode)); // recursive\n\n return result;\n};\n\n/**\n * Determines if a node's content is editable.\n * @param {Element} [node]\n * @returns True if it's content-editable; false if it's not or `node` is falsy.\n */\nconst isContentEditable = function (node) {\n // CAREFUL: JSDom does not support the `HTMLElement.isContentEditable` API so we have\n // to use the attribute directly to check for this, which can either be empty or 'true';\n // if it's `null` (not specified) or 'false', it's a non-editable element\n const attValue = node?.getAttribute?.('contenteditable');\n return attValue === '' || attValue === 'true';\n};\n\n/**\n * @param {Element} el container to check in\n * @param {boolean} includeContainer add container to check\n * @param {(node: Element) => boolean} filter filter candidates\n * @returns {Element[]}\n */\nconst getCandidates = function (el, includeContainer, filter) {\n // even if `includeContainer=false`, we still have to check it for inertness because\n // if it's inert, all its children are inert\n if (isInert(el)) {\n return [];\n }\n\n let candidates = Array.prototype.slice.apply(\n el.querySelectorAll(candidateSelector)\n );\n if (includeContainer && matches.call(el, candidateSelector)) {\n candidates.unshift(el);\n }\n candidates = candidates.filter(filter);\n return candidates;\n};\n\n/**\n * @callback GetShadowRoot\n * @param {Element} element to check for shadow root\n * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.\n */\n\n/**\n * @callback ShadowRootFilter\n * @param {Element} shadowHostNode the element which contains shadow content\n * @returns {boolean} true if a shadow root could potentially contain valid candidates.\n */\n\n/**\n * @typedef {Object} CandidateScope\n * @property {Element} scopeParent contains inner candidates\n * @property {Element[]} candidates list of candidates found in the scope parent\n */\n\n/**\n * @typedef {Object} IterativeOptions\n * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;\n * if a function, implies shadow support is enabled and either returns the shadow root of an element\n * or a boolean stating if it has an undisclosed shadow root\n * @property {(node: Element) => boolean} filter filter candidates\n * @property {boolean} flatten if true then result will flatten any CandidateScope into the returned list\n * @property {ShadowRootFilter} shadowRootFilter filter shadow roots;\n */\n\n/**\n * @param {Element[]} elements list of element containers to match candidates from\n * @param {boolean} includeContainer add container list to check\n * @param {IterativeOptions} options\n * @returns {Array.<Element|CandidateScope>}\n */\nconst getCandidatesIteratively = function (\n elements,\n includeContainer,\n options\n) {\n const candidates = [];\n const elementsToCheck = Array.from(elements);\n while (elementsToCheck.length) {\n const element = elementsToCheck.shift();\n if (isInert(element, false)) {\n // no need to look up since we're drilling down\n // anything inside this container will also be inert\n continue;\n }\n\n if (element.tagName === 'SLOT') {\n // add shadow dom slot scope (slot itself cannot be focusable)\n const assigned = element.assignedElements();\n const content = assigned.length ? assigned : element.children;\n const nestedCandidates = getCandidatesIteratively(content, true, options);\n if (options.flatten) {\n candidates.push(...nestedCandidates);\n } else {\n candidates.push({\n scopeParent: element,\n candidates: nestedCandidates,\n });\n }\n } else {\n // check candidate element\n const validCandidate = matches.call(element, candidateSelector);\n if (\n validCandidate &&\n options.filter(element) &&\n (includeContainer || !elements.includes(element))\n ) {\n candidates.push(element);\n }\n\n // iterate over shadow content if possible\n const shadowRoot =\n element.shadowRoot ||\n // check for an undisclosed shadow\n (typeof options.getShadowRoot === 'function' &&\n options.getShadowRoot(element));\n\n // no inert look up because we're already drilling down and checking for inertness\n // on the way down, so all containers to this root node should have already been\n // vetted as non-inert\n const validShadowRoot =\n !isInert(shadowRoot, false) &&\n (!options.shadowRootFilter || options.shadowRootFilter(element));\n\n if (shadowRoot && validShadowRoot) {\n // add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed\n // shadow exists, so look at light dom children as fallback BUT create a scope for any\n // child candidates found because they're likely slotted elements (elements that are\n // children of the web component element (which has the shadow), in the light dom, but\n // slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,\n // _after_ we return from this recursive call\n const nestedCandidates = getCandidatesIteratively(\n shadowRoot === true ? element.children : shadowRoot.children,\n true,\n options\n );\n\n if (options.flatten) {\n candidates.push(...nestedCandidates);\n } else {\n candidates.push({\n scopeParent: element,\n candidates: nestedCandidates,\n });\n }\n } else {\n // there's not shadow so just dig into the element's (light dom) children\n // __without__ giving the element special scope treatment\n elementsToCheck.unshift(...element.children);\n }\n }\n }\n return candidates;\n};\n\n/**\n * @private\n * Determines if the node has an explicitly specified `tabindex` attribute.\n * @param {HTMLElement} node\n * @returns {boolean} True if so; false if not.\n */\nconst hasTabIndex = function (node) {\n return !isNaN(parseInt(node.getAttribute('tabindex'), 10));\n};\n\n/**\n * Determine the tab index of a given node.\n * @param {HTMLElement} node\n * @returns {number} Tab order (negative, 0, or positive number).\n * @throws {Error} If `node` is falsy.\n */\nconst getTabIndex = function (node) {\n if (!node) {\n throw new Error('No node provided');\n }\n\n if (node.tabIndex < 0) {\n // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default\n // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,\n // yet they are still part of the regular tab order; in FF, they get a default\n // `tabIndex` of 0; since Chrome still puts those elements in the regular tab\n // order, consider their tab index to be 0.\n // Also browsers do not return `tabIndex` correctly for contentEditable nodes;\n // so if they don't have a tabindex attribute specifically set, assume it's 0.\n if (\n (/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) ||\n isContentEditable(node)) &&\n !hasTabIndex(node)\n ) {\n return 0;\n }\n }\n\n return node.tabIndex;\n};\n\n/**\n * Determine the tab index of a given node __for sort order purposes__.\n * @param {HTMLElement} node\n * @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default,\n * has tabIndex -1, but needs to be sorted by document order in order for its content to be\n * inserted into the correct sort position.\n * @returns {number} Tab order (negative, 0, or positive number).\n */\nconst getSortOrderTabIndex = function (node, isScope) {\n const tabIndex = getTabIndex(node);\n\n if (tabIndex < 0 && isScope && !hasTabIndex(node)) {\n return 0;\n }\n\n return tabIndex;\n};\n\nconst sortOrderedTabbables = function (a, b) {\n return a.tabIndex === b.tabIndex\n ? a.documentOrder - b.documentOrder\n : a.tabIndex - b.tabIndex;\n};\n\nconst isInput = function (node) {\n return node.tagName === 'INPUT';\n};\n\nconst isHiddenInput = function (node) {\n return isInput(node) && node.type === 'hidden';\n};\n\nconst isDetailsWithSummary = function (node) {\n const r =\n node.tagName === 'DETAILS' &&\n Array.prototype.slice\n .apply(node.children)\n .some((child) => child.tagName === 'SUMMARY');\n return r;\n};\n\nconst getCheckedRadio = function (nodes, form) {\n for (let i = 0; i < nodes.length; i++) {\n if (nodes[i].checked && nodes[i].form === form) {\n return nodes[i];\n }\n }\n};\n\nconst isTabbableRadio = function (node) {\n if (!node.name) {\n return true;\n }\n const radioScope = node.form || getRootNode(node);\n const queryRadios = function (name) {\n return radioScope.querySelectorAll(\n 'input[type=\"radio\"][name=\"' + name + '\"]'\n );\n };\n\n let radioSet;\n if (\n typeof window !== 'undefined' &&\n typeof window.CSS !== 'undefined' &&\n typeof window.CSS.escape === 'function'\n ) {\n radioSet = queryRadios(window.CSS.escape(node.name));\n } else {\n try {\n radioSet = queryRadios(node.name);\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error(\n 'Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s',\n err.message\n );\n return false;\n }\n }\n\n const checked = getCheckedRadio(radioSet, node.form);\n return !checked || checked === node;\n};\n\nconst isRadio = function (node) {\n return isInput(node) && node.type === 'radio';\n};\n\nconst isNonTabbableRadio = function (node) {\n return isRadio(node) && !isTabbableRadio(node);\n};\n\n// determines if a node is ultimately attached to the window's document\nconst isNodeAttached = function (node) {\n // The root node is the shadow root if the node is in a shadow DOM; some document otherwise\n // (but NOT _the_ document; see second 'If' comment below for more).\n // If rootNode is shadow root, it'll have a host, which is the element to which the shadow\n // is attached, and the one we need to check if it's in the document or not (because the\n // shadow, and all nodes it contains, is never considered in the document since shadows\n // behave like self-contained DOMs; but if the shadow's HOST, which is part of the document,\n // is hidden, or is not in the document itself but is detached, it will affect the shadow's\n // visibility, including all the nodes it contains). The host could be any normal node,\n // or a custom element (i.e. web component). Either way, that's the one that is considered\n // part of the document, not the shadow root, nor any of its children (i.e. the node being\n // tested).\n // To further complicate things, we have to look all the way up until we find a shadow HOST\n // that is attached (or find none) because the node might be in nested shadows...\n // If rootNode is not a shadow root, it won't have a host, and so rootNode should be the\n // document (per the docs) and while it's a Document-type object, that document does not\n // appear to be the same as the node's `ownerDocument` for some reason, so it's safer\n // to ignore the rootNode at this point, and use `node.ownerDocument`. Otherwise,\n // using `rootNode.contains(node)` will _always_ be true we'll get false-positives when\n // node is actually detached.\n // NOTE: If `nodeRootHost` or `node` happens to be the `document` itself (which is possible\n // if a tabbable/focusable node was quickly added to the DOM, focused, and then removed\n // from the DOM as in https://github.com/focus-trap/focus-trap-react/issues/905), then\n // `ownerDocument` will be `null`, hence the optional chaining on it.\n let nodeRoot = node && getRootNode(node);\n let nodeRootHost = nodeRoot?.host;\n\n // in some cases, a detached node will return itself as the root instead of a document or\n // shadow root object, in which case, we shouldn't try to look further up the host chain\n let attached = false;\n if (nodeRoot && nodeRoot !== node) {\n attached = !!(\n nodeRootHost?.ownerDocument?.contains(nodeRootHost) ||\n node?.ownerDocument?.contains(node)\n );\n\n while (!attached && nodeRootHost) {\n // since it's not attached and we have a root host, the node MUST be in a nested shadow DOM,\n // which means we need to get the host's host and check if that parent host is contained\n // in (i.e. attached to) the document\n nodeRoot = getRootNode(nodeRootHost);\n nodeRootHost = nodeRoot?.host;\n attached = !!nodeRootHost?.ownerDocument?.contains(nodeRootHost);\n }\n }\n\n return attached;\n};\n\nconst isZeroArea = function (node) {\n const { width, height } = node.getBoundingClientRect();\n return width === 0 && height === 0;\n};\nconst isHidden = function (node, { displayCheck, getShadowRoot }) {\n // NOTE: visibility will be `undefined` if node is detached from the document\n // (see notes about this further down), which means we will consider it visible\n // (this is legacy behavior from a very long way back)\n // NOTE: we check this regardless of `displayCheck=\"none\"` because this is a\n // _visibility_ check, not a _display_ check\n if (getComputedStyle(node).visibility === 'hidden') {\n return true;\n }\n\n const isDirectSummary = matches.call(node, 'details>summary:first-of-type');\n const nodeUnderDetails = isDirectSummary ? node.parentElement : node;\n if (matches.call(nodeUnderDetails, 'details:not([open]) *')) {\n return true;\n }\n\n if (\n !displayCheck ||\n displayCheck === 'full' ||\n displayCheck === 'legacy-full'\n ) {\n if (typeof getShadowRoot === 'function') {\n // figure out if we should consider the node to be in an undisclosed shadow and use the\n // 'non-zero-area' fallback\n const originalNode = node;\n while (node) {\n const parentElement = node.parentElement;\n const rootNode = getRootNode(node);\n if (\n parentElement &&\n !parentElement.shadowRoot &&\n getShadowRoot(parentElement) === true // check if there's an undisclosed shadow\n ) {\n // node has an undisclosed shadow which means we can only treat it as a black box, so we\n // fall back to a non-zero-area test\n return isZeroArea(node);\n } else if (node.assignedSlot) {\n // iterate up slot\n node = node.assignedSlot;\n } else if (!parentElement && rootNode !== node.ownerDocument) {\n // cross shadow boundary\n node = rootNode.host;\n } else {\n // iterate up normal dom\n node = parentElement;\n }\n }\n\n node = originalNode;\n }\n // else, `getShadowRoot` might be true, but all that does is enable shadow DOM support\n // (i.e. it does not also presume that all nodes might have undisclosed shadows); or\n // it might be a falsy value, which means shadow DOM support is disabled\n\n // Since we didn't find it sitting in an undisclosed shadow (or shadows are disabled)\n // now we can just test to see if it would normally be visible or not, provided it's\n // attached to the main document.\n // NOTE: We must consider case where node is inside a shadow DOM and given directly to\n // `isTabbable()` or `isFocusable()` -- regardless of `getShadowRoot` option setting.\n\n if (isNodeAttached(node)) {\n // this works wherever the node is: if there's at least one client rect, it's\n // somehow displayed; it also covers the CSS 'display: contents' case where the\n // node itself is hidden in place of its contents; and there's no need to search\n // up the hierarchy either\n return !node.getClientRects().length;\n }\n\n // Else, the node isn't attached to the document, which means the `getClientRects()`\n // API will __always__ return zero rects (this can happen, for example, if React\n // is used to render nodes onto a detached tree, as confirmed in this thread:\n // https://github.com/facebook/react/issues/9117#issuecomment-284228870)\n //\n // It also means that even window.getComputedStyle(node).display will return `undefined`\n // because styles are only computed for nodes that are in the document.\n //\n // NOTE: THIS HAS BEEN THE CASE FOR YEARS. It is not new, nor is it caused by tabbable\n // somehow. Though it was never stated officially, anyone who has ever used tabbable\n // APIs on nodes in detached containers has actually implicitly used tabbable in what\n // was later (as of v5.2.0 on Apr 9, 2021) called `displayCheck=\"none\"` mode -- essentially\n // considering __everything__ to be visible because of the innability to determine styles.\n //\n // v6.0.0: As of this major release, the default 'full' option __no longer treats detached\n // nodes as visible with the 'none' fallback.__\n if (displayCheck !== 'legacy-full') {\n return true; // hidden\n }\n // else, fallback to 'none' mode and consider the node visible\n } else if (displayCheck === 'non-zero-area') {\n // NOTE: Even though this tests that the node's client rect is non-zero to determine\n // whether it's displayed, and that a detached node will __always__ have a zero-area\n // client rect, we don't special-case for whether the node is attached or not. In\n // this mode, we do want to consider nodes that have a zero area to be hidden at all\n // times, and that includes attached or not.\n return isZeroArea(node);\n }\n\n // visible, as far as we can tell, or per current `displayCheck=none` mode, we assume\n // it's visible\n return false;\n};\n\n// form fields (nested) inside a disabled fieldset are not focusable/tabbable\n// unless they are in the _first_ <legend> element of the top-most disabled\n// fieldset\nconst isDisabledFromFieldset = function (node) {\n if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {\n let parentNode = node.parentElement;\n // check if `node` is contained in a disabled <fieldset>\n while (parentNode) {\n if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) {\n // look for the first <legend> among the children of the disabled <fieldset>\n for (let i = 0; i < parentNode.children.length; i++) {\n const child = parentNode.children.item(i);\n // when the first <legend> (in document order) is found\n if (child.tagName === 'LEGEND') {\n // if its parent <fieldset> is not nested in another disabled <fieldset>,\n // return whether `node` is a descendant of its first <legend>\n return matches.call(parentNode, 'fieldset[disabled] *')\n ? true\n : !child.contains(node);\n }\n }\n // the disabled <fieldset> containing `node` has no <legend>\n return true;\n }\n parentNode = parentNode.parentElement;\n }\n }\n\n // else, node's tabbable/focusable state should not be affected by a fieldset's\n // enabled/disabled state\n return false;\n};\n\nconst isNodeMatchingSelectorFocusable = function (options, node) {\n if (\n node.disabled ||\n // we must do an inert look up to filter out any elements inside an inert ancestor\n // because we're limited in the type of selectors we can use in JSDom (see related\n // note related to `candidateSelectors`)\n isInert(node) ||\n isHiddenInput(node) ||\n isHidden(node, options) ||\n // For a details element with a summary, the summary element gets the focus\n isDetailsWithSummary(node) ||\n isDisabledFromFieldset(node)\n ) {\n return false;\n }\n return true;\n};\n\nconst isNodeMatchingSelectorTabbable = function (options, node) {\n if (\n isNonTabbableRadio(node) ||\n getTabIndex(node) < 0 ||\n !isNodeMatchingSelectorFocusable(options, node)\n ) {\n return false;\n }\n return true;\n};\n\nconst isValidShadowRootTabbable = function (shadowHostNode) {\n const tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10);\n if (isNaN(tabIndex) || tabIndex >= 0) {\n return true;\n }\n // If a custom element has an explicit negative tabindex,\n // browsers will not allow tab targeting said element's children.\n return false;\n};\n\n/**\n * @param {Array.<Element|CandidateScope>} candidates\n * @returns Element[]\n */\nconst sortByOrder = function (candidates) {\n const regularTabbables = [];\n const orderedTabbables = [];\n candidates.forEach(function (item, i) {\n const isScope = !!item.scopeParent;\n const element = isScope ? item.scopeParent : item;\n const candidateTabindex = getSortOrderTabIndex(element, isScope);\n const elements = isScope ? sortByOrder(item.candidates) : element;\n if (candidateTabindex === 0) {\n isScope\n ? regularTabbables.push(...elements)\n : regularTabbables.push(element);\n } else {\n orderedTabbables.push({\n documentOrder: i,\n tabIndex: candidateTabindex,\n item: item,\n isScope: isScope,\n content: elements,\n });\n }\n });\n\n return orderedTabbables\n .sort(sortOrderedTabbables)\n .reduce((acc, sortable) => {\n sortable.isScope\n ? acc.push(...sortable.content)\n : acc.push(sortable.content);\n return acc;\n }, [])\n .concat(regularTabbables);\n};\n\nconst tabbable = function (container, options) {\n options = options || {};\n\n let candidates;\n if (options.getShadowRoot) {\n candidates = getCandidatesIteratively(\n [container],\n options.includeContainer,\n {\n filter: isNodeMatchingSelectorTabbable.bind(null, options),\n flatten: false,\n getShadowRoot: options.getShadowRoot,\n shadowRootFilter: isValidShadowRootTabbable,\n }\n );\n } else {\n candidates = getCandidates(\n container,\n options.includeContainer,\n isNodeMatchingSelectorTabbable.bind(null, options)\n );\n }\n return sortByOrder(candidates);\n};\n\nconst focusable = function (container, options) {\n options = options || {};\n\n let candidates;\n if (options.getShadowRoot) {\n candidates = getCandidatesIteratively(\n [container],\n options.includeContainer,\n {\n filter: isNodeMatchingSelectorFocusable.bind(null, options),\n flatten: true,\n getShadowRoot: options.getShadowRoot,\n }\n );\n } else {\n candidates = getCandidates(\n container,\n options.includeContainer,\n isNodeMatchingSelectorFocusable.bind(null, options)\n );\n }\n\n return candidates;\n};\n\nconst isTabbable = function (node, options) {\n options = options || {};\n if (!node) {\n throw new Error('No node provided');\n }\n if (matches.call(node, candidateSelector) === false) {\n return false;\n }\n return isNodeMatchingSelectorTabbable(options, node);\n};\n\nconst focusableCandidateSelector = /* #__PURE__ */ candidateSelectors\n .concat('iframe')\n .join(',');\n\nconst isFocusable = function (node, options) {\n options = options || {};\n if (!node) {\n throw new Error('No node provided');\n }\n if (matches.call(node, focusableCandidateSelector) === false) {\n return false;\n }\n return isNodeMatchingSelectorFocusable(options, node);\n};\n\nexport { tabbable, focusable, isTabbable, isFocusable, getTabIndex };\n","import {\n tabbable,\n focusable,\n isFocusable,\n isTabbable,\n getTabIndex,\n} from 'tabbable';\n\nconst activeFocusTraps = {\n activateTrap(trapStack, trap) {\n if (trapStack.length > 0) {\n const activeTrap = trapStack[trapStack.length - 1];\n if (activeTrap !== trap) {\n activeTrap.pause();\n }\n }\n\n const trapIndex = trapStack.indexOf(trap);\n if (trapIndex === -1) {\n trapStack.push(trap);\n } else {\n // move this existing trap to the front of the queue\n trapStack.splice(trapIndex, 1);\n trapStack.push(trap);\n }\n },\n\n deactivateTrap(trapStack, trap) {\n const trapIndex = trapStack.indexOf(trap);\n if (trapIndex !== -1) {\n trapStack.splice(trapIndex, 1);\n }\n\n if (trapStack.length > 0) {\n trapStack[trapStack.length - 1].unpause();\n }\n },\n};\n\nconst isSelectableInput = function (node) {\n return (\n node.tagName &&\n node.tagName.toLowerCase() === 'input' &&\n typeof node.select === 'function'\n );\n};\n\nconst isEscapeEvent = function (e) {\n return e?.key === 'Escape' || e?.key === 'Esc' || e?.keyCode === 27;\n};\n\nconst isTabEvent = function (e) {\n return e?.key === 'Tab' || e?.keyCode === 9;\n};\n\n// checks for TAB by default\nconst isKeyForward = function (e) {\n return isTabEvent(e) && !e.shiftKey;\n};\n\n// checks for SHIFT+TAB by default\nconst isKeyBackward = function (e) {\n return isTabEvent(e) && e.shiftKey;\n};\n\nconst delay = function (fn) {\n return setTimeout(fn, 0);\n};\n\n// Array.find/findIndex() are not supported on IE; this replicates enough\n// of Array.findIndex() for our needs\nconst findIndex = function (arr, fn) {\n let idx = -1;\n\n arr.every(function (value, i) {\n if (fn(value)) {\n idx = i;\n return false; // break\n }\n\n return true; // next\n });\n\n return idx;\n};\n\n/**\n * Get an option's value when it could be a plain value, or a handler that provides\n * the value.\n * @param {*} value Option's value to check.\n * @param {...*} [params] Any parameters to pass to the handler, if `value` is a function.\n * @returns {*} The `value`, or the handler's returned value.\n */\nconst valueOrHandler = function (value, ...params) {\n return typeof value === 'function' ? value(...params) : value;\n};\n\nconst getActualTarget = function (event) {\n // NOTE: If the trap is _inside_ a shadow DOM, event.target will always be the\n // shadow host. However, event.target.composedPath() will be an array of\n // nodes \"clicked\" from inner-most (the actual element inside the shadow) to\n // outer-most (the host HTML document). If we have access to composedPath(),\n // then use its first element; otherwise, fall back to event.target (and\n // this only works for an _open_ shadow DOM; otherwise,\n // composedPath()[0] === event.target always).\n return event.target.shadowRoot && typeof event.composedPath === 'function'\n ? event.composedPath()[0]\n : event.target;\n};\n\n// NOTE: this must be _outside_ `createFocusTrap()` to make sure all traps in this\n// current instance use the same stack if `userOptions.trapStack` isn't specified\nconst internalTrapStack = [];\n\nconst createFocusTrap = function (elements, userOptions) {\n // SSR: a live trap shouldn't be created in this type of environment so this\n // should be safe code to execute if the `document` option isn't specified\n const doc = userOptions?.document || document;\n\n const trapStack = userOptions?.trapStack || internalTrapStack;\n\n const config = {\n returnFocusOnDeactivate: true,\n escapeDeactivates: true,\n delayInitialFocus: true,\n isKeyForward,\n isKeyBackward,\n ...userOptions,\n };\n\n const state = {\n // containers given to createFocusTrap()\n // @type {Array<HTMLElement>}\n containers: [],\n\n // list of objects identifying tabbable nodes in `containers` in the trap\n // NOTE: it's possible that a group has no tabbable nodes if nodes get removed while the trap\n // is active, but the trap should never get to a state where there isn't at least one group\n // with at least one tabbable node in it (that would lead to an error condition that would\n // result in an error being thrown)\n // @type {Array<{\n // container: HTMLElement,\n // tabbableNodes: Array<HTMLElement>, // empty if none\n // focusableNodes: Array<HTMLElement>, // empty if none\n // posTabIndexesFound: boolean,\n // firstTabbableNode: HTMLElement|undefined,\n // lastTabbableNode: HTMLElement|undefined,\n // firstDomTabbableNode: HTMLElement|undefined,\n // lastDomTabbableNode: HTMLElement|undefined,\n // nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined\n // }>}\n containerGroups: [], // same order/length as `containers` list\n\n // references to objects in `containerGroups`, but only those that actually have\n // tabbable nodes in them\n // NOTE: same order as `containers` and `containerGroups`, but __not necessarily__\n // the same length\n tabbableGroups: [],\n\n nodeFocusedBeforeActivation: null,\n mostRecentlyFocusedNode: null,\n active: false,\n paused: false,\n\n // timer ID for when delayInitialFocus is true and initial focus in this trap\n // has been delayed during activation\n delayInitialFocusTimer: undefined,\n\n // the most recent KeyboardEvent for the configured nav key (typically [SHIFT+]TAB), if any\n recentNavEvent: undefined,\n };\n\n let trap; // eslint-disable-line prefer-const -- some private functions reference it, and its methods reference private functions, so we must declare here and define later\n\n /**\n * Gets a configuration option value.\n * @param {Object|undefined} configOverrideOptions If true, and option is defined in this set,\n * value will be taken from this object. Otherwise, value will be taken from base configuration.\n * @param {string} optionName Name of the option whose value is sought.\n * @param {string|undefined} [configOptionName] Name of option to use __instead of__ `optionName`\n * IIF `configOverrideOptions` is not defined. Otherwise, `optionName` is used.\n */\n const getOption = (configOverrideOptions, optionName, configOptionName) => {\n return configOverrideOptions &&\n configOverrideOptions[optionName] !== undefined\n ? configOverrideOptions[optionName]\n : config[configOptionName || optionName];\n };\n\n /**\n * Finds the index of the container that contains the element.\n * @param {HTMLElement} element\n * @param {Event} [event] If available, and `element` isn't directly found in any container,\n * the event's composed path is used to see if includes any known trap containers in the\n * case where the element is inside a Shadow DOM.\n * @returns {number} Index of the container in either `state.containers` or\n * `state.containerGroups` (the order/length of these lists are the same); -1\n * if the element isn't found.\n */\n const findContainerIndex = function (element, event) {\n const composedPath =\n typeof event?.composedPath === 'function'\n ? event.composedPath()\n : undefined;\n // NOTE: search `containerGroups` because it's possible a group contains no tabbable\n // nodes, but still contains focusable nodes (e.g. if they all have `tabindex=-1`)\n // and we still need to find the element in there\n return state.containerGroups.findIndex(\n ({ container, tabbableNodes }) =>\n container.contains(element) ||\n // fall back to explicit tabbable search which will take into consideration any\n // web components if the `tabbableOptions.getShadowRoot` option was used for\n // the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't\n // look inside web components even if open)\n composedPath?.includes(container) ||\n tabbableNodes.find((node) => node === element)\n );\n };\n\n /**\n * Gets the node for the given option, which is expected to be an option that\n * can be either a DOM node, a string that is a selector to get a node, `false`\n * (if a node is explicitly NOT given), or a function that returns any of these\n * values.\n * @param {string} optionName\n * @returns {undefined | false | HTMLElement | SVGElement} Returns\n * `undefined` if the option is not specified; `false` if the option\n * resolved to `false` (node explicitly not given); otherwise, the resolved\n * DOM node.\n * @throws {Error} If the option is set, not `false`, and is not, or does not\n * resolve to a node.\n */\n const getNodeForOption = function (optionName, ...params) {\n let optionValue = config[optionName];\n\n if (typeof optionValue === 'function') {\n optionValue = optionValue(...params);\n }\n\n if (optionValue === true) {\n optionValue = undefined; // use default value\n }\n\n if (!optionValue) {\n if (optionValue === undefined || optionValue === false) {\n return optionValue;\n }\n // else, empty string (invalid), null (invalid), 0 (invalid)\n\n throw new Error(\n `\\`${optionName}\\` was specified but was not a node, or did not return a node`\n );\n }\n\n let node = optionValue; // could be HTMLElement, SVGElement, or non-empty string at this point\n\n if (typeof optionValue === 'string') {\n node = doc.querySelector(optionValue); // resolve to node, or null if fails\n if (!node) {\n throw new Error(\n `\\`${optionName}\\` as selector refers to no known node`\n );\n }\n }\n\n return node;\n };\n\n const getInitialFocusNode = function () {\n let node = getNodeForOption('initialFocus');\n\n // false explicitly indicates we want no initialFocus at all\n if (node === false) {\n return false;\n }\n\n if (node === undefined || !isFocusable(node, config.tabbableOptions)) {\n // option not specified nor focusable: use fallback options\n if (findContainerIndex(doc.activeElement) >= 0) {\n node = doc.activeElement;\n } else {\n const firstTabbableGroup = state.tabbableGroups[0];\n const firstTabbableNode =\n firstTabbableGroup && firstTabbableGroup.firstTabbableNode;\n\n // NOTE: `fallbackFocus` option function cannot return `false` (not supported)\n node = firstTabbableNode || getNodeForOption('fallbackFocus');\n }\n }\n\n if (!node) {\n throw new Error(\n 'Your focus-trap needs to have at least one focusable element'\n );\n }\n\n return node;\n };\n\n const updateTabbableNodes = function () {\n state.containerGroups = state.containers.map((container) => {\n const tabbableNodes = tabbable(container, config.tabbableOptions);\n\n // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes\n // are a superset of tabbable nodes since nodes with negative `tabindex` attributes\n // are focusable but not tabbable\n const focusableNodes = focusable(container, config.tabbableOptions);\n\n const firstTabbableNode =\n tabbableNodes.length > 0 ? tabbableNodes[0] : undefined;\n const lastTabbableNode =\n tabbableNodes.length > 0\n ? tabbableNodes[tabbableNodes.length - 1]\n : undefined;\n\n const firstDomTabbableNode = focusableNodes.find((node) =>\n isTabbable(node)\n );\n const lastDomTabbableNode = focusableNodes\n .slice()\n .reverse()\n .find((node) => isTabbable(node));\n\n const posTabIndexesFound = !!tabbableNodes.find(\n (node) => getTabIndex(node) > 0\n );\n\n return {\n container,\n tabbableNodes,\n focusableNodes,\n\n /** True if at least one node with positive `tabindex` was found in this container. */\n posTabIndexesFound,\n\n /** First tabbable node in container, __tabindex__ order; `undefined` if none. */\n firstTabbableNode,\n /** Last tabbable node in container, __tabindex__ order; `undefined` if none. */\n lastTabbableNode,\n\n // NOTE: DOM order is NOT NECESSARILY \"document position\" order, but figuring that out\n // would require more than just https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition\n // because that API doesn't work with Shadow DOM as well as it should (@see\n // https://github.com/whatwg/dom/issues/320) and since this first/last is only needed, so far,\n // to address an edge case related to positive tabindex support, this seems like a much easier,\n // \"close enough most of the time\" alternative for positive tabindexes which should generally\n // be avoided anyway...\n /** First tabbable node in container, __DOM__ order; `undefined` if none. */\n firstDomTabbableNode,\n /** Last tabbable node in container, __DOM__ order; `undefined` if none. */\n lastDomTabbableNode,\n\n /**\n * Finds the __tabbable__ node that follows the given node in the specified direction,\n * in this container, if any.\n * @param {HTMLElement} node\n * @param {boolean} [forward] True if going in forward tab order; false if going\n * in reverse.\n * @returns {HTMLElement|undefined} The next tabbable node, if any.\n */\n nextTabbableNode(node, forward = true) {\n const nodeIdx = tabbableNodes.indexOf(node);\n if (nodeIdx < 0) {\n // either not tabbable nor focusable, or was focused but not tabbable (negative tabindex):\n // since `node` should at least have been focusable, we assume that's the case and mimic\n // what browsers do, which is set focus to the next node in __document position order__,\n // regardless of positive tabindexes, if any -- and for reasons explained in the NOTE\n // above related to `firstDomTabbable` and `lastDomTabbable` properties, we fall back to\n // basic DOM order\n if (forward) {\n return focusableNodes\n .slice(focusableNodes.indexOf(node) + 1)\n .find((el) => isTabbable(el));\n }\n\n return focusableNodes\n .slice(0, focusableNodes.indexOf(node))\n .reverse()\n .find((el) => isTabbable(el));\n }\n\n return tabbableNodes[nodeIdx + (forward ? 1 : -1)];\n },\n };\n });\n\n state.tabbableGroups = state.containerGroups.filter(\n (group) => group.tabbableNodes.length > 0\n );\n\n // throw if no groups have tabbable nodes and we don't have a fallback focus node either\n if (\n state.tabbableGroups.length <= 0 &&\n !getNodeForOption('fallbackFocus') // returning false not supported for this option\n ) {\n throw new Error(\n 'Your focus-trap must have at least one container with at least one tabbable node in it at all times'\n );\n }\n\n // NOTE: Positive tabindexes are only properly supported in single-container traps because\n // doing it across multiple containers where tabindexes could be all over the place\n // would require Tabbable to support multiple containers, would require additional\n // specialized Shadow DOM support, and would require Tabbable's multi-container support\n // to look at those containers in document position order rather than user-provided\n // order (as they are treated in Focus-trap, for legacy reasons). See discussion on\n // https://github.com/focus-trap/focus-trap/issues/375 for more details.\n if (\n state.containerGroups.find((g) => g.posTabIndexesFound) &&\n state.containerGroups.length > 1\n ) {\n throw new Error(\n \"At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.\"\n );\n }\n };\n\n const tryFocus = function (node) {\n if (node === false) {\n return;\n }\n\n if (node === doc.activeElement) {\n return;\n }\n\n if (!node || !node.focus) {\n tryFocus(getInitialFocusNode());\n return;\n }\n\n node.focus({ preventScroll: !!config.preventScroll });\n // NOTE: focus() API does not trigger focusIn event so set MRU node manually\n state.mostRecentlyFocusedNode = node;\n\n if (isSelectableInput(node)) {\n node.select();\n }\n };\n\n const getReturnFocusNode = function (previousActiveElement) {\n const node = getNodeForOption('setReturnFocus', previousActiveElement);\n return node ? node : node === false ? false : previousActiveElement;\n };\n\n /**\n * Finds the next node (in either direction) where focus should move according to a\n * keyboard focus-in event.\n * @param {Object} params\n * @param {Node} [params.target] Known target __from which__ to navigate, if any.\n * @param {KeyboardEvent|FocusEvent} [params.event] Event to use if `target` isn't known (event\n * will be used to determine the `target`). Ignored if `target` is specified.\n * @param {boolean} [params.isBackward] True if focus should move backward.\n * @returns {Node|undefined} The next node, or `undefined` if a next node couldn't be\n * determined given the current state of the trap.\n */\n const findNextNavNode = function ({ target, event, isBackward = false }) {\n target = target || getActualTarget(event);\n updateTabbableNodes();\n\n let destinationNode = null;\n\n if (state.tabbableGroups.length > 0) {\n // make sure the target is actually contained in a group\n // NOTE: the target may also be the container itself if it's focusable\n // with tabIndex='-1' and was given initial focus\n const containerIndex = findContainerIndex(target, event);\n const containerGroup =\n containerIndex >= 0 ? state.containerGroups[containerIndex] : undefined;\n\n if (containerIndex < 0) {\n // target not found in any group: quite possible focus has escaped the trap,\n // so bring it back into...\n if (isBackward) {\n // ...the last node in the last group\n destinationNode =\n state.tabbableGroups[state.tabbableGroups.length - 1]\n .lastTabbableNode;\n } else {\n // ...the first node in the first group\n destinationNode = state.tabbableGroups[0].firstTabbableNode;\n }\n } else if (isBackward) {\n // REVERSE\n\n // is the target the first tabbable node in a group?\n let startOfGroupIndex = findIndex(\n state.tabbableGroups,\n ({ firstTabbableNode }) => target === firstTabbableNode\n );\n\n if (\n startOfGroupIndex < 0 &&\n (containerGroup.container === target ||\n (isFocusable(target, config.tabbableOptions) &&\n !isTabbable(target, config.tabbableOptions) &&\n !containerGroup.nextTabbableNode(target, false)))\n ) {\n // an exception case where the target is either the container itself, or\n // a non-tabbable node that was given focus (i.e. tabindex is negative\n // and user clicked on it or node was programmatically given focus)\n // and is not followed by any other tabbable node, in which\n // case, we should handle shift+tab as if focus were on the container's\n // first tabbable node, and go to the last tabbable node of the LAST group\n startOfGroupIndex = containerIndex;\n }\n\n if (startOfGroupIndex >= 0) {\n // YES: then shift+tab should go to the last tabbable node in the\n // previous group (and wrap around to the last tabbable node of\n // the LAST group if it's the first tabbable node of the FIRST group)\n const destinationGroupIndex =\n startOfGroupIndex === 0\n ? state.tabbableGroups.length - 1\n : startOfGroupIndex - 1;\n\n const destinationGroup = state.tabbableGroups[destinationGroupIndex];\n\n destinationNode =\n getTabIndex(target) >= 0\n ? destinationGroup.lastTabbableNode\n : destinationGroup.lastDomTabbableNode;\n } else if (!isTabEvent(event)) {\n // user must have customized the nav keys so we have to move focus manually _within_\n // the active group: do this based on the order determined by tabbable()\n destinationNode = containerGroup.nextTabbableNode(target, false);\n }\n } else {\n // FORWARD\n\n // is the target the last tabbable node in a group?\n let lastOfGroupIndex = findIndex(\n state.tabbableGroups,\n ({ lastTabbableNode }) => target === lastTabbableNode\n );\n\n if (\n lastOfGroupIndex < 0 &&\n (containerGroup.container === target ||\n (isFocusable(target, config.tabbableOptions) &&\n !isTabbable(target, config.tabbableOptions) &&\n !containerGroup.nextTabbableNode(target)))\n ) {\n // an exception case where the target is the container itself, or\n // a non-tabbable node that was given focus (i.e. tabindex is negative\n // and user clicked on it or node was programmatically given focus)\n // and is not followed by any other tabbable node, in which\n // case, we should handle tab as if focus were on the container's\n // last tabbable node, and go to the first tabbable node of the FIRST group\n lastOfGroupIndex = containerIndex;\n }\n\n if (lastOfGroupIndex >= 0) {\n // YES: then tab should go to the first tabbable node in the next\n // group (and wrap around to the first tabbable node of the FIRST\n // group if it's the last tabbable node of the LAST group)\n const destinationGroupIndex =\n lastOfGroupIndex === state.tabbableGroups.length - 1\n ? 0\n : lastOfGroupIndex + 1;\n\n const destinationGroup = state.tabbableGroups[destinationGroupIndex];\n\n destinationNode =\n getTabIndex(target) >= 0\n ? destinationGroup.firstTabbableNode\n : destinationGroup.firstDomTabbableNode;\n } else if (!isTabEvent(event)) {\n // user must have customized the nav keys so we have to move focus manually _within_\n // the active group: do this based on the order determined by tabbable()\n destinationNode = containerGroup.nextTabbableNode(target);\n }\n }\n } else {\n // no groups available\n // NOTE: the fallbackFocus option does not support returning false to opt-out\n destinationNode = getNodeForOption('fallbackFocus');\n }\n\n return destinationNode;\n };\n\n // This needs to be done on mousedown and touchstart instead of click\n // so that it precedes the focus event.\n const checkPointerDown = function (e) {\n const target = getActualTarget(e);\n\n if (findContainerIndex(target, e) >= 0) {\n // allow the click since it ocurred inside the trap\n return;\n }\n\n if (valueOrHandler(config.clickOutsideDeactivates, e)) {\n // immediately deactivate the trap\n trap.deactivate({\n // NOTE: by setting `returnFocus: false`, deactivate() will do nothing,\n // which will result in the outside click setting focus to the node\n // that was clicked (and if not focusable, to \"nothing\"); by setting\n // `returnFocus: true`, we'll attempt to re-focus the node originally-focused\n // on activation (or the configured `setReturnFocus` node), whether the\n // outside click was on a focusable node or not\n returnFocus: config.returnFocusOnDeactivate,\n });\n return;\n }\n\n // This is needed for mobile devices.\n // (If we'll only let `click` events through,\n // then on mobile they will be blocked anyways if `touchstart` is blocked.)\n if (valueOrHandler(config.allowOutsideClick, e)) {\n // allow the click outside the trap to take place\n return;\n }\n\n // otherwise, prevent the click\n e.preventDefault();\n };\n\n // In case focus escapes the trap for some strange reason, pull it back in.\n // NOTE: the focusIn event is NOT cancelable, so if focus escapes, it may cause unexpected\n // scrolling if the node that got focused was out of view; there's nothing we can do to\n // prevent that from happening by the time we discover that focus escaped\n const checkFocusIn = function (event) {\n const target = getActualTarget(event);\n const targetContained = findContainerIndex(target, event) >= 0;\n\n // In Firefox when you Tab out of an iframe the Document is briefly focused.\n if (targetContained || target instanceof Document) {\n if (targetContained) {\n state.mostRecentlyFocusedNode = target;\n }\n } else {\n // escaped! pull it back in to where it just left\n event.stopImmediatePropagation();\n\n // focus will escape if the MRU node had a positive tab index and user tried to nav forward;\n // it will also escape if the MRU node had a 0 tab index and user tried to nav backward\n // toward a node with a positive tab index\n let nextNode; // next node to focus, if we find one\n let navAcrossContainers = true;\n if (state.mostRecentlyFocusedNode) {\n if (getTabIndex(state.mostRecentlyFocusedNode) > 0) {\n // MRU container index must be >=0 otherwise we wouldn't have it as an MRU node...\n const mruContainerIdx = findContainerIndex(\n state.mostRecentlyFocusedNode\n );\n // there MAY not be any tabbable nodes in the container if there are at least 2 containers\n // and the MRU node is focusable but not tabbable (focus-trap requires at least 1 container\n // with at least one tabbable node in order to function, so this could be the other container\n // with nothing tabbable in it)\n const { tabbableNodes } = state.containerGroups[mruContainerIdx];\n if (tabbableNodes.length > 0) {\n // MRU tab index MAY not be found if the MRU node is focusable but not tabbable\n const mruTabIdx = tabbableNodes.findIndex(\n (node) => node === state.mostRecentlyFocusedNode\n );\n if (mruTabIdx >= 0) {\n if (config.isKeyForward(state.recentNavEvent)) {\n if (mruTabIdx + 1 < tabbableNodes.length) {\n nextNode = tabbableNodes[mruTabIdx + 1];\n navAcrossContainers = false;\n }\n // else, don't wrap within the container as focus should move to next/previous\n // container\n } else {\n if (mruTabIdx - 1 >= 0) {\n nextNode = tabbableNodes[mruTabIdx - 1];\n navAcrossContainers = false;\n }\n // else, don't wrap within the container as focus should move to next/previous\n // container\n }\n // else, don't find in container order without considering direction too\n }\n }\n // else, no tabbable nodes in that container (which means we must have at least one other\n // container with at least one tabbable node in it, otherwise focus-trap would've thrown\n // an error the last time updateTabbableNodes() was run): find next node among all known\n // containers\n } else {\n // check to see if there's at least one tabbable node with a positive tab index inside\n // the trap because focus seems to escape when navigating backward from a tabbable node\n // with tabindex=0 when this is the case (instead of wrapping to the tabbable node with\n // the greatest positive tab index like it should)\n if (\n !state.containerGroups.some((g) =>\n g.tabbableNodes.some((n) => getTabIndex(n) > 0)\n )\n ) {\n // no containers with tabbable nodes with positive tab indexes which means the focus\n // escaped for some other reason and we should just execute the fallback to the\n // MRU node or initial focus node, if any\n navAcrossContainers = false;\n }\n }\n } else {\n // no MRU node means we're likely in some initial condition when the trap has just\n // been activated and initial focus hasn't been given yet, in which case we should\n // fall through to trying to focus the initial focus node, which is what should\n // happen below at this point in the logic\n navAcrossContainers = false;\n }\n\n if (navAcrossContainers) {\n nextNode = findNextNavNode({\n // move FROM the MRU node, not event-related node (which will be the node that is\n // outside the trap causing the focus escape we're trying to fix)\n target: state.mostRecentlyFocusedNode,\n isBackward: config.isKeyBackward(state.recentNavEvent),\n });\n }\n\n if (nextNode) {\n tryFocus(nextNode);\n } else {\n tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());\n }\n }\n\n state.recentNavEvent = undefined; // clear\n };\n\n // Hijack key nav events on the first and last focusable nodes of the trap,\n // in order to prevent focus from escaping. If it escapes for even a\n // moment it can end up scrolling the page and causing confusion so we\n // kind of need to capture the action at the keydown phase.\n const checkKeyNav = function (event, isBackward = false) {\n state.recentNavEvent = event;\n\n const destinationNode = findNextNavNode({ event, isBackward });\n if (destinationNode) {\n if (isTabEvent(event)) {\n // since tab natively moves focus, we wouldn't have a destination node unless we\n // were on the edge of a container and had to move to the next/previous edge, in\n // which case we want to prevent default to keep the browser from moving focus\n // to where it normally would\n event.preventDefault();\n }\n tryFocus(destinationNode);\n }\n // else, let the browser take care of [shift+]tab and move the focus\n };\n\n const checkKey = function (event) {\n if (\n isEscapeEvent(event) &&\n valueOrHandler(config.escapeDeactivates, event) !== false\n ) {\n event.preventDefault();\n trap.deactivate();\n return;\n }\n\n if (config.isKeyForward(event) || config.isKeyBackward(event)) {\n checkKeyNav(event, config.isKeyBackward(event));\n }\n };\n\n const checkClick = function (e) {\n const target = getActualTarget(e);\n\n if (findContainerIndex(target, e) >= 0) {\n return;\n }\n\n if (valueOrHandler(config.clickOutsideDeactivates, e)) {\n return;\n }\n\n if (valueOrHandler(config.allowOutsideClick, e)) {\n return;\n }\n\n e.preventDefault();\n e.stopImmediatePropagation();\n };\n\n //\n // EVENT LISTENERS\n //\n\n const addListeners = function () {\n if (!state.active) {\n return;\n }\n\n // There can be only one listening focus trap at a time\n activeFocusTraps.activateTrap(trapStack, trap);\n\n // Delay ensures that the focused element doesn't capture the event\n // that caused the focus trap activation.\n state.delayInitialFocusTimer = config.delayInitialFocus\n ? delay(function () {\n tryFocus(getInitialFocusNode());\n })\n : tryFocus(getInitialFocusNode());\n\n doc.addEventListener('focusin', checkFocusIn, true);\n doc.addEventListener('mousedown', checkPointerDown, {\n capture: true,\n passive: false,\n });\n doc.addEventListener('touchstart', checkPointerDown, {\n capture: true,\n passive: false,\n });\n doc.addEventListener('click', checkClick, {\n capture: true,\n passive: false,\n });\n doc.addEventListener('keydown', checkKey, {\n capture: true,\n passive: false,\n });\n\n return trap;\n };\n\n const removeListeners = function () {\n if (!state.active) {\n return;\n }\n\n doc.removeEventListener('focusin', checkFocusIn, true);\n doc.removeEventListener('mousedown', checkPointerDown, true);\n doc.removeEventListener('touchstart', checkPointerDown, true);\n doc.removeEventListener('click', checkClick, true);\n doc.removeEventListener('keydown', checkKey, true);\n\n return trap;\n };\n\n //\n // MUTATION OBSERVER\n //\n\n const checkDomRemoval = function (mutations) {\n const isFocusedNodeRemoved = mutations.some(function (mutation) {\n const removedNodes = Array.from(mutation.removedNodes);\n return removedNodes.some(function (node) {\n return node === state.mostRecentlyFocusedNode;\n });\n });\n\n // If the currently focused is removed then browsers will move focus to the\n // <body> element. If this happens, try to move focus back into the trap.\n if (isFocusedNodeRemoved) {\n tryFocus(getInitialFocusNode());\n }\n };\n\n // Use MutationObserver - if supported - to detect if focused node is removed\n // from the DOM.\n const mutationObserver =\n typeof window !== 'undefined' && 'MutationObserver' in window\n ? new MutationObserver(checkDomRemoval)\n : undefined;\n\n const updateObservedNodes = function () {\n if (!mutationObserver) {\n return;\n }\n\n mutationObserver.disconnect();\n if (state.active && !state.paused) {\n state.containers.map(function (container) {\n mutationObserver.observe(container, {\n subtree: true,\n childList: true,\n });\n });\n }\n };\n\n //\n // TRAP DEFINITION\n //\n\n trap = {\n get active() {\n return state.active;\n },\n\n get paused() {\n return state.paused;\n },\n\n activate(activateOptions) {\n if (state.active) {\n return this;\n }\n\n const onActivate = getOption(activateOptions, 'onActivate');\n const onPostActivate = getOption(activateOptions, 'onPostActivate');\n const checkCanFocusTrap = getOption(activateOptions, 'checkCanFocusTrap');\n\n if (!checkCanFocusTrap) {\n updateTabbableNodes();\n }\n\n state.active = true;\n state.paused = false;\n state.nodeFocusedBeforeActivation = doc.activeElement;\n\n onActivate?.();\n\n const finishActivation = () => {\n if (checkCanFocusTrap) {\n updateTabbableNodes();\n }\n addListeners();\n updateObservedNodes();\n onPostActivate?.();\n };\n\n if (checkCanFocusTrap) {\n checkCanFocusTrap(state.containers.concat()).then(\n finishActivation,\n finishActivation\n );\n return this;\n }\n\n finishActivation();\n return this;\n },\n\n deactivate(deactivateOptions) {\n if (!state.active) {\n return this;\n }\n\n const options = {\n onDeactivate: config.onDeactivate,\n onPostDeactivate: config.onPostDeactivate,\n checkCanReturnFocus: config.checkCanReturnFocus,\n ...deactivateOptions,\n };\n\n clearTimeout(state.delayInitialFocusTimer); // noop if undefined\n state.delayInitialFocusTimer = undefined;\n\n removeListeners();\n state.active = false;\n state.paused = false;\n updateObservedNodes();\n\n activeFocusTraps.deactivateTrap(trapStack, trap);\n\n const onDeactivate = getOption(options, 'onDeactivate');\n const onPostDeactivate = getOption(options, 'onPostDeactivate');\n const checkCanReturnFocus = getOption(options, 'checkCanReturnFocus');\n const returnFocus = getOption(\n options,\n 'returnFocus',\n 'returnFocusOnDeactivate'\n );\n\n onDeactivate?.();\n\n const finishDeactivation = () => {\n delay(() => {\n if (returnFocus) {\n tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));\n }\n onPostDeactivate?.();\n });\n };\n\n if (returnFocus && checkCanReturnFocus) {\n checkCanReturnFocus(\n getReturnFocusNode(state.nodeFocusedBeforeActivation)\n ).then(finishDeactivation, finishDeactivation);\n return this;\n }\n\n finishDeactivation();\n return this;\n },\n\n pause(pauseOptions) {\n if (state.paused || !state.active) {\n return this;\n }\n\n const onPause = getOption(pauseOptions, 'onPause');\n const onPostPause = getOption(pauseOptions, 'onPostPause');\n\n state.paused = true;\n onPause?.();\n\n removeListeners();\n updateObservedNodes();\n\n onPostPause?.();\n return this;\n },\n\n unpause(unpauseOptions) {\n if (!state.paused || !state.active) {\n return this;\n }\n\n const onUnpause = getOption(unpauseOptions, 'onUnpause');\n const onPostUnpause = getOption(unpauseOptions, 'onPostUnpause');\n\n state.paused = false;\n onUnpause?.();\n\n updateTabbableNodes();\n addListeners();\n updateObservedNodes();\n\n onPostUnpause?.();\n return this;\n },\n\n updateContainerElements(containerElements) {\n const elementsAsArray = [].concat(containerElements).filter(Boolean);\n\n state.containers = elementsAsArray.map((element) =>\n typeof element === 'string' ? doc.querySelector(element) : element\n );\n\n if (state.active) {\n updateTabbableNodes();\n }\n\n updateObservedNodes();\n\n return this;\n },\n };\n\n // initialize container elements\n trap.updateContainerElements(elements);\n\n return trap;\n};\n\nexport { createFocusTrap };\n","import { createAnatomy } from \"@zag-js/anatomy\"\n\nexport const anatomy = createAnatomy(\"popover\").parts(\n \"arrow\",\n \"arrowTip\",\n \"anchor\",\n \"trigger\",\n \"positioner\",\n \"content\",\n \"title\",\n \"description\",\n \"closeTrigger\",\n)\nexport const parts = anatomy.build()\n","import { dataAttr } from \"@zag-js/dom-query\"\nimport type { PositioningOptions } from \"@zag-js/popper\"\nimport { getPlacementStyles } from \"@zag-js/popper\"\nimport type { NormalizeProps, PropTypes } from \"@zag-js/types\"\nimport { parts } from \"./popover.anatomy\"\nimport { dom } from \"./popover.dom\"\nimport type { MachineApi, Send, State } from \"./popover.types\"\n\nexport function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T> {\n const isOpen = state.matches(\"open\")\n\n const currentPlacement = state.context.currentPlacement\n const portalled = state.context.currentPortalled\n const rendered = state.context.renderedElements\n\n const popperStyles = getPlacementStyles({\n ...state.context.positioning,\n placement: currentPlacement,\n })\n\n return {\n portalled,\n isOpen,\n\n open() {\n send(\"OPEN\")\n },\n\n close() {\n send(\"CLOSE\")\n },\n\n setPositioning(options: Partial<PositioningOptions> = {}) {\n send({ type: \"SET_POSITIONING\", options })\n },\n\n arrowProps: normalize.element({\n id: dom.getArrowId(state.context),\n ...parts.arrow.attrs,\n style: popperStyles.arrow,\n }),\n\n arrowTipProps: normalize.element({\n ...parts.arrowTip.attrs,\n style: popperStyles.arrowTip,\n }),\n\n anchorProps: normalize.element({\n ...parts.anchor.attrs,\n id: dom.getAnchorId(state.context),\n }),\n\n triggerProps: normalize.button({\n ...parts.trigger.attrs,\n type: \"button\",\n \"data-placement\": currentPlacement,\n id: dom.getTriggerId(state.context),\n \"aria-haspopup\": \"dialog\",\n \"aria-expanded\": isOpen,\n \"data-state\": isOpen ? \"open\" : \"closed\",\n \"aria-controls\": dom.getContentId(state.context),\n onClick() {\n send(\"TOGGLE\")\n },\n onBlur(event) {\n send({ type: \"TRIGGER_BLUR\", target: event.relatedTarget })\n },\n }),\n\n positionerProps: normalize.element({\n id: dom.getPositionerId(state.context),\n ...parts.positioner.attrs,\n style: popperStyles.floating,\n }),\n\n contentProps: normalize.element({\n ...parts.content.attrs,\n id: dom.getContentId(state.context),\n tabIndex: -1,\n role: \"dialog\",\n hidden: !isOpen,\n \"data-state\": isOpen ? \"open\" : \"closed\",\n \"data-expanded\": dataAttr(isOpen),\n \"aria-labelledby\": rendered.title ? dom.getTitleId(state.context) : undefined,\n \"aria-describedby\": rendered.description ? dom.getDescriptionId(state.context) : undefined,\n \"data-placement\": currentPlacement,\n }),\n\n titleProps: normalize.element({\n ...parts.title.attrs,\n id: dom.getTitleId(state.context),\n }),\n\n descriptionProps: normalize.element({\n ...parts.description.attrs,\n id: dom.getDescriptionId(state.context),\n }),\n\n closeTriggerProps: normalize.button({\n ...parts.closeTrigger.attrs,\n id: dom.getCloseTriggerId(state.context),\n type: \"button\",\n \"aria-label\": \"close\",\n onClick() {\n send(\"REQUEST_CLOSE\")\n },\n }),\n }\n}\n","import { createScope } from \"@zag-js/dom-query\"\nimport { getFirstTabbable, getFocusables, getLastTabbable, getTabbables } from \"@zag-js/tabbable\"\nimport { runIfFn } from \"@zag-js/utils\"\nimport type { MachineContext as Ctx } from \"./popover.types\"\n\nexport const dom = createScope({\n getActiveEl: (ctx: Ctx) => dom.getDoc(ctx).activeElement,\n\n getAnchorId: (ctx: Ctx) => ctx.ids?.anchor ?? `popover:${ctx.id}:anchor`,\n getTriggerId: (ctx: Ctx) => ctx.ids?.trigger ?? `popover:${ctx.id}:trigger`,\n getContentId: (ctx: Ctx) => ctx.ids?.content ?? `popover:${ctx.id}:content`,\n getPositionerId: (ctx: Ctx) => ctx.ids?.positioner ?? `popover:${ctx.id}:popper`,\n getArrowId: (ctx: Ctx) => ctx.ids?.arrow ?? `popover:${ctx.id}:arrow`,\n getTitleId: (ctx: Ctx) => ctx.ids?.title ?? `popover:${ctx.id}:title`,\n getDescriptionId: (ctx: Ctx) => ctx.ids?.description ?? `popover:${ctx.id}:desc`,\n getCloseTriggerId: (ctx: Ctx) => ctx.ids?.closeTrigger ?? `popover:${ctx.id}:close`,\n\n getAnchorEl: (ctx: Ctx) => dom.getById(ctx, dom.getAnchorId(ctx)),\n getTriggerEl: (ctx: Ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),\n getContentEl: (ctx: Ctx) => dom.getById(ctx, dom.getContentId(ctx)),\n getPositionerEl: (ctx: Ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),\n getTitleEl: (ctx: Ctx) => dom.getById(ctx, dom.getTitleId(ctx)),\n getDescriptionEl: (ctx: Ctx) => dom.getById(ctx, dom.getDescriptionId(ctx)),\n\n getFocusableEls: (ctx: Ctx) => getFocusables(dom.getContentEl(ctx)),\n getFirstFocusableEl: (ctx: Ctx) => dom.getFocusableEls(ctx)[0],\n\n getDocTabbableEls: (ctx: Ctx) => getTabbables(dom.getDoc(ctx).body),\n getTabbableEls: (ctx: Ctx) => getTabbables(dom.getContentEl(ctx), \"if-empty\"),\n getFirstTabbableEl: (ctx: Ctx) => getFirstTabbable(dom.getContentEl(ctx), \"if-empty\"),\n getLastTabbableEl: (ctx: Ctx) => getLastTabbable(dom.getContentEl(ctx), \"if-empty\"),\n\n getInitialFocusEl: (ctx: Ctx) => {\n let el: HTMLElement | null = runIfFn(ctx.initialFocusEl)\n if (!el && ctx.autoFocus) el = dom.getFirstFocusableEl(ctx)\n if (!el) el = dom.getContentEl(ctx)\n return el\n },\n})\n","import { ariaHidden } from \"@zag-js/aria-hidden\"\nimport { createMachine } from \"@zag-js/core\"\nimport { trackDismissableElement } from \"@zag-js/dismissable\"\nimport { nextTick, raf } from \"@zag-js/dom-query\"\nimport { getPlacement } from \"@zag-js/popper\"\nimport { preventBodyScroll } from \"@zag-js/remove-scroll\"\nimport { proxyTabFocus } from \"@zag-js/tabbable\"\nimport { compact, runIfFn } from \"@zag-js/utils\"\nimport { createFocusTrap, type FocusTrap } from \"focus-trap\"\nimport { dom } from \"./popover.dom\"\nimport type { MachineContext, MachineState, UserDefinedContext } from \"./popover.types\"\n\nexport function machine(userContext: UserDefinedContext) {\n const ctx = compact(userContext)\n return createMachine<MachineContext, MachineState>(\n {\n id: \"popover\",\n initial: ctx.open ? \"open\" : \"closed\",\n context: {\n closeOnInteractOutside: true,\n closeOnEsc: true,\n autoFocus: true,\n modal: false,\n portalled: true,\n positioning: {\n placement: \"bottom\",\n ...ctx.positioning,\n },\n currentPlacement: undefined,\n ...ctx,\n renderedElements: {\n title: true,\n description: true,\n },\n },\n\n computed: {\n currentPortalled: (ctx) => !!ctx.modal || !!ctx.portalled,\n },\n\n watch: {\n open: [\"toggleVisibility\"],\n },\n\n entry: [\"checkRenderedElements\"],\n\n states: {\n closed: {\n on: {\n TOGGLE: {\n target: \"open\",\n actions: [\"invokeOnOpen\"],\n },\n OPEN: {\n target: \"open\",\n actions: [\"invokeOnOpen\"],\n },\n },\n },\n\n open: {\n activities: [\n \"trapFocus\",\n \"preventScroll\",\n \"hideContentBelow\",\n \"trackPositioning\",\n \"trackDismissableElement\",\n \"proxyTabFocus\",\n ],\n entry: [\"setInitialFocus\"],\n on: {\n CLOSE: {\n target: \"closed\",\n actions: [\"invokeOnClose\"],\n },\n REQUEST_CLOSE: {\n target: \"closed\",\n actions: [\"restoreFocusIfNeeded\", \"invokeOnClose\"],\n },\n TOGGLE: {\n target: \"closed\",\n actions: [\"invokeOnClose\"],\n },\n SET_POSITIONING: {\n actions: \"setPositioning\",\n },\n },\n },\n },\n },\n {\n activities: {\n trackPositioning(ctx) {\n ctx.currentPlacement = ctx.positioning.placement\n const anchorEl = dom.getAnchorEl(ctx) ?? dom.getTriggerEl(ctx)\n const getPositionerEl = () => dom.getPositionerEl(ctx)\n return getPlacement(anchorEl, getPositionerEl, {\n ...ctx.positioning,\n defer: true,\n onComplete(data) {\n ctx.currentPlacement = data.placement\n },\n onCleanup() {\n ctx.currentPlacement = undefined\n },\n })\n },\n trackDismissableElement(ctx, _evt, { send }) {\n const getContentEl = () => dom.getContentEl(ctx)\n let restoreFocus = true\n return trackDismissableElement(getContentEl, {\n pointerBlocking: ctx.modal,\n exclude: dom.getTriggerEl(ctx),\n defer: true,\n onEscapeKeyDown(event) {\n ctx.onEscapeKeyDown?.(event)\n if (ctx.closeOnEsc) return\n event.preventDefault()\n },\n onInteractOutside(event) {\n ctx.onInteractOutside?.(event)\n if (event.defaultPrevented) return\n restoreFocus = !(event.detail.focusable || event.detail.contextmenu)\n if (!ctx.closeOnInteractOutside) {\n event.preventDefault()\n }\n },\n onPointerDownOutside: ctx.onPointerDownOutside,\n onFocusOutside: ctx.onFocusOutside,\n onDismiss() {\n send({ type: \"REQUEST_CLOSE\", src: \"interact-outside\", restoreFocus })\n },\n })\n },\n proxyTabFocus(ctx) {\n if (ctx.modal || !ctx.portalled) return\n const getContentEl = () => dom.getContentEl(ctx)\n return proxyTabFocus(getContentEl, {\n triggerElement: dom.getTriggerEl(ctx),\n defer: true,\n onFocus(el) {\n el.focus({ preventScroll: true })\n },\n })\n },\n hideContentBelow(ctx) {\n if (!ctx.modal) return\n const getElements = () => [dom.getContentEl(ctx), dom.getTriggerEl(ctx)]\n return ariaHidden(getElements, { defer: true })\n },\n preventScroll(ctx) {\n if (!ctx.modal) return\n return preventBodyScroll(dom.getDoc(ctx))\n },\n trapFocus(ctx) {\n if (!ctx.modal) return\n let trap: FocusTrap | undefined\n nextTick(() => {\n const el = dom.getContentEl(ctx)\n if (!el) return\n trap = createFocusTrap(el, {\n escapeDeactivates: false,\n allowOutsideClick: true,\n preventScroll: true,\n returnFocusOnDeactivate: true,\n document: dom.getDoc(ctx),\n fallbackFocus: el,\n initialFocus: runIfFn(ctx.initialFocusEl),\n })\n try {\n trap.activate()\n } catch {}\n })\n return () => trap?.deactivate()\n },\n },\n actions: {\n setPositioning(ctx, evt) {\n const anchorEl = dom.getAnchorEl(ctx) ?? dom.getTriggerEl(ctx)\n const getPositionerEl = () => dom.getPositionerEl(ctx)\n getPlacement(anchorEl, getPositionerEl, {\n ...ctx.positioning,\n ...evt.options,\n defer: true,\n listeners: false,\n })\n },\n checkRenderedElements(ctx) {\n raf(() => {\n Object.assign(ctx.renderedElements, {\n title: !!dom.getTitleEl(ctx),\n description: !!dom.getDescriptionEl(ctx),\n })\n })\n },\n setInitialFocus(ctx) {\n raf(() => {\n dom.getInitialFocusEl(ctx)?.focus({ preventScroll: true })\n })\n },\n restoreFocusIfNeeded(ctx, evt) {\n if (!evt.restoreFocus) return\n raf(() => {\n dom.getTriggerEl(ctx)?.focus({ preventScroll: true })\n })\n },\n invokeOnOpen(ctx) {\n ctx.onOpen?.()\n },\n invokeOnClose(ctx) {\n ctx.onClose?.()\n },\n toggleVisibility(ctx, _evt, { send }) {\n send({ type: ctx.open ? \"OPEN\" : \"CLOSE\", src: \"controlled\" })\n },\n },\n },\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAgD,cAAc;;;ACO9D,SAAS,WAAW,SAAS,OAAO,gBAAgB,cAAc,UAAU,gBAAgB;;;AEPrF,IAAMA,iBAAgB,CAAC,YAC5B,OAAO,YAAY,YAAY,YAAY,QAAQ,QAAQ,aAAa;AAEnE,IAAM,UAAU,CAAC,YACtBA,eAAc,OAAO,KAAK,QAAQ,YAAY;AAEzC,SAAS,UAAU,IAAS;AACjC,MAAI,CAACA,eAAc,EAAE;AAAG,WAAO;AAC/B,SAAO,GAAG,cAAc,KAAK,GAAG,eAAe,KAAK,GAAG,eAAe,EAAE,SAAS;AACnF;AAIO,SAAS,oBAAoB,SAAkB;AACpD,QAAM,WAAW,SAAS,QAAQ,aAAa,UAAU,KAAK,KAAK,EAAE;AACrE,SAAO,WAAW;AACpB;AAEO,IAAM,oBACG;ACbT,IAAM,gBAAgB,CAC3B,WACA,mBAAyC,UACtC;AACH,MAAI,CAAC;AAAW,WAAO,CAAC;AACxB,QAAM,WAAW,MAAM,KAAK,UAAU,iBAA8B,iBAAiB,CAAC;AAEtF,QAAM,UAAU,oBAAoB,QAAS,oBAAoB,cAAc,SAAS,WAAW;AACnG,MAAI,WAAWA,eAAc,SAAS,KAAK,YAAY,SA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,eAAe,CAAC;AAAA,YAC/B,WAAW;AAAA,cACT;AAAA,cACA;AAAA,cACA,aAAa;AAAA,YACf;AAAA,YAEC;AAAA;AAAA,QACH;AAAA,MAEJ;AAAA,MACA,oBAAoB;AAAA,QAClB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA,MACJ,aAAa;AAAA,QACX,GAAG;AAAA,QACH,WAAW,cAAc,SAAS,SAAY;AAAA,MAChD;AAAA,MACA;AAAA,MAEC,WAAC,EAAE,aAAa,MAAM;AACrB,eACE,gBAAAA;AAAA,UAAC;AAAA;AAAA,YACC,WAAU;AAAA,YACT,GAAG;AAAA,YAEH;AAAA;AAAA,QACH;AAAA,MAEJ;AAAA;AAAA,EACF;AAEJ;","names":["isHTMLElement","root","handler","getDocument","node","contains","candidateSelectors","candidateSelector","join","NoElement","Element","matches","prototype","msMatchesSelector","webkitMatchesSelector","getRootNode","element","_element$getRootNode","call","ownerDocument","isInert","node","lookUp","_node$getAttribute","inertAtt","getAttribute","inert","result","parentNode","isContentEditable","_node$getAttribute2","attValue","getCandidates","el","includeContainer","filter","candidates","Array","slice","apply","querySelectorAll","unshift","getCandidatesIteratively","elements","options","elementsToCheck","from","length","shift","tagName","assigned","assignedElements","content","children","nestedCandidates","flatten","push","scopeParent","validCandidate","includes","shadowRoot","getShadowRoot","validShadowRoot","shadowRootFilter","hasTabIndex","isNaN","parseInt","getTabIndex","Error","tabIndex","test","getSortOrderTabIndex","isScope","sortOrderedTabbables","a","b","documentOrder","isInput","isHiddenInput","type","isDetailsWithSummary","r","some","child","getCheckedRadio","nodes","form","i","checked","isTabbableRadio","name","radioScope","queryRadios","radioSet","window","CSS","escape","err","console","error","message","isRadio","isNonTabbableRadio","isNodeAttached","_nodeRoot","nodeRoot","nodeRootHost","host","attached","_nodeRootHost","_nodeRootHost$ownerDo","_node$ownerDocument","contains","_nodeRoot2","_nodeRootHost2","_nodeRootHost2$ownerD","isZeroArea","_node$getBoundingClie","getBoundingClientRect","width","height","isHidden","_ref","displayCheck","getComputedStyle","visibility","isDirectSummary","nodeUnderDetails","parentElement","originalNode","rootNode","assignedSlot","getClientRects","isDisabledFromFieldset","disabled","item","isNodeMatchingSelectorFocusable","isNodeMatchingSelectorTabbable","isValidShadowRootTabbable","shadowHostNode","sortByOrder","regularTabbables","orderedTabbables","forEach","candidateTabindex","sort","reduce","acc","sortable","concat","tabbable","container","bind","focusable","isTabbable","focusableCandidateSelector","isFocusable","activeFocusTraps","activateTrap","trapStack","trap","length","activeTrap","pause","trapIndex","indexOf","push","splice","deactivateTrap","unpause","isSelectableInput","node","tagName","toLowerCase","select","isEscapeEvent","e","key","keyCode","isTabEvent","isKeyForward","shiftKey","isKeyBackward","delay","fn","setTimeout","findIndex","arr","idx","every","value","i","valueOrHandler","_len","arguments","params","Array","_key","apply","getActualTarget","event","target","shadowRoot","composedPath","internalTrapStack","createFocusTrap","elements","userOptions","doc","document","config","_objectSpread","returnFocusOnDeactivate","escapeDeactivates","delayInitialFocus","state","containers","containerGroups","tabbableGroups","nodeFocusedBeforeActivation","mostRecentlyFocusedNode","active","paused","delayInitialFocusTimer","undefined","recentNavEvent","getOption","configOverrideOptions","optionName","configOptionName","findContainerIndex","element","_ref","container","tabbableNodes","contains","includes","find","getNodeForOption","optionValue","_len2","_key2","Error","concat","querySelector","getInitialFocusNode","isFocusable","tabbableOptions","activeElement","firstTabbableGroup","firstTabbableNode","updateTabbableNodes","map","tabbable","focusableNodes","focusable","lastTabbableNode","firstDomTabbableNode","isTabbable","lastDomTabbableNode","slice","reverse","posTabIndexesFound","getTabIndex","nextTabbableNode","forward","nodeIdx","el","filter","group","g","tryFocus","focus","preventScroll","getReturnFocusNode","previousActiveElement","findNextNavNode","_ref2","_ref2$isBackward","isBackward","destinationNode","containerIndex","containerGroup","startOfGroupIndex","_ref3","destinationGroupIndex","destinationGroup","lastOfGroupIndex","_ref4","checkPointerDown","clickOutsideDeactivates","deactivate","returnFocus","allowOutsideClick","preventDefault","checkFocusIn","targetContained","Document","stopImmediatePropagation","nextNode","navAcrossContainers","mruContainerIdx","mruTabIdx","some","n","checkKeyNav","checkKey","checkClick","addListeners","addEventListener","capture","passive","removeListeners","removeEventListener","checkDomRemoval","mutations","isFocusedNodeRemoved","mutation","removedNodes","from","mutationObserver","window","MutationObserver","updateObservedNodes","disconnect","observe","subtree","childList","activate","activateOptions","onActivate","onPostActivate","checkCanFocusTrap","finishActivation","then","deactivateOptions","options","onDeactivate","onPostDeactivate","checkCanReturnFocus","clearTimeout","finishDeactivation","pauseOptions","onPause","onPostPause","unpauseOptions","onUnpause","onPostUnpause","updateContainerElements","containerElements","elementsAsArray","Boolean","ctx","runIfFn","jsx","Popover"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Popover
3
- } from "../../chunk-3PF5QYAQ.js";
3
+ } from "../../chunk-WOX3LUVT.js";
4
4
  import "../../chunk-BMO4IZHV.js";
5
5
  import "../../chunk-LRCAKRPK.js";
6
6
  import "../../chunk-H7V2CGOB.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Popover
3
- } from "../../chunk-3PF5QYAQ.js";
3
+ } from "../../chunk-WOX3LUVT.js";
4
4
  import "../../chunk-BMO4IZHV.js";
5
5
  import "../../chunk-LRCAKRPK.js";
6
6
  import "../../chunk-H7V2CGOB.js";
@@ -29,7 +29,17 @@ var CustomOption = ({ onChange, mode, ...props }) => {
29
29
  /* @__PURE__ */ jsx(
30
30
  "input",
31
31
  {
32
- className: clsx("w-0 flex-1"),
32
+ style: { visibility: "hidden" },
33
+ className: "w-0 h-0 absolute",
34
+ autoFocus: true
35
+ }
36
+ ),
37
+ /* @__PURE__ */ jsx(
38
+ "input",
39
+ {
40
+ className: clsx(
41
+ "w-0 flex-1 outline-none rounded-3px focus:border-#1E3DE4"
42
+ ),
33
43
  onChange: (e) => onChange(e.target.value),
34
44
  ...props
35
45
  }
@@ -103,6 +113,9 @@ var DecimalsSelect = ({
103
113
  onOpen: () => setOpen(true),
104
114
  onClose: () => setOpen(false),
105
115
  open,
116
+ positioning: {
117
+ placement: "auto"
118
+ },
106
119
  children: /* @__PURE__ */ jsxs(
107
120
  "div",
108
121
  {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/DecimalsSelect/index.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport clsx from 'clsx';\nimport { Popover } from '../Popover';\nimport { Check, ChevronUp } from 'lucide-react';\n\nconst Value: React.FC<{\n value?: number;\n mode: 'decimals' | 'pow';\n}> = ({ mode, value }) => {\n if (mode === 'pow')\n return (\n <span>\n 10 <sup>{value}</sup>\n </span>\n );\n return value;\n};\n\nconst CustomOption: React.FC<{\n onChange: (value: string) => void;\n value?: number | string;\n mode: 'decimals' | 'pow';\n}> = ({ onChange, mode, ...props }) => {\n return (\n <div className=\"w-full flex items-center gap-10px\">\n {mode === 'pow' && '10^'}\n <input\n className={clsx('w-0 flex-1')}\n onChange={e => onChange(e.target.value)}\n {...props}\n />\n </div>\n );\n};\n\nconst defaultOptions = [18, 8, 6];\n\ntype DecimalsSelectProps = {\n value?: number;\n onChange: (value?: number) => void;\n max?: number;\n placeholder?: string;\n className?: string;\n optionsClassName?: string;\n popoverClassName?: string;\n mode?: 'decimals' | 'pow';\n options?: number[];\n};\n\nexport const DecimalsSelect = ({\n max,\n onChange,\n optionsClassName,\n popoverClassName,\n className,\n placeholder,\n value,\n options = defaultOptions,\n mode = 'decimals',\n}: DecimalsSelectProps) => {\n const [open, setOpen] = useState(false);\n const [selected, setSelected] = useState(() =>\n options.find(option => option === value),\n );\n const handleDecimalsChange = (value: string) => {\n if (!value) {\n onChange(undefined);\n return;\n }\n let num = Number(value);\n if (value.includes('-') || value.includes('.') || isNaN(num)) return;\n if (max && num > max) num = max;\n if (num < 0) num = 0;\n setSelected(undefined);\n onChange(num);\n };\n return (\n <Popover\n content={\n <div className=\"flex flex-col gap-8px w-76px\">\n {options.map(option => (\n <div\n className={clsx(\n 'cursor-pointer bg-[#fff] hover:bg-[#f1f3f5] w-full flex items-center justify-between',\n optionsClassName,\n )}\n key={option}\n onClick={() => {\n setSelected(option);\n onChange(option);\n setOpen(false);\n }}\n >\n <Value mode={mode} value={option} />\n {option === selected && <Check className=\"w-16px h-16px\" />}\n </div>\n ))}\n <div className={clsx('bg-[#fff] w-full', optionsClassName)}>\n <CustomOption\n onChange={handleDecimalsChange}\n value={selected === undefined && value !== undefined ? value : ''}\n mode={mode}\n />\n </div>\n </div>\n }\n containerClassName={popoverClassName}\n onOpen={() => setOpen(true)}\n onClose={() => setOpen(false)}\n open={open}\n >\n <div\n className={clsx(\n 'inline-flex justify-between items-center px-8px h-24px w-100px cursor-pointer',\n 'border-1 border-solid border-#E8E9EA rounded-2px',\n className,\n )}\n >\n <span>\n {value === undefined ? (\n placeholder\n ) : (\n <Value mode={mode} value={value} />\n )}\n </span>\n <ChevronUp className={clsx('w-12px h-12px', !open && 'rotate-180')} />\n </div>\n </Popover>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAgB,gBAAgB;AAChC,OAAO,UAAU;AAEjB,SAAS,OAAO,iBAAiB;AAQ3B,SACK,KADL;AANN,IAAM,QAGD,CAAC,EAAE,MAAM,MAAM,MAAM;AACxB,MAAI,SAAS;AACX,WACE,qBAAC,UAAK;AAAA;AAAA,MACD,oBAAC,SAAK,iBAAM;AAAA,OACjB;AAEJ,SAAO;AACT;AAEA,IAAM,eAID,CAAC,EAAE,UAAU,MAAM,GAAG,MAAM,MAAM;AACrC,SACE,qBAAC,SAAI,WAAU,qCACZ;AAAA,aAAS,SAAS;AAAA,IACnB;AAAA,MAAC;AAAA;AAAA,QACC,WAAW,KAAK,YAAY;AAAA,QAC5B,UAAU,OAAK,SAAS,EAAE,OAAO,KAAK;AAAA,QACrC,GAAG;AAAA;AAAA,IACN;AAAA,KACF;AAEJ;AAEA,IAAM,iBAAiB,CAAC,IAAI,GAAG,CAAC;AAczB,IAAM,iBAAiB,CAAC;AAAA,EAC7B;AAAA,E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AM,QAAQ,KAAK;AAAA,MAC5B;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACC,WAAW;AAAA,YACT;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,UAEA;AAAA,gCAAC,UACE,oBAAU,SACT,cAEA,oBAAC,SAAM,MAAY,OAAc,GAErC;AAAA,YACA,oBAAC,aAAU,WAAW,KAAK,iBAAiB,CAAC,QAAQ,YAAY,GAAG;AAAA;AAAA;AAAA,MACtE;AAAA;AAAA,EACF;AAEJ;","names":["value"]}
1
+ {"version":3,"sources":["../../../src/components/DecimalsSelect/index.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport clsx from 'clsx';\nimport { Popover } from '../Popover';\nimport { Check, ChevronUp } from 'lucide-react';\n\nconst Value: React.FC<{\n value?: number;\n mode: 'decimals' | 'pow';\n}> = ({ mode, value }) => {\n if (mode === 'pow')\n return (\n <span>\n 10 <sup>{value}</sup>\n </span>\n );\n return value;\n};\n\nconst CustomOption: React.FC<{\n onChange: (value: string) => void;\n value?: number | string;\n mode: 'decimals' | 'pow';\n}> = ({ onChange, mode, ...props }) => {\n return (\n <div className=\"w-full flex items-center gap-10px\">\n {mode === 'pow' && '10^'}\n <input\n style={{ visibility: 'hidden' }}\n className=\"w-0 h-0 absolute\"\n autoFocus\n />\n <input\n className={clsx(\n 'w-0 flex-1 outline-none rounded-3px focus:border-#1E3DE4',\n )}\n onChange={e => onChange(e.target.value)}\n {...props}\n />\n </div>\n );\n};\n\nconst defaultOptions = [18, 8, 6];\n\ntype DecimalsSelectProps = {\n value?: number;\n onChange: (value?: number) => void;\n max?: number;\n placeholder?: string;\n className?: string;\n optionsClassName?: string;\n popoverClassName?: string;\n mode?: 'decimals' | 'pow';\n options?: number[];\n};\n\nexport const DecimalsSelect = ({\n max,\n onChange,\n optionsClassName,\n popoverClassName,\n className,\n placeholder,\n value,\n options = defaultOptions,\n mode = 'decimals',\n}: DecimalsSelectProps) => {\n const [open, setOpen] = useState(false);\n const [selected, setSelected] = useState(() =>\n options.find(option => option === value),\n );\n const handleDecimalsChange = (value: string) => {\n if (!value) {\n onChange(undefined);\n return;\n }\n let num = Number(value);\n if (value.includes('-') || value.includes('.') || isNaN(num)) return;\n if (max && num > max) num = max;\n if (num < 0) num = 0;\n setSelected(undefined);\n onChange(num);\n };\n return (\n <Popover\n content={\n <div className=\"flex flex-col gap-8px w-76px\">\n {options.map(option => (\n <div\n className={clsx(\n 'cursor-pointer bg-[#fff] hover:bg-[#f1f3f5] w-full flex items-center justify-between',\n optionsClassName,\n )}\n key={option}\n onClick={() => {\n setSelected(option);\n onChange(option);\n setOpen(false);\n }}\n >\n <Value mode={mode} value={option} />\n {option === selected && <Check className=\"w-16px h-16px\" />}\n </div>\n ))}\n <div className={clsx('bg-[#fff] w-full', optionsClassName)}>\n <CustomOption\n onChange={handleDecimalsChange}\n value={selected === undefined && value !== undefined ? value : ''}\n mode={mode}\n />\n </div>\n </div>\n }\n containerClassName={popoverClassName}\n onOpen={() => setOpen(true)}\n onClose={() => setOpen(false)}\n open={open}\n positioning={{\n placement: 'auto',\n }}\n >\n <div\n className={clsx(\n 'inline-flex justify-between items-center px-8px h-24px w-100px cursor-pointer',\n 'border-1 border-solid border-#E8E9EA rounded-2px',\n className,\n )}\n >\n <span>\n {value === undefined ? (\n placeholder\n ) : (\n <Value mode={mode} value={value} />\n )}\n </span>\n <ChevronUp className={clsx('w-12px h-12px', !open && 'rotate-180')} />\n </div>\n </Popover>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAgB,gBAAgB;AAChC,OAAO,UAAU;AAEjB,SAAS,OAAO,iBAAiB;AAQ3B,SACK,KADL;AANN,IAAM,QAGD,CAAC,EAAE,MAAM,MAAM,MAAM;AACxB,MAAI,SAAS;AACX,WACE,qBAAC,UAAK;AAAA;AAAA,MACD,oBAAC,SAAK,iBAAM;AAAA,OACjB;AAEJ,SAAO;AACT;AAEA,IAAM,eAID,CAAC,EAAE,UAAU,MAAM,GAAG,MAAM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ACf,sBAAQ,KAAK;AAAA,YACf;AAAA,YAEA;AAAA,kCAAC,SAAM,MAAY,OAAO,QAAQ;AAAA,cACjC,WAAW,YAAY,oBAAC,SAAM,WAAU,iBAAgB;AAAA;AAAA;AAAA,UARpD;AAAA,QASP,CACD;AAAA,QACD,oBAAC,SAAI,WAAW,KAAK,oBAAoB,gBAAgB,GACvD;AAAA,UAAC;AAAA;AAAA,YACC,UAAU;AAAA,YACV,OAAO,aAAa,UAAa,UAAU,SAAY,QAAQ;AAAA,YAC/D;AAAA;AAAA,QACF,GACF;AAAA,SACF;AAAA,MAEF,oBAAoB;AAAA,MACpB,QAAQ,MAAM,QAAQ,IAAI;AAAA,MAC1B,SAAS,MAAM,QAAQ,KAAK;AAAA,MAC5B;AAAA,MACA,aAAa;AAAA,QACX,WAAW;AAAA,MACb;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACC,WAAW;AAAA,YACT;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,UAEA;AAAA,gCAAC,UACE,oBAAU,SACT,cAEA,oBAAC,SAAM,MAAY,OAAc,GAErC;AAAA,YACA,oBAAC,aAAU,WAAW,KAAK,iBAAiB,CAAC,QAAQ,YAAY,GAAG;AAAA;AAAA;AAAA,MACtE;AAAA;AAAA,EACF;AAEJ;","names":["value"]}
@@ -1,13 +1,16 @@
1
1
  import React__default, { ComponentProps, HTMLAttributes } from 'react';
2
- import _Popover from '@cfx-kit/ui-components/dist/Popover';
2
+ import _Popover, { PositioningOptions } from '@cfx-kit/ui-components/dist/Popover';
3
3
 
4
- interface PopoverProps extends Omit<ComponentProps<typeof _Popover>, 'trigger'> {
4
+ type PopoverProps = Omit<ComponentProps<typeof _Popover>, 'trigger' | 'positioning'> & {
5
5
  containerClassName?: string;
6
6
  content?: React__default.ReactNode;
7
7
  children?: React__default.ReactNode;
8
8
  triggerProps?: HTMLAttributes<HTMLElement>;
9
9
  className?: string;
10
- }
10
+ positioning?: Omit<PositioningOptions, 'placement'> & {
11
+ placement?: PositioningOptions['placement'] | 'auto';
12
+ };
13
+ };
11
14
  declare const Popover: React__default.FC<PopoverProps>;
12
15
 
13
16
  export { Popover, PopoverProps };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Popover
3
- } from "../../chunk-3PF5QYAQ.js";
3
+ } from "../../chunk-WOX3LUVT.js";
4
4
  import "../../chunk-BMO4IZHV.js";
5
5
  import "../../chunk-LRCAKRPK.js";
6
6
  import "../../chunk-H7V2CGOB.js";
package/dist/uno.css CHANGED
@@ -111,6 +111,7 @@
111
111
  .h-\[8px\]{height:8px;}
112
112
  .h-\[920px\]{height:920px;}
113
113
  .h-\[var\(--radix-select-trigger-height\)\]{height:var(--radix-select-trigger-height);}
114
+ .h-0{height:0;}
114
115
  .h-1\.5714rem{height:1.5714rem;}
115
116
  .h-10{height:2.5rem;}
116
117
  .h-12{height:3rem;}
@@ -269,6 +270,7 @@
269
270
  .border-\#E8E9EA{--un-border-opacity:1;border-color:rgb(232 233 234 / var(--un-border-opacity));}
270
271
  .border-transparent{border-color:transparent;}
271
272
  .\[\&\>a\]\:hover\:border-\#fff:hover>a{--un-border-opacity:1;border-color:rgb(255 255 255 / var(--un-border-opacity));}
273
+ .focus\:border-\#1E3DE4:focus{--un-border-opacity:1;border-color:rgb(30 61 228 / var(--un-border-opacity));}
272
274
  .border-b-\#e8e9ea{--un-border-opacity:1;--un-border-bottom-opacity:var(--un-border-opacity);border-bottom-color:rgb(232 233 234 / var(--un-border-bottom-opacity));}
273
275
  .after\:border-l-\#EFF2FA::after{--un-border-opacity:1;--un-border-left-opacity:var(--un-border-opacity);border-left-color:rgb(239 242 250 / var(--un-border-left-opacity));}
274
276
  .rounded{border-radius:0.25rem;}
@@ -280,6 +282,7 @@
280
282
  .rounded-0\.2857rem{border-radius:0.2857rem;}
281
283
  .rounded-12px{border-radius:12px;}
282
284
  .rounded-2px{border-radius:2px;}
285
+ .rounded-3px{border-radius:3px;}
283
286
  .rounded-50\%{border-radius:50%;}
284
287
  .rounded-full{border-radius:9999px;}
285
288
  .rounded-lg{border-radius:0.5rem;}
@@ -7,7 +7,7 @@ interface AddressCache {
7
7
  [key: string]: unknown;
8
8
  }
9
9
  declare const ADDRESS_FUNC_CACHE: AddressCache;
10
- declare const convertCheckSum: <T extends LooseAddressType>(address: T) => `0x${string}` | T;
10
+ declare const convertCheckSum: <T extends LooseAddressType>(address: T) => T | `0x${string}`;
11
11
  declare const isCoreMainOrTestAddress: (address: LooseAddressType) => boolean;
12
12
  declare const isCoreMainnetAddress: (address: LooseAddressType) => boolean;
13
13
  declare const isCoreTestnetAddress: (address: LooseAddressType) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfxjs/sirius-next-common",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist/**"
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/Popover/index.tsx","../../../node_modules/.pnpm/@cfx-kit+ui-components@0.0.18_@zag-js+accordion@0.19.1_@zag-js+checkbox@0.19.1_@zag-js+dialog_toqhwacqm4ck723ovqekq5mm7u/node_modules/@cfx-kit/ui-components/dist/Popover.js","../../../node_modules/.pnpm/@zag-js+tabbable@0.19.1/node_modules/@zag-js/tabbable/src/proxy-tab-focus.ts","../../../node_modules/.pnpm/@zag-js+tabbable@0.19.1/node_modules/@zag-js/tabbable/src/shared.ts","../../../node_modules/.pnpm/@zag-js+tabbable@0.19.1/node_modules/@zag-js/tabbable/src/focusable.ts","../../../node_modules/.pnpm/@zag-js+tabbable@0.19.1/node_modules/@zag-js/tabbable/src/tabbable.ts","../../../node_modules/.pnpm/@zag-js+aria-hidden@0.19.1/node_modules/@zag-js/aria-hidden/src/index.ts","../../../node_modules/.pnpm/@zag-js+interact-outside@0.19.1/node_modules/@zag-js/interact-outside/src/index.ts","../../../node_modules/.pnpm/@zag-js+interact-outside@0.19.1/node_modules/@zag-js/interact-outside/src/get-window-frames.ts","../../../node_modules/.pnpm/@zag-js+dismissable@0.19.1/node_modules/@zag-js/dismissable/src/dismissable-layer.ts","../../../node_modules/.pnpm/@zag-js+dismissable@0.19.1/node_modules/@zag-js/dismissable/src/escape-keydown.ts","../../../node_modules/.pnpm/@zag-js+dismissable@0.19.1/node_modules/@zag-js/dismissable/src/layer-stack.ts","../../../node_modules/.pnpm/@zag-js+dismissable@0.19.1/node_modules/@zag-js/dismissable/src/pointer-event-outside.ts","../../../node_modules/.pnpm/@zag-js+remove-scroll@0.19.1/node_modules/@zag-js/remove-scroll/src/index.ts","../../../node_modules/.pnpm/tabbable@6.2.0/node_modules/tabbable/src/index.js","../../../node_modules/.pnpm/focus-trap@7.5.2/node_modules/focus-trap/index.js","../../../node_modules/.pnpm/@zag-js+popover@0.19.1/node_modules/@zag-js/popover/src/popover.anatomy.ts","../../../node_modules/.pnpm/@zag-js+popover@0.19.1/node_modules/@zag-js/popover/src/popover.connect.ts","../../../node_modules/.pnpm/@zag-js+popover@0.19.1/node_modules/@zag-js/popover/src/popover.dom.ts","../../../node_modules/.pnpm/@zag-js+popover@0.19.1/node_modules/@zag-js/popover/src/popover.machine.ts"],"sourcesContent":["import React, { HTMLAttributes, ComponentProps, useRef } from 'react';\nimport _Popover from '@cfx-kit/ui-components/dist/Popover';\nimport clsx from 'clsx';\nimport { cn } from 'src/utils';\n\nexport interface PopoverProps\n extends Omit<ComponentProps<typeof _Popover>, 'trigger'> {\n containerClassName?: string;\n content?: React.ReactNode;\n children?: React.ReactNode;\n triggerProps?: HTMLAttributes<HTMLElement>;\n className?: string;\n}\n\nexport const Popover: React.FC<PopoverProps> = ({\n content,\n children = null,\n positioning = {},\n className,\n containerClassName,\n arrow = true,\n ...rest\n}) => {\n const { placement = 'top' } = positioning;\n const triggerRef = useRef<HTMLSpanElement>(null);\n return (\n <_Popover\n trigger={({ triggerProps }) => {\n return (\n <span\n ref={triggerRef}\n {...(content ? triggerProps : {})}\n className={cn(\n 'sirius-popover-trigger',\n className,\n triggerProps.className,\n )}\n >\n {children}\n </span>\n );\n }}\n containerClassName={clsx(\n 'sirius-popover-container',\n 'text-#333 text-14px lh-[1.5715] font-400 ws-normal cursor-auto text-left select-text absolute top-0 left-0 z-1030 text-transform-none filter-drop-shadow',\n '[&>[data-part=arrow]]:[--arrow-size:12px] [&>[data-part=arrow]]:[--arrow-background:#fff] [&>[data-part=arrow]]:[--arrow-shadow-color:gray]',\n containerClassName,\n )}\n {...rest}\n positioning={{\n ...positioning,\n placement,\n }}\n arrow={arrow}\n >\n {({ contentProps }) => {\n return (\n <div\n className=\"sirius-popover-content px-12px py-16px shadow decoration-none rounded-5px bg-#fff bg-clip-padding\"\n {...contentProps}\n >\n {content}\n </div>\n );\n }}\n </_Popover>\n );\n};\n","import {\n __objRest,\n __spreadProps,\n __spreadValues\n} from \"./chunk-W7QWXYJO.js\";\n\n// src/Popover/index.tsx\nimport { useEffect, useMemo, useId, isValidElement, cloneElement, Children, Fragment } from \"react\";\nimport { machine, connect } from \"@zag-js/popover\";\nimport { useMachine, normalizeProps, Portal } from \"@zag-js/react\";\nimport { Fragment as Fragment2, jsx, jsxs } from \"react/jsx-runtime\";\nvar Popover = (_a) => {\n var _b = _a, {\n id,\n open,\n closeOnEsc = true,\n closeOnInteractOutside = true,\n arrow = false,\n children,\n containerClassName,\n trigger\n } = _b, props = __objRest(_b, [\n \"id\",\n \"open\",\n \"closeOnEsc\",\n \"closeOnInteractOutside\",\n \"arrow\",\n \"children\",\n \"containerClassName\",\n \"trigger\"\n ]);\n const uniqueId = useId();\n const [state, send] = useMachine(machine(__spreadValues({ id: id != null ? id : uniqueId, closeOnEsc, closeOnInteractOutside }, props)));\n const api = connect(state, send, normalizeProps);\n const Wrapper = useMemo(() => api.portalled ? Portal : Fragment, [api.portalled]);\n useEffect(() => {\n if (open === true) {\n api.open();\n } else {\n api.close();\n }\n }, [open]);\n return /* @__PURE__ */ jsxs(Fragment2, { children: [\n typeof trigger === \"function\" ? trigger({ triggerProps: api.triggerProps, isOpen: api.isOpen }) : null,\n api.isOpen && /* @__PURE__ */ jsx(Wrapper, { children: /* @__PURE__ */ jsxs(\"div\", __spreadProps(__spreadValues({ className: `ui-popover${containerClassName ? ` ${containerClassName}` : \"\"}` }, api.positionerProps), { children: [\n arrow && /* @__PURE__ */ jsx(\"div\", __spreadProps(__spreadValues({}, api.arrowProps), { children: /* @__PURE__ */ jsx(\"div\", __spreadValues({}, api.arrowTipProps)) })),\n typeof children === \"function\" && children({ contentProps: api.contentProps, closeTriggerProps: api.closeTriggerProps, close: api.close }),\n typeof children !== \"function\" ? Children.count(children) === 1 && isValidElement(children) ? cloneElement(children, __spreadValues({}, api.contentProps)) : /* @__PURE__ */ jsx(\"div\", __spreadProps(__spreadValues({}, api.contentProps), { children })) : null\n ] })) })\n ] });\n};\nvar Popover_default = Popover;\nexport {\n Popover_default as default\n};\n","import { raf } from \"@zag-js/dom-query\"\nimport { getNextTabbable, getTabbableEdges } from \"./tabbable\"\n\ntype MaybeElement = HTMLElement | null\ntype NodeOrFn = MaybeElement | (() => MaybeElement)\n\ntype ProxyTabFocusOptions<T = MaybeElement> = {\n triggerElement?: T\n onFocus?: (elementToFocus: HTMLElement) => void\n defer?: boolean\n}\n\n/**\n * Proxies tab focus within a container to a reference element\n * when the container is rendered in a portal\n */\n\nfunction proxyTabFocusImpl(container: MaybeElement, options: ProxyTabFocusOptions = {}) {\n const { triggerElement, onFocus } = options\n\n const doc = container?.ownerDocument || document\n const body = doc.body\n\n function onKeyDown(event: KeyboardEvent) {\n if (event.key !== \"Tab\") return\n\n let elementToFocus: MaybeElement | undefined = null\n\n // get all tabbable elements within the container\n const [firstTabbable, lastTabbable] = getTabbableEdges(container, true)\n\n const noTabbableElements = !firstTabbable && !lastTabbable\n\n // if we're focused on the first tabbable element and the user tabs backwards\n // we want to focus the reference element\n if (event.shiftKey && (doc.activeElement === firstTabbable || noTabbableElements)) {\n elementToFocus = triggerElement\n } else if (!event.shiftKey && doc.activeElement === triggerElement) {\n // if we're focused on the reference element and the user tabs forwards\n // we want to focus the first tabbable element\n elementToFocus = firstTabbable\n } else if (!event.shiftKey && (doc.activeElement === lastTabbable || noTabbableElements)) {\n // if we're focused on the last tabbable element and the user tabs forwards\n // we want to focus the next tabbable element after the reference element\n elementToFocus = getNextTabbable(body, triggerElement)\n }\n\n if (!elementToFocus) return\n\n event.preventDefault()\n\n onFocus?.(elementToFocus) ?? elementToFocus.focus()\n }\n\n // listen for the tab key in the capture phase\n doc?.addEventListener(\"keydown\", onKeyDown, true)\n\n return () => {\n doc?.removeEventListener(\"keydown\", onKeyDown, true)\n }\n}\n\nexport function proxyTabFocus(container: NodeOrFn, options: ProxyTabFocusOptions<NodeOrFn>) {\n const { defer, triggerElement, ...restOptions } = options\n const func = defer ? raf : (v: any) => v()\n const cleanups: (VoidFunction | undefined)[] = []\n cleanups.push(\n func(() => {\n const node = typeof container === \"function\" ? container() : container\n const trigger = typeof triggerElement === \"function\" ? triggerElement() : triggerElement\n cleanups.push(proxyTabFocusImpl(node, { triggerElement: trigger, ...restOptions }))\n }),\n )\n return () => {\n cleanups.forEach((fn) => fn?.())\n }\n}\n","export const isHTMLElement = (element: any): element is HTMLElement =>\n typeof element === \"object\" && element !== null && element.nodeType === 1\n\nexport const isFrame = (element: any): element is HTMLIFrameElement =>\n isHTMLElement(element) && element.tagName === \"IFRAME\"\n\nexport function isVisible(el: any) {\n if (!isHTMLElement(el)) return false\n return el.offsetWidth > 0 || el.offsetHeight > 0 || el.getClientRects().length > 0\n}\n\nexport type IncludeContainerType = boolean | \"if-empty\"\n\nexport function hasNegativeTabIndex(element: Element) {\n const tabIndex = parseInt(element.getAttribute(\"tabindex\") || \"0\", 10)\n return tabIndex < 0\n}\n\nexport const focusableSelector =\n /*#__PURE__*/ \"input:not([type='hidden']):not([disabled]), select:not([disabled]), \" +\n \"textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], \" +\n \"iframe, object, embed, area[href], audio[controls], video[controls], \" +\n \"[contenteditable]:not([contenteditable='false']), details > summary:first-of-type\"\n","import { focusableSelector, isFrame, isHTMLElement, isVisible, type IncludeContainerType } from \"./shared\"\n\n/**\n * Returns the focusable elements within the element\n */\n\nexport const getFocusables = (\n container: Pick<HTMLElement, \"querySelectorAll\"> | null,\n includeContainer: IncludeContainerType = false,\n) => {\n if (!container) return []\n const elements = Array.from(container.querySelectorAll<HTMLElement>(focusableSelector))\n\n const include = includeContainer == true || (includeContainer == \"if-empty\" && elements.length === 0)\n if (include && isHTMLElement(container) && isFocusable(container)) {\n elements.unshift(container)\n }\n\n const focusableElements = elements.filter(isFocusable)\n\n focusableElements.forEach((element, i) => {\n if (isFrame(element) && element.contentDocument) {\n const frameBody = element.contentDocument.body\n focusableElements.splice(i, 1, ...getFocusables(frameBody))\n }\n })\n\n return focusableElements\n}\n/**\n * Whether this element is focusable\n */\n\nexport function isFocusable(element: HTMLElement | null): element is HTMLElement {\n if (!element || element.closest(\"[inert]\")) return false\n return element.matches(focusableSelector) && isVisible(element)\n}\n\nexport function getFirstFocusable(container: HTMLElement, includeContainer?: IncludeContainerType) {\n const [first] = getFocusables(container, includeContainer)\n return first || null\n}\n","import { isFocusable } from \"./focusable\"\nimport { focusableSelector, hasNegativeTabIndex, isFrame, type IncludeContainerType } from \"./shared\"\n\n/**\n * Returns the tabbable elements within the element\n */\nexport function getTabbables(container: HTMLElement | null, includeContainer?: IncludeContainerType) {\n if (!container) return []\n const elements = Array.from(container.querySelectorAll<HTMLElement>(focusableSelector))\n const tabbableElements = elements.filter(isTabbable)\n\n if (includeContainer && isTabbable(container)) {\n tabbableElements.unshift(container)\n }\n\n tabbableElements.forEach((element, i) => {\n if (isFrame(element) && element.contentDocument) {\n const frameBody = element.contentDocument.body\n const allFrameTabbable = getTabbables(frameBody)\n tabbableElements.splice(i, 1, ...allFrameTabbable)\n }\n })\n\n if (!tabbableElements.length && includeContainer) {\n return elements\n }\n\n return tabbableElements\n}\n\n/**\n * Whether this element is tabbable\n */\nexport function isTabbable(el: HTMLElement | null): el is HTMLElement {\n if (el != null && el.tabIndex > 0) return true\n return isFocusable(el) && !hasNegativeTabIndex(el)\n}\n\n/**\n * Returns the first focusable element within the element\n */\nexport function getFirstTabbable(container: HTMLElement | null, includeContainer?: IncludeContainerType) {\n const [first] = getTabbables(container, includeContainer)\n return first || null\n}\n\n/**\n * Returns the last focusable element within the element\n */\nexport function getLastTabbable(container: HTMLElement | null, includeContainer?: IncludeContainerType) {\n const elements = getTabbables(container, includeContainer)\n return elements[elements.length - 1] || null\n}\n\n/**\n * Returns the first and last focusable elements within the element\n */\nexport function getTabbableEdges(container: HTMLElement | null, includeContainer?: IncludeContainerType) {\n const elements = getTabbables(container, includeContainer)\n const first = elements[0] || null\n const last = elements[elements.length - 1] || null\n return [first, last]\n}\n\n/**\n * Returns the next tabbable element after the current element\n */\nexport function getNextTabbable(container: HTMLElement | null, current?: HTMLElement | null) {\n const tabbables = getTabbables(container)\n const doc = container?.ownerDocument || document\n const currentElement = current ?? (doc.activeElement as HTMLElement | null)\n if (!currentElement) return null\n const index = tabbables.indexOf(currentElement)\n return tabbables[index + 1] || null\n}\n","// Credits: https://github.com/adobe/react-spectrum/blob/main/packages/@react-aria/overlays/src/ariaHideOutside.ts\nimport { raf } from \"@zag-js/dom-query\"\n\nconst refCountMap = new WeakMap<Element, number>()\nconst observerStack: any[] = []\n\nexport type AriaHiddenOptions = {\n rootEl?: HTMLElement\n defer?: boolean\n}\n\ntype MaybeElement = HTMLElement | null\ntype Targets = Array<MaybeElement>\ntype TargetsOrFn = Targets | (() => Targets)\n\nfunction ariaHiddenImpl(targets: Targets, options: AriaHiddenOptions = {}) {\n const { rootEl } = options\n\n const exclude = targets.filter(Boolean) as HTMLElement[]\n if (exclude.length === 0) return\n\n const doc = exclude[0].ownerDocument || document\n const win = doc.defaultView ?? window\n\n const visibleNodes = new Set<Element>(exclude)\n const hiddenNodes = new Set<Element>()\n\n const root = rootEl ?? doc.body\n\n let walk = (root: Element) => {\n // Keep live announcer and top layer elements (e.g. toasts) visible.\n for (let element of root.querySelectorAll(\"[data-live-announcer], [data-zag-top-layer]\")) {\n visibleNodes.add(element)\n }\n\n let acceptNode = (node: Element) => {\n // Skip this node and its children if it is one of the target nodes, or a live announcer.\n // Also skip children of already hidden nodes, as aria-hidden is recursive. An exception is\n // made for elements with role=\"row\" since VoiceOver on iOS has issues hiding elements with role=\"row\".\n // For that case we want to hide the cells inside as well (https://bugs.webkit.org/show_bug.cgi?id=222623).\n if (\n visibleNodes.has(node) ||\n (hiddenNodes.has(node.parentElement!) && node.parentElement!.getAttribute(\"role\") !== \"row\")\n ) {\n return NodeFilter.FILTER_REJECT\n }\n\n // Skip this node but continue to children if one of the targets is inside the node.\n for (let target of visibleNodes) {\n if (node.contains(target)) {\n return NodeFilter.FILTER_SKIP\n }\n }\n\n return NodeFilter.FILTER_ACCEPT\n }\n\n let walker = doc.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, { acceptNode })\n\n // TreeWalker does not include the root.\n let acceptRoot = acceptNode(root)\n if (acceptRoot === NodeFilter.FILTER_ACCEPT) {\n hide(root)\n }\n\n if (acceptRoot !== NodeFilter.FILTER_REJECT) {\n let node = walker.nextNode() as Element\n while (node != null) {\n hide(node)\n node = walker.nextNode() as Element\n }\n }\n }\n\n let hide = (node: Element) => {\n let refCount = refCountMap.get(node) ?? 0\n\n // If already aria-hidden, and the ref count is zero, then this element\n // was already hidden and there's nothing for us to do.\n if (node.getAttribute(\"aria-hidden\") === \"true\" && refCount === 0) {\n return\n }\n\n if (refCount === 0) {\n node.setAttribute(\"aria-hidden\", \"true\")\n }\n\n hiddenNodes.add(node)\n refCountMap.set(node, refCount + 1)\n }\n\n if (observerStack.length) {\n observerStack[observerStack.length - 1].disconnect()\n }\n\n walk(root)\n\n const observer = new win.MutationObserver((changes) => {\n for (let change of changes) {\n if (change.type !== \"childList\" || change.addedNodes.length === 0) {\n continue\n }\n\n // If the parent element of the added nodes is not within one of the targets,\n // and not already inside a hidden node, hide all of the new children.\n if (![...visibleNodes, ...hiddenNodes].some((node) => node.contains(change.target))) {\n for (let node of change.removedNodes) {\n if (node instanceof win.Element) {\n visibleNodes.delete(node)\n hiddenNodes.delete(node)\n }\n }\n\n for (let node of change.addedNodes) {\n if (\n (node instanceof win.HTMLElement || node instanceof win.SVGElement) &&\n (node.dataset.liveAnnouncer === \"true\" || node.dataset.zagTopLayer === \"true\")\n ) {\n visibleNodes.add(node)\n } else if (node instanceof win.Element) {\n walk(node)\n }\n }\n }\n }\n })\n\n observer.observe(root, { childList: true, subtree: true })\n\n let observerWrapper = {\n observe() {\n observer.observe(root, { childList: true, subtree: true })\n },\n disconnect() {\n observer.disconnect()\n },\n }\n\n observerStack.push(observerWrapper)\n\n return () => {\n observer.disconnect()\n\n for (let node of hiddenNodes) {\n let count = refCountMap.get(node)\n if (count === 1) {\n node.removeAttribute(\"aria-hidden\")\n refCountMap.delete(node)\n } else {\n refCountMap.set(node, count! - 1)\n }\n }\n\n // Remove this observer from the stack, and start the previous one.\n if (observerWrapper === observerStack[observerStack.length - 1]) {\n observerStack.pop()\n if (observerStack.length) {\n observerStack[observerStack.length - 1].observe()\n }\n } else {\n observerStack.splice(observerStack.indexOf(observerWrapper), 1)\n }\n }\n}\n\nexport function ariaHidden(targetsOrFn: TargetsOrFn, options: AriaHiddenOptions = {}) {\n const { defer } = options\n const func = defer ? raf : (v: any) => v()\n const cleanups: (VoidFunction | undefined)[] = []\n cleanups.push(\n func(() => {\n const targets = typeof targetsOrFn === \"function\" ? targetsOrFn() : targetsOrFn\n cleanups.push(ariaHiddenImpl(targets, options))\n }),\n )\n return () => {\n cleanups.forEach((fn) => fn?.())\n }\n}\n","import { addDomEvent, fireCustomEvent, isContextMenuEvent } from \"@zag-js/dom-event\"\nimport { contains, getDocument, getEventTarget, getWindow, isHTMLElement, raf } from \"@zag-js/dom-query\"\nimport { isFocusable } from \"@zag-js/tabbable\"\nimport { callAll } from \"@zag-js/utils\"\nimport { getWindowFrames } from \"./get-window-frames\"\n\nexport type InteractOutsideHandlers = {\n onPointerDownOutside?: (event: PointerDownOutsideEvent) => void\n onFocusOutside?: (event: FocusOutsideEvent) => void\n onInteractOutside?: (event: InteractOutsideEvent) => void\n}\n\nexport type InteractOutsideOptions = InteractOutsideHandlers & {\n exclude?: (target: HTMLElement) => boolean\n defer?: boolean\n}\n\nexport type EventDetails<T> = {\n originalEvent: T\n contextmenu: boolean\n focusable: boolean\n}\n\nconst POINTER_OUTSIDE_EVENT = \"pointerdown.outside\"\nconst FOCUS_OUTSIDE_EVENT = \"focus.outside\"\n\nexport type PointerDownOutsideEvent = CustomEvent<EventDetails<PointerEvent>>\n\nexport type FocusOutsideEvent = CustomEvent<EventDetails<FocusEvent>>\n\nexport type InteractOutsideEvent = PointerDownOutsideEvent | FocusOutsideEvent\n\nexport type MaybeElement = HTMLElement | null | undefined\nexport type NodeOrFn = MaybeElement | (() => MaybeElement)\n\nfunction isComposedPathFocusable(event: Event) {\n const composedPath = event.composedPath() ?? [event.target as HTMLElement]\n for (const node of composedPath) {\n if (isHTMLElement(node) && isFocusable(node)) return true\n }\n return false\n}\n\nconst isPointerEvent = (event: Event): event is PointerEvent => \"clientY\" in event\n\nfunction isEventPointWithin(node: MaybeElement, event: Event) {\n if (!isPointerEvent(event) || !node) return false\n\n const rect = node.getBoundingClientRect()\n if (rect.width === 0 || rect.height === 0) return false\n\n return (\n rect.top <= event.clientY &&\n event.clientY <= rect.top + rect.height &&\n rect.left <= event.clientX &&\n event.clientX <= rect.left + rect.width\n )\n}\n\nfunction trackInteractOutsideImpl(node: MaybeElement, options: InteractOutsideOptions) {\n const { exclude, onFocusOutside, onPointerDownOutside, onInteractOutside } = options\n\n if (!node) return\n\n const doc = getDocument(node)\n const win = getWindow(node)\n const frames = getWindowFrames(win)\n\n function isEventOutside(event: Event): boolean {\n const target = getEventTarget(event)\n if (!isHTMLElement(target)) return false\n if (contains(node, target)) return false\n if (isEventPointWithin(node, event)) return false\n return !exclude?.(target)\n }\n\n let clickHandler: VoidFunction\n\n function onPointerDown(event: PointerEvent) {\n //\n function handler() {\n if (!node || !isEventOutside(event)) return\n\n if (onPointerDownOutside || onInteractOutside) {\n const handler = callAll(onPointerDownOutside, onInteractOutside) as EventListener\n node.addEventListener(POINTER_OUTSIDE_EVENT, handler, { once: true })\n }\n\n fireCustomEvent(node, POINTER_OUTSIDE_EVENT, {\n bubbles: false,\n cancelable: true,\n detail: {\n originalEvent: event,\n contextmenu: isContextMenuEvent(event),\n focusable: isComposedPathFocusable(event),\n },\n })\n }\n\n if (event.pointerType === \"touch\") {\n frames.removeEventListener(\"click\", handler)\n doc.removeEventListener(\"click\", handler)\n\n clickHandler = handler\n\n doc.addEventListener(\"click\", handler, { once: true })\n frames.addEventListener(\"click\", handler, { once: true })\n } else {\n handler()\n }\n }\n const cleanups = new Set<VoidFunction>()\n\n const timer = setTimeout(() => {\n cleanups.add(frames.addEventListener(\"pointerdown\", onPointerDown, true))\n cleanups.add(addDomEvent(doc, \"pointerdown\", onPointerDown, true))\n }, 0)\n\n function onFocusin(event: FocusEvent) {\n //\n if (!node || !isEventOutside(event)) return\n\n if (onFocusOutside || onInteractOutside) {\n const handler = callAll(onFocusOutside, onInteractOutside) as EventListener\n node.addEventListener(FOCUS_OUTSIDE_EVENT, handler, { once: true })\n }\n\n fireCustomEvent(node, FOCUS_OUTSIDE_EVENT, {\n bubbles: false,\n cancelable: true,\n detail: {\n originalEvent: event,\n contextmenu: false,\n focusable: isFocusable(getEventTarget(event)),\n },\n })\n }\n\n cleanups.add(addDomEvent(doc, \"focusin\", onFocusin, true))\n cleanups.add(frames.addEventListener(\"focusin\", onFocusin, true))\n\n return () => {\n clearTimeout(timer)\n if (clickHandler) {\n frames.removeEventListener(\"click\", clickHandler)\n doc.removeEventListener(\"click\", clickHandler)\n }\n cleanups.forEach((fn) => fn())\n }\n}\n\nexport function trackInteractOutside(nodeOrFn: NodeOrFn, options: InteractOutsideOptions) {\n const { defer } = options\n const func = defer ? raf : (v: any) => v()\n const cleanups: (VoidFunction | undefined)[] = []\n cleanups.push(\n func(() => {\n const node = typeof nodeOrFn === \"function\" ? nodeOrFn() : nodeOrFn\n cleanups.push(trackInteractOutsideImpl(node, options))\n }),\n )\n return () => {\n cleanups.forEach((fn) => fn?.())\n }\n}\n","export function getWindowFrames(win: Window) {\n const frames = {\n each(cb: (win: Window) => void) {\n for (let i = 0; i < win.frames?.length; i += 1) {\n const frame = win.frames[i]\n if (frame) cb(frame)\n }\n },\n addEventListener(event: string, listener: any, options?: any) {\n frames.each((frame) => {\n try {\n frame.document.addEventListener(event, listener, options)\n } catch (err) {\n console.warn(err)\n }\n })\n return () => {\n try {\n frames.removeEventListener(event, listener, options)\n } catch (err) {\n console.warn(err)\n }\n }\n },\n removeEventListener(event: string, listener: any, options?: any) {\n frames.each((frame) => {\n try {\n frame.document.removeEventListener(event, listener, options)\n } catch (err) {\n console.warn(err)\n }\n })\n },\n }\n return frames\n}\n","import { contains, getEventTarget, raf } from \"@zag-js/dom-query\"\nimport {\n trackInteractOutside,\n type FocusOutsideEvent,\n type InteractOutsideHandlers,\n type PointerDownOutsideEvent,\n} from \"@zag-js/interact-outside\"\nimport { warn } from \"@zag-js/utils\"\nimport { trackEscapeKeydown } from \"./escape-keydown\"\nimport { layerStack, type Layer } from \"./layer-stack\"\nimport { assignPointerEventToLayers, clearPointerEvent, disablePointerEventsOutside } from \"./pointer-event-outside\"\n\ntype MaybeElement = HTMLElement | null\ntype Container = MaybeElement | Array<MaybeElement>\ntype NodeOrFn = MaybeElement | (() => MaybeElement)\n\nexport type DismissableElementHandlers = InteractOutsideHandlers & {\n onEscapeKeyDown?: (event: KeyboardEvent) => void\n}\n\nexport type DismissableElementOptions = DismissableElementHandlers & {\n debug?: boolean\n pointerBlocking?: boolean\n onDismiss: () => void\n exclude?: Container | (() => Container)\n defer?: boolean\n}\n\nfunction trackDismissableElementImpl(node: MaybeElement, options: DismissableElementOptions) {\n if (!node) {\n warn(\"[@zag-js/dismissable] node is `null` or `undefined`\")\n return\n }\n\n const { onDismiss, pointerBlocking, exclude: excludeContainers, debug } = options\n\n const layer: Layer = { dismiss: onDismiss, node, pointerBlocking }\n\n layerStack.add(layer)\n assignPointerEventToLayers()\n\n function onPointerDownOutside(event: PointerDownOutsideEvent) {\n const target = getEventTarget(event.detail.originalEvent)\n if (layerStack.isBelowPointerBlockingLayer(node!) || layerStack.isInBranch(target)) return\n options.onPointerDownOutside?.(event)\n options.onInteractOutside?.(event)\n if (event.defaultPrevented) return\n if (debug) {\n console.log(\"onPointerDownOutside:\", event.detail.originalEvent)\n }\n onDismiss?.()\n }\n\n function onFocusOutside(event: FocusOutsideEvent) {\n const target = getEventTarget(event.detail.originalEvent)\n if (layerStack.isInBranch(target)) return\n options.onFocusOutside?.(event)\n options.onInteractOutside?.(event)\n if (event.defaultPrevented) return\n if (debug) {\n console.log(\"onFocusOutside:\", event.detail.originalEvent)\n }\n onDismiss?.()\n }\n\n function onEscapeKeyDown(event: KeyboardEvent) {\n if (!layerStack.isTopMost(node!)) return\n options.onEscapeKeyDown?.(event)\n if (!event.defaultPrevented && onDismiss) {\n event.preventDefault()\n onDismiss()\n }\n }\n\n function exclude(target: Element) {\n if (!node) return false\n const containers = typeof excludeContainers === \"function\" ? excludeContainers() : excludeContainers\n const _containers = Array.isArray(containers) ? containers : [containers]\n return _containers.some((node) => contains(node, target)) || layerStack.isInNestedLayer(node, target)\n }\n\n const cleanups = [\n pointerBlocking ? disablePointerEventsOutside(node) : undefined,\n trackEscapeKeydown(node, onEscapeKeyDown),\n trackInteractOutside(node, { exclude, onFocusOutside, onPointerDownOutside }),\n ]\n\n return () => {\n layerStack.remove(node!)\n // re-assign pointer event to remaining layers\n assignPointerEventToLayers()\n // remove pointer event from removed layer\n clearPointerEvent(node!)\n cleanups.forEach((fn) => fn?.())\n }\n}\n\nexport function trackDismissableElement(nodeOrFn: NodeOrFn, options: DismissableElementOptions) {\n const { defer } = options\n const func = defer ? raf : (v: any) => v()\n const cleanups: (VoidFunction | undefined)[] = []\n cleanups.push(\n func(() => {\n const node = typeof nodeOrFn === \"function\" ? nodeOrFn() : nodeOrFn\n cleanups.push(trackDismissableElementImpl(node, options))\n }),\n )\n return () => {\n cleanups.forEach((fn) => fn?.())\n }\n}\n","import { addDomEvent } from \"@zag-js/dom-event\"\nimport { getDocument } from \"@zag-js/dom-query\"\n\nexport function trackEscapeKeydown(node: HTMLElement, fn?: (event: KeyboardEvent) => void) {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") fn?.(event)\n }\n return addDomEvent(getDocument(node), \"keydown\", handleKeyDown)\n}\n","import { contains } from \"@zag-js/dom-query\"\n\nexport type Layer = {\n dismiss: VoidFunction\n node: HTMLElement\n pointerBlocking?: boolean\n}\n\nexport const layerStack = {\n layers: [] as Layer[],\n branches: [] as HTMLElement[],\n count(): number {\n return this.layers.length\n },\n pointerBlockingLayers(): Layer[] {\n return this.layers.filter((layer) => layer.pointerBlocking)\n },\n topMostPointerBlockingLayer(): Layer | undefined {\n return [...this.pointerBlockingLayers()].slice(-1)[0]\n },\n hasPointerBlockingLayer(): boolean {\n return this.pointerBlockingLayers().length > 0\n },\n isBelowPointerBlockingLayer(node: HTMLElement) {\n const index = this.indexOf(node)\n const highestBlockingIndex = this.topMostPointerBlockingLayer()\n ? this.indexOf(this.topMostPointerBlockingLayer()?.node)\n : -1\n return index < highestBlockingIndex\n },\n isTopMost(node: HTMLElement | null) {\n const layer = this.layers[this.count() - 1]\n return layer?.node === node\n },\n getNestedLayers(node: HTMLElement) {\n return Array.from(this.layers).slice(this.indexOf(node) + 1)\n },\n isInNestedLayer(node: HTMLElement, target: HTMLElement | EventTarget | null) {\n return this.getNestedLayers(node).some((layer) => contains(layer.node, target))\n },\n isInBranch(target: HTMLElement | EventTarget | null) {\n return Array.from(this.branches).some((branch) => contains(branch, target))\n },\n add(layer: Layer) {\n this.layers.push(layer)\n },\n addBranch(node: HTMLElement) {\n this.branches.push(node)\n },\n remove(node: HTMLElement) {\n const index = this.indexOf(node)\n if (index < 0) return\n\n // dismiss nested layers\n if (index < this.count() - 1) {\n const _layers = this.getNestedLayers(node)\n _layers.forEach((layer) => layer.dismiss())\n }\n // remove this layer\n this.layers.splice(index, 1)\n },\n removeBranch(node: HTMLElement) {\n const index = this.branches.indexOf(node)\n if (index >= 0) this.branches.splice(index, 1)\n },\n indexOf(node: HTMLElement | undefined) {\n return this.layers.findIndex((layer) => layer.node === node)\n },\n dismiss(node: HTMLElement) {\n this.layers[this.indexOf(node)]?.dismiss()\n },\n clear() {\n this.remove(this.layers[0].node)\n },\n}\n","import { getDocument } from \"@zag-js/dom-query\"\nimport { layerStack } from \"./layer-stack\"\n\nlet originalBodyPointerEvents: string\n\nexport function assignPointerEventToLayers() {\n layerStack.layers.forEach(({ node }) => {\n node.style.pointerEvents = layerStack.isBelowPointerBlockingLayer(node) ? \"none\" : \"auto\"\n })\n}\n\nexport function clearPointerEvent(node: HTMLElement) {\n node.style.pointerEvents = \"\"\n}\n\nconst DATA_ATTR = \"data-inert\"\n\nexport function disablePointerEventsOutside(node: HTMLElement) {\n const doc = getDocument(node)\n\n if (layerStack.hasPointerBlockingLayer() && !doc.body.hasAttribute(DATA_ATTR)) {\n originalBodyPointerEvents = document.body.style.pointerEvents\n doc.body.style.pointerEvents = \"none\"\n doc.body.setAttribute(DATA_ATTR, \"\")\n }\n\n return () => {\n if (layerStack.hasPointerBlockingLayer()) return\n doc.body.style.pointerEvents = originalBodyPointerEvents\n doc.body.removeAttribute(DATA_ATTR)\n if (doc.body.style.length === 0) doc.body.removeAttribute(\"style\")\n }\n}\n","import { isIos } from \"@zag-js/dom-query\"\n\nconst LOCK_CLASSNAME = \"data-zag-scroll-lock\"\n\nfunction assignStyle(el: HTMLElement | null | undefined, style: Partial<CSSStyleDeclaration>) {\n if (!el) return\n const previousStyle = el.style.cssText\n Object.assign(el.style, style)\n return () => {\n el.style.cssText = previousStyle\n }\n}\n\nfunction setCSSProperty(el: HTMLElement | null | undefined, property: string, value: string) {\n if (!el) return\n const previousValue = el.style.getPropertyValue(property)\n el.style.setProperty(property, value)\n return () => {\n if (previousValue) {\n el.style.setProperty(property, previousValue)\n } else {\n el.style.removeProperty(property)\n }\n }\n}\n\nfunction getPaddingProperty(documentElement: HTMLElement) {\n // RTL <body> scrollbar\n const documentLeft = documentElement.getBoundingClientRect().left\n const scrollbarX = Math.round(documentLeft) + documentElement.scrollLeft\n return scrollbarX ? \"paddingLeft\" : \"paddingRight\"\n}\n\nexport function preventBodyScroll(_document?: Document) {\n const doc = _document ?? document\n const win = doc.defaultView ?? window\n\n const { documentElement, body } = doc\n\n const locked = body.hasAttribute(LOCK_CLASSNAME)\n if (locked) return\n\n body.setAttribute(LOCK_CLASSNAME, \"\")\n\n const scrollbarWidth = win.innerWidth - documentElement.clientWidth\n const setScrollbarWidthProperty = () => setCSSProperty(documentElement, \"--scrollbar-width\", `${scrollbarWidth}px`)\n const paddingProperty = getPaddingProperty(documentElement)\n\n const setStyle = () =>\n assignStyle(body, {\n overflow: \"hidden\",\n [paddingProperty]: `${scrollbarWidth}px`,\n })\n\n // Only iOS doesn't respect `overflow: hidden` on document.body\n const setIOSStyle = () => {\n const { scrollX, scrollY, visualViewport } = win\n\n // iOS 12 does not support `visuaViewport`.\n const offsetLeft = visualViewport?.offsetLeft ?? 0\n const offsetTop = visualViewport?.offsetTop ?? 0\n\n const restoreStyle = assignStyle(body, {\n position: \"fixed\",\n overflow: \"hidden\",\n top: `${-(scrollY - Math.floor(offsetTop))}px`,\n left: `${-(scrollX - Math.floor(offsetLeft))}px`,\n right: \"0\",\n [paddingProperty]: `${scrollbarWidth}px`,\n })\n\n return () => {\n restoreStyle?.()\n win.scrollTo(scrollX, scrollY)\n }\n }\n\n const cleanups = [setScrollbarWidthProperty(), isIos() ? setIOSStyle() : setStyle()]\n\n return () => {\n cleanups.forEach((fn) => fn?.())\n body.removeAttribute(LOCK_CLASSNAME)\n }\n}\n","// NOTE: separate `:not()` selectors has broader browser support than the newer\n// `:not([inert], [inert] *)` (Feb 2023)\n// CAREFUL: JSDom does not support `:not([inert] *)` as a selector; using it causes\n// the entire query to fail, resulting in no nodes found, which will break a lot\n// of things... so we have to rely on JS to identify nodes inside an inert container\nconst candidateSelectors = [\n 'input:not([inert])',\n 'select:not([inert])',\n 'textarea:not([inert])',\n 'a[href]:not([inert])',\n 'button:not([inert])',\n '[tabindex]:not(slot):not([inert])',\n 'audio[controls]:not([inert])',\n 'video[controls]:not([inert])',\n '[contenteditable]:not([contenteditable=\"false\"]):not([inert])',\n 'details>summary:first-of-type:not([inert])',\n 'details:not([inert])',\n];\nconst candidateSelector = /* #__PURE__ */ candidateSelectors.join(',');\n\nconst NoElement = typeof Element === 'undefined';\n\nconst matches = NoElement\n ? function () {}\n : Element.prototype.matches ||\n Element.prototype.msMatchesSelector ||\n Element.prototype.webkitMatchesSelector;\n\nconst getRootNode =\n !NoElement && Element.prototype.getRootNode\n ? (element) => element?.getRootNode?.()\n : (element) => element?.ownerDocument;\n\n/**\n * Determines if a node is inert or in an inert ancestor.\n * @param {Element} [node]\n * @param {boolean} [lookUp] If true and `node` is not inert, looks up at ancestors to\n * see if any of them are inert. If false, only `node` itself is considered.\n * @returns {boolean} True if inert itself or by way of being in an inert ancestor.\n * False if `node` is falsy.\n */\nconst isInert = function (node, lookUp = true) {\n // CAREFUL: JSDom does not support inert at all, so we can't use the `HTMLElement.inert`\n // JS API property; we have to check the attribute, which can either be empty or 'true';\n // if it's `null` (not specified) or 'false', it's an active element\n const inertAtt = node?.getAttribute?.('inert');\n const inert = inertAtt === '' || inertAtt === 'true';\n\n // NOTE: this could also be handled with `node.matches('[inert], :is([inert] *)')`\n // if it weren't for `matches()` not being a function on shadow roots; the following\n // code works for any kind of node\n // CAREFUL: JSDom does not appear to support certain selectors like `:not([inert] *)`\n // so it likely would not support `:is([inert] *)` either...\n const result = inert || (lookUp && node && isInert(node.parentNode)); // recursive\n\n return result;\n};\n\n/**\n * Determines if a node's content is editable.\n * @param {Element} [node]\n * @returns True if it's content-editable; false if it's not or `node` is falsy.\n */\nconst isContentEditable = function (node) {\n // CAREFUL: JSDom does not support the `HTMLElement.isContentEditable` API so we have\n // to use the attribute directly to check for this, which can either be empty or 'true';\n // if it's `null` (not specified) or 'false', it's a non-editable element\n const attValue = node?.getAttribute?.('contenteditable');\n return attValue === '' || attValue === 'true';\n};\n\n/**\n * @param {Element} el container to check in\n * @param {boolean} includeContainer add container to check\n * @param {(node: Element) => boolean} filter filter candidates\n * @returns {Element[]}\n */\nconst getCandidates = function (el, includeContainer, filter) {\n // even if `includeContainer=false`, we still have to check it for inertness because\n // if it's inert, all its children are inert\n if (isInert(el)) {\n return [];\n }\n\n let candidates = Array.prototype.slice.apply(\n el.querySelectorAll(candidateSelector)\n );\n if (includeContainer && matches.call(el, candidateSelector)) {\n candidates.unshift(el);\n }\n candidates = candidates.filter(filter);\n return candidates;\n};\n\n/**\n * @callback GetShadowRoot\n * @param {Element} element to check for shadow root\n * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.\n */\n\n/**\n * @callback ShadowRootFilter\n * @param {Element} shadowHostNode the element which contains shadow content\n * @returns {boolean} true if a shadow root could potentially contain valid candidates.\n */\n\n/**\n * @typedef {Object} CandidateScope\n * @property {Element} scopeParent contains inner candidates\n * @property {Element[]} candidates list of candidates found in the scope parent\n */\n\n/**\n * @typedef {Object} IterativeOptions\n * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;\n * if a function, implies shadow support is enabled and either returns the shadow root of an element\n * or a boolean stating if it has an undisclosed shadow root\n * @property {(node: Element) => boolean} filter filter candidates\n * @property {boolean} flatten if true then result will flatten any CandidateScope into the returned list\n * @property {ShadowRootFilter} shadowRootFilter filter shadow roots;\n */\n\n/**\n * @param {Element[]} elements list of element containers to match candidates from\n * @param {boolean} includeContainer add container list to check\n * @param {IterativeOptions} options\n * @returns {Array.<Element|CandidateScope>}\n */\nconst getCandidatesIteratively = function (\n elements,\n includeContainer,\n options\n) {\n const candidates = [];\n const elementsToCheck = Array.from(elements);\n while (elementsToCheck.length) {\n const element = elementsToCheck.shift();\n if (isInert(element, false)) {\n // no need to look up since we're drilling down\n // anything inside this container will also be inert\n continue;\n }\n\n if (element.tagName === 'SLOT') {\n // add shadow dom slot scope (slot itself cannot be focusable)\n const assigned = element.assignedElements();\n const content = assigned.length ? assigned : element.children;\n const nestedCandidates = getCandidatesIteratively(content, true, options);\n if (options.flatten) {\n candidates.push(...nestedCandidates);\n } else {\n candidates.push({\n scopeParent: element,\n candidates: nestedCandidates,\n });\n }\n } else {\n // check candidate element\n const validCandidate = matches.call(element, candidateSelector);\n if (\n validCandidate &&\n options.filter(element) &&\n (includeContainer || !elements.includes(element))\n ) {\n candidates.push(element);\n }\n\n // iterate over shadow content if possible\n const shadowRoot =\n element.shadowRoot ||\n // check for an undisclosed shadow\n (typeof options.getShadowRoot === 'function' &&\n options.getShadowRoot(element));\n\n // no inert look up because we're already drilling down and checking for inertness\n // on the way down, so all containers to this root node should have already been\n // vetted as non-inert\n const validShadowRoot =\n !isInert(shadowRoot, false) &&\n (!options.shadowRootFilter || options.shadowRootFilter(element));\n\n if (shadowRoot && validShadowRoot) {\n // add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed\n // shadow exists, so look at light dom children as fallback BUT create a scope for any\n // child candidates found because they're likely slotted elements (elements that are\n // children of the web component element (which has the shadow), in the light dom, but\n // slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,\n // _after_ we return from this recursive call\n const nestedCandidates = getCandidatesIteratively(\n shadowRoot === true ? element.children : shadowRoot.children,\n true,\n options\n );\n\n if (options.flatten) {\n candidates.push(...nestedCandidates);\n } else {\n candidates.push({\n scopeParent: element,\n candidates: nestedCandidates,\n });\n }\n } else {\n // there's not shadow so just dig into the element's (light dom) children\n // __without__ giving the element special scope treatment\n elementsToCheck.unshift(...element.children);\n }\n }\n }\n return candidates;\n};\n\n/**\n * @private\n * Determines if the node has an explicitly specified `tabindex` attribute.\n * @param {HTMLElement} node\n * @returns {boolean} True if so; false if not.\n */\nconst hasTabIndex = function (node) {\n return !isNaN(parseInt(node.getAttribute('tabindex'), 10));\n};\n\n/**\n * Determine the tab index of a given node.\n * @param {HTMLElement} node\n * @returns {number} Tab order (negative, 0, or positive number).\n * @throws {Error} If `node` is falsy.\n */\nconst getTabIndex = function (node) {\n if (!node) {\n throw new Error('No node provided');\n }\n\n if (node.tabIndex < 0) {\n // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default\n // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,\n // yet they are still part of the regular tab order; in FF, they get a default\n // `tabIndex` of 0; since Chrome still puts those elements in the regular tab\n // order, consider their tab index to be 0.\n // Also browsers do not return `tabIndex` correctly for contentEditable nodes;\n // so if they don't have a tabindex attribute specifically set, assume it's 0.\n if (\n (/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) ||\n isContentEditable(node)) &&\n !hasTabIndex(node)\n ) {\n return 0;\n }\n }\n\n return node.tabIndex;\n};\n\n/**\n * Determine the tab index of a given node __for sort order purposes__.\n * @param {HTMLElement} node\n * @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default,\n * has tabIndex -1, but needs to be sorted by document order in order for its content to be\n * inserted into the correct sort position.\n * @returns {number} Tab order (negative, 0, or positive number).\n */\nconst getSortOrderTabIndex = function (node, isScope) {\n const tabIndex = getTabIndex(node);\n\n if (tabIndex < 0 && isScope && !hasTabIndex(node)) {\n return 0;\n }\n\n return tabIndex;\n};\n\nconst sortOrderedTabbables = function (a, b) {\n return a.tabIndex === b.tabIndex\n ? a.documentOrder - b.documentOrder\n : a.tabIndex - b.tabIndex;\n};\n\nconst isInput = function (node) {\n return node.tagName === 'INPUT';\n};\n\nconst isHiddenInput = function (node) {\n return isInput(node) && node.type === 'hidden';\n};\n\nconst isDetailsWithSummary = function (node) {\n const r =\n node.tagName === 'DETAILS' &&\n Array.prototype.slice\n .apply(node.children)\n .some((child) => child.tagName === 'SUMMARY');\n return r;\n};\n\nconst getCheckedRadio = function (nodes, form) {\n for (let i = 0; i < nodes.length; i++) {\n if (nodes[i].checked && nodes[i].form === form) {\n return nodes[i];\n }\n }\n};\n\nconst isTabbableRadio = function (node) {\n if (!node.name) {\n return true;\n }\n const radioScope = node.form || getRootNode(node);\n const queryRadios = function (name) {\n return radioScope.querySelectorAll(\n 'input[type=\"radio\"][name=\"' + name + '\"]'\n );\n };\n\n let radioSet;\n if (\n typeof window !== 'undefined' &&\n typeof window.CSS !== 'undefined' &&\n typeof window.CSS.escape === 'function'\n ) {\n radioSet = queryRadios(window.CSS.escape(node.name));\n } else {\n try {\n radioSet = queryRadios(node.name);\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error(\n 'Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s',\n err.message\n );\n return false;\n }\n }\n\n const checked = getCheckedRadio(radioSet, node.form);\n return !checked || checked === node;\n};\n\nconst isRadio = function (node) {\n return isInput(node) && node.type === 'radio';\n};\n\nconst isNonTabbableRadio = function (node) {\n return isRadio(node) && !isTabbableRadio(node);\n};\n\n// determines if a node is ultimately attached to the window's document\nconst isNodeAttached = function (node) {\n // The root node is the shadow root if the node is in a shadow DOM; some document otherwise\n // (but NOT _the_ document; see second 'If' comment below for more).\n // If rootNode is shadow root, it'll have a host, which is the element to which the shadow\n // is attached, and the one we need to check if it's in the document or not (because the\n // shadow, and all nodes it contains, is never considered in the document since shadows\n // behave like self-contained DOMs; but if the shadow's HOST, which is part of the document,\n // is hidden, or is not in the document itself but is detached, it will affect the shadow's\n // visibility, including all the nodes it contains). The host could be any normal node,\n // or a custom element (i.e. web component). Either way, that's the one that is considered\n // part of the document, not the shadow root, nor any of its children (i.e. the node being\n // tested).\n // To further complicate things, we have to look all the way up until we find a shadow HOST\n // that is attached (or find none) because the node might be in nested shadows...\n // If rootNode is not a shadow root, it won't have a host, and so rootNode should be the\n // document (per the docs) and while it's a Document-type object, that document does not\n // appear to be the same as the node's `ownerDocument` for some reason, so it's safer\n // to ignore the rootNode at this point, and use `node.ownerDocument`. Otherwise,\n // using `rootNode.contains(node)` will _always_ be true we'll get false-positives when\n // node is actually detached.\n // NOTE: If `nodeRootHost` or `node` happens to be the `document` itself (which is possible\n // if a tabbable/focusable node was quickly added to the DOM, focused, and then removed\n // from the DOM as in https://github.com/focus-trap/focus-trap-react/issues/905), then\n // `ownerDocument` will be `null`, hence the optional chaining on it.\n let nodeRoot = node && getRootNode(node);\n let nodeRootHost = nodeRoot?.host;\n\n // in some cases, a detached node will return itself as the root instead of a document or\n // shadow root object, in which case, we shouldn't try to look further up the host chain\n let attached = false;\n if (nodeRoot && nodeRoot !== node) {\n attached = !!(\n nodeRootHost?.ownerDocument?.contains(nodeRootHost) ||\n node?.ownerDocument?.contains(node)\n );\n\n while (!attached && nodeRootHost) {\n // since it's not attached and we have a root host, the node MUST be in a nested shadow DOM,\n // which means we need to get the host's host and check if that parent host is contained\n // in (i.e. attached to) the document\n nodeRoot = getRootNode(nodeRootHost);\n nodeRootHost = nodeRoot?.host;\n attached = !!nodeRootHost?.ownerDocument?.contains(nodeRootHost);\n }\n }\n\n return attached;\n};\n\nconst isZeroArea = function (node) {\n const { width, height } = node.getBoundingClientRect();\n return width === 0 && height === 0;\n};\nconst isHidden = function (node, { displayCheck, getShadowRoot }) {\n // NOTE: visibility will be `undefined` if node is detached from the document\n // (see notes about this further down), which means we will consider it visible\n // (this is legacy behavior from a very long way back)\n // NOTE: we check this regardless of `displayCheck=\"none\"` because this is a\n // _visibility_ check, not a _display_ check\n if (getComputedStyle(node).visibility === 'hidden') {\n return true;\n }\n\n const isDirectSummary = matches.call(node, 'details>summary:first-of-type');\n const nodeUnderDetails = isDirectSummary ? node.parentElement : node;\n if (matches.call(nodeUnderDetails, 'details:not([open]) *')) {\n return true;\n }\n\n if (\n !displayCheck ||\n displayCheck === 'full' ||\n displayCheck === 'legacy-full'\n ) {\n if (typeof getShadowRoot === 'function') {\n // figure out if we should consider the node to be in an undisclosed shadow and use the\n // 'non-zero-area' fallback\n const originalNode = node;\n while (node) {\n const parentElement = node.parentElement;\n const rootNode = getRootNode(node);\n if (\n parentElement &&\n !parentElement.shadowRoot &&\n getShadowRoot(parentElement) === true // check if there's an undisclosed shadow\n ) {\n // node has an undisclosed shadow which means we can only treat it as a black box, so we\n // fall back to a non-zero-area test\n return isZeroArea(node);\n } else if (node.assignedSlot) {\n // iterate up slot\n node = node.assignedSlot;\n } else if (!parentElement && rootNode !== node.ownerDocument) {\n // cross shadow boundary\n node = rootNode.host;\n } else {\n // iterate up normal dom\n node = parentElement;\n }\n }\n\n node = originalNode;\n }\n // else, `getShadowRoot` might be true, but all that does is enable shadow DOM support\n // (i.e. it does not also presume that all nodes might have undisclosed shadows); or\n // it might be a falsy value, which means shadow DOM support is disabled\n\n // Since we didn't find it sitting in an undisclosed shadow (or shadows are disabled)\n // now we can just test to see if it would normally be visible or not, provided it's\n // attached to the main document.\n // NOTE: We must consider case where node is inside a shadow DOM and given directly to\n // `isTabbable()` or `isFocusable()` -- regardless of `getShadowRoot` option setting.\n\n if (isNodeAttached(node)) {\n // this works wherever the node is: if there's at least one client rect, it's\n // somehow displayed; it also covers the CSS 'display: contents' case where the\n // node itself is hidden in place of its contents; and there's no need to search\n // up the hierarchy either\n return !node.getClientRects().length;\n }\n\n // Else, the node isn't attached to the document, which means the `getClientRects()`\n // API will __always__ return zero rects (this can happen, for example, if React\n // is used to render nodes onto a detached tree, as confirmed in this thread:\n // https://github.com/facebook/react/issues/9117#issuecomment-284228870)\n //\n // It also means that even window.getComputedStyle(node).display will return `undefined`\n // because styles are only computed for nodes that are in the document.\n //\n // NOTE: THIS HAS BEEN THE CASE FOR YEARS. It is not new, nor is it caused by tabbable\n // somehow. Though it was never stated officially, anyone who has ever used tabbable\n // APIs on nodes in detached containers has actually implicitly used tabbable in what\n // was later (as of v5.2.0 on Apr 9, 2021) called `displayCheck=\"none\"` mode -- essentially\n // considering __everything__ to be visible because of the innability to determine styles.\n //\n // v6.0.0: As of this major release, the default 'full' option __no longer treats detached\n // nodes as visible with the 'none' fallback.__\n if (displayCheck !== 'legacy-full') {\n return true; // hidden\n }\n // else, fallback to 'none' mode and consider the node visible\n } else if (displayCheck === 'non-zero-area') {\n // NOTE: Even though this tests that the node's client rect is non-zero to determine\n // whether it's displayed, and that a detached node will __always__ have a zero-area\n // client rect, we don't special-case for whether the node is attached or not. In\n // this mode, we do want to consider nodes that have a zero area to be hidden at all\n // times, and that includes attached or not.\n return isZeroArea(node);\n }\n\n // visible, as far as we can tell, or per current `displayCheck=none` mode, we assume\n // it's visible\n return false;\n};\n\n// form fields (nested) inside a disabled fieldset are not focusable/tabbable\n// unless they are in the _first_ <legend> element of the top-most disabled\n// fieldset\nconst isDisabledFromFieldset = function (node) {\n if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {\n let parentNode = node.parentElement;\n // check if `node` is contained in a disabled <fieldset>\n while (parentNode) {\n if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) {\n // look for the first <legend> among the children of the disabled <fieldset>\n for (let i = 0; i < parentNode.children.length; i++) {\n const child = parentNode.children.item(i);\n // when the first <legend> (in document order) is found\n if (child.tagName === 'LEGEND') {\n // if its parent <fieldset> is not nested in another disabled <fieldset>,\n // return whether `node` is a descendant of its first <legend>\n return matches.call(parentNode, 'fieldset[disabled] *')\n ? true\n : !child.contains(node);\n }\n }\n // the disabled <fieldset> containing `node` has no <legend>\n return true;\n }\n parentNode = parentNode.parentElement;\n }\n }\n\n // else, node's tabbable/focusable state should not be affected by a fieldset's\n // enabled/disabled state\n return false;\n};\n\nconst isNodeMatchingSelectorFocusable = function (options, node) {\n if (\n node.disabled ||\n // we must do an inert look up to filter out any elements inside an inert ancestor\n // because we're limited in the type of selectors we can use in JSDom (see related\n // note related to `candidateSelectors`)\n isInert(node) ||\n isHiddenInput(node) ||\n isHidden(node, options) ||\n // For a details element with a summary, the summary element gets the focus\n isDetailsWithSummary(node) ||\n isDisabledFromFieldset(node)\n ) {\n return false;\n }\n return true;\n};\n\nconst isNodeMatchingSelectorTabbable = function (options, node) {\n if (\n isNonTabbableRadio(node) ||\n getTabIndex(node) < 0 ||\n !isNodeMatchingSelectorFocusable(options, node)\n ) {\n return false;\n }\n return true;\n};\n\nconst isValidShadowRootTabbable = function (shadowHostNode) {\n const tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10);\n if (isNaN(tabIndex) || tabIndex >= 0) {\n return true;\n }\n // If a custom element has an explicit negative tabindex,\n // browsers will not allow tab targeting said element's children.\n return false;\n};\n\n/**\n * @param {Array.<Element|CandidateScope>} candidates\n * @returns Element[]\n */\nconst sortByOrder = function (candidates) {\n const regularTabbables = [];\n const orderedTabbables = [];\n candidates.forEach(function (item, i) {\n const isScope = !!item.scopeParent;\n const element = isScope ? item.scopeParent : item;\n const candidateTabindex = getSortOrderTabIndex(element, isScope);\n const elements = isScope ? sortByOrder(item.candidates) : element;\n if (candidateTabindex === 0) {\n isScope\n ? regularTabbables.push(...elements)\n : regularTabbables.push(element);\n } else {\n orderedTabbables.push({\n documentOrder: i,\n tabIndex: candidateTabindex,\n item: item,\n isScope: isScope,\n content: elements,\n });\n }\n });\n\n return orderedTabbables\n .sort(sortOrderedTabbables)\n .reduce((acc, sortable) => {\n sortable.isScope\n ? acc.push(...sortable.content)\n : acc.push(sortable.content);\n return acc;\n }, [])\n .concat(regularTabbables);\n};\n\nconst tabbable = function (container, options) {\n options = options || {};\n\n let candidates;\n if (options.getShadowRoot) {\n candidates = getCandidatesIteratively(\n [container],\n options.includeContainer,\n {\n filter: isNodeMatchingSelectorTabbable.bind(null, options),\n flatten: false,\n getShadowRoot: options.getShadowRoot,\n shadowRootFilter: isValidShadowRootTabbable,\n }\n );\n } else {\n candidates = getCandidates(\n container,\n options.includeContainer,\n isNodeMatchingSelectorTabbable.bind(null, options)\n );\n }\n return sortByOrder(candidates);\n};\n\nconst focusable = function (container, options) {\n options = options || {};\n\n let candidates;\n if (options.getShadowRoot) {\n candidates = getCandidatesIteratively(\n [container],\n options.includeContainer,\n {\n filter: isNodeMatchingSelectorFocusable.bind(null, options),\n flatten: true,\n getShadowRoot: options.getShadowRoot,\n }\n );\n } else {\n candidates = getCandidates(\n container,\n options.includeContainer,\n isNodeMatchingSelectorFocusable.bind(null, options)\n );\n }\n\n return candidates;\n};\n\nconst isTabbable = function (node, options) {\n options = options || {};\n if (!node) {\n throw new Error('No node provided');\n }\n if (matches.call(node, candidateSelector) === false) {\n return false;\n }\n return isNodeMatchingSelectorTabbable(options, node);\n};\n\nconst focusableCandidateSelector = /* #__PURE__ */ candidateSelectors\n .concat('iframe')\n .join(',');\n\nconst isFocusable = function (node, options) {\n options = options || {};\n if (!node) {\n throw new Error('No node provided');\n }\n if (matches.call(node, focusableCandidateSelector) === false) {\n return false;\n }\n return isNodeMatchingSelectorFocusable(options, node);\n};\n\nexport { tabbable, focusable, isTabbable, isFocusable, getTabIndex };\n","import {\n tabbable,\n focusable,\n isFocusable,\n isTabbable,\n getTabIndex,\n} from 'tabbable';\n\nconst activeFocusTraps = {\n activateTrap(trapStack, trap) {\n if (trapStack.length > 0) {\n const activeTrap = trapStack[trapStack.length - 1];\n if (activeTrap !== trap) {\n activeTrap.pause();\n }\n }\n\n const trapIndex = trapStack.indexOf(trap);\n if (trapIndex === -1) {\n trapStack.push(trap);\n } else {\n // move this existing trap to the front of the queue\n trapStack.splice(trapIndex, 1);\n trapStack.push(trap);\n }\n },\n\n deactivateTrap(trapStack, trap) {\n const trapIndex = trapStack.indexOf(trap);\n if (trapIndex !== -1) {\n trapStack.splice(trapIndex, 1);\n }\n\n if (trapStack.length > 0) {\n trapStack[trapStack.length - 1].unpause();\n }\n },\n};\n\nconst isSelectableInput = function (node) {\n return (\n node.tagName &&\n node.tagName.toLowerCase() === 'input' &&\n typeof node.select === 'function'\n );\n};\n\nconst isEscapeEvent = function (e) {\n return e?.key === 'Escape' || e?.key === 'Esc' || e?.keyCode === 27;\n};\n\nconst isTabEvent = function (e) {\n return e?.key === 'Tab' || e?.keyCode === 9;\n};\n\n// checks for TAB by default\nconst isKeyForward = function (e) {\n return isTabEvent(e) && !e.shiftKey;\n};\n\n// checks for SHIFT+TAB by default\nconst isKeyBackward = function (e) {\n return isTabEvent(e) && e.shiftKey;\n};\n\nconst delay = function (fn) {\n return setTimeout(fn, 0);\n};\n\n// Array.find/findIndex() are not supported on IE; this replicates enough\n// of Array.findIndex() for our needs\nconst findIndex = function (arr, fn) {\n let idx = -1;\n\n arr.every(function (value, i) {\n if (fn(value)) {\n idx = i;\n return false; // break\n }\n\n return true; // next\n });\n\n return idx;\n};\n\n/**\n * Get an option's value when it could be a plain value, or a handler that provides\n * the value.\n * @param {*} value Option's value to check.\n * @param {...*} [params] Any parameters to pass to the handler, if `value` is a function.\n * @returns {*} The `value`, or the handler's returned value.\n */\nconst valueOrHandler = function (value, ...params) {\n return typeof value === 'function' ? value(...params) : value;\n};\n\nconst getActualTarget = function (event) {\n // NOTE: If the trap is _inside_ a shadow DOM, event.target will always be the\n // shadow host. However, event.target.composedPath() will be an array of\n // nodes \"clicked\" from inner-most (the actual element inside the shadow) to\n // outer-most (the host HTML document). If we have access to composedPath(),\n // then use its first element; otherwise, fall back to event.target (and\n // this only works for an _open_ shadow DOM; otherwise,\n // composedPath()[0] === event.target always).\n return event.target.shadowRoot && typeof event.composedPath === 'function'\n ? event.composedPath()[0]\n : event.target;\n};\n\n// NOTE: this must be _outside_ `createFocusTrap()` to make sure all traps in this\n// current instance use the same stack if `userOptions.trapStack` isn't specified\nconst internalTrapStack = [];\n\nconst createFocusTrap = function (elements, userOptions) {\n // SSR: a live trap shouldn't be created in this type of environment so this\n // should be safe code to execute if the `document` option isn't specified\n const doc = userOptions?.document || document;\n\n const trapStack = userOptions?.trapStack || internalTrapStack;\n\n const config = {\n returnFocusOnDeactivate: true,\n escapeDeactivates: true,\n delayInitialFocus: true,\n isKeyForward,\n isKeyBackward,\n ...userOptions,\n };\n\n const state = {\n // containers given to createFocusTrap()\n // @type {Array<HTMLElement>}\n containers: [],\n\n // list of objects identifying tabbable nodes in `containers` in the trap\n // NOTE: it's possible that a group has no tabbable nodes if nodes get removed while the trap\n // is active, but the trap should never get to a state where there isn't at least one group\n // with at least one tabbable node in it (that would lead to an error condition that would\n // result in an error being thrown)\n // @type {Array<{\n // container: HTMLElement,\n // tabbableNodes: Array<HTMLElement>, // empty if none\n // focusableNodes: Array<HTMLElement>, // empty if none\n // posTabIndexesFound: boolean,\n // firstTabbableNode: HTMLElement|undefined,\n // lastTabbableNode: HTMLElement|undefined,\n // firstDomTabbableNode: HTMLElement|undefined,\n // lastDomTabbableNode: HTMLElement|undefined,\n // nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined\n // }>}\n containerGroups: [], // same order/length as `containers` list\n\n // references to objects in `containerGroups`, but only those that actually have\n // tabbable nodes in them\n // NOTE: same order as `containers` and `containerGroups`, but __not necessarily__\n // the same length\n tabbableGroups: [],\n\n nodeFocusedBeforeActivation: null,\n mostRecentlyFocusedNode: null,\n active: false,\n paused: false,\n\n // timer ID for when delayInitialFocus is true and initial focus in this trap\n // has been delayed during activation\n delayInitialFocusTimer: undefined,\n\n // the most recent KeyboardEvent for the configured nav key (typically [SHIFT+]TAB), if any\n recentNavEvent: undefined,\n };\n\n let trap; // eslint-disable-line prefer-const -- some private functions reference it, and its methods reference private functions, so we must declare here and define later\n\n /**\n * Gets a configuration option value.\n * @param {Object|undefined} configOverrideOptions If true, and option is defined in this set,\n * value will be taken from this object. Otherwise, value will be taken from base configuration.\n * @param {string} optionName Name of the option whose value is sought.\n * @param {string|undefined} [configOptionName] Name of option to use __instead of__ `optionName`\n * IIF `configOverrideOptions` is not defined. Otherwise, `optionName` is used.\n */\n const getOption = (configOverrideOptions, optionName, configOptionName) => {\n return configOverrideOptions &&\n configOverrideOptions[optionName] !== undefined\n ? configOverrideOptions[optionName]\n : config[configOptionName || optionName];\n };\n\n /**\n * Finds the index of the container that contains the element.\n * @param {HTMLElement} element\n * @param {Event} [event] If available, and `element` isn't directly found in any container,\n * the event's composed path is used to see if includes any known trap containers in the\n * case where the element is inside a Shadow DOM.\n * @returns {number} Index of the container in either `state.containers` or\n * `state.containerGroups` (the order/length of these lists are the same); -1\n * if the element isn't found.\n */\n const findContainerIndex = function (element, event) {\n const composedPath =\n typeof event?.composedPath === 'function'\n ? event.composedPath()\n : undefined;\n // NOTE: search `containerGroups` because it's possible a group contains no tabbable\n // nodes, but still contains focusable nodes (e.g. if they all have `tabindex=-1`)\n // and we still need to find the element in there\n return state.containerGroups.findIndex(\n ({ container, tabbableNodes }) =>\n container.contains(element) ||\n // fall back to explicit tabbable search which will take into consideration any\n // web components if the `tabbableOptions.getShadowRoot` option was used for\n // the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't\n // look inside web components even if open)\n composedPath?.includes(container) ||\n tabbableNodes.find((node) => node === element)\n );\n };\n\n /**\n * Gets the node for the given option, which is expected to be an option that\n * can be either a DOM node, a string that is a selector to get a node, `false`\n * (if a node is explicitly NOT given), or a function that returns any of these\n * values.\n * @param {string} optionName\n * @returns {undefined | false | HTMLElement | SVGElement} Returns\n * `undefined` if the option is not specified; `false` if the option\n * resolved to `false` (node explicitly not given); otherwise, the resolved\n * DOM node.\n * @throws {Error} If the option is set, not `false`, and is not, or does not\n * resolve to a node.\n */\n const getNodeForOption = function (optionName, ...params) {\n let optionValue = config[optionName];\n\n if (typeof optionValue === 'function') {\n optionValue = optionValue(...params);\n }\n\n if (optionValue === true) {\n optionValue = undefined; // use default value\n }\n\n if (!optionValue) {\n if (optionValue === undefined || optionValue === false) {\n return optionValue;\n }\n // else, empty string (invalid), null (invalid), 0 (invalid)\n\n throw new Error(\n `\\`${optionName}\\` was specified but was not a node, or did not return a node`\n );\n }\n\n let node = optionValue; // could be HTMLElement, SVGElement, or non-empty string at this point\n\n if (typeof optionValue === 'string') {\n node = doc.querySelector(optionValue); // resolve to node, or null if fails\n if (!node) {\n throw new Error(\n `\\`${optionName}\\` as selector refers to no known node`\n );\n }\n }\n\n return node;\n };\n\n const getInitialFocusNode = function () {\n let node = getNodeForOption('initialFocus');\n\n // false explicitly indicates we want no initialFocus at all\n if (node === false) {\n return false;\n }\n\n if (node === undefined || !isFocusable(node, config.tabbableOptions)) {\n // option not specified nor focusable: use fallback options\n if (findContainerIndex(doc.activeElement) >= 0) {\n node = doc.activeElement;\n } else {\n const firstTabbableGroup = state.tabbableGroups[0];\n const firstTabbableNode =\n firstTabbableGroup && firstTabbableGroup.firstTabbableNode;\n\n // NOTE: `fallbackFocus` option function cannot return `false` (not supported)\n node = firstTabbableNode || getNodeForOption('fallbackFocus');\n }\n }\n\n if (!node) {\n throw new Error(\n 'Your focus-trap needs to have at least one focusable element'\n );\n }\n\n return node;\n };\n\n const updateTabbableNodes = function () {\n state.containerGroups = state.containers.map((container) => {\n const tabbableNodes = tabbable(container, config.tabbableOptions);\n\n // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes\n // are a superset of tabbable nodes since nodes with negative `tabindex` attributes\n // are focusable but not tabbable\n const focusableNodes = focusable(container, config.tabbableOptions);\n\n const firstTabbableNode =\n tabbableNodes.length > 0 ? tabbableNodes[0] : undefined;\n const lastTabbableNode =\n tabbableNodes.length > 0\n ? tabbableNodes[tabbableNodes.length - 1]\n : undefined;\n\n const firstDomTabbableNode = focusableNodes.find((node) =>\n isTabbable(node)\n );\n const lastDomTabbableNode = focusableNodes\n .slice()\n .reverse()\n .find((node) => isTabbable(node));\n\n const posTabIndexesFound = !!tabbableNodes.find(\n (node) => getTabIndex(node) > 0\n );\n\n return {\n container,\n tabbableNodes,\n focusableNodes,\n\n /** True if at least one node with positive `tabindex` was found in this container. */\n posTabIndexesFound,\n\n /** First tabbable node in container, __tabindex__ order; `undefined` if none. */\n firstTabbableNode,\n /** Last tabbable node in container, __tabindex__ order; `undefined` if none. */\n lastTabbableNode,\n\n // NOTE: DOM order is NOT NECESSARILY \"document position\" order, but figuring that out\n // would require more than just https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition\n // because that API doesn't work with Shadow DOM as well as it should (@see\n // https://github.com/whatwg/dom/issues/320) and since this first/last is only needed, so far,\n // to address an edge case related to positive tabindex support, this seems like a much easier,\n // \"close enough most of the time\" alternative for positive tabindexes which should generally\n // be avoided anyway...\n /** First tabbable node in container, __DOM__ order; `undefined` if none. */\n firstDomTabbableNode,\n /** Last tabbable node in container, __DOM__ order; `undefined` if none. */\n lastDomTabbableNode,\n\n /**\n * Finds the __tabbable__ node that follows the given node in the specified direction,\n * in this container, if any.\n * @param {HTMLElement} node\n * @param {boolean} [forward] True if going in forward tab order; false if going\n * in reverse.\n * @returns {HTMLElement|undefined} The next tabbable node, if any.\n */\n nextTabbableNode(node, forward = true) {\n const nodeIdx = tabbableNodes.indexOf(node);\n if (nodeIdx < 0) {\n // either not tabbable nor focusable, or was focused but not tabbable (negative tabindex):\n // since `node` should at least have been focusable, we assume that's the case and mimic\n // what browsers do, which is set focus to the next node in __document position order__,\n // regardless of positive tabindexes, if any -- and for reasons explained in the NOTE\n // above related to `firstDomTabbable` and `lastDomTabbable` properties, we fall back to\n // basic DOM order\n if (forward) {\n return focusableNodes\n .slice(focusableNodes.indexOf(node) + 1)\n .find((el) => isTabbable(el));\n }\n\n return focusableNodes\n .slice(0, focusableNodes.indexOf(node))\n .reverse()\n .find((el) => isTabbable(el));\n }\n\n return tabbableNodes[nodeIdx + (forward ? 1 : -1)];\n },\n };\n });\n\n state.tabbableGroups = state.containerGroups.filter(\n (group) => group.tabbableNodes.length > 0\n );\n\n // throw if no groups have tabbable nodes and we don't have a fallback focus node either\n if (\n state.tabbableGroups.length <= 0 &&\n !getNodeForOption('fallbackFocus') // returning false not supported for this option\n ) {\n throw new Error(\n 'Your focus-trap must have at least one container with at least one tabbable node in it at all times'\n );\n }\n\n // NOTE: Positive tabindexes are only properly supported in single-container traps because\n // doing it across multiple containers where tabindexes could be all over the place\n // would require Tabbable to support multiple containers, would require additional\n // specialized Shadow DOM support, and would require Tabbable's multi-container support\n // to look at those containers in document position order rather than user-provided\n // order (as they are treated in Focus-trap, for legacy reasons). See discussion on\n // https://github.com/focus-trap/focus-trap/issues/375 for more details.\n if (\n state.containerGroups.find((g) => g.posTabIndexesFound) &&\n state.containerGroups.length > 1\n ) {\n throw new Error(\n \"At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.\"\n );\n }\n };\n\n const tryFocus = function (node) {\n if (node === false) {\n return;\n }\n\n if (node === doc.activeElement) {\n return;\n }\n\n if (!node || !node.focus) {\n tryFocus(getInitialFocusNode());\n return;\n }\n\n node.focus({ preventScroll: !!config.preventScroll });\n // NOTE: focus() API does not trigger focusIn event so set MRU node manually\n state.mostRecentlyFocusedNode = node;\n\n if (isSelectableInput(node)) {\n node.select();\n }\n };\n\n const getReturnFocusNode = function (previousActiveElement) {\n const node = getNodeForOption('setReturnFocus', previousActiveElement);\n return node ? node : node === false ? false : previousActiveElement;\n };\n\n /**\n * Finds the next node (in either direction) where focus should move according to a\n * keyboard focus-in event.\n * @param {Object} params\n * @param {Node} [params.target] Known target __from which__ to navigate, if any.\n * @param {KeyboardEvent|FocusEvent} [params.event] Event to use if `target` isn't known (event\n * will be used to determine the `target`). Ignored if `target` is specified.\n * @param {boolean} [params.isBackward] True if focus should move backward.\n * @returns {Node|undefined} The next node, or `undefined` if a next node couldn't be\n * determined given the current state of the trap.\n */\n const findNextNavNode = function ({ target, event, isBackward = false }) {\n target = target || getActualTarget(event);\n updateTabbableNodes();\n\n let destinationNode = null;\n\n if (state.tabbableGroups.length > 0) {\n // make sure the target is actually contained in a group\n // NOTE: the target may also be the container itself if it's focusable\n // with tabIndex='-1' and was given initial focus\n const containerIndex = findContainerIndex(target, event);\n const containerGroup =\n containerIndex >= 0 ? state.containerGroups[containerIndex] : undefined;\n\n if (containerIndex < 0) {\n // target not found in any group: quite possible focus has escaped the trap,\n // so bring it back into...\n if (isBackward) {\n // ...the last node in the last group\n destinationNode =\n state.tabbableGroups[state.tabbableGroups.length - 1]\n .lastTabbableNode;\n } else {\n // ...the first node in the first group\n destinationNode = state.tabbableGroups[0].firstTabbableNode;\n }\n } else if (isBackward) {\n // REVERSE\n\n // is the target the first tabbable node in a group?\n let startOfGroupIndex = findIndex(\n state.tabbableGroups,\n ({ firstTabbableNode }) => target === firstTabbableNode\n );\n\n if (\n startOfGroupIndex < 0 &&\n (containerGroup.container === target ||\n (isFocusable(target, config.tabbableOptions) &&\n !isTabbable(target, config.tabbableOptions) &&\n !containerGroup.nextTabbableNode(target, false)))\n ) {\n // an exception case where the target is either the container itself, or\n // a non-tabbable node that was given focus (i.e. tabindex is negative\n // and user clicked on it or node was programmatically given focus)\n // and is not followed by any other tabbable node, in which\n // case, we should handle shift+tab as if focus were on the container's\n // first tabbable node, and go to the last tabbable node of the LAST group\n startOfGroupIndex = containerIndex;\n }\n\n if (startOfGroupIndex >= 0) {\n // YES: then shift+tab should go to the last tabbable node in the\n // previous group (and wrap around to the last tabbable node of\n // the LAST group if it's the first tabbable node of the FIRST group)\n const destinationGroupIndex =\n startOfGroupIndex === 0\n ? state.tabbableGroups.length - 1\n : startOfGroupIndex - 1;\n\n const destinationGroup = state.tabbableGroups[destinationGroupIndex];\n\n destinationNode =\n getTabIndex(target) >= 0\n ? destinationGroup.lastTabbableNode\n : destinationGroup.lastDomTabbableNode;\n } else if (!isTabEvent(event)) {\n // user must have customized the nav keys so we have to move focus manually _within_\n // the active group: do this based on the order determined by tabbable()\n destinationNode = containerGroup.nextTabbableNode(target, false);\n }\n } else {\n // FORWARD\n\n // is the target the last tabbable node in a group?\n let lastOfGroupIndex = findIndex(\n state.tabbableGroups,\n ({ lastTabbableNode }) => target === lastTabbableNode\n );\n\n if (\n lastOfGroupIndex < 0 &&\n (containerGroup.container === target ||\n (isFocusable(target, config.tabbableOptions) &&\n !isTabbable(target, config.tabbableOptions) &&\n !containerGroup.nextTabbableNode(target)))\n ) {\n // an exception case where the target is the container itself, or\n // a non-tabbable node that was given focus (i.e. tabindex is negative\n // and user clicked on it or node was programmatically given focus)\n // and is not followed by any other tabbable node, in which\n // case, we should handle tab as if focus were on the container's\n // last tabbable node, and go to the first tabbable node of the FIRST group\n lastOfGroupIndex = containerIndex;\n }\n\n if (lastOfGroupIndex >= 0) {\n // YES: then tab should go to the first tabbable node in the next\n // group (and wrap around to the first tabbable node of the FIRST\n // group if it's the last tabbable node of the LAST group)\n const destinationGroupIndex =\n lastOfGroupIndex === state.tabbableGroups.length - 1\n ? 0\n : lastOfGroupIndex + 1;\n\n const destinationGroup = state.tabbableGroups[destinationGroupIndex];\n\n destinationNode =\n getTabIndex(target) >= 0\n ? destinationGroup.firstTabbableNode\n : destinationGroup.firstDomTabbableNode;\n } else if (!isTabEvent(event)) {\n // user must have customized the nav keys so we have to move focus manually _within_\n // the active group: do this based on the order determined by tabbable()\n destinationNode = containerGroup.nextTabbableNode(target);\n }\n }\n } else {\n // no groups available\n // NOTE: the fallbackFocus option does not support returning false to opt-out\n destinationNode = getNodeForOption('fallbackFocus');\n }\n\n return destinationNode;\n };\n\n // This needs to be done on mousedown and touchstart instead of click\n // so that it precedes the focus event.\n const checkPointerDown = function (e) {\n const target = getActualTarget(e);\n\n if (findContainerIndex(target, e) >= 0) {\n // allow the click since it ocurred inside the trap\n return;\n }\n\n if (valueOrHandler(config.clickOutsideDeactivates, e)) {\n // immediately deactivate the trap\n trap.deactivate({\n // NOTE: by setting `returnFocus: false`, deactivate() will do nothing,\n // which will result in the outside click setting focus to the node\n // that was clicked (and if not focusable, to \"nothing\"); by setting\n // `returnFocus: true`, we'll attempt to re-focus the node originally-focused\n // on activation (or the configured `setReturnFocus` node), whether the\n // outside click was on a focusable node or not\n returnFocus: config.returnFocusOnDeactivate,\n });\n return;\n }\n\n // This is needed for mobile devices.\n // (If we'll only let `click` events through,\n // then on mobile they will be blocked anyways if `touchstart` is blocked.)\n if (valueOrHandler(config.allowOutsideClick, e)) {\n // allow the click outside the trap to take place\n return;\n }\n\n // otherwise, prevent the click\n e.preventDefault();\n };\n\n // In case focus escapes the trap for some strange reason, pull it back in.\n // NOTE: the focusIn event is NOT cancelable, so if focus escapes, it may cause unexpected\n // scrolling if the node that got focused was out of view; there's nothing we can do to\n // prevent that from happening by the time we discover that focus escaped\n const checkFocusIn = function (event) {\n const target = getActualTarget(event);\n const targetContained = findContainerIndex(target, event) >= 0;\n\n // In Firefox when you Tab out of an iframe the Document is briefly focused.\n if (targetContained || target instanceof Document) {\n if (targetContained) {\n state.mostRecentlyFocusedNode = target;\n }\n } else {\n // escaped! pull it back in to where it just left\n event.stopImmediatePropagation();\n\n // focus will escape if the MRU node had a positive tab index and user tried to nav forward;\n // it will also escape if the MRU node had a 0 tab index and user tried to nav backward\n // toward a node with a positive tab index\n let nextNode; // next node to focus, if we find one\n let navAcrossContainers = true;\n if (state.mostRecentlyFocusedNode) {\n if (getTabIndex(state.mostRecentlyFocusedNode) > 0) {\n // MRU container index must be >=0 otherwise we wouldn't have it as an MRU node...\n const mruContainerIdx = findContainerIndex(\n state.mostRecentlyFocusedNode\n );\n // there MAY not be any tabbable nodes in the container if there are at least 2 containers\n // and the MRU node is focusable but not tabbable (focus-trap requires at least 1 container\n // with at least one tabbable node in order to function, so this could be the other container\n // with nothing tabbable in it)\n const { tabbableNodes } = state.containerGroups[mruContainerIdx];\n if (tabbableNodes.length > 0) {\n // MRU tab index MAY not be found if the MRU node is focusable but not tabbable\n const mruTabIdx = tabbableNodes.findIndex(\n (node) => node === state.mostRecentlyFocusedNode\n );\n if (mruTabIdx >= 0) {\n if (config.isKeyForward(state.recentNavEvent)) {\n if (mruTabIdx + 1 < tabbableNodes.length) {\n nextNode = tabbableNodes[mruTabIdx + 1];\n navAcrossContainers = false;\n }\n // else, don't wrap within the container as focus should move to next/previous\n // container\n } else {\n if (mruTabIdx - 1 >= 0) {\n nextNode = tabbableNodes[mruTabIdx - 1];\n navAcrossContainers = false;\n }\n // else, don't wrap within the container as focus should move to next/previous\n // container\n }\n // else, don't find in container order without considering direction too\n }\n }\n // else, no tabbable nodes in that container (which means we must have at least one other\n // container with at least one tabbable node in it, otherwise focus-trap would've thrown\n // an error the last time updateTabbableNodes() was run): find next node among all known\n // containers\n } else {\n // check to see if there's at least one tabbable node with a positive tab index inside\n // the trap because focus seems to escape when navigating backward from a tabbable node\n // with tabindex=0 when this is the case (instead of wrapping to the tabbable node with\n // the greatest positive tab index like it should)\n if (\n !state.containerGroups.some((g) =>\n g.tabbableNodes.some((n) => getTabIndex(n) > 0)\n )\n ) {\n // no containers with tabbable nodes with positive tab indexes which means the focus\n // escaped for some other reason and we should just execute the fallback to the\n // MRU node or initial focus node, if any\n navAcrossContainers = false;\n }\n }\n } else {\n // no MRU node means we're likely in some initial condition when the trap has just\n // been activated and initial focus hasn't been given yet, in which case we should\n // fall through to trying to focus the initial focus node, which is what should\n // happen below at this point in the logic\n navAcrossContainers = false;\n }\n\n if (navAcrossContainers) {\n nextNode = findNextNavNode({\n // move FROM the MRU node, not event-related node (which will be the node that is\n // outside the trap causing the focus escape we're trying to fix)\n target: state.mostRecentlyFocusedNode,\n isBackward: config.isKeyBackward(state.recentNavEvent),\n });\n }\n\n if (nextNode) {\n tryFocus(nextNode);\n } else {\n tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());\n }\n }\n\n state.recentNavEvent = undefined; // clear\n };\n\n // Hijack key nav events on the first and last focusable nodes of the trap,\n // in order to prevent focus from escaping. If it escapes for even a\n // moment it can end up scrolling the page and causing confusion so we\n // kind of need to capture the action at the keydown phase.\n const checkKeyNav = function (event, isBackward = false) {\n state.recentNavEvent = event;\n\n const destinationNode = findNextNavNode({ event, isBackward });\n if (destinationNode) {\n if (isTabEvent(event)) {\n // since tab natively moves focus, we wouldn't have a destination node unless we\n // were on the edge of a container and had to move to the next/previous edge, in\n // which case we want to prevent default to keep the browser from moving focus\n // to where it normally would\n event.preventDefault();\n }\n tryFocus(destinationNode);\n }\n // else, let the browser take care of [shift+]tab and move the focus\n };\n\n const checkKey = function (event) {\n if (\n isEscapeEvent(event) &&\n valueOrHandler(config.escapeDeactivates, event) !== false\n ) {\n event.preventDefault();\n trap.deactivate();\n return;\n }\n\n if (config.isKeyForward(event) || config.isKeyBackward(event)) {\n checkKeyNav(event, config.isKeyBackward(event));\n }\n };\n\n const checkClick = function (e) {\n const target = getActualTarget(e);\n\n if (findContainerIndex(target, e) >= 0) {\n return;\n }\n\n if (valueOrHandler(config.clickOutsideDeactivates, e)) {\n return;\n }\n\n if (valueOrHandler(config.allowOutsideClick, e)) {\n return;\n }\n\n e.preventDefault();\n e.stopImmediatePropagation();\n };\n\n //\n // EVENT LISTENERS\n //\n\n const addListeners = function () {\n if (!state.active) {\n return;\n }\n\n // There can be only one listening focus trap at a time\n activeFocusTraps.activateTrap(trapStack, trap);\n\n // Delay ensures that the focused element doesn't capture the event\n // that caused the focus trap activation.\n state.delayInitialFocusTimer = config.delayInitialFocus\n ? delay(function () {\n tryFocus(getInitialFocusNode());\n })\n : tryFocus(getInitialFocusNode());\n\n doc.addEventListener('focusin', checkFocusIn, true);\n doc.addEventListener('mousedown', checkPointerDown, {\n capture: true,\n passive: false,\n });\n doc.addEventListener('touchstart', checkPointerDown, {\n capture: true,\n passive: false,\n });\n doc.addEventListener('click', checkClick, {\n capture: true,\n passive: false,\n });\n doc.addEventListener('keydown', checkKey, {\n capture: true,\n passive: false,\n });\n\n return trap;\n };\n\n const removeListeners = function () {\n if (!state.active) {\n return;\n }\n\n doc.removeEventListener('focusin', checkFocusIn, true);\n doc.removeEventListener('mousedown', checkPointerDown, true);\n doc.removeEventListener('touchstart', checkPointerDown, true);\n doc.removeEventListener('click', checkClick, true);\n doc.removeEventListener('keydown', checkKey, true);\n\n return trap;\n };\n\n //\n // MUTATION OBSERVER\n //\n\n const checkDomRemoval = function (mutations) {\n const isFocusedNodeRemoved = mutations.some(function (mutation) {\n const removedNodes = Array.from(mutation.removedNodes);\n return removedNodes.some(function (node) {\n return node === state.mostRecentlyFocusedNode;\n });\n });\n\n // If the currently focused is removed then browsers will move focus to the\n // <body> element. If this happens, try to move focus back into the trap.\n if (isFocusedNodeRemoved) {\n tryFocus(getInitialFocusNode());\n }\n };\n\n // Use MutationObserver - if supported - to detect if focused node is removed\n // from the DOM.\n const mutationObserver =\n typeof window !== 'undefined' && 'MutationObserver' in window\n ? new MutationObserver(checkDomRemoval)\n : undefined;\n\n const updateObservedNodes = function () {\n if (!mutationObserver) {\n return;\n }\n\n mutationObserver.disconnect();\n if (state.active && !state.paused) {\n state.containers.map(function (container) {\n mutationObserver.observe(container, {\n subtree: true,\n childList: true,\n });\n });\n }\n };\n\n //\n // TRAP DEFINITION\n //\n\n trap = {\n get active() {\n return state.active;\n },\n\n get paused() {\n return state.paused;\n },\n\n activate(activateOptions) {\n if (state.active) {\n return this;\n }\n\n const onActivate = getOption(activateOptions, 'onActivate');\n const onPostActivate = getOption(activateOptions, 'onPostActivate');\n const checkCanFocusTrap = getOption(activateOptions, 'checkCanFocusTrap');\n\n if (!checkCanFocusTrap) {\n updateTabbableNodes();\n }\n\n state.active = true;\n state.paused = false;\n state.nodeFocusedBeforeActivation = doc.activeElement;\n\n onActivate?.();\n\n const finishActivation = () => {\n if (checkCanFocusTrap) {\n updateTabbableNodes();\n }\n addListeners();\n updateObservedNodes();\n onPostActivate?.();\n };\n\n if (checkCanFocusTrap) {\n checkCanFocusTrap(state.containers.concat()).then(\n finishActivation,\n finishActivation\n );\n return this;\n }\n\n finishActivation();\n return this;\n },\n\n deactivate(deactivateOptions) {\n if (!state.active) {\n return this;\n }\n\n const options = {\n onDeactivate: config.onDeactivate,\n onPostDeactivate: config.onPostDeactivate,\n checkCanReturnFocus: config.checkCanReturnFocus,\n ...deactivateOptions,\n };\n\n clearTimeout(state.delayInitialFocusTimer); // noop if undefined\n state.delayInitialFocusTimer = undefined;\n\n removeListeners();\n state.active = false;\n state.paused = false;\n updateObservedNodes();\n\n activeFocusTraps.deactivateTrap(trapStack, trap);\n\n const onDeactivate = getOption(options, 'onDeactivate');\n const onPostDeactivate = getOption(options, 'onPostDeactivate');\n const checkCanReturnFocus = getOption(options, 'checkCanReturnFocus');\n const returnFocus = getOption(\n options,\n 'returnFocus',\n 'returnFocusOnDeactivate'\n );\n\n onDeactivate?.();\n\n const finishDeactivation = () => {\n delay(() => {\n if (returnFocus) {\n tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));\n }\n onPostDeactivate?.();\n });\n };\n\n if (returnFocus && checkCanReturnFocus) {\n checkCanReturnFocus(\n getReturnFocusNode(state.nodeFocusedBeforeActivation)\n ).then(finishDeactivation, finishDeactivation);\n return this;\n }\n\n finishDeactivation();\n return this;\n },\n\n pause(pauseOptions) {\n if (state.paused || !state.active) {\n return this;\n }\n\n const onPause = getOption(pauseOptions, 'onPause');\n const onPostPause = getOption(pauseOptions, 'onPostPause');\n\n state.paused = true;\n onPause?.();\n\n removeListeners();\n updateObservedNodes();\n\n onPostPause?.();\n return this;\n },\n\n unpause(unpauseOptions) {\n if (!state.paused || !state.active) {\n return this;\n }\n\n const onUnpause = getOption(unpauseOptions, 'onUnpause');\n const onPostUnpause = getOption(unpauseOptions, 'onPostUnpause');\n\n state.paused = false;\n onUnpause?.();\n\n updateTabbableNodes();\n addListeners();\n updateObservedNodes();\n\n onPostUnpause?.();\n return this;\n },\n\n updateContainerElements(containerElements) {\n const elementsAsArray = [].concat(containerElements).filter(Boolean);\n\n state.containers = elementsAsArray.map((element) =>\n typeof element === 'string' ? doc.querySelector(element) : element\n );\n\n if (state.active) {\n updateTabbableNodes();\n }\n\n updateObservedNodes();\n\n return this;\n },\n };\n\n // initialize container elements\n trap.updateContainerElements(elements);\n\n return trap;\n};\n\nexport { createFocusTrap };\n","import { createAnatomy } from \"@zag-js/anatomy\"\n\nexport const anatomy = createAnatomy(\"popover\").parts(\n \"arrow\",\n \"arrowTip\",\n \"anchor\",\n \"trigger\",\n \"positioner\",\n \"content\",\n \"title\",\n \"description\",\n \"closeTrigger\",\n)\nexport const parts = anatomy.build()\n","import { dataAttr } from \"@zag-js/dom-query\"\nimport type { PositioningOptions } from \"@zag-js/popper\"\nimport { getPlacementStyles } from \"@zag-js/popper\"\nimport type { NormalizeProps, PropTypes } from \"@zag-js/types\"\nimport { parts } from \"./popover.anatomy\"\nimport { dom } from \"./popover.dom\"\nimport type { MachineApi, Send, State } from \"./popover.types\"\n\nexport function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): MachineApi<T> {\n const isOpen = state.matches(\"open\")\n\n const currentPlacement = state.context.currentPlacement\n const portalled = state.context.currentPortalled\n const rendered = state.context.renderedElements\n\n const popperStyles = getPlacementStyles({\n ...state.context.positioning,\n placement: currentPlacement,\n })\n\n return {\n portalled,\n isOpen,\n\n open() {\n send(\"OPEN\")\n },\n\n close() {\n send(\"CLOSE\")\n },\n\n setPositioning(options: Partial<PositioningOptions> = {}) {\n send({ type: \"SET_POSITIONING\", options })\n },\n\n arrowProps: normalize.element({\n id: dom.getArrowId(state.context),\n ...parts.arrow.attrs,\n style: popperStyles.arrow,\n }),\n\n arrowTipProps: normalize.element({\n ...parts.arrowTip.attrs,\n style: popperStyles.arrowTip,\n }),\n\n anchorProps: normalize.element({\n ...parts.anchor.attrs,\n id: dom.getAnchorId(state.context),\n }),\n\n triggerProps: normalize.button({\n ...parts.trigger.attrs,\n type: \"button\",\n \"data-placement\": currentPlacement,\n id: dom.getTriggerId(state.context),\n \"aria-haspopup\": \"dialog\",\n \"aria-expanded\": isOpen,\n \"data-state\": isOpen ? \"open\" : \"closed\",\n \"aria-controls\": dom.getContentId(state.context),\n onClick() {\n send(\"TOGGLE\")\n },\n onBlur(event) {\n send({ type: \"TRIGGER_BLUR\", target: event.relatedTarget })\n },\n }),\n\n positionerProps: normalize.element({\n id: dom.getPositionerId(state.context),\n ...parts.positioner.attrs,\n style: popperStyles.floating,\n }),\n\n contentProps: normalize.element({\n ...parts.content.attrs,\n id: dom.getContentId(state.context),\n tabIndex: -1,\n role: \"dialog\",\n hidden: !isOpen,\n \"data-state\": isOpen ? \"open\" : \"closed\",\n \"data-expanded\": dataAttr(isOpen),\n \"aria-labelledby\": rendered.title ? dom.getTitleId(state.context) : undefined,\n \"aria-describedby\": rendered.description ? dom.getDescriptionId(state.context) : undefined,\n \"data-placement\": currentPlacement,\n }),\n\n titleProps: normalize.element({\n ...parts.title.attrs,\n id: dom.getTitleId(state.context),\n }),\n\n descriptionProps: normalize.element({\n ...parts.description.attrs,\n id: dom.getDescriptionId(state.context),\n }),\n\n closeTriggerProps: normalize.button({\n ...parts.closeTrigger.attrs,\n id: dom.getCloseTriggerId(state.context),\n type: \"button\",\n \"aria-label\": \"close\",\n onClick() {\n send(\"REQUEST_CLOSE\")\n },\n }),\n }\n}\n","import { createScope } from \"@zag-js/dom-query\"\nimport { getFirstTabbable, getFocusables, getLastTabbable, getTabbables } from \"@zag-js/tabbable\"\nimport { runIfFn } from \"@zag-js/utils\"\nimport type { MachineContext as Ctx } from \"./popover.types\"\n\nexport const dom = createScope({\n getActiveEl: (ctx: Ctx) => dom.getDoc(ctx).activeElement,\n\n getAnchorId: (ctx: Ctx) => ctx.ids?.anchor ?? `popover:${ctx.id}:anchor`,\n getTriggerId: (ctx: Ctx) => ctx.ids?.trigger ?? `popover:${ctx.id}:trigger`,\n getContentId: (ctx: Ctx) => ctx.ids?.content ?? `popover:${ctx.id}:content`,\n getPositionerId: (ctx: Ctx) => ctx.ids?.positioner ?? `popover:${ctx.id}:popper`,\n getArrowId: (ctx: Ctx) => ctx.ids?.arrow ?? `popover:${ctx.id}:arrow`,\n getTitleId: (ctx: Ctx) => ctx.ids?.title ?? `popover:${ctx.id}:title`,\n getDescriptionId: (ctx: Ctx) => ctx.ids?.description ?? `popover:${ctx.id}:desc`,\n getCloseTriggerId: (ctx: Ctx) => ctx.ids?.closeTrigger ?? `popover:${ctx.id}:close`,\n\n getAnchorEl: (ctx: Ctx) => dom.getById(ctx, dom.getAnchorId(ctx)),\n getTriggerEl: (ctx: Ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),\n getContentEl: (ctx: Ctx) => dom.getById(ctx, dom.getContentId(ctx)),\n getPositionerEl: (ctx: Ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),\n getTitleEl: (ctx: Ctx) => dom.getById(ctx, dom.getTitleId(ctx)),\n getDescriptionEl: (ctx: Ctx) => dom.getById(ctx, dom.getDescriptionId(ctx)),\n\n getFocusableEls: (ctx: Ctx) => getFocusables(dom.getContentEl(ctx)),\n getFirstFocusableEl: (ctx: Ctx) => dom.getFocusableEls(ctx)[0],\n\n getDocTabbableEls: (ctx: Ctx) => getTabbables(dom.getDoc(ctx).body),\n getTabbableEls: (ctx: Ctx) => getTabbables(dom.getContentEl(ctx), \"if-empty\"),\n getFirstTabbableEl: (ctx: Ctx) => getFirstTabbable(dom.getContentEl(ctx), \"if-empty\"),\n getLastTabbableEl: (ctx: Ctx) => getLastTabbable(dom.getContentEl(ctx), \"if-empty\"),\n\n getInitialFocusEl: (ctx: Ctx) => {\n let el: HTMLElement | null = runIfFn(ctx.initialFocusEl)\n if (!el && ctx.autoFocus) el = dom.getFirstFocusableEl(ctx)\n if (!el) el = dom.getContentEl(ctx)\n return el\n },\n})\n","import { ariaHidden } from \"@zag-js/aria-hidden\"\nimport { createMachine } from \"@zag-js/core\"\nimport { trackDismissableElement } from \"@zag-js/dismissable\"\nimport { nextTick, raf } from \"@zag-js/dom-query\"\nimport { getPlacement } from \"@zag-js/popper\"\nimport { preventBodyScroll } from \"@zag-js/remove-scroll\"\nimport { proxyTabFocus } from \"@zag-js/tabbable\"\nimport { compact, runIfFn } from \"@zag-js/utils\"\nimport { createFocusTrap, type FocusTrap } from \"focus-trap\"\nimport { dom } from \"./popover.dom\"\nimport type { MachineContext, MachineState, UserDefinedContext } from \"./popover.types\"\n\nexport function machine(userContext: UserDefinedContext) {\n const ctx = compact(userContext)\n return createMachine<MachineContext, MachineState>(\n {\n id: \"popover\",\n initial: ctx.open ? \"open\" : \"closed\",\n context: {\n closeOnInteractOutside: true,\n closeOnEsc: true,\n autoFocus: true,\n modal: false,\n portalled: true,\n positioning: {\n placement: \"bottom\",\n ...ctx.positioning,\n },\n currentPlacement: undefined,\n ...ctx,\n renderedElements: {\n title: true,\n description: true,\n },\n },\n\n computed: {\n currentPortalled: (ctx) => !!ctx.modal || !!ctx.portalled,\n },\n\n watch: {\n open: [\"toggleVisibility\"],\n },\n\n entry: [\"checkRenderedElements\"],\n\n states: {\n closed: {\n on: {\n TOGGLE: {\n target: \"open\",\n actions: [\"invokeOnOpen\"],\n },\n OPEN: {\n target: \"open\",\n actions: [\"invokeOnOpen\"],\n },\n },\n },\n\n open: {\n activities: [\n \"trapFocus\",\n \"preventScroll\",\n \"hideContentBelow\",\n \"trackPositioning\",\n \"trackDismissableElement\",\n \"proxyTabFocus\",\n ],\n entry: [\"setInitialFocus\"],\n on: {\n CLOSE: {\n target: \"closed\",\n actions: [\"invokeOnClose\"],\n },\n REQUEST_CLOSE: {\n target: \"closed\",\n actions: [\"restoreFocusIfNeeded\", \"invokeOnClose\"],\n },\n TOGGLE: {\n target: \"closed\",\n actions: [\"invokeOnClose\"],\n },\n SET_POSITIONING: {\n actions: \"setPositioning\",\n },\n },\n },\n },\n },\n {\n activities: {\n trackPositioning(ctx) {\n ctx.currentPlacement = ctx.positioning.placement\n const anchorEl = dom.getAnchorEl(ctx) ?? dom.getTriggerEl(ctx)\n const getPositionerEl = () => dom.getPositionerEl(ctx)\n return getPlacement(anchorEl, getPositionerEl, {\n ...ctx.positioning,\n defer: true,\n onComplete(data) {\n ctx.currentPlacement = data.placement\n },\n onCleanup() {\n ctx.currentPlacement = undefined\n },\n })\n },\n trackDismissableElement(ctx, _evt, { send }) {\n const getContentEl = () => dom.getContentEl(ctx)\n let restoreFocus = true\n return trackDismissableElement(getContentEl, {\n pointerBlocking: ctx.modal,\n exclude: dom.getTriggerEl(ctx),\n defer: true,\n onEscapeKeyDown(event) {\n ctx.onEscapeKeyDown?.(event)\n if (ctx.closeOnEsc) return\n event.preventDefault()\n },\n onInteractOutside(event) {\n ctx.onInteractOutside?.(event)\n if (event.defaultPrevented) return\n restoreFocus = !(event.detail.focusable || event.detail.contextmenu)\n if (!ctx.closeOnInteractOutside) {\n event.preventDefault()\n }\n },\n onPointerDownOutside: ctx.onPointerDownOutside,\n onFocusOutside: ctx.onFocusOutside,\n onDismiss() {\n send({ type: \"REQUEST_CLOSE\", src: \"interact-outside\", restoreFocus })\n },\n })\n },\n proxyTabFocus(ctx) {\n if (ctx.modal || !ctx.portalled) return\n const getContentEl = () => dom.getContentEl(ctx)\n return proxyTabFocus(getContentEl, {\n triggerElement: dom.getTriggerEl(ctx),\n defer: true,\n onFocus(el) {\n el.focus({ preventScroll: true })\n },\n })\n },\n hideContentBelow(ctx) {\n if (!ctx.modal) return\n const getElements = () => [dom.getContentEl(ctx), dom.getTriggerEl(ctx)]\n return ariaHidden(getElements, { defer: true })\n },\n preventScroll(ctx) {\n if (!ctx.modal) return\n return preventBodyScroll(dom.getDoc(ctx))\n },\n trapFocus(ctx) {\n if (!ctx.modal) return\n let trap: FocusTrap | undefined\n nextTick(() => {\n const el = dom.getContentEl(ctx)\n if (!el) return\n trap = createFocusTrap(el, {\n escapeDeactivates: false,\n allowOutsideClick: true,\n preventScroll: true,\n returnFocusOnDeactivate: true,\n document: dom.getDoc(ctx),\n fallbackFocus: el,\n initialFocus: runIfFn(ctx.initialFocusEl),\n })\n try {\n trap.activate()\n } catch {}\n })\n return () => trap?.deactivate()\n },\n },\n actions: {\n setPositioning(ctx, evt) {\n const anchorEl = dom.getAnchorEl(ctx) ?? dom.getTriggerEl(ctx)\n const getPositionerEl = () => dom.getPositionerEl(ctx)\n getPlacement(anchorEl, getPositionerEl, {\n ...ctx.positioning,\n ...evt.options,\n defer: true,\n listeners: false,\n })\n },\n checkRenderedElements(ctx) {\n raf(() => {\n Object.assign(ctx.renderedElements, {\n title: !!dom.getTitleEl(ctx),\n description: !!dom.getDescriptionEl(ctx),\n })\n })\n },\n setInitialFocus(ctx) {\n raf(() => {\n dom.getInitialFocusEl(ctx)?.focus({ preventScroll: true })\n })\n },\n restoreFocusIfNeeded(ctx, evt) {\n if (!evt.restoreFocus) return\n raf(() => {\n dom.getTriggerEl(ctx)?.focus({ preventScroll: true })\n })\n },\n invokeOnOpen(ctx) {\n ctx.onOpen?.()\n },\n invokeOnClose(ctx) {\n ctx.onClose?.()\n },\n toggleVisibility(ctx, _evt, { send }) {\n send({ type: ctx.open ? \"OPEN\" : \"CLOSE\", src: \"controlled\" })\n },\n },\n },\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAgD,cAAc;;;ACO9D,SAAS,WAAW,SAAS,OAAO,gBAAgB,cAAc,UAAU,gBAAgB;;;AEPrF,IAAMA,iBAAgB,CAAC,YAC5B,OAAO,YAAY,YAAY,YAAY,QAAQ,QAAQ,aAAa;AAEnE,IAAM,UAAU,CAAC,YACtBA,eAAc,OAAO,KAAK,QAAQ,YAAY;AAEzC,SAAS,UAAU,IAAS;AACjC,MAAI,CAACA,eAAc,EAAE;AAAG,WAAO;AAC/B,SAAO,GAAG,cAAc,KAAK,GAAG,eAAe,KAAK,GAAG,eAAe,EAAE,SAAS;AACnF;AAIO,SAAS,oBAAoB,SAAkB;AACpD,QAAM,WAAW,SAAS,QAAQ,aAAa,UAAU,KAAK,KAAK,EAAE;AACrE,SAAO,WAAW;AACpB;AAEO,IAAM,oBACG;ACbT,IAAM,gBAAgB,CAC3B,WACA,mBAAyC,UACtC;AACH,MAAI,CAAC;AAAW,WAAO,CAAC;AACxB,QAAM,WAAW,MAAM,KAAK,UAAU,iBAA8B,iBAAiB,CAAC;AAEtF,QAAM,UAAU,oBAAoB,QAAS,oBAAoB,cAAc,SAAS,WAAW;AACnG,MAAI,WAAWA,eAAc,SAAS,KAAK,YAAY,SAAS,GAAG;AACjE,aAAS,QAAQ,SAAS;EAC5B;AAEA,QAAM,oBAAoB,SAAS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Aa;AAAA,YACf;AAAA,YAEC;AAAA;AAAA,QACH;AAAA,MAEJ;AAAA,MACA,oBAAoB;AAAA,QAClB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACC,GAAG;AAAA,MACJ,aAAa;AAAA,QACX,GAAG;AAAA,QACH;AAAA,MACF;AAAA,MACA;AAAA,MAEC,WAAC,EAAE,aAAa,MAAM;AACrB,eACE,gBAAAA;AAAA,UAAC;AAAA;AAAA,YACC,WAAU;AAAA,YACT,GAAG;AAAA,YAEH;AAAA;AAAA,QACH;AAAA,MAEJ;AAAA;AAAA,EACF;AAEJ;","names":["isHTMLElement","root","handler","getDocument","node","contains","candidateSelectors","candidateSelector","join","NoElement","Element","matches","prototype","msMatchesSelector","webkitMatchesSelector","getRootNode","element","_element$getRootNode","call","ownerDocument","isInert","node","lookUp","_node$getAttribute","inertAtt","getAttribute","inert","result","parentNode","isContentEditable","_node$getAttribute2","attValue","getCandidates","el","includeContainer","filter","candidates","Array","slice","apply","querySelectorAll","unshift","getCandidatesIteratively","elements","options","elementsToCheck","from","length","shift","tagName","assigned","assignedElements","content","children","nestedCandidates","flatten","push","scopeParent","validCandidate","includes","shadowRoot","getShadowRoot","validShadowRoot","shadowRootFilter","hasTabIndex","isNaN","parseInt","getTabIndex","Error","tabIndex","test","getSortOrderTabIndex","isScope","sortOrderedTabbables","a","b","documentOrder","isInput","isHiddenInput","type","isDetailsWithSummary","r","some","child","getCheckedRadio","nodes","form","i","checked","isTabbableRadio","name","radioScope","queryRadios","radioSet","window","CSS","escape","err","console","error","message","isRadio","isNonTabbableRadio","isNodeAttached","_nodeRoot","nodeRoot","nodeRootHost","host","attached","_nodeRootHost","_nodeRootHost$ownerDo","_node$ownerDocument","contains","_nodeRoot2","_nodeRootHost2","_nodeRootHost2$ownerD","isZeroArea","_node$getBoundingClie","getBoundingClientRect","width","height","isHidden","_ref","displayCheck","getComputedStyle","visibility","isDirectSummary","nodeUnderDetails","parentElement","originalNode","rootNode","assignedSlot","getClientRects","isDisabledFromFieldset","disabled","item","isNodeMatchingSelectorFocusable","isNodeMatchingSelectorTabbable","isValidShadowRootTabbable","shadowHostNode","sortByOrder","regularTabbables","orderedTabbables","forEach","candidateTabindex","sort","reduce","acc","sortable","concat","tabbable","container","bind","focusable","isTabbable","focusableCandidateSelector","isFocusable","activeFocusTraps","activateTrap","trapStack","trap","length","activeTrap","pause","trapIndex","indexOf","push","splice","deactivateTrap","unpause","isSelectableInput","node","tagName","toLowerCase","select","isEscapeEvent","e","key","keyCode","isTabEvent","isKeyForward","shiftKey","isKeyBackward","delay","fn","setTimeout","findIndex","arr","idx","every","value","i","valueOrHandler","_len","arguments","params","Array","_key","apply","getActualTarget","event","target","shadowRoot","composedPath","internalTrapStack","createFocusTrap","elements","userOptions","doc","document","config","_objectSpread","returnFocusOnDeactivate","escapeDeactivates","delayInitialFocus","state","containers","containerGroups","tabbableGroups","nodeFocusedBeforeActivation","mostRecentlyFocusedNode","active","paused","delayInitialFocusTimer","undefined","recentNavEvent","getOption","configOverrideOptions","optionName","configOptionName","findContainerIndex","element","_ref","container","tabbableNodes","contains","includes","find","getNodeForOption","optionValue","_len2","_key2","Error","concat","querySelector","getInitialFocusNode","isFocusable","tabbableOptions","activeElement","firstTabbableGroup","firstTabbableNode","updateTabbableNodes","map","tabbable","focusableNodes","focusable","lastTabbableNode","firstDomTabbableNode","isTabbable","lastDomTabbableNode","slice","reverse","posTabIndexesFound","getTabIndex","nextTabbableNode","forward","nodeIdx","el","filter","group","g","tryFocus","focus","preventScroll","getReturnFocusNode","previousActiveElement","findNextNavNode","_ref2","_ref2$isBackward","isBackward","destinationNode","containerIndex","containerGroup","startOfGroupIndex","_ref3","destinationGroupIndex","destinationGroup","lastOfGroupIndex","_ref4","checkPointerDown","clickOutsideDeactivates","deactivate","returnFocus","allowOutsideClick","preventDefault","checkFocusIn","targetContained","Document","stopImmediatePropagation","nextNode","navAcrossContainers","mruContainerIdx","mruTabIdx","some","n","checkKeyNav","checkKey","checkClick","addListeners","addEventListener","capture","passive","removeListeners","removeEventListener","checkDomRemoval","mutations","isFocusedNodeRemoved","mutation","removedNodes","from","mutationObserver","window","MutationObserver","updateObservedNodes","disconnect","observe","subtree","childList","activate","activateOptions","onActivate","onPostActivate","checkCanFocusTrap","finishActivation","then","deactivateOptions","options","onDeactivate","onPostDeactivate","checkCanReturnFocus","clearTimeout","finishDeactivation","pauseOptions","onPause","onPostPause","unpauseOptions","onUnpause","onPostUnpause","updateContainerElements","containerElements","elementsAsArray","Boolean","ctx","runIfFn","jsx","Popover"]}