'use client';'use strict';

var chunkYPSNKU2I_cjs = require('./chunk-YPSNKU2I.cjs');
var chunk4IQP4J4C_cjs = require('./chunk-4IQP4J4C.cjs');
var chunk5XB54L7P_cjs = require('./chunk-5XB54L7P.cjs');
var icons = require('@onbeam/icons');
var reactPopover = require('@radix-ui/react-popover');
var react = require('react');
var css = require('@onbeam/styled-system/css');
var reactDeviceDetect = require('react-device-detect');
var utils = require('@onbeam/utils');
var recipes = require('@onbeam/styled-system/recipes');
var jsxRuntime = require('react/jsx-runtime');

var p=e=>{if(typeof e!="string")return;let n=new Date(e);if(!Number.isNaN(n.getTime()))return n},f=e=>`${utils.padString(e.getFullYear(),4,"0")}-${utils.padString(e.getMonth()+1,2,"0")}-${utils.padString(e.getDate(),2,"0")}`;var g=chunk5XB54L7P_cjs.a(({value:e,className:n,calendarProps:v,children:h,...k},I)=>{let t=react.useRef(null);react.useImperativeHandle(I,()=>t.current);let[b,u]=react.useState(p(e)||new Date),[C,w]=react.useState(p(e)),i=recipes.datePicker();react.useEffect(()=>{let r=t.current?.value;if(!r)return;let a=p(r);a&&(u(a),w(a));},[t.current?.value]);let y=r=>{if(!t.current)return;Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value")?.set?.call(t.current,f(r)),t.current.dispatchEvent(new Event("input",{bubbles:!0}));};return jsxRuntime.jsxs(reactPopover.Popover,{children:[jsxRuntime.jsx(reactPopover.PopoverAnchor,{children:jsxRuntime.jsx(reactPopover.PopoverTrigger,{asChild:!0,children:jsxRuntime.jsx(chunk4IQP4J4C_cjs.a,{ref:t,type:"date",size:"sm",className:css.cx(i.input,n),leftAddon:jsxRuntime.jsx(icons.CalendarIcon,{height:16,width:16}),value:e,...k})})}),jsxRuntime.jsx(reactPopover.PopoverPortal,{children:jsxRuntime.jsxs(reactPopover.PopoverContent,{side:"bottom",align:"end",sideOffset:4,className:css.cx(recipes.customScrollbar(),i.content),"data-desktop":reactDeviceDetect.isDesktop,onOpenAutoFocus:r=>r.preventDefault(),children:[h,jsxRuntime.jsx(chunkYPSNKU2I_cjs.a,{mode:"single",required:!0,selected:C,onSelect:y,month:b,onMonthChange:u,className:i.calendar,...v})]})})]})});g.displayName="DatePicker";

exports.a = g;
//# sourceMappingURL=out.js.map
//# sourceMappingURL=chunk-WNROPRPV.cjs.map