"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
  var target = {};
  for (var prop in source)
    if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
      target[prop] = source[prop];
  if (source != null && __getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(source)) {
      if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
        target[prop] = source[prop];
    }
  return target;
};
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/atoms/dialog.tsx
var dialog_exports = {};
__export(dialog_exports, {
  Dialog: () => Dialog
});
module.exports = __toCommonJS(dialog_exports);
var RadixDialog = __toESM(require("@radix-ui/react-dialog"), 1);
var import_react_icons = require("@radix-ui/react-icons");
var import_themes4 = require("@radix-ui/themes");
var import_react3 = require("react");

// src/theme/portal-provider.tsx
var import_react = require("react");
var import_jsx_runtime = require("react/jsx-runtime");
var PortalContext = (0, import_react.createContext)(
  null
);
var usePortalContainer = () => {
  try {
    const state = (0, import_react.useContext)(PortalContext);
    return state;
  } catch (error) {
    throw new Error("PortalProvider not found");
  }
};

// src/atoms/heading.tsx
var import_themes = require("@radix-ui/themes");
var import_react2 = require("react");

// src/utils/map-with-responsive.ts
var mapWithResponsive = (args) => {
  const { value, mapFn } = args;
  if (typeof value === "string") {
    return mapFn(value);
  }
  ;
  if (typeof value === "object") {
    const newObj = {};
    let key;
    for (key in value) {
      newObj[key] = mapFn(value[key]);
    }
    return newObj;
  }
  return value;
};

// src/atoms/heading.tsx
var import_themes2 = require("@radix-ui/themes");
var import_jsx_runtime2 = require("react/jsx-runtime");
var mapVariant = (variant) => {
  switch (variant) {
    case "heading1":
      return "7";
    case "heading2":
      return "6";
    case "heading3":
      return "5";
    case "heading4":
      return "4";
    case "heading5":
      return "3";
    default:
      return void 0;
  }
};
function Heading2(props) {
  const _a = props, { size, children, variant } = _a, rest = __objRest(_a, ["size", "children", "variant"]);
  const radixSize = (0, import_react2.useMemo)(() => {
    return variant ? mapWithResponsive({
      value: variant,
      mapFn: mapVariant
    }) : size;
  }, [size, variant]);
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_themes.Heading, __spreadProps(__spreadValues({}, rest), { size: radixSize, children }));
}

// src/atoms/icon-button.tsx
var import_themes3 = require("@radix-ui/themes");

// src/atoms/dialog.tsx
var import_jsx_runtime3 = require("react/jsx-runtime");
var preventDefault = (e) => {
  e.preventDefault();
};
function Content2(props) {
  const _a = props, {
    children,
    style = {},
    width,
    maxWidth,
    minWidth,
    maxHeight,
    height,
    minHeight,
    title,
    buttons,
    hideCloseButton,
    className
  } = _a, rest = __objRest(_a, [
    "children",
    "style",
    "width",
    "maxWidth",
    "minWidth",
    "maxHeight",
    "height",
    "minHeight",
    "title",
    "buttons",
    "hideCloseButton",
    "className"
  ]);
  const { dialogContainerRef } = usePortalContainer();
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(RadixDialog.Portal, { container: dialogContainerRef.current, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_themes4.Theme, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(RadixDialog.Overlay, { className: "DialogOverlay", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
    RadixDialog.Content,
    __spreadProps(__spreadValues({
      className: `DialogContent ${className || ""}`,
      onPointerDownOutside: preventDefault,
      style: __spreadValues({
        width,
        maxWidth,
        minWidth,
        maxHeight,
        height,
        minHeight
      }, style)
    }, rest), {
      children: [
        /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_themes4.Flex, { gap: "2", justify: "between", width: "100%", children: [
          /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(RadixDialog.Title, { asChild: true, children: typeof title === "string" && title !== "" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Heading2, { mb: "2", variant: "heading3", children: title }) : title }),
          !hideCloseButton && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(RadixDialog.Close, { asChild: true, className: "DialogClose", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_themes3.IconButton, { color: "gray", variant: "ghost", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_icons.Cross1Icon, {}) }) })
        ] }),
        children,
        buttons ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_themes4.Flex, { gap: "3", justify: "end", mt: "3", width: "100%", children: buttons }) : null
      ]
    })
  ) }) }) });
}
function Close2(_a) {
  var _b = _a, {
    children
  } = _b, rest = __objRest(_b, [
    "children"
  ]);
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(RadixDialog.Close, __spreadProps(__spreadValues({ asChild: true }, rest), { children }));
}
function Trigger2(_a) {
  var _b = _a, {
    children
  } = _b, rest = __objRest(_b, [
    "children"
  ]);
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(RadixDialog.Trigger, __spreadProps(__spreadValues({ asChild: true }, rest), { children }));
}
function Root2(props) {
  (0, import_react3.useEffect)(() => {
    if (!props.open) {
      const timer = setTimeout(() => {
        var _a;
        const activeElement = document.activeElement;
        (_a = activeElement == null ? void 0 : activeElement.blur) == null ? void 0 : _a.call(activeElement);
        document.body.style.pointerEvents = "";
      }, 100);
      return () => {
        clearTimeout(timer);
      };
    }
  }, [props.open]);
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(RadixDialog.Root, __spreadValues({}, props));
}
var Dialog = {
  Root: Root2,
  Trigger: Trigger2,
  Content: Content2,
  Close: Close2,
  Description: RadixDialog.Description,
  Title: RadixDialog.Title
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  Dialog
});
//# sourceMappingURL=dialog.cjs.map