1import{c as w,e as S,u as E,aj as N,r as n,j as e,B as f,a5 as k}from"./index-_aijvlUq.js";import{E as C}from"./EmptyState-CPGKooqj.js";import{a as P}from"./Skeleton-B3Wj6cNd.js";function F(){const{showError:u}=w(),[p]=S(),d=E(),o=p.get("src")||"",i=p.get("title")||"Printable",l=N(o),[t,m]=n.useState(null),[h,x]=n.useState(l?null:"This printable link is not valid."),r=n.useMemo(()=>t?URL.createObjectURL(t):null,[t]);n.useEffect(()=>()=>{r&&URL.revokeObjectURL(r)},[r]),n.useEffect(()=>{if(!l)return;let s=!0;return fetch(o,{credentials:"include"}).then(async a=>{if(!a.ok)throw new Error(a.status===403?"You don't have access to this printable.":"Couldn't load the printable.");const v=await a.blob(),j=a.headers.get("Content-Disposition")||"",y=/filename="([^"]+)"/.exec(j)?.[1]||o.split("?")[0].split("/").pop().replace(/(\.pdf)?$/i,".pdf")||"printable.pdf";s&&m(new File([v],y,{type:"application/pdf"}))}).catch(a=>{s&&x(a.message||"Couldn't load the printable.")}),()=>{s=!1}},[o,l]);const c=!!t&&typeof navigator<"u"&&navigator.canShare?.({files:[t]}),b=()=>window.history.length>1?d(-1):d("/");async function g(){try{await navigator.share({files:[t],title:i})}catch(s){s?.name!=="AbortError"&&u("Couldn't open the share sheet. Use Save to phone instead.")}}return e.jsxs("div",{className:"px-4 pt-3 md:px-0 md:pt-0 space-y-4",children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900",children:i}),h?e.jsx(C,{card:!0,title:h,action:e.jsx(f,{variant:"secondary",onClick:b,children:"Back"})}):t?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[c&&e.jsx(f,{onClick:g,children:"Share or print"}),e.jsx("a",{href:r,download:t.name,className:k({variant:c?"secondary":"primary",size:"md"}),children:"Save to phone"})]}),e.jsx("p",{className:"text-sm text-gray-500",children:c?"Share or print opens your phoneâs share sheet â choose Print there.":"Save it, then open it from your downloads to print."}),e.jsx("object",{data:r,type:"application/pdf","aria-label":i,className:"w-full h-[70vh] rounded-xl border border-gray-200 bg-white",children:e.jsx("p",{className:"p-4 text-sm text-gray-500",children:"Your phone canât preview this PDF here. Use Share or print, or Save to phone."})})]}):e.jsx(P,{})]})}export{F as PrintPdfViewPage,F 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.