1import{H as b,D as g,G as E,v as i}from"./chunk-4N6VE7H7-C1-DtyEO.js";import{j as t}from"./jsx-runtime-DN4qZZRM.js";import{aE as j,aG as y}from"./server-CZ4_3qZu.js";import{f as R}from"./famguru_icon-DL2FSZhJ.js";import"./_commonjsHelpers-_d1bhYXs.js";import"./preload-helper-BlTxHScW.js";import"./index-BkhzYjtM.js";import"./exports-P9MXnzSC.js";const I=b(function(){const{fileId:s}=g(),[a]=E(),r=i.useRef(null),[p,w]=i.useState(!1),[l,h]=i.useState(null);return i.useEffect(()=>((async()=>{try{if(!s)throw new Error("File ID is required");r.current&&r.current.abort(),r.current=new AbortController;let e=a.get("filename");if(e)try{e=j(e)}catch(n){console.warn("Error sanitizing filename:",n),e="files"}let c=`/trips/requirementfiles/${s}/download-zip`;e&&(c+=`?filename=${encodeURIComponent(e)}`);const d=await y.api.get(c,{responseType:"blob",signal:r.current.signal}),x=new Blob([d.data],{type:"application/zip"}),m=window.URL.createObjectURL(x),o=document.createElement("a");o.href=m;const f=d.headers["content-disposition"];let u=e?.length?`${e}.zip`:"files.zip";if(f){const n=f.match(/filename="?([^";\n]+)"?/i);n&&n[1]&&(u=n[1])}o.setAttribute("download",u),document.body.appendChild(o),o.click(),w(!0),document.body.removeChild(o),window.URL.revokeObjectURL(m),setTimeout(()=>{window.history.back()},500)}catch(e){console.error("Error downloading file:",e),h("Error downloading file"),e?.code!=="ECONNABORTED"&&e?.name!=="AbortError"&&window.history.back()}})(),()=>{r.current&&r.current.abort()}),[s,a]),t.jsx("div",{className:"flex items-center justify-center min-h-screen",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx("img",{src:R}),!l&&t.jsx("h1",{className:"font-bold text-orange-600 text-xl my-5",children:p?"File download started":"Preparing files..."}),l&&t.jsx("div",{className:"text-base text-center text-red-600 mt-5",children:"Error fetching files"}),t.jsx("div",{className:"text-center text-orange-600 mt-5",children:t.jsx("a",{href:"/",className:"text-orange-600 underline text-sm font-semibold",children:"Back to FamGuru"})})]})})});export{I 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.