PageSourceSearch

https://localpdf.online/app/assets/index-qvDU5HiG.js

js localpdf.online collected 2026-10-02 01:06:51 UTC 9,798 bytes, 14 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-mammoth-B-gX-_UO.js","assets/vendor-react-C_xdI0Ng.js","assets/vendor-excel--wYEJF5V.js"])))=>i.map(i=>d[i]);
2import{u as Ne,_ as je}from"./index-DbFRh42P.js";import{r as n,j as t}from"./vendor-react-C_xdI0Ng.js";import{L as D}from"./linear-icon-BS_Bu1OG.js";import"./vendor-icons-CmfhFn4k.js";function Re({inputFiles:g,onStart:re,onBack:ce,onPickFiles:o,onClearFiles:Q,currentStep:H,progress:le=0,outputCount:ie=0,onDownload:K}){var te;const{runtime:k}=Ne(),v=n.useRef(null),[d,de]=n.useState([]),[I,G]=n.useState("pdf"),[l,pe]=n.useState("standard"),[S,he]=n.useState(!1),[M,fe]=n.useState(!0),[p,V]=n.useState(!1),[_,J]=n.useState(""),[B,W]=n.useState(""),[h,Y]=n.useState([]),[x,w]=n.useState(0),[Z,$]=n.useState(null),[ue,E]=n.useState(!1),[me,X]=n.useState(!1),b=typeof process<"u"&&!!((te=process.versions)!=null&&te.node);n.useEffect(()=>{(async()=>{const a=await Promise.all(g.map(async u=>(await k.vfs.read(u)).getName()));de(a)})()},[g,k.vfs]),n.useEffect(()=>{let e=!1,a=[];const u=i=>{if(!(typeof URL>"u"||typeof URL.revokeObjectURL!="function"))for(const A of i)URL.revokeObjectURL(A)},L=()=>{Y(i=>(u(i),[])),w(0)};return(async()=>{if(g.length===0){W(""),$(null),E(!1),L();return}if(typeof document>"u"){W("Preview is unavailable in this runtime."),$(null),E(!1),L();return}E(!0),$(null);try{const i=await je(()=>import("./vendor-mammoth-B-gX-_UO.js").then(s=>s.i),__vite__mapDeps([0,1,2])),be=await(await(await k.vfs.read(g[0])).getBlob()).arrayBuffer(),q=(await i.extractRawText({arrayBuffer:be})).value.replace(/\r/g,"").split(`
3`).map(s=>s.trim()).filter(s=>s.length>0).slice(0,28).join(`
4`);e||W(q.length>0?q:"No readable text found in this DOCX file.");const O=l==="high"?28:l==="min"?18:22,ae=l==="high"?18:l==="min"?14:16,se=l==="high"?30:l==="min"?23:26,y=860,N=1120,ne=y-O*2,ye=(q||"No readable text found in this DOCX file.").split(`
5`),z=document.createElement("canvas");z.width=y,z.height=N;const T=z.getContext("2d");if(!T)throw new Error("Preview canvas is unavailable.");T.textBaseline="top",T.font=`${ae}px "Noto Sans", Arial, sans-serif`;const j=[];for(const s of ye){const r=(s.trim().length>0?s:" ").split(/\s+/);let c="";for(const f of r){const m=c.length>0?`${c} ${f}`:f;T.measureText(m).width<=ne?c=m:(j.push(c.length>0?c:f),c=c.length>0?f:"")}c.length>0?j.push(c):j.push(" ")}const oe=Math.max(1,Math.floor((N-O*2)/se)),U=[];for(let s=0;s<j.length;s+=oe)U.push(j.slice(s,s+oe));U.length===0&&U.push(["No readable text found in this DOCX file."]);const P=[];for(const s of U){const C=document.createElement("canvas");C.width=y,C.height=N;const r=C.getContext("2d");if(!r)continue;r.fillStyle="#ffffff",r.fillRect(0,0,y,N),r.fillStyle="#0f172a",r.textBaseline="top",r.font=`${ae}px "Noto Sans", Arial, sans-serif`;let c=O;for(const m of s)r.fillText(m,O,c,ne),c+=se;r.strokeStyle="rgba(15, 23, 42, 0.14)",r.lineWidth=2,r.strokeRect(1,1,y-2,N-2);const f=await new Promise(m=>C.toBlob(m,"image/png"));f&&P.push(URL.createObjectURL(f))}if(P.length===0)throw new Error("Failed to create preview image.");a=P,e||(Y(s=>(u(s),P)),w(s=>Math.max(0,Math.min(s,P.length-1))),a=[])}catch(i){if(e)return;const A=i instanceof Error&&i.message.trim().length>0?i.message:"Preview is unavailable for this file.";$(A),L()}finally{e||E(!1)}})(),()=>{e=!0,u(a)}},[g,S,l,k.vfs]),n.useEffect(()=>{!b&&p&&(V(!1),J(""))},[b,p]);const F=d[0]??"No file selected",ge=n.useMemo(()=>{if(d.length===0)return"converted.pdf";const e=d[0],a=e.lastIndexOf(".");return`${a>0?e.slice(0,a):e}.pdf`},[d]),ee=H==="processing",R=H==="result"&&ie>0,ve=d.length>0&&(!p||_.trim().length>0)&&!ee,xe=async e=>{const a=e.target.files?Array.from(e.target.files):[];e.target.value="",!(a.length===0||!o)&&await o(a)},we=async e=>{e.length===0||!o||await o(e)};return t.jsx("div",{className:"tool-config-root word-concept-root",children:t.jsxs("div",{className:"ocr-concept-workspace",children:[t.jsxs("section",{className:"tool-config-card ocr-concept-left word-concept-left",children:[t.jsx("h3",{className:"word-concept-title",children:"Conversion settings"}),t.jsxs("div",{className:`ocr-concept-upload ${o?"":"upload-readonly"}`,role:o?"button":void 0,tabIndex:o?0:-1,onClick:()=>{var e;o&&((e=v.current)==null||e.click())},onKeyDown:e=>{var a;o&&(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),(a=v.current)==null||a.click())},children:[t.jsx("input",{ref:v,type:"file",accept:".docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document",style:{display:"none"},onChange:e=>{xe(e)}}),t.jsx("span",{className:"ocr-concept-upload-icon","aria-hidden":"true",children:t.jsx(D,{name:"word",className:"linear-icon icon-md"})}),t.jsx("p",{className:"ocr-concept-upload-title",children:"Drop files or click to upload"}),t.jsx("p",{className:"ocr-concept-upload-copy",children:"DOCX only. Processing runs locally in browser."})]}),t.jsxs("div",{className:"ocr-concept-file-chip",children:[t.jsxs("div",{className:"word-concept-file-name-group",children:[t.jsx(D,{name:"word",className:"linear-icon"}),t.jsx("span",{className:"ocr-concept-file-name",children:F})]}),d.length>0&&Q&&t.jsx("button",{type:"button",className:"ocr-concept-clear-btn",onClick:e=>{e.stopPropagation(),Q()},"aria-label":"Clear selected file",children:t.jsx(D,{name:"x",className:"linear-icon"})})]}),t.jsxs("div",{className:"ocr-concept-settings",children:[t.jsx("label",{className:"tool-config-label",htmlFor:"word-quality",children:"Quality and size"}),t.jsxs("select",{id:"word-quality",className:"tool-config-select",value:l,onCh
5ange:e=>pe(e.target.value),children:[t.jsx("option",{value:"standard",children:"Standard (screen and print)"}),t.jsx("option",{value:"high",children:"High quality (print ready)"}),t.jsx("option",{value:"min",children:"Minimum size (email)"})]}),t.jsxs("div",{className:"ocr-concept-checks",children:[t.jsxs("label",{className:"ocr-concept-check",children:[t.jsx("input",{type:"checkbox",checked:S,onChange:e=>he(e.target.checked)}),"Create PDF/A (archive mode)"]}),t.jsxs("label",{className:"ocr-concept-check",children:[t.jsx("input",{type:"checkbox",checked:M,onChange:e=>fe(e.target.checked)}),"Searchable PDF (best effort)"]}),t.jsxs("label",{className:"ocr-concept-check",children:[t.jsx("input",{type:"checkbox",checked:p,disabled:!b,onChange:e=>V(e.target.checked)}),"Protect with password ",b?"":"(desktop runtime only)"]})]}),p&&t.jsx("input",{className:"tool-config-input",type:"password",placeholder:"Enter password to open PDF",value:_,onChange:e=>J(e.target.value)})]}),t.jsxs("div",{className:"tool-config-actions ocr-concept-actions",children:[t.jsx("button",{className:"btn-ghost",onClick:ce,children:"Cancel"}),t.jsxs("button",{className:"btn-primary btn-inline",disabled:R?!1:!ve,onClick:()=>{if(R&&K){K();return}re({quality:l,pdfA:S,searchablePdf:M,protectWithPassword:p,password:_.trim()})},children:[t.jsx(D,{name:R?"download":"play",className:"linear-icon"}),ee?`Converting ${Math.max(0,Math.min(100,Math.round(le)))}%`:R?"Download PDF":"Convert to PDF"]})]})]}),t.jsx("section",{className:`tool-config-card ocr-concept-right ${me?"word-preview-drop-active":""}`,onDragOver:e=>{o&&(e.preventDefault(),X(!0))},onDragLeave:()=>X(!1),onDrop:e=>{if(!o)return;e.preventDefault(),X(!1);const a=Array.from(e.dataTransfer.files??[]);we(a)},children:d.length===0?t.jsxs("div",{className:`ocr-concept-empty ${o?"word-preview-upload-target":""}`,role:o?"button":void 0,tabIndex:o?0:-1,onClick:()=>{var e;o&&((e=v.current)==null||e.click())},onKeyDown:e=>{var a;o&&(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),(a=v.current)==null||a.click())},children:[t.jsx(D,{name:"word",className:"linear-icon icon-md"}),t.jsx("h4",{className:"ocr-concept-empty-title",children:"Word to PDF"}),t.jsx("p",{className:"ocr-concept-empty-copy",children:"Drop DOCX here or click to upload. Then review preview on the right."})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"ocr-concept-tabs",role:"tablist","aria-label":"Word preview tabs",children:[t.jsx("button",{type:"button",className:`ocr-concept-tab ${I==="pdf"?"active":""}`,onClick:()=>G("pdf"),children:"PDF"}),t.jsx("button",{type:"button",className:`ocr-concept-tab ${I==="details"?"active":""}`,onClick:()=>G("details"),children:"Details"})]}),t.jsx("div",{className:"ocr-concept-toolbar",children:h.length>1&&t.jsxs("div",{className:"word-preview-pager",children:[t.jsx("button",{type:"button",className:"ocr-concept-tool-btn",onClick:()=>w(e=>Math.max(0,e-1)),disabled:x<=0,children:"Prev"}),t.jsx("select",{className:"tool-config-select word-preview-select",value:x,onChange:e=>w(Number(e.target.value)),children:h.map((e,a)=>t.jsxs("option",{value:a,children:["Page ",a+1]},`preview-page-${a+1}`))}),t.jsx("button",{type:"button",className:"ocr-concept-tool-btn",onClick:()=>w(e=>Math.min(h.length-1,e+1)),disabled:x>=h.length-1,children:"Next"})]})}),t.jsx("div",{className:"ocr-concept-editor",children:I==="pdf"?ue?t.jsx("pre",{className:"ocr-concept-editor-copy",children:"Preparing DOCX preview..."}):Z?t.jsx("pre",{className:"ocr-concept-editor-copy",children:`Preview error: ${Z}`}):h.length>0?t.jsx("img",{className:"word-concept-preview-image",src:h[x]??h[0],alt:`Generated PDF preview page ${x+1}`}):t.jsx("pre",{className:"ocr-concept-editor-copy",children:B}):t.jsx("pre",{className:"ocr-concept-editor-copy",children:`Input: ${F}
6Output: ${ge}
7Quality: ${l}
8PDF/A: ${S?"enabled":"disabled"}
9Searchable PDF (requested): ${M?"enabled":"disabled"}
10Searchable result: best effort (some scripts/symbols may be rasterized)
11Password protection: ${p?"enabled":"disabled"}
12Password mode: ${b?"available":"browser runtime - unavailable"}
13Preview text lines: ${B.length===0?0:B.split(`
14`).length}`})})]})})]})})}export{Re 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.