PageSourceSearch

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

js localpdf.online collected 2026-10-02 01:06:29 UTC 10,251 bytes, 1 lines download raw bytes

1import{r as a,j as e}from"./vendor-react-C_xdI0Ng.js";import{u as Z}from"./index-DbFRh42P.js";import{L as r}from"./linear-icon-BS_Bu1OG.js";import"./vendor-icons-CmfhFn4k.js";function M(s){return typeof s!="number"||!Number.isFinite(s)?"-":s<1e3?`${Math.round(s)}ms`:`${(s/1e3).toFixed(1)}s`}function ne({inputFiles:s,onStart:J,onBack:F,onPickFiles:t,onClearFiles:k,viewState:l="idle",progress:P=0,errorMessage:B,resultText:x,resultJson:j,resultPdfUrl:N,resultMeta:o,onDownloadOutput:v}){const{runtime:O}=Z(),b=a.useRef(null),[z,w]=a.useState(""),[G,y]=a.useState(!1),[f,U]=a.useState("auto"),[C,H]=a.useState("eng"),[u,E]=a.useState("fast"),[D,K]=a.useState(!0),[S,W]=a.useState(!1),[h,X]=a.useState("txt"),[i,d]=a.useState("text"),[T,_]=a.useState(!1),[R,$]=a.useState(""),p=!!j,m=!!N;a.useEffect(()=>{if(s.length>0){O.vfs.read(s[0]).then(c=>w(c.getName()));return}w("")},[s,O.vfs]),a.useEffect(()=>{if(h==="json"&&p){d("json");return}if(h==="searchable-pdf"&&m){d("overlay");return}d("text")},[p,m,h]);const A=s.length>0,q=A&&l!=="running",L=Math.max(0,Math.min(100,Math.round(P))),I=a.useMemo(()=>l==="done"||!!x||p||m,[p,m,x,l]),g=a.useMemo(()=>{const c=[{id:"text",label:"Text"}];
1return p&&c.push({id:"json",label:"JSON"}),m&&c.push({id:"overlay",label:"Overlay"}),c},[p,m]);a.useEffect(()=>{$(x??"")},[x]),a.useEffect(()=>{var c;g.some(n=>n.id===i)||d(((c=g[0])==null?void 0:c.id)??"text")},[i,g]);const Q=async c=>{const n=c.target.files?Array.from(c.target.files):[];c.target.value="",!(n.length===0||!t)&&await t(n)},V=async c=>{if(c.preventDefault(),y(!1),!t)return;const n=Array.from(c.dataTransfer.files??[]);n.length!==0&&await t(n)},Y=async()=>{if(typeof navigator>"u"||!navigator.clipboard)return;const c=i==="json"?j:R;c&&await navigator.clipboard.writeText(c)};return e.jsx("div",{className:"tool-config-root ocr-concept-root ocr-pdf-concept-root",children:e.jsxs("div",{className:"ocr-concept-workspace",children:[e.jsxs("section",{className:"tool-config-card ocr-concept-left ocr-pdf-concept-left",children:[e.jsxs("div",{className:`ocr-concept-upload ${G?"dragging":""} ${t?"":"upload-readonly"}`,onClick:()=>{var c;t&&((c=b.current)==null||c.click())},onDragOver:c=>{t&&(c.preventDefault(),y(!0))},onDragLeave:()=>{t&&y(!1)},onDrop:c=>{V(c)},role:t?"button":void 0,tabIndex:t?0:-1,onKeyDown:c=>{var n;t&&(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),(n=b.current)==null||n.click())},children:[e.jsx("input",{ref:b,type:"file",accept:"application/pdf,image/*",multiple:!0,style:{display:"none"},onChange:c=>{Q(c)}}),e.jsx("div",{className:"ocr-concept-upload-icon",children:e.jsx(r,{name:"upload",className:"linear-icon icon-md"})}),e.jsx("p",{className:"ocr-concept-upload-title",children:"Drop file here"}),e.jsx("p",{className:"ocr-concept-upload-copy",children:"PDF, JPG, PNG, WEBP. All processing stays local in browser."}),e.jsxs("div",{className:"ocr-concept-file-chip",children:[e.jsx("span",{className:"ocr-concept-file-name",children:z||"No file selected"}),k?e.jsx("button",{type:"button",className:"ocr-concept-clear-btn",onClick:c=>{c.stopPropagation(),k()},"aria-label":"Clear selected files",title:"Clear selected files",children:e.jsx(r,{name:"x",className:"linear-icon"})}):e.jsx(r,{name:"refresh",className:"linear-icon"})]})]}),e.jsxs("div",{className:"ocr-concept-settings",children:[e.jsx("label",{className:"tool-config-label",htmlFor:"ocr-language-mode",children:"Language mode"}),e.jsxs("select",{id:"ocr-language-mode",className:"tool-config-select",value:f,onChange:c=>U(c.target.value==="manual"?"manual":"auto"),children:[e.jsx("option",{value:"auto",children:"Auto detect (recommended)"}),e.jsx("option",{value:"manual",children:"Manual selection"})]}),e.jsx("label",{className:"tool-config-label",htmlFor:"ocr-language",children:"OCR language"}),e.jsxs("select",{id:"ocr-language",className:"tool-config-select",value:C,disabled:f!=="manual",onChange:c=>H(c.target.value),children:[e.jsx("option",{value:"rus+eng",children:"Russian + English"}),e.jsx("option",{value:"eng",children:"English"}),e.jsx("option",{value:"rus",children:"Russian"}),e.jsx("option",{value:"ukr",children:"Ukrainian"}),e.jsx("option",{value:"deu",children:"German"}),e.jsx("option",{value:"fra",children:"French"}),e.jsx("option",{value:"spa",children:"Spanish"}),e.jsx("option",{value:"ita",children:"Italian"}),e.jsx("option",{value:"por",children:"Portuguese"}),e.jsx("option",{value:"jpn",children:"Japanese"}),e.jsx("option",{value:"chi_sim",children:"Chinese (Simplified)"}),e.jsx("option",{value:"hin",children:"Hindi"})]}),e.jsx("span",{className:"tool-config-label",children:"Mode"}),e.jsxs("div",{className:"ocr-concept-mode-switch",role:"radiogroup","aria-label":"OCR mode",children:[e.jsx("button",{type:"button",className:`ocr-concept-mode-option ${u==="accurate"?"active":""}`,onClick:()=>E("accurate"),"aria-pressed":u==="accurate",children:"Accurate"}),e.jsx("button",{type:"button",className:`ocr-concept-mode-option ${u==="fast"?"active":""}`,onClick:()=>E("fast"),"aria-pressed":u==="fast",children:"Fast"})]}),e.jsxs("div",{className:"ocr-concept-checks",children:[e.jsxs("label",{className:"ocr-concept-check",children:[e.jsx("input",{type:"checkbox",checked:D,onChange:c=>K(c.target.checked)}),"Preserve formatting"]}),e.jsxs("label",{className:"ocr-concept-check",children:[e.jsx("input",{type:"checkbox",checked:S,onChange:c=>W(c.target.checked)}),"Detect tables"]})]}),e.jsx("label",{className:"tool-config-label",htmlFor:"ocr-output",children:"Output format"}),e.jsxs("select",{id:"ocr-output",className:"tool-config-select",value:h,onChange:c=>{const n=c.target.value;X(n==="json"||n==="searchable-pdf"?n:"txt")},children:[e.jsx("option",{value:"txt",children:"TXT report (recommended)"}),e.jsx("option",{value:"searchable-pdf",children:"Searchable PDF (experimental)"}),e.jsx("option",{value:"json",children:"JSON report (advanced)"})]})]}),e.jsxs("div",{className:"tool-config-actions ocr-concept-actions",children:[e.jsx("button",{className:"btn-ghost",onClick:F,children:"Cancel"}),e.jsx("button",{className:"btn-primary",disabled:!q,onClick:()=>J({languageMode:f,language:C,outputFormat:h,mode:u,preserveFormatting:D,detectTables:S}),children:e.jsxs("span",{className:"btn-inline",children:[e.jsx(r,{name:"play",className:"linear-icon"}),l==="running"?"Running OCR...":"Run OCR"]})})]})]}),e.jsxs("section",{className:"tool-config-card ocr-concept-right",children:[!A&&l!=="running"&&!I&&e.jsxs("div",{className:"ocr-concept-empty",children:[e.jsx(r,{name:"ocr",className:"linear-icon icon-md"}),e.jsx("h3",{className:"ocr-concept-empty-title",children:"Ready to process OCR"}),e.jsx("p",{className:"ocr-concept-empty-copy",children:"Upload a document on the left, configure options, then run OCR."}),e.jsxs("div",{className:"ocr-pdf-empty-hint",children:[e.jsx("span",{className:"ocr-pdf-empty-pill",children:"Local runtime only"}),e.jsx("span",{className:"ocr-pdf-empty-pill",children:"Text + JSON + PDF overlay"})]})]}),l==="running"&&e.jsxs("div",{className:"ocr-concept-loading",children:[e.jsx("div",{className:"ocr-concept-spinner"}),e.jsx("h3",{className:"ocr-concept-loading-title",children:"Running OCR..."}),e.jsxs("p",{className:"ocr-concept-loading-copy",children:["Processing in local runtime. Progress: ",L,"%"]}),e.jsx("div",{className:"wizard-progress-track ocr-concept-progress-track",children:e.jsx("div",{className:"wizard-progress-bar",style:{width:`${L}%`}})})]}),l==="error"&&e.jsxs("div",{className:"ocr-concept-empty",children:[e.jsx(r,{name:"x",className:"linear-icon icon-md"}),e.jsx("h3",{className:"ocr-concept-empty-title",children:"OCR failed"}),e.jsx("p",{className:"ocr-concept-empty-copy",children:B||"Unexpected OCR error."})]}),I&&l!=="running"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"ocr-concept-tabs",role:"tablist","aria-label":"OCR preview tabs",children:g.map(c=>e.jsx("button",{type:"button",className:`ocr-concept-tab ${i===c.id?"active":""}`,onClick:()=>d(c.id),children:c.label},c.id))}),e.jsxs("div",{className:"ocr-concept-toolbar",children:[e.jsxs("button",{type:"button",className:"ocr-concept-tool-btn",onClick:()=>{Y()},children:[e.jsx(r,{name:"tool",className:"linear-icon"}),"Copy"]}),e.jsxs("button",{type:"button",className:"ocr-concept-tool-btn",onClick:()=>{v==null||v()},children:[e.jsx(r,{name:"download",className:"linear-icon"}),"Download"]}),e.jsxs("button",{type:"button",className:"ocr-concept-tool-btn",onClick:()=>d("text"),children:[e.jsx(r,{name:"refresh",className:"linear-icon"}),"Normalize view"]}),e.jsxs("button",{type:"button",className:`ocr-concept-tool-btn ocr-concept-tool-btn-accent ${T?"active":""}`,onClick:()=>{d("text"),_(c=>!c)},children:[e.jsx(r,{name:"refresh",className:"linear-icon"}),"Text editor"]})]}),e.jsxs("div",{className:"ocr-concept-editor","aria-live":"polite",children:[i==="text"&&(T?e.jsx("textarea",{className:"ocr-concept-editor-input",value:R,onChange:c=>$(c.target.value),placeholder:"No text preview available for this output format."}):e.jsx("pre",{className:"ocr-concept-editor-copy",children:R||"No text preview available for this output format."})),i==="json"&&e.jsx("pre",{className:"ocr-concept-editor-copy",children:j||"JSON preview is available when output format = JSON."}),i==="overlay"&&N&&e.jsxs("div",{className:"ocr-concept-pdf-preview-wrap",children:[e.jsx("iframe",{className:"ocr-concept-pdf-preview",src:`${N}#toolbar=0&navpanes=0`,title:"Searchable PDF preview"}),e.jsx("div",{className:"ocr-concept-pdf-preview-lock","aria-hidden":"true"})]})]}),e.jsxs("div",{className:"ocr-concept-stats",children:[e.jsxs("span",{className:"ocr-concept-stat",children:["Accuracy: ",e.jsx("strong",{children:typeof(o==null?void 0:o.accuracy)=="number"?`${o.accuracy.toFixed(1)}%`:"-"})]}),e.jsxs("span",{className:"ocr-concept-stat",children:["Files: ",e.jsx("strong",{children:typeof(o==null?void 0:o.pages)=="number"?o.pages:s.length})]}),e.jsxs("span",{className:"ocr-concept-stat",children:["Language: ",e.jsx("strong",{children:(o==null?void 0:o.language)||(f==="auto"?"Auto":C.toUpperCase())})]}),e.jsxs("span",{className:"ocr-concept-stat",children:["Time: ",e.jsx("strong",{children:M(o==null?void 0:o.durationMs)})]})]})]})]})]})})}export{ne 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.