@ttianqii/takaui 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -69,7 +69,7 @@ export declare interface CustomField {
69
69
  required?: boolean;
70
70
  }
71
71
 
72
- export declare function DataGrid<T>({ columns, data, getRowId, onRowClick, children, recordCount, currentPage: externalPage, pageSize: externalPageSize, onPaginationChange, }: DataGridProps<T>): JSX.Element;
72
+ export declare function DataGrid<T>({ columns, data, getRowId, onRowClick, children, recordCount, currentPage: externalPage, pageSize: externalPageSize, onPaginationChange, loading, emptyMessage, manualPagination, }: DataGridProps<T>): JSX.Element;
73
73
 
74
74
  export declare interface DataGridColumn<T = any> {
75
75
  id: string;
@@ -125,8 +125,19 @@ declare interface DataGridContextValue<T = any> {
125
125
  sortedData: T[];
126
126
  totalPages: number;
127
127
  recordCount: number;
128
+ loading: boolean;
129
+ emptyMessage: string;
130
+ manualPagination: boolean;
128
131
  }
129
132
 
133
+ export declare function DataGridEmptyState({ message }: DataGridEmptyStateProps): JSX.Element;
134
+
135
+ declare interface DataGridEmptyStateProps {
136
+ message: string;
137
+ }
138
+
139
+ export declare function DataGridLoadingSpinner(): JSX.Element;
140
+
130
141
  export declare function DataGridPagination({ mode, pageSizeOptions }: DataGridPaginationProps): JSX.Element;
131
142
 
132
143
  declare interface DataGridPaginationProps {
@@ -144,6 +155,9 @@ export declare interface DataGridProps<T = any> {
144
155
  currentPage?: number;
145
156
  pageSize?: number;
146
157
  onPaginationChange?: (pagination: PaginationState) => void;
158
+ loading?: boolean;
159
+ emptyMessage?: string;
160
+ manualPagination?: boolean;
147
161
  }
148
162
 
149
163
  export declare function DataGridTable(): JSX.Element;
package/dist/takaui.cjs CHANGED
@@ -1,2 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const wt=require("clsx"),Nt=require("tailwind-merge"),e=require("react/jsx-runtime"),I=require("react"),St=require("@radix-ui/react-slot"),Dt=require("@radix-ui/react-checkbox"),M=require("lucide-react"),Mt=require("@radix-ui/react-dropdown-menu"),Ct=require("@radix-ui/react-select"),K=require("date-fns"),kt=require("@radix-ui/react-popover"),Tt=require("@radix-ui/react-label"),Rt=require("@radix-ui/react-dialog");function Ne(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(s,r,i.get?i:{enumerable:!0,get:()=>t[r]})}}return s.default=t,Object.freeze(s)}const w=Ne(I),Ee=Ne(Dt),Q=Ne(Mt),U=Ne(Ct),Ce=Ne(kt),tt=Ne(Tt),le=Ne(Rt);function o(...t){return Nt.twMerge(wt.clsx(t))}const y=w.forwardRef(({className:t,variant:s="default",size:r="default",asChild:i=!1,...p},N)=>{const d=i?St.Slot:"button";return e.jsx(d,{className:o("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50",s==="default"&&"bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800 active:scale-95",s==="destructive"&&"bg-red-600 text-white hover:bg-red-700 active:bg-red-800 active:scale-95",s==="outline"&&"border border-gray-300 bg-white text-gray-900 hover:bg-gray-50 active:bg-gray-100 active:scale-95",s==="secondary"&&"bg-gray-200 text-gray-900 hover:bg-gray-300 active:bg-gray-400 active:scale-95",s==="ghost"&&"bg-transparent text-gray-900 hover:bg-gray-100 active:bg-gray-200 active:scale-95",s==="link"&&"bg-transparent text-blue-600 underline-offset-4 hover:text-blue-700 hover:underline active:text-blue-800",r==="default"&&"h-9 px-4 py-2",r==="sm"&&"h-8 px-3 text-xs gap-1.5",r==="lg"&&"h-10 px-6",r==="icon"&&"h-9 w-9 p-0",r==="icon-sm"&&"h-8 w-8 p-0",r==="icon-lg"&&"h-10 w-10 p-0",t),ref:N,...p})});y.displayName="Button";const Re=w.forwardRef(({className:t,...s},r)=>e.jsx(Ee.Root,{ref:r,className:o("peer h-4 w-4 shrink-0 rounded border border-gray-200 bg-white ring-offset-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-400 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-gray-900 data-[state=checked]:border-gray-900 data-[state=checked]:text-white transition-colors",t),...s,children:e.jsx(Ee.Indicator,{className:o("flex items-center justify-center text-current"),children:e.jsx(M.Check,{className:"h-3.5 w-3.5 stroke-[2.5]"})})}));Re.displayName=Ee.Root.displayName;const ue=w.forwardRef(({className:t,type:s,...r},i)=>e.jsx("input",{type:s,className:o("flex h-10 w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-400 focus:outline-none focus:border-gray-500 hover:border-gray-400 disabled:cursor-not-allowed disabled:opacity-50 transition-colors",t),ref:i,...r}));ue.displayName="Input";const st=w.forwardRef(({className:t,orientation:s="horizontal",decorative:r=!0,...i},p)=>e.jsx("div",{ref:p,role:r?"none":"separator","aria-orientation":s,className:o("shrink-0 bg-gray-200",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...i}));st.displayName="Separator";const at=w.createContext({variant:"default"});function Ye({className:t,variant:s="default",...r}){return e.jsx(at.Provider,{value:{variant:s},children:e.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:e.jsx("table",{"data-slot":"table",className:o("w-full caption-bottom text-sm",t),...r})})})}function _e({className:t,...s}){return e.jsx("thead",{"data-slot":"table-header",className:o("bg-gray-50 [&_tr]:border-b [&_tr]:border-gray-200",t),...s})}function Le({className:t,...s}){return e.jsx("tbody",{"data-slot":"table-body",className:o("[&_tr:last-child]:border-b-0",t),...s})}function It({className:t,...s}){return e.jsx("tfoot",{"data-slot":"table-footer",className:o("bg-muted/50 border-t font-medium [&>tr]:last:border-b-0",t),...s})}function we({className:t,...s}){const{variant:r}=w.useContext(at);return e.jsx("tr",{"data-slot":"table-row",className:o("hover:bg-gray-50 data-[state=selected]:bg-gray-50 transition-colors border-b border-gray-200",r==="clean"&&"border-b-0",t),...s})}function Ge({className:t,...s}){return e.jsx("th",{"data-slot":"table-head",className:o("text-foreground h-auto px-3 py-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...s})}function Te({className:t,...s}){return e.jsx("td",{"data-slot":"table-cell",className:o("px-3 py-2 text-left align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...s})}function Pt({className:t,...s}){return e.jsx("caption",{"data-slot":"table-caption",className:o("text-muted-foreground mt-4 text-sm",t),...s})}function zt({...t}){return e.jsx(Q.Root,{"data-slot":"dropdown-menu",...t})}function Ht({...t}){return e.jsx(Q.Portal,{"data-slot":"dropdown-menu-portal",...t})}function Ft({...t}){return e.jsx(Q.Trigger,{"data-slot":"dropdown-menu-trigger",suppressHydrationWarning:!0,...t})}function At({className:t,sideOffset:s=4,...r}){return e.jsx(Q.Portal,{children:e.jsx(Q.Content,{"data-slot":"dropdown-menu-content",sideOffset:s,className:o("bg-white text-gray-900 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 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-gray-200 p-2 shadow-lg",t),...r})})}function Et({...t}){return e.jsx(Q.Group,{"data-slot":"dropdown-menu-group",...t})}function Ot({className:t,inset:s,variant:r="default",...i}){return e.jsx(Q.Item,{"data-slot":"dropdown-menu-item","data-inset":s,"data-variant":r,className:o("focus:bg-gray-100 focus:text-gray-900 data-[variant=destructive]:text-red-600 data-[variant=destructive]:focus:bg-red-50 data-[variant=destructive]:focus:text-red-700 [&_svg:not([class*='text-'])]:text-gray-500 relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none select-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...i})}function $t({className:t,children:s,checked:r,...i}){return e.jsxs(Q.CheckboxItem,{"data-slot":"dropdown-menu-checkbox-item",className:o("focus:bg-gray-100 focus:text-gray-900 relative flex cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),checked:r,...i,children:[e.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:e.jsx(Q.ItemIndicator,{children:e.jsx(M.CheckIcon,{className:"size-4 text-blue-600"})})}),s]})}function Yt({...t}){return e.jsx(Q.RadioGroup,{"data-slot":"dropdown-menu-radio-group",...t})}function _t({className:t,children:s,...r}){return e.jsxs(Q.RadioItem,{"data-slot":"dropdown-menu-radio-item",className:o("focus:bg-gray-100 focus:text-gray-900 relative flex cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...r,children:[e.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:e.jsx(Q.ItemIndicator,{children:e.jsx(M.CircleIcon,{className:"size-2 fill-blue-600"})})}),s]})}function Lt({className:t,inset:s,...r}){return e.jsx(Q.Label,{"data-slot":"dropdown-menu-label","data-inset":s,className:o("px-2 py-1.5 text-sm font-semibold text-gray-900 data-[inset]:pl-8",t),...r})}function Gt({className:t,...s}){return e.jsx(Q.Separator,{"data-slot":"dropdown-menu-separator",className:o("bg-gray-100 my-1 h-px",t),...s})}function Vt({className:t,...s}){return e.jsx("span",{"data-slot":"dropdown-menu-shortcut",className:o("text-gray-500 ml-auto text-xs tracking-widest",t),...s})}function Wt({...t}){return e.jsx(Q.Sub,{"data-slot":"dropdown-menu-sub",...t})}function Bt({className:t,inset:s,children:r,...i}){return e.jsxs(Q.SubTrigger,{"data-slot":"dropdown-menu-sub-trigger","data-inset":s,className:o("focus:bg-gray-100 focus:text-gray-900 data-[state=open]:bg-gray-100 data-[state=open]:text-gray-900 [&_svg:not([class*='text-'])]:text-gray-500 flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none select-none transition-colors data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...i,children:[r,e.jsx(M.ChevronRightIcon,{className:"ml-auto size-4"})]})}function qt({className:t,...s}){return e.jsx(Q.SubContent,{"data-slot":"dropdown-menu-sub-content",className:o("bg-white text-gray-900 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 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border border-gray-200 p-2 shadow-lg",t),...s})}function Jt({data:t=[],columns:s,searchPlaceholder:r="Search...",onRowClick:i,className:p="",showPagination:N=!0,showSearch:d=!0,pageSize:T,pageSizeOptions:H=[5,10,20,50],renderToolbar:A,variant:B="default",onPaginationChange:v,onSearchChange:C,onSortChange:R}){const S=T??H[0]??10,[E,W]=I.useState(1),[Y,O]=I.useState(S),[V,f]=I.useState(""),[P,q]=I.useState(null),[L,z]=I.useState("asc"),h=I.useMemo(()=>{if(!d||!V.trim())return t;const a=V.toLowerCase();return t.filter(g=>s.some(m=>(m.accessor?m.accessor(g):g[m.key])?.toString().toLowerCase().includes(a)))},[t,V,d,s]),x=I.useMemo(()=>P?[...h].sort((a,g)=>{const m=s.find(te=>te.key===P);if(!m)return 0;const b=m.accessor?m.accessor(a):a[m.key],$=m.accessor?m.accessor(g):g[m.key];if(b===$)return 0;if(b==null)return 1;if($==null)return-1;const X=b<$?-1:1;return L==="asc"?X:-X}):h,[h,P,L,s]),u=I.useMemo(()=>{if(!N)return x;const a=(E-1)*Y;return x.slice(a,a+Y)},[x,E,Y,N]);I.useEffect(()=>{if(v){const a=Math.ceil(x.length/Y);v({page:E,limit:Y,total:x.length,totalPages:a})}},[E,Y,x.length]),I.useEffect(()=>{W(1),C&&C(V)},[V]);const l=a=>{let g="asc";P===a?(g=L==="asc"?"desc":"asc",z(g)):(q(a),z("asc")),R&&R(a,P===a?g:"asc")},k=(a,g,m)=>{const b=g.accessor?g.accessor(a):a[g.key];return g.cell?g.cell(b,a,m):b};return e.jsxs("div",{className:o("w-full space-y-4",p),children:[(d||A)&&e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[d&&e.jsxs("div",{className:"relative w-full sm:w-auto",children:[e.jsx(M.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),e.jsx(ue,{placeholder:r,value:V,onChange:a=>f(a.target.value),className:"pl-10 w-full sm:w-[300px] bg-gray-50 border-gray-300"})]}),A&&e.jsx("div",{className:"w-full sm:w-auto",children:A()})]}),e.jsx("div",{className:"border border-gray-200 rounded-lg overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Ye,{variant:B,children:[e.jsx(_e,{children:e.jsx(we,{children:s.map(a=>e.jsx(Ge,{className:"h-10 px-0 py-0",style:{width:a.width},children:a.align==="center"||!a.align&&typeof a.header!="string"?e.jsx("div",{className:"h-10 flex items-center justify-center",children:typeof a.header!="string"?a.header:e.jsx("span",{className:o("text-xs font-normal text-gray-500 uppercase tracking-widest",a.headerClassName),children:a.header})}):e.jsx("div",{className:o("h-10 flex items-center text-xs font-normal text-gray-500 uppercase tracking-widest",a.headerClassName),children:typeof a.header!="string"?e.jsx("div",{children:a.header}):a.sortable!==!1?e.jsxs(y,{variant:"ghost",className:o("h-auto px-3 py-1.5 text-xs font-normal hover:bg-transparent hover:text-gray-900",a.headerClassName),onClick:()=>l(a.key),children:[a.header,P===a.key&&L==="desc"?e.jsx(M.ChevronDown,{className:"h-4 w-4"}):P===a.key&&L==="asc"?e.jsx(M.ChevronUp,{className:"h-4 w-4"}):e.jsx(M.ChevronsUpDown,{className:"h-4 w-4"})]}):e.jsx("span",{className:"px-3",children:a.header})})},a.key))})}),e.jsx(Le,{children:u.length===0?e.jsx(we,{children:e.jsx(Te,{colSpan:s.length,className:"text-center py-8 text-gray-500",children:"No results found."})}):u.map((a,g)=>e.jsx(we,{className:"hover:bg-gray-50 cursor-pointer",onClick:()=>i?.(a),children:s.map(m=>{const b=m.align==="center"||!m.align&&typeof m.header!="string";return e.jsx(Te,{className:b?"px-0 py-4":"px-3 py-4",style:{width:m.width},children:b?e.jsx("div",{className:"flex items-center justify-center h-full",children:k(a,m,g)}):k(a,m,g)},m.key)})},g))})]})})}),N&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 px-2 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-700",children:"Rows per page:"}),e.jsx("select",{value:Y,onChange:a=>{const g=Number(a.target.value);O(g),W(1)},className:"border border-gray-300 rounded px-2 py-1 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",children:H.map(a=>e.jsx("option",{value:a,children:a},a))})]}),e.jsxs("div",{className:"text-sm text-gray-600",children:["Showing ",u.length," of ",x.length," row(s)"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm text-gray-700",children:["Page ",E," of ",Math.ceil(x.length/Y)]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:()=>W(a=>Math.max(1,a-1)),disabled:E===1,className:"h-8 w-8 p-0",children:e.jsx(M.ChevronLeft,{className:"h-4 w-4"})}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>W(a=>Math.min(Math.ceil(x.length/Y),a+1)),disabled:E===Math.ceil(x.length/Y),className:"h-8 w-8 p-0",children:e.jsx(M.ChevronRight,{className:"h-4 w-4"})})]})]})]})]})}const rt=I.createContext(null);function ke(){const t=I.useContext(rt);if(!t)throw new Error("useDataGrid must be used within DataGrid");return t}function Ut({columns:t,data:s,getRowId:r=A=>A?.id||String(Math.random()),onRowClick:i,children:p,recordCount:N,currentPage:d,pageSize:T,onPaginationChange:H}){const[A,B]=I.useState(0),[v,C]=I.useState(10),R=d!==void 0?d-1:A,S=T??v,[E,W]=I.useState([]),[Y,O]=I.useState(new Set),V=I.useMemo(()=>E.length===0?s:[...s].sort((G,Z)=>{for(const se of E){const ae=t.find(de=>de.id===se.id);if(!ae?.accessorKey)continue;const he=G[ae.accessorKey],pe=Z[ae.accessorKey];if(he===pe)continue;const me=he<pe?-1:1;return se.desc?-me:me}return 0}),[s,E,t]),f=I.useMemo(()=>{const F=R*S,G=F+S;return V.slice(F,G)},[V,R,S]),P=N??V.length,q=Math.ceil(P/S),L=q,z=(F,G)=>{const Z={page:F+1,limit:G,total:P,totalPages:Math.ceil(P/G)};H?.(Z)},h=R>0,x=R<q-1,u=()=>{const F=R-1;d===void 0&&B(F),z(F,S)},l=()=>{const F=Math.min(R+1,L-1);d===void 0&&B(F),z(F,S)},k=F=>{T===void 0&&C(F),d===void 0&&B(0),z(0,F)},a=F=>{const G=Math.max(0,Math.min(F,L-1));d===void 0&&B(G),z(G,S)},g={pageIndex:R,pageSize:S},m=F=>{const G=typeof F=="function"?F(g):F;d===void 0&&B(G.pageIndex),T===void 0&&C(G.pageSize),z(G.pageIndex,G.pageSize)},b=F=>{O(G=>{const Z=new Set(G);return Z.has(F)?Z.delete(F):Z.add(F),Z})},$=()=>{Y.size===f.length?O(new Set):O(new Set(f.map(F=>r(F))))},X=f.length>0&&Y.size===f.length,te={columns:t,data:s,getRowId:r,onRowClick:i,pagination:g,setPagination:m,canPreviousPage:h,canNextPage:x,previousPage:u,nextPage:l,setPageSize:k,goToPage:a,pageCount:L,sorting:E,setSorting:W,selectedRows:Y,toggleRow:b,toggleAllRows:$,isAllRowsSelected:X,paginatedData:f,sortedData:V,totalPages:q,recordCount:P};return e.jsx(rt.Provider,{value:te,children:p})}function Kt(){const{columns:t,paginatedData:s,getRowId:r,onRowClick:i}=ke();return e.jsx("div",{className:"border border-gray-200 rounded-lg overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Ye,{children:[e.jsx(_e,{children:e.jsx(we,{children:t.map(p=>e.jsx(Ge,{className:"h-10 px-0 py-0",style:{width:p.size?`${p.size}px`:void 0},children:p.align==="center"?e.jsx("div",{className:"h-10 flex items-center justify-center",children:typeof p.header!="string"?p.header:e.jsx("span",{className:"text-xs font-normal text-gray-500 uppercase tracking-widest",children:p.header})}):e.jsx("div",{className:"h-10 flex items-center text-xs font-normal text-gray-500 uppercase tracking-widest",children:typeof p.header!="string"?e.jsx("div",{children:p.header}):e.jsx("span",{className:"px-3",children:p.header})})},p.id))})}),e.jsx(Le,{children:s.length===0?e.jsx(we,{children:e.jsx(Te,{colSpan:t.length,className:"text-center py-8 text-gray-500",children:"No results found."})}):s.map((p,N)=>e.jsx(we,{className:"hover:bg-gray-50 cursor-pointer",onClick:()=>i?.(p),children:t.map(d=>{const T=d.align==="center",H=d.cell?d.cell(p,N):d.accessorKey?p[d.accessorKey]:null;return e.jsx(Te,{className:T?"px-0 py-4":"px-3 py-4",style:{width:d.size?`${d.size}px`:void 0},children:T?e.jsx("div",{className:"flex items-center justify-center h-full",children:H}):H},d.id)})},r(p)))})]})})})}const Se=U.Root,Xt=U.Group,De=U.Value,ve=w.forwardRef(({className:t,children:s,...r},i)=>e.jsxs(U.Trigger,{ref:i,className:o("flex h-10 w-full items-center justify-between rounded-md border border-gray-300 bg-white px-3 py-2 text-sm ring-offset-white placeholder:text-gray-400 focus:outline-none focus:border-gray-500 hover:border-gray-400 disabled:cursor-not-allowed disabled:opacity-50 transition-colors",t),...r,children:[s,e.jsx(U.Icon,{asChild:!0,children:e.jsx(M.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));ve.displayName=U.Trigger.displayName;const nt=w.forwardRef(({className:t,...s},r)=>e.jsx(U.ScrollUpButton,{ref:r,className:o("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(M.ChevronUp,{className:"h-4 w-4"})}));nt.displayName=U.ScrollUpButton.displayName;const ot=w.forwardRef(({className:t,...s},r)=>e.jsx(U.ScrollDownButton,{ref:r,className:o("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(M.ChevronDown,{className:"h-4 w-4"})}));ot.displayName=U.ScrollDownButton.displayName;const je=w.forwardRef(({className:t,children:s,position:r="popper",...i},p)=>e.jsx(U.Portal,{children:e.jsxs(U.Content,{ref:p,className:o("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-gray-200 bg-white text-gray-950 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",r==="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",t),position:r,...i,children:[e.jsx(nt,{}),e.jsx(U.Viewport,{className:o("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(ot,{})]})}));je.displayName=U.Content.displayName;const lt=w.forwardRef(({className:t,...s},r)=>e.jsx(U.Label,{ref:r,className:o("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));lt.displayName=U.Label.displayName;const ge=w.forwardRef(({className:t,children:s,...r},i)=>e.jsxs(U.Item,{ref:i,className:o("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-gray-100 focus:text-gray-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(U.ItemIndicator,{children:e.jsx(M.Check,{className:"h-4 w-4"})})}),e.jsx(U.ItemText,{children:s})]}));ge.displayName=U.Item.displayName;const it=w.forwardRef(({className:t,...s},r)=>e.jsx(U.Separator,{ref:r,className:o("-mx-1 my-1 h-px bg-gray-100",t),...s}));it.displayName=U.Separator.displayName;function Zt({mode:t="simple",pageSizeOptions:s=[5,10,15,20]}){const{canPreviousPage:r,canNextPage:i,previousPage:p,nextPage:N,pageCount:d,pagination:T,setPageSize:H,goToPage:A}=ke();I.useEffect(()=>{s.includes(T.pageSize)||H(s[0])},[]);const B=()=>{const v=T.pageIndex,C=d,R=[];if(C<=7)for(let S=0;S<C;S++)R.push(S);else if(v<=3){for(let S=0;S<=4;S++)R.push(S);R.push("..."),R.push(C-1)}else if(v>=C-4){R.push(0),R.push("...");for(let S=C-5;S<C;S++)R.push(S)}else R.push(0),R.push("..."),R.push(v-1),R.push(v),R.push(v+1),R.push("..."),R.push(C-1);return R};return t==="simple"?e.jsx("div",{className:"flex items-center justify-end px-2 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm text-gray-700 hidden sm:block",children:["Page ",T.pageIndex+1," of ",d]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:p,disabled:!r,className:"h-8 w-8 p-0",children:e.jsx(M.ChevronLeft,{className:"h-4 w-4"})}),e.jsx(y,{variant:"outline",size:"sm",onClick:N,disabled:!i,className:"h-8 w-8 p-0",children:e.jsx(M.ChevronRight,{className:"h-4 w-4"})})]})]})}):e.jsxs("div",{className:"flex items-center justify-between gap-3 px-2 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-600 hidden sm:inline",children:"Rows per page:"}),e.jsxs(Se,{value:String(T.pageSize),onValueChange:v=>H(Number(v)),children:[e.jsx(ve,{className:"h-8 w-16",children:e.jsx(De,{})}),e.jsx(je,{children:s.map(v=>e.jsx(ge,{value:String(v),children:v},v))})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:p,disabled:!r,className:"h-8 w-8 p-0",children:e.jsx(M.ChevronLeft,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-sm text-gray-700 sm:hidden px-2",children:[T.pageIndex+1," / ",d]}),e.jsx("div",{className:"hidden sm:flex gap-1",children:B().map((v,C)=>typeof v=="number"?e.jsx(y,{variant:T.pageIndex===v?"default":"outline",size:"sm",onClick:()=>A(v),className:"h-8 w-8 p-0",children:v+1},C):e.jsx("span",{className:"flex h-8 w-8 items-center justify-center text-gray-400",children:v},C))}),e.jsx(y,{variant:"outline",size:"sm",onClick:N,disabled:!i,className:"h-8 w-8 p-0",children:e.jsx(M.ChevronRight,{className:"h-4 w-4"})})]})]})}function Qt({id:t,title:s}){const{sorting:r,setSorting:i}=ke(),p=r.find(H=>H.id===t),N=!!p,d=p?.desc??!1,T=()=>{i(H=>{const A=H.find(B=>B.id===t);return A?A.desc?[]:[{id:t,desc:!0}]:[{id:t,desc:!1}]})};return e.jsxs(y,{variant:"ghost",className:"h-auto px-3 py-1.5 font-normal hover:bg-transparent hover:text-gray-900",onClick:T,children:[s,N&&d?e.jsx(M.ChevronDown,{className:"h-4 w-4"}):N?e.jsx(M.ChevronUp,{className:"h-4 w-4"}):e.jsx(M.ChevronsUpDown,{className:"h-4 w-4"})]})}function es(){const{toggleAllRows:t,isAllRowsSelected:s}=ke();return e.jsx(Re,{checked:s,onCheckedChange:t})}function ts({row:t}){const{selectedRows:s,toggleRow:r,getRowId:i}=ke(),p=i(t);return e.jsx(Re,{checked:s.has(p),onCheckedChange:()=>r(p)})}const ss=t=>new Date(t.getFullYear(),t.getMonth(),1),as=t=>new Date(t.getFullYear(),t.getMonth()+1,0),rs=(t,s)=>{const r=[],i=new Date(t);for(;i<=s;)r.push(new Date(i)),i.setDate(i.getDate()+1);return r},Ze=(t,s)=>t.getMonth()===s.getMonth()&&t.getFullYear()===s.getFullYear(),Me=(t,s)=>t.getDate()===s.getDate()&&t.getMonth()===s.getMonth()&&t.getFullYear()===s.getFullYear(),Qe=t=>Me(t,new Date),ns=t=>{const s=new Date;return s.setDate(s.getDate()+1),Me(t,s)},et=(t,s)=>{const r=new Date(t);return r.setMonth(r.getMonth()+s),r},Fe=(t,s)=>{const r=["January","February","March","April","May","June","July","August","September","October","November","December"],i=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return s==="MMMM yyyy"?`${r[t.getMonth()]} ${t.getFullYear()}`:s==="MMM d, yyyy"?`${i[t.getMonth()]} ${t.getDate()}, ${t.getFullYear()}`:s==="d"?t.getDate().toString():t.toLocaleDateString()};function os({selected:t,onSelect:s,events:r=[],holidays:i=[],className:p,...N}){const[d,T]=w.useState(new Date),[H,A]=w.useState("calendar"),B=ss(d),v=as(d),C=rs(B,v),R=["January","February","March","April","May","June","July","August","September","October","November","December"],S=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],E=d.getFullYear(),W=Array.from({length:20},(h,x)=>E-10+x),Y=()=>{T(et(d,-1))},O=()=>{T(et(d,1))},V=()=>{const h=new Date(d);h.setFullYear(E-1),T(h)},f=()=>{const h=new Date(d);h.setFullYear(E+1),T(h)},P=h=>{const x=new Date(d);x.setMonth(h),T(x),A("calendar")},q=h=>{const x=new Date(d);x.setFullYear(h),T(x),A("calendar")},L=h=>r.filter(x=>Me(x.date,h)),z=h=>i.some(x=>Me(x.date,h));return H==="months"?e.jsxs("div",{className:o("bg-white rounded-lg border border-gray-200 w-full",p),...N,children:[e.jsx("div",{className:"px-6 py-4 border-b border-gray-100",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>A("calendar"),className:"h-9 px-3 text-sm font-medium text-gray-600 hover:text-gray-900 hover:bg-gray-50 rounded",children:"← Back"}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:V,className:"h-9 w-9 p-0 border-gray-200 rounded",children:e.jsx(M.ChevronLeft,{className:"h-4 w-4"})}),e.jsx(y,{variant:"ghost",onClick:()=>A("years"),className:"h-9 px-4 text-lg font-semibold text-gray-900 hover:bg-gray-50 rounded",children:E}),e.jsx(y,{variant:"outline",size:"sm",onClick:f,className:"h-9 w-9 p-0 border-gray-200 rounded",children:e.jsx(M.ChevronRight,{className:"h-4 w-4"})})]})]})}),e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"grid grid-cols-3 gap-2",children:R.map((h,x)=>e.jsx(y,{variant:"ghost",onClick:()=>P(x),className:o("h-11 w-full text-sm font-medium rounded transition-all duration-200",x===d.getMonth()?"bg-gray-900 text-white hover:bg-gray-800 shadow-sm":"text-gray-600 hover:text-gray-900 hover:bg-gray-50"),children:h},h))})})]}):H==="years"?e.jsxs("div",{className:o("bg-white rounded-lg border border-gray-200 w-full",p),...N,children:[e.jsx("div",{className:"px-6 py-4 border-b border-gray-100",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>A("months"),className:"h-9 px-3 text-sm font-medium text-gray-600 hover:text-gray-900 hover:bg-gray-50 rounded",children:"← Back"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Select Year"})]})}),e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"grid grid-cols-4 gap-2 max-h-64 overflow-y-auto",children:W.map(h=>e.jsx(y,{variant:"ghost",onClick:()=>q(h),className:o("h-11 w-full text-sm font-medium rounded transition-all duration-200",h===E?"bg-gray-900 text-white hover:bg-gray-800 shadow-sm":"text-gray-600 hover:text-gray-900 hover:bg-gray-50"),children:h},h))})})]}):e.jsxs("div",{className:o("bg-white rounded-lg border border-gray-200 w-full",p),...N,children:[e.jsx("div",{className:"px-6 py-4 border-b border-gray-100",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:Y,className:"h-9 w-9 p-0 border-gray-200 rounded",children:e.jsx(M.ChevronLeft,{className:"h-4 w-4"})}),e.jsx(y,{variant:"ghost",onClick:()=>A("months"),className:"h-9 px-4 text-lg font-semibold text-gray-900 hover:bg-gray-50 rounded",children:Fe(d,"MMMM yyyy")}),e.jsx(y,{variant:"outline",size:"sm",onClick:O,className:"h-9 w-9 p-0 border-gray-200 rounded",children:e.jsx(M.ChevronRight,{className:"h-4 w-4"})})]})}),e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:S.map((h,x)=>e.jsx("div",{className:"h-10 flex items-center justify-center",children:e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase",children:h})},x))}),e.jsxs("div",{className:"grid grid-cols-7 gap-1",children:[Array.from({length:B.getDay()}).map((h,x)=>e.jsx("div",{className:"h-12"},`empty-${x}`)),C.map(h=>{const x=L(h),u=t&&Me(h,t),l=Qe(h),k=Ze(h,d),a=z(h);return e.jsx("div",{className:"relative",children:e.jsxs(y,{variant:"ghost",size:"sm",className:o("h-12 w-full p-0 text-sm relative rounded transition-all duration-200",!k&&"text-gray-300",k&&!u&&!l&&!a&&"text-gray-700 hover:bg-gray-50",a&&!u&&"text-red-600 font-medium hover:bg-red-50",l&&!u&&"bg-gray-100 text-gray-900 font-medium border border-gray-200",u&&"bg-gray-900 text-white font-medium shadow-sm"),onClick:()=>s?.(h),children:[Fe(h,"d"),x.length>0&&e.jsxs("div",{className:"absolute bottom-1 left-1/2 transform -translate-x-1/2 flex space-x-0.5",children:[x.slice(0,3).map((g,m)=>{const b=$=>{if(u)return"bg-white/80";switch($){case"class":return"bg-blue-500";case"meeting":return"bg-green-500";case"appointment":return"bg-orange-500";case"deadline":return"bg-red-500";default:return"bg-gray-500"}};return e.jsx("div",{className:o("w-1 h-1 rounded-full",b(g.type))},m)}),x.length>3&&e.jsx("div",{className:o("w-1 h-1 rounded-full",u?"bg-white/60":"bg-gray-400")})]})]})},h.toISOString())})]})]}),t&&e.jsx("div",{className:"border-t border-gray-100",children:e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsx("h4",{className:"text-sm font-semibold text-gray-900",children:Qe(t)?"Today":ns(t)?"Tomorrow":Fe(t,"MMM d, yyyy")})}),(()=>{const h=r.filter(x=>Me(x.date,t));return e.jsxs("div",{className:"space-y-3",children:[h.length>0&&h.map(x=>{const l=(k=>{switch(k){case"class":return{bg:"bg-blue-50",border:"border-blue-100",dot:"bg-blue-500",text:"text-blue-900",subtext:"text-blue-600"};case"meeting":return{bg:"bg-green-50",border:"border-green-100",dot:"bg-green-500",text:"text-green-900",subtext:"text-green-600"};case"appointment":return{bg:"bg-orange-50",border:"border-orange-100",dot:"bg-orange-500",text:"text-orange-900",subtext:"text-orange-600"};case"deadline":return{bg:"bg-red-50",border:"border-red-100",dot:"bg-red-500",text:"text-red-900",subtext:"text-red-600"};default:return{bg:"bg-gray-50",border:"border-gray-100",dot:"bg-gray-500",text:"text-gray-900",subtext:"text-gray-600"}}})(x.type);return e.jsxs("div",{className:`flex items-center space-x-3 p-3 ${l.bg} rounded border ${l.border} hover:shadow-sm transition-shadow cursor-pointer`,children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${l.dot} flex-shrink-0`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`text-sm font-medium ${l.text} truncate`,children:x.title}),(x.time||x.location)&&e.jsxs("p",{className:`text-xs ${l.subtext} truncate`,children:[x.time,x.time&&x.location&&" • ",x.location]})]})]},x.id||x.title)}),h.length===0&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-12 h-12 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-3",children:e.jsx(M.Calendar,{className:"w-5 h-5 text-gray-400"})}),e.jsx("p",{className:"text-sm text-gray-500",children:"No events scheduled"})]})]})})()]})}),!Ze(d,new Date)&&e.jsx("div",{className:"p-6 pt-0",children:e.jsx(y,{variant:"outline",size:"sm",onClick:()=>{const h=new Date;T(h),s?.(h),A("calendar")},className:"w-full h-10 text-sm font-medium border-gray-200 hover:bg-gray-50 rounded",children:"Today"})})]})}const Ve=Ce.Root,We=Ce.Trigger,ls=Ce.Anchor,Ie=w.forwardRef(({className:t,align:s="center",sideOffset:r=4,...i},p)=>e.jsx(Ce.Portal,{children:e.jsx(Ce.Content,{ref:p,align:s,sideOffset:r,className:o("z-50 w-auto rounded-md border border-gray-200 bg-white p-3 text-gray-950 shadow-lg outline-none","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",t),...i})}));Ie.displayName=Ce.Content.displayName;function is({date:t,onDateChange:s,mode:r="single",dateRange:i,onDateRangeChange:p,placeholder:N="Pick a date",dateFormat:d="PPP",disabled:T=!1,className:H,variant:A="outline",size:B="default",align:v="start",showIcon:C=!0,icon:R,minDate:S,maxDate:E,disabledDates:W,isDateDisabled:Y,fullWidth:O=!1,customTrigger:V,numberOfMonths:f=1,holidays:P=[]}){const[q,L]=w.useState(!1),[z,h]=w.useState(t||new Date),[x,u]=w.useState("calendar"),[l,k]=w.useState(i?.from),[a,g]=w.useState(i?.to),[m,b]=w.useState();w.useEffect(()=>{k(i?.from),g(i?.to)},[i]),w.useEffect(()=>{q&&(u("calendar"),r==="single"&&t?h(t):r==="range"&&i?.from&&h(i.from))},[q,t,i,r]);const $=c=>{if(r==="range")if(!l||l&&a)k(c),g(void 0),p?.({from:c,to:void 0});else{const _=l<c?l:c,oe=l<c?c:l;k(_),g(oe),p?.({from:_,to:oe}),L(!1)}else s?.(c),L(!1)},X=c=>!!(W?.some(_=>_.toDateString()===c.toDateString())||S&&c<S||E&&c>E||Y?.(c)),te=c=>P.some(_=>K.isSameDay(_.date,c)),F=K.startOfMonth(z),G=K.endOfMonth(z),Z=K.eachDayOfInterval({start:F,end:G}),se=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],ae=K.addMonths(z,1),he=K.startOfMonth(ae),pe=K.endOfMonth(ae),me=K.eachDayOfInterval({start:he,end:pe}),de=()=>{h(K.subMonths(z,1))},xe=()=>{h(K.addMonths(z,1))},ie=(c,_)=>K.format(c,_),n=c=>{if(l&&a)return c>=l&&c<=a;if(l&&!a&&m){const _=l<m?l:m,oe=l<m?m:l;return c>=_&&c<=oe}return!1},j=c=>l&&K.isSameDay(c,l),J=c=>a&&K.isSameDay(c,a),D=()=>{const c=new Date(z);c.setFullYear(fe-1),h(c)},ce=()=>{const c=new Date(z);c.setFullYear(fe+1),h(c)},re=c=>{const _=new Date(z.getFullYear(),c,1);h(_),u("calendar")},ee=c=>{const _=new Date(c,z.getMonth(),1);h(_),u("calendar")},Pe=["January","February","March","April","May","June","July","August","September","October","November","December"],fe=z.getFullYear(),ze=Array.from({length:20},(c,_)=>fe-10+_),Ke=V||e.jsxs(y,{variant:A,size:B,className:o("justify-start text-left font-normal",!t&&!l&&"text-gray-500",O&&"w-full",H),disabled:T,children:[C&&(R||e.jsx(M.Calendar,{className:"mr-2 h-4 w-4"})),r==="range"?l&&a?e.jsxs("span",{children:[K.format(l,d)," - ",K.format(a,d)]}):l?e.jsxs("span",{children:[K.format(l,d)," - ..."]}):e.jsx("span",{children:N}):t?K.format(t,d):e.jsx("span",{children:N})]}),ye=(c,_)=>{const oe=r==="single"?t&&K.isSameDay(c,t):j(c)||J(c),yt=K.isToday(c),He=X(c),be=r==="range"&&n(c),bt=te(c),Xe=c.getDay(),vt=j(c),jt=J(c);return e.jsx("div",{className:o("relative p-0.5",be&&"bg-gray-100",be&&Xe===0&&"rounded-l-md",be&&Xe===6&&"rounded-r-md",be&&vt&&"rounded-l-md",be&&jt&&"rounded-r-md"),onMouseEnter:()=>r==="range"&&l&&!a&&b(c),onMouseLeave:()=>b(void 0),children:e.jsx(y,{variant:"ghost",size:"sm",disabled:He||T,className:o("h-10 w-full p-0 text-sm relative transition-all duration-200 rounded-md text-gray-900",!_&&"text-gray-300",bt&&!oe&&"text-red-600 font-medium",yt&&!oe&&!be&&"bg-gray-50 text-gray-900 font-medium border border-gray-200",oe&&"bg-gray-900 text-white font-medium shadow-sm z-10 hover:bg-gray-800",be&&!oe&&"text-gray-900 bg-gray-100",He&&"opacity-40 cursor-not-allowed"),onClick:()=>!He&&$(c),children:ie(c,"d")})},c.toISOString())};return e.jsxs(Ve,{open:q,onOpenChange:L,children:[e.jsx(We,{asChild:!0,children:Ke}),e.jsx(Ie,{className:o("p-0 border-gray-200",f===2?"w-[640px]":"w-80"),align:v,side:"bottom",sideOffset:4,collisionPadding:8,children:e.jsxs("div",{className:"bg-white rounded-lg","data-takaui":"datepicker",children:[e.jsx("div",{className:"border-b border-gray-100 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:de,className:"h-9 w-9 p-0",children:e.jsx(M.ChevronLeft,{className:"h-4 w-4"})}),f===2?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>u("months"),className:"h-9 px-3 font-semibold text-base",children:ie(z,"MMMM")}),e.jsx("span",{className:"text-gray-400 text-sm",children:"-"}),e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>u("months"),className:"h-9 px-3 font-semibold text-base",children:ie(ae,"MMMM yyyy")})]}):e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>u("months"),className:"h-9 px-4 font-semibold text-lg",children:ie(z,"MMMM yyyy")}),e.jsx(y,{variant:"outline",size:"sm",onClick:xe,className:"h-9 w-9 p-0",children:e.jsx(M.ChevronRight,{className:"h-4 w-4"})})]})}),e.jsxs("div",{className:"p-6",children:[x==="years"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>u("months"),className:"h-9 px-3 text-sm font-medium text-gray-600",children:"← Back"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Select Year"})]}),e.jsx("div",{className:"grid grid-cols-4 gap-2 max-h-64 overflow-y-auto",children:ze.map(c=>e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>ee(c),className:o("h-11 w-full text-sm font-medium rounded-md transition-all duration-200",c===fe?"bg-gray-900 text-white shadow-sm hover:bg-gray-800":"text-gray-900 bg-transparent"),children:c},c))})]}),x==="months"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>u("calendar"),className:"h-9 px-3 text-sm font-medium text-gray-600",children:"← Back"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(y,{variant:"outline",size:"sm",onClick:D,className:"h-9 w-9 p-0",children:e.jsx(M.ChevronLeft,{className:"h-4 w-4"})}),e.jsx(y,{variant:"ghost",onClick:()=>u("years"),className:"h-9 px-4 text-lg font-semibold text-gray-900",children:fe}),e.jsx(y,{variant:"outline",size:"sm",onClick:ce,className:"h-9 w-9 p-0",children:e.jsx(M.ChevronRight,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:Pe.map((c,_)=>e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>re(_),className:o("h-11 w-full text-sm font-medium rounded-md transition-all duration-200",_===z.getMonth()?"bg-gray-900 text-white shadow-sm hover:bg-gray-800":"text-gray-900 bg-transparent"),children:c},c))})]}),x==="calendar"&&e.jsxs("div",{className:o("flex",f===2?"gap-6":"gap-0"),children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:se.map((c,_)=>e.jsx("div",{className:"h-8 flex items-center justify-center",children:e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase",children:c})},_))}),e.jsxs("div",{className:"grid grid-cols-7",children:[Array.from({length:F.getDay()}).map((c,_)=>e.jsx("div",{className:"h-10"},`empty-${_}`)),Z.map(c=>ye(c,K.isSameMonth(c,z)))]})]}),f===2&&e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:se.map((c,_)=>e.jsx("div",{className:"h-8 flex items-center justify-center",children:e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase",children:c})},_))}),e.jsxs("div",{className:"grid grid-cols-7",children:[Array.from({length:he.getDay()}).map((c,_)=>e.jsx("div",{className:"h-10"},`next-empty-${_}`)),me.map(c=>ye(c,K.isSameMonth(c,ae)))]})]})]})]})]})})]})}const cs=({time:t,onTimeChange:s,timezone:r="UTC",format:i="24h",showTimezone:p=!1,minuteStep:N=1,showSeconds:d=!1,placeholder:T="Select time",variant:H="outline",size:A="default",showClockFace:B=!1})=>{const v=i==="24h",C=t?t.getHours():0,R=t?t.getMinutes():0,S=t?t.getSeconds():0,E=C>=12?"PM":"AM",[W,Y]=I.useState(C),[O,V]=I.useState(R),[f,P]=I.useState(S),[q,L]=I.useState(E),[z,h]=I.useState(""),[x,u]=I.useState(""),[l,k]=I.useState(""),a=I.useRef(null),g=I.useRef(null),m=I.useRef(null),b=I.useRef(null),$=I.useRef(null),X=I.useRef(null);I.useEffect(()=>{if(t){const n=t.getHours(),j=t.getMinutes(),J=t.getSeconds(),D=n>=12?"PM":"AM";n!==W&&Y(n),j!==O&&V(j),J!==f&&P(J),D!==q&&L(D)}},[t]),I.useEffect(()=>{b.current&&b.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"center",behavior:"smooth"}),$.current&&$.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"center",behavior:"smooth"}),X.current&&X.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"center",behavior:"smooth"})},[W,O,f,v]);const te=(n,j,J)=>{const D=new Date;D.setHours(n),D.setMinutes(j),D.setSeconds(J),s(D)},F=n=>{let j=n;v||(q==="PM"&&n!==12?j=n+12:q==="AM"&&n===12&&(j=0)),Y(j),te(j,O,f)},G=n=>{V(n),te(W,n,f)},Z=n=>{P(n),te(W,O,n)},se=n=>{if(q===n)return;L(n);const j=n==="PM"?W%12+12:W%12;Y(j),te(j,O,f)},ae=()=>{const n=new Date;Y(n.getHours()),V(n.getMinutes()),P(n.getSeconds()),L(n.getHours()>=12?"PM":"AM"),s(n)},he=()=>{if(!t)return T;const n=v?W:W%12||12,j=O.toString().padStart(2,"0"),J=f.toString().padStart(2,"0");let D=`${n.toString().padStart(2,"0")}:${j}`;return d&&(D+=`:${J}`),v||(D+=` ${q}`),p&&(D+=` ${r}`),D},pe=()=>{const n=v?23:12,j=v?0:1;return Array.from({length:n-j+1},(J,D)=>j+D)},me=()=>Array.from({length:Math.floor(60/N)},(n,j)=>j*N),de=()=>Array.from({length:60},(n,j)=>j),xe=v?W:W%12||12,ie=()=>{const ce=(xe%12*30+O*.5)*(Math.PI/180)-Math.PI/2,re=O*6*(Math.PI/180)-Math.PI/2,ee=100+50*Math.cos(ce),Pe=100+50*Math.sin(ce),fe=100+70*Math.cos(re),ze=100+70*Math.sin(re);return e.jsxs("svg",{width:200,height:200,className:"mx-auto",children:[e.jsx("circle",{cx:100,cy:100,r:95,fill:"white",stroke:"#e5e7eb",strokeWidth:"2"}),Array.from({length:12},(Ke,ye)=>{const c=ye*30*(Math.PI/180)-Math.PI/2,_=100+80*Math.cos(c),oe=100+80*Math.sin(c);return e.jsx("text",{x:_,y:oe,textAnchor:"middle",dominantBaseline:"middle",className:"text-sm fill-gray-600",children:ye===0?12:ye},ye)}),e.jsx("line",{x1:100,y1:100,x2:ee,y2:Pe,stroke:"#374151",strokeWidth:"6",strokeLinecap:"round"}),e.jsx("line",{x1:100,y1:100,x2:fe,y2:ze,stroke:"#ef4444",strokeWidth:"4",strokeLinecap:"round"}),e.jsx("circle",{cx:100,cy:100,r:"6",fill:"#ef4444"})]})};return e.jsxs(Ve,{children:[e.jsx(We,{asChild:!0,children:e.jsxs(y,{variant:H,size:A,className:o("justify-start text-left font-normal",!t&&"text-muted-foreground"),children:[e.jsx(M.Clock,{className:"mr-2 h-4 w-4"}),he()]})}),e.jsx(Ie,{className:"w-auto p-0",align:"start",children:e.jsxs("div",{className:"p-6 space-y-4 min-w-[460px]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-center gap-6",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{ref:a,type:"text",inputMode:"numeric",value:z!==""?z.padStart(2,"0"):xe.toString().padStart(2,"0"),onKeyDown:n=>{if(n.key>="0"&&n.key<="9"){n.preventDefault();const j=z+n.key;if(j.length===1)h(n.key);else if(j.length===2){const J=parseInt(j),D=v?23:12,ce=v?0:1;let re=J;J<ce&&(re=ce),J>D&&(re=D),h(""),F(re),setTimeout(()=>g.current?.focus(),0)}}else n.key==="Backspace"?(n.preventDefault(),z.length>0&&h(z.slice(0,-1))):n.key==="ArrowRight"||n.key==="Tab"?(n.key==="ArrowRight"&&n.preventDefault(),g.current?.focus()):n.key===":"&&(n.preventDefault(),g.current?.focus())},onBlur:()=>{if(z){const n=parseInt(z),j=v?23:12,J=v?0:1;let D=n;n<J&&(D=J),n>j&&(D=j),F(D)}h("")},onFocus:()=>{h("")},className:"text-6xl font-medium tabular-nums leading-none w-[85px] text-center bg-transparent outline-none focus:ring-2 focus:ring-primary rounded px-1 cursor-text",readOnly:!0}),e.jsx("div",{className:"text-6xl font-medium leading-none flex items-center px-1",children:":"}),e.jsx("input",{ref:g,type:"text",inputMode:"numeric",value:x!==""?x.padStart(2,"0"):O.toString().padStart(2,"0"),onKeyDown:n=>{if(n.key>="0"&&n.key<="9"){n.preventDefault();const j=x+n.key;if(j.length===1)u(n.key);else if(j.length===2){const J=parseInt(j),D=Math.min(59,Math.max(0,J));u(""),G(D),d&&setTimeout(()=>m.current?.focus(),0)}}else n.key==="Backspace"?(n.preventDefault(),x.length>0?u(x.slice(0,-1)):a.current?.focus()):n.key==="ArrowLeft"?(n.preventDefault(),a.current?.focus()):n.key==="ArrowRight"||n.key==="Tab"?(n.key==="ArrowRight"&&n.preventDefault(),d&&m.current?.focus()):n.key===":"&&(n.preventDefault(),d&&m.current?.focus())},onBlur:()=>{if(x){const n=parseInt(x),j=Math.min(59,Math.max(0,n));G(j)}u("")},onFocus:()=>{u("")},className:"text-6xl font-medium tabular-nums leading-none w-[85px] text-center bg-transparent outline-none focus:ring-2 focus:ring-primary rounded px-1 cursor-text",readOnly:!0}),d&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-6xl font-medium leading-none flex items-center px-1",children:":"}),e.jsx("input",{ref:m,type:"text",inputMode:"numeric",value:l!==""?l.padStart(2,"0"):f.toString().padStart(2,"0"),onKeyDown:n=>{if(n.key>="0"&&n.key<="9"){n.preventDefault();const j=l+n.key;if(j.length===1)k(n.key);else if(j.length===2){const J=parseInt(j),D=Math.min(59,Math.max(0,J));k(""),Z(D)}}else n.key==="Backspace"?(n.preventDefault(),l.length>0?k(l.slice(0,-1)):g.current?.focus()):n.key==="ArrowLeft"&&(n.preventDefault(),g.current?.focus())},onBlur:()=>{if(l){const n=parseInt(l),j=Math.min(59,Math.max(0,n));Z(j)}k("")},onFocus:()=>{k("")},className:"text-6xl font-medium tabular-nums leading-none w-[85px] text-center bg-transparent outline-none focus:ring-2 focus:ring-primary rounded px-1 cursor-text",readOnly:!0})]})]}),!v&&e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(y,{size:"sm",variant:q==="AM"?"default":"outline",onClick:()=>se("AM"),className:"h-8 w-12 text-xs font-medium",children:"AM"}),e.jsx(y,{size:"sm",variant:q==="PM"?"default":"outline",onClick:()=>se("PM"),className:"h-8 w-12 text-xs font-medium",children:"PM"})]})]}),p&&e.jsx("div",{className:"text-xs text-gray-500 text-center",children:r})]}),B?e.jsx("div",{className:"space-y-4",children:ie()}):e.jsxs("div",{className:"flex gap-2 justify-center items-start",children:[e.jsxs("div",{className:"flex-1 max-w-[80px]",children:[e.jsx("div",{className:"text-xs text-center text-gray-500 mb-2",children:"Hour"}),e.jsx("div",{ref:b,className:"h-40 overflow-y-scroll border rounded-md scrollbar-thin scrollbar-thumb-gray-300 scrollbar-track-gray-100",children:pe().map(n=>e.jsx("button",{"data-selected":xe===n,onClick:()=>F(n),className:o("w-full py-2 text-center transition-colors",xe===n?"bg-blue-500 text-white font-medium":"hover:bg-gray-100 text-gray-700"),children:n.toString().padStart(2,"0")},n))})]}),e.jsxs("div",{className:"flex-1 max-w-[80px]",children:[e.jsx("div",{className:"text-xs text-center text-gray-500 mb-2",children:"Min"}),e.jsx("div",{ref:$,className:"h-40 overflow-y-scroll border rounded-md scrollbar-thin scrollbar-thumb-gray-300 scrollbar-track-gray-100",children:me().map(n=>e.jsx("button",{"data-selected":O===n,onClick:()=>G(n),className:o("w-full py-2 text-center transition-colors",O===n?"bg-blue-500 text-white font-medium":"hover:bg-gray-100 text-gray-700"),children:n.toString().padStart(2,"0")},n))})]}),d&&e.jsxs("div",{className:"flex-1 max-w-[80px]",children:[e.jsx("div",{className:"text-xs text-center text-gray-500 mb-2",children:"Sec"}),e.jsx("div",{ref:X,className:"h-40 overflow-y-scroll border rounded-md scrollbar-thin scrollbar-thumb-gray-300 scrollbar-track-gray-100",children:de().map(n=>e.jsx("button",{"data-selected":f===n,onClick:()=>Z(n),className:o("w-full py-2 text-center transition-colors",f===n?"bg-blue-500 text-white font-medium":"hover:bg-gray-100 text-gray-700"),children:n.toString().padStart(2,"0")},n))})]})]}),e.jsxs("div",{className:"flex gap-2 justify-between pt-2 border-t",children:[e.jsx(y,{size:"sm",variant:"outline",onClick:ae,children:"Now"}),e.jsx(y,{size:"sm",onClick:()=>s(t),children:"Done"})]})]})})]})},Be=w.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:o("rounded-lg border border-gray-200 bg-white text-gray-950 shadow-sm",t),...s}));Be.displayName="Card";const qe=w.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:o("flex flex-col space-y-1.5 p-6",t),...s}));qe.displayName="CardHeader";const Je=w.forwardRef(({className:t,...s},r)=>e.jsx("h3",{ref:r,className:o("text-2xl font-semibold leading-none tracking-tight",t),...s}));Je.displayName="CardTitle";const ct=w.forwardRef(({className:t,...s},r)=>e.jsx("p",{ref:r,className:o("text-sm text-gray-500",t),...s}));ct.displayName="CardDescription";const Ue=w.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:o("p-6 pt-0",t),...s}));Ue.displayName="CardContent";const dt=w.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:o("flex items-center p-6 pt-0",t),...s}));dt.displayName="CardFooter";const ne=w.forwardRef(({className:t,...s},r)=>e.jsx(tt.Root,{ref:r,className:o("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...s}));ne.displayName=tt.Root.displayName;const ut=le.Root,ds=le.Portal,ht=w.forwardRef(({className:t,...s},r)=>e.jsx(le.Overlay,{ref:r,className:o("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s}));ht.displayName=le.Overlay.displayName;const mt=w.forwardRef(({className:t,children:s,...r},i)=>e.jsxs(ds,{children:[e.jsx(ht,{}),e.jsxs(le.Content,{ref:i,className:o("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-gray-200 bg-white p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",t),...r,children:[s,e.jsxs(le.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-gray-950 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-gray-100",children:[e.jsx(M.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));mt.displayName=le.Content.displayName;const xt=({className:t,...s})=>e.jsx("div",{className:o("flex flex-col space-y-1.5 text-center sm:text-left",t),...s});xt.displayName="ModalHeader";const gt=w.forwardRef(({className:t,...s},r)=>e.jsx(le.Title,{ref:r,className:o("text-lg font-semibold leading-none tracking-tight",t),...s}));gt.displayName=le.Title.displayName;const pt=w.forwardRef(({className:t,...s},r)=>e.jsx(le.Description,{ref:r,className:o("text-sm text-gray-500",t),...s}));pt.displayName=le.Description.displayName;function us({isOpen:t,onClose:s,title:r,description:i,children:p,className:N}){return e.jsx(ut,{open:t,onOpenChange:s,children:e.jsxs(mt,{className:N,children:[(r||i)&&e.jsxs(xt,{children:[r&&e.jsx(gt,{children:r}),i&&e.jsx(pt,{children:i})]}),p]})})}const Ae=["January","February","March","April","May","June","July","August","September","October","November","December"];function ft({onWeekChange:t,initialDate:s=new Date,className:r,compact:i=!1}){const[p,N]=w.useState(s),[d,T]=w.useState(!1),[H,A]=w.useState(!1),[B,v]=w.useState(!1),[C,R]=w.useState(s.getFullYear()),[S,E]=w.useState(s.getMonth()),[W,Y]=w.useState(0),O=w.useRef(null),V=w.useRef(null),f=u=>{const l=[],k=new Date(u),a=k.getDay(),g=a===0?-6:1-a;k.setDate(k.getDate()+g);for(let m=0;m<7;m++){const b=new Date(k);b.setDate(k.getDate()+m),l.push(b)}return l},P=(u,l)=>{const k=new Date(u,l,1),a=new Date(u,l+1,0),g=new Date(k);g.setDate(k.getDate()-(k.getDay()+6)%7);const m=[],b=new Date(g);for(;b<=a||b.getMonth()===l;){const $=new Date(b);if($.setDate(b.getDate()+6),m.push({start:new Date(b),end:new Date($)}),b.setDate(b.getDate()+7),m.length>6)break}return m},q=(u,l)=>{const k=u.toLocaleDateString("en-US",{month:"short"}),a=l.toLocaleDateString("en-US",{month:"short"});return k===a?`${k} ${u.getDate()}-${l.getDate()}`:`${k} ${u.getDate()}-${a} ${l.getDate()}`},L=f(p),z=Array.from({length:10},(u,l)=>C-5+l),h=u=>{const l=new Date(p);l.setDate(p.getDate()+(u==="next"?7:-7)),N(l),R(l.getFullYear()),E(l.getMonth()),t?.(l)},x=(u,l)=>{Y(l),T(!1),N(u.start),t?.(u.start)};return w.useEffect(()=>{const u=l=>{O.current&&!O.current.contains(l.target)&&V.current&&!V.current.contains(l.target)&&(T(!1),A(!1),v(!1))};return d&&document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u)}},[d]),w.useEffect(()=>{const l=P(C,S).findIndex(k=>p>=k.start&&p<=k.end);l!==-1&&Y(l)},[p,C,S]),e.jsxs("div",{className:o("flex items-center gap-3",r),children:[e.jsx(y,{variant:"outline",size:"sm",onClick:()=>h("prev"),className:o("rounded-lg border-gray-200 hover:border-gray-300 hover:bg-gray-50",i?"h-8 w-8 p-0":"h-9 w-9 p-0"),children:e.jsx(M.ChevronLeft,{className:o(i?"h-3 w-3":"h-4 w-4","text-gray-600")})}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{ref:V,className:o("flex items-center gap-2 bg-white rounded-lg border border-gray-200 shadow-sm cursor-pointer hover:bg-gray-50 transition-colors",i?"px-2 py-1":"px-3 py-2"),onClick:()=>T(!d),children:[e.jsx(M.Calendar,{className:o(i?"h-3 w-3":"h-4 w-4","text-gray-500")}),e.jsx("span",{className:o(i?"text-xs":"text-sm","font-medium text-gray-700"),children:L.length>=7&&L[0]&&L[6]&&`${L[0].getDate()}-${L[6].getDate()} ${Ae[L[0].getMonth()]} ${L[0].getFullYear()}`}),e.jsx(M.ChevronRight,{className:o(i?"h-2 w-2":"h-3 w-3","text-gray-400 transition-transform",d&&"rotate-90")})]}),d&&e.jsxs("div",{ref:O,className:"absolute top-full right-0 mt-2 bg-white border border-gray-200 rounded-lg shadow-lg p-4 z-50 w-80 sm:w-96",children:[!H&&!B&&e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>{const u=S===0?11:S-1,l=S===0?C-1:C;E(u),R(l)},className:"h-8 w-8 p-0",children:e.jsx(M.ChevronLeft,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{className:"text-lg font-semibold text-gray-800 hover:text-blue-600 transition-colors",onClick:()=>A(!H),children:Ae[S]}),e.jsx("button",{className:"text-lg font-semibold text-gray-800 hover:text-blue-600 transition-colors",onClick:()=>v(!B),children:C})]}),e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>{const u=S===11?0:S+1,l=S===11?C+1:C;E(u),R(l)},className:"h-8 w-8 p-0",children:e.jsx(M.ChevronRight,{className:"h-4 w-4"})})]}),H?e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>A(!1),className:"h-9 px-3 text-sm font-medium",children:"← Back"}),e.jsx("span",{className:"text-lg font-semibold",children:C})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:Ae.map((u,l)=>e.jsx("button",{className:o("h-11 w-full text-sm font-medium rounded-xl transition-all",S===l?"bg-blue-500 text-white":"text-gray-600 hover:bg-gray-50"),onClick:()=>{E(l),A(!1)},children:u},u))})]}):B?e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-start mb-4",children:e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>v(!1),className:"h-9 px-3 text-sm font-medium",children:"← Back"})}),e.jsx("div",{className:"grid grid-cols-4 gap-2 max-h-64 overflow-y-auto",children:z.map(u=>e.jsx("button",{className:o("h-11 w-full text-sm font-medium rounded-xl transition-all",C===u?"bg-blue-500 text-white":"text-gray-600 hover:bg-gray-50"),onClick:()=>{R(u),v(!1),A(!0)},children:u},u))})]}):e.jsx("div",{className:"grid grid-cols-2 gap-2 max-h-64 overflow-y-auto",children:P(C,S).map((u,l)=>{const k=new Date>=u.start&&new Date<=u.end,a=W===l;return e.jsx("button",{className:o("w-full p-3 text-left rounded-lg border transition-all",a?"bg-blue-500 text-white border-blue-500":k?"bg-white text-blue-600 border-blue-500":"bg-white border-gray-200 text-gray-700 hover:border-blue-300"),onClick:()=>x(u,l),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:o("font-medium text-sm",a?"text-white":"text-gray-800"),children:["Week ",l+1]}),e.jsx("div",{className:o("text-xs",a?"text-blue-100":"text-gray-500"),children:q(u.start,u.end)})]})},l)})}),e.jsx("div",{className:"flex gap-2 pt-3 border-t border-gray-100 mt-3",children:e.jsx(y,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>{const u=new Date;N(u),T(!1),A(!1),v(!1),t?.(u)},children:"This Week"})})]})]}),e.jsx(y,{variant:"outline",size:"sm",onClick:()=>h("next"),className:o("rounded-lg border-gray-200 hover:border-gray-300 hover:bg-gray-50",i?"h-8 w-8 p-0":"h-9 w-9 p-0"),children:e.jsx(M.ChevronRight,{className:o(i?"h-3 w-3":"h-4 w-4","text-gray-600")})})]})}const Oe={calculateWeekDates:t=>{const s=[],r=new Date(t),i=r.getDay(),p=i===0?-6:1-i;r.setDate(r.getDate()+p);for(let N=0;N<7;N++){const d=new Date(r);d.setDate(r.getDate()+N),s.push(d)}return s},formatDateDisplay:t=>t.toLocaleDateString("en-US",{month:"short",day:"numeric"}),getWeekNumber:t=>{const s=new Date(t.getFullYear(),0,1),r=(t.getTime()-s.getTime())/864e5;return Math.ceil((r+s.getDay()+1)/7)},getWeekOfMonth:t=>{const r=new Date(t.getFullYear(),t.getMonth(),1).getDay(),i=t.getDate()+r-1;return Math.ceil(i/7)}},hs=["08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00"],ms=["Monday","Tuesday","Wednesday","Thursday","Friday"],xs=[{name:"Blue",value:"bg-blue-500"},{name:"Green",value:"bg-emerald-500"},{name:"Purple",value:"bg-purple-500"},{name:"Orange",value:"bg-orange-500"},{name:"Pink",value:"bg-pink-500"}];function gs({title:t="Weekly Schedule",subtitle:s,events:r,onEventAdd:i,onEventUpdate:p,onEventDelete:N,className:d,timeSlots:T=hs,daysOfWeek:H=ms,showAddButton:A=!0,eventColors:B=xs,customFields:v=[],showWeekNavigation:C=!1,showHalfHourLines:R=!0,showCurrentTimeIndicator:S=!0,slotHeight:E=85}){const[W,Y]=I.useState(!1),[O,V]=I.useState(null),[f,P]=I.useState({title:"",day:"",startTime:"",endTime:"",color:"bg-blue-500",description:"",recurrenceType:"none",specificDate:"",scheduleMode:"day"}),[q,L]=I.useState(new Date),z=C?Oe.calculateWeekDates(q):[],h=(a,g,m)=>{if(m){V(m);const b={title:m.title,day:m.day,startTime:m.startTime,endTime:m.endTime,color:m.color,description:m.description||"",recurrenceType:m.recurrenceType||"none",specificDate:m.specificDate||"",scheduleMode:m.specificDate?"date":"day"};v.forEach($=>{const X=m[$.key];b[$.key]=X instanceof Date?X.toISOString():X||($.type==="number"?0:"")}),P(b)}else{V(null);const b={title:"",day:a||"",startTime:g||"",endTime:"",color:"bg-blue-500",description:"",recurrenceType:"none",specificDate:"",scheduleMode:"day"};v.forEach($=>{b[$.key]=$.type==="number"?0:""}),P(b)}Y(!0)},x=()=>{if(!f.title||!f.day||!f.startTime||!f.endTime)return;const a={...f,id:O?.id||Date.now().toString()};O?p?.(a):i?.(f),Y(!1)},u=()=>{O&&(N?.(O.id),Y(!1))},l=(a,g)=>r.filter(m=>{if(m.day!==a)return!1;const b=parseInt(m.startTime.replace(":","")),$=parseInt(g.replace(":",""));return b===$}),k=a=>{const[g,m]=a.startTime.split(":").map(Number),[b,$]=a.endTime.split(":").map(Number),X=g*60+m,G=(b*60+$-X)/60,Z=Math.max(4,E*.1);return G*E-Z};return e.jsxs(e.Fragment,{children:[e.jsxs(Be,{className:o("w-full",d),children:[e.jsx(qe,{className:"pb-6 bg-gradient-to-r from-slate-50 to-gray-50 border-b border-gray-100",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx(Je,{className:"text-2xl",children:t}),s&&e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:s})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[C&&e.jsx(ft,{onWeekChange:L,initialDate:q}),A&&e.jsxs(y,{onClick:()=>h(),className:"gap-2",children:[e.jsx(M.Plus,{className:"h-4 w-4"}),"Add Event"]})]})]})}),e.jsx(Ue,{className:"p-0",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("div",{className:"min-w-[800px]",children:[e.jsxs("div",{className:"grid border-b border-gray-200",style:{gridTemplateColumns:`80px repeat(${H.length}, 1fr)`},children:[e.jsx("div",{className:"p-3 bg-gray-50 border-r border-gray-200",children:e.jsx("span",{className:"text-xs font-medium text-gray-500",children:"Time"})}),H.map((a,g)=>{const m=new Date,b=C&&z[g],$=b&&b.getDate()===m.getDate()&&b.getMonth()===m.getMonth()&&b.getFullYear()===m.getFullYear();return e.jsxs("div",{className:"p-4 text-center border-r border-gray-200 last:border-r-0 bg-gray-50 hover:bg-white/50 transition-colors",children:[e.jsx("div",{className:`font-semibold text-sm ${$?"text-blue-600":"text-gray-800"}`,children:a}),C&&b&&e.jsx("div",{className:`text-xs mt-1 font-medium ${$?"text-blue-600 font-bold":"text-gray-500"}`,children:Oe.formatDateDisplay(b)})]},a)})]}),T.map(a=>{const g=new Date,m=g.getHours(),b=g.getMinutes(),[$,X]=a.split(":"),te=parseInt(X||"0"),G=parseInt($||"0")*60+te,Z=G+60,se=m*60+b,ae=se>=G&&se<Z,me=(se-G)/60*E;return e.jsxs("div",{className:"grid border-b border-gray-100 last:border-b-0",style:{gridTemplateColumns:`80px repeat(${H.length}, 1fr)`},children:[e.jsx("div",{className:"p-2 bg-gray-50/50 border-r border-gray-200",children:e.jsx("span",{className:"text-xs text-gray-600",children:a})}),H.map((de,xe)=>{const ie=l(de,a),n=new Date,j=C&&z[xe],J=j?j.getDate()===n.getDate()&&j.getMonth()===n.getMonth()&&j.getFullYear()===n.getFullYear():!1;return e.jsxs("div",{className:"relative border-r border-gray-200 last:border-r-0 hover:bg-blue-50/30 cursor-pointer transition-colors",style:{minHeight:`${E}px`},onClick:()=>!ie.length&&h(de,a),children:[R&&e.jsx("div",{className:"absolute top-1/2 left-0 right-0 h-px bg-gray-200/60 z-[5]"}),ie.map(D=>{const ce=k(D),re=ce<40;return e.jsx("div",{className:o("absolute rounded-md text-white cursor-pointer hover:scale-[1.02] transition-transform overflow-visible",D.color,re?"inset-x-1 py-0.5 px-1":"inset-1 p-2"),style:{height:`${ce}px`,zIndex:10,minHeight:re?"auto":void 0},onClick:ee=>{ee.stopPropagation(),h(void 0,void 0,D)},children:re?e.jsxs("div",{className:"flex items-center justify-between gap-1",children:[e.jsx("div",{className:"font-semibold truncate text-[10px] leading-tight flex-1",children:D.title}),e.jsxs("div",{className:"text-[9px] opacity-80 whitespace-nowrap",children:[D.startTime,"-",D.endTime]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs font-semibold truncate",children:D.title}),v.filter(ee=>ee.showInCard&&D[ee.key]).map(ee=>e.jsxs("div",{className:"text-xs opacity-90 flex items-center gap-1 mt-1",children:[ee.icon,e.jsx("span",{className:"truncate",children:D[ee.key]instanceof Date?D[ee.key].toLocaleString():String(D[ee.key]||"")})]},ee.key)),e.jsx("div",{className:"text-xs opacity-80 mt-1",children:e.jsxs("span",{children:[D.startTime,"-",D.endTime]})})]})},D.id)}),S&&J&&ae&&e.jsxs("div",{className:"absolute left-0 right-0 flex items-center z-20",style:{top:`${me-8}px`},children:[e.jsx("div",{className:"h-[3px] bg-red-500 absolute -left-14 right-0"}),e.jsxs("div",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded font-bold whitespace-nowrap relative z-30 -ml-14",children:[g.getHours(),":",g.getMinutes().toString().padStart(2,"0")]})]}),!ie.length&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 hover:opacity-100 transition-opacity",children:e.jsx(M.Plus,{className:"h-5 w-5 text-gray-400"})})]},`${de}-${a}`)})]},a)})]})})})]}),e.jsx(us,{isOpen:W,onClose:()=>Y(!1),title:O?"Edit Event":"Add New Event",children:e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{className:"text-sm font-medium",children:"Schedule Type"}),e.jsxs(Se,{value:String(f.scheduleMode),onValueChange:a=>P({...f,scheduleMode:a}),children:[e.jsx(ve,{children:e.jsx(De,{placeholder:"Select schedule type"})}),e.jsxs(je,{children:[e.jsx(ge,{value:"day",children:"By Day (Monday, Tuesday, etc.)"}),e.jsx(ge,{value:"date",children:"By Date (Specific date)"})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:f.scheduleMode==="day"?"Schedule by day of the week (e.g., every Monday)":"Schedule by specific date (e.g., January 15, 2025)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{htmlFor:"title",children:"Title *"}),e.jsx(ue,{id:"title",value:String(f.title),onChange:a=>P({...f,title:a.target.value}),placeholder:"Event title"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[f.scheduleMode==="day"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{children:"Day *"}),e.jsxs(Se,{value:String(f.day),onValueChange:a=>P({...f,day:a}),children:[e.jsx(ve,{children:e.jsx(De,{placeholder:"Select day"})}),e.jsx(je,{children:H.map(a=>e.jsx(ge,{value:a,children:a},a))})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{htmlFor:"specificDate",children:"Date *"}),e.jsx(ue,{id:"specificDate",type:"date",value:String(f.specificDate),onChange:a=>P({...f,specificDate:a.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{htmlFor:"startTime",children:"Start Time *"}),e.jsx(ue,{id:"startTime",type:"time",value:String(f.startTime),onChange:a=>P({...f,startTime:a.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{htmlFor:"endTime",children:"End Time *"}),e.jsx(ue,{id:"endTime",type:"time",value:String(f.endTime),onChange:a=>P({...f,endTime:a.target.value})})]})]}),v.length>0&&e.jsx("div",{className:"grid grid-cols-2 gap-4",children:v.map(a=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ne,{htmlFor:a.key,children:[a.label," ",a.required&&"*"]}),a.type==="select"?e.jsxs(Se,{value:String(f[a.key]||""),onValueChange:g=>P({...f,[a.key]:g}),children:[e.jsx(ve,{children:e.jsx(De,{placeholder:a.placeholder||`Select ${a.label}`})}),e.jsx(je,{children:a.options?.map(g=>e.jsx(ge,{value:g.value,children:g.label},g.value))})]}):e.jsx(ue,{id:a.key,type:a.type,value:a.type==="number"?Number(f[a.key]||0):String(f[a.key]||""),onChange:g=>P({...f,[a.key]:a.type==="number"?parseInt(g.target.value)||0:g.target.value}),placeholder:a.placeholder})]},a.key))}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"isRecurring",checked:f.recurrenceType!=="none",onChange:a=>{a.target.checked?P({...f,recurrenceType:f.scheduleMode==="day"?"weekly":"monthly"}):P({...f,recurrenceType:"none"})},className:"w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 focus:ring-2"}),e.jsx(ne,{htmlFor:"isRecurring",className:"text-sm font-medium text-gray-700 cursor-pointer",children:f.scheduleMode==="day"?"Repeat every week on this day":"Repeat every month on this date"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{children:"Color"}),e.jsxs(Se,{value:String(f.color),onValueChange:a=>P({...f,color:a}),children:[e.jsx(ve,{children:e.jsx(De,{})}),e.jsx(je,{children:B.map(a=>e.jsx(ge,{value:a.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:o("w-4 h-4 rounded",a.value)}),a.name]})},a.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{htmlFor:"description",children:"Description"}),e.jsx(ue,{id:"description",value:String(f.description||""),onChange:a=>P({...f,description:a.target.value}),placeholder:"Optional description"})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[O&&e.jsxs(y,{variant:"destructive",onClick:u,className:"gap-2",children:[e.jsx(M.Trash2,{className:"h-4 w-4"}),"Delete"]}),e.jsx("div",{className:"flex-1"}),e.jsx(y,{variant:"outline",onClick:()=>Y(!1),children:"Cancel"}),e.jsxs(y,{onClick:x,children:[O?"Update":"Add"," Event"]})]})]})})]})}const $e=[{label:"UTC",offset:0},{label:"EST",offset:-5},{label:"CST",offset:-6},{label:"MST",offset:-7},{label:"PST",offset:-8},{label:"GMT",offset:0},{label:"CET",offset:1},{label:"EET",offset:2},{label:"IST",offset:5.5},{label:"CST (China)",offset:8},{label:"JST",offset:9},{label:"AEST",offset:10},{label:"NZST",offset:12},{label:"HST",offset:-10},{label:"AKST",offset:-9},{label:"Asia/Bangkok",offset:7}],ps=(t,s,r)=>{const i=$e.find(d=>d.label===s)?.offset||0,p=$e.find(d=>d.label===r)?.offset||0,N=new Date(t);return N.setHours(N.getHours()+(p-i)),N},fs=(t,s,r="24h",i=!1)=>{const p=r==="12h"?t.getHours()%12||12:t.getHours(),N=t.getMinutes().toString().padStart(2,"0"),d=t.getSeconds().toString().padStart(2,"0"),T=t.getHours()>=12?"PM":"AM";let H=`${p.toString().padStart(2,"0")}:${N}`;return i&&(H+=`:${d}`),r==="12h"&&(H+=` ${T}`),H+=` ${s}`,H};exports.Button=y;exports.Calendar=os;exports.Card=Be;exports.CardContent=Ue;exports.CardDescription=ct;exports.CardFooter=dt;exports.CardHeader=qe;exports.CardTitle=Je;exports.Checkbox=Re;exports.DataGrid=Ut;exports.DataGridColumnHeader=Qt;exports.DataGridPagination=Zt;exports.DataGridTable=Kt;exports.DataGridTableRowSelect=ts;exports.DataGridTableRowSelectAll=es;exports.DataTable=Jt;exports.DatePicker=is;exports.DropdownMenu=zt;exports.DropdownMenuCheckboxItem=$t;exports.DropdownMenuContent=At;exports.DropdownMenuGroup=Et;exports.DropdownMenuItem=Ot;exports.DropdownMenuLabel=Lt;exports.DropdownMenuPortal=Ht;exports.DropdownMenuRadioGroup=Yt;exports.DropdownMenuRadioItem=_t;exports.DropdownMenuSeparator=Gt;exports.DropdownMenuShortcut=Vt;exports.DropdownMenuSub=Wt;exports.DropdownMenuSubContent=qt;exports.DropdownMenuSubTrigger=Bt;exports.DropdownMenuTrigger=Ft;exports.Input=ue;exports.Label=ne;exports.Modal=ut;exports.Popover=Ve;exports.PopoverAnchor=ls;exports.PopoverContent=Ie;exports.PopoverTrigger=We;exports.Schedule=gs;exports.Select=Se;exports.SelectContent=je;exports.SelectGroup=Xt;exports.SelectItem=ge;exports.SelectLabel=lt;exports.SelectSeparator=it;exports.SelectTrigger=ve;exports.SelectValue=De;exports.Separator=st;exports.TIMEZONES=$e;exports.Table=Ye;exports.TableBody=Le;exports.TableCaption=Pt;exports.TableCell=Te;exports.TableFooter=It;exports.TableHead=Ge;exports.TableHeader=_e;exports.TableRow=we;exports.TimePicker=cs;exports.WeekNavigator=ft;exports.cn=o;exports.convertTimezone=ps;exports.formatTimeWithTimezone=fs;exports.useDataGrid=ke;exports.weekNavigatorUtils=Oe;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const St=require("clsx"),Dt=require("tailwind-merge"),e=require("react/jsx-runtime"),R=require("react"),Mt=require("@radix-ui/react-slot"),Ct=require("@radix-ui/react-checkbox"),C=require("lucide-react"),kt=require("@radix-ui/react-dropdown-menu"),Tt=require("@radix-ui/react-select"),K=require("date-fns"),Rt=require("@radix-ui/react-popover"),It=require("@radix-ui/react-label"),zt=require("@radix-ui/react-dialog");function we(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(s,r,i.get?i:{enumerable:!0,get:()=>t[r]})}}return s.default=t,Object.freeze(s)}const w=we(R),Fe=we(Ct),Z=we(kt),U=we(Tt),Ce=we(Rt),tt=we(It),ce=we(zt);function o(...t){return Dt.twMerge(St.clsx(t))}const p=w.forwardRef(({className:t,variant:s="default",size:r="default",asChild:i=!1,...b},N)=>{const c=i?Mt.Slot:"button";return e.jsx(c,{className:o("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50",s==="default"&&"bg-blue-600 text-white hover:bg-blue-700 active:bg-blue-800 active:scale-95",s==="destructive"&&"bg-red-600 text-white hover:bg-red-700 active:bg-red-800 active:scale-95",s==="outline"&&"border border-gray-300 bg-white text-gray-900 hover:bg-gray-50 active:bg-gray-100 active:scale-95",s==="secondary"&&"bg-gray-200 text-gray-900 hover:bg-gray-300 active:bg-gray-400 active:scale-95",s==="ghost"&&"bg-transparent text-gray-900 hover:bg-gray-100 active:bg-gray-200 active:scale-95",s==="link"&&"bg-transparent text-blue-600 underline-offset-4 hover:text-blue-700 hover:underline active:text-blue-800",r==="default"&&"h-9 px-4 py-2",r==="sm"&&"h-8 px-3 text-xs gap-1.5",r==="lg"&&"h-10 px-6",r==="icon"&&"h-9 w-9 p-0",r==="icon-sm"&&"h-8 w-8 p-0",r==="icon-lg"&&"h-10 w-10 p-0",t),ref:N,...b})});p.displayName="Button";const Re=w.forwardRef(({className:t,...s},r)=>e.jsx(Fe.Root,{ref:r,className:o("peer h-4 w-4 shrink-0 rounded border border-gray-200 bg-white ring-offset-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-400 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-gray-900 data-[state=checked]:border-gray-900 data-[state=checked]:text-white transition-colors",t),...s,children:e.jsx(Fe.Indicator,{className:o("flex items-center justify-center text-current"),children:e.jsx(C.Check,{className:"h-3.5 w-3.5 stroke-[2.5]"})})}));Re.displayName=Fe.Root.displayName;const xe=w.forwardRef(({className:t,type:s,...r},i)=>e.jsx("input",{type:s,className:o("flex h-10 w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-400 focus:outline-none focus:border-gray-500 hover:border-gray-400 disabled:cursor-not-allowed disabled:opacity-50 transition-colors",t),ref:i,...r}));xe.displayName="Input";const st=w.forwardRef(({className:t,orientation:s="horizontal",decorative:r=!0,...i},b)=>e.jsx("div",{ref:b,role:r?"none":"separator","aria-orientation":s,className:o("shrink-0 bg-gray-200",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...i}));st.displayName="Separator";const at=w.createContext({variant:"default"});function Ye({className:t,variant:s="default",...r}){return e.jsx(at.Provider,{value:{variant:s},children:e.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:e.jsx("table",{"data-slot":"table",className:o("w-full caption-bottom text-sm",t),...r})})})}function Le({className:t,...s}){return e.jsx("thead",{"data-slot":"table-header",className:o("bg-gray-50 [&_tr]:border-b [&_tr]:border-gray-200",t),...s})}function _e({className:t,...s}){return e.jsx("tbody",{"data-slot":"table-body",className:o("[&_tr:last-child]:border-b-0",t),...s})}function Pt({className:t,...s}){return e.jsx("tfoot",{"data-slot":"table-footer",className:o("bg-muted/50 border-t font-medium [&>tr]:last:border-b-0",t),...s})}function Me({className:t,...s}){const{variant:r}=w.useContext(at);return e.jsx("tr",{"data-slot":"table-row",className:o("hover:bg-gray-50 data-[state=selected]:bg-gray-50 transition-colors border-b border-gray-200",r==="clean"&&"border-b-0",t),...s})}function Ge({className:t,...s}){return e.jsx("th",{"data-slot":"table-head",className:o("text-foreground h-auto px-3 py-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...s})}function Te({className:t,...s}){return e.jsx("td",{"data-slot":"table-cell",className:o("px-3 py-2 text-left align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...s})}function Ht({className:t,...s}){return e.jsx("caption",{"data-slot":"table-caption",className:o("text-muted-foreground mt-4 text-sm",t),...s})}function Et({...t}){return e.jsx(Z.Root,{"data-slot":"dropdown-menu",...t})}function At({...t}){return e.jsx(Z.Portal,{"data-slot":"dropdown-menu-portal",...t})}function Ft({...t}){return e.jsx(Z.Trigger,{"data-slot":"dropdown-menu-trigger",suppressHydrationWarning:!0,...t})}function Ot({className:t,sideOffset:s=4,...r}){return e.jsx(Z.Portal,{children:e.jsx(Z.Content,{"data-slot":"dropdown-menu-content",sideOffset:s,className:o("bg-white text-gray-900 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 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border border-gray-200 p-2 shadow-lg",t),...r})})}function $t({...t}){return e.jsx(Z.Group,{"data-slot":"dropdown-menu-group",...t})}function Yt({className:t,inset:s,variant:r="default",...i}){return e.jsx(Z.Item,{"data-slot":"dropdown-menu-item","data-inset":s,"data-variant":r,className:o("focus:bg-gray-100 focus:text-gray-900 data-[variant=destructive]:text-red-600 data-[variant=destructive]:focus:bg-red-50 data-[variant=destructive]:focus:text-red-700 [&_svg:not([class*='text-'])]:text-gray-500 relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none select-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...i})}function Lt({className:t,children:s,checked:r,...i}){return e.jsxs(Z.CheckboxItem,{"data-slot":"dropdown-menu-checkbox-item",className:o("focus:bg-gray-100 focus:text-gray-900 relative flex cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),checked:r,...i,children:[e.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:e.jsx(Z.ItemIndicator,{children:e.jsx(C.CheckIcon,{className:"size-4 text-blue-600"})})}),s]})}function _t({...t}){return e.jsx(Z.RadioGroup,{"data-slot":"dropdown-menu-radio-group",...t})}function Gt({className:t,children:s,...r}){return e.jsxs(Z.RadioItem,{"data-slot":"dropdown-menu-radio-item",className:o("focus:bg-gray-100 focus:text-gray-900 relative flex cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...r,children:[e.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:e.jsx(Z.ItemIndicator,{children:e.jsx(C.CircleIcon,{className:"size-2 fill-blue-600"})})}),s]})}function Wt({className:t,inset:s,...r}){return e.jsx(Z.Label,{"data-slot":"dropdown-menu-label","data-inset":s,className:o("px-2 py-1.5 text-sm font-semibold text-gray-900 data-[inset]:pl-8",t),...r})}function Bt({className:t,...s}){return e.jsx(Z.Separator,{"data-slot":"dropdown-menu-separator",className:o("bg-gray-100 my-1 h-px",t),...s})}function Vt({className:t,...s}){return e.jsx("span",{"data-slot":"dropdown-menu-shortcut",className:o("text-gray-500 ml-auto text-xs tracking-widest",t),...s})}function qt({...t}){return e.jsx(Z.Sub,{"data-slot":"dropdown-menu-sub",...t})}function Jt({className:t,inset:s,children:r,...i}){return e.jsxs(Z.SubTrigger,{"data-slot":"dropdown-menu-sub-trigger","data-inset":s,className:o("focus:bg-gray-100 focus:text-gray-900 data-[state=open]:bg-gray-100 data-[state=open]:text-gray-900 [&_svg:not([class*='text-'])]:text-gray-500 flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none select-none transition-colors data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...i,children:[r,e.jsx(C.ChevronRightIcon,{className:"ml-auto size-4"})]})}function Ut({className:t,...s}){return e.jsx(Z.SubContent,{"data-slot":"dropdown-menu-sub-content",className:o("bg-white text-gray-900 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 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border border-gray-200 p-2 shadow-lg",t),...s})}function Kt({data:t=[],columns:s,searchPlaceholder:r="Search...",onRowClick:i,className:b="",showPagination:N=!0,showSearch:c=!0,pageSize:I,pageSizeOptions:M=[5,10,20,50],renderToolbar:F,variant:W="default",onPaginationChange:z,onSearchChange:v,onSortChange:Y}){const k=I??M[0]??10,[S,L]=R.useState(1),[P,O]=R.useState(k),[J,f]=R.useState(""),[H,B]=R.useState(null),[_,E]=R.useState("asc"),m=R.useMemo(()=>{if(!c||!J.trim())return t;const a=J.toLowerCase();return t.filter(g=>s.some(h=>(h.accessor?h.accessor(g):g[h.key])?.toString().toLowerCase().includes(a)))},[t,J,c,s]),x=R.useMemo(()=>H?[...m].sort((a,g)=>{const h=s.find(te=>te.key===H);if(!h)return 0;const y=h.accessor?h.accessor(a):a[h.key],$=h.accessor?h.accessor(g):g[h.key];if(y===$)return 0;if(y==null)return 1;if($==null)return-1;const X=y<$?-1:1;return _==="asc"?X:-X}):m,[m,H,_,s]),d=R.useMemo(()=>{if(!N)return x;const a=(S-1)*P;return x.slice(a,a+P)},[x,S,P,N]);R.useEffect(()=>{if(z){const a=Math.ceil(x.length/P);z({page:S,limit:P,total:x.length,totalPages:a})}},[S,P,x.length]),R.useEffect(()=>{L(1),v&&v(J)},[J]);const l=a=>{let g="asc";H===a?(g=_==="asc"?"desc":"asc",E(g)):(B(a),E("asc")),Y&&Y(a,H===a?g:"asc")},T=(a,g,h)=>{const y=g.accessor?g.accessor(a):a[g.key];return g.cell?g.cell(y,a,h):y};return e.jsxs("div",{className:o("w-full space-y-4",b),children:[(c||F)&&e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[c&&e.jsxs("div",{className:"relative w-full sm:w-auto",children:[e.jsx(C.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),e.jsx(xe,{placeholder:r,value:J,onChange:a=>f(a.target.value),className:"pl-10 w-full sm:w-[300px] bg-gray-50 border-gray-300"})]}),F&&e.jsx("div",{className:"w-full sm:w-auto",children:F()})]}),e.jsx("div",{className:"border border-gray-200 rounded-lg overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Ye,{variant:W,children:[e.jsx(Le,{children:e.jsx(Me,{children:s.map(a=>e.jsx(Ge,{className:"h-10 px-0 py-0",style:{width:a.width},children:a.align==="center"||!a.align&&typeof a.header!="string"?e.jsx("div",{className:"h-10 flex items-center justify-center",children:typeof a.header!="string"?a.header:e.jsx("span",{className:o("text-xs font-normal text-gray-500 uppercase tracking-widest",a.headerClassName),children:a.header})}):e.jsx("div",{className:o("h-10 flex items-center text-xs font-normal text-gray-500 uppercase tracking-widest",a.headerClassName),children:typeof a.header!="string"?e.jsx("div",{children:a.header}):a.sortable!==!1?e.jsxs(p,{variant:"ghost",className:o("h-auto px-3 py-1.5 text-xs font-normal hover:bg-transparent hover:text-gray-900",a.headerClassName),onClick:()=>l(a.key),children:[a.header,H===a.key&&_==="desc"?e.jsx(C.ChevronDown,{className:"h-4 w-4"}):H===a.key&&_==="asc"?e.jsx(C.ChevronUp,{className:"h-4 w-4"}):e.jsx(C.ChevronsUpDown,{className:"h-4 w-4"})]}):e.jsx("span",{className:"px-3",children:a.header})})},a.key))})}),e.jsx(_e,{children:d.length===0?e.jsx(Me,{children:e.jsx(Te,{colSpan:s.length,className:"text-center py-8 text-gray-500",children:"No results found."})}):d.map((a,g)=>e.jsx(Me,{className:"hover:bg-gray-50 cursor-pointer",onClick:()=>i?.(a),children:s.map(h=>{const y=h.align==="center"||!h.align&&typeof h.header!="string";return e.jsx(Te,{className:y?"px-0 py-4":"px-3 py-4",style:{width:h.width},children:y?e.jsx("div",{className:"flex items-center justify-center h-full",children:T(a,h,g)}):T(a,h,g)},h.key)})},g))})]})})}),N&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 px-2 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-700",children:"Rows per page:"}),e.jsx("select",{value:P,onChange:a=>{const g=Number(a.target.value);O(g),L(1)},className:"border border-gray-300 rounded px-2 py-1 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500",children:M.map(a=>e.jsx("option",{value:a,children:a},a))})]}),e.jsxs("div",{className:"text-sm text-gray-600",children:["Showing ",d.length," of ",x.length," row(s)"]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm text-gray-700",children:["Page ",S," of ",Math.ceil(x.length/P)]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(p,{variant:"outline",size:"sm",onClick:()=>L(a=>Math.max(1,a-1)),disabled:S===1,className:"h-8 w-8 p-0",children:e.jsx(C.ChevronLeft,{className:"h-4 w-4"})}),e.jsx(p,{variant:"outline",size:"sm",onClick:()=>L(a=>Math.min(Math.ceil(x.length/P),a+1)),disabled:S===Math.ceil(x.length/P),className:"h-8 w-8 p-0",children:e.jsx(C.ChevronRight,{className:"h-4 w-4"})})]})]})]})]})}const rt=R.createContext(null);function ke(){const t=R.useContext(rt);if(!t)throw new Error("useDataGrid must be used within DataGrid");return t}function Xt({columns:t,data:s,getRowId:r=v=>v?.id||String(Math.random()),onRowClick:i,children:b,recordCount:N,currentPage:c,pageSize:I,onPaginationChange:M,loading:F=!1,emptyMessage:W="No data found",manualPagination:z=!1}){const[v,Y]=R.useState(0),[k,S]=R.useState(10),L=c!==void 0?c-1:v,P=I??k,[O,J]=R.useState([]),[f,H]=R.useState(new Set),B=R.useMemo(()=>O.length===0?s:[...s].sort((V,Q)=>{for(const fe of O){const he=t.find(n=>n.id===fe.id);if(!he?.accessorKey)continue;const ue=V[he.accessorKey],le=Q[he.accessorKey];if(ue===le)continue;const ae=ue<le?-1:1;return fe.desc?-ae:ae}return 0}),[s,O,t]),_=R.useMemo(()=>{if(z)return s;const A=L*P,V=A+P;return B.slice(A,V)},[z,s,B,L,P]),E=N??B.length,m=Math.ceil(E/P),x=m,d=(A,V)=>{const Q={page:A+1,limit:V,total:E,totalPages:Math.ceil(E/V)};M?.(Q)},l=L>0,T=L<m-1,a=()=>{const A=L-1;c===void 0&&Y(A),d(A,P)},g=()=>{const A=Math.min(L+1,x-1);c===void 0&&Y(A),d(A,P)},h=A=>{I===void 0&&S(A),c===void 0&&Y(0),d(0,A)},y=A=>{const V=Math.max(0,Math.min(A,x-1));c===void 0&&Y(V),d(V,P)},$={pageIndex:L,pageSize:P},X=A=>{const V=typeof A=="function"?A($):A;c===void 0&&Y(V.pageIndex),I===void 0&&S(V.pageSize),d(V.pageIndex,V.pageSize)},te=A=>{H(V=>{const Q=new Set(V);return Q.has(A)?Q.delete(A):Q.add(A),Q})},de=()=>{f.size===_.length?H(new Set):H(new Set(_.map(A=>r(A))))},se=_.length>0&&f.size===_.length,oe={columns:t,data:s,getRowId:r,onRowClick:i,pagination:$,setPagination:X,canPreviousPage:l,canNextPage:T,previousPage:a,nextPage:g,setPageSize:h,goToPage:y,pageCount:x,sorting:O,setSorting:J,selectedRows:f,toggleRow:te,toggleAllRows:de,isAllRowsSelected:se,paginatedData:_,sortedData:B,totalPages:m,recordCount:E,loading:F,emptyMessage:W,manualPagination:z};return e.jsx(rt.Provider,{value:oe,children:b})}function nt(){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"4rem 1.5rem",minHeight:"300px",background:"rgba(255, 255, 255, 0.8)",color:"#6b7280"},children:[e.jsx("div",{style:{width:"2.5rem",height:"2.5rem",border:"3px solid rgba(59, 130, 246, 0.1)",borderTopColor:"#3b82f6",borderRadius:"50%",animation:"spin 0.8s linear infinite",marginBottom:"1rem"}}),e.jsx("span",{style:{fontSize:"0.875rem",fontWeight:500,color:"#374151"},children:"Loading data..."}),e.jsx("style",{children:`
2
+ @keyframes spin {
3
+ to { transform: rotate(360deg); }
4
+ }
5
+ `})]})}function ot({message:t}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"4rem 1.5rem",minHeight:"300px",color:"#6b7280"},children:[e.jsx("div",{style:{fontSize:"3.5rem",marginBottom:"1.25rem",opacity:.3,filter:"grayscale(100%)"},children:"📊"}),e.jsx("div",{style:{fontSize:"1rem",textAlign:"center",color:"#9ca3af",fontWeight:500},children:t})]})}function Zt(){const{columns:t,paginatedData:s,getRowId:r,onRowClick:i,loading:b,emptyMessage:N}=ke();return b&&s.length===0?e.jsx(nt,{}):!b&&s.length===0?e.jsx("div",{className:"border border-gray-200 rounded-lg overflow-hidden",children:e.jsx(ot,{message:N})}):e.jsx("div",{className:"border border-gray-200 rounded-lg overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Ye,{children:[e.jsx(Le,{children:e.jsx(Me,{children:t.map(c=>e.jsx(Ge,{className:"h-10 px-0 py-0",style:{width:c.size?`${c.size}px`:void 0},children:c.align==="center"?e.jsx("div",{className:"h-10 flex items-center justify-center",children:typeof c.header!="string"?c.header:e.jsx("span",{className:"text-xs font-normal text-gray-500 uppercase tracking-widest",children:c.header})}):e.jsx("div",{className:"h-10 flex items-center text-xs font-normal text-gray-500 uppercase tracking-widest",children:typeof c.header!="string"?e.jsx("div",{children:c.header}):e.jsx("span",{className:"px-3",children:c.header})})},c.id))})}),e.jsx(_e,{children:s.map((c,I)=>e.jsx(Me,{className:"hover:bg-gray-50 cursor-pointer",onClick:()=>i?.(c),children:t.map(M=>{const F=M.align==="center",W=M.cell?M.cell(c,I):M.accessorKey?c[M.accessorKey]:null;return e.jsx(Te,{className:F?"px-0 py-4":"px-3 py-4",style:{width:M.size?`${M.size}px`:void 0},children:F?e.jsx("div",{className:"flex items-center justify-center h-full",children:W}):W},M.id)})},r(c)))})]})})})}const Ne=U.Root,Qt=U.Group,Se=U.Value,ve=w.forwardRef(({className:t,children:s,...r},i)=>e.jsxs(U.Trigger,{ref:i,className:o("flex h-10 w-full items-center justify-between rounded-md border border-gray-300 bg-white px-3 py-2 text-sm ring-offset-white placeholder:text-gray-400 focus:outline-none focus:border-gray-500 hover:border-gray-400 disabled:cursor-not-allowed disabled:opacity-50 transition-colors",t),...r,children:[s,e.jsx(U.Icon,{asChild:!0,children:e.jsx(C.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));ve.displayName=U.Trigger.displayName;const lt=w.forwardRef(({className:t,...s},r)=>e.jsx(U.ScrollUpButton,{ref:r,className:o("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(C.ChevronUp,{className:"h-4 w-4"})}));lt.displayName=U.ScrollUpButton.displayName;const it=w.forwardRef(({className:t,...s},r)=>e.jsx(U.ScrollDownButton,{ref:r,className:o("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(C.ChevronDown,{className:"h-4 w-4"})}));it.displayName=U.ScrollDownButton.displayName;const je=w.forwardRef(({className:t,children:s,position:r="popper",...i},b)=>e.jsx(U.Portal,{children:e.jsxs(U.Content,{ref:b,className:o("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-gray-200 bg-white text-gray-950 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",r==="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",t),position:r,...i,children:[e.jsx(lt,{}),e.jsx(U.Viewport,{className:o("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(it,{})]})}));je.displayName=U.Content.displayName;const ct=w.forwardRef(({className:t,...s},r)=>e.jsx(U.Label,{ref:r,className:o("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));ct.displayName=U.Label.displayName;const ge=w.forwardRef(({className:t,children:s,...r},i)=>e.jsxs(U.Item,{ref:i,className:o("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-gray-100 focus:text-gray-900 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...r,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(U.ItemIndicator,{children:e.jsx(C.Check,{className:"h-4 w-4"})})}),e.jsx(U.ItemText,{children:s})]}));ge.displayName=U.Item.displayName;const dt=w.forwardRef(({className:t,...s},r)=>e.jsx(U.Separator,{ref:r,className:o("-mx-1 my-1 h-px bg-gray-100",t),...s}));dt.displayName=U.Separator.displayName;function es({mode:t="simple",pageSizeOptions:s=[5,10,15,20]}){const{canPreviousPage:r,canNextPage:i,previousPage:b,nextPage:N,pageCount:c,pagination:I,setPageSize:M,goToPage:F,loading:W}=ke();R.useEffect(()=>{s.includes(I.pageSize)||M(s[0])},[]);const z=()=>{const v=I.pageIndex,Y=c,k=[];if(Y<=7)for(let S=0;S<Y;S++)k.push(S);else if(v<=3){for(let S=0;S<=4;S++)k.push(S);k.push("..."),k.push(Y-1)}else if(v>=Y-4){k.push(0),k.push("...");for(let S=Y-5;S<Y;S++)k.push(S)}else k.push(0),k.push("..."),k.push(v-1),k.push(v),k.push(v+1),k.push("..."),k.push(Y-1);return k};return t==="simple"?e.jsx("div",{className:"flex items-center justify-end px-2 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm text-gray-700 hidden sm:block",children:["Page ",I.pageIndex+1," of ",c]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(p,{variant:"outline",size:"sm",onClick:b,disabled:!r||W,className:"h-8 w-8 p-0",children:e.jsx(C.ChevronLeft,{className:"h-4 w-4"})}),e.jsx(p,{variant:"outline",size:"sm",onClick:N,disabled:!i||W,className:"h-8 w-8 p-0",children:e.jsx(C.ChevronRight,{className:"h-4 w-4"})})]})]})}):e.jsxs("div",{className:"flex items-center justify-between gap-3 px-2 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-600 hidden sm:inline",children:"Rows per page:"}),e.jsxs(Ne,{value:String(I.pageSize),onValueChange:v=>M(Number(v)),children:[e.jsx(ve,{className:"h-8 w-16",children:e.jsx(Se,{})}),e.jsx(je,{children:s.map(v=>e.jsx(ge,{value:String(v),children:v},v))})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"outline",size:"sm",onClick:b,disabled:!r||W,className:"h-8 w-8 p-0",children:e.jsx(C.ChevronLeft,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-sm text-gray-700 sm:hidden px-2",children:[I.pageIndex+1," / ",c]}),e.jsx("div",{className:"hidden sm:flex gap-1",children:z().map((v,Y)=>typeof v=="number"?e.jsx(p,{variant:I.pageIndex===v?"default":"outline",size:"sm",onClick:()=>F(v),disabled:W,className:"h-8 w-8 p-0",children:v+1},Y):e.jsx("span",{className:"flex h-8 w-8 items-center justify-center text-gray-400",children:v},Y))}),e.jsx(p,{variant:"outline",size:"sm",onClick:N,disabled:!i||W,className:"h-8 w-8 p-0",children:e.jsx(C.ChevronRight,{className:"h-4 w-4"})})]})]})}function ts({id:t,title:s}){const{sorting:r,setSorting:i}=ke(),b=r.find(M=>M.id===t),N=!!b,c=b?.desc??!1,I=()=>{i(M=>{const F=M.find(W=>W.id===t);return F?F.desc?[]:[{id:t,desc:!0}]:[{id:t,desc:!1}]})};return e.jsxs(p,{variant:"ghost",className:"h-auto px-3 py-1.5 font-normal hover:bg-transparent hover:text-gray-900",onClick:I,children:[s,N&&c?e.jsx(C.ChevronDown,{className:"h-4 w-4"}):N?e.jsx(C.ChevronUp,{className:"h-4 w-4"}):e.jsx(C.ChevronsUpDown,{className:"h-4 w-4"})]})}function ss(){const{toggleAllRows:t,isAllRowsSelected:s}=ke();return e.jsx(Re,{checked:s,onCheckedChange:t})}function as({row:t}){const{selectedRows:s,toggleRow:r,getRowId:i}=ke(),b=i(t);return e.jsx(Re,{checked:s.has(b),onCheckedChange:()=>r(b)})}const rs=t=>new Date(t.getFullYear(),t.getMonth(),1),ns=t=>new Date(t.getFullYear(),t.getMonth()+1,0),os=(t,s)=>{const r=[],i=new Date(t);for(;i<=s;)r.push(new Date(i)),i.setDate(i.getDate()+1);return r},Ze=(t,s)=>t.getMonth()===s.getMonth()&&t.getFullYear()===s.getFullYear(),De=(t,s)=>t.getDate()===s.getDate()&&t.getMonth()===s.getMonth()&&t.getFullYear()===s.getFullYear(),Qe=t=>De(t,new Date),ls=t=>{const s=new Date;return s.setDate(s.getDate()+1),De(t,s)},et=(t,s)=>{const r=new Date(t);return r.setMonth(r.getMonth()+s),r},Ee=(t,s)=>{const r=["January","February","March","April","May","June","July","August","September","October","November","December"],i=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return s==="MMMM yyyy"?`${r[t.getMonth()]} ${t.getFullYear()}`:s==="MMM d, yyyy"?`${i[t.getMonth()]} ${t.getDate()}, ${t.getFullYear()}`:s==="d"?t.getDate().toString():t.toLocaleDateString()};function is({selected:t,onSelect:s,events:r=[],holidays:i=[],className:b,...N}){const[c,I]=w.useState(new Date),[M,F]=w.useState("calendar"),W=rs(c),z=ns(c),v=os(W,z),Y=["January","February","March","April","May","June","July","August","September","October","November","December"],k=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],S=c.getFullYear(),L=Array.from({length:20},(m,x)=>S-10+x),P=()=>{I(et(c,-1))},O=()=>{I(et(c,1))},J=()=>{const m=new Date(c);m.setFullYear(S-1),I(m)},f=()=>{const m=new Date(c);m.setFullYear(S+1),I(m)},H=m=>{const x=new Date(c);x.setMonth(m),I(x),F("calendar")},B=m=>{const x=new Date(c);x.setFullYear(m),I(x),F("calendar")},_=m=>r.filter(x=>De(x.date,m)),E=m=>i.some(x=>De(x.date,m));return M==="months"?e.jsxs("div",{className:o("bg-white rounded-lg border border-gray-200 w-full",b),...N,children:[e.jsx("div",{className:"px-6 py-4 border-b border-gray-100",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>F("calendar"),className:"h-9 px-3 text-sm font-medium text-gray-600 hover:text-gray-900 hover:bg-gray-50 rounded",children:"← Back"}),e.jsxs("div",{className:"flex items-center space-x-1",children:[e.jsx(p,{variant:"outline",size:"sm",onClick:J,className:"h-9 w-9 p-0 border-gray-200 rounded",children:e.jsx(C.ChevronLeft,{className:"h-4 w-4"})}),e.jsx(p,{variant:"ghost",onClick:()=>F("years"),className:"h-9 px-4 text-lg font-semibold text-gray-900 hover:bg-gray-50 rounded",children:S}),e.jsx(p,{variant:"outline",size:"sm",onClick:f,className:"h-9 w-9 p-0 border-gray-200 rounded",children:e.jsx(C.ChevronRight,{className:"h-4 w-4"})})]})]})}),e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"grid grid-cols-3 gap-2",children:Y.map((m,x)=>e.jsx(p,{variant:"ghost",onClick:()=>H(x),className:o("h-11 w-full text-sm font-medium rounded transition-all duration-200",x===c.getMonth()?"bg-gray-900 text-white hover:bg-gray-800 shadow-sm":"text-gray-600 hover:text-gray-900 hover:bg-gray-50"),children:m},m))})})]}):M==="years"?e.jsxs("div",{className:o("bg-white rounded-lg border border-gray-200 w-full",b),...N,children:[e.jsx("div",{className:"px-6 py-4 border-b border-gray-100",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>F("months"),className:"h-9 px-3 text-sm font-medium text-gray-600 hover:text-gray-900 hover:bg-gray-50 rounded",children:"← Back"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Select Year"})]})}),e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"grid grid-cols-4 gap-2 max-h-64 overflow-y-auto",children:L.map(m=>e.jsx(p,{variant:"ghost",onClick:()=>B(m),className:o("h-11 w-full text-sm font-medium rounded transition-all duration-200",m===S?"bg-gray-900 text-white hover:bg-gray-800 shadow-sm":"text-gray-600 hover:text-gray-900 hover:bg-gray-50"),children:m},m))})})]}):e.jsxs("div",{className:o("bg-white rounded-lg border border-gray-200 w-full",b),...N,children:[e.jsx("div",{className:"px-6 py-4 border-b border-gray-100",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(p,{variant:"outline",size:"sm",onClick:P,className:"h-9 w-9 p-0 border-gray-200 rounded",children:e.jsx(C.ChevronLeft,{className:"h-4 w-4"})}),e.jsx(p,{variant:"ghost",onClick:()=>F("months"),className:"h-9 px-4 text-lg font-semibold text-gray-900 hover:bg-gray-50 rounded",children:Ee(c,"MMMM yyyy")}),e.jsx(p,{variant:"outline",size:"sm",onClick:O,className:"h-9 w-9 p-0 border-gray-200 rounded",children:e.jsx(C.ChevronRight,{className:"h-4 w-4"})})]})}),e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:k.map((m,x)=>e.jsx("div",{className:"h-10 flex items-center justify-center",children:e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase",children:m})},x))}),e.jsxs("div",{className:"grid grid-cols-7 gap-1",children:[Array.from({length:W.getDay()}).map((m,x)=>e.jsx("div",{className:"h-12"},`empty-${x}`)),v.map(m=>{const x=_(m),d=t&&De(m,t),l=Qe(m),T=Ze(m,c),a=E(m);return e.jsx("div",{className:"relative",children:e.jsxs(p,{variant:"ghost",size:"sm",className:o("h-12 w-full p-0 text-sm relative rounded transition-all duration-200",!T&&"text-gray-300",T&&!d&&!l&&!a&&"text-gray-700 hover:bg-gray-50",a&&!d&&"text-red-600 font-medium hover:bg-red-50",l&&!d&&"bg-gray-100 text-gray-900 font-medium border border-gray-200",d&&"bg-gray-900 text-white font-medium shadow-sm"),onClick:()=>s?.(m),children:[Ee(m,"d"),x.length>0&&e.jsxs("div",{className:"absolute bottom-1 left-1/2 transform -translate-x-1/2 flex space-x-0.5",children:[x.slice(0,3).map((g,h)=>{const y=$=>{if(d)return"bg-white/80";switch($){case"class":return"bg-blue-500";case"meeting":return"bg-green-500";case"appointment":return"bg-orange-500";case"deadline":return"bg-red-500";default:return"bg-gray-500"}};return e.jsx("div",{className:o("w-1 h-1 rounded-full",y(g.type))},h)}),x.length>3&&e.jsx("div",{className:o("w-1 h-1 rounded-full",d?"bg-white/60":"bg-gray-400")})]})]})},m.toISOString())})]})]}),t&&e.jsx("div",{className:"border-t border-gray-100",children:e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsx("h4",{className:"text-sm font-semibold text-gray-900",children:Qe(t)?"Today":ls(t)?"Tomorrow":Ee(t,"MMM d, yyyy")})}),(()=>{const m=r.filter(x=>De(x.date,t));return e.jsxs("div",{className:"space-y-3",children:[m.length>0&&m.map(x=>{const l=(T=>{switch(T){case"class":return{bg:"bg-blue-50",border:"border-blue-100",dot:"bg-blue-500",text:"text-blue-900",subtext:"text-blue-600"};case"meeting":return{bg:"bg-green-50",border:"border-green-100",dot:"bg-green-500",text:"text-green-900",subtext:"text-green-600"};case"appointment":return{bg:"bg-orange-50",border:"border-orange-100",dot:"bg-orange-500",text:"text-orange-900",subtext:"text-orange-600"};case"deadline":return{bg:"bg-red-50",border:"border-red-100",dot:"bg-red-500",text:"text-red-900",subtext:"text-red-600"};default:return{bg:"bg-gray-50",border:"border-gray-100",dot:"bg-gray-500",text:"text-gray-900",subtext:"text-gray-600"}}})(x.type);return e.jsxs("div",{className:`flex items-center space-x-3 p-3 ${l.bg} rounded border ${l.border} hover:shadow-sm transition-shadow cursor-pointer`,children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${l.dot} flex-shrink-0`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`text-sm font-medium ${l.text} truncate`,children:x.title}),(x.time||x.location)&&e.jsxs("p",{className:`text-xs ${l.subtext} truncate`,children:[x.time,x.time&&x.location&&" • ",x.location]})]})]},x.id||x.title)}),m.length===0&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-12 h-12 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-3",children:e.jsx(C.Calendar,{className:"w-5 h-5 text-gray-400"})}),e.jsx("p",{className:"text-sm text-gray-500",children:"No events scheduled"})]})]})})()]})}),!Ze(c,new Date)&&e.jsx("div",{className:"p-6 pt-0",children:e.jsx(p,{variant:"outline",size:"sm",onClick:()=>{const m=new Date;I(m),s?.(m),F("calendar")},className:"w-full h-10 text-sm font-medium border-gray-200 hover:bg-gray-50 rounded",children:"Today"})})]})}const We=Ce.Root,Be=Ce.Trigger,cs=Ce.Anchor,Ie=w.forwardRef(({className:t,align:s="center",sideOffset:r=4,...i},b)=>e.jsx(Ce.Portal,{children:e.jsx(Ce.Content,{ref:b,align:s,sideOffset:r,className:o("z-50 w-auto rounded-md border border-gray-200 bg-white p-3 text-gray-950 shadow-lg outline-none","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",t),...i})}));Ie.displayName=Ce.Content.displayName;function ds({date:t,onDateChange:s,mode:r="single",dateRange:i,onDateRangeChange:b,placeholder:N="Pick a date",dateFormat:c="PPP",disabled:I=!1,className:M,variant:F="outline",size:W="default",align:z="start",showIcon:v=!0,icon:Y,minDate:k,maxDate:S,disabledDates:L,isDateDisabled:P,fullWidth:O=!1,customTrigger:J,numberOfMonths:f=1,holidays:H=[]}){const[B,_]=w.useState(!1),[E,m]=w.useState(t||new Date),[x,d]=w.useState("calendar"),[l,T]=w.useState(i?.from),[a,g]=w.useState(i?.to),[h,y]=w.useState();w.useEffect(()=>{T(i?.from),g(i?.to)},[i]),w.useEffect(()=>{B&&(d("calendar"),r==="single"&&t?m(t):r==="range"&&i?.from&&m(i.from))},[B,t,i,r]);const $=u=>{if(r==="range")if(!l||l&&a)T(u),g(void 0),b?.({from:u,to:void 0});else{const G=l<u?l:u,ie=l<u?u:l;T(G),g(ie),b?.({from:G,to:ie}),_(!1)}else s?.(u),_(!1)},X=u=>!!(L?.some(G=>G.toDateString()===u.toDateString())||k&&u<k||S&&u>S||P?.(u)),te=u=>H.some(G=>K.isSameDay(G.date,u)),de=K.startOfMonth(E),se=K.endOfMonth(E),oe=K.eachDayOfInterval({start:de,end:se}),A=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],V=K.addMonths(E,1),Q=K.startOfMonth(V),fe=K.endOfMonth(V),he=K.eachDayOfInterval({start:Q,end:fe}),ue=()=>{m(K.subMonths(E,1))},le=()=>{m(K.addMonths(E,1))},ae=(u,G)=>K.format(u,G),n=u=>{if(l&&a)return u>=l&&u<=a;if(l&&!a&&h){const G=l<h?l:h,ie=l<h?h:l;return u>=G&&u<=ie}return!1},j=u=>l&&K.isSameDay(u,l),q=u=>a&&K.isSameDay(u,a),D=()=>{const u=new Date(E);u.setFullYear(pe-1),m(u)},me=()=>{const u=new Date(E);u.setFullYear(pe+1),m(u)},re=u=>{const G=new Date(E.getFullYear(),u,1);m(G),d("calendar")},ee=u=>{const G=new Date(u,E.getMonth(),1);m(G),d("calendar")},ze=["January","February","March","April","May","June","July","August","September","October","November","December"],pe=E.getFullYear(),Pe=Array.from({length:20},(u,G)=>pe-10+G),Ke=J||e.jsxs(p,{variant:F,size:W,className:o("justify-start text-left font-normal",!t&&!l&&"text-gray-500",O&&"w-full",M),disabled:I,children:[v&&(Y||e.jsx(C.Calendar,{className:"mr-2 h-4 w-4"})),r==="range"?l&&a?e.jsxs("span",{children:[K.format(l,c)," - ",K.format(a,c)]}):l?e.jsxs("span",{children:[K.format(l,c)," - ..."]}):e.jsx("span",{children:N}):t?K.format(t,c):e.jsx("span",{children:N})]}),ye=(u,G)=>{const ie=r==="single"?t&&K.isSameDay(u,t):j(u)||q(u),vt=K.isToday(u),He=X(u),be=r==="range"&&n(u),jt=te(u),Xe=u.getDay(),wt=j(u),Nt=q(u);return e.jsx("div",{className:o("relative p-0.5",be&&"bg-gray-100",be&&Xe===0&&"rounded-l-md",be&&Xe===6&&"rounded-r-md",be&&wt&&"rounded-l-md",be&&Nt&&"rounded-r-md"),onMouseEnter:()=>r==="range"&&l&&!a&&y(u),onMouseLeave:()=>y(void 0),children:e.jsx(p,{variant:"ghost",size:"sm",disabled:He||I,className:o("h-10 w-full p-0 text-sm relative transition-all duration-200 rounded-md text-gray-900",!G&&"text-gray-300",jt&&!ie&&"text-red-600 font-medium",vt&&!ie&&!be&&"bg-gray-50 text-gray-900 font-medium border border-gray-200",ie&&"bg-gray-900 text-white font-medium shadow-sm z-10 hover:bg-gray-800",be&&!ie&&"text-gray-900 bg-gray-100",He&&"opacity-40 cursor-not-allowed"),onClick:()=>!He&&$(u),children:ae(u,"d")})},u.toISOString())};return e.jsxs(We,{open:B,onOpenChange:_,children:[e.jsx(Be,{asChild:!0,children:Ke}),e.jsx(Ie,{className:o("p-0 border-gray-200",f===2?"w-[640px]":"w-80"),align:z,side:"bottom",sideOffset:4,collisionPadding:8,children:e.jsxs("div",{className:"bg-white rounded-lg","data-takaui":"datepicker",children:[e.jsx("div",{className:"border-b border-gray-100 px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(p,{variant:"outline",size:"sm",onClick:ue,className:"h-9 w-9 p-0",children:e.jsx(C.ChevronLeft,{className:"h-4 w-4"})}),f===2?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>d("months"),className:"h-9 px-3 font-semibold text-base",children:ae(E,"MMMM")}),e.jsx("span",{className:"text-gray-400 text-sm",children:"-"}),e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>d("months"),className:"h-9 px-3 font-semibold text-base",children:ae(V,"MMMM yyyy")})]}):e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>d("months"),className:"h-9 px-4 font-semibold text-lg",children:ae(E,"MMMM yyyy")}),e.jsx(p,{variant:"outline",size:"sm",onClick:le,className:"h-9 w-9 p-0",children:e.jsx(C.ChevronRight,{className:"h-4 w-4"})})]})}),e.jsxs("div",{className:"p-6",children:[x==="years"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>d("months"),className:"h-9 px-3 text-sm font-medium text-gray-600",children:"← Back"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Select Year"})]}),e.jsx("div",{className:"grid grid-cols-4 gap-2 max-h-64 overflow-y-auto",children:Pe.map(u=>e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>ee(u),className:o("h-11 w-full text-sm font-medium rounded-md transition-all duration-200",u===pe?"bg-gray-900 text-white shadow-sm hover:bg-gray-800":"text-gray-900 bg-transparent"),children:u},u))})]}),x==="months"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>d("calendar"),className:"h-9 px-3 text-sm font-medium text-gray-600",children:"← Back"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(p,{variant:"outline",size:"sm",onClick:D,className:"h-9 w-9 p-0",children:e.jsx(C.ChevronLeft,{className:"h-4 w-4"})}),e.jsx(p,{variant:"ghost",onClick:()=>d("years"),className:"h-9 px-4 text-lg font-semibold text-gray-900",children:pe}),e.jsx(p,{variant:"outline",size:"sm",onClick:me,className:"h-9 w-9 p-0",children:e.jsx(C.ChevronRight,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:ze.map((u,G)=>e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>re(G),className:o("h-11 w-full text-sm font-medium rounded-md transition-all duration-200",G===E.getMonth()?"bg-gray-900 text-white shadow-sm hover:bg-gray-800":"text-gray-900 bg-transparent"),children:u},u))})]}),x==="calendar"&&e.jsxs("div",{className:o("flex",f===2?"gap-6":"gap-0"),children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:A.map((u,G)=>e.jsx("div",{className:"h-8 flex items-center justify-center",children:e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase",children:u})},G))}),e.jsxs("div",{className:"grid grid-cols-7",children:[Array.from({length:de.getDay()}).map((u,G)=>e.jsx("div",{className:"h-10"},`empty-${G}`)),oe.map(u=>ye(u,K.isSameMonth(u,E)))]})]}),f===2&&e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"grid grid-cols-7 gap-1 mb-2",children:A.map((u,G)=>e.jsx("div",{className:"h-8 flex items-center justify-center",children:e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase",children:u})},G))}),e.jsxs("div",{className:"grid grid-cols-7",children:[Array.from({length:Q.getDay()}).map((u,G)=>e.jsx("div",{className:"h-10"},`next-empty-${G}`)),he.map(u=>ye(u,K.isSameMonth(u,V)))]})]})]})]})]})})]})}const us=({time:t,onTimeChange:s,timezone:r="UTC",format:i="24h",showTimezone:b=!1,minuteStep:N=1,showSeconds:c=!1,placeholder:I="Select time",variant:M="outline",size:F="default",showClockFace:W=!1})=>{const z=i==="24h",v=t?t.getHours():0,Y=t?t.getMinutes():0,k=t?t.getSeconds():0,S=v>=12?"PM":"AM",[L,P]=R.useState(v),[O,J]=R.useState(Y),[f,H]=R.useState(k),[B,_]=R.useState(S),[E,m]=R.useState(""),[x,d]=R.useState(""),[l,T]=R.useState(""),a=R.useRef(null),g=R.useRef(null),h=R.useRef(null),y=R.useRef(null),$=R.useRef(null),X=R.useRef(null);R.useEffect(()=>{if(t){const n=t.getHours(),j=t.getMinutes(),q=t.getSeconds(),D=n>=12?"PM":"AM";n!==L&&P(n),j!==O&&J(j),q!==f&&H(q),D!==B&&_(D)}},[t]),R.useEffect(()=>{y.current&&y.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"center",behavior:"smooth"}),$.current&&$.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"center",behavior:"smooth"}),X.current&&X.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"center",behavior:"smooth"})},[L,O,f,z]);const te=(n,j,q)=>{const D=new Date;D.setHours(n),D.setMinutes(j),D.setSeconds(q),s(D)},de=n=>{let j=n;z||(B==="PM"&&n!==12?j=n+12:B==="AM"&&n===12&&(j=0)),P(j),te(j,O,f)},se=n=>{J(n),te(L,n,f)},oe=n=>{H(n),te(L,O,n)},A=n=>{if(B===n)return;_(n);const j=n==="PM"?L%12+12:L%12;P(j),te(j,O,f)},V=()=>{const n=new Date;P(n.getHours()),J(n.getMinutes()),H(n.getSeconds()),_(n.getHours()>=12?"PM":"AM"),s(n)},Q=()=>{if(!t)return I;const n=z?L:L%12||12,j=O.toString().padStart(2,"0"),q=f.toString().padStart(2,"0");let D=`${n.toString().padStart(2,"0")}:${j}`;return c&&(D+=`:${q}`),z||(D+=` ${B}`),b&&(D+=` ${r}`),D},fe=()=>{const n=z?23:12,j=z?0:1;return Array.from({length:n-j+1},(q,D)=>j+D)},he=()=>Array.from({length:Math.floor(60/N)},(n,j)=>j*N),ue=()=>Array.from({length:60},(n,j)=>j),le=z?L:L%12||12,ae=()=>{const me=(le%12*30+O*.5)*(Math.PI/180)-Math.PI/2,re=O*6*(Math.PI/180)-Math.PI/2,ee=100+50*Math.cos(me),ze=100+50*Math.sin(me),pe=100+70*Math.cos(re),Pe=100+70*Math.sin(re);return e.jsxs("svg",{width:200,height:200,className:"mx-auto",children:[e.jsx("circle",{cx:100,cy:100,r:95,fill:"white",stroke:"#e5e7eb",strokeWidth:"2"}),Array.from({length:12},(Ke,ye)=>{const u=ye*30*(Math.PI/180)-Math.PI/2,G=100+80*Math.cos(u),ie=100+80*Math.sin(u);return e.jsx("text",{x:G,y:ie,textAnchor:"middle",dominantBaseline:"middle",className:"text-sm fill-gray-600",children:ye===0?12:ye},ye)}),e.jsx("line",{x1:100,y1:100,x2:ee,y2:ze,stroke:"#374151",strokeWidth:"6",strokeLinecap:"round"}),e.jsx("line",{x1:100,y1:100,x2:pe,y2:Pe,stroke:"#ef4444",strokeWidth:"4",strokeLinecap:"round"}),e.jsx("circle",{cx:100,cy:100,r:"6",fill:"#ef4444"})]})};return e.jsxs(We,{children:[e.jsx(Be,{asChild:!0,children:e.jsxs(p,{variant:M,size:F,className:o("justify-start text-left font-normal",!t&&"text-muted-foreground"),children:[e.jsx(C.Clock,{className:"mr-2 h-4 w-4"}),Q()]})}),e.jsx(Ie,{className:"w-auto p-0",align:"start",children:e.jsxs("div",{className:"p-6 space-y-4 min-w-[460px]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-center gap-6",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{ref:a,type:"text",inputMode:"numeric",value:E!==""?E.padStart(2,"0"):le.toString().padStart(2,"0"),onKeyDown:n=>{if(n.key>="0"&&n.key<="9"){n.preventDefault();const j=E+n.key;if(j.length===1)m(n.key);else if(j.length===2){const q=parseInt(j),D=z?23:12,me=z?0:1;let re=q;q<me&&(re=me),q>D&&(re=D),m(""),de(re),setTimeout(()=>g.current?.focus(),0)}}else n.key==="Backspace"?(n.preventDefault(),E.length>0&&m(E.slice(0,-1))):n.key==="ArrowRight"||n.key==="Tab"?(n.key==="ArrowRight"&&n.preventDefault(),g.current?.focus()):n.key===":"&&(n.preventDefault(),g.current?.focus())},onBlur:()=>{if(E){const n=parseInt(E),j=z?23:12,q=z?0:1;let D=n;n<q&&(D=q),n>j&&(D=j),de(D)}m("")},onFocus:()=>{m("")},className:"text-6xl font-medium tabular-nums leading-none w-[85px] text-center bg-transparent outline-none focus:ring-2 focus:ring-primary rounded px-1 cursor-text",readOnly:!0}),e.jsx("div",{className:"text-6xl font-medium leading-none flex items-center px-1",children:":"}),e.jsx("input",{ref:g,type:"text",inputMode:"numeric",value:x!==""?x.padStart(2,"0"):O.toString().padStart(2,"0"),onKeyDown:n=>{if(n.key>="0"&&n.key<="9"){n.preventDefault();const j=x+n.key;if(j.length===1)d(n.key);else if(j.length===2){const q=parseInt(j),D=Math.min(59,Math.max(0,q));d(""),se(D),c&&setTimeout(()=>h.current?.focus(),0)}}else n.key==="Backspace"?(n.preventDefault(),x.length>0?d(x.slice(0,-1)):a.current?.focus()):n.key==="ArrowLeft"?(n.preventDefault(),a.current?.focus()):n.key==="ArrowRight"||n.key==="Tab"?(n.key==="ArrowRight"&&n.preventDefault(),c&&h.current?.focus()):n.key===":"&&(n.preventDefault(),c&&h.current?.focus())},onBlur:()=>{if(x){const n=parseInt(x),j=Math.min(59,Math.max(0,n));se(j)}d("")},onFocus:()=>{d("")},className:"text-6xl font-medium tabular-nums leading-none w-[85px] text-center bg-transparent outline-none focus:ring-2 focus:ring-primary rounded px-1 cursor-text",readOnly:!0}),c&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-6xl font-medium leading-none flex items-center px-1",children:":"}),e.jsx("input",{ref:h,type:"text",inputMode:"numeric",value:l!==""?l.padStart(2,"0"):f.toString().padStart(2,"0"),onKeyDown:n=>{if(n.key>="0"&&n.key<="9"){n.preventDefault();const j=l+n.key;if(j.length===1)T(n.key);else if(j.length===2){const q=parseInt(j),D=Math.min(59,Math.max(0,q));T(""),oe(D)}}else n.key==="Backspace"?(n.preventDefault(),l.length>0?T(l.slice(0,-1)):g.current?.focus()):n.key==="ArrowLeft"&&(n.preventDefault(),g.current?.focus())},onBlur:()=>{if(l){const n=parseInt(l),j=Math.min(59,Math.max(0,n));oe(j)}T("")},onFocus:()=>{T("")},className:"text-6xl font-medium tabular-nums leading-none w-[85px] text-center bg-transparent outline-none focus:ring-2 focus:ring-primary rounded px-1 cursor-text",readOnly:!0})]})]}),!z&&e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(p,{size:"sm",variant:B==="AM"?"default":"outline",onClick:()=>A("AM"),className:"h-8 w-12 text-xs font-medium",children:"AM"}),e.jsx(p,{size:"sm",variant:B==="PM"?"default":"outline",onClick:()=>A("PM"),className:"h-8 w-12 text-xs font-medium",children:"PM"})]})]}),b&&e.jsx("div",{className:"text-xs text-gray-500 text-center",children:r})]}),W?e.jsx("div",{className:"space-y-4",children:ae()}):e.jsxs("div",{className:"flex gap-2 justify-center items-start",children:[e.jsxs("div",{className:"flex-1 max-w-[80px]",children:[e.jsx("div",{className:"text-xs text-center text-gray-500 mb-2",children:"Hour"}),e.jsx("div",{ref:y,className:"h-40 overflow-y-scroll border rounded-md scrollbar-thin scrollbar-thumb-gray-300 scrollbar-track-gray-100",children:fe().map(n=>e.jsx("button",{"data-selected":le===n,onClick:()=>de(n),className:o("w-full py-2 text-center transition-colors",le===n?"bg-blue-500 text-white font-medium":"hover:bg-gray-100 text-gray-700"),children:n.toString().padStart(2,"0")},n))})]}),e.jsxs("div",{className:"flex-1 max-w-[80px]",children:[e.jsx("div",{className:"text-xs text-center text-gray-500 mb-2",children:"Min"}),e.jsx("div",{ref:$,className:"h-40 overflow-y-scroll border rounded-md scrollbar-thin scrollbar-thumb-gray-300 scrollbar-track-gray-100",children:he().map(n=>e.jsx("button",{"data-selected":O===n,onClick:()=>se(n),className:o("w-full py-2 text-center transition-colors",O===n?"bg-blue-500 text-white font-medium":"hover:bg-gray-100 text-gray-700"),children:n.toString().padStart(2,"0")},n))})]}),c&&e.jsxs("div",{className:"flex-1 max-w-[80px]",children:[e.jsx("div",{className:"text-xs text-center text-gray-500 mb-2",children:"Sec"}),e.jsx("div",{ref:X,className:"h-40 overflow-y-scroll border rounded-md scrollbar-thin scrollbar-thumb-gray-300 scrollbar-track-gray-100",children:ue().map(n=>e.jsx("button",{"data-selected":f===n,onClick:()=>oe(n),className:o("w-full py-2 text-center transition-colors",f===n?"bg-blue-500 text-white font-medium":"hover:bg-gray-100 text-gray-700"),children:n.toString().padStart(2,"0")},n))})]})]}),e.jsxs("div",{className:"flex gap-2 justify-between pt-2 border-t",children:[e.jsx(p,{size:"sm",variant:"outline",onClick:V,children:"Now"}),e.jsx(p,{size:"sm",onClick:()=>s(t),children:"Done"})]})]})})]})},Ve=w.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:o("rounded-lg border border-gray-200 bg-white text-gray-950 shadow-sm",t),...s}));Ve.displayName="Card";const qe=w.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:o("flex flex-col space-y-1.5 p-6",t),...s}));qe.displayName="CardHeader";const Je=w.forwardRef(({className:t,...s},r)=>e.jsx("h3",{ref:r,className:o("text-2xl font-semibold leading-none tracking-tight",t),...s}));Je.displayName="CardTitle";const ut=w.forwardRef(({className:t,...s},r)=>e.jsx("p",{ref:r,className:o("text-sm text-gray-500",t),...s}));ut.displayName="CardDescription";const Ue=w.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:o("p-6 pt-0",t),...s}));Ue.displayName="CardContent";const mt=w.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:o("flex items-center p-6 pt-0",t),...s}));mt.displayName="CardFooter";const ne=w.forwardRef(({className:t,...s},r)=>e.jsx(tt.Root,{ref:r,className:o("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...s}));ne.displayName=tt.Root.displayName;const ht=ce.Root,ms=ce.Portal,xt=w.forwardRef(({className:t,...s},r)=>e.jsx(ce.Overlay,{ref:r,className:o("fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s}));xt.displayName=ce.Overlay.displayName;const gt=w.forwardRef(({className:t,children:s,...r},i)=>e.jsxs(ms,{children:[e.jsx(xt,{}),e.jsxs(ce.Content,{ref:i,className:o("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-gray-200 bg-white p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",t),...r,children:[s,e.jsxs(ce.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-gray-950 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-gray-100",children:[e.jsx(C.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));gt.displayName=ce.Content.displayName;const ft=({className:t,...s})=>e.jsx("div",{className:o("flex flex-col space-y-1.5 text-center sm:text-left",t),...s});ft.displayName="ModalHeader";const pt=w.forwardRef(({className:t,...s},r)=>e.jsx(ce.Title,{ref:r,className:o("text-lg font-semibold leading-none tracking-tight",t),...s}));pt.displayName=ce.Title.displayName;const yt=w.forwardRef(({className:t,...s},r)=>e.jsx(ce.Description,{ref:r,className:o("text-sm text-gray-500",t),...s}));yt.displayName=ce.Description.displayName;function hs({isOpen:t,onClose:s,title:r,description:i,children:b,className:N}){return e.jsx(ht,{open:t,onOpenChange:s,children:e.jsxs(gt,{className:N,children:[(r||i)&&e.jsxs(ft,{children:[r&&e.jsx(pt,{children:r}),i&&e.jsx(yt,{children:i})]}),b]})})}const Ae=["January","February","March","April","May","June","July","August","September","October","November","December"];function bt({onWeekChange:t,initialDate:s=new Date,className:r,compact:i=!1}){const[b,N]=w.useState(s),[c,I]=w.useState(!1),[M,F]=w.useState(!1),[W,z]=w.useState(!1),[v,Y]=w.useState(s.getFullYear()),[k,S]=w.useState(s.getMonth()),[L,P]=w.useState(0),O=w.useRef(null),J=w.useRef(null),f=d=>{const l=[],T=new Date(d),a=T.getDay(),g=a===0?-6:1-a;T.setDate(T.getDate()+g);for(let h=0;h<7;h++){const y=new Date(T);y.setDate(T.getDate()+h),l.push(y)}return l},H=(d,l)=>{const T=new Date(d,l,1),a=new Date(d,l+1,0),g=new Date(T);g.setDate(T.getDate()-(T.getDay()+6)%7);const h=[],y=new Date(g);for(;y<=a||y.getMonth()===l;){const $=new Date(y);if($.setDate(y.getDate()+6),h.push({start:new Date(y),end:new Date($)}),y.setDate(y.getDate()+7),h.length>6)break}return h},B=(d,l)=>{const T=d.toLocaleDateString("en-US",{month:"short"}),a=l.toLocaleDateString("en-US",{month:"short"});return T===a?`${T} ${d.getDate()}-${l.getDate()}`:`${T} ${d.getDate()}-${a} ${l.getDate()}`},_=f(b),E=Array.from({length:10},(d,l)=>v-5+l),m=d=>{const l=new Date(b);l.setDate(b.getDate()+(d==="next"?7:-7)),N(l),Y(l.getFullYear()),S(l.getMonth()),t?.(l)},x=(d,l)=>{P(l),I(!1),N(d.start),t?.(d.start)};return w.useEffect(()=>{const d=l=>{O.current&&!O.current.contains(l.target)&&J.current&&!J.current.contains(l.target)&&(I(!1),F(!1),z(!1))};return c&&document.addEventListener("mousedown",d),()=>{document.removeEventListener("mousedown",d)}},[c]),w.useEffect(()=>{const l=H(v,k).findIndex(T=>b>=T.start&&b<=T.end);l!==-1&&P(l)},[b,v,k]),e.jsxs("div",{className:o("flex items-center gap-3",r),children:[e.jsx(p,{variant:"outline",size:"sm",onClick:()=>m("prev"),className:o("rounded-lg border-gray-200 hover:border-gray-300 hover:bg-gray-50",i?"h-8 w-8 p-0":"h-9 w-9 p-0"),children:e.jsx(C.ChevronLeft,{className:o(i?"h-3 w-3":"h-4 w-4","text-gray-600")})}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{ref:J,className:o("flex items-center gap-2 bg-white rounded-lg border border-gray-200 shadow-sm cursor-pointer hover:bg-gray-50 transition-colors",i?"px-2 py-1":"px-3 py-2"),onClick:()=>I(!c),children:[e.jsx(C.Calendar,{className:o(i?"h-3 w-3":"h-4 w-4","text-gray-500")}),e.jsx("span",{className:o(i?"text-xs":"text-sm","font-medium text-gray-700"),children:_.length>=7&&_[0]&&_[6]&&`${_[0].getDate()}-${_[6].getDate()} ${Ae[_[0].getMonth()]} ${_[0].getFullYear()}`}),e.jsx(C.ChevronRight,{className:o(i?"h-2 w-2":"h-3 w-3","text-gray-400 transition-transform",c&&"rotate-90")})]}),c&&e.jsxs("div",{ref:O,className:"absolute top-full right-0 mt-2 bg-white border border-gray-200 rounded-lg shadow-lg p-4 z-50 w-80 sm:w-96",children:[!M&&!W&&e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>{const d=k===0?11:k-1,l=k===0?v-1:v;S(d),Y(l)},className:"h-8 w-8 p-0",children:e.jsx(C.ChevronLeft,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{className:"text-lg font-semibold text-gray-800 hover:text-blue-600 transition-colors",onClick:()=>F(!M),children:Ae[k]}),e.jsx("button",{className:"text-lg font-semibold text-gray-800 hover:text-blue-600 transition-colors",onClick:()=>z(!W),children:v})]}),e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>{const d=k===11?0:k+1,l=k===11?v+1:v;S(d),Y(l)},className:"h-8 w-8 p-0",children:e.jsx(C.ChevronRight,{className:"h-4 w-4"})})]}),M?e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>F(!1),className:"h-9 px-3 text-sm font-medium",children:"← Back"}),e.jsx("span",{className:"text-lg font-semibold",children:v})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:Ae.map((d,l)=>e.jsx("button",{className:o("h-11 w-full text-sm font-medium rounded-xl transition-all",k===l?"bg-blue-500 text-white":"text-gray-600 hover:bg-gray-50"),onClick:()=>{S(l),F(!1)},children:d},d))})]}):W?e.jsxs("div",{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-start mb-4",children:e.jsx(p,{variant:"ghost",size:"sm",onClick:()=>z(!1),className:"h-9 px-3 text-sm font-medium",children:"← Back"})}),e.jsx("div",{className:"grid grid-cols-4 gap-2 max-h-64 overflow-y-auto",children:E.map(d=>e.jsx("button",{className:o("h-11 w-full text-sm font-medium rounded-xl transition-all",v===d?"bg-blue-500 text-white":"text-gray-600 hover:bg-gray-50"),onClick:()=>{Y(d),z(!1),F(!0)},children:d},d))})]}):e.jsx("div",{className:"grid grid-cols-2 gap-2 max-h-64 overflow-y-auto",children:H(v,k).map((d,l)=>{const T=new Date>=d.start&&new Date<=d.end,a=L===l;return e.jsx("button",{className:o("w-full p-3 text-left rounded-lg border transition-all",a?"bg-blue-500 text-white border-blue-500":T?"bg-white text-blue-600 border-blue-500":"bg-white border-gray-200 text-gray-700 hover:border-blue-300"),onClick:()=>x(d,l),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:o("font-medium text-sm",a?"text-white":"text-gray-800"),children:["Week ",l+1]}),e.jsx("div",{className:o("text-xs",a?"text-blue-100":"text-gray-500"),children:B(d.start,d.end)})]})},l)})}),e.jsx("div",{className:"flex gap-2 pt-3 border-t border-gray-100 mt-3",children:e.jsx(p,{size:"sm",variant:"outline",className:"flex-1",onClick:()=>{const d=new Date;N(d),I(!1),F(!1),z(!1),t?.(d)},children:"This Week"})})]})]}),e.jsx(p,{variant:"outline",size:"sm",onClick:()=>m("next"),className:o("rounded-lg border-gray-200 hover:border-gray-300 hover:bg-gray-50",i?"h-8 w-8 p-0":"h-9 w-9 p-0"),children:e.jsx(C.ChevronRight,{className:o(i?"h-3 w-3":"h-4 w-4","text-gray-600")})})]})}const Oe={calculateWeekDates:t=>{const s=[],r=new Date(t),i=r.getDay(),b=i===0?-6:1-i;r.setDate(r.getDate()+b);for(let N=0;N<7;N++){const c=new Date(r);c.setDate(r.getDate()+N),s.push(c)}return s},formatDateDisplay:t=>t.toLocaleDateString("en-US",{month:"short",day:"numeric"}),getWeekNumber:t=>{const s=new Date(t.getFullYear(),0,1),r=(t.getTime()-s.getTime())/864e5;return Math.ceil((r+s.getDay()+1)/7)},getWeekOfMonth:t=>{const r=new Date(t.getFullYear(),t.getMonth(),1).getDay(),i=t.getDate()+r-1;return Math.ceil(i/7)}},xs=["08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00"],gs=["Monday","Tuesday","Wednesday","Thursday","Friday"],fs=[{name:"Blue",value:"bg-blue-500"},{name:"Green",value:"bg-emerald-500"},{name:"Purple",value:"bg-purple-500"},{name:"Orange",value:"bg-orange-500"},{name:"Pink",value:"bg-pink-500"}];function ps({title:t="Weekly Schedule",subtitle:s,events:r,onEventAdd:i,onEventUpdate:b,onEventDelete:N,className:c,timeSlots:I=xs,daysOfWeek:M=gs,showAddButton:F=!0,eventColors:W=fs,customFields:z=[],showWeekNavigation:v=!1,showHalfHourLines:Y=!0,showCurrentTimeIndicator:k=!0,slotHeight:S=85}){const[L,P]=R.useState(!1),[O,J]=R.useState(null),[f,H]=R.useState({title:"",day:"",startTime:"",endTime:"",color:"bg-blue-500",description:"",recurrenceType:"none",specificDate:"",scheduleMode:"day"}),[B,_]=R.useState(new Date),E=v?Oe.calculateWeekDates(B):[],m=(a,g,h)=>{if(h){J(h);const y={title:h.title,day:h.day,startTime:h.startTime,endTime:h.endTime,color:h.color,description:h.description||"",recurrenceType:h.recurrenceType||"none",specificDate:h.specificDate||"",scheduleMode:h.specificDate?"date":"day"};z.forEach($=>{const X=h[$.key];y[$.key]=X instanceof Date?X.toISOString():X||($.type==="number"?0:"")}),H(y)}else{J(null);const y={title:"",day:a||"",startTime:g||"",endTime:"",color:"bg-blue-500",description:"",recurrenceType:"none",specificDate:"",scheduleMode:"day"};z.forEach($=>{y[$.key]=$.type==="number"?0:""}),H(y)}P(!0)},x=()=>{if(!f.title||!f.day||!f.startTime||!f.endTime)return;const a={...f,id:O?.id||Date.now().toString()};O?b?.(a):i?.(f),P(!1)},d=()=>{O&&(N?.(O.id),P(!1))},l=(a,g)=>r.filter(h=>{if(h.day!==a)return!1;const y=parseInt(h.startTime.replace(":","")),$=parseInt(g.replace(":",""));return y===$}),T=a=>{const[g,h]=a.startTime.split(":").map(Number),[y,$]=a.endTime.split(":").map(Number),X=g*60+h,se=(y*60+$-X)/60,oe=Math.max(4,S*.1);return se*S-oe};return e.jsxs(e.Fragment,{children:[e.jsxs(Ve,{className:o("w-full",c),children:[e.jsx(qe,{className:"pb-6 bg-gradient-to-r from-slate-50 to-gray-50 border-b border-gray-100",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx(Je,{className:"text-2xl",children:t}),s&&e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:s})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[v&&e.jsx(bt,{onWeekChange:_,initialDate:B}),F&&e.jsxs(p,{onClick:()=>m(),className:"gap-2",children:[e.jsx(C.Plus,{className:"h-4 w-4"}),"Add Event"]})]})]})}),e.jsx(Ue,{className:"p-0",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("div",{className:"min-w-[800px]",children:[e.jsxs("div",{className:"grid border-b border-gray-200",style:{gridTemplateColumns:`80px repeat(${M.length}, 1fr)`},children:[e.jsx("div",{className:"p-3 bg-gray-50 border-r border-gray-200",children:e.jsx("span",{className:"text-xs font-medium text-gray-500",children:"Time"})}),M.map((a,g)=>{const h=new Date,y=v&&E[g],$=y&&y.getDate()===h.getDate()&&y.getMonth()===h.getMonth()&&y.getFullYear()===h.getFullYear();return e.jsxs("div",{className:"p-4 text-center border-r border-gray-200 last:border-r-0 bg-gray-50 hover:bg-white/50 transition-colors",children:[e.jsx("div",{className:`font-semibold text-sm ${$?"text-blue-600":"text-gray-800"}`,children:a}),v&&y&&e.jsx("div",{className:`text-xs mt-1 font-medium ${$?"text-blue-600 font-bold":"text-gray-500"}`,children:Oe.formatDateDisplay(y)})]},a)})]}),I.map(a=>{const g=new Date,h=g.getHours(),y=g.getMinutes(),[$,X]=a.split(":"),te=parseInt(X||"0"),se=parseInt($||"0")*60+te,oe=se+60,A=h*60+y,V=A>=se&&A<oe,he=(A-se)/60*S;return e.jsxs("div",{className:"grid border-b border-gray-100 last:border-b-0",style:{gridTemplateColumns:`80px repeat(${M.length}, 1fr)`},children:[e.jsx("div",{className:"p-2 bg-gray-50/50 border-r border-gray-200",children:e.jsx("span",{className:"text-xs text-gray-600",children:a})}),M.map((ue,le)=>{const ae=l(ue,a),n=new Date,j=v&&E[le],q=j?j.getDate()===n.getDate()&&j.getMonth()===n.getMonth()&&j.getFullYear()===n.getFullYear():!1;return e.jsxs("div",{className:"relative border-r border-gray-200 last:border-r-0 hover:bg-blue-50/30 cursor-pointer transition-colors",style:{minHeight:`${S}px`},onClick:()=>!ae.length&&m(ue,a),children:[Y&&e.jsx("div",{className:"absolute top-1/2 left-0 right-0 h-px bg-gray-200/60 z-[5]"}),ae.map(D=>{const me=T(D),re=me<40;return e.jsx("div",{className:o("absolute rounded-md text-white cursor-pointer hover:scale-[1.02] transition-transform overflow-visible",D.color,re?"inset-x-1 py-0.5 px-1":"inset-1 p-2"),style:{height:`${me}px`,zIndex:10,minHeight:re?"auto":void 0},onClick:ee=>{ee.stopPropagation(),m(void 0,void 0,D)},children:re?e.jsxs("div",{className:"flex items-center justify-between gap-1",children:[e.jsx("div",{className:"font-semibold truncate text-[10px] leading-tight flex-1",children:D.title}),e.jsxs("div",{className:"text-[9px] opacity-80 whitespace-nowrap",children:[D.startTime,"-",D.endTime]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs font-semibold truncate",children:D.title}),z.filter(ee=>ee.showInCard&&D[ee.key]).map(ee=>e.jsxs("div",{className:"text-xs opacity-90 flex items-center gap-1 mt-1",children:[ee.icon,e.jsx("span",{className:"truncate",children:D[ee.key]instanceof Date?D[ee.key].toLocaleString():String(D[ee.key]||"")})]},ee.key)),e.jsx("div",{className:"text-xs opacity-80 mt-1",children:e.jsxs("span",{children:[D.startTime,"-",D.endTime]})})]})},D.id)}),k&&q&&V&&e.jsxs("div",{className:"absolute left-0 right-0 flex items-center z-20",style:{top:`${he-8}px`},children:[e.jsx("div",{className:"h-[3px] bg-red-500 absolute -left-14 right-0"}),e.jsxs("div",{className:"bg-red-500 text-white text-xs px-2 py-0.5 rounded font-bold whitespace-nowrap relative z-30 -ml-14",children:[g.getHours(),":",g.getMinutes().toString().padStart(2,"0")]})]}),!ae.length&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 hover:opacity-100 transition-opacity",children:e.jsx(C.Plus,{className:"h-5 w-5 text-gray-400"})})]},`${ue}-${a}`)})]},a)})]})})})]}),e.jsx(hs,{isOpen:L,onClose:()=>P(!1),title:O?"Edit Event":"Add New Event",children:e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{className:"text-sm font-medium",children:"Schedule Type"}),e.jsxs(Ne,{value:String(f.scheduleMode),onValueChange:a=>H({...f,scheduleMode:a}),children:[e.jsx(ve,{children:e.jsx(Se,{placeholder:"Select schedule type"})}),e.jsxs(je,{children:[e.jsx(ge,{value:"day",children:"By Day (Monday, Tuesday, etc.)"}),e.jsx(ge,{value:"date",children:"By Date (Specific date)"})]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:f.scheduleMode==="day"?"Schedule by day of the week (e.g., every Monday)":"Schedule by specific date (e.g., January 15, 2025)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{htmlFor:"title",children:"Title *"}),e.jsx(xe,{id:"title",value:String(f.title),onChange:a=>H({...f,title:a.target.value}),placeholder:"Event title"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[f.scheduleMode==="day"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{children:"Day *"}),e.jsxs(Ne,{value:String(f.day),onValueChange:a=>H({...f,day:a}),children:[e.jsx(ve,{children:e.jsx(Se,{placeholder:"Select day"})}),e.jsx(je,{children:M.map(a=>e.jsx(ge,{value:a,children:a},a))})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{htmlFor:"specificDate",children:"Date *"}),e.jsx(xe,{id:"specificDate",type:"date",value:String(f.specificDate),onChange:a=>H({...f,specificDate:a.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{htmlFor:"startTime",children:"Start Time *"}),e.jsx(xe,{id:"startTime",type:"time",value:String(f.startTime),onChange:a=>H({...f,startTime:a.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{htmlFor:"endTime",children:"End Time *"}),e.jsx(xe,{id:"endTime",type:"time",value:String(f.endTime),onChange:a=>H({...f,endTime:a.target.value})})]})]}),z.length>0&&e.jsx("div",{className:"grid grid-cols-2 gap-4",children:z.map(a=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ne,{htmlFor:a.key,children:[a.label," ",a.required&&"*"]}),a.type==="select"?e.jsxs(Ne,{value:String(f[a.key]||""),onValueChange:g=>H({...f,[a.key]:g}),children:[e.jsx(ve,{children:e.jsx(Se,{placeholder:a.placeholder||`Select ${a.label}`})}),e.jsx(je,{children:a.options?.map(g=>e.jsx(ge,{value:g.value,children:g.label},g.value))})]}):e.jsx(xe,{id:a.key,type:a.type,value:a.type==="number"?Number(f[a.key]||0):String(f[a.key]||""),onChange:g=>H({...f,[a.key]:a.type==="number"?parseInt(g.target.value)||0:g.target.value}),placeholder:a.placeholder})]},a.key))}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{type:"checkbox",id:"isRecurring",checked:f.recurrenceType!=="none",onChange:a=>{a.target.checked?H({...f,recurrenceType:f.scheduleMode==="day"?"weekly":"monthly"}):H({...f,recurrenceType:"none"})},className:"w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 focus:ring-2"}),e.jsx(ne,{htmlFor:"isRecurring",className:"text-sm font-medium text-gray-700 cursor-pointer",children:f.scheduleMode==="day"?"Repeat every week on this day":"Repeat every month on this date"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{children:"Color"}),e.jsxs(Ne,{value:String(f.color),onValueChange:a=>H({...f,color:a}),children:[e.jsx(ve,{children:e.jsx(Se,{})}),e.jsx(je,{children:W.map(a=>e.jsx(ge,{value:a.value,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:o("w-4 h-4 rounded",a.value)}),a.name]})},a.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ne,{htmlFor:"description",children:"Description"}),e.jsx(xe,{id:"description",value:String(f.description||""),onChange:a=>H({...f,description:a.target.value}),placeholder:"Optional description"})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[O&&e.jsxs(p,{variant:"destructive",onClick:d,className:"gap-2",children:[e.jsx(C.Trash2,{className:"h-4 w-4"}),"Delete"]}),e.jsx("div",{className:"flex-1"}),e.jsx(p,{variant:"outline",onClick:()=>P(!1),children:"Cancel"}),e.jsxs(p,{onClick:x,children:[O?"Update":"Add"," Event"]})]})]})})]})}const $e=[{label:"UTC",offset:0},{label:"EST",offset:-5},{label:"CST",offset:-6},{label:"MST",offset:-7},{label:"PST",offset:-8},{label:"GMT",offset:0},{label:"CET",offset:1},{label:"EET",offset:2},{label:"IST",offset:5.5},{label:"CST (China)",offset:8},{label:"JST",offset:9},{label:"AEST",offset:10},{label:"NZST",offset:12},{label:"HST",offset:-10},{label:"AKST",offset:-9},{label:"Asia/Bangkok",offset:7}],ys=(t,s,r)=>{const i=$e.find(c=>c.label===s)?.offset||0,b=$e.find(c=>c.label===r)?.offset||0,N=new Date(t);return N.setHours(N.getHours()+(b-i)),N},bs=(t,s,r="24h",i=!1)=>{const b=r==="12h"?t.getHours()%12||12:t.getHours(),N=t.getMinutes().toString().padStart(2,"0"),c=t.getSeconds().toString().padStart(2,"0"),I=t.getHours()>=12?"PM":"AM";let M=`${b.toString().padStart(2,"0")}:${N}`;return i&&(M+=`:${c}`),r==="12h"&&(M+=` ${I}`),M+=` ${s}`,M};exports.Button=p;exports.Calendar=is;exports.Card=Ve;exports.CardContent=Ue;exports.CardDescription=ut;exports.CardFooter=mt;exports.CardHeader=qe;exports.CardTitle=Je;exports.Checkbox=Re;exports.DataGrid=Xt;exports.DataGridColumnHeader=ts;exports.DataGridEmptyState=ot;exports.DataGridLoadingSpinner=nt;exports.DataGridPagination=es;exports.DataGridTable=Zt;exports.DataGridTableRowSelect=as;exports.DataGridTableRowSelectAll=ss;exports.DataTable=Kt;exports.DatePicker=ds;exports.DropdownMenu=Et;exports.DropdownMenuCheckboxItem=Lt;exports.DropdownMenuContent=Ot;exports.DropdownMenuGroup=$t;exports.DropdownMenuItem=Yt;exports.DropdownMenuLabel=Wt;exports.DropdownMenuPortal=At;exports.DropdownMenuRadioGroup=_t;exports.DropdownMenuRadioItem=Gt;exports.DropdownMenuSeparator=Bt;exports.DropdownMenuShortcut=Vt;exports.DropdownMenuSub=qt;exports.DropdownMenuSubContent=Ut;exports.DropdownMenuSubTrigger=Jt;exports.DropdownMenuTrigger=Ft;exports.Input=xe;exports.Label=ne;exports.Modal=ht;exports.Popover=We;exports.PopoverAnchor=cs;exports.PopoverContent=Ie;exports.PopoverTrigger=Be;exports.Schedule=ps;exports.Select=Ne;exports.SelectContent=je;exports.SelectGroup=Qt;exports.SelectItem=ge;exports.SelectLabel=ct;exports.SelectSeparator=dt;exports.SelectTrigger=ve;exports.SelectValue=Se;exports.Separator=st;exports.TIMEZONES=$e;exports.Table=Ye;exports.TableBody=_e;exports.TableCaption=Ht;exports.TableCell=Te;exports.TableFooter=Pt;exports.TableHead=Ge;exports.TableHeader=Le;exports.TableRow=Me;exports.TimePicker=us;exports.WeekNavigator=bt;exports.cn=o;exports.convertTimezone=ys;exports.formatTimeWithTimezone=bs;exports.useDataGrid=ke;exports.weekNavigatorUtils=Oe;
2
6
  //# sourceMappingURL=takaui.cjs.map