'use strict';

var tailwindMerge = require('tailwind-merge');
var lodashEs = require('lodash-es');
var react = require('@tw-classed/react');
var core = require('@tw-classed/core');
var clsx6 = require('clsx');
var createVariatGroupTransfomer = require('tailwind-group-variant');
var ToastPrimitive = require('@radix-ui/react-toast');
var React2 = require('react');
var jsxRuntime = require('react/jsx-runtime');
var solid = require('@heroicons/react/24/solid');
var framerMotion = require('framer-motion');
var valtio = require('valtio');
var reactMergeRefs = require('react-merge-refs');
var useDimensions = require('react-cool-dimensions');
var Tooltip = require('@radix-ui/react-tooltip');
var jsxRuntime$1 = require('valtio-signal/jsx-runtime');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

function _interopNamespace(e) {
  if (e && e.__esModule) return e;
  var n = Object.create(null);
  if (e) {
    Object.keys(e).forEach(function (k) {
      if (k !== 'default') {
        var d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: function () { return e[k]; }
        });
      }
    });
  }
  n.default = e;
  return Object.freeze(n);
}

var clsx6__default = /*#__PURE__*/_interopDefault(clsx6);
var createVariatGroupTransfomer__default = /*#__PURE__*/_interopDefault(createVariatGroupTransfomer);
var ToastPrimitive__namespace = /*#__PURE__*/_interopNamespace(ToastPrimitive);
var React2__default = /*#__PURE__*/_interopDefault(React2);
var useDimensions__default = /*#__PURE__*/_interopDefault(useDimensions);
var Tooltip__namespace = /*#__PURE__*/_interopNamespace(Tooltip);

var __defProp = Object.defineProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};

// src/components/Toast/Toast.tsx
var Toast_exports = {};
__export(Toast_exports, {
  Action: () => Action2,
  Close: () => Close2,
  Container: () => Container,
  Description: () => Description2,
  Title: () => Title2,
  ToastAction: () => ToastAction,
  ToastViewportElement: () => ToastViewportElement,
  Viewport: () => Viewport2
});
var twMerge = tailwindMerge.extendTailwindMerge({
  classGroups: {
    "font-size": [
      {
        // Fixes incorect merging of text size
        text: ["h1", "h2", "h3", "h4", "h5", "h6"]
      }
    ]
  }
});
var { classed } = react.createClassed({ merger: twMerge });
core.createClassed({ merger: twMerge });
var classedVariantMap = (variantMap) => variantMap;
function generateCompoundVariants(compoundVariantPropMap) {
  const { commonVariantProps, compoundVariantMapLists } = lodashEs.transform(
    compoundVariantPropMap,
    (result, value, key) => {
      if (typeof value === "boolean" || typeof value === "string") {
        result.commonVariantProps[key] = value;
        return result;
      }
      const compoundVariantMapList = lodashEs.map(value, (className, variantMapKey) => ({
        [key]: variantMapKey,
        class: className
      }));
      result.compoundVariantMapLists.push(compoundVariantMapList);
      return result;
    },
    {
      commonVariantProps: {},
      compoundVariantMapLists: []
    }
  );
  return compoundVariantMapLists.flat().map(({ class: cls, ...props }) => {
    return {
      ...commonVariantProps,
      class: twMerge(cls, compoundVariantPropMap.className),
      ...props
    };
  });
}

// src/utils/notEmpty.ts
function notEmpty(value) {
  return value !== null && value !== void 0;
}

// src/utils/classed/expandVariant.ts
var expandVariant = createVariatGroupTransfomer__default.default({});
function mergeVariants(variants, overrides) {
  const variantArray = Array.isArray(variants) ? variants : Object.values(variants);
  const mergerFn = (objectValue, sourceValue) => tailwindMerge.twMerge(`${objectValue || ""}`, `${sourceValue}`);
  const mergedVariants = lodashEs.mergeWith({}, ...[...variantArray, overrides], mergerFn);
  return mergedVariants;
}
var sizeVariants = {
  width: {
    xs: clsx6__default.default("w-28"),
    sm: clsx6__default.default("w-34"),
    md: clsx6__default.default("w-40"),
    lg: clsx6__default.default("w-48")
  },
  height: {
    xs: clsx6__default.default("h-28"),
    sm: clsx6__default.default("h-34"),
    md: clsx6__default.default("h-40"),
    lg: clsx6__default.default("h-48")
  },
  inlineWidth: {
    xs: clsx6__default.default("w-16 text-xs"),
    sm: clsx6__default.default("w-20 text-xs"),
    md: clsx6__default.default("w-22 text-xs"),
    lg: clsx6__default.default("w-26 text-xs")
  },
  inlineHeight: {
    xs: clsx6__default.default("h-16 text-xs"),
    sm: clsx6__default.default("h-20 text-xs"),
    md: clsx6__default.default("h-22 text-xs"),
    lg: clsx6__default.default("h-26 text-xs")
  },
  textSize: {
    xs: "text-xs",
    sm: "text-sm",
    md: "text-md",
    lg: "text-lg"
  },
  lineHeight: {
    xs: "leading-xs",
    sm: "leading-sm",
    md: "leading-md",
    lg: "leading-lg"
  },
  paddingY: {
    xs: "py-4",
    sm: "py-6",
    md: "py-8",
    lg: "py-10"
  },
  paddingX: {
    xs: clsx6__default.default("px-4"),
    sm: clsx6__default.default("px-6"),
    md: clsx6__default.default("px-8"),
    lg: clsx6__default.default("px-10")
  },
  extraPaddingX: {
    xs: clsx6__default.default("px-14"),
    sm: clsx6__default.default("px-16"),
    md: clsx6__default.default("px-18"),
    lg: clsx6__default.default("px-20")
  }
};

