import{j as i,r as m}from"./sikshya-admin-sikshya-react-E_TY_un4.js";import{D as b}from"./sikshya-admin-sikshya-datepicker-2wS9MLBN.js";function f(t){const n=String(t||"").trim();if(!n)return null;const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(n);if(!e)return null;const r=Number(e[1]),a=Number(e[2]),s=Number(e[3]);if(!Number.isFinite(r)||!Number.isFinite(a)||!Number.isFinite(s))return null;const l=new Date(r,a-1,s,0,0,0,0);return Number.isFinite(l.getTime())?l:null}function x(t){if(!t)return"";const n=t.getFullYear(),e=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${n}-${e}-${r}`}function g(t){const n=String(t||"").trim();if(!n)return null;const e=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?$/.exec(n);if(!e)return null;const r=Number(e[1]),a=Number(e[2]),s=Number(e[3]),l=Number(e[4]),o=Number(e[5]),c=e[6]?Number(e[6]):0;if(![r,a,s,l,o,c].every(d=>Number.isFinite(d)))return null;const u=new Date(r,a-1,s,l,o,c,0);return Number.isFinite(u.getTime())?u:null}function N(t){if(!t)return"";const n=t.getFullYear(),e=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),a=String(t.getHours()).padStart(2,"0"),s=String(t.getMinutes()).padStart(2,"0");return`${n}-${e}-${r}T${a}:${s}`}const h=m.forwardRef(function(n,e){const{className:r="",...a}=n;return i.jsx("input",{ref:e,...a,className:`block w-full rounded-xl border border-slate-200 bg-white px-3 py-2 text-sm text-slate-900 placeholder:text-slate-400 focus:border-brand-500 focus:outline-none focus:ring-2 focus:ring-brand-500/20 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-600 dark:bg-slate-800 dark:text-white dark:placeholder:text-slate-500 ${r}`})});function k(t){const{label:n,description:e,disabled:r=!1,className:a="",container:s="label",placeholder:l=t.kind==="date"?"Select a date…":"Select date & time…"}=t,o=t.kind==="date"?f(t.value):g(t.value),c=d=>{t.kind==="date"?t.onChange(x(d)):t.onChange(N(d))},u=s==="div"?"div":"label";return i.jsxs(u,{className:`block text-sm ${a}`,children:[n?i.jsx("span",{className:"text-slate-600 dark:text-slate-400",children:n}):null,e?i.jsx("span",{className:"mt-1 block text-xs text-slate-500 dark:text-slate-400",children:e}):null,i.jsx("div",{className:"mt-1 w-full",children:i.jsx(b,{selected:o,onChange:c,disabled:r,placeholderText:l,dateFormat:t.kind==="date"?"yyyy-MM-dd":"yyyy-MM-dd HH:mm",showTimeSelect:t.kind==="datetime",timeIntervals:15,timeCaption:"Time",customInput:i.jsx(h,{}),wrapperClassName:"w-full",popperPlacement:"bottom-start"})})]})}export{k as D};
