1import{r as a,j as e}from"./vendor-ui-B6LJVmB2.js";import{I as y,B as w,O as N,b as k,C as _}from"./index-R7rnvG6Y.js";import{a as S}from"./vendor-react-C26fm6iv.js";import{L as C,E as P,a as E,C as D,b as L,c as j,I as A,F as f,d as I,D as F,S as U}from"./vendor-icons-rWq2ByuV.js";import"./vendor-query-D2dui6iP.js";import"./vendor-supabase-C_jStVHz.js";import"./vendor-markdown--mR8Btqo.js";const B="https://auth.simplyasking.io";function K(){const{token:s}=S(),[t,r]=a.useState({type:"loading"}),[n,i]=a.useState(""),[o,x]=a.useState(!1),[b,p]=a.useState(!1),c=a.useCallback(async l=>{if(!s){r({type:"error",message:"Invalid link"});return}try{const g=new URL(`/functions/v1/share-document/view/${s}`,B);l&&g.searchParams.set("password",l);const m=await fetch(g.toString()),h=await m.json();if(m.status===401&&h.has_password){r({type:"password_required"});return}if(!m.ok){r({type:"error",message:h.error||"This link is no longer available."});return}r({type:"success",data:h})}catch{r({type:"error",message:"Failed to load document. Please try again."})}},[s]);a.useEffect(()=>{c()},[c]);const u=a.useCallback(async()=>{p(!0),await c(n),p(!1)},[c,n]);if(t.type==="password_required")return e.jsx(d,{children:e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[60vh] px-4",children:e.jsxs("div",{className:"w-full max-w-sm space-y-6 text-center",children:[e.jsx("div",{className:"mx-auto h-14 w-14 rounded-full bg-[var(--gold-rich-12)] border border-[var(--gold-35)] flex items-center justify-center",children:e.jsx(C,{className:"h-6 w-6 text-[var(--gold)]"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-white/95",children:"Password Protected"}),e.jsx("p",{className:"text-sm text-white/60 mt-2",children:"Enter the password to view this document."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(y,{type:o?"text":"password",value:n,onChange:l=>i(l.target.value),placeholder:"Enter password",onKeyDown:l=>l.key==="Enter"&&void u(),className:"bg-white/5 border-white/10 text-white placeholder:text-white/30 pr-10","aria-label":"Share link password"}),e.jsx("button",{type:"button",onClick:()=>x(l=>!l),"aria-label":o?"Hide password":"Show password",className:"absolute right-3 top-1/2 -translate-y-1/2 p-1 text-white/50 hover:text-white/90 transition-colors",children:o?e.jsx(P,{className:"h-4 w-4"}):e.jsx(E,{className:"h-4 w-4"})})]}),e.jsx(w,{variant:"primary",className:"w-full",onClick:()=>void u(),disabled:!n.trim(),loading:b,children:"View Document"})]})]})})});if(t.type==="error")return e.jsx(d,{children:e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[60vh] px-4",children:e.jsxs("div",{className:"text-center space-y-4 max-w-md",children:[e.jsx("div",{className:"mx-auto h-14 w-14 rounded-full bg-red-500/10 border border-red-500/30 flex items-center justify-center",children:e.jsx(D,{className:"h-6 w-6 text-red-400"})}),e.jsx("h1",{className:"text-xl font-semibold text-white/95",children:"Link Unavailable"}),e.jsx("p",{className:"text-sm text-white/60",children:t.message})]})})});if(t.type==="loading")return e.jsx(d,{children:e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsx(L,{className:"h-8 w-8 animate-spin"})})});const{data:v}=t;return e.jsx(R,{data:v})}function R({data:s}){var o;const t=a.useMemo(()=>M(s.file_type),[s.file_type]),r=a.useCallback(()=>{window.print()},[]),n=s.title,i=s.org_name;return a.useEffect(()=>{if(!i)return;const x=document.title;return document.title=`${n} â ${i}`,()=>{document.title=x}},[n,i]),e.jsx(N,{brand:s.org_brand,children:e.jsx(d,{orgName:s.org_name,orgLogoUrl:s.org_logo_url,children:e.jsxs("div",{className:"max-w-3xl mx-auto px-4 sm:px-6 py-8 sm:py-12",children:[e.jsxs("section",{className:"rounded-2xl border p-6 sm:p-8 mb-6 print:border-none print:p-0",style:{background:"linear-gradient(165deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.02) 50%, rgba(255,255,255,0.01) 100%)",borderColor:"rgba(255, 255, 255, 0.08)",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.35)"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[10px] font-medium uppercase tracking-[0.12em] border",style:{color:"var(--gold)",backgroundColor:"var(--gold-rich-8)",borderColor:"var(--gold-rich-30)"},children:[t?e.jsx(A,{className:"h-3 w-3"}):e.jsx(f,{className:"h-3 w-3"}),s.file_type||"document"]}),s.created_at&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] text-white/50",children:[e.jsx(I,{className:"h-3 w-3"}),k(s.created_at,"MMM d, yyyy")]})]}),e.jsx("h1",{className:"text-2xl sm:text-[28px] font-light text-white/95 tracking-tight leading-tight",children:s.title}),e.jsx("div",{className:"mt-5 h-px",style:{background:"linear-gradient(to right, var(--gold-rich-35) 0%, var(--gold-rich-10) 35%, transparent 100%)"}})]}),t&&s.org_logo_url&&e.jsx("section",{className:"mb-6 rounded-2xl overflow-hidden border bg-black/40 print:border-none",children:e.jsx("img",{src:s.org_logo_url,alt:s.title,className:"w-full h-auto max-h-[60vh] object-contain"})}),e.jsx("section",{className:"rounded-2xl border p-6 sm:p-8 print:border-none print:p-0",style:{background:"linear-gradient(165deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.015) 100%)",borderColor:"rgba(255, 255, 255, 0.07)"},children:(o=s.content_text)!=null&&o.trim()?e.jsx("div",{className:"text-white/85 leading-relaxed",children:e.jsx(_,{content:s.content_text,variant:"full",className:"text-white/85"})}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(f,{className:"h-8 w-8 text-white/30 mb-3"}),e.jsx("p",{className:"text-sm text-white/50",children:t?"No extracted text is available for this image.":"No preview is available for this document."})]})}),s.allow_download&&e.jsx("div",{className:"mt-6 flex justify-end print:hidden",children:e.jsxs(w,{variant:"secondary",onClick:r,"aria-label":"Print or save as PDF",children:[e.jsx(F,{className:"h-4 w-4"}),"Save as PDF"]})}),e.jsx("div",{className:"mt-10 pt-6 border-t border-white/5 print:hidden",children:e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 text-xs text-white/40",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(U,{className:"h-3.5 w-3.5"}),i?`Shared securely by ${i}`:"Shared securely via Simply Asking"]}),!i&&e.jsxs("a",{href:"https://simplyasking.io",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-white/55 hover:text-[var(--gold)] transition-colors",children:["Learn more",e.jsx(j,{className:"h-3 w-3"})]})]})})]})})})}function M(s){if(!s)return!1;const t=s.toLowerCase();return t==="image"||t==="png"||t==="jpg"||t==="jpeg"||t==="gif"||t==="webp"||t==="svg"||t.startsWith("image/")}function d({children:s,orgName:t,orgLogoUrl:r}){return e.jsxs("div",{className:"min-h-screen flex flex-col bg-[#0a0a0f]",children:[e.jsx("header",{className:"border-b px-4 sm:px-6 py-4 print:hidden",style:{borderColor:"rgba(255, 255, 255, 0.06)"},children:e.jsxs("div",{className:"max-w-3xl mx-auto flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[r?e.jsx("img",{src:r,alt:t??"",className:"h-8 w-auto rounded"}):t?e.jsx("div",{className:"h-9 w-9 rounded-lg flex items-center justify-center border",style:{background:"linear-gradient(135deg, var(--gold-rich-15), var(--gold-rich-5))",borderColor:"var(--gold-rich-30)"},children:e.jsx("span",{className:"text-sm font-semibold",style:{color:"var(--gold)"},children:t.charAt(0).toUpperCase()})}):null,t&&e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-white/85 truncate",children:t}),e.jsx("p",{className:"text-[11px] text-white/40",children:"shared a document with you"})]})]}),!t&&e.jsx("a",{href:"https://simplyasking.io",target:"_blank",rel:"noopener noreferrer",className:"hidden sm:inline-flex items-center gap-2 text-[11px] text-white/40 hover:text-white/70 transition-colors",children:e.jsx("img",{src:"/assets/NBG_Logo_1.svg",alt:"Simply Asking",className:"h-5 w-auto opacity-80"})})]})}),e.jsx("main",{className:"flex-1",children:s}),e.jsx("footer",{className:"border-t px-4 sm:px-6 py-6 print:hidden",style:{borderColor:"rgba(255, 255, 255, 0.06)"},children:e.jsx("div",{className:"max-w-3xl mx-auto text-center",children:e.jsxs("a",{href:"https://simplyasking.io",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-xs text-white/30 hover:text-white/60 transition-colors",children:["Powered by Simply Asking",e.jsx(j,{className:"h-3 w-3"})]})})})]})}export{K as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.