import {
  $07b14b47974efb58$export$5b6b19405a83ff9d,
  $3b117e43dc0ca95d$export$27c701ed9e449e99,
  $de32f1b87079253c$export$2e1e1122cf0cba88
} from "./chunk-YNY3GJXN.js";
import {
  __name
} from "./chunk-MM7DTO55.js";

// src/components/components/Popover/WithPopover.tsx
import React, { useCallback, useState } from "react";
import { Popover, convertToReactAriaPlacement } from "storybook/internal/components";
var WithPopover = /* @__PURE__ */ __name(({
  placement: placementProp = "bottom-start",
  hasChrome = true,
  hasCloseButton = false,
  closeLabel,
  offset = 8,
  padding,
  popover,
  children,
  defaultVisible,
  visible,
  onVisibleChange,
  ...props
}) => {
  const placement = convertToReactAriaPlacement(placementProp);
  const [isOpen, setIsOpen] = useState(defaultVisible ?? false);
  const onOpenChange = useCallback(
    (isOpen2) => {
      setIsOpen(isOpen2);
      onVisibleChange?.(isOpen2);
    },
    [onVisibleChange]
  );
  const onHide = useCallback(() => setIsOpen(false), []);
  return React.createElement(
    $de32f1b87079253c$export$2e1e1122cf0cba88,
    {
      defaultOpen: defaultVisible,
      isOpen: visible ?? isOpen,
      onOpenChange,
      ...props
    },
    React.createElement($3b117e43dc0ca95d$export$27c701ed9e449e99, null, children),
    React.createElement(
      $07b14b47974efb58$export$5b6b19405a83ff9d,
      {
        placement,
        offset,
        style: { outlineColor: "transparent" }
      },
      React.createElement(
        Popover,
        {
          hasChrome,
          hideLabel: closeLabel,
          onHide: hasCloseButton ? onHide : void 0,
          padding
        },
        typeof popover === "function" ? popover({ onHide }) : popover
      )
    )
  );
}, "WithPopover");

export {
  WithPopover
};
