'use strict';
'use client';
import { jsxs, jsx } from 'react/jsx-runtime';
import { cn } from '../../../fd-toolbox/lib/utils.js';
import { Button } from '../button/Button.js';
import { Dialog } from '@base-ui/react/dialog';
import { Icon, iconNames } from '../icon/Icon.js';
import { onYesClick } from './YesOrNoDialog.funcs.js';
import { elements } from '../../../fd-toolbox/constants/elements.js';

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", {
  value,
  configurable: true
});
function YesOrNoDialog({
  title,
  className,
  trigger,
  asTriggerChild,
  onResponse,
  onCloseClick,
  showNoButton,
  triggerClassName,
  disabled
}) {
  const isShowNoButton = showNoButton ?? true;
  return /* @__PURE__ */jsxs(Dialog.Root, {
    children: [/* @__PURE__ */jsx(Dialog.Trigger, {
      render: asTriggerChild && trigger ? trigger : void 0,
      className: triggerClassName,
      disabled,
      children: !asTriggerChild && trigger
    }), /* @__PURE__ */jsxs(Dialog.Portal, {
      children: [/* @__PURE__ */jsx(Dialog.Backdrop, {
        className: "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/80"
      }), /* @__PURE__ */jsxs(Dialog.Viewport, {
        className: cn("fixed top-1/2 left-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 border", "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out p-6 pt-11 shadow-lg duration-200", "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95", "data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-1/2 data-[state=open]:slide-in-from-left-1/2", "data-[state=open]:slide-in-from-top-1/2 sm:rounded", className),
        children: [/* @__PURE__ */jsxs("div", {
          tabIndex: 1,
          children: [/* @__PURE__ */jsx(Dialog.Title, {
            children: title
          }), /* @__PURE__ */jsx(Dialog.Description, {}), /* @__PURE__ */jsxs(Dialog.Close, {
            className: "ring-offset-background focus:ring-primary data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none",
            children: [/* @__PURE__ */jsx(Icon, {
              name: iconNames.cross
            }), /* @__PURE__ */jsx("span", {
              className: "sr-only",
              children: "Close"
            })]
          })]
        }), /* @__PURE__ */jsxs("div", {
          className: "flex flex-row justify-end gap-2",
          children: [/* @__PURE__ */jsx(Dialog.Close, {
            children: /* @__PURE__ */jsx(Button, {
              id: elements.dialogButton.yes,
              className: "rounded",
              onClick: () => onYesClick(onResponse, onCloseClick),
              variant: "outline",
              children: isShowNoButton ? "Yes" : "Ok"
            })
          }), isShowNoButton && /* @__PURE__ */jsx(Dialog.Close, {
            children: /* @__PURE__ */jsx(Button, {
              id: elements.dialogButton.no,
              onClick: () => onResponse?.(false),
              children: "No"
            })
          })]
        })]
      })]
    })]
  });
}
__name(YesOrNoDialog, "YesOrNoDialog");

export { YesOrNoDialog };