// src/styles/input-component.variants.ts
var inputComponentVariants = classedVariantMap({
  size: sizeVariants,
  rounded: {
    roundedLeft: "rounded-r-0 rounded-l-md",
    roundedRight: "rounded-l-0 rounded-r-md",
    rounded: "rounded-md"
  }
});
react.classed("div", {
  variants: {
    orientation: {
      horizontal: "inline-flex flex-row items-center ",
      vertical: "flex flex-col justify-center"
    }
  }
});
var inputComponentWidths = {
  xs: clsx6__default.default("w-168"),
  sm: clsx6__default.default("w-184"),
  md: clsx6__default.default("w-216"),
  lg: clsx6__default.default("w-400")
};
var inputComponentMinWidths = {
  none: "",
  xs: clsx6__default.default("min-w-[168px]"),
  sm: clsx6__default.default("min-w-[184px]"),
  md: clsx6__default.default("min-w-[216px]"),
  lg: clsx6__default.default("min-w-[400px]")
};
react.classed("div", {
  variants: {
    size: {
      xs: "",
      sm: "",
      md: "",
      lg: ""
    },
    minWidth: inputComponentMinWidths,
    width: {
      autoWidth: "w-auto",
      fullWidth: "!w-full",
      fixedWidth: ""
    }
  },
  defaultVariants: {
    width: "fixedWidth",
    size: "md"
  },
  compoundVariants: [
    { size: "xs", width: "fixedWidth", class: inputComponentWidths.xs },
    { size: "sm", width: "fixedWidth", class: inputComponentWidths.sm },
    { size: "md", width: "fixedWidth", class: inputComponentWidths.md },
    { size: "lg", width: "fixedWidth", class: inputComponentWidths.lg }
  ]
});
var inputSizeVariants = mergeVariants([
  inputComponentVariants.size.lineHeight,
  inputComponentVariants.size.paddingX,
  inputComponentVariants.size.paddingY,
  inputComponentVariants.size.textSize
]);
react.classed("div", "inline-flex", {
  variants: {
    size: inputSizeVariants
  }
});
var headingTextSize = {
  h1: clsx6__default.default("text-h1"),
  h2: clsx6__default.default("text-h2"),
  h3: clsx6__default.default("text-h3"),
  h4: clsx6__default.default("text-h4"),
  h5: clsx6__default.default("text-h5"),
  h6: clsx6__default.default("text-h6")
};
var textSize = {
  xs: clsx6__default.default("text-xs"),
  sm: clsx6__default.default("text-sm"),
  md: clsx6__default.default("text-md"),
  lg: clsx6__default.default("text-lg")
};
var textVariants = {
  fontWeight: {
    regular: clsx6__default.default("font-regular"),
    medium: clsx6__default.default("font-medium"),
    bold: clsx6__default.default("font-bold")
  },
  size: {
    ...textSize,
    ...headingTextSize
  },
  font: {
    body: "font-body",
    heading: "font-heading",
    mono: "font-mono"
  },
  leading: {
    none: clsx6__default.default("leading-none"),
    xs: clsx6__default.default("leading-xs"),
    sm: clsx6__default.default("leading-sm"),
    md: clsx6__default.default("leading-md"),
    lg: clsx6__default.default("leading-lg"),
    h1: clsx6__default.default("leading-h1"),
    h2: clsx6__default.default("leading-h2"),
    h3: clsx6__default.default("leading-h3"),
    h4: clsx6__default.default("leading-h4"),
    h5: clsx6__default.default("leading-h5"),
    h6: clsx6__default.default("leading-h6")
  },
  spaceY: {
    xs: clsx6__default.default("space-y-4"),
    sm: clsx6__default.default("space-y-6"),
    md: clsx6__default.default("space-y-8"),
    lg: clsx6__default.default("space-y-16")
  },
  spaceX: {
    xs: clsx6__default.default("space-x-4"),
    sm: clsx6__default.default("space-x-6"),
    md: clsx6__default.default("space-x-8"),
    lg: clsx6__default.default("space-x-16")
  },
  color: {
    inherit: clsx6__default.default("text-inherit"),
    current: clsx6__default.default("text-current"),
    tint: clsx6__default.default("text-content-tint"),
    ghost: clsx6__default.default("text-content-ghost"),
    subtle: clsx6__default.default("text-content-subtle"),
    medium: clsx6__default.default("text-content"),
    weak: clsx6__default.default("text-content-weak"),
    moderate: clsx6__default.default("text-content-moderate"),
    high: clsx6__default.default("text-content-high"),
    intense: clsx6__default.default("text-content-intense"),
    strong: clsx6__default.default("text-content-intense"),
    inverse: clsx6__default.default("text-inverse"),
    danger: clsx6__default.default("text-danger")
  },
  align: {
    center: clsx6__default.default("text-center"),
    right: clsx6__default.default("text-right"),
    left: clsx6__default.default("text-left"),
    start: clsx6__default.default("text-left"),
    end: clsx6__default.default("text-end")
  },
  maxLines: {
    1: "line-clamp-1",
    2: "line-clamp-2",
    3: "line-clamp-3",
    4: "line-clamp-4",
    5: "line-clamp-5",
    6: "line-clamp-6"
  }
};

