PageSourceSearch

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

js localpdf.online collected 2026-10-02 01:09:04 UTC 9,591 bytes, 13 lines download raw bytes

1import{j as t}from"./jsx-runtime-0DLF9kdB.js";import{r as n}from"./index-DH-tsESH.js";import{u as Ne}from"./platform-context-pZZ_Wbof.js";import{L as D}from"./linear-icon-C4MoDyVR.js";function Re({inputFiles:g,onStart:re,onBack:ce,onPickFiles:o,onClearFiles:H,currentStep:K,progress:le=0,outputCount:ie=0,onDownload:G}){var te;const{runtime:k}=Ne(),v=n.useRef(null),[d,de]=n.useState([]),[T,_]=n.useState("pdf"),[l,pe]=n.useState("standard"),[S,fe]=n.useState(!1),[I,he]=n.useState(!0),[p,J]=n.useState(!1),[B,V]=n.useState(""),[W,X]=n.useState(""),[f,Y]=n.useState([]),[x,w]=n.useState(0),[Z,$]=n.useState(null),[ue,R]=n.useState(!1),[me,q]=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){X(""),$(null),R(!1),L();return}if(typeof document>"u"){X("Preview is unavailable in this runtime."),$(null),R(!1),L();return}R(!0),$(null);try{const i=await import("./index-EReD-Y9T.js").then(function(s){return s.i}),be=await(await(await k.vfs.read(g[0])).getBlob()).arrayBuffer(),z=(await i.extractRawText({arrayBuffer:be})).value.replace(/\r/g,"").split(`
2`).map(s=>s.trim()).filter(s=>s.length>0).slice(0,28).join(`
3`);e||X(z.length>0?z:"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=(z||"No readable text found in this DOCX file.").split(`
4`),Q=document.createElement("canvas");Q.width=y,Q.height=N;const U=Q.getContext("2d");if(!U)throw new Error("Preview canvas is unavailable.");U.textBaseline="top",U.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 h of r){const m=c.length>0?`${c} ${h}`:h;U.measureText(m).width<=ne?c=m:(j.push(c.length>0?c:h),c=c.length>0?h:"")}c.length>0?j.push(c):j.push(" ")}const oe=Math.max(1,Math.floor((N-O*2)/se)),M=[];for(let s=0;s<j.length;s+=oe)M.push(j.slice(s,s+oe));M.length===0&&M.push(["No readable text found in this DOCX file."]);const P=[];for(const s of M){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 h=await new Promise(m=>C.toBlob(m,"image/png"));h&&P.push(URL.createObjectURL(h))}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||R(!1)}})(),()=>{e=!0,u(a)}},[g,S,l,k.vfs]),n.useEffect(()=>{!b&&p&&(J(!1),V(""))},[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=K==="processing",E=K==="result"&&ie>0,ve=d.length>0&&(!p||B.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&&H&&t.jsx("button",{type:"button",className:"ocr-concept-clear-btn",onClick:e=>{e.stopPropagation(),H()},"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
4ange: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=>fe(e.target.checked)}),"Create PDF/A (archive mode)"]}),t.jsxs("label",{className:"ocr-concept-check",children:[t.jsx("input",{type:"checkbox",checked:I,onChange:e=>he(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=>J(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:B,onChange:e=>V(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:E?!1:!ve,onClick:()=>{if(E&&G){G();return}re({quality:l,pdfA:S,searchablePdf:I,protectWithPassword:p,password:B.trim()})},children:[t.jsx(D,{name:E?"download":"play",className:"linear-icon"}),ee?`Converting ${Math.max(0,Math.min(100,Math.round(le)))}%`:E?"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(),q(!0))},onDragLeave:()=>q(!1),onDrop:e=>{if(!o)return;e.preventDefault(),q(!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 ${T==="pdf"?"active":""}`,onClick:()=>_("pdf"),children:"PDF"}),t.jsx("button",{type:"button",className:`ocr-concept-tab ${T==="details"?"active":""}`,onClick:()=>_("details"),children:"Details"})]}),t.jsx("div",{className:"ocr-concept-toolbar",children:f.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:f.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(f.length-1,e+1)),disabled:x>=f.length-1,children:"Next"})]})}),t.jsx("div",{className:"ocr-concept-editor",children:T==="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}`}):f.length>0?t.jsx("img",{className:"word-concept-preview-image",src:f[x]??f[0],alt:`Generated PDF preview page ${x+1}`}):t.jsx("pre",{className:"ocr-concept-editor-copy",children:W}):t.jsx("pre",{className:"ocr-concept-editor-copy",children:`Input: ${F}
5Output: ${ge}
6Quality: ${l}
7PDF/A: ${S?"enabled":"disabled"}
8Searchable PDF (requested): ${I?"enabled":"disabled"}
9Searchable result: best effort (some scripts/symbols may be rasterized)
10Password protection: ${p?"enabled":"disabled"}
11Password mode: ${b?"available":"browser runtime - unavailable"}
12Preview text lines: ${W.length===0?0:W.split(`
13`).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.