'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/components/Select/index.ts
var Select_exports = {};
__export(Select_exports, {
  Select: () => Select,
  SelectContent: () => SelectContent,
  SelectGroup: () => SelectGroup,
  SelectIcon: () => SelectIcon,
  SelectItem: () => SelectItem,
  SelectLabel: () => SelectLabel,
  SelectPortal: () => SelectPortal,
  SelectRoot: () => SelectRoot,
  SelectSeparator: () => SelectSeparator,
  SelectTrigger: () => SelectTrigger,
  SelectValue: () => SelectValue
});
module.exports = __toCommonJS(Select_exports);

// src/components/Select/Select.tsx
var React3 = __toESM(require("react"), 1);
var import_react_hooks3 = require("@paalan/react-hooks");
var import_react_icons2 = require("@paalan/react-icons");
var import_lib16 = require("@paalan/react-shared/lib");
var SelectPrimitive = __toESM(require("@radix-ui/react-select"), 1);

// src/base/Box/Box.tsx
var import_system = require("@paalan/react-shared/system");
var import_utils = require("@paalan/react-shared/utils");
var import_jsx_runtime = require("react/jsx-runtime");
var Box = (0, import_utils.forwardRef)((props, ref) => {
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_system.StyledComponent, { ...props, ref });
});
Box.withComponent = import_system.WithStyledComponent;

// src/base/Center/Center.tsx
var import_lib = require("@paalan/react-shared/lib");
var import_utils2 = require("@paalan/react-shared/utils");
var import_jsx_runtime2 = require("react/jsx-runtime");
var Center = (0, import_utils2.forwardRef)((props, ref) => {
  const { children, className, ...restProps } = props;
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Box, { className: (0, import_lib.cn)("flex items-center justify-center", className), ...restProps, ref, children });
});

// src/base/Container/Container.tsx
var import_lib2 = require("@paalan/react-shared/lib");
var import_utils3 = require("@paalan/react-shared/utils");
var import_jsx_runtime3 = require("react/jsx-runtime");
var Container = (0, import_utils3.forwardRef)((props, ref) => {
  const { children, className, ...restProps } = props;
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Box, { className: (0, import_lib2.cn)("container", className), ...restProps, ref, children });
});

// src/base/Flex/Flex.tsx
var import_lib3 = require("@paalan/react-shared/lib");
var import_utils4 = require("@paalan/react-shared/utils");
var import_jsx_runtime4 = require("react/jsx-runtime");
var Flex = (0, import_utils4.forwardRef)((props, ref) => {
  const { children, className, ...restProps } = props;
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box, { className: (0, import_lib3.cn)("flex", className), ...restProps, ref, children });
});

// src/base/Grid/Grid.tsx
var import_lib4 = require("@paalan/react-shared/lib");
var import_utils5 = require("@paalan/react-shared/utils");
var import_jsx_runtime5 = require("react/jsx-runtime");
var Grid = (0, import_utils5.forwardRef)((props, ref) => {
  const { children, className, ...restProps } = props;
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box, { className: (0, import_lib4.cn)("grid", className), ...restProps, ref, children });
});
var GridItem = (0, import_utils5.forwardRef)((props, ref) => {
  const { children, ...restProps } = props;
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Box, { ...restProps, ref, children });
});

// src/base/HStack/HStack.tsx
var import_lib5 = require("@paalan/react-shared/lib");
var import_utils6 = require("@paalan/react-shared/utils");
var import_jsx_runtime6 = require("react/jsx-runtime");
var HStack = (0, import_utils6.forwardRef)((props, ref) => {
  const { children, className, ...restProps } = props;
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Box, { className: (0, import_lib5.cn)("flex flex-row items-center gap-2", className), ...restProps, ref, children });
});

// src/base/Heading/Heading.tsx
var import_lib6 = require("@paalan/react-shared/lib");
var import_utils7 = require("@paalan/react-shared/utils");
var import_jsx_runtime7 = require("react/jsx-runtime");
var headingSizes = {
  h1: "text-3xl font-bold",
  h2: "text-2xl font-bold",
  h3: "text-xl font-semibold",
  h4: "text-lg font-semibold",
  h5: "text-base font-semibold",
  h6: "text-sm font-semibold"
};
var Heading = (0, import_utils7.forwardRef)((props, ref) => {
  const { children, as: headTag = "h1", className, ...restProps } = props;
  const size = headingSizes[headTag];
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Box, { as: headTag, ...restProps, ref, className: (0, import_lib6.cn)(size, className), children });
});

// src/base/Paper/Paper.tsx
var import_lib7 = require("@paalan/react-shared/lib");
var import_utils8 = require("@paalan/react-shared/utils");
var import_class_variance_authority = require("class-variance-authority");
var import_jsx_runtime8 = require("react/jsx-runtime");
var paperVariants = (0, import_class_variance_authority.cva)("bg-background text-foreground", {
  variants: {
    shadow: {
      default: "shadow",
      sm: "shadow-sm",
      md: "shadow-md",
      lg: "shadow-lg",
      xl: "shadow-xl",
      "2xl": "shadow-2xl",
      inner: "shadow-inner",
      none: "shadow-none"
    }
  },
  defaultVariants: {
    shadow: "default"
  }
});
var Paper = (0, import_utils8.forwardRef)(
  ({ withBorder, shadow, className, ...props }, ref) => {
    return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
      Box,
      {
        ref,
        className: (0, import_lib7.cn)(paperVariants({ shadow }), withBorder ? "border border-border" : "", className),
        ...props
      }
    );
  }
);

// src/base/Portal/Portal.tsx
var import_react = require("react");
var import_react_hooks = require("@paalan/react-hooks");
var import_utils9 = require("@paalan/react-shared/utils");
var import_react_dom = require("react-dom");
var import_jsx_runtime9 = 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 defaultProps = {};
var Portal = (0, import_react.forwardRef)((props, ref) => {
  const { children, target, ...others } = { ...defaultProps, ...props };
  const [mounted, setMounted] = (0, import_react.useState)(false);
  const nodeRef = (0, import_react.useRef)(null);
  (0, import_react_hooks.useIsomorphicEffect)(() => {
    setMounted(true);
    nodeRef.current = !target ? createPortalNode(others) : typeof target === "string" ? document.querySelector(target) : target;
    if (!nodeRef.current) return;
    (0, import_utils9.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_runtime9.jsx)(import_jsx_runtime9.Fragment, { children }), nodeRef.current);
});
Portal.displayName = "Portal";

// src/base/Stack/Stack.tsx
var import_lib8 = require("@paalan/react-shared/lib");
var import_utils10 = require("@paalan/react-shared/utils");
var import_jsx_runtime10 = require("react/jsx-runtime");
var Stack = (0, import_utils10.forwardRef)((props, ref) => {
  const { children, className, direction, ...restProps } = props;
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Box, { className: (0, import_lib8.cn)("flex flex-col gap-2", className), flexDirection: direction, ...restProps, ref, children });
});

// src/base/Text/Text.tsx
var import_lib9 = require("@paalan/react-shared/lib");
var import_utils11 = require("@paalan/react-shared/utils");
var import_jsx_runtime11 = require("react/jsx-runtime");
var Text = (0, import_utils11.forwardRef)((props, ref) => {
  const { children, className, as = "p", ...restProps } = props;
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Box, { as, ref, className: (0, import_lib9.cn)("", className), ...restProps, children });
});

// src/base/Typography/Typography.tsx
var import_lib10 = require("@paalan/react-shared/lib");
var import_utils12 = require("@paalan/react-shared/utils");
var import_jsx_runtime12 = require("react/jsx-runtime");
var H1 = (0, import_utils12.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
  Box,
  {
    as: "h1",
    ref,
    className: (0, import_lib10.cn)("scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl", className),
    ...props
  }
));
H1.displayName = "H1";
var H2 = (0, import_utils12.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
  Box,
  {
    as: "h2",
    ref,
    className: (0, import_lib10.cn)(
      "mt-10 scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight transition-colors first:mt-0",
      className
    ),
    ...props
  }
));
H2.displayName = "H2";
var H3 = (0, import_utils12.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
  Box,
  {
    as: "h3",
    ref,
    className: (0, import_lib10.cn)("mt-8 scroll-m-20 text-2xl font-semibold tracking-tight", className),
    ...props
  }
));
H3.displayName = "H3";
var H4 = (0, import_utils12.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { as: "h4", ref, className: (0, import_lib10.cn)("scroll-m-20 text-xl font-semibold tracking-tight", className), ...props }));
H4.displayName = "H4";
var H5 = (0, import_utils12.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { as: "h5", ref, className: (0, import_lib10.cn)("scroll-m-20 text-lg font-semibold tracking-tight", className), ...props }));
H5.displayName = "H5";
var H6 = (0, import_utils12.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { as: "h6", ref, className: (0, import_lib10.cn)("scroll-m-20 text-base font-semibold tracking-tight", className), ...props }));
H6.displayName = "H6";
var P = (0, import_utils12.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { as: "p", ref, className: (0, import_lib10.cn)("leading-7 [&:not(:first-child)]:mt-4", className), ...props }));
P.displayName = "P";
var BlockQuote = (0, import_utils12.forwardRef)(
  ({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
    Box,
    {
      as: "blockquote",
      ref,
      className: (0, import_lib10.cn)(
        "mt-6 border-l-2 border-slate-300 pl-6 italic text-slate-800 dark:border-slate-600 dark:text-slate-200",
        className
      ),
      ...props
    }
  )
);
BlockQuote.displayName = "BlockQuote";
var TableLayout = (0, import_utils12.forwardRef)(
  ({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { as: "table", ref, className: (0, import_lib10.cn)("w-full", className), ...props })
);
TableLayout.displayName = "Table";
var THead = (0, import_utils12.forwardRef)(
  ({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { as: "thead", ref, className: (0, import_lib10.cn)("", className), ...props })
);
THead.displayName = "THead";
var TBody = (0, import_utils12.forwardRef)(
  ({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { as: "tbody", ref, className: (0, import_lib10.cn)("", className), ...props })
);
TBody.displayName = "TBody";
var TR = (0, import_utils12.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
  Box,
  {
    as: "tr",
    ref,
    className: (0, import_lib10.cn)(
      "m-0 border-t border-slate-300 p-0 even:bg-slate-100 dark:border-slate-700 dark:even:bg-slate-800",
      className
    ),
    ...props
  }
));
TR.displayName = "TR";
var TD = (0, import_utils12.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
  Box,
  {
    as: "td",
    ref,
    className: (0, import_lib10.cn)(
      "border border-slate-200 px-4 py-2 text-left dark:border-slate-700 [&[align=center]]:text-center [&[align=right]]:text-right",
      className
    ),
    ...props
  }
));
TD.displayName = "TD";
var TH = (0, import_utils12.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
  Box,
  {
    as: "th",
    ref,
    className: (0, import_lib10.cn)(
      "border border-slate-200 px-4 py-2 text-left font-bold dark:border-slate-700 [&[align=center]]:text-center [&[align=right]]:text-right",
      className
    ),
    ...props
  }
));
TH.displayName = "TH";
var UL = (0, import_utils12.forwardRef)(({ className, unstyled = false, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
  Box,
  {
    as: "ul",
    ref,
    className: (0, import_lib10.cn)(
      {
        "m-4 list-disc [&>li]:mt-2": !unstyled
      },
      className
    ),
    ...props
  }
));
UL.displayName = "UL";
var OL = (0, import_utils12.forwardRef)(({ className, unstyled = false, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
  Box,
  {
    as: "ol",
    ref,
    className: (0, import_lib10.cn)(
      {
        "m-4 list-decimal [&>li]:mt-2": !unstyled
      },
      className
    ),
    ...props
  }
));
OL.displayName = "OL";
var LI = (0, import_utils12.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { as: "li", ref, className: (0, import_lib10.cn)("", className), ...props }));
LI.displayName = "LI";
var Code = (0, import_utils12.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
  Box,
  {
    as: "code",
    ref,
    className: (0, import_lib10.cn)("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-normal", className),
    ...props
  }
));
Code.displayName = "Code";
var Lead = (0, import_utils12.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { as: "p", ref, className: (0, import_lib10.cn)("text-xl text-muted-foreground", className), ...props }));
Lead.displayName = "Lead";
var Large = (0, import_utils12.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { as: "div", ref, className: (0, import_lib10.cn)("text-lg font-semibold", className), ...props }));
Large.displayName = "Large";
var Small = (0, import_utils12.forwardRef)(
  ({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { as: "small", ref, className: (0, import_lib10.cn)("text-sm font-medium leading-none", className), ...props })
);
Small.displayName = "Small";
var Subtle = (0, import_utils12.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { as: "p", ref, className: (0, import_lib10.cn)("text-sm text-muted-foreground", className), ...props }));
Subtle.displayName = "Subtle";
var Strong = (0, import_utils12.forwardRef)(
  ({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Box, { as: "strong", ref, className: (0, import_lib10.cn)("font-semibold", className), ...props })
);
Strong.displayName = "Strong";

// src/base/VStack/VStack.tsx
var import_lib11 = require("@paalan/react-shared/lib");
var import_utils13 = require("@paalan/react-shared/utils");
var import_jsx_runtime13 = require("react/jsx-runtime");
var VStack = (0, import_utils13.forwardRef)((props, ref) => {
  const { children, className, ...restProps } = props;
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Box, { className: (0, import_lib11.cn)("flex flex-col items-stretch gap-2", className), ...restProps, ref, children });
});

// src/base/Wrap/Wrap.tsx
var import_lib12 = require("@paalan/react-shared/lib");
var import_utils14 = require("@paalan/react-shared/utils");
var import_jsx_runtime14 = require("react/jsx-runtime");
var Wrap = (0, import_utils14.forwardRef)((props, ref) => {
  const { children, className, ...restProps } = props;
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Box, { className: (0, import_lib12.cn)("flex flex-wrap gap-2", className), ...restProps, ref, children });
});
var WrapItem = (0, import_utils14.forwardRef)((props, ref) => {
  const { children, className, ...restProps } = props;
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Box, { className: (0, import_lib12.cn)("flex flex-none items-start", className), ...restProps, ref, children });
});

// src/components/ErrorMessage/ErrorMessage.tsx
var import_lib13 = require("@paalan/react-shared/lib");
var import_jsx_runtime15 = require("react/jsx-runtime");
var ErrorMessage = ({ message, className, label, ...props }) => {
  const errorMessage = message || (label ? `${label} is required` : "");
  if (!errorMessage) return null;
  return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Text, { className: (0, import_lib13.cn)("mt-2 text-sm text-danger", className), ...props, children: errorMessage });
};

// src/components/Label/Label.tsx
var React2 = __toESM(require("react"), 1);
var import_react_icons = require("@paalan/react-icons");
var import_lib15 = require("@paalan/react-shared/lib");
var LabelPrimitive = __toESM(require("@radix-ui/react-label"), 1);
var import_class_variance_authority2 = require("class-variance-authority");

// src/components/Tooltip/Tooltip.tsx
var React = __toESM(require("react"), 1);
var import_react_hooks2 = require("@paalan/react-hooks");
var import_lib14 = require("@paalan/react-shared/lib");
var TooltipPrimitive = __toESM(require("@radix-ui/react-tooltip"), 1);
var import_jsx_runtime16 = require("react/jsx-runtime");
var TooltipProvider = TooltipPrimitive.Provider;
var TooltipRoot = TooltipPrimitive.Root;
var TooltipTrigger = TooltipPrimitive.Trigger;
var TooltipPortal = TooltipPrimitive.Portal;
var TooltipContent = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
  TooltipPrimitive.Content,
  {
    ref,
    sideOffset,
    className: (0, import_lib14.cn)(
      "z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
      className
    ),
    ...props
  }
));
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
var Tooltip = React.forwardRef(
  ({
    className,
    trigger,
    asPortal,
    content,
    side = "top",
    align = "center",
    defaultOpen,
    open,
    onOpenChange,
    ...props
  }, ref) => {
    const TooltipPortalComponent = asPortal ? TooltipPortal : React.Fragment;
    const [localOpen, setLocalOpen] = (0, import_react_hooks2.useControllableState)({
      defaultValue: defaultOpen,
      value: open,
      onChange: onOpenChange
    });
    return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TooltipProvider, { delayDuration: 100, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(TooltipRoot, { open: localOpen, onOpenChange: setLocalOpen, children: [
      /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TooltipTrigger, { asChild: true, children: trigger }),
      /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TooltipPortalComponent, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
        TooltipContent,
        {
          ref,
          className: (0, import_lib14.cn)("bg-secondary fill-secondary text-secondary-foreground", className),
          side,
          align,
          ...props,
          children: [
            content,
            /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TooltipPrimitive.Arrow, { width: 11, height: 5 })
          ]
        }
      ) })
    ] }) });
  }
);

// src/components/Label/Label.tsx
var import_jsx_runtime17 = require("react/jsx-runtime");
var labelVariants = (0, import_class_variance_authority2.cva)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
var Label = React2.forwardRef(
  ({ className, required = false, labelDescription, text, isInvalid, children, disabled, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
    LabelPrimitive.Root,
    {
      ref,
      className: (0, import_lib15.cn)(labelVariants(), { "text-danger": isInvalid, "opacity-70": disabled }, className),
      ...props,
      children: [
        text || children,
        required && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "text-danger/70", children: "*" }),
        labelDescription && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
          Tooltip,
          {
            trigger: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_icons.InfoOutlineIcon, { className: "ml-1 text-muted-foreground", "aria-hidden": "true" }),
            content: labelDescription
          }
        )
      ]
    }
  )
);
Label.displayName = LabelPrimitive.Root.displayName;

// src/components/Select/helper.ts
var isSelectOptionGroup = (option) => {
  return Object.hasOwnProperty.call(option, "options");
};

// src/components/Select/Select.tsx
var import_jsx_runtime18 = require("react/jsx-runtime");
var SelectRoot = SelectPrimitive.Root;
var SelectPortal = SelectPrimitive.Portal;
var SelectIcon = SelectPrimitive.Icon;
var SelectGroup = SelectPrimitive.Group;
var SelectValue = SelectPrimitive.Value;
var SelectTrigger = React3.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
  SelectPrimitive.Trigger,
  {
    ref,
    className: (0, import_lib16.cn)(
      "flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
      className
    ),
    ...props,
    children: [
      children,
      /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_icons2.CaretSortIcon, { className: "size-4 opacity-80" }) })
    ]
  }
));
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
var SelectContent = React3.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectPrimitive.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
  SelectPrimitive.Content,
  {
    ref,
    className: (0, import_lib16.cn)(
      "relative z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out 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-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
      position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
      className
    ),
    position,
    ...props,
    children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
      SelectPrimitive.Viewport,
      {
        className: (0, import_lib16.cn)(
          "p-1",
          position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
        ),
        children
      }
    )
  }
) }));
SelectContent.displayName = SelectPrimitive.Content.displayName;
var SelectLabel = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectPrimitive.Label, { ref, className: (0, import_lib16.cn)("px-2 py-1.5 text-sm font-semibold", className), ...props }));
SelectLabel.displayName = SelectPrimitive.Label.displayName;
var SelectItem = React3.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
  SelectPrimitive.Item,
  {
    ref,
    className: (0, import_lib16.cn)(
      "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
      className
    ),
    ...props,
    children: [
      /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "absolute right-2 flex size-3.5 items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_icons2.CheckIcon, { className: "size-4" }) }) }),
      /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectPrimitive.ItemText, { children })
    ]
  }
));
SelectItem.displayName = SelectPrimitive.Item.displayName;
var SelectSeparator = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectPrimitive.Separator, { ref, className: (0, import_lib16.cn)("-mx-1 my-1 h-px bg-muted", className), ...props }));
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
var Select = React3.forwardRef(
  ({
    placeholder = "Select",
    label,
    triggerClassName,
    contentClassName,
    options,
    id,
    required,
    value,
    defaultValue,
    onValueChange,
    onBlur,
    isInvalid: invalid,
    inline,
    className,
    errorMessage,
    noOptionsMessage = "No option found.",
    ...props
  }, ref) => {
    const [localValue, setLocalValue] = (0, import_react_hooks3.useControllableState)({
      value: (0, import_lib16.isDefinedValue)(value) ? value : "",
      defaultValue: (0, import_lib16.isDefinedValue)(defaultValue) ? defaultValue : "",
      onChange: onValueChange
    });
    const labelId = id ? id : label ? label.toString().toLowerCase().replace(/\s/g, "-") : void 0;
    const isInvalid = (0, import_lib16.isAriaInvalid)(props["aria-invalid"]) || invalid;
    const groups = React3.useMemo(() => {
      const groupArray = [];
      options.forEach((option) => {
        if (typeof option === "string" || typeof option === "number") {
          if (!groupArray.length) {
            groupArray.push({ options: [] });
          }
          if (option) {
            groupArray[0].options.push({ key: option.toString(), label: option.toString(), value: option.toString() });
          }
        } else if (isSelectOptionGroup(option)) {
          groupArray.push(option);
        } else {
          if (!groupArray.length) {
            groupArray.push({ options: [] });
          }
          groupArray[0].options.push(option);
        }
      });
      return groupArray;
    }, [options]);
    const selectedOption = React3.useMemo(() => {
      if (!localValue) return null;
      for (const group of groups) {
        for (const option of group.options) {
          if (option.value === localValue) {
            return option;
          }
        }
      }
      return null;
    }, [groups, localValue]);
    return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
        Box,
        {
          className: (0, import_lib16.cn)(
            "flex w-full flex-col gap-2",
            {
              "flex-row items-center": inline
            },
            className
          ),
          children: [
            label && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label, { htmlFor: labelId, required, children: label }),
            /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(SelectRoot, { ...props, required, value: localValue, onValueChange: setLocalValue, children: [
              /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
                SelectTrigger,
                {
                  className: (0, import_lib16.cn)(
                    !localValue && "text-muted-foreground",
                    {
                      "border-danger text-danger focus-visible:ring-danger/40 ": isInvalid
                    },
                    triggerClassName
                  ),
                  id: labelId,
                  ref,
                  onBlur,
                  children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder, children: selectedOption?.label || localValue || placeholder })
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { className: contentClassName, children: !groups.length ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Text, { className: "px-3 py-1 text-center text-sm text-gray-500", children: noOptionsMessage }) : groups.map((group, index) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(React3.Fragment, { children: [
                /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(SelectGroup, { children: [
                  group.label && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectLabel, { children: group.label }),
                  group.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
                    SelectItem,
                    {
                      className: (0, import_lib16.cn)("cursor-pointer", option.className),
                      value: option.value,
                      disabled: option.disabled,
                      children: option.labelContent || option.label
                    },
                    option.key || option.value
                  ))
                ] }),
                index !== groups.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectSeparator, {})
              ] }, `${group.label || ""}${index.toString()}`)) })
            ] })
          ]
        }
      ),
      isInvalid && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ErrorMessage, { message: errorMessage })
    ] });
  }
);
Select.displayName = "Select";