// src/components/Button/Button.styles.tsx
var buttonVariants = {
  variants: {
    loading: {
      true: "cursor-default"
    },
    cursorPointer: {
      false: "cursor-auto"
    },
    size: mergeVariants(
      [inputComponentVariants.size.paddingX, inputComponentVariants.size.paddingY],
      {
        xs: "text-xs px-6",
        sm: "text-sm",
        md: "text-sm",
        lg: "text-sm"
      }
    ),
    fontWeight: textVariants.fontWeight,
    noWrap: {
      true: "whitespace-nowrap"
    },
    inline: {
      true: "inline"
    },
    justify: {
      center: "justify-center",
      start: "justify-start",
      end: "justify-end"
    },
    fullWidth: {
      true: "w-full"
    },
    hoverable: {
      true: ""
    },
    variant: {
      filled: "",
      outlined: "ring-[1.35px] ring-inset",
      glass: "",
      text: "",
      ghost: ""
    },
    rounded: {
      sm: clsx6__default.default("rounded "),
      default: clsx6__default.default("rounded"),
      true: "rounded-full"
    },
    gradient: {
      true: ""
    },
    coloredShadow: {
      true: ""
    },
    extraRoundedPadding: {
      true: ""
    },
    color: {
      primary: "",
      secondary: "",
      surface: "",
      inverse: "",
      info: "",
      success: "",
      danger: "",
      caution: "",
      heart: ""
    },
    hoverBackgroundColor: {
      primary: "",
      secondary: "",
      inverse: "",
      info: "",
      success: "",
      danger: "",
      caution: "",
      heart: ""
    },
    backgroundNoise: {
      true: "noisy-surface-texture"
    },
    gap: {
      true: ""
    }
  },
  compoundVariants: [
    ...generateCompoundVariants({
      gap: true,
      size: {
        xs: clsx6__default.default("gap-4"),
        sm: clsx6__default.default("gap-6"),
        md: clsx6__default.default("gap-6"),
        lg: clsx6__default.default("gap-6")
      }
    }),
    ...generateCompoundVariants({
      variant: "filled",
      color: {
        primary: "filled-accent-primary",
        secondary: "filled-accent-secondary",
        inverse: "filled-accent-inverse",
        heart: "filled-accent-heart",
        info: "filled-accent-info",
        success: "filled-accent-success",
        danger: "filled-accent-danger",
        caution: "filled-accent-caution"
      }
    }),
    ...generateCompoundVariants({
      variant: "filled",
      hoverable: true,
      color: {
        primary: "filled-hover-accent-primary",
        secondary: "filled-hover-accent-secondary",
        inverse: "filled-hover-accent-inverse",
        heart: "filled-hover-accent-heart",
        info: "filled-hover-accent-info",
        success: "filled-hover-accent-success",
        danger: "filled-hover-accent-danger",
        caution: "filled-hover-accent-caution"
      }
    }),
    ...generateCompoundVariants({
      variant: "filled",
      hoverBackgroundColor: {
        primary: "filled-hover-accent-primary",
        secondary: "filled-hover-accent-secondary",
        inverse: "filled-hover-accent-inverse",
        heart: "filled-hover-accent-heart",
        info: "filled-hover-accent-info",
        success: "filled-hover-accent-success",
        danger: "filled-hover-accent-danger",
        caution: "filled-hover-accent-caution"
      }
    }),
    ...generateCompoundVariants({
      variant: "glass",
      hoverBackgroundColor: {
        primary: "hover:glass-accent-primary",
        secondary: "hover:glass-accent-secondary",
        inverse: "hover:glass-accent-inverse",
        heart: "hover:glass-accent-heart",
        info: "hover:glass-accent-info",
        success: "hover:glass-accent-success",
        danger: "hover:glass-accent-danger",
        caution: "hover:glass-accent-caution"
      }
    }),
    ...generateCompoundVariants({
      variant: "glass",
      className: "overflow-hidden",
      color: {
        primary: "glass-accent-primary",
        secondary: "glass-accent-secondary",
        inverse: "glass-accent-inverse",
        heart: "glass-accent-heart",
        info: "glass-accent-info",
        success: "glass-accent-success",
        danger: "glass-accent-danger",
        caution: "glass-accent-caution"
      }
    }),
    ...generateCompoundVariants({
      variant: "ghost",
      className: "overflow-hidden bg-transparent",
      color: {
        primary: "ghost-accent-primary",
        secondary: "ghost-accent-secondary",
        inverse: "ghost-accent-inverse",
        heart: "ghost-accent-heart",
        info: "ghost-accent-info",
        success: "ghost-accent-success",
        danger: "ghost-accent-danger",
        caution: "ghost-accent-caution"
      }
    }),
    ...generateCompoundVariants({
      variant: "outlined",
      className: "overflow-hidden z-0 bg-surface-soft",
      color: {
        primary: "ring-boundary-weak",
        secondary: "ring-boundary-weak",
        inverse: "text-inverse ring-inverse",
        heart: "text-heart ring-heart",
        info: "text-info ring-info",
        success: "text-success ring-success",
        danger: "text-danger ring-danger",
        caution: "text-caution ring-caution"
      }
    }),
    // Colored Shadow
    ...generateCompoundVariants({
      coloredShadow: true,
      className: clsx6__default.default("shadow-lg "),
      color: {
        primary: "shadow-primary/70",
        secondary: "shadow-secondary/70",
        inverse: "shadow-inverse/70",
        heart: "shadow-heart/70",
        info: "shadow-info/70",
        success: "shadow-success/70",
        danger: "shadow-danger/70",
        caution: "shadow-caution/70"
      }
    }),
    // Gradient
    ...generateCompoundVariants({
      gradient: true,
      variant: "filled",
      className: clsx6__default.default("border-none transition-all hover:brightness-[1.05]"),
      color: {
        primary: clsx6__default.default("bg-gradient-primary-dark-to-light-tr"),
        secondary: clsx6__default.default("bg-gradient-secondary-dark-to-light-tr"),
        inverse: clsx6__default.default("bg-gradient-inverse-dark-to-light-tr"),
        heart: clsx6__default.default("bg-gradient-heart-dark-to-light-tr"),
        info: clsx6__default.default("bg-gradient-info-dark-to-light-tr"),
        success: clsx6__default.default("bg-gradient-success-dark-to-light-tr"),
        danger: clsx6__default.default("bg-gradient-danger-dark-to-light-tr"),
        caution: clsx6__default.default("bg-gradient-caution-dark-to-light-tr")
      }
    }),
    // Extra Padding X
    ...generateCompoundVariants({
      rounded: true,
      extraRoundedPadding: true,
      size: sizeVariants.extraPaddingX
    })
  ]
};
var ButtonElement = classed.button(
  "inline-flex font-medium items-center justify-center select-none align-middle",
  "disabled:text-content-tint disabled:cursor-default disabled:pointer-events-none relative",
  "transition-colors duration-100",
  "box-border",
  "shrink-0",
  {
    defaultVariants: {
      size: "md",
      rounded: "default",
      noWrap: true,
      fontWeight: "medium",
      hoverable: true,
      color: "primary",
      justify: "center",
      variant: "filled",
      extraRoundedPadding: true,
      gap: true
    },
    variants: buttonVariants.variants,
    compoundVariants: buttonVariants.compoundVariants
  }
);
var InlineButtonIconElement = classed("span", "flex items-center justify-center", {
  variants: {
    size: {
      xs: "h-12 w-12",
      sm: "h-14 w-14",
      md: "h-16 w-16",
      lg: "h-18 w-18"
    },
    offset: {
      right: "-mr-6",
      left: "-ml-6"
    }
  },
  defaultVariants: { size: "md" }
});
var InlineButtonIcon = ({
  offset,
  position,
  size,
  icon,
  className
}) => {
  return Boolean(className || icon) ? /* @__PURE__ */ jsxRuntime.jsx(
    InlineButtonIconElement,
    {
      size,
      className,
      offset: offset ? position : void 0,
      children: icon
    }
  ) : null;
};
var ButtonComponent = React2.forwardRef(
  ({
    size = "md",
    startIcon,
    endIcon,
    startIconClassName,
    endIconClassName,
    children,
    variant = "filled",
    color = "primary",
    rounded,
    extraRoundedPadding: extraRoundedPaddingProp,
    ...props
  }, ref) => {
    function getExtraRoundedPaddingProp() {
      if (extraRoundedPaddingProp)
        return extraRoundedPaddingProp;
      if (variant === "ghost" || variant === "text")
        return false;
      return true;
    }
    const extraRoundedPadding = getExtraRoundedPaddingProp();
    const inlineButtonIconProps = {
      size,
      offset: Boolean(rounded && extraRoundedPadding)
    };
    return /* @__PURE__ */ jsxRuntime.jsxs(
      ButtonElement,
      {
        variant,
        color,
        extraRoundedPadding,
        rounded,
        size,
        ...props,
        ref,
        children: [
          /* @__PURE__ */ jsxRuntime.jsx(
            InlineButtonIcon,
            {
              position: "left",
              icon: startIcon,
              className: startIconClassName,
              ...inlineButtonIconProps
            }
          ),
          children,
          /* @__PURE__ */ jsxRuntime.jsx(
            InlineButtonIcon,
            {
              position: "right",
              icon: endIcon,
              className: endIconClassName,
              ...inlineButtonIconProps
            }
          )
        ]
      }
    );
  }
);
var Button = react.deriveClassed((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(ButtonComponent, { ...props, ref }));
var IconButtonElement = classed("button", ButtonElement, "p-8 shrink-0", {
  variants: {
    size: mergeVariants([sizeVariants.width, sizeVariants.height])
  }
});
var IconButton = React2.forwardRef(
  ({ className, children, ...props }, ref) => {
    return /* @__PURE__ */ jsxRuntime.jsx(IconButtonElement, { ...props, className, ref, extraRoundedPadding: false, children });
  }
);
var CloseButton = React2.forwardRef(
  ({ className, animated, color = "secondary", ...props }, ref) => {
    return /* @__PURE__ */ jsxRuntime.jsx(
      IconButton,
      {
        ref,
        size: "sm",
        variant: "ghost",
        color,
        rounded: true,
        ...props,
        className: tailwindMerge.twMerge(
          clsx6__default.default("text-content-subtle hover:text-content-weak", {
            "opacity-50 transition-opacity duration-300 ease-in-out group-hover:opacity-100": animated
          }),
          className
        ),
        children: /* @__PURE__ */ jsxRuntime.jsx(solid.XMarkIcon, { className: clsx6__default.default("fill-current") })
      }
    );
  }
);
var toastState = valtio.proxy({
  toasts: [],
  toastTimeOuts: /* @__PURE__ */ new Map(),
  newToastStackCount: 1,
  maxToasts: 5,
  isStacked: false,
  showAllToasts: false
});
function dismissToast(toastId) {
  if (!toastState.toastTimeOuts.has(toastId)) {
    const toast2 = toastState.toasts.find(({ id }) => id === toastId);
    const timeout = setTimeout(() => {
      toastState.toastTimeOuts.delete(toastId);
      toastState.toasts = toastState.toasts.filter((toast3) => {
        return toast3.id !== toastId;
      });
    }, toast2.duration ?? 0);
    updateToast({ id: toastId, closing: true });
    toastState.toastTimeOuts.set(toastId, timeout);
  }
}
function updateToast(toastData) {
  toastState.toasts = toastState.toasts.map((toast2) => {
    if (toast2.id === toastData.id) {
      return { ...toast2, ...toastData };
    }
    return toast2;
  });
}
var toastActions = {
  addToast: (payload) => {
    toastState.toasts.push(payload);
    const { toasts, maxToasts, showAllToasts } = toastState;
    if (toasts.length > maxToasts && !showAllToasts) {
      toastState.isStacked = true;
    }
  },
  removeToast: (toastId) => {
    toastState.toasts = toastState.toasts.filter(({ id }) => id !== toastId);
    toastState.toastTimeOuts.delete(toastId);
    const { toasts, maxToasts } = toastState;
    if (toasts.length <= maxToasts) {
      toastState.isStacked = false;
    }
  },
  updateToast,
  dismissToast,
  dismissToasts: () => {
    toastState.toasts.forEach((toast2) => {
      dismissToast(toast2.id);
    });
    toastState.isStacked = false;
    toastState.showAllToasts = false;
  },
  toggleStacked: (payload) => {
    toastState.isStacked = payload === void 0 ? toastState.isStacked : payload;
  },
  toggleMaxStacked: () => {
    const { toasts, maxToasts } = toastState;
    toastState.isStacked = toasts.length > maxToasts;
  },
  toggleShowAllToasts: (payload) => {
    if (payload) {
      toastState.showAllToasts = true;
      toastState.isStacked = false;
    } else {
      const { toasts, maxToasts } = toastState;
      toastState.showAllToasts = false;
      toastState.isStacked = toasts.length > maxToasts;
    }
  }
};
function toast({ autoDismiss = true, ...props }) {
  const id = lodashEs.uniqueId("toast");
  function update(props2) {
    toastActions.updateToast({ ...props2, id });
  }
  function dismiss() {
    toastActions.dismissToast(id);
  }
  toastActions.addToast({
    ...props,
    open: true,
    id,
    onOpenChange: (open) => {
      if (!open && autoDismiss) {
        dismiss();
      }
    }
  });
  return {
    id,
    dismiss,
    update
  };
}

// src/constants/theme.ts
var LIGHT_MODE = "light";
var DARK_MODE = "dark";
var DEFAULT_THEME = DARK_MODE;

// src/utils/environment-utils.ts
function isClientSide() {
  return typeof window !== "undefined";
}

// src/hooks/useDarkMode.tsx
var getInitialIsDarkMode = (fallback) => {
  if (!isClientSide())
    return DEFAULT_THEME === DARK_MODE;
  const savedTheme = localStorage.getItem("color-theme");
  if (!savedTheme) {
    return Boolean(fallback);
  }
  return savedTheme === DARK_MODE;
};
var useDarkMode = () => {
  const initialIsDarkMode = getInitialIsDarkMode();
  const [isDarkMode, setIsDarkMode] = React2.useState(initialIsDarkMode);
  function setDarkMode(enabled) {
    if (!isClientSide()) {
      return;
    }
    const htmlTag = document.documentElement;
    if (enabled) {
      htmlTag.classList.add(DARK_MODE);
      htmlTag.setAttribute("data-mode", DARK_MODE);
      localStorage.setItem("color-theme", DARK_MODE);
    } else {
      htmlTag.classList.remove(DARK_MODE);
      htmlTag.removeAttribute("data-mode");
      localStorage.setItem("color-theme", LIGHT_MODE);
    }
    setIsDarkMode(enabled);
  }
  const toggleDarkMode = () => {
    setDarkMode(!isDarkMode);
  };
  React2.useLayoutEffect(() => {
    if (initialIsDarkMode !== isDarkMode) {
      setDarkMode(initialIsDarkMode);
    }
  }, [initialIsDarkMode, isDarkMode]);
  return { isDarkMode, setDarkMode, toggleDarkMode };
};
function useIsDarkMode() {
  const { isDarkMode } = useDarkMode();
  return isDarkMode;
}
function Wrap({
  children,
  if: conditionProp,
  wrap: wrapper,
  fallback
}) {
  const fallbackWrapperFn = fallback ?? ((c) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: c }));
  if (!Boolean(conditionProp))
    return fallbackWrapperFn(children);
  const getCondition = () => {
    if (typeof conditionProp === "object") {
      return lodashEs.findKey(conditionProp, (e) => Boolean(e));
    }
    return conditionProp;
  };
  const condition = getCondition();
  const getWrapperFn = () => {
    if (typeof wrapper === "function")
      return wrapper;
    if (typeof wrapper === "object" && typeof condition === "string" && condition in wrapper) {
      return wrapper[condition];
    }
    return fallbackWrapperFn;
  };
  const wrapperFn = getWrapperFn();
  if (typeof condition === "boolean") {
    return Boolean(condition) ? wrapperFn(children) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
  }
  return wrapperFn(children);
}
var ToastContainerElement = framerMotion.motion(
  classed(
    "div",
    "bg-surface",
    "border border-highlight-moderate",
    "relative",
    "p-10 rounded",
    // 'mb-4 md:mb-8 first:mb-0',
    "mb-4 md:mb-8",
    "active:cursor-grabbing",
    "shadow-lg",
    "w-full max-w-[400px]",
    {
      variants: {
        stacked: {
          true: "absolute bottom-0"
        },
        firstStackItem: {
          true: "mb-0"
        }
      }
    }
  )
);
var ToastViewportElement = framerMotion.motion(
  classed(
    ToastPrimitive__namespace.Viewport,
    "fixed bottom-0 z-[100]",
    "list-none",
    "max-h-screen",
    "flex flex-col-reverse",
    "right-0 w-full",
    expandVariant(`
      md:(max-w-[400px])
      sm:(top-auto,bottom-0,right-0)`)
  )
);
var ToastViewport = React2.forwardRef((props, ref) => {
  return /* @__PURE__ */ jsxRuntime.jsx(ToastViewportElement, { ...props, ref });
});
var ToastContainer = React2__default.default.forwardRef(
  ({ children, id, index = 0, ...props }, forwardRef5) => {
    const { toasts, isStacked } = valtio.useSnapshot(toastState);
    const [swipeComplete, setSwipeComplete] = React2.useState(false);
    const { observe } = useDimensions__default.default();
    const ref = reactMergeRefs.mergeRefs([forwardRef5, observe]);
    const custom = { index, count: toasts.length };
    const animate = {
      opacity: [0, 0.9, 1],
      y: 0
    };
    const initial = {
      // opacity: isStacked ? (index === 0 ? 1 : [0, 0.9, 1]) : 0,
      opacity: 0,
      y: isStacked ? 0 : 40,
      position: "relative"
    };
    const isDarkMode = useIsDarkMode();
    const toastMotionVariants = {
      initial,
      animate,
      exit: { opacity: 0 },
      exitStacked: { opacity: 0, y: 0 },
      initialStacked: { y: 0, opacity: index === 0 ? 1 : 0 },
      animateStacked: ({ index: index2, count }) => {
        const input = [0, count - 1];
        const lightModeBrightness = framerMotion.interpolate([0, count], [1, 1.5])(index2);
        const darkModeBrightness = framerMotion.interpolate(input, [1, 0.3])(index2);
        const brightness = isDarkMode ? darkModeBrightness : lightModeBrightness;
        const zIndex = framerMotion.interpolate(input, [100, 50])(index2);
        const opacity = framerMotion.interpolate(input, [1, 0], { ease: framerMotion.easeIn })(index2);
        const blur = framerMotion.interpolate(input, [0, 1.2])(index2);
        const scaleX = framerMotion.interpolate(input, [1, 0.7])(index2);
        const y = framerMotion.interpolate(input, [0, -30])(index2);
        return {
          opacity,
          scaleX,
          transition: { bounce: 0, duration: 2, restSpeed: 0.5 },
          x: 0,
          y: index2 === 0 ? 0 : y,
          zIndex,
          position: "absolute",
          filter: `brightness(${brightness}) blur(${blur}px)`
          // backdropFilter: ``,
          // right: 8,
        };
      }
    };
    return /* @__PURE__ */ jsxRuntime.jsx(
      ToastPrimitive__namespace.Root,
      {
        onSwipeEnd: () => {
          setSwipeComplete(true);
        },
        onSwipeStart: () => {
          setSwipeComplete(false);
        },
        ...props,
        forceMount: true,
        id,
        asChild: true,
        ref,
        children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.motion.li, { layout: true, className: "group relative w-full max-w-[400px] px-8", children: /* @__PURE__ */ jsxRuntime.jsx(
          Wrap,
          {
            if: isStacked,
            wrap: (c) => /* @__PURE__ */ jsxRuntime.jsx(framerMotion.motion.div, { layout: true, className: "relative", children: c }),
            children: /* @__PURE__ */ jsxRuntime.jsx(ToastViewportActions, { index, children: /* @__PURE__ */ jsxRuntime.jsx(
              ToastContainerElement,
              {
                variants: toastMotionVariants,
                custom,
                exit: "exit",
                initial: "initial",
                animate: isStacked ? "animateStacked" : "animate",
                drag: "x",
                dragDirectionLock: true,
                dragConstraints: { left: 0, right: 600 },
                dragElastic: 0.05,
                layoutId: id,
                layout: "position",
                className: "right-0",
                dragSnapToOrigin: !swipeComplete,
                firstStackItem: isStacked && index === 0,
                stacked: isStacked,
                children
              }
            ) })
          }
        ) })
      }
    );
  }
);
var ToastViewportActionButton = ({
  children,
  onClick,
  ...props
}) => {
  const isDarkMode = useIsDarkMode();
  return /* @__PURE__ */ jsxRuntime.jsx(
    Button,
    {
      "data-color-scheme": isDarkMode ? void 0 : "default",
      size: "xs",
      rounded: true,
      color: "inverse",
      variant: "glass",
      ...props,
      onClick: (e) => {
        e.stopPropagation();
        onClick?.(e);
      },
      children
    }
  );
};
var ToastViewportActions = ({
  children,
  index
}) => {
  const { toasts, showAllToasts, isStacked } = valtio.useSnapshot(toastState);
  const isFirstStackItem = isStacked && index === 0;
  const isFirstListItem = !isStacked && index === toasts.length - 1;
  const [open, setOpen] = React2.useState(false);
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(
    Tooltip__namespace.Root,
    {
      delayDuration: 0,
      open,
      onOpenChange: (open2) => {
        setOpen(open2);
      },
      children: [
        /* @__PURE__ */ jsxRuntime.jsx(Tooltip__namespace.Trigger, { asChild: true, children }),
        /* @__PURE__ */ jsxRuntime.jsx(Tooltip__namespace.Portal, { forceMount: true, children: /* @__PURE__ */ jsxRuntime.jsx(
          Tooltip__namespace.Content,
          {
            align: "end",
            sideOffset: -2,
            className: clsx6__default.default("pb-8", {
              "gradient-mask-t-90 z-[101]  p-16 pb-8": isStacked
            }),
            children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: open && /* @__PURE__ */ jsxRuntime.jsxs(
              framerMotion.motion.div,
              {
                className: clsx6__default.default("relative flex w-full min-w-[200px] justify-end gap-6"),
                initial: { y: "150%", zIndex: 0, opacity: 0 },
                animate: { y: 0, opacity: 1, zIndex: 200 },
                exit: {
                  y: "150%",
                  opacity: [0.5, 0.4, 0],
                  zIndex: 0,
                  transition: { opacity: { duration: 0.2 } }
                },
                style: { position: "relative" },
                transition: { y: { damping: 300, duration: 0.3 } },
                children: [
                  isFirstStackItem && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(
                    ToastViewportActionButton,
                    {
                      color: "inverse",
                      onClick: () => {
                        toastActions.toggleShowAllToasts(true);
                      },
                      children: [
                        toasts.length,
                        " Notifications"
                      ]
                    }
                  ) }),
                  isFirstListItem && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: showAllToasts && /* @__PURE__ */ jsxRuntime.jsx(
                    ToastViewportActionButton,
                    {
                      onClick: () => {
                        toastActions.toggleShowAllToasts(false);
                      },
                      children: "Collapse"
                    }
                  ) }),
                  (isFirstListItem || isFirstStackItem) && /* @__PURE__ */ jsxRuntime.jsx(
                    ToastViewportActionButton,
                    {
                      hoverBackgroundColor: "danger",
                      onClick: () => {
                        toastActions.dismissToasts();
                      },
                      children: "Clear All"
                    }
                  )
                ]
              }
            ) })
          }
        ) })
      ]
    }
  ) });
};
var ToastAction = ({ altText, ...props }) => {
  return /* @__PURE__ */ jsxRuntime.jsx(ToastPrimitive__namespace.Action, { altText, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(Button, { size: "sm", variant: "glass", color: "primary", ...props }) });
};
var ToastClose = ({ className, ...props }) => {
  return /* @__PURE__ */ jsxRuntime.jsx(ToastPrimitive__namespace.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(CloseButton, { ...props }) });
};
var ToastTitle = classed(ToastPrimitive__namespace.Title, "font-medium text-content-intense text-sm");
var ToastDescriptionElement = classed(
  ToastPrimitive__namespace.Description,
  "font-body text-content-high mt-1 text-sm"
);
var ToastDescription = ({
  children,
  ...props
}) => {
  return children ? /* @__PURE__ */ jsxRuntime.jsxs(ToastDescriptionElement, { ...props, children: [
    " ",
    children
  ] }) : null;
};
var Container = ToastContainer;
var Viewport2 = ToastViewport;
var Title2 = ToastTitle;
var Description2 = ToastDescription;
var Close2 = ToastClose;
var Action2 = ToastAction;

