import{d as k,j as e,C as E,e as v,R as P,I as z,r as i,u as _,f as M,B as F}from"./index-C0htHi5J.js";/**
 * @license lucide-react v0.563.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const R=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],L=k("chevron-left",R);/**
 * @license lucide-react v0.563.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const $=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],B=k("chevron-right",$),G=({items:h,itemType:r,loading:m=!1,error:p=null,loadingMessage:j="Loading...",emptyMessage:s="No items found",gridClassName:b="grid grid-cols-2 md:grid-cols-3 gap-4 auto-rows-max",minHeight:c="h-96",selectedItems:d=new Set,onItemClick:g,showTypeBadge:N=!0,renderItem:x})=>{const l=h.length===0;return p?e.jsx("div",{className:v("flex items-center justify-center w-full",c),children:e.jsx("div",{className:"max-w-md p-6 rounded-lg border border-destructive/50 bg-destructive/10",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(E,{className:"h-4 w-4 text-destructive shrink-0 mt-0.5"}),e.jsx("div",{children:e.jsx("p",{className:"text-sm text-destructive",children:p})})]})})}):m&&l?e.jsx("div",{className:v("flex items-center justify-center w-full",c),children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-2 border-primary border-t-transparent rounded-full"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:j})]})}):l&&!m?e.jsx("div",{className:v("flex items-center justify-center w-full text-muted-foreground",c),children:e.jsx("p",{className:"text-sm",children:s})}):e.jsx("div",{className:b,children:h.map((a,w)=>{if(x)return e.jsx(P.Fragment,{children:x(a,w)},a.id||w);const o=a.id,u=a.label||"Unknown",f=a.highlighted===!0,y=d instanceof Map||d instanceof Set?d.has(o):!1;return e.jsx(z,{id:o,label:u,type:r,metadata:a,isSelected:y,isHighlighted:f,showTypeBadge:N,onClick:()=>g==null?void 0:g(o)},o)})})},C=h=>({node:"nodes",edge:"edges",hyperedge:"hyperedges"})[h],O=i.memo(function({entityType:r,fetchFunction:m}){const{selectedItems:p,selectItem:j}=_(),[s,b]=i.useState(0),[c,d]=i.useState([]),[g,N]=i.useState(0),[x]=i.useState(12),[l,a]=i.useState(!1),[w,o]=i.useState(null),u=Math.ceil(g/x),f=async t=>{a(!0),o(null);try{const n=await m(t,x);d(n.items||[]),N(n.total||0),b(t)}catch(n){console.error(`Failed to load ${C(r)}:`,n),o(`Failed to load ${C(r)}`)}finally{a(!1)}};i.useEffect(()=>{f(0)},[]);const y=()=>{const{setViewMode:t,meta:n}=_.getState(),S=(n==null?void 0:n.type)||"graph";t(S==="graph"?"graph":"hypergraph")};return e.jsxs("div",{className:"w-full h-full flex items-center justify-center md:justify-end overflow-hidden md:pr-[10vw] relative",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"absolute inset-0 z-10 pointer-events-auto bg-white/1",onClick:y}),e.jsxs(M,{position:"custom",className:"w-[90vw] md:w-[70vw] lg:w-[60vw] h-[80vh] md:h-[72vh] z-20 flex flex-col pointer-events-auto relative border-t border-l border-white/60 shadow-[0_40px_120px_-30px_rgba(0,0,0,0.2)]",contentClassName:"p-0 flex flex-col",children:[e.jsx("div",{className:"absolute inset-0 z-0 pointer-events-none opacity-[0.015] mix-blend-overlay",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch' /%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23noiseFilter)' /%3E%3C/svg%3E")`}}),e.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden p-10 pb-24 flex flex-col items-start relative z-10 scrollbar-thin scroll-smooth",onClick:t=>t.stopPropagation(),children:e.jsx(G,{items:c,itemType:r,loading:l&&c.length===0,error:w,loadingMessage:"Loading...",emptyMessage:`No ${C(r)} found`,selectedItems:p,onItemClick:t=>j(t,r),showTypeBadge:!1,gridClassName:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6 auto-rows-max w-full",minHeight:"min-h-full"})}),u>1&&e.jsxs("div",{className:v("absolute bottom-8 left-1/2 -translate-x-1/2 flex items-center justify-center gap-1.5 p-1.5 rounded-full bg-white/70 border border-white shadow-[0_10px_30px_rgba(0,0,0,0.1)] ring-1 ring-black/[0.03] z-20 hover:shadow-[0_15px_40px_rgba(0,0,0,0.15)] transition-shadow duration-300",F.STRONG),onClick:t=>t.stopPropagation(),children:[e.jsx("button",{onClick:()=>f(Math.max(0,s-1)),disabled:s===0||l,className:`w-9 h-9 flex items-center justify-center rounded-full transition-all duration-300 ${s>0&&!l?"hover:bg-white text-foreground cursor-pointer shadow-sm active:scale-95":"text-foreground/20 cursor-not-allowed"}`,title:"Previous page",children:e.jsx(L,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5 bg-black/[0.03] rounded-full text-[12px] font-bold tracking-tight",children:[e.jsx("span",{className:"text-foreground/80",children:s+1}),e.jsx("span",{className:"text-foreground/20 font-light select-none",children:"/"}),e.jsx("span",{className:"text-foreground/40",children:u})]}),e.jsx("button",{onClick:()=>f(s+1),disabled:s>=u-1||l,className:`w-9 h-9 flex items-center justify-center rounded-full transition-all duration-300 ${s<u-1&&!l?"hover:bg-white text-foreground cursor-pointer shadow-sm active:scale-95":"text-foreground/20 cursor-not-allowed"}`,title:"Next page",children:e.jsx(B,{className:"w-4 h-4"})})]})]})]})});export{O as default};
//# sourceMappingURL=PaginatedGridView-BwMITpDm.js.map
