1import{ca as g,_ as k,m as E}from"./index-R7rnvG6Y.js";import{r as l,j as e}from"./vendor-ui-B6LJVmB2.js";import"./vendor-icons-rWq2ByuV.js";import"./vendor-query-D2dui6iP.js";import"./vendor-supabase-C_jStVHz.js";import"./vendor-react-C26fm6iv.js";import"./vendor-markdown--mR8Btqo.js";function D({fileUrl:c,fileName:N,onError:n}){const[b,d]=l.useState(!0),[p,h]=l.useState(null),[u,y]=l.useState([]),[i,f]=l.useState(0);if(l.useEffect(()=>{let t=!0;return(async()=>{try{d(!0),h(null);const r=await k(()=>import("./xlsx-CkFp8p6R.js"),[]),o=await fetch(c);if(!o.ok)throw new Error(`Failed to fetch file: ${o.statusText}`);const s=await o.arrayBuffer();if(!t)return;const v=r.read(s,{type:"array"});if(!t)return;const w=v.SheetNames.map(x=>{const j=v.Sheets[x],S=r.utils.sheet_to_json(j,{header:1,defval:""});return{name:x,data:S}});y(w),f(0),d(!1)}catch(r){if(E("ExcelPreview",r,"Error parsing Excel:"),!t)return;const o=r instanceof Error?r.message:"Failed to parse spreadsheet. The file may be corrupted or inaccessible.";h(o),d(!1),n==null||n(new Error(o))}})(),()=>{t=!1}},[c,n]),b)return e.jsx(g,{variant:"loading",message:"Loading spreadsheet..."});if(p)return e.jsx(g,{variant:"error",message:p,fileUrl:c});const m=u[i];return!m||!m.data.length?e.jsx("div",{className:"flex items-center justify-center min-h-[600px]",style:{backgroundColor:"var(--surface-50)"},children:e.jsx("p",{className:"text-sm",style:{color:"var(--text-secondary)"},children:"No data available"})}):e.jsxs("div",{className:"w-full rounded-lg overflow-hidden border",style:{backgroundColor:"var(--surface-50)",borderColor:"var(--gold-bg)"},children:[u.length>1&&e.jsx("div",{className:"flex gap-2 px-4 py-2 border-b overflow-x-auto",style:{backgroundColor:"rgba(15, 25, 20, 0.7)",borderColor:"var(--white-10)"},children:u.map((t,a)=>e.jsx("button",{onClick:()=>f(a),className:"px-4 py-2 rounded text-sm font-medium transition-colors whitespace-nowrap",style:{backgroundColor:a===i?"var(--gold-20)":"var(--white-5)",color:a===i?"var(--gold)":"rgba(255, 255, 255, 0.7)",border:a===i?"1px solid var(--gold-border-hover)":"1px solid transparent"},children:t.name},t.name))}),e.jsx("div",{className:"overflow-auto",style:{maxHeight:"70vh"},children:e.jsx("table",{className:"w-full border-collapse",style:{backgroundColor:"rgba(15, 25, 20, 0.3)"},children:e.jsx("tbody",{children:m.data.map((t,a)=>e.jsx("tr",{style:{borderBottom:"1px solid var(--white-10)"},children:t.map((r,o)=>{const s=a===0;return e.jsx("td",{className:"px-4 py-2",style:{backgroundColor:s?"var(--gold-10)":"transparent",color:s?"var(--gold)":"rgba(255, 255, 255, 0.9)",fontWeight:s?600:400,fontSize:"13px"},children:r!=null?String(r):""},o)})},a))})})})]})}export{D as ExcelPreview};
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.