// src/components/Flex/Flex.tsx
var flexGapVariants = {
  false: "gap-0",
  true: "gap-8",
  xs: "gap-2",
  sm: "gap-4",
  md: "gap-8",
  lg: "gap-16",
  xl: "gap-24"
};
var Flex = classed("div", "flex", {
  defaultVariants: {},
  variants: {
    row: {
      true: "flex-row",
      reverse: "flex-row-reverse"
    },
    column: {
      true: "flex-col",
      reverse: "flex-col-reverse"
    },
    dir: {
      row: "flex-row",
      column: "flex-col"
    },
    inlineFlex: {
      true: "inline-flex"
    },
    noFlex: {
      true: ""
    },
    flexNone: {
      true: "flex-none"
    },
    wrap: {
      true: "flex-wrap",
      reverse: "flex-wrap-reverse wrap"
    },
    grow: {
      true: "flex-grow"
    },
    shrink: {
      true: "flex-shrink"
    },
    auto: {
      true: "flex-auto"
    },
    basisAuto: {
      true: "basis-auto"
    },
    centerAlign: {
      true: "justify-center items-center"
    },
    gap: flexGapVariants,
    textAlign: {
      left: "text-left",
      center: "text-center",
      right: "text-right",
      end: "text-end",
      start: "text-start",
      justify: "text-justify"
    },
    justify: {
      start: "justify-start",
      end: "justify-end",
      center: "justify-center",
      between: "justify-between",
      around: "justify-around",
      evenly: "justify-evenly"
    },
    align: {
      start: "items-start",
      end: "items-end",
      center: "items-center",
      baseline: "items-baseline",
      stretch: "items-stretch"
    },
    alignSelf: {
      start: "self-start",
      center: "self-center",
      end: "self-end",
      stretch: "self-stretch",
      baseline: "self-baseline",
      auto: "self-auto"
    },
    justifySelf: {
      auto: "justify-self-auto",
      start: "justify-self-start",
      end: "justify-self-end",
      center: "justify-self-center",
      stretch: "justify-self-stretch"
    },
    fullWidth: {
      true: "w-full"
    }
  }
});

