import { jsxs, jsx } from "react/jsx-runtime";
import { Dialog } from "@choiceform/design-system";
import { observer, use$ as useSelector } from "../../_vendor/@legendapp/state/react.js";
import { useEventCallback } from "../../_vendor/usehooks-ts/dist-index.js";
import { coreStore$, coreActions } from "../../stores/core-store.js";
const AttachmentPreviewDialog = observer(() => {
  const attachmentPreviewDialog = useSelector(coreStore$.ui.attachmentPreviewDialog);
  const handleOpenChange = useEventCallback((open) => {
    if (open) {
      coreActions.setAttachmentPreviewDialog(attachmentPreviewDialog.attachment);
    } else {
      coreActions.closeAttachmentPreviewDialog();
    }
  });
  return /* @__PURE__ */ jsxs(
    Dialog,
    {
      outsidePress: true,
      draggable: true,
      open: attachmentPreviewDialog.open,
      onOpenChange: handleOpenChange,
      className: "overflow-hidden",
      focusManagerProps: {
        initialFocus: 0
      },
      children: [
        /* @__PURE__ */ jsx(
          Dialog.Header,
          {
            title: attachmentPreviewDialog.attachment?.name,
            className: "border-none"
          }
        ),
        /* @__PURE__ */ jsx(Dialog.Content, { children: attachmentPreviewDialog.attachment && /* @__PURE__ */ jsx(
          "img",
          {
            src: attachmentPreviewDialog.attachment.url,
            alt: attachmentPreviewDialog.attachment.name,
            className: "max-h-[80vh] max-w-[80vw]"
          }
        ) })
      ]
    }
  );
});
export {
  AttachmentPreviewDialog
};
//# sourceMappingURL=attachment-preview-dialog.js.map
