'use client';
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
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/Portal/Portal.tsx
var Portal_exports = {};
__export(Portal_exports, {
  Portal: () => Portal
});
module.exports = __toCommonJS(Portal_exports);
var import_react5 = require("react");
var import_react_dom = require("react-dom");

// ../hooks/src/use-isomorphic-effect/use-isomorphic-effect.ts
var import_react = require("react");
var useIsomorphicEffect = typeof document !== "undefined" ? import_react.useLayoutEffect : import_react.useEffect;

// ../../node_modules/clsx/dist/clsx.mjs
function r(e) {
  var t, f, n = "";
  if ("string" == typeof e || "number" == typeof e) n += e;
  else if ("object" == typeof e) if (Array.isArray(e)) {
    var o = e.length;
    for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
  } else for (f in e) e[f] && (n && (n += " "), n += f);
  return n;
}
function clsx() {
  for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
  return n;
}

// ../../node_modules/class-variance-authority/dist/index.mjs
var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
var cx = clsx;
var cva = (base, config) => (props) => {
  var _config_compoundVariants;
  if ((config === null || config === void 0 ? void 0 : config.variants) == null) return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
  const { variants, defaultVariants } = config;
  const getVariantClassNames = Object.keys(variants).map((variant) => {
    const variantProp = props === null || props === void 0 ? void 0 : props[variant];
    const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];
    if (variantProp === null) return null;
    const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);
    return variants[variant][variantKey];
  });
  const propsWithoutUndefined = props && Object.entries(props).reduce((acc, param) => {
    let [key, value] = param;
    if (value === void 0) {
      return acc;
    }
    acc[key] = value;
    return acc;
  }, {});
  const getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (_config_compoundVariants = config.compoundVariants) === null || _config_compoundVariants === void 0 ? void 0 : _config_compoundVariants.reduce((acc, param) => {
    let { class: cvClass, className: cvClassName, ...compoundVariantOptions } = param;
    return Object.entries(compoundVariantOptions).every((param2) => {
      let [key, value] = param2;
      return Array.isArray(value) ? value.includes({
        ...defaultVariants,
        ...propsWithoutUndefined
      }[key]) : {
        ...defaultVariants,
        ...propsWithoutUndefined
      }[key] === value;
    }) ? [
      ...acc,
      cvClass,
      cvClassName
    ] : acc;
  }, []);
  return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
};

// ../shared/src/constants/colors.ts
var TAILWIND_COLOR_VARIANTS = [
  "gray",
  "red",
  "orange",
  "amber",
  "yellow",
  "lime",
  "green",
  "emerald",
  "teal",
  "cyan",
  "sky",
  "blue",
  "indigo",
  "violet",
  "purple",
  "fuchsia",
  "pink",
  "rose"
];
var COLOR_VARIANTS = [
  "primary",
  "secondary",
  "tertiary",
  "destructive",
  "info",
  "success",
  "warning",
  "danger",
  "muted",
  "accent"
];
var ALL_COLOR_VARIANTS = [...TAILWIND_COLOR_VARIANTS, ...COLOR_VARIANTS];
var BOX_COLOR_VARIANTS = [
  ...ALL_COLOR_VARIANTS,
  "muted",
  "black",
  "white",
  "transparent",
  "background",
  "foreground",
  "inherit",
  "currentColor",
  "dimmed"
];
var tailwindBoxVariants = cva("", {
  variants: {
    bg: {
      gray: "bg-gray-600",
      red: "bg-red-600",
      orange: "bg-orange-600",
      amber: "bg-amber-600",
      yellow: "bg-yellow-600",
      lime: "bg-lime-600",
      green: "bg-green-600",
      emerald: "bg-emerald-600",
      teal: "bg-teal-600",
      cyan: "bg-cyan-600",
      sky: "bg-sky-600",
      blue: "bg-blue-600",
      indigo: "bg-indigo-600",
      violet: "bg-violet-600",
      purple: "bg-purple-600",
      fuchsia: "bg-fuchsia-600",
      pink: "bg-pink-600",
      rose: "bg-rose-600",
      black: "bg-black",
      white: "bg-white",
      transparent: "bg-transparent",
      background: "bg-background",
      foreground: "bg-foreground",
      inherit: "bg-inherit",
      primary: "bg-primary",
      secondary: "bg-secondary",
      tertiary: "bg-tertiary",
      destructive: "bg-destructive",
      info: "bg-info",
      success: "bg-success",
      warning: "bg-warning",
      danger: "bg-danger",
      muted: "bg-muted",
      accent: "bg-accent",
      currentColor: "bg-current",
      dimmed: "bg-gray-500"
    },
    textColor: {
      gray: "text-gray-600",
      red: "text-red-600",
      orange: "text-orange-600",
      amber: "text-amber-600",
      yellow: "text-yellow-600",
      lime: "text-lime-600",
      green: "text-green-600",
      emerald: "text-emerald-600",
      teal: "text-teal-600",
      cyan: "text-cyan-600",
      sky: "text-sky-600",
      blue: "text-blue-600",
      indigo: "text-indigo-600",
      violet: "text-violet-600",
      purple: "text-purple-600",
      fuchsia: "text-fuchsia-600",
      pink: "text-pink-600",
      rose: "text-rose-600",
      black: "text-black",
      white: "text-white",
      transparent: "text-transparent",
      background: "text-background",
      foreground: "text-foreground",
      inherit: "text-inherit",
      primary: "text-primary",
      secondary: "text-secondary",
      tertiary: "text-tertiary",
      destructive: "text-destructive",
      info: "text-info",
      success: "text-success",
      warning: "text-warning",
      danger: "text-danger",
      muted: "text-muted",
      accent: "text-accent",
      currentColor: "text-current",
      dimmed: "text-gray-500"
    },
    borderColor: {
      gray: "border-gray-600",
      red: "border-red-600",
      orange: "border-orange-600",
      amber: "border-amber-600",
      yellow: "border-yellow-600",
      lime: "border-lime-600",
      green: "border-green-600",
      emerald: "border-emerald-600",
      teal: "border-teal-600",
      cyan: "border-cyan-600",
      sky: "border-sky-600",
      blue: "border-blue-600",
      indigo: "border-indigo-600",
      violet: "border-violet-600",
      purple: "border-purple-600",
      fuchsia: "border-fuchsia-600",
      pink: "border-pink-600",
      rose: "border-rose-600",
      black: "border-black",
      white: "border-white",
      transparent: "border-transparent",
      background: "border-background",
      foreground: "border-foreground",
      inherit: "border-inherit",
      primary: "border-primary",
      secondary: "border-secondary",
      tertiary: "border-tertiary",
      destructive: "border-destructive",
      info: "border-info",
      success: "border-success",
      warning: "border-warning",
      danger: "border-danger",
      muted: "border-muted",
      accent: "border-accent",
      currentColor: "border-current",
      dimmed: "border-gray-500"
    },
    fontSize: {
      xs: "text-xs",
      "2xs": "text-2xs",
      "3xs": "text-3xs",
      tiny: "text-tiny",
      sm: "text-sm",
      base: "text-base",
      lg: "text-lg",
      xl: "text-xl",
      "2xl": "text-2xl",
      "3xl": "text-3xl",
      "4xl": "text-4xl",
      "5xl": "text-5xl",
      "6xl": "text-6xl",
      "7xl": "text-7xl",
      "8xl": "text-8xl",
      "9xl": "text-9xl"
    }
  },
  defaultVariants: {}
});

// ../shared/src/utils/helper.ts
var isDefinedValue = (value) => value !== void 0 && value !== null;

// ../shared/src/utils/assign-ref/assign-ref.ts
var assignRef = (ref, value) => {
  if (!isDefinedValue(ref)) return;
  if (typeof ref === "function") {
    ref(value);
  } else if (typeof ref === "object" && ref !== null && "current" in ref) {
    try {
      ref.current = value;
    } catch (error) {
      throw new Error(`Cannot assign value '${value}' to ref '${ref}'`);
    }
  }
};

// ../shared/src/utils/create-context.ts
var import_react2 = require("react");

// ../shared/src/utils/create-context-container.tsx
var import_react3 = require("react");
var import_jsx_runtime = require("react/jsx-runtime");

// ../shared/src/utils/forward-ref.ts
var import_react4 = require("react");

// ../shared/src/utils/patch-console-error.ts
var initialError = console.error;
var patchConsoleError = () => {
  console.error = () => {
  };
};
patchConsoleError.release = () => {
  console.error = initialError;
};

// ../shared/src/utils/slot.tsx
var React = __toESM(require("react"), 1);

// ../../node_modules/@base-ui/utils/esm/mergeObjects.js
function mergeObjects(a, b) {
  if (a && !b) {
    return a;
  }
  if (!a && b) {
    return b;
  }
  if (a || b) {
    return {
      ...a,
      ...b
    };
  }
  return void 0;
}

