{"mappings":"AAoBA,OAAO,cAAMA,2BAA2B,aAAa,SAAS;AAoC9D,OAAO,cAAMC,2BAA2B,aAAa,SAAS","names":["hidePopover: (this: void | HTMLElement, element: HTMLElement) => void","showPopover: (this: void | HTMLElement, element: HTMLElement) => void"],"sources":["../../../src/internal/popover.ts"],"sourcesContent":["import { memoize } from \"./utils.js\";\n\nconst POPOVER = \"popover\";\n\nconst supportPopover = memoize(() => Object.hasOwn(HTMLElement.prototype, POPOVER));\n\nconst getPopoverAttribute = (element: HTMLElement) => element.getAttribute(POPOVER);\n\nconst shimHide = (element: HTMLElement) => {\n  element.style.display = \"none\";\n};\n\nconst standardHide = (element: HTMLElement) => {\n  if (getPopoverAttribute(element) !== null) {\n    element.hidePopover();\n  } else {\n    shimHide(element);\n  }\n};\n\nexport const hidePopover: (this: void | HTMLElement, element: HTMLElement) => void = function (this, element) {\n  const hideFn = supportPopover() ? standardHide : shimHide;\n  hideFn.call(this, element);\n};\n\nconst shimShow = (element: HTMLElement) => {\n  element.style.display = \"block\";\n\n  if (getPopoverAttribute(element) !== \"manual\") {\n    const listenType = \"click\";\n    const listener = (e: MouseEvent) => {\n      if (!element.contains(e.target as Node)) {\n        element.dispatchEvent(\n          new Event(\"toggle\", {\n            bubbles: true,\n            composed: true,\n            newState: \"closed\",\n          } as ToggleEvent),\n        );\n        hidePopover(element);\n        document.removeEventListener(listenType, listener);\n      }\n    };\n\n    document.addEventListener(listenType, listener);\n  }\n};\n\nconst standardShow = (element: HTMLElement) => {\n  if (getPopoverAttribute(element) !== null) {\n    element.showPopover();\n  } else {\n    shimShow(element);\n  }\n};\n\nexport const showPopover: (this: void | HTMLElement, element: HTMLElement) => void = function (this, element) {\n  const showFn = supportPopover() ? standardShow : shimShow;\n  showFn.call(this, element);\n};\n"],"version":3,"file":"popover.d.ts"}