"use client";
import { jsxs, jsx } from 'react/jsx-runtime';
import { format } from 'date-fns';
import { Calendar } from 'lucide-react';
import { cn } from '../lib/utils.mjs';
import { Button } from './button.mjs';
import { Calendar as Calendar$1 } from './calendar.mjs';
import { Popover, PopoverTrigger, PopoverContent } from './popover.mjs';
import { forwardRef } from 'react';

const DatePicker = forwardRef(function DatePickerCmp({ date, setDate }, ref) {
  return /* @__PURE__ */ jsxs(Popover, { children: [
    /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
      Button,
      {
        variant: "outline",
        className: cn(
          "w-full justify-start text-left font-normal",
          !date && "text-muted-foreground"
        ),
        children: [
          /* @__PURE__ */ jsx(Calendar, { className: "mr-2 h-4 w-4" }),
          date ? format(date, "PPP") : /* @__PURE__ */ jsx("span", { children: "Pick a date" })
        ]
      }
    ) }),
    /* @__PURE__ */ jsx(PopoverContent, { className: "w-auto p-0", ref, children: /* @__PURE__ */ jsx(
      Calendar$1,
      {
        mode: "single",
        selected: date,
        onSelect: setDate,
        initialFocus: true
      }
    ) })
  ] });
});

export { DatePicker };