// ../../node_modules/@base-ui/react/esm/merge-props/mergeProps.js
var EMPTY_PROPS = {};
function mergeProps(a, b, c, d, e) {
  if (!c && !d && !e && !a) {
    return createInitialMergedProps(b);
  }
  let merged = createInitialMergedProps(a);
  if (b) {
    merged = mergeInto(merged, b);
  }
  if (c) {
    merged = mergeInto(merged, c);
  }
  if (d) {
    merged = mergeInto(merged, d);
  }
  if (e) {
    merged = mergeInto(merged, e);
  }
  return merged;
}
function createInitialMergedProps(inputProps) {
  if (isPropsGetter(inputProps)) {
    return {
      ...resolvePropsGetter(inputProps, EMPTY_PROPS)
    };
  }
  return copyInitialProps(inputProps);
}
function mergeInto(merged, inputProps) {
  if (isPropsGetter(inputProps)) {
    return resolvePropsGetter(inputProps, merged);
  }
  return mutablyMergeInto(merged, inputProps);
}
function copyInitialProps(inputProps) {
  const copiedProps = {
    ...inputProps
  };
  for (const propName in copiedProps) {
    const propValue = copiedProps[propName];
    if (isEventHandler(propName, propValue)) {
      copiedProps[propName] = wrapEventHandler(propValue);
    }
  }
  return copiedProps;
}
function mutablyMergeInto(mergedProps, externalProps) {
  if (!externalProps) {
    return mergedProps;
  }
  for (const propName in externalProps) {
    const externalPropValue = externalProps[propName];
    switch (propName) {
      case "style": {
        mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
        break;
      }
      case "className": {
        mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
        break;
      }
      default: {
        if (isEventHandler(propName, externalPropValue)) {
          mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
        } else {
          mergedProps[propName] = externalPropValue;
        }
      }
    }
  }
  return mergedProps;
}
function isEventHandler(key, value) {
  const code0 = key.charCodeAt(0);
  const code1 = key.charCodeAt(1);
  const code2 = key.charCodeAt(2);
  return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
}
function isPropsGetter(inputProps) {
  return typeof inputProps === "function";
}
function resolvePropsGetter(inputProps, previousProps) {
  if (isPropsGetter(inputProps)) {
    return inputProps(previousProps);
  }
  return inputProps ?? EMPTY_PROPS;
}
function mergeEventHandlers(ourHandler, theirHandler) {
  if (!theirHandler) {
    return ourHandler;
  }
  if (!ourHandler) {
    return wrapEventHandler(theirHandler);
  }
  return (...args) => {
    const event = args[0];
    if (isSyntheticEvent(event)) {
      const baseUIEvent = event;
      makeEventPreventable(baseUIEvent);
      const result2 = theirHandler(...args);
      if (!baseUIEvent.baseUIHandlerPrevented) {
        ourHandler?.(...args);
      }
      return result2;
    }
    const result = theirHandler(...args);
    ourHandler?.(...args);
    return result;
  };
}
function wrapEventHandler(handler) {
  if (!handler) {
    return handler;
  }
  return (...args) => {
    const event = args[0];
    if (isSyntheticEvent(event)) {
      makeEventPreventable(event);
    }
    return handler(...args);
  };
}
function makeEventPreventable(event) {
  event.preventBaseUIHandler = () => {
    event.baseUIHandlerPrevented = true;
  };
  return event;
}
function mergeClassNames(ourClassName, theirClassName) {
  if (theirClassName) {
    if (ourClassName) {
      return theirClassName + " " + ourClassName;
    }
    return theirClassName;
  }
  return ourClassName;
}
function isSyntheticEvent(event) {
  return event != null && typeof event === "object" && "nativeEvent" in event;
}

// ../shared/src/utils/slot.tsx
var mergeRefs = (...refs) => {
  return (value) => {
    refs.forEach((ref) => {
      if (ref) assignRef(ref, value);
    });
  };
};
var Slot = React.forwardRef(({ children, ...slotProps }, ref) => {
  if (!React.isValidElement(children)) {
    return children ?? null;
  }
  const child = children;
  const childProps = child.props;
  const childPropsWithoutRef = Object.fromEntries(
    Object.entries(childProps).filter(([key]) => key !== "ref")
  );
  const merged = mergeProps(slotProps, childPropsWithoutRef);
  if (ref) {
    const hasEnumerableChildRef = Object.keys(childProps).includes("ref");
    const childRef = hasEnumerableChildRef ? childProps.ref : null;
    merged.ref = childRef ? mergeRefs(ref, childRef) : ref;
  }
  return React.cloneElement(child, merged);
});
Slot.displayName = "Slot";

// src/Portal/Portal.tsx
var import_jsx_runtime2 = require("react/jsx-runtime");
var createPortalNode = (props) => {
  const node = document.createElement("div");
  node.setAttribute("data-portal", "true");
  if (typeof props.className === "string") {
    node.classList.add(...props.className.split(" "));
  }
  if (typeof props.style === "object") {
    Object.assign(node.style, props.style);
  }
  if (typeof props.id === "string") {
    node.setAttribute("id", props.id);
  }
  return node;
};
var Portal = (0, import_react5.forwardRef)((props, ref) => {
  const { children, target, ...others } = props;
  const [mounted, setMounted] = (0, import_react5.useState)(false);
  const nodeRef = (0, import_react5.useRef)(null);
  useIsomorphicEffect(() => {
    setMounted(true);
    nodeRef.current = !target ? createPortalNode(others) : typeof target === "string" ? document.querySelector(target) : target;
    if (!nodeRef.current) return;
    assignRef(ref, nodeRef.current);
    if (!target && nodeRef.current) {
      document.body.appendChild(nodeRef.current);
    }
    return () => {
      if (!target && nodeRef.current) {
        document.body.removeChild(nodeRef.current);
      }
    };
  }, [target]);
  if (!mounted || !nodeRef.current) {
    return null;
  }
  return (0, import_react_dom.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children }), nodeRef.current);
});
Portal.displayName = "Portal";