// src/utils/toArray.ts
function toArray(v, options) {
  const val = Array.isArray(v) ? v : [v];
  if (options?.notEmpty)
    return val.filter(notEmpty);
  return val;
}
var ToastIconElement = classed("span", "h-24 w-24 text-content-intense", {
  variants: {
    variant: {
      danger: "i-heroicons-x-circle",
      info: "i-heroicons-information-circle-solid",
      success: "i-heroicons-check-circle-solid",
      warning: "i-heroicons-exclaimation-triangle-solid"
    }
  }
});
var ToastIcon = ({ variant, className }) => {
  if (variant === "neutral" || !variant) {
    return null;
  }
  return /* @__PURE__ */ jsxRuntime$1.jsx(ToastIconElement, { variant, className });
};
var ToastActionButtons = ({
  action,
  className,
  justify
}) => {
  const actions = toArray(action, { notEmpty: true });
  return /* @__PURE__ */ jsxRuntime$1.jsx(Flex, { justify, className: "", grow: true, gap: "md", children: actions.length > 0 && actions.map((action2, i) => {
    function defaultProps() {
      const indexProps = {
        0: { variant: "glass" },
        1: { variant: "outlined" }
      };
      return indexProps[i];
    }
    return /* @__PURE__ */ jsxRuntime$1.jsx(
      Toast_exports.Action,
      {
        className: tailwindMerge.twMerge("grow shrink max-w-[115px]", className),
        size: "xs",
        ...defaultProps(),
        ...action2,
        color: "inverse"
      },
      i
    );
  }) });
};
var ToasterToast = framerMotion.motion((props) => {
  const {
    action,
    id,
    open: openProp,
    defaultOpen,
    title,
    description,
    closing,
    duration,
    onOpenChange,
    variant = "neutral",
    ...rest
  } = props;
  const isDarkMode = useIsDarkMode();
  function getColorScheme() {
    if (!isDarkMode && variant === "neutral")
      return "surface";
    if (variant === "neutral")
      return "neutral-dark";
    return variant;
  }
  return /* @__PURE__ */ jsxRuntime$1.jsxs(
    Toast_exports.Container,
    {
      open: true,
      defaultOpen,
      onOpenChange,
      "data-color-scheme": getColorScheme(),
      id,
      layout: true,
      ...rest,
      children: [
        closing && /* @__PURE__ */ jsxRuntime$1.jsx(
          framerMotion.motion.div,
          {
            className: "bg-content-ghost absolute left-0 top-0 h-6 w-full origin-right ",
            initial: { opacity: 0 },
            animate: { scaleX: 0, opacity: 100 },
            transition: { duration: (duration ?? NaN) / 1e3 }
          }
        ),
        /* @__PURE__ */ jsxRuntime$1.jsx(ToasterContent, { ...props })
      ]
    }
  );
});
var ToastContainer2 = ({
  variant,
  children,
  id,
  align,
  justify
}) => {
  return /* @__PURE__ */ jsxRuntime$1.jsxs(Flex, { gap: true, justify: "between", children: [
    /* @__PURE__ */ jsxRuntime$1.jsxs(Flex, { gap: true, align, justify, className: "w-full", children: [
      /* @__PURE__ */ jsxRuntime$1.jsx(ToastIcon, { variant }),
      children
    ] }),
    /* @__PURE__ */ jsxRuntime$1.jsx("div", { className: "-mr-4", children: /* @__PURE__ */ jsxRuntime$1.jsx(
      CloseButton,
      {
        animated: true,
        onClick: () => {
          toastActions.removeToast(id);
        }
      }
    ) })
  ] });
};
var ToasterContent = (props) => {
  const { title, description, action, variant, id } = props;
  const actions = toArray(action, { notEmpty: true });
  const containerProps = {
    variant,
    id
  };
  if (description && actions.length > 0) {
    return /* @__PURE__ */ jsxRuntime$1.jsx(ToastContainer2, { ...containerProps, children: /* @__PURE__ */ jsxRuntime$1.jsxs("div", { className: "flex w-full flex-col gap-8", children: [
      /* @__PURE__ */ jsxRuntime$1.jsxs("div", { children: [
        /* @__PURE__ */ jsxRuntime$1.jsx(Toast_exports.Title, { children: title }),
        /* @__PURE__ */ jsxRuntime$1.jsx(Toast_exports.Description, { children: description })
      ] }),
      /* @__PURE__ */ jsxRuntime$1.jsx(ToastActionButtons, { action })
    ] }) });
  }
  return /* @__PURE__ */ jsxRuntime$1.jsxs(ToastContainer2, { ...containerProps, align: "center", justify: "between", children: [
    /* @__PURE__ */ jsxRuntime$1.jsx(Toast_exports.Title, { className: "mr-8 shrink-0 ", children: title }),
    /* @__PURE__ */ jsxRuntime$1.jsx(ToastActionButtons, { justify: "end", action })
  ] });
};
var Toaster = () => {
  const { toasts, maxToasts, showAllToasts, isStacked } = valtio.useSnapshot(
    toastState
  );
  const toastsArr = React2.useMemo(() => {
    const arr = isStacked ? [...toasts].reverse() : toasts;
    return showAllToasts ? arr : lodashEs.slice(arr, 0, maxToasts);
  }, [isStacked, maxToasts, showAllToasts, toasts]);
  return /* @__PURE__ */ jsxRuntime$1.jsxs(jsxRuntime$1.Fragment, { children: [
    /* @__PURE__ */ jsxRuntime$1.jsx(framerMotion.AnimatePresence, { mode: "popLayout", children: toastsArr.map(({ id, open, ...props }, index) => {
      return /* @__PURE__ */ jsxRuntime$1.jsx(ToasterToast, { forceMount: true, open, id, ...props, index }, id);
    }) }),
    /* @__PURE__ */ jsxRuntime$1.jsx(Toast_exports.Viewport, { layoutRoot: true })
  ] });
};

exports.Toast = Toast_exports;
exports.ToastAction = ToastAction;
exports.Toaster = Toaster;
exports.toast = toast;
exports.toastActions = toastActions;
exports.toastState = toastState;
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.cjs.map