import { S as reactExports, J as jsxRuntimeExports } from "./server-BiCSmoPr.js";
import { h as createLucideIcon, I as INVESTOR_DOCUMENTS, p as motion, L as Link, a as INVESTOR_DOCUMENT_CATEGORIES } from "./router-K1srMTuI.js";
import { A as ArrowLeft } from "./arrow-left-DOE61fAZ.js";
import { F as FileText } from "./file-text-CbBXWTmN.js";
import { D as Download } from "./download-DZtVm_yI.js";
import "node:async_hooks";
import "node:stream/web";
import "node:stream";
const __iconNode$2 = [
  ["path", { d: "M8 2v4", key: "1cmpym" }],
  ["path", { d: "M16 2v4", key: "4m81vk" }],
  ["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
  ["path", { d: "M3 10h18", key: "8toen8" }]
];
const Calendar = createLucideIcon("calendar", __iconNode$2);
const __iconNode$1 = [
  [
    "path",
    {
      d: "M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",
      key: "sc7q7i"
    }
  ]
];
const Funnel = createLucideIcon("funnel", __iconNode$1);
const __iconNode = [
  ["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
  ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
];
const Search = createLucideIcon("search", __iconNode);
function InvestorDesk() {
  const [documents, setDocuments] = reactExports.useState(INVESTOR_DOCUMENTS);
  const [query, setQuery] = reactExports.useState("");
  const [category, setCategory] = reactExports.useState("All");
  const [sort, setSort] = reactExports.useState("newest");
  const [selected, setSelected] = reactExports.useState(null);
  reactExports.useEffect(() => {
    let mounted = true;
    fetch("/api/investor-documents").then((response) => {
      if (!response.ok) throw new Error("Unable to load investor documents");
      return response.json();
    }).then((data) => {
      if (mounted) setDocuments(data.documents);
    }).catch(() => {
      if (mounted) setDocuments(INVESTOR_DOCUMENTS);
    });
    return () => {
      mounted = false;
    };
  }, []);
  const filtered = reactExports.useMemo(() => {
    const r = documents.filter((d) => (category === "All" || d.category === category) && `${d.title} ${d.description}`.toLowerCase().includes(query.toLowerCase()));
    r.sort((a, b) => {
      if (sort === "title") return a.title.localeCompare(b.title);
      if (sort === "oldest") return a.date.localeCompare(b.date);
      return b.date.localeCompare(a.date);
    });
    return r;
  }, [documents, query, category, sort]);
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("main", { className: "min-h-screen bg-bone px-6 pt-32 pb-24", children: [
    /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mx-auto max-w-7xl", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs(motion.div, { initial: {
        opacity: 0,
        y: 20
      }, animate: {
        opacity: 1,
        y: 0
      }, transition: {
        duration: 0.8
      }, className: "mb-14 md:mb-16", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs(Link, { to: "/", className: "mb-10 inline-flex items-center gap-2 text-[10px] uppercase tracking-[0.18em] text-muted-foreground transition-colors hover:text-foreground sm:tracking-[0.3em]", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(ArrowLeft, { className: "h-3 w-3" }),
          " Back to SR18"
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-8 flex items-center gap-3 text-[10px] uppercase tracking-[0.18em] text-muted-foreground sm:gap-4 sm:tracking-[0.35em]", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gold", children: "Investor Desk" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "h-px w-8 shrink-0 bg-border sm:w-12" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "min-w-0 leading-relaxed", children: "Confidential Knowledge Vault" })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("h1", { className: "text-display max-w-4xl text-[clamp(2.25rem,11vw,3.4rem)] leading-[1.06] sm:text-[clamp(2.8rem,6vw,5rem)] sm:leading-[1.04]", children: [
          "Documents, disclosures, and ",
          /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "italic text-gold-gradient", children: "diligence" }),
          "."
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-6 max-w-2xl text-base leading-7 text-muted-foreground sm:text-lg", children: "A curated archive for capital partners and prospective investors." })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs(motion.div, { initial: {
        opacity: 0,
        y: 12
      }, animate: {
        opacity: 1,
        y: 0
      }, transition: {
        duration: 0.6,
        delay: 0.2
      }, className: "mb-8 flex flex-col items-stretch gap-4 border border-border bg-background p-6 lg:flex-row lg:items-center", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative flex-1", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Search, { className: "absolute left-4 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("input", { value: query, onChange: (e) => setQuery(e.target.value), placeholder: "Search documents…", className: "w-full bg-mist py-3 pr-4 pl-11 text-sm outline-none focus:ring-1 focus:ring-gold" })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 text-xs", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Funnel, { className: "h-4 w-4 text-muted-foreground" }),
          /* @__PURE__ */ jsxRuntimeExports.jsxs("select", { value: sort, onChange: (e) => setSort(e.target.value), className: "bg-mist px-4 py-3 text-sm outline-none focus:ring-1 focus:ring-gold uppercase tracking-wider", children: [
            /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "newest", children: "Newest first" }),
            /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "oldest", children: "Oldest first" }),
            /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "title", children: "Title A–Z" })
          ] })
        ] })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(motion.div, { initial: {
        opacity: 0
      }, animate: {
        opacity: 1
      }, transition: {
        delay: 0.3
      }, className: "flex flex-wrap gap-2 mb-10", children: INVESTOR_DOCUMENT_CATEGORIES.map((c) => /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: () => setCategory(c), className: `border px-4 py-2 text-[10px] uppercase tracking-[0.14em] transition-all sm:tracking-[0.25em] ${category === c ? "bg-foreground text-background border-foreground" : "border-border hover:border-foreground"}`, children: c }, c)) }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid gap-px bg-border md:grid-cols-2 lg:grid-cols-3", children: [
        filtered.map((d, i) => /* @__PURE__ */ jsxRuntimeExports.jsxs(motion.button, { initial: {
          opacity: 0,
          y: 20
        }, animate: {
          opacity: 1,
          y: 0
        }, transition: {
          duration: 0.6,
          delay: i * 0.04
        }, onClick: () => setSelected(d), className: "group bg-background p-6 text-left transition-all hover:bg-background hover:shadow-xl sm:p-7", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-8 flex items-start justify-between", children: [
            /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-12 w-12 items-center justify-center bg-mist transition-colors group-hover:bg-gold", children: /* @__PURE__ */ jsxRuntimeExports.jsx(FileText, { className: "h-5 w-5 text-foreground" }) }),
            /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[10px] uppercase tracking-[0.18em] text-gold sm:tracking-[0.25em]", children: d.type })
          ] }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-2 text-[10px] uppercase tracking-[0.18em] text-muted-foreground sm:tracking-[0.3em]", children: d.category }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-display mb-3 text-xl leading-tight", children: d.title }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mb-6 line-clamp-3 text-sm leading-relaxed text-muted-foreground", children: d.description }),
          /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-4 border-t border-border pt-4 text-[10px] uppercase tracking-[0.14em] text-muted-foreground sm:tracking-[0.25em]", children: [
            /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex items-center gap-2", children: [
              /* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: "h-3 w-3" }),
              d.date
            ] }),
            /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: d.size })
          ] })
        ] }, d.id)),
        filtered.length === 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "bg-background p-10 text-center text-muted-foreground sm:p-16 md:col-span-2 lg:col-span-3", children: "No documents match your filters." })
      ] })
    ] }),
    selected && /* @__PURE__ */ jsxRuntimeExports.jsx(motion.div, { initial: {
      opacity: 0
    }, animate: {
      opacity: 1
    }, className: "fixed inset-0 z-50 flex items-center justify-center bg-foreground/60 p-4 backdrop-blur-md sm:p-6", onClick: () => setSelected(null), children: /* @__PURE__ */ jsxRuntimeExports.jsxs(motion.div, { initial: {
      y: 20,
      opacity: 0
    }, animate: {
      y: 0,
      opacity: 1
    }, onClick: (e) => e.stopPropagation(), className: "max-h-[85vh] w-full max-w-3xl overflow-auto bg-background", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start justify-between gap-5 border-b border-border p-6 sm:gap-6 sm:p-8", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-2 text-[10px] uppercase tracking-[0.18em] text-gold sm:tracking-[0.3em]", children: selected.category }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "text-display text-2xl leading-tight sm:text-3xl", children: selected.title }),
          /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-3 text-[10px] uppercase tracking-[0.14em] text-muted-foreground sm:tracking-[0.25em]", children: [
            selected.date,
            " · ",
            selected.size,
            " · ",
            selected.type
          ] }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-4 max-w-2xl text-sm leading-relaxed text-muted-foreground", children: selected.description })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: () => setSelected(null), className: "text-2xl text-muted-foreground hover:text-foreground", children: "×" })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "p-6 sm:p-8", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-6 flex aspect-[4/3] flex-col items-center justify-center gap-4 bg-mist px-5 text-center", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(FileText, { className: "h-16 w-16 text-muted-foreground" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-muted-foreground", children: selected.downloadUrl ? "Document ready for download" : "Preview unavailable - request access to download" })
        ] }),
        selected.downloadUrl ? /* @__PURE__ */ jsxRuntimeExports.jsxs("a", { href: selected.downloadUrl, className: "flex w-full items-center justify-center gap-3 bg-foreground py-4 text-xs uppercase tracking-[0.14em] text-background transition-colors hover:bg-gold hover:text-foreground sm:tracking-[0.25em]", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Download, { className: "h-4 w-4" }),
          " Download Document"
        ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("button", { className: "flex w-full items-center justify-center gap-3 bg-foreground py-4 text-xs uppercase tracking-[0.14em] text-background transition-colors hover:bg-gold hover:text-foreground sm:tracking-[0.25em]", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Download, { className: "h-4 w-4" }),
          " Request Document Access"
        ] })
      ] })
    ] }) })
  ] });
}
export {
  InvestorDesk as component
};
