PageSourceSearch

https://toolbreezy.com/_next/static/chunks/82072-7a889b5ea19c5dc2.js

js toolbreezy.com collected 2026-10-02 01:48:27 UTC 47,350 bytes, 12 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[82072],{37816:(e,t,n)=>{function s(e,t,n){return a((t,n)=>e.convertToViewportPoint(t,n),t,n)}function l(e,t,n){return a((t,n)=>e.convertToPdfPoint(t,n),t,n)}function a(e,t,n){let s,l=Number.isFinite(t)?t:0,a=Number.isFinite(n)?n:0;try{s=e(l,a)}catch{return{x:0,y:0}}if(!Array.isArray(s))return{x:0,y:0};let r=Number(s[0]),i=Number(s[1]);return{x:Number.isFinite(r)?r:0,y:Number.isFinite(i)?i:0}}n.d(t,{X:()=>l,n:()=>s})},46906:(e,t,n)=>{n.d(t,{oh:()=>l});let s=["failed to fetch dynamically imported module","error loading dynamically imported module","importing a module script failed","unable to preload css","failed to load chunk","loading css chunk"];function l(e,t){return!function(e){if("ChunkLoadError"===function(e){if(e&&"object"==typeof e){let t=e.name;if("string"==typeof t)return t}return""}(e))return!0;let t=(function(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){let t=e.message;if("string"==typeof t)return t}return""})(e).toLowerCase();return!!t&&(!!(t.includes("loading chunk")&&t.includes("failed"))||s.some(e=>t.includes(e)))}(e)?t:"Part of this tool could not be downloaded, so it stopped before finishing. This is not a problem with your file. Either the connection dropped, or this page has been open since before the site was last updated. Reload the page and try again. Nothing was uploaded either way."}},53055:(e,t,n)=>{function s(e,t){return Number.isSafeInteger(e)?null===t?{lo:e,hi:e}:Number.isSafeInteger(t)?{lo:Math.min(e,t),hi:Math.max(e,t)}:null:null}function l(e,t,n){let s=Math.floor(n);if(!Number.isFinite(e)||!Number.isInteger(s)||s<1)return null;if(null===t)return e>s?null:{from:Math.max(e,1),to:s};if(!Number.isFinite(t))return null;let l=Math.min(e,t);if(1>Math.max(e,t)||l>s)return null;let a=e=>Math.min(Math.max(e,1),s);return{from:a(e),to:a(t)}}n.d(t,{H:()=>l,j:()=>s})},82072:(e,t,n)=>{n.r(t),n.d(t,{default:()=>V});var s=n(45993),l=n(75837),a=n(17832),r=n(2504),i=n(90029),o=n(41285),d=n(8890),u=n(36648),h=n(40647),c=n(77771),m=n(15662),f=n(30845),g=n(35323),p=n(41945),x=n(14552),b=n(53055);let w=/^\s*([-*•·●▪◦⁃–])\s+/,y=/^\s*(\d{1,3}|[ivxlcIVXLC]{1,6})[.)]\s+/;function k(e){let t=e.filter(e=>""!==e.str.trim()).sort((e,t)=>e.y-t.y||e.x-t.x),n=[],s=[],l=0,a=0;for(let e of t){let t=Math.max(1.5,.45*(a||e.h||10));s.length>0&&Math.abs(e.y-l)<=t?(s.push(e),a=Math.max(a,e.h)):(s.length>0&&n.push(s),s=[e],l=e.y,a=e.h)}return s.length>0&&n.push(s),n}function j(e){let t=new Map;for(let n of e){let e=n.str.trim().length;if(0===e)continue;let s=.6*Math.round(n.size/.6);t.set(s,(t.get(s)??0)+e)}let n=0,s=-1;for(let[e,l]of t)l>s&&(s=l,n=e);return n}function v(e,t){let n=[...e].sort((e,t)=>e.x-t.x),s=n[0];if(!s)return null;let l=Math.max(1.2*t,5),a=[],r=null,i="",o=s.x,d=0,u=null;for(let e of n){let t=0;u&&(t=e.x-(u.x+u.w));let n=null!==u&&t>=l;u&&(!(t>Math.max(.8,.22*(u.h||10)))||/\s$/.test(i)||/^\s/.test(e.str)||(i+=" ")),i+=e.str,o=Math.max(o,e.x+e.w),d=Math.max(d,e.h),!r||n?(r={x:e.x,right:e.x+e.w,text:e.str,items:[e]},a.push(r)):(!(t>Math.max(.8,.22*(u?.h||10)))||/\s$/.test(r.text)||/^\s/.test(e.str)||(r.text+=" "),r.text+=e.str,r.right=Math.max(r.right,e.x+e.w),r.items.push(e)),u=e}let h=i.replace(/\s+$/,"");if(""===h.trim())return null;let c=function(e){let t=new Map,n=new Map;for(let s of e){let e=s.str.trim().length;0!==e&&(t.set(s.font,(t.get(s.font)??0)+e),n.set(s.font,s.family))}let s="",l=-1;for(let[e,n]of t)n>l&&(l=n,s=e);return{font:s,family:n.get(s)??""}}(n);return{items:n,segs:a.map(e=>({...e,text:e.text.trim()})).filter(e=>""!==e.text),text:h,x:s.x,right:o,y:s.y,size:j(n)||s.size,height:d||10,font:c.font,family:c.family}}function N(e,t){let n=[];for(let s of k(e)){let e=v(s,t);e&&n.push(e)}return n}function $(e,t){let n=[],s=e.x,l=e.x+e.w;for(let e=0;e<t.length;e++){let a=t[e];a&&l>a[0]+1&&s<a[1]-1&&n.push(e)}return n}function M(e){return e.toLowerCase().replace(/\d+/g,"#").replace(/\s+/g," ").trim()}let S={Title:1,H:2,H1:1,H2:2,H3:3,H4:4,H5:5,H6:6},z=e=>(.6*Math.round(e/.6)).toFixed(1),P=[[/ff/g,"ff"],[/fi/g,"fi"],[/fl/g,"fl"],[/ffi/g,"ffi"],[/ffl/g,"ffl"],[/ſt/g,"st"],[/st/g,"st"]];function T(e,t){let n=e.replace(/­/g,"").replace(/ /g," ");
1if(!t)return n;for(let[e,t]of P)n=n.replace(e,t);return n.replace(/[‘’‛]/g,"'").replace(/[“”‟]/g,'"').replace(/…/g,"...").replace(/[‒–—]/g,"-")}function C(e){return e.replace(/([\\`*[\]])/g,"\\$1")}function F(e,t){let n=[];for(let t of e){let e=n[n.length-1];e&&e.role===t.role&&e.url===t.url?e.text+=t.text:n.push({...t})}let s="",l=0;for(let e of n){let n=C(T(e.text,t)),r=/^\s*/.exec(n)?.[0]??"",i=/\s*$/.exec(n)?.[0]??"",o=n.slice(r.length,n.length-i.length);if(""===o){s+=n;continue}if("plain"!==e.role&&o.replace(/\s/g,"").length>=2){let t="bold"===e.role?"**":"*";o=`${t}${o}${t}`}if(e.url){var a;o=`[${o}](${a=e.url,/[()\s<>]/.test(a)?`<${a.replace(/[<>]/g,"")}>`:a})`,l+=1}s+=`${r}${o}${i}`}return{text:s,links:l}}function H(e,t,n,s){let l=[],a=null;for(let r of e.items){if(a){let e=r.x-(a.x+a.w),t=Math.max(.8,.22*(a.h||10)),n=l[l.length-1],s=!n||/\s$/.test(n.text);!(e>t)||s||/^\s/.test(r.str)||l.push({text:" ",role:"plain",url:null})}l.push({text:r.str,role:s?"plain":t.fontRoles[r.font]??"plain",url:t.links?function(e,t){let n=e.x+e.w/2,s=e.y-e.h/2;for(let e of t)if(e.url&&n>=e.left&&n<=e.right&&s>=e.top&&s<=e.bottom)return e.url;return null}(r,n):null}),a=r}return l}let D=/^ {0,3}(`{3,}|~{3,})\s*(\S*)/;var L=n(37816);async function E(){let e=await Promise.all([n.e(31889),n.e(53046)]).then(n.bind(n,42975));return e.GlobalWorkerOptions.workerSrc=new n.U(n(91035)).toString(),e}function B(e){e?.destroy?.()}async function A(e,t){let n=await e.getPage(t);try{let e=n.getViewport({scale:1}),s=await n.getTextContent({includeMarkedContent:!0}),l=s.styles,a=[],r=[],i=0;for(let t of s.items){if(!("str"in t)){"beginMarkedContent"===t.type||"beginMarkedContentProps"===t.type?r.push("string"==typeof t.id?t.id:""):"endMarkedContent"===t.type&&r.pop();continue}if(""===t.str)continue;let n=t.transform,s=(0,L.n)(e,Number(n[4]),Number(n[5])),o=Math.hypot(Number(n[2])||0,Number(n[3])||0),d=Number(t.height)||0,u=o>0?o:d,h=null;for(let e=r.length-1;e>=0;e--){let t=r[e];if(t){h=t;break}}let c="string"==typeof t.fontName?t.fontName:"";a.push({order:i++,str:t.str,x:s.x,y:s.y,w:Number(t.width)||0,h:d>0?d:u,size:u,font:c,family:function(e){let t=e.toLowerCase();return t.includes("monospace")?"monospace":t.includes("sans")?"sans-serif":t.includes("serif")?"serif":"sans-serif"}(String(l[c]?.fontFamily??"")),mc:h})}let o=[],d=[];try{d=await n.getAnnotations()}catch{d=[]}for(let t of d){if(!t||"object"!=typeof t||"Link"!==t.subtype)continue;let n=t.rect;if(!Array.isArray(n)||n.length<4)continue;let s=(0,L.n)(e,Number(n[0]),Number(n[1])),l=(0,L.n)(e,Number(n[2]),Number(n[3])),a=s.x,r=s.y,i=l.x,d=l.y;o.push({left:Math.min(a,i),right:Math.max(a,i),top:Math.min(r,d),bottom:Math.max(r,d),url:"string"==typeof t.url&&""!==t.url?t.url:null})}let u=new Map;try{let e=await n.getStructTree();e&&(u=function(e){let t=new Map,n=(e,s)=>{if(!e||"object"!=typeof e)return;let l=S["string"==typeof e.role?e.role:""]??s;if("content"===e.type&&"string"==typeof e.id&&l>0)return void t.set(e.id,l);let a=e.children;if(Array.isArray(a))for(let e of a)n(e,l)};return n(e,0),t}(e))}catch{u=new Map}return{number:t,width:e.width,height:e.height,items:a,tagged:u,hasTags:u.size>0,links:o}}finally{n.cleanup()}}var R=n(35339),J=n(46906);let O="toolbreezy.pdf-to-markdown",I={headingStyle:"atx",bullet:"-",pageBreaks:!1,normalize:!0,joinHyphens:!0,stripEdges:!0,columns:"auto",links:!0,tables:!0},K="flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",U=[[0,"Body text"],[1,"H1"],[2,"H2"],[3,"H3"],[4,"H4"],[5,"H5"],[6,"H6"]];function V(){let[e,t]=(0,l.useState)(null),[n,S]=(0,l.useState)([]),[P,L]=(0,l.useState)(0),[V,_]=(0,l.useState)(0),[q,X]=(0,l.useState)(!1),[Y,G]=(0,l.useState)({done:0,total:0}),[Z,Q]=(0,l.useState)(""),[ee,et]=(0,l.useState)(""),[en,es]=(0,l.useState)(!1),[el,ea]=(0,l.useState)(""),[er,ei]=(0,l.useState)([]),[eo,ed]=(0,l.useState)(I),[eu,eh]=(0,l.useState)("tags"),[ec,em]=(0,l.useState)({}),[ef,eg]=(0,l.useState)({}),[ep,ex]=(0,l.useState)([]),[eb,ew]=(0,l.useState)(""),[ey,ek]=(0,l.useState)(""),[ej,ev]=(0,l.useState)(0),[eN,e$]=(0,l.useState)("markdown"),[eM,eS]=(0,l.useState)(""),ez=(0,l.useRef)(null),eP=(0,l.useRef)(null),eT=(0,l.useRef)(new Map),eC=(0,l.useRef)(0);(0,l.useEffect)(()=>{ed(function(){try{let e=window.localStorage.getItem(O);if(!e)return I;let t=JSON.parse(e);return{headingStyle:"setext"===t.headingStyle?"setext":"atx",bullet:"*"===t.bullet?"*":"-",pageBreaks:!0===t.pageBreaks,normalize:!1!==t.normalize,joinHyphens:!1!==t.joinHyphens,stripEdges:!1!==t.stripEdges,columns:"single"===t.columns?"single":"auto",links:!1!==t.links,tables:!1!==t.tables}}catch{return I}}())},[]),(0,a.Vd)(O,()=>JSON.stringify(eo),[eo]);let eF=(0,l.useCallback)(async e=>{let t=eC.current+1;eC.current=t,X(!0),Q(""),et(""),ea(""),S([]),ei([]),L(0),_(0),G({done:0,total:0}),ew(""),ek(""),em({}),eg({}),ex([]),eh("tags"),e$("markdown"),eT.current.clear(),B(eP.current),eP.current=null;try{let n=await E(),s=await e.arrayBuffer(),l=await n.getDocument({data:s}).promise;if(eC.current!==t)return void B(l);eP.current=l,L(l.numPages),ev(t)}catch(n){if(eC.current!==t)return;let e=n?.name??"";Q((0,J.oh)(n,"PasswordException"===e?"This PDF is locked with a password, so nothing can be read out of it until the password comes off. Our PDF Password Remover does that part.":"Could not open that PDF. The file may be damaged, or it may not be a PDF at all.")),X(!1)}},[]);(0,l.useEffect)(()=>{let e=eP.current;if(!e||0===ej)return;let t=eC.current+1;eC.current=t;let n=!1;return async function(e){let s=function(e,t){let n=Math.max(1,Math.floor(t)),s=e.replace(/\s*-\s*/g,"-").trim();if(""===s){let e=[];for(let t=1;t<=n;t++)e.push(t);return{pages:e,refused:null}}let l=new Set;for(let e of s.split(/[,;
1\s]+/)){if(""===e)continue;let t=/^(\d{1,7})(?:-(\d{1,7})?)?$/.exec(e);if(!t)return{pages:[],refused:`"${e}" is not a page number or a range like 1-12.`};let s=t[1];if(void 0===s)continue;let a=t[2],r=void 0===a&&e.includes("-"),i=Number(s),o=void 0!==a?Number(a):r?null:i,d=(0,b.H)(i,o,n);if(i<1||null!==o&&o<1)return{pages:[],refused:`Pages start at 1, so "${e}" has nowhere to land.`};if(null===d||i>n||null!==o&&o>n)return{pages:[],refused:`You asked for "${e}" and this file has ${n} ${1===n?"page":"pages"}.`};for(let e=Math.min(d.from,d.to);e<=Math.max(d.from,d.to);e++)l.add(e)}return 0===l.size?{pages:[],refused:"That page box does not name a page."}:{pages:[...l].sort((e,t)=>e-t),refused:null}}(ey,e.numPages);if(null!==s.refused){et(s.refused),S([]),ei([]),_(0),X(!1);return}et("");let l=s.pages.slice(0,300),a=eT.current,r=l.filter(e=>!a.has(e)).length;a.size+r>300&&a.clear(),_(s.pages.length),X(!0),Q(""),G({done:0,total:l.length});let i=[],o=[],d=0;try{for(let s of l){if(n||eC.current!==t)return;let r=a.get(s);if(r)i.push(r);else try{let t=await A(e,s);a.set(s,t),i.push(t)}catch{o.push(s)}if(d+=1,n||eC.current!==t)return;G({done:d,total:l.length}),await new Promise(e=>setTimeout(e,0))}if(n||eC.current!==t)return;ei(o),S(i)}catch{n||eC.current!==t||(Q("Stopped partway through reading this PDF. The file may be damaged."),S([]),ei([]))}finally{n||eC.current!==t||X(!1)}}(e),()=>{n=!0}},[ej,ey]),(0,l.useEffect)(()=>{let e=setTimeout(()=>ek(eb),350);return()=>clearTimeout(e)},[eb]),(0,l.useEffect)(()=>()=>{eC.current+=1,B(eP.current),eP.current=null},[]);let eH=(0,l.useCallback)(e=>{if(!e)return;if("application/pdf"!==e.type&&!/\.pdf$/i.test(e.name))return void Q("That is not a PDF. This tool reads PDF files only.");let n=e.size/1048576;if(n>100)return void Q(`That file is ${n.toFixed(0)} MB and the ceiling here is 100 MB, because the whole thing is held in your own browser's memory.`);t(e),eF(e)},[eF]);(0,l.useEffect)(()=>{function e(e){let t=e.clipboardData?.files?.[0];t&&("application/pdf"===t.type||/\.pdf$/i.test(t.name))&&(e.preventDefault(),eH(t))}return window.addEventListener("paste",e),()=>window.removeEventListener("paste",e)},[eH]);let eD=(0,l.useMemo)(()=>({headingStyle:eo.headingStyle,bullet:eo.bullet,pageBreaks:eo.pageBreaks,normalize:eo.normalize,joinHyphens:eo.joinHyphens,stripEdges:eo.stripEdges,restored:ep,columns:eo.columns,headingSource:eu,levels:ec,fontRoles:ef,links:eo.links,tables:eo.tables}),[eo,ep,eu,ec,ef]),eL=(0,l.useMemo)(()=>0===n.length?null:function(e,t,n){let s=new Set(n.restored),l=[],a=new Map,r=0,i=e.map(e=>{let t=[],n=0,s=0;for(let a of e.items){let i=a.str.trim();if(""===i)continue;n+=i.length;let o=function(e){if(e.includes("(cid:"))return"no character map in the font";let t=0,n=0;for(let s of e){if(/\s/.test(s))continue;t+=1;let e=s.codePointAt(0)??0;"�"===s||e<32?n+=1:e>=57344&&e<=63743&&(n+=1)}return 0===t?null:n/t>=.34?"glyphs the font could not map to characters":null}(a.str);if(o){r+=1,(s+=1)<=12&&l.push({page:e.number,text:i.slice(0,60),font:a.font,reason:o});continue}t.push(a)}return a.set(e.number,s),{page:e,items:t,rawChars:n}}),o=[];for(let e of i)o.push(...e.items);let d=j(o)||10,u=[],h=new Map;for(let e of i){let t=N(e.items,d),n=.11*e.page.height,s=.89*e.page.height,l=[];for(let e of t){if(e.y>n&&e.y<s)continue;let t=M(e.text);l.push(t);let a=h.get(t);if(a)a.pages+=1;else{var c;h.set(t,{sample:e.text.slice(0,70),pages:1,kind:(c=e.text,/^\s*(?:page\s+)?\d{1,4}(?:\s*(?:\/|of)\s*\d{1,4})?\s*$/i.test(c))?"page number":"repeated"})}}u.push(l)}let m=n.stripEdges?function(e){let t=new Set;if(e.length<3)return t;let n=new Map;for(let t of e)for(let e of new Set(t))n.set(e,(n.get(e)??0)+1);let s=Math.max(2,Math.ceil(.6*e.length));for(let[e,l]of n)""!==e&&l>=s&&t.add(e);return t}(u):new Set;if(n.stripEdges)for(let[e,t]of h)"page number"===t.kind&&m.add(e);let f=new Set([...m].filter(e=>!s.has(e))),g=[...h.entries()].filter(([e])=>m.has(e)).map(([e,t])=>({key:e,sample:t.sample,pages:t.pages,kind:t.kind})).sort((e,t)=>t.pages-e.pages),p=e.filter(e=>e.hasTags).length,x="tags"===n.headingSource&&p>0,b=i.map(e=>{let t="single"===n.columns?[]:function(e,t){let n=k(e);if(n.length<8)return[];let s=1/0,l=-1/0;for(let t of e)""!==t.str.trim()&&(t.x<s&&(s=t.x),t.x+t.w>l&&(l=t.x+t.w));let a=l-s;if(!Number.isFinite(a)||a<=0)return[];let r=a/240,i=Array(240).fill(0);for(let e of n){let t=new Set;for(let n of e){let e=Math.max(0,Math.floor((n.x-s)/r)),l=Math.min(239,Math.ceil((n.x+n.w-s)/r)-1);for(let n=e;n<=l;n++)t.add(n)}for(let e of t)i[e]=(i[e]??0)+1}let o=Math.max(1,Math.floor(.12*n.length)),d=Math.max(3*r,.025*a,.015*t),u=Math.floor(19.2),h=[],c=-1;for(let e=0;e<240;e++){let t=(i[e]??0)<=o;if(t&&c<0&&(c=e),c>=0&&(!t||239===e)){let n=t?e:e-1;if(c>u&&n<239-u){let e=s+c*r,t=s+(n+1)*r;t-e>=d&&h.push([e,t])}c=-1}}if(0===h.length||h.length>2)return[];let m=[],f=s;for(let e of h)m.push([f,e[0]]),f=e[1];m.push([f,l]);let g=Math.max(4,Math.floor(.15*n.length));for(let e of m){if(e[1]-e[0]<.12*a)return[];let t=0,s=0;for(let l of n){let n=1/0,a=-1/0;for(let t of l)t.x<e[0]-1||t.x+t.w>e[1]+1||(n=Math.min(n,t.x),a=Math.max(a,t.x+t.w));!(a<n)&&(t+=1,a-n>=(e[1]-e[0])*.65&&(s+=1))}if(t<g||s<.5*t)return[]}return m}(e.items,e.page.width),s=function(e,t,n){if(t.length<2)return N(e,n);let s=[],l=t.map(()=>[]),a=()=>{for(let e of l)for(let t of e){let e=v(t,n);e&&s.push(e)}l=t.map(()=>[])};for(let r of k(e)){if(r.some(e=>$(e,t).length>1)){a();let e=v(r,n);e&&s.push(e);continue}let e=t.map(()=>[]);for(let n of r){let s=$(n,t),l=1===s.length?s[0]??0:function(e,t){let n=e.x+e.w/2,s=0,l=1/0;for(let e=0;e<t.length;e++){let a=t[e];if(!a)continue;let r=n<a[0]?a[0]-n:n>a[1]?n-a[1]:0;r<l&&(l=r,s=e)}return s}(n,t);e[l]?.push(n)}for(let n=0;n<t.length;n++){let t=e[n],s=l[n];t&&s&&t.length>0&&s.push(t)}}return a(),s}(e.items,t,d),l=.11*e.page.height,a=.89*e.page.height,r=[],i=s.filter(e=>!((!(e.y>l)||!(e.y<a))&&f.has(M(e.text)))||(r.push(e),!1));return{...e,bands:t,lines:i,stripped:r}}),S=[];for(let e of b)S.push(...e.lines);let P=(function(e,t){let n=new Map;for(let s of e){if(s.size<=1.06*t||s.text.length>180)continue;let e=z(s.size),l=n.get(e);l?(l.lines+=1,l.sample.length<8&&s.text.length>l.sample.length&&(l.sample=s.text)):n.set(e,{size:s.size,lines:1,sample:s.text})}let s=[...n.entries()].sort((e,t)=>
1t[1].size-e[1].size),l=0;return s.map(([e,t])=>{let n=t.lines>=2||t.sample.trim().length>=4;return n&&(l+=1),{key:e,size:t.size,lines:t.lines,sample:t.sample.slice(0,90),level:n?Math.min(l,4):0}})})(S,d).map(e=>({...e,level:n.levels[e.key]??e.level})),D={};for(let e of P)D[e.key]=e.level;let L=(function(e,t){let n=new Map,s=0;for(let l of e){let e=l.str.trim().length;if(0===e||Math.abs(l.size-t)>.6)continue;s+=e;let a=n.get(l.font);a?(a.chars+=e,a.sample.length<24&&l.str.trim().length>a.sample.length&&(a.sample=l.str.trim())):n.set(l.font,{family:l.family,chars:e,sample:l.str.trim()})}return 0===s?[]:[...n.entries()].sort((e,t)=>t[1].chars-e[1].chars).map(([e,t],n)=>{let l=t.chars/s;return{font:e,family:t.family,chars:t.chars,share:l,sample:t.sample.slice(0,40),role:1===n&&l<=.25?"bold":"plain"}})})(o,d).map(e=>({...e,role:n.fontRoles[e.font]??e.role})),E={};for(let e of L)E[e.font]=e.role;let B={...n,fontRoles:E,levels:D},A=[],R=[],J=[],O=[];for(let e of b){let{page:t,lines:s}=e,l=e.items.reduce((e,t)=>e+t.str.trim().length,0),r=e.rawChars>=12;r||O.push(t.number);let i=new Set,o={number:t.number,hasText:r,unreadable:r&&l<12,chars:l,columns:0===e.bands.length?1:e.bands.length,reordered:function(e){let t=0,n=-1;for(let s of e){let e=1/0;for(let t of s.items)t.order<e&&(e=t.order);isFinite(e)&&(e<n?t+=1:n=e)}return t}(s),headings:0,tables:0,weakTables:0,lists:0,links:0,internalLinks:t.links.filter(e=>!e.url).length,hyphenJoins:0,stripped:e.stripped.length,excluded:a.get(t.number)??0,unwritten:0},u=s.map(e=>{let n=function(e,t,n,s,l){if(n&&t.hasTags){let n=new Map;for(let s of e.items){if(!s.mc)continue;let e=t.tagged.get(s.mc);void 0!==e&&n.set(e,(n.get(e)??0)+s.str.trim().length)}let s=0,l=0;for(let[e,t]of n)t>l&&(l=t,s=e);return s}let a=e.size<=1.06*s||e.text.length>180?null:z(e.size);return null===a?0:l[a]??0}(e,t,x,d,D);if(n>0)return{line:e,kind:"heading",level:n,marker:"",markerKind:"bullet",markerLength:0};let s=function(e){let t=w.exec(e);if(t&&t[0])return{kind:"bullet",marker:t[1]??"-",length:t[0].length};let n=y.exec(e);return n&&n[0]?{kind:"number",marker:n[1]??"1",length:n[0].length}:null}(e.text);return s?{line:e,kind:"list",level:0,marker:s.marker,markerKind:s.kind,markerLength:s.length}:"monospace"===e.family?{line:e,kind:"code",level:0,marker:"",markerKind:"bullet",markerLength:0}:{line:e,kind:"text",level:0,marker:"",markerKind:"bullet",markerLength:0}}),h=n.tables?function(e,t,n){let s=Math.max(.7*t,3),l=[],a=-1,r=(t,n)=>{if(n-t+1<2)return;let a=e.slice(t,n+1),r=[];for(let e of a)for(let t of e.segs)r.push(t.x);r.sort((e,t)=>e-t);let i=[];for(let e=0;e<a.length;e++){let t=a[e];if(t)for(let n of t.segs){let t=i.find(e=>Math.abs(e.x-n.x)<=s);t?(t.hits+=1,t.rows.add(e)):i.push({x:n.x,hits:1,rows:new Set([e])})}}let o=i.filter(e=>e.rows.size>=Math.max(2,Math.ceil(.5*a.length))).map(e=>e.x).sort((e,t)=>e-t);if(o.length<3)return;let d=[],u=0,h=0;for(let e of a){let t=Array(o.length).fill("");for(let n of e.segs){let e=0,l=1/0;for(let t=0;t<o.length;t++){let s=o[t];if(void 0===s)continue;let a=Math.abs(n.x-s);a<l&&(l=a,e=t)}h+=1,l<=s&&(u+=1),t[e]=""===t[e]?n.text:`${t[e]} ${n.text}`}d.push(t)}if(0===h)return;let c=1/0,m=-1/0,f=1/0,g=-1/0;for(let e of a)c=Math.min(c,e.x),m=Math.max(m,e.right),f=Math.min(f,e.y-e.height),g=Math.max(g,e.y);l.push({from:t,to:n,boundaries:o,rows:d,confidence:u/h,box:{x:c,y:f,w:m-c,h:g-f}})};for(let t=0;t<e.length;t++){let s=e[t],l=!!s&&s.segs.length>=3&&!n?.(t);l&&a<0&&(a=t),!l&&a>=0&&(r(a,t-1),a=-1)}return a>=0&&r(a,e.length-1),l}(s,d,e=>u[e]?.kind==="heading"):[],c=new Map;for(let e=0;e<h.length;e++){let t=h[e];if(t)for(let n=t.from;n<=t.to;n++)c.set(n,e)}let m=[];for(let e=1;e<s.length;e++){let t=s[e],n=s[e-1];if(!t||!n)continue;let l=t.y-n.y;l>0&&m.push(l)}let f=function(e){if(0===e.length)return 0;let t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2),s=t[n]??0;return t.length%2==1?s:((t[n-1]??s)+s)/2}(m)||1.2*d,g=0,p=1/0;for(let e of s)e.right>g&&(g=e.right),e.x<p&&(p=e.x);Number.isFinite(p)||(p=0);let b=[],k=[],j=()=>{if(0===k.length)return;let e=F(k,n.normalize);k=[];let t=e.text.trim();""!==t&&(o.links+=e.links,b.push(t.replace(/^(\s*)(#{1,6}\s|>\s|\d{1,3}[.)]\s|[-+]\s)/,(e,t,n)=>`${t}\\${n}`)))},v=(e,s)=>{let l=H(e,B,t.links,!1);if(s&&k.length>0){let e=k[k.length-1],t=l[0]?.text??"",s=e?.text??"";n.joinHyphens&&/[A-Za-zÀ-ɏ][-‐]$/.test(s)&&/^[a-zß-ɏ]/.test(t)&&!/\d[-‐]$/.test(s)&&e?(e.text=e.text.slice(0,-1),o.hyphenJoins+=1):k.push({text:" ",role:"plain",url:null})}for(let t of(k.push(...l),e.items))i.add(t.order)},N=0;for(;N<u.length;){let e=c.get(N),l=void 0===e?void 0:h[e];if(l){j();for(let e=l.from;e<=l.to;e++)for(let t of s[e]?.items??[])i.add(t.order);
1if(l.confidence>=.75){o.tables+=1;let e=l.rows[0]??[],t=e=>C(T(e,n.normalize)).replace(/\|/g,"\\|")||" ",s=[`| ${e.map(t).join(" | ")} |`,`| ${e.map(()=>"---").join(" | ")} |`,...l.rows.slice(1).map(e=>`| ${e.map(t).join(" | ")} |`)];b.push(s.join("\n"))}else{o.weakTables+=1,J.push({page:t.number,rows:l.rows.length,confidence:l.confidence,box:l.box});let e=l.rows.map(e=>e.filter(e=>""!==e).join("    ")).join("\n");b.push(`<!-- page ${t.number}: these lines line up like a table but not cleanly enough to rebuild, so they are left as they were -->
2
3\`\`\`
4${T(e,n.normalize)}
5\`\`\``)}N=l.to+1;continue}let a=u[N];if(!a){N+=1;continue}if("heading"===a.kind){j();let e=[a.line],s=N+1;for(;s<u.length;){let t=u[s],n=e[e.length-1];if(!t||!n||"heading"!==t.kind||t.level!==a.level||t.line.y-n.y>1.8*n.height)break;e.push(t.line),s+=1}let l=[];for(let n=0;n<e.length;n++){let s=e[n];if(s)for(let e of(n>0&&l.push({text:" ",role:"plain",url:null}),l.push(...H(s,B,t.links,!0)),s.items))i.add(e.order)}let r=F(l,n.normalize),d=r.text.trim();if(""!==d)if(o.headings+=1,o.links+=r.links,"setext"===n.headingStyle&&a.level<=2){let e=(1===a.level?"=":"-").repeat(Math.min(80,Math.max(3,d.length)));b.push(`${d}
6${e}`)}else b.push(`${"#".repeat(Math.min(6,a.level))} ${d}`);N=s;continue}if("code"===a.kind){j();let e=[];for(;N<u.length;){let t=u[N];if(!t||"code"!==t.kind)break;for(let n of(e.push(t.line),t.line.items))i.add(n.order);N+=1}b.push(`\`\`\`
7${e.map(e=>T(e.text,n.normalize)).join("\n")}
8\`\`\``);continue}if("list"===a.kind){j();let e=Math.max(0,Math.round((a.line.x-p)/Math.max(1.2*d,4))),s="number"===a.markerKind?`${a.marker}.`:n.bullet,l=H(a.line,B,t.links,!1),r=a.markerLength;for(;r>0&&l.length>0;){let e=l[0];if(!e)break;e.text.length<=r?(r-=e.text.length,l.shift()):(e.text=e.text.slice(r),r=0)}for(let e of a.line.items)i.add(e.order);let u=F(l,n.normalize),h=u.text.trim();""!==h&&(o.lists+=1,o.links+=u.links,b.push(`${"  ".repeat(Math.min(4,e))}${s} ${h}`)),N+=1;continue}let r=N>0?u[N-1]:void 0,m=!0;if(r&&"text"===r.kind&&k.length>0){let e=a.line.y-r.line.y,t=r.line.right<.82*g&&/[.!?:]["'’)\]]?$/.test(r.line.text),n=a.line.x>r.line.x+Math.max(6,a.line.height);m=e<=0||e>1.45*f||t||n}m&&j(),v(a.line,!m),N+=1}j();let $=new Set;for(let t of e.stripped)for(let e of t.items)$.add(e.order);for(let t of e.items)""!==t.str.trim()&&(i.has(t.order)||$.has(t.order)||(o.unwritten+=1));R.push(o);let M=b.join("\n\n").trim();n.pageBreaks&&(M=""===M?`<!-- page ${t.number} -->`:`<!-- page ${t.number} -->
9
10${M}`),""!==M&&A.push(M)}let I=A.join("\n\n").replace(/\n{3,}/g,"\n\n").trim(),K=e=>R.reduce((t,n)=>t+e(n),0),U={headings:K(e=>e.headings),tables:K(e=>e.tables),weakTables:K(e=>e.weakTables),lists:K(e=>e.lists),links:K(e=>e.links),internalLinks:K(e=>e.internalLinks),reordered:K(e=>e.reordered),hyphenJoins:K(e=>e.hyphenJoins),stripped:K(e=>e.stripped),excluded:r,unwritten:K(e=>e.unwritten),columnPages:R.filter(e=>e.columns>1).length},V=e[0]?.number??0,W=e[e.length-1]?.number??0,_=[];if(e.length>0&&e.length<t&&_.push(`Converted pages ${V} to ${W} of ${t}. The rest of this document is not in this file.`),O.length>0&&O.length<e.length){let e=O.slice(0,25).join(", "),t=O.length>25?`, and ${O.length-25} more`:"";_.push(`${O.length} of these pages carry no text layer, so nothing was converted from them: ${e}${t}.`)}U.unwritten>0&&_.push(`${U.unwritten} text runs were read but not written into the markdown. Check the page report.`);let q=0===_.length?I:`${_.map(e=>`<!-- ${e} -->`).join("\n")}
11
12${I}`;return{markdown:I,fileText:q,notices:_,words:function(e){let t=e.trim();return""===t?0:t.split(/\s+/).length}(I),allBlank:e.length>0&&O.length===e.length,report:{method:x?"tags":P.length>0?"sizes":"none",taggedPages:p,bodySize:d,clusters:P,fonts:L,removals:g,excluded:l,excludedTotal:r,weakTables:J,pages:R,blankPages:O,totals:U}}}(n,P,eD),[n,P,eD]),eE=eL?.report??null,eB=(0,l.useMemo)(()=>eL?function(e){let t=e.split("\n"),n=[],s=null;for(let e=0;e<t.length;e++){let l=t[e]??"",a=D.exec(l);if(null!==s){a&&a[1]&&a[1][0]===s[0]&&a[1].length>=s.length&&!a[2]&&(s=null);continue}if(a&&a[1]){s=a[1];continue}let r=/^(#{1,6})\s+(.+)$/.exec(l);if(r){n.push({level:r[1]?.length??1,text:r[2]??""});continue}let i=t[e+1]??"",o=l.trim();!(""===o||o.startsWith("|"))&&(/^=+$/.test(i)?n.push({level:1,text:o}):/^-{3,}$/.test(i)&&n.push({level:2,text:o}))}return n}(eL.markdown):[],[eL]),eA=null!==eE&&("tags"!==eE.method||eE.taggedPages<eE.pages.length),eR=V>300&&n.length>0,eJ=n[0]?.number??0,eO=n[n.length-1]?.number??0,eI=null!==eL&&!eL.allBlank&&""!==eL.markdown.trim();function eK(e){eC.current+=1,B(eP.current),eP.current=null,eT.current.clear(),t(null),S([]),ei([]),L(0),_(0),X(!1),Q(""),et(""),ea(e),ew(""),ek(""),em({}),eg({}),ex([]),eh("tags"),ev(0),G({done:0,total:0}),ez.current&&(ez.current.value="")}let eU=(e,t)=>ed(n=>({...n,[e]:t}));return(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(g.J,{htmlFor:"pdf-to-markdown-input",children:"Choose your PDF"}),(0,s.jsxs)("div",{onDragOver:e=>{e.preventDefault(),es(!0)},onDragLeave:()=>es(!1),onDrop:e=>{e.preventDefault(),es(!1),eH(e.dataTransfer.files?.[0])},onClick:()=>ez.current?.click(),className:(0,x.cn)("flex cursor-pointer flex-col items-center justify-center rounded-lg border-2 border-dashed p-8 text-center transition-colors",en?"border-primary bg-accent":"border-input hover:border-foreground
12/30 hover:bg-accent/50"),children:[(0,s.jsx)(r.A,{className:"mb-2 size-8 text-muted-foreground"}),(0,s.jsx)("p",{className:"font-medium",children:e?e.name:"Drag a PDF into the box, or click to choose one"}),(0,s.jsxs)("p",{className:"mt-1 flex items-center gap-1 text-sm text-muted-foreground",children:[(0,s.jsx)(i.A,{className:"size-4"})," Paste one too. Up to ",300," pages a pass and"," ",100," MB, read on your own computer and never uploaded."]})]}),(0,s.jsx)("input",{ref:ez,id:"pdf-to-markdown-input",type:"file",accept:"application/pdf,.pdf",className:"hidden",onChange:e=>{eH(e.target.files?.[0]),ez.current&&(ez.current.value="")}})]}),Z&&(0,s.jsx)("p",{className:"text-sm text-destructive",children:Z}),el&&(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:el}),q&&(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-sm text-muted-foreground",children:[(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)(o.A,{className:"size-4 animate-spin"}),0===Y.total?"Opening the file":`Reading page ${Math.min(Y.done+1,Y.total)} of ${Y.total}`]}),(0,s.jsx)(c.$,{type:"button",size:"sm",variant:"outline",onClick:()=>eK("Stopped before it finished, so there is nothing to convert."),children:"Stop"})]}),er.length>0&&!q&&(0,s.jsxs)("p",{className:"text-sm text-destructive",children:[1===er.length?"Page":"Pages"," ",er.slice(0,40).join(", "),er.length>40?`, and ${er.length-40} more`:""," could not be read at all, so nothing from"," ",1===er.length?"that page":"those pages"," is in the output below."]}),ee&&!q&&(0,s.jsxs)("div",{className:"space-y-2 rounded-lg border border-destructive/40 bg-destructive/5 p-4",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-destructive",children:ee}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Nothing was converted, because converting a range you did not ask for is worse than saying no. Fix the box below and it goes again."}),(0,s.jsxs)("div",{className:"w-56 space-y-1",children:[(0,s.jsx)(g.J,{htmlFor:"pdf-to-markdown-pages-fix",className:"text-xs",children:"Pages to convert"}),(0,s.jsx)(f.p,{id:"pdf-to-markdown-pages-fix",value:eb,placeholder:"1-12, 20, 44-",onChange:e=>ew(e.target.value)})]})]}),eL&&eE&&(0,s.jsxs)(s.Fragment,{children:[eL.allBlank?(0,s.jsxs)("div",{className:"space-y-2 rounded-lg border border-destructive/40 bg-destructive/5 p-4",children:[(0,s.jsxs)("p",{className:"flex items-center gap-2 font-medium text-destructive",children:[(0,s.jsx)(d.A,{className:"size-4"})," There is no text in this PDF to convert."]}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Every page you picked is a picture of a document rather than a document. Nothing in it can be selected or searched, so a converter has nothing to read and a markdown file would come out empty. That is why there is no download button here."}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Reading a scan takes character recognition, which means downloading a recognition model to your browser, and nothing on this site touches the network while it works. Our Scanned PDF Converter is built for that job."})]}):(0,s.jsxs)("div",{className:"flex flex-wrap items-end gap-5 rounded-lg border bg-card p-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-3xl font-semibold tabular-nums",children:eL.words.toLocaleString()}),(0,s.jsx)("div",{className:"text-xs text-muted-foreground",children:"words of markdown"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-lg font-medium tabular-nums",children:eE.totals.headings}),(0,s.jsx)("div",{className:"text-xs text-muted-foreground",children:"headings"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-lg font-medium tabular-nums",children:eE.totals.tables}),(0,s.jsxs)("div",{className:"text-xs text-muted-foreground",children:["tables rebuilt",eE.totals.weakTables>0?`, ${eE.totals.weakTables} left alone`:""]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-lg font-medium tabular-nums",children:eE.totals.links}),(0,s.jsx)("div",{className:"text-xs text-muted-foreground",children:"links kept"})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"text-lg font-medium tabular-nums",children:[n.length," of ",P]}),(0,s.jsx)("div",{className:"text-xs text-muted-foreground",children:"pages converted"})]})]}),eL.notices.length>0&&(0,s.jsxs)("div",{className:"space-y-1 rounded-lg border border-amber-500/40 bg-amber-500/5 p-3 text-sm",children:[eL.notices.map(e=>(0,s.jsx)("p",{children:e},e)),(0,s.jsx)("p",{className:"text-muted-foreground",children:"Each of these is written into the top of the downloaded file as well, so a document that came over in pieces cannot look complete once it is out of this tab."})]}),eR&&(0,s.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Your pages box covers ",V," pages and ",300," are read in one pass, so this is pages ",eJ," to ",eO,". Put ",eO+1,"- in the box to carry on from there."]}),!eL.allBlank&&(0,s.jsxs)("div",{className:"space-y-3 rounded-lg border p-4",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsxs)("h3",{className:"flex items-center gap-2 text-sm font-semibold",children:["tags"===eE.method?(0,s.jsx)(u.A,{className:"size-4"}):(0,s.jsx)(h.A,{className:"size-4"}),"Heading map"]}),eE.taggedPages>0&&(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs",children:[(0,s.jsx)(c.$,{type:"button",size:"sm",variant:"tags"===eu?"default":"outline",onClick:()=>eh("tags"),children:"Use the PDF tags"}),(0,s.jsx)(c.$,{type:"button",size:"sm",variant:"sizes"===eu?"default":"outline",onClick:()=>eh("sizes"),children:"Measure sizes instead"})]})]}),"tags"===eE.method?(0,s.jsxs)("p",{className:"text-sm",children:["This PDF carries real heading tags on ",eE.taggedPages," of ",n.length," ","pages, so on those pages the outline is the one the document declares about itself rather than anything measured here, which beats a guess every time."," ",eE.taggedPages<eE.pages.length?"The pages that carry no tags fall back to measured font sizes, and those sizes are listed below where you can change them. ":"","If the tagging is wrong, and plenty of exported PDFs are tagged badly, switch to measured sizes and the controls below take over."]}):(0,s.jsxs)("p",{className:"text-sm",children:[eE.taggedPages>0?"Measuring font sizes and ignoring the tags in this file, at your request.":"No heading tags in this PDF, so the levels are measured."," ","Body text here measures about ",eE.bodySize.toFixed(1)," pt.",eE.cluster
12s.length>0?" Every size above that is listed below with what it was found on. Change any one and the markdown re-renders.":""]}),"none"===eE.method&&(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Nothing in this document is set meaningfully larger than body text, so no headings were found. Some documents really are one long block of prose. If yours has headings that are bold rather than bigger, they are in the output as plain paragraphs."}),eA&&eE.clusters.length>0&&(0,s.jsxs)("div",{className:"space-y-2",children:[eE.clusters.map(e=>(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 rounded-md border bg-card p-2.5",children:[(0,s.jsxs)("span",{className:"w-20 shrink-0 text-sm font-medium tabular-nums",children:[e.size.toFixed(1)," pt"]}),(0,s.jsxs)("span",{className:"w-24 shrink-0 text-xs text-muted-foreground tabular-nums",children:[e.lines," ",1===e.lines?"line":"lines"]}),(0,s.jsx)("span",{className:"min-w-40 flex-1 truncate text-sm text-muted-foreground",children:e.sample}),(0,s.jsx)("select",{"aria-label":`Level for text set at ${e.size.toFixed(1)} point`,className:(0,x.cn)(K,"h-8 w-32 shrink-0"),value:e.level,onChange:t=>em(n=>({...n,[e.key]:Number(t.target.value)})),children:U.map(([e,t])=>(0,s.jsx)("option",{value:e,children:t},e))})]},e.key)),Object.keys(ec).length>0&&(0,s.jsx)(c.$,{type:"button",size:"sm",variant:"outline",onClick:()=>em({}),children:"Put the measured levels back"})]}),eE.fonts.length>1&&(0,s.jsxs)("div",{className:"space-y-2 border-t pt-3",children:[(0,s.jsx)("p",{className:"text-sm",children:"Fonts used at body size. A PDF never records the word bold, it records a second font, so which one means emphasis is a judgement and here is the count it was made on."}),eE.fonts.slice(0,6).map(e=>(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 rounded-md border bg-card p-2.5",children:[(0,s.jsxs)("span",{className:"w-16 shrink-0 text-sm font-medium tabular-nums",children:[Math.round(100*e.share),"%"]}),(0,s.jsx)("span",{className:"min-w-40 flex-1 truncate text-sm text-muted-foreground",children:e.sample||e.family}),(0,s.jsxs)("select",{"aria-label":`Style for the font setting ${Math.round(100*e.share)} percent of body text`,className:(0,x.cn)(K,"h-8 w-32 shrink-0"),value:e.role,onChange:t=>eg(n=>({...n,[e.font]:t.target.value})),children:[(0,s.jsx)("option",{value:"plain",children:"Plain text"}),(0,s.jsx)("option",{value:"bold",children:"Bold"}),(0,s.jsx)("option",{value:"italic",children:"Italic"})]})]},e.font)),eE.fonts.length>6&&(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Showing 6 of ",eE.fonts.length," fonts, the ones setting the most text."]})]})]}),(0,s.jsxs)("div",{className:"space-y-3 rounded-lg border p-4",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-end gap-4",children:[(0,s.jsxs)("div",{className:"w-40 space-y-1",children:[(0,s.jsx)(g.J,{htmlFor:"pdf-to-markdown-headings",className:"text-xs",children:"Heading style"}),(0,s.jsxs)("select",{id:"pdf-to-markdown-headings",className:K,value:eo.headingStyle,onChange:e=>eU("headingStyle","setext"===e.target.value?"setext":"atx"),children:[(0,s.jsx)("option",{value:"atx",children:"# Hashes"}),(0,s.jsx)("option",{value:"setext",children:"Underlines"})]})]}),(0,s.jsxs)("div",{className:"w-40 space-y-1",children:[(0,s.jsx)(g.J,{htmlFor:"pdf-to-markdown-bullet",className:"text-xs",children:"Bullet"}),(0,s.jsxs)("select",{id:"pdf-to-markdown-bullet",className:K,value:eo.bullet,onChange:e=>eU("bullet","*"===e.target.value?"*":"-"),children:[(0,s.jsx)("option",{value:"-",children:"- dash"}),(0,s.jsx)("option",{value:"*",children:"* asterisk"})]})]}),(0,s.jsxs)("div",{className:"w-40 space-y-1",children:[(0,s.jsx)(g.J,{htmlFor:"pdf-to-markdown-columns",className:"text-xs",children:"Column layout"}),(0,s.jsxs)("select",{id:"pdf-to-markdown-columns",className:K,value:eo.columns,onChange:e=>eU("columns","single"===e.target.value?"single":"auto"),children:[(0,s.jsx)("option",{value:"auto",children:"Find the columns"}),(0,s.jsx)("option",{value:"single",children:"Read straight across"})]})]}),(0,s.jsxs)("div",{className:"w-44 space-y-1",children:[(0,s.jsx)(g.J,{htmlFor:"pdf-to-markdown-pages",className:"text-xs",children:"Pages (blank means all)"}),(0,s.jsx)(f.p,{id:"pdf-to-markdown-pages",value:eb,placeholder:"1-12, 20, 44-",onChange:e=>ew(e.target.value)})]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-2 text-sm",children:[(0,s.jsxs)("label",{className:"flex cursor-pointer items-center gap-2",children:[(0,s.jsx)("input",{type:"checkbox",checked:eo.stripEdges,onChange:e=>eU("stripEdges",e.target.checked),className:"h-4 w-4 accent-primary"}),"Drop repeated headers and footers"]}
12),(0,s.jsxs)("label",{className:"flex cursor-pointer items-center gap-2",children:[(0,s.jsx)("input",{type:"checkbox",checked:eo.tables,onChange:e=>eU("tables",e.target.checked),className:"h-4 w-4 accent-primary"}),"Rebuild tables"]}),(0,s.jsxs)("label",{className:"flex cursor-pointer items-center gap-2",children:[(0,s.jsx)("input",{type:"checkbox",checked:eo.links,onChange:e=>eU("links",e.target.checked),className:"h-4 w-4 accent-primary"}),"Keep links"]}),(0,s.jsxs)("label",{className:"flex cursor-pointer items-center gap-2",children:[(0,s.jsx)("input",{type:"checkbox",checked:eo.joinHyphens,onChange:e=>eU("joinHyphens",e.target.checked),className:"h-4 w-4 accent-primary"}),"Rejoin split words"]}),(0,s.jsxs)("label",{className:"flex cursor-pointer items-center gap-2",children:[(0,s.jsx)("input",{type:"checkbox",checked:eo.normalize,onChange:e=>eU("normalize",e.target.checked),className:"h-4 w-4 accent-primary"}),"Straighten quotes and ligatures"]}),(0,s.jsxs)("label",{className:"flex cursor-pointer items-center gap-2",children:[(0,s.jsx)("input",{type:"checkbox",checked:eo.pageBreaks,onChange:e=>eU("pageBreaks",e.target.checked),className:"h-4 w-4 accent-primary"}),"Mark page breaks"]})]})]}),!eL.allBlank&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[(0,s.jsx)("span",{className:"mr-1 text-muted-foreground",children:"Show"}),(0,s.jsx)(c.$,{type:"button",size:"sm",variant:"markdown"===eN?"default":"outline",onClick:()=>e$("markdown"),children:"Markdown"}),(0,s.jsxs)(c.$,{type:"button",size:"sm",variant:"outline"===eN?"default":"outline",onClick:()=>e$("outline"),children:["Outline (",eE.totals.headings,")"]}),(0,s.jsx)(c.$,{type:"button",size:"sm",variant:"report"===eN?"default":"outline",onClick:()=>e$("report"),children:"Page report"})]}),"markdown"===eN&&(0,s.jsx)(p.T,{readOnly:!0,value:eL.markdown,"aria-label":"Markdown output",className:"min-h-[24rem] font-mono text-xs"}),"outline"===eN&&(0,s.jsxs)("div",{className:"max-h-[24rem] overflow-auto rounded-lg border p-3",children:[0===eB.length?(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"No headings in the output, so this document arrives as plain paragraphs."}):(0,s.jsx)("ul",{className:"space-y-1 text-sm",children:eB.slice(0,300).map((e,t)=>(0,s.jsxs)("li",{style:{paddingLeft:`${(e.level-1)*1.1}rem`},className:(0,x.cn)("truncate",1===e.level?"font-semibold":"text-muted-foreground"),children:[(0,s.jsxs)("span",{className:"mr-2 text-xs tabular-nums opacity-60",children:["H",e.level]}),e.text]},`${t}-${e.text}`))}),eB.length>300&&(0,s.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["Showing the first ",300," of ",eB.length," headings. The markdown itself holds all of them."]})]}),"report"===eN&&(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-5",children:[(0,s.jsx)(W,{value:eE.blankPages.length,label:"pages with no text layer",alarm:eE.blankPages.length>0}),(0,s.jsx)(W,{value:eE.totals.columnPages,label:"pages read as columns"}),(0,s.jsx)(W,{value:eE.totals.reordered,label:"lines moved out of file order"}),(0,s.jsx)(W,{value:eE.totals.weakTables,label:"tables too ragged to rebuild",alarm:eE.totals.weakTables>0}),(0,s.jsx)(W,{value:eE.totals.unwritten,label:"text runs read but not written",alarm:eE.totals.unwritten>0})]}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"These are counts rather than a survival score. A page with no text layer has nothing on either side to compare, so a percentage there would either read 100 or read nothing at all, and both are worse than saying the page was not converted."}),eE.blankPages.length>0&&(0,s.jsxs)("p",{className:"text-sm",children:["No text layer on"," ",1===eE.blankPages.length?"page":"pages"," ",eE.blankPages.slice(0,40).join(", "),eE.blankPages.length>40?`, and ${eE.blankPages.length-40} more`:"",". Those pages are scans or full page images, and nothing was converted from them."]}),eE.removals.length>0&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("h4",{className:"text-sm font-semibold",children:"Taken out as running headers and footers"}),eE.removals.slice(0,20).map(e=>
12{let t=ep.includes(e.key);return(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 rounded-md border bg-card p-2.5 text-sm",children:[(0,s.jsx)("span",{className:"min-w-40 flex-1 truncate",children:e.sample||"(a bare page number)"}),(0,s.jsxs)("span",{className:"shrink-0 text-xs text-muted-foreground tabular-nums",children:["page number"===e.kind?"page number":"repeated"," on"," ",e.pages," ",1===e.pages?"page":"pages"]}),(0,s.jsx)(c.$,{type:"button",size:"sm",variant:t?"default":"outline",onClick:()=>ex(n=>t?n.filter(t=>t!==e.key):[...n,e.key]),children:t?"Kept in":"Put it back"})]},e.key)}),eE.removals.length>20&&(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Showing ",20," of ",eE.removals.length," removals, longest running first."]})]}),eE.weakTables.length>0&&(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("h4",{className:"text-sm font-semibold",children:"Tables left as they were"}),(0,s.jsx)("ul",{className:"space-y-1 text-sm text-muted-foreground",children:eE.weakTables.slice(0,12).map((e,t)=>(0,s.jsxs)("li",{children:[`Page ${e.page}, ${e.rows} rows, ${Math.round(100*e.confidence)}% of the cells lined up.`," ","Below the bar to rebuild, so those lines are in the markdown as a plain block with a comment naming the page."]},`${e.page}-${t}`))}),eE.weakTables.length>12&&(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Showing ",12," of ",eE.weakTables.length,". Every one of them is in the markdown with a comment naming its page."]})]}),eE.excluded.length>0&&(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsxs)("h4",{className:"text-sm font-semibold",children:["Thrown out as unreadable (",eE.excludedTotal," in total)"]}),(0,s.jsx)("ul",{className:"space-y-1 text-sm text-muted-foreground",children:eE.excluded.slice(0,20).map((e,t)=>(0,s.jsxs)("li",{className:"truncate",children:["Page ",e.page,": ",e.reason,". ",e.text]},`${e.page}-${t}`))}),eE.excludedTotal>eE.excluded.length&&(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Showing ",Math.min(eE.excluded.length,20)," of"," ",eE.excludedTotal,"."]})]}),(0,s.jsx)("div",{className:"overflow-x-auto rounded-lg border",children:(0,s.jsxs)("table",{className:"w-full text-sm",children:[(0,s.jsx)("thead",{className:"bg-muted/50 text-xs",children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{className:"p-2 text-left font-medium",children:"Page"}),(0,s.jsx)("th",{className:"p-2 text-right font-medium",children:"Headings"}),(0,s.jsx)("th",{className:"p-2 text-right font-medium",children:"Tables"}),(0,s.jsx)("th",{className:"p-2 text-right font-medium",children:"Lists"}),(0,s.jsx)("th",{className:"p-2 text-right font-medium",children:"Links"}),(0,s.jsx)("th",{className:"p-2 text-right font-medium",children:"Reordered"}),(0,s.jsx)("th",{className:"p-2 text-right font-medium",children:"Stripped"}),(0,s.jsx)("th",{className:"p-2 text-left font-medium",children:"What happened"})]})}),(0,s.jsx)("tbody",{children:eE.pages.map(e=>(0,s.jsxs)("tr",{className:"border-t",children:[(0,s.jsx)("td",{className:"p-2 tabular-nums",children:e.number}),(0,s.jsx)("td",{className:"p-2 text-right tabular-nums",children:e.headings}),(0,s.jsxs)("td",{className:"p-2 text-right tabular-nums",children:[e.tables,e.weakTables>0?` (+${e.weakTables})`:""]}),(0,s.jsx)("td",{className:"p-2 text-right tabular-nums",children:e.lists}),(0,s.jsx)("td",{className:"p-2 text-right tabular-nums",children:e.links}),(0,s.jsx)("td",{className:"p-2 text-right tabular-nums",children:e.reordered}),(0,s.jsx)("td",{className:"p-2 text-right tabular-nums",children:e.stripped}),(0,s.jsx)("td",{className:(0,x.cn)("p-2 text-xs",e.hasText?"text-muted-foreground":"text-destructive"),children:e.hasText?e.unreadable?"text present but the font could not map it to characters":`${e.columns>1?`${e.columns} columns, `:""}${e.chars.toLocaleString()} characters${e.internalLinks>0?`, ${e.internalLinks} internal links dropped`:""}${e.hyphenJoins>0?`, ${e.hyphenJoins} words rejoined`:""}`:"no text layer, nothing to compare and nothing converted"})]},e.number))})]})})]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[!eL.allBlank&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(m.i,{value:eL.fileText,label:"Copy markdown",describe:"the markdown",variant:"default",size:"default",disabled:!eI}),(0,s.jsx)(c.$,{variant:"outline",onClick:function(){if(!eL||!eI)return;let t=new Blob([eL.fileText],{type:"text/markdown;charset=utf-8"});(0,R.WN)(t,`${(e?.name||"document").replace(/\.pdf$/i,"")}.md`),eS("download"),setTimeout(()=>eS(e=>"download"===e?"":e),1600)},disabled:!eI,children:"download"===eM?"Saved":"Download .md"})]}),(0,s.jsx)(c.$,{variant:"outline",onClick:()=>eK(""),children:"Start over"})]})]})]})}function W({value:e,label:t,alarm:n=!1}){return(0,s.jsxs)("div",{className:"rounded-lg border bg-card p-3",children:[(0,s.jsx)("div",{className:(0,x.cn)("text-2xl font-semibold tabular-nums",n&&e>
120?"text-destructive":""),children:e.toLocaleString()}),(0,s.jsx)("div",{className:"text-xs text-muted-foreground",children:t})]})}}}]);

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.