1import{p as k,j as e}from"./index-B4Uy4NJO.js";import{r as a,J as R,aF as F,a0 as S,O as f}from"./lucide-mMo7nqgk.js";import{p as C}from"./reportExport-BGriXW13.js";import"./vendor-Cv6_TLXB.js";import"./framer-mxZmfqgM.js";const U=()=>{const{shareToken:n,agencySlug:o,reportSlug:i}=k(),b=a.useRef(null),[g,r]=a.useState(!0),[w,c]=a.useState(null),[j,d]=a.useState(null),[t,_]=a.useState(null),[p,y]=a.useState(null);if(a.useEffect(()=>{if(!n&&(!o||!i)){c("INVALID_LINK"),d("No valid share token or report identifier provided."),r(!1);return}(async()=>{try{r(!0),c(null),d(null);let x="";n?x=`token=${encodeURIComponent(n)}`:o&&i&&(x=`agencySlug=${encodeURIComponent(o)}&reportSlug=${encodeURIComponent(i)}`);const u=await fetch(`/api/public-report?${x}`),l=await u.json();if(!u.ok||!l.success||!l.data){c(l.error||"UNAVAILABLE"),d(l.message||"This report is no longer available."),r(!1);return}const s=l.data;_(s);const m=await fetch(s.report_url,{mode:"cors"});if(!m.ok)throw new Error(`Failed to fetch report assets (${m.status})`);const N=await m.text(),v=C(N,{report_name:s.report_name,brand_name:s.brand_name,brand_logo_url:s.brand_logo_url,primary_color:s.primary_color,accent_color:s.accent_color,agency_website:s.agency_website,agency_email:s.agency_email,cta_text:s.cta_text,cta_url:s.cta_url,hidden_sections:s.hidden_sections||[]});y(v),r(!1)}catch{c("LOAD_ERROR"),d("Could not render report content. Please try refreshing."),r(!1)}})()},[n,o,i]),g)return e.jsxs("div",{className:"fixed inset-0 bg-[#FDFCFB] flex flex-col items-center justify-center space-y-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-indigo-50 flex items-center justify-center text-[#635FF4]",children:e.jsx(R,{className:"w-6 h-6 animate-spin"})}),e.jsx("p",{className:"text-xs font-black text-slate-400 uppercase tracking-widest animate-pulse",children:"Loading Client Report..."})]});if(w||!t)return e.jsx("div",{className:"fixed inset-0 bg-[#0F172A] flex items-center justify-center p-6 text-white text-center font-sans",children:e.jsxs("div",{className:"max-w-md w-full bg-slate-900/90 border border-slate-800 p-8 md:p-10 rounded-3xl shadow-2xl space-y-6",children:[e.jsx("div",{className:"w-16 h-16 bg-slate-800 border border-slate-700 rounded-2xl flex items-center justify-center mx-auto text-slate-400",children:e.jsx(F,{className:"w-8 h-8"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl font-black tracking-tight text-white",children:"Report Unavailable"}),e.jsx("p",{className:"text-sm text-slate-400 font-medium leading-relaxed",children:j||"This report is currently in draft mode, disabled, or does not exist."})]}),e.jsx("div",{className:"pt-2 text-xs text-slate-500",children:"If you believe this is an error, please contact the person or agency who shared this link with you."})]})});const h=t.primary_color||"#635FF4";return e.jsxs("div",{className:"fixed inset-0 bg-[#FDFCFB] flex flex-col overflow-hidden font-sans",children:[e.jsxs("header",{className:"h-16 bg-white/95 backdrop-blur-md border-b border-slate-200/80 px-4 md:px-8 flex items-center justify-between shrink-0 shadow-sm z-30",children:[e.jsxs("div",{className:"flex items-center gap-3 md:gap-4 min-w-0",children:[t.brand_logo_url?e.jsx("img",{src:t.brand_logo_url,alt:t.brand_name||"Agency Logo",className:"h-8 max-w-[140px] md:max-w-[180px] object-contain shrink-0"}):t.brand_name?e.jsx("div",{className:"text-sm md:text-base font-black tracking-tight shrink-0 truncate max-w-[160px] md:max-w-xs",style:{color:h},children:t.brand_name}):e.jsx("div",{className:"w-8 h-8 rounded-xl bg-slate-100 flex items-center justify-center text-slate-400 shrink-0",children:e.jsx(S,{className:"w-4 h-4"})}),e.jsx("div",{className:"h-5 w-px bg-slate-200 hidden sm:block shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-xs md:text-sm font-bold text-slate-900 truncate max-w-[180px] sm:max-w-xs md:max-w-md",children:t.report_name}),e.jsx("p",{className:"text-[10px] text-slate-400 font-medium truncate",children:t.input_value?`Audit for ${t.input_value.replace(/^https?:\/\//i,"").replace(/\/$/,"")}`:"UX Audit"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[t.overall_score!==null&&t.overall_score!==void 0&&e.jsxs("div",{className:"hidden lg:flex items-center gap-1.5 px-3 py-1 bg-emerald-50 border border-emerald-200 rounded-full text-emerald-800 text-xs font-extrabold",children:[e.jsx("span",{children:"Overall Score:"}),e.jsxs("span",{className:"text-emerald-600 font-black",children:[t.overall_score,"/100"]})]}),t.cta_text&&t.cta_url?e.jsxs("a",{href:t.cta_url,target:"_blank",rel:"noopener noreferrer",className:"px-4 py-2 text-white rounded-xl text-xs font-extrabold tracking-wide uppercase shadow-md transition-all hover:opacity-90 active:scale-95 flex items-center gap-1.5",style:{backgroundColor:h},children:[e.jsx("span",{children:t.cta_text}),e.jsx(f,{className:"w-3.5 h-3.5"})]}):t.agency_website?e.jsxs("a",{href:t.agency_website,target:"_blank",rel:"noopener noreferrer",className:"px-4 py-2 bg-slate-900 hover:bg-slate-800 text-white rounded-xl text-xs font-bold transition-all flex items-center gap-1.5",children:[e.jsx("span",{children:"Visit Website"}),e.jsx(f,{className:"w-3.5 h-3.5"})]}):null]})]}),e.jsx("main",{className:"flex-1 relative overflow-hidden bg-slate-100",children:p?e.jsx("iframe",{ref:b,srcDoc:p,title:t.report_name||"UX Audit Report",className:"w-full h-full border-none bg-white",sandbox:"allow-scripts allow-same-origin allow-popups allow-forms allow-downloads"}):e.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-6 text-slate-400",children:"Failed to render report."})})]})};export{U as PublicReportViewer};
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.