PageSourceSearch

https://onlineocr.org/spa-assets/assets/main.js

js onlineocr.org collected 2026-09-24 10:23:41 UTC 35,263 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DocxEditorShell.js","assets/docx-editor.js","assets/docx-editor.css","assets/applyDocxAiHighlights.js"])))=>i.map(i=>d[i]);
2import{r,_ as Ae,j as s,c as Ws}from"./docx-editor.js";function fe(t,e){const p=t==null?void 0:t.csrf_token;return typeof p=="string"&&p.length>0?p:e}async function Js(t,e,p,u){const _=new FormData;_.append(t.csrfField,e),_.append("baseline",p),_.append("revision",u);const d=await fetch(`${t.apiBase}jobs`,{method:"POST",body:_,credentials:"include",headers:{[t.csrfHeader]:e}});let h=null;try{h=await d.json()}catch{h=null}const N=fe(h,e);return d.ok?{ok:!0,data:h??{},csrf:N}:{ok:!1,status:d.status,data:h,csrf:N}}async function Qs(t,e,p,u){const _=new FormData;_.append(t.csrfField,e),_.append("baseline",p),_.append("revision",u);const d=await fetch(`${t.apiBase}estimate`,{method:"POST",body:_,credentials:"include",headers:{[t.csrfHeader]:e}});let h=null;try{h=await d.json()}catch{h=null}const N=fe(h,e);return d.ok?{ok:!0,data:h??{},csrf:N}:{ok:!1,status:d.status,data:h,csrf:N}}async function Gs(t,e,p){const u=new FormData;u.append(t.csrfField,e);const _=await fetch(`${t.apiBase}jobs/${p}/process`,{method:"POST",body:u,credentials:"include",headers:{[t.csrfHeader]:e}});let d=null;try{d=await _.json()}catch{d=null}const h=fe(d,e);return _.ok?{ok:!0,data:d??{},csrf:h}:{ok:!1,status:_.status,data:d,csrf:h}}async function ks(t,e,p){const u=await fetch(`${t.apiBase}jobs/${p}`,{method:"GET",credentials:"include",headers:{[t.csrfHeader]:e}});let _=null;try{_=await u.json()}catch{_=null}const d=fe(_,e);return u.ok?{ok:!0,data:_??{},csrf:d}:{ok:!1,status:u.status,data:_,csrf:d}}async function Ks(t,e,p,u){const _=await fetch(`${t.apiBase}jobs/${p}/docx/revision`,{method:"POST",body:u,credentials:"include",headers:{[t.csrfHeader]:e,"Content-Type":"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}});let d=null;try{d=await _.json()}catch{d=null}const h=fe(d,e);return _.ok?{ok:!0,data:d??{},csrf:h}:{ok:!1,status:_.status,data:d,csrf:h}}function a(t,e){var u;const p=(u=t.react)==null?void 0:u[e];return typeof p=="string"&&p.length>0?p:e}function v(t,e){if(!t)return null;const p=t[e];return typeof p=="string"?p:null}function ue(t){if(typeof t=="number"&&Number.isFinite(t))return Math.trunc(t);if(typeof t=="string"&&t.trim()!==""){const e=Number(t);if(Number.isFinite(e))return Math.trunc(e)}return null}function Ss(t){return typeof t=="boolean"?t:t===1||t==="1"?!0:t===0||t==="0"?!1:null}function Vs(){const t=window.navigator,e=Intl.DateTimeFormat().resolvedOptions().timeZone||"",p=window.screen?`${window.screen.width}x${window.screen.height}x${window.devicePixelRatio||1}`:"",u=t.platform||"",_="ocr_device_id";let d="";try{d=window.localStorage.getItem(_)||"",d||(d=`d_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,12)}`,window.localStorage.setItem(_,d))}catch{d=`d_${Math.random().toString(36).slice(2,12)}`}const h=`${t.language||""}|${e}|${p}|${u}|${t.userAgent||""}|${t.hardwareConcurrency||""}|${t.maxTouchPoints||0}`;let N=2166136261;for(let w=0;w<h.length;w+=1)N^=h.charCodeAt(w),N+=(N<<1)+(N<<4)+(N<<7)+(N<<8)+(N<<24);const j=(N>>>0).toString(16),me=new Date(Date.now()+31536e6).toUTCString();return document.cookie=`ocr_device_id=${encodeURIComponent(d)}; expires=${me}; path=/; SameSite=Lax`,{fpHash:j,deviceId:d,timezone:e,screen:p,platform:u}}const Me=r.lazy(()=>Ae(()=>import("./DocxEditorShell.js"),__vite__mapDeps([0,1,2])));function Cs(t,e){return!t||!e?null:`${t.name}:${t.size}|${e.name}:${e.size}`}function Zs(){const t=window.__DOCUMENT_APP__;return t?s.jsx(Xs,{boot:t}):s.jsx("div",{className:"cc-app",children:s.jsx("p",{className:"cc-error",children:"Missing app bootstrap. Open this tool from the website (/app)."})})}function Xs({boot:t}){var xs,gs,bs,ws,vs,ys;const{i18n:e}=t,p=t.maxFileBytes,[u,_]=r.useState(t.isLoggedIn===!0),[d,h]=r.useState(t.csrfToken),N=r.useRef(d);N.current=d;const[j,me]=r.useState(null),[w,We]=r.useState(null),[l,k]=r.useState("idle"),[Je,f]=r.useState(null),[x,$e]=r.useState(null),[he,ne]=r.useState(null),[B,Z]=r.useState(null),[Qe,Ge]=r.useState(!1),[Ke,X]=r.useState(null),[qe,H]=r.useState(!1),[A,I]=r.useState(1),[T,Pe]=r.useState("compare"),[Y,z]=r.useState(null),[ee,M]=r.useState(!1),[Ve,W]=r.useState(null),[re,se]=r.useState(null),[As,J]=r.useState(null),[$s,ie]=r.useState(!1),[qs,Q]=r.useState(null),[Be,ae]=r.useState(null),[te,Ze]=r.useState(null),[Xe,L]=r.useState(null),[Ps,Bs]=r.useState(0),[Ye,Fs]=r.useState(0),[es,ss]=r.useState(0),[Fe,as]=r.useState(!1),[pe,Is]=r.useState(""),[_e,Ie]=r.useState(""),[G,De]=r.useState(!1),[le,oe]=r.useState(!1),[ts,q]=r.useState(null),[xe,cs]=r.useState(null),F=r.useRef(null),D=r.useRef(null),Re=r.useRef(!1),ns=r.useMemo(()=>{const c=t.googleOAuth;if(!(c!=null&&c.configured))return;const n=typeof window<"u"?window.location.href:c.connectUrl.replace(/auth\/google.*/,"app");return{uploadUrl:c.uploadUrl,csrfField:t.csrfField,csrfHeader:t.csrfHeader,csrfToken:d,onCsrfToken:h,connectUrl:c.connectUrl,returnUrl:n}},[t.googleOAuth,t.csrfField,t.csrfHeader,d]),[Ds,Te]=r.useState(!1),ge=r.useRef(!1),rs=r.useRef(null),$=r.useCallback((c,n)=>{if(typeof n>"u"){console.info(`[CC_DEBUG] ${c}`);return}console.info(`[CC_DEBUG] ${c}`,n)},[]),ze=r.useCallback(()=>{as(!1),oe(!1),q(null),De(!1),Ie(""),cs(null),D.current=null;const c=window.turnstile;if(c&&F.current){try{c.remove(F.current)}catch{}F.current=null}},[]),Le=r.useCallback(c=>{cs(c),as(!0),q(null),De(!1),Ie(""),D.current=null},[]);r.useEffect(()=>{var i;$("app:mount",{href:window.location.href,referrer:document.referrer,navType:(i=performance.getEntriesByType("navigation"))!=null&&i[0]?performance.getEntriesByType("navigation")[0].type:"unknown"});const c=()=>$("app:pagehide",{href:window.location.href}),n=()=>$("app:beforeunload",{href:window.location.href});return window.addEventListener("pagehide",c),window.addEventListener("beforeunload",n),()=>{$("app:unmount"),window.removeEventListener("pagehide",c),window.removeEventListener("beforeunload",n)}},[$]),r.useEffect(()=>{if(!Fe)return;const c="cc-quickauth-turnstile",n=window.setInterval(()=>{var m;const i=window.turnstile;if(!(!document.getElementById(c)||!i||!((m=t.quickAuth)!=null&&m.turnstileSiteKey))){if(window.clearInterval(n),F.current){try{i.remove(F.current)}catch{}F.current=null}try{F.current=i.render(`#${c}`,{sitekey:t.quickAuth.turnstileSiteKey,theme:"auto",callback:C=>{D.current=C,q(null)},"error-callback":()=>{D.current=null},"expired-callback":()=>{D.current=null}})}catch{q(a(e,"quickauth_turnstile_error"))}}},120);return()=>window.clearInterval(n)},[(xs=t.quickAuth)==null?void 0:xs.turnstileSiteKey,e,Fe]);const be=r.useRef(null),is=r.useMemo(()=>Cs(j,w),[j,w]),Ue=B!==null&&is!==null&&Ke!==null&&Ke===is,Rs=u&&Ue&&B.sufficient_balance&&qe&&l!=="submitting"&&l!=="polling"&&l!=="ocr",Ts=r.useCallback(()=>{I(1),Z(null),X(null),H(!1),f(null)},[]);r.useEffect(()=>{if(l!=="polling"||x===null)return;const c=async()=>{const i=await ks(t,N.current,x);if(h(i.csrf),!i.ok){const S=v(i.data,"message")??a(e,"poll_error");f(S),k("error");return}const o=i.data,m=v(o,"status"),C=be.current===x&&m==="pending"&&o.async_queued!==!0?{...o,async_queued:!0}:o;ne(C),(m==="completed"||m==="failed")&&(be.current=null,k(m==="completed"?"done":"error"),m==="failed"&&f(v(o,"error_message")??a(e,"status_failed")))};c();const n=window.setInterval(()=>void c(),2500);return()=>window.clearInterval(n)},[t,e,x,l]),r.useEffect(()=>{Te(!1)},[x]),r.useEffect(()=>{const c=t.resumeJobId;if(!(!c||ge.current||!t.featureEnabled)){if(!u){f(a(e,"guest_need_login"));return}ge.current=!0,(async()=>{try{const n=await ks(t,N.current,c);if(h(n.csrf),!n.ok){f(v(n.data,"message")??a(e,"resume_job_error")),ge.current=!1;return}const i=n.data,o=v(i,"status");if($e(c),ne(i),o==="completed"){k("done"),I(3);return}if(o==="failed"){k("error"),f(v(i,"error_message")??a(e,"status_failed")),I(2);return}if(o==="pending"||o==="processing"){k("polling"),I(2);return}I(2)}catch{ge.current=!1,f(a(e,"resume_job_error"))}})()}},[t,t.resumeJobId,t.featureEnabled,u,e]),r.useEffect(()=>{if(typeof window>"u")return;const c=new URLSearchParams(window.location.search);if(c.get("google_docs")!=="1")return;
2Re.current=!0,c.delete("google_docs");const n=new URL(window.location.href);n.searchParams.delete("google_docs"),window.history.replaceState({},"",n.toString())},[]),r.useEffect(()=>{var c;Re.current&&(!((c=t.googleOAuth)!=null&&c.configured)||!t.googleOAuth.connected||l!=="done"||!Y||ee||(Re.current=!1,ss(n=>n+1)))},[t.googleOAuth,l,Y,ee]),r.useEffect(()=>{if(!(l!=="done"||x===null||typeof window>"u"))try{const c=new URL(window.location.href);if(c.searchParams.get("job")===String(x))return;c.searchParams.set("job",String(x)),window.history.replaceState({},"",`${c.pathname}?${c.searchParams.toString()}${c.hash}`)}catch{}},[l,x]);const ls=r.useCallback(async c=>{if(!x||l!=="done")return!1;try{const n=await Ks(t,N.current,x,c);return h(n.csrf),n.ok?(Te(!0),!0):!1}catch{return!1}},[t,x,l]),os=r.useCallback(async()=>{if(xe==="continue"){I(2),await we(!0);return}if(xe==="estimate"){await we(!0);return}xe==="submit"&&await ds(!0)},[xe]),zs=r.useCallback(async()=>{var c,n;if(!((c=t.quickAuth)!=null&&c.quickRegisterUrl)||!((n=t.quickAuth)!=null&&n.quickLoginUrl)){q(a(e,"quickauth_unavailable"));return}if(!pe.trim()){q(a(e,"quickauth_email_required"));return}if(!D.current){q(a(e,"quickauth_turnstile_required"));return}if(G&&!_e){q(a(e,"quickauth_password_required"));return}oe(!0),q(null);try{const i=new FormData,o=Vs();i.append("email",pe.trim()),G&&i.append("password",_e),i.append("fp_hash",o.fpHash),i.append("device_id",o.deviceId),i.append("timezone",o.timezone),i.append("screen",o.screen),i.append("platform",o.platform),i.append("cf-turnstile-response",D.current),i.append(t.csrfField,N.current);const m=G?t.quickAuth.quickLoginUrl:t.quickAuth.quickRegisterUrl,C=await fetch(m,{method:"POST",body:i,credentials:"same-origin",headers:{[t.csrfHeader]:N.current}}),S=await C.json().catch(()=>({})),E=v(S,"csrf_token");if(E&&h(E),!C.ok||S.success!==!0){if((S.email_exists===!0||S.email_exists===1||S.email_exists==="true")&&!G){De(!0),q(v(S,"message")??a(e,"quickauth_need_password")),D.current=null;const P=window.turnstile;if(P&&F.current)try{P.reset(F.current)}catch{}oe(!1);return}q(v(S,"message")??a(e,"quickauth_failed")),D.current=null;const b=window.turnstile;if(b&&F.current)try{b.reset(F.current)}catch{}oe(!1);return}_(!0),ze(),await os()}catch{q(a(e,"quickauth_failed"))}finally{oe(!1)}},[t.csrfField,t.csrfHeader,(gs=t.quickAuth)==null?void 0:gs.quickLoginUrl,(bs=t.quickAuth)==null?void 0:bs.quickRegisterUrl,ze,os,e,pe,G,_e]);async function we(c=!1){var y,b,P,js,Ns;if(f(null),!u&&!c){Le("estimate");return}if(!t.featureEnabled){f(a(e,"feature_off"));return}if(!j||!w){f(a(e,"upload_both"));return}if(j.size>p||w.size>p){f(a(e,"max_file").replace("{mb}",String(t.maxFileMb)));return}Ge(!0);const n=await Qs(t,d,j,w);if(h(n.csrf),Ge(!1),!n.ok){f(v(n.data,"message")??`HTTP ${n.status}`);return}const i=ue((y=n.data)==null?void 0:y.pages_old),o=ue((b=n.data)==null?void 0:b.pages_new),m=ue((P=n.data)==null?void 0:P.credits_estimated),C=ue((js=n.data)==null?void 0:js.credits_balance),S=Ss((Ns=n.data)==null?void 0:Ns.sufficient_balance);if(i===null||o===null||m===null||C===null||S===null){f(a(e,"error_generic"));return}const E=Cs(j,w);if(!E){f(a(e,"error_generic"));return}X(E),H(!1),Z({pages_old:i,pages_new:o,credits_estimated:m,credits_balance:C,sufficient_balance:S})}async function ds(c=!1){var C,S,E;if(f(null),!u&&!c){Le("submit");return}if(!t.featureEnabled){f(a(e,"feature_off")),k("error");return}if(!j||!w){f(a(e,"upload_both"));return}if(j.size>p||w.size>p){f(a(e,"max_file").replace("{mb}",String(t.maxFileMb)));return}if(!Ue||!B){f(a(e,"need_estimate_first"));return}if(!B.sufficient_balance){f(a(e,"insufficient_credits"));return}if(!qe){f(a(e,"need_charge_consent"));return}Z(null),X(null),H(!1),k("submitting");const n=await Js(t,d,j,w);if(h(n.csrf),!n.ok){if(n.status===400&&v(n.data,"error_code")==="insufficient_credits"){const y=(C=n.data)==null?void 0:C.credits_required,b=(S=n.data)==null?void 0:S.credits_balance,P=typeof y=="number"&&typeof b=="number"?` (${a(e,"credits_need")} ${y}, ${a(e,"credits_have")} ${b})`:"";f(a(e,"insufficient_credits")+P)}else f(v(n.data,"message")??`HTTP ${n.status}`);k("error");return}const i=ue((E=n.data)==null?void 0:E.job_id);if(i===null||i<1){f(a(e,"error_generic")),k("error");return}$e(i),ne(n.data);const o=v(n.data,"status");if(o==="completed"){k("done");return}if(o==="failed"){k("error"),f(v(n.data,"error_message")??a(e,"status_failed"));return}k("ocr");let m=!1;try{const y=await Gs(t,n.csrf,i);if(h(y.csrf),y.ok&&y.data){ne(y.data);const b=v(y.data,"status");if(b==="completed"){k("done");return}if(b==="failed"){k("error"),f(v(y.data,"error_message")??a(e,"status_failed"));return}y.data.async_queued===!0&&(be.current=i),m=!0}else if(!y.ok){y.status===503?f(v(y.data,"message")??a(e,"process_disabled")):f(v(y.data,"message")??`HTTP ${y.status}`),k("error");return}}catch{f(a(e,"process_network_error")),k("error");return}m&&k("polling")}const us=(c="unknown")=>{$("reset:start",{reason:c,phase:l,jobId:x,wizardStep:A});try{if(typeof window<"u"){const n=new URL(window.location.href);if(n.searchParams.has("job")){n.searchParams.delete("job");const i=n.searchParams.toString();window.history.replaceState({},"",`${n.pathname}${i?`?${i}`:""}${n.hash}`)}}}catch{}be.current=null,me(null),We(null),$e(null),ne(null),Z(null),X(null),H(!1),f(null),k("idle"),I(1),Pe("compare"),z(null),M(!1),W(null),se(null),J(null),ie(!1),Q(null),ae(null),Ze(null),L(null),Te(!1)},g=he,Ls=g?v(g,"status"):null,R=g&&typeof g.pages_old=="number"&&typeof g.pages_new=="number"&&typeof g.credits_estimated=="number"&&g?{pages_old:g.pages_old,pages_new:g.pages_new,credits_estimated:g.credits_estimated}:B,fs=u?B!==null?B.credits_balance:t.userCredits:null,ve=g&&typeof g.artifacts=="object"&&g.artifacts!==null?g.artifacts:null,de=ve?v(ve,"baseline_docx"):null,U=ve?v(ve,"revision_docx"):null,ye=Ss(g==null?void 0:g.revision_docx_user_saved)===!0||Ds,je=g==null?void 0:g.result,O=je&&typeof je=="object"&&je!==null?je:null,Ne=O&&typeof O.preview=="object"&&O.preview!==null?O.preview:null,ke=Ne?v(Ne,"baseline_plain"):null,K=Ne?v(Ne,"revision_plain"):null;r.useEffect(()=>{l==="done"&&(U||K)&&I(3)},[l,U,K]);const Se=r.useMemo(()=>
2{if(!(w!=null&&w.name))return"new-edition.docx";const c=w.name.replace(/\.pdf$/i,"").trim();return c?`${c}.docx`:"new-edition.docx"},[w]),Oe=r.useMemo(()=>{if(!(j!=null&&j.name))return"baseline.docx";const c=j.name.replace(/\.pdf$/i,"").trim();return c?`${c}.docx`:"baseline.docx"},[j]),ce=O&&typeof O.openai=="object"&&O.openai!==null?O.openai:null,ms=ce&&Array.isArray(ce.changes)?ce.changes.filter(c=>typeof c=="object"&&c!==null):[],Us=ce&&Array.isArray(ce.local_changes)?ce.local_changes.filter(c=>typeof c=="object"&&c!==null):[],hs=ms.length>0?ms:Us,V=r.useMemo(()=>{if(ye)return[];if(l!=="done"||!he)return[];const c=he.result;if(!c||typeof c!="object")return[];const n=c.openai;if(!n||typeof n!="object")return[];const i=Array.isArray(n.changes)?n.changes:[],o=Array.isArray(n.local_changes)?n.local_changes:[],m=i.length>0?i:o;if(!Array.isArray(m))return[];const C=(E,y)=>{if(typeof y!="string")return;const b=y.trim();b.length>=4&&!E.includes(b)&&E.push(b)},S=[];return m.forEach((E,y)=>{if(typeof E!="object"||E===null)return;const b=E,P=[];C(P,b.new_excerpt),C(P,b.old_excerpt),P.length!==0&&S.push({changeId:String(b.id??`idx-${y}`),texts:P,severity:typeof b.severity_hint=="string"?b.severity_hint:"low",aiComment:typeof b.ai_comment=="string"&&b.ai_comment.trim()!==""?b.ai_comment:typeof b.summary=="string"?b.summary:""})}),S},[l,he,ye]);r.useEffect(()=>{$("highlightItems rebuilt",{count:V.length,ids:V.map(c=>c.changeId),phase:l,jobId:x})},[$,V,x,l]);const Ce=r.useMemo(()=>V.map(c=>({changeId:c.changeId,texts:[...c.texts],aiComment:c.aiComment??""})),[V]),Ee=r.useMemo(()=>{const c=new Set(V.map(i=>i.changeId)),n=[];return hs.forEach((i,o)=>{const m=String(i.id??`idx-${o}`);c.has(m)&&!n.includes(m)&&n.push(m)}),n},[hs,V]);r.useEffect(()=>{if(l!=="done"||x===null){z(null),M(!1),W(null),se(null),L(null);return}const c=(K==null?void 0:K.trim())??"";if(!U&&!c){z(null),M(!1),W(null),se(null),L(null);return}let n=!1;return M(!0),W(null),(async()=>{try{let i=null;if(U)try{const o=await fetch(U,{credentials:"same-origin"});o.ok&&(i=await o.arrayBuffer())}catch{i=null}if(!i&&c){const{plainTextToDocxBuffer:o}=await Ae(async()=>{const{plainTextToDocxBuffer:m}=await import("./plainTextToDocx.js");return{plainTextToDocxBuffer:m}},[]);i=await o(c)}if(n)return;i?(se(i),W(null),$("docx revision source ready",{hasDocx:!!U})):(z(null),W(a(e,"docx_embed_fail")),se(null),L(null))}catch{n||(z(null),W(a(e,"docx_embed_fail")),se(null),L(null))}finally{n||M(!1)}})(),()=>{n=!0}},[l,K,U,x,Se,e,$]),r.useEffect(()=>{if(!re){z(null),L(null);return}let c=!1;return M(!0),(async()=>{try{let n=re,i=null;if(Ce.length>0&&!ye){const{applyDocxAiHighlights:o}=await Ae(async()=>{const{applyDocxAiHighlights:C}=await import("./applyDocxAiHighlights.js");return{applyDocxAiHighlights:C}},__vite__mapDeps([3,1,2])),m=await o(re,Ce,te);n=m.buffer,i=m.focusParagraphIndex}if(c)return;z({buffer:n,fileName:Se}),L(i),$("docx ready",{focusChangeId:te,focusParagraph:i,hasHighlights:Ce.length>0})}catch{c||(z({buffer:re,fileName:Se}),L(null))}finally{c||M(!1)}})(),()=>{c=!0}},[re,Ce,te,Ps,Se,ye,$]),r.useEffect(()=>{if(l!=="done"||x===null){J(null),ie(!1),Q(null),ae(null);return}const c=(ke==null?void 0:ke.trim())??"";if(!de&&!c){J(null),ie(!1),Q(null),ae(null);return}let n=!1;return ie(!0),Q(null),(async()=>{try{let i=null;if(de)try{const o=await fetch(de,{credentials:"same-origin"});o.ok&&(i=await o.arrayBuffer())}catch{i=null}if(!i&&c){const{plainTextToDocxBuffer:o}=await Ae(async()=>{const{plainTextToDocxBuffer:m}=await import("./plainTextToDocx.js");return{plainTextToDocxBuffer:m}},[]);i=await o(c)}if(n)return;i?(ae(i),Q(null),$("docx baseline ready",{hasDocx:!!de})):(J(null),Q(a(e,"docx_embed_fail")),ae(null))}catch{n||(J(null),Q(a(e,"docx_embed_fail")),ae(null))}finally{n||ie(!1)}})(),()=>{n=!0}},[l,x,ke,de,Oe,e,$]),r.useEffect(()=>{if(!Be){J(null);return}J({buffer:Be,fileName:Oe})},[Be,Oe]);const Os=r.useCallback(()=>{const c=rs.current;if(c){if(document.fullscreenElement){document.exitFullscreen();return}c.requestFullscreen()}},[]);r.useEffect(()=>{Ee.length!==0&&(!te||!Ee.includes(te))&&(Ze(Ee[0]),Bs(c=>c+1))},[T,te,Ee]);const ps=r.useMemo(()=>
2{if(!(l!=="done"||x===null||!u))return{enabled:!0,intervalMs:9e4,save:ls,statusIdle:a(e,"cloud_save_idle"),statusOk:a(e,"cloud_save_ok"),statusErr:a(e,"cloud_save_err")}},[l,x,u,ls,e]),Hs=r.useCallback(()=>{if(!(!x||typeof window>"u"))try{const c=new URL(window.location.href);c.searchParams.set("job",String(x)),navigator.clipboard.writeText(c.toString())}catch{}},[x]),Ms=R?`${Math.max(R.pages_old,R.pages_new)}×${t.creditsPerPage}`:`—×${t.creditsPerPage}`,He={c1:A===1?"current":"done",c2:A===1?"upcoming":A===2?"current":"done",c3:A===3?"current":"upcoming"},_s=s.jsx("nav",{className:"cc-flow-steps","aria-label":a(e,"flow_aria"),children:s.jsxs("ol",{className:"cc-wizard-crumbs-list cc-wizard-crumbs-list--in-card",children:[s.jsxs("li",{className:`cc-crumb cc-crumb--${He.c1}`,"aria-current":A===1?"step":void 0,children:[s.jsx("span",{className:"cc-crumb-num",children:"1"}),s.jsx("span",{className:"cc-crumb-label",children:a(e,"wizard_crumb_upload")})]}),s.jsxs("li",{className:`cc-crumb cc-crumb--${He.c2}`,"aria-current":A===2?"step":void 0,children:[s.jsx("span",{className:"cc-crumb-num",children:"2"}),s.jsx("span",{className:"cc-crumb-label",children:a(e,"wizard_crumb_estimate")})]}),s.jsxs("li",{className:`cc-crumb cc-crumb--${He.c3}`,"aria-current":A===3?"step":void 0,children:[s.jsx("span",{className:"cc-crumb-num",children:"3"}),s.jsx("span",{className:"cc-crumb-label",children:a(e,"wizard_crumb_review")})]})]})});return s.jsxs("div",{className:"cc-app",children:[A!==3?s.jsxs("header",{className:"cc-hero",children:[(ws=e.badge)!=null&&ws.trim()?s.jsx("div",{className:"cc-badge",children:e.badge}):null,s.jsx("h1",{className:"cc-title",children:e.title??"Compare contracts"}
2),s.jsx("p",{className:"cc-sub",children:e.subtitle??""}),A===1&&((vs=e.preview_notice)!=null&&vs.trim())?s.jsx("p",{className:"cc-notice",children:e.preview_notice}):null]}):null,!u&&s.jsxs("div",{className:"cc-guest-banner",role:"status",children:[s.jsx("p",{className:"cc-guest-banner-text",children:a(e,"guest_banner")}),s.jsxs("div",{className:"cc-guest-banner-actions",children:[s.jsxs("a",{className:"cc-btn cc-btn-sm",href:t.loginUrl,children:[s.jsx("i",{className:"fas fa-sign-in-alt","aria-hidden":!0}),a(e,"guest_login")]}),s.jsx("a",{className:"cc-btn cc-btn-secondary cc-btn-sm",href:t.registerUrl,children:a(e,"guest_register")})]})]}),!t.featureEnabled&&s.jsx("div",{className:"cc-error",role:"status",children:a(e,"feature_off_detail")}),Fe&&s.jsx("div",{role:"dialog","aria-modal":"true","aria-label":a(e,"quickauth_title"),style:{position:"fixed",inset:0,zIndex:1100,background:"rgba(2,6,23,.55)",display:"flex",alignItems:"center",justifyContent:"center",padding:"1rem"},children:s.jsx("div",{className:"cc-card",style:{maxWidth:520,width:"100%"},children:s.jsxs("div",{className:"cc-pad",style:{display:"grid",gap:".75rem"},children:[s.jsx("h3",{style:{margin:0},children:a(e,"quickauth_title")}),s.jsx("p",{className:"cc-muted",style:{margin:0},children:a(e,"quickauth_desc")}),s.jsx("input",{type:"email",value:pe,onChange:c=>Is(c.target.value),placeholder:a(e,"quickauth_email_placeholder"),className:"cc-input",disabled:le}),G&&s.jsx("input",{type:"password",value:_e,onChange:c=>Ie(c.target.value),placeholder:a(e,"quickauth_password_placeholder"),className:"cc-input",disabled:le}),s.jsx("div",{id:"cc-quickauth-turnstile"}),ts?s.jsx("div",{className:"cc-error",children:ts}
2):null,s.jsxs("div",{className:"cc-actions cc-actions-row",children:[s.jsx("button",{type:"button",className:"cc-btn cc-btn-secondary",onClick:ze,disabled:le,children:a(e,"quickauth_cancel")}),s.jsx("button",{type:"button",className:"cc-btn",onClick:()=>void zs(),disabled:le,children:le?a(e,"quickauth_processing"):G?a(e,"quickauth_sign_in"):a(e,"quickauth_continue")})]})]})})}),s.jsxs("div",{className:`cc-wizard-shell${A===3?" cc-wizard-shell--review":""}`,children:[A===1&&t.featureEnabled&&s.jsxs("div",{className:"cc-wizard-step cc-wizard-step--upload",children:[s.jsxs("section",{className:"cc-card cc-card--full","aria-labelledby":"cc-upload-heading",children:[s.jsxs("div",{className:"cc-card-h cc-card-h--split",children:[s.jsxs("div",{className:"cc-card-h-main",children:[s.jsx("div",{className:"cc-card-h-icon","aria-hidden":!0,children:s.jsx("i",{className:"fas fa-file-upload"})}),s.jsxs("div",{className:"cc-card-h-text",children:[s.jsx("h2",{id:"cc-upload-heading",children:e.upload_section_title??"Documents"}),(ys=e.upload_section_hint)!=null&&ys.trim()?s.jsx("p",{className:"cc-card-h-lead",children:e.upload_section_hint}):null]})]}),s.jsx("div",{className:"cc-card-h-aside",children:_s})]}),s.jsx("div",{className:"cc-pad",children:s.jsxs("div",{className:"cc-upload-grid",children:[s.jsxs("div",{className:"cc-field",children:[s.jsxs("div",{className:"cc-label-row",children:[s.jsx("span",{className:"cc-label",id:"cc-lbl-old",children:e.label_old??"Baseline"}),s.jsx("span",{className:`cc-file-pill ${j?"cc-file-ok":""}`,children:j?a(e,"file_ready"):a(e,"file_missing")})]}),s.jsxs("label",{className:"cc-drop",htmlFor:"cc-input-old",children:[s.jsx("input",{id:"cc-input-old",type:"file",accept:"application/pdf,.pdf",disabled:l==="submitting"||l==="polling"||l==="ocr",onChange:c=>{var n;me(((n=c.target.files)==null?void 0:n[0])??null),Z(null),X(null),H(!1)}}),s.jsxs("div",{className:"cc-drop-inner",children:[s.jsx("div",{className:"cc-drop-icon-wrap","aria-hidden":!0,children:s.jsx("i",{className:"fas fa-file-pdf"})}),s.jsx("p",{className:"cc-drop-hint",children:e.drop_hint??"Select file"}),s.jsx("div",{className:"cc-muted",children:e.pdf_only??"PDF"}),j&&s.jsx("div",{className:"cc-drop-name",children:j.name})]})]})]}),s.jsxs("div",{className:"cc-field",children:[s.jsxs("div",{className:"cc-label-row",children:[s.jsx("span",{className:"cc-label",id:"cc-lbl-new",children:e.label_new??"Revision"}),s.jsx("span",{className:`cc-file-pill ${w?"cc-file-ok":""}`,children:w?a(e,"file_ready"):a(e,"file_missing")})]}),s.jsxs("label",{className:"cc-drop",htmlFor:"cc-input-new",children:[s.jsx("input",{id:"cc-input-new",type:"file",accept:"application/pdf,.pdf",disabled:l==="submitting"||l==="polling"||l==="ocr",onChange:c=>{var n;We(((n=c.target.files)==null?void 0:n[0])??null),Z(null),X(null),H(!1)}}),s.jsxs("div",{className:"cc-drop-inner",children:[s.jsx("div",{className:"cc-drop-icon-wrap","aria-hidden":!0,children:s.jsx("i",{className:"fas fa-file-pdf"})}),s.jsx("p",{className:"cc-drop-hint",children:e.drop_hint??"Select file"}),s.jsx("div",{className:"cc-muted",children:e.pdf_only??"PDF"}),w&&s.jsx("div",{className:"cc-drop-name",children:w.name})]})]})]})]})})]}),s.jsx("p",{className:"cc-wizard-step1-help",children:a(e,"wizard_step1_help")}),s.jsxs("section",{className:"cc-ai cc-ai--step1 cc-ai--full","aria-labelledby":"cc-ai-h",children:[s.jsxs("div",{className:"cc-ai-h",id:"cc-ai-h",children:[s.jsx("i",{className:"fas fa-robot","aria-hidden":!0}),e.ai_panel_title??"AI"]}),s.jsx("p",{children:a(e,"ai_roadmap")})]}),s.jsx("div",{className:"cc-wizard-footer-cta",children:s.jsxs("button",{type:"button",className:"cc-btn",disabled:!j||!w||!t.featureEnabled||l==="submitting"||l==="polling"||l==="ocr",onClick:()=>{if(!u){Le("continue");return}I(2),we()},children:[a(e,"wizard_continue"),s.jsx("i",{className:"fas fa-arrow-right","aria-hidden":!0,style:{marginLeft:"0.35rem"}})]})})]}),A===2&&t.featureEnabled&&s.jsx("div",{className:"cc-wizard-step cc-wizard-step--estimate",children:s.jsxs("section",{className:"cc-card cc-card--full","aria-labelledby":"
2cc-est-heading",children:[s.jsxs("div",{className:"cc-card-h cc-card-h--split",children:[s.jsxs("div",{className:"cc-card-h-main",children:[s.jsx("div",{className:"cc-card-h-icon","aria-hidden":!0,children:s.jsx("i",{className:"fas fa-calculator"})}),s.jsxs("div",{className:"cc-card-h-text",children:[s.jsx("h2",{id:"cc-est-heading",children:e.estimate_title??"Estimate"}),s.jsx("p",{className:"cc-card-h-lead",children:a(e,"estimate_help")})]})]}),s.jsxs("div",{className:"cc-card-h-aside",children:[_s,s.jsxs("button",{type:"button",className:"cc-btn cc-btn-secondary cc-btn-sm",onClick:Ts,children:[s.jsx("i",{className:"fas fa-arrow-left","aria-hidden":!0}),a(e,"wizard_back")]})]})]}),s.jsxs("div",{className:"cc-pad",children:[s.jsxs("div",{className:"cc-stat-grid",children:[s.jsxs("div",{className:"cc-stat",children:[s.jsx("span",{className:"cc-stat-k",children:e.pages_old??"Baseline pages"}),s.jsx("span",{className:"cc-stat-v",children:R?R.pages_old:"—"})]}),s.jsxs("div",{className:"cc-stat",children:[s.jsx("span",{className:"cc-stat-k",children:e.pages_new??"New pages"}),s.jsx("span",{className:"cc-stat-v",children:R?R.pages_new:"—"})]}),s.jsxs("div",{className:"cc-stat",children:[s.jsx("span",{className:"cc-stat-k",children:a(e,"stat_rate")}),s.jsx("span",{className:"cc-stat-v",children:Ms})]}),s.jsxs("div",{className:"cc-stat",children:[s.jsx("span",{className:"cc-stat-k",children:e.total_credits??"Total"}),s.jsx("span",{className:"cc-stat-v cc-stat-accent",children:R?R.credits_estimated:"—"})]})]}),s.jsxs("div",{className:"cc-balance",children:[s.jsxs("div",{children:[s.jsx("div",{className:"cc-stat-k",style:{marginBottom:"0.15rem"},children:e.balance_label??"Balance"}),fs!==null?s.jsxs("div",{className:"cc-balance-val",children:[fs," ",s.jsx("span",{style:{fontWeight:600,fontSize:"0.85rem",color:"#64748b"},children:e.credits_word??""})]}):s.jsx("div",{className:"cc-muted",style:{marginTop:"0.25rem"},children:e.balance_login_hint??""})]}),t.paymentBuyUrl&&s.jsxs("a",{className:"cc-link-btn",href:t.paymentBuyUrl,children:[s.jsx("i",{className:"fas fa-coins","aria-hidden":!0}),a(e,"buy_credits")]})]}),Je&&s.jsx("div",{className:"cc-error",children:Je}),u&&B&&!B.sufficient_balance&&x===null&&s.jsx("div",{className:"cc-warn",role:"status",children:a(e,"estimate_insufficient")}),u&&Ue&&B.sufficient_balance&&x===null&&l!=="submitting"&&l!=="polling"&&l!=="ocr"&&s.jsxs("label",{className:"cc-consent",children:[s.jsx("input",{type:"checkbox",checked:qe,onChange:c=>H(c.target.checked)}),s.jsx("span",{children:a(e,"charge_consent_label").replace("{credits}",String(B.credits_estimated))})]}),(l==="ocr"||l==="polling")&&s.jsxs("div",{className:"cc-status",role:"status",children:[s.jsx("span",{className:"cc-spinner","aria-hidden":!0}),l==="ocr"||Ls==="processing"?a(e,"status_ocr_running"):g&&g.async_queued===!0?a(e,"status_background_started"):a(e,"status_pending")]}),s.jsxs("div",{className:"cc-actions cc-actions-row",children:[s.jsxs("button",{type:"button",className:"cc-btn cc-btn-secondary",disabled:!t.featureEnabled||Qe||l==="submitting"||l==="polling"||l==="ocr"||!j||!w,onClick:()=>void we(),children:[s.jsx("i",{className:"fas fa-calculator","aria-hidden":!0}),Qe?a(e,"btn_estimating"):a(e,"btn_estimate_only")]}),s.jsxs("button",{type:"button",className:"cc-btn",disabled:!t.featureEnabled||l==="submitting"||l==="polling"||l==="ocr"||!j||!w||!Rs,onClick:()=>void ds(),children:[s.jsx("i",{className:"fas fa-play","aria-hidden":!0}),l==="submitting"?a(e,"btn_working"):a(e,"btn_confirm_start")]}),l==="error"&&s.jsxs("button",{type:"button",className:"cc-btn cc-btn-secondary",onClick:()=>us("error-reset-click"),children:[s.jsx("i",{className:"fas fa-redo","aria-hidden":!0}),a(e,"btn_reset")]})]}),s.jsx("p",{className:"cc-hint",children:a(e,"worker_hint")}),v(g,"message")&&(l==="polling"||l==="ocr")&&!(g&&g.async_queued===!0)&&s.jsx("p",{className:"cc-hint",style:{marginTop:"0.5rem"},children:v(g,"message")}),g&&g.async_queued===!0&&(l==="polling"||l==="ocr")&&s.jsx("p",{className:"cc-hint",style:{marginTop:"0.5rem"},children:a(e,"status_background_detail")})]})]})}),A===3&&t.featureEnabled&&l==="done"&&(U||K)&&s.jsx("div",{className:"cc-review-layout",children:s.jsxs("div",{className:"cc-review-main",children:[s.jsxs("div",{className:"cc-review-tabs",role:"tablist","aria-label":a(e,"review_tabs_aria"),children:[s.jsxs("div",{className:"cc-review-tabs-left",children:[s.jsxs("button",{type:"button",role:"tab","aria-selected":T==="compare",className:`cc-review-tab${T==="compare"?" cc-review-tab--active":""}`,onClick:()=>Pe("compare"),children:[s.jsx("i",{className:"fas fa-columns","aria-hidden":!0}),"Compare"]},"tab-compare"),s.jsxs("button",{type:"button",role:"tab","aria-selected":T==="revision",className:`cc-review-tab${T==="revision"?" cc-review-tab--active":""}`,onClick:()=>Pe("revision"),children:[s.jsx("i",{className:"fas fa-file-word","aria-hidden":!0}),"Latest revision"]},"tab-revision"),s.jsxs("button",{type:"button",className:"cc-review-tab",disabled:ee||!Y,title:a(e,"google_docs_title"),onClick:()=>{ss(c=>c+1)},children:[s.jsx("i",{className:"fas fa-file-export","aria-hidden":!0}),a(e,"google_docs_btn")]})]}),s.jsx("div",{className:"cc-review-tabs-center",children:s.jsx("h2",{className:"cc-review-title",children:e.title??"Compare contract revisions"})}),s.jsxs("div",{className:"cc-review-tabs-right",children:[x!==null?s.jsxs("div",{className:"cc-permalink-row",children:[s.jsxs("code",{title:a(e,"job_permalink_hint"),children:["#",x]}),s.jsxs("button",{type:"button",className:"cc-btn cc-btn-secondary cc-btn-sm",title:a(e,"job_permalink_hint"),onClick:()=>Hs(),children:[s.jsx("i",{className:"fas fa-link","aria-hidden":!0}),a(e,"job_link_copy")]})]}
2):null,s.jsxs("button",{type:"button",className:"cc-btn cc-btn-secondary cc-btn-sm",onClick:()=>us("review-top-new-comparison"),children:[s.jsx("i",{className:"fas fa-redo","aria-hidden":!0}),a(e,"review_new_comparison")]}),s.jsxs("button",{type:"button",className:"cc-btn cc-btn-secondary cc-btn-sm",onClick:()=>Fs(c=>c+1),disabled:ee||!Y,children:[s.jsx("i",{className:"fas fa-download","aria-hidden":!0}),"Download docx"]}),T==="revision"&&s.jsx("button",{type:"button",className:"cc-icon-nav-btn",title:"Fullscreen","aria-label":"Fullscreen",onClick:Os,children:s.jsx("i",{className:"fas fa-expand","aria-hidden":!0})})]})]}),s.jsxs("div",{className:"cc-review-panel",children:[T==="compare"&&s.jsx("div",{id:"cc-docx-panel",className:"cc-review-word",children:s.jsx(r.Suspense,{fallback:s.jsxs("div",{className:"cc-status",role:"status",children:[s.jsx("span",{className:"cc-spinner","aria-hidden":!0}),a(e,"docx_chunk_loading")]}),children:s.jsxs("div",{className:"cc-word-diff",children:[s.jsx("div",{className:"cc-word-diff-pane",children:s.jsx(Me,{embeddedDocx:As,embeddedLoading:$s,embeddedError:qs,readOnly:!0,allowLocalFileActions:!1,hideChromeLabel:!0,labels:{pick:a(e,"docx_pick"),clear:a(e,"docx_clear"),save_download:a(e,"docx_save_download"),hint:a(e,"docx_hint"),placeholder:a(e,"docx_placeholder"),error_read:a(e,"docx_error_read"),error_size:a(e,"docx_error_size"),doc_name_fallback:a(e,"docx_name_fallback"),author:a(e,"docx_author"),seed_empty:a(e,"docx_seed_empty"),seeding:a(e,"docx_seeding")}})}),s.jsx("div",{className:"cc-word-diff-pane",children:s.jsx(Me,{embeddedDocx:Y,embeddedLoading:ee,embeddedError:Ve,focusParagraphIndex:Xe,readOnly:!1,allowLocalFileActions:!1,hideChromeLabel:!0,downloadRequestNonce:Ye,googleDocsFlowNonce:es,googleDriveDirectUpload:ns,revisionCloudSave:ps,labels:{pick:a(e,"docx_pick"),clear:a(e,"docx_clear"),save_download:a(e,"docx_save_download"),hint:a(e,"docx_hint"),placeholder:a(e,"docx_placeholder"),error_read:a(e,"docx_error_read"),error_size:a(e,"docx_error_size"),doc_name_fallback:a(e,"docx_name_fallback"),author:a(e,"docx_author"),seed_empty:a(e,"docx_seed_empty"),seeding:a(e,"docx_seeding")}})})]})})}),T==="revision"&&s.jsx("div",{ref:rs,className:"cc-review-word cc-review-word--single",children:s.jsx(r.Suspense,{fallback:s.jsxs("div",{className:"cc-status",role:"status",children:[s.jsx("span",{className:"cc-spinner","aria-hidden":!0}),a(e,"docx_chunk_loading")]}),children:s.jsx("div",{className:"cc-word-diff-pane cc-word-diff-pane--single",children:s.jsx(Me,{embeddedDocx:Y,embeddedLoading:ee,embeddedError:Ve,focusParagraphIndex:Xe,readOnly:!1,allowLocalFileActions:!1,hideChromeLabel:!0,downloadRequestNonce:Ye,googleDocsFlowNonce:es,googleDriveDirectUpload:ns,revisionCloudSave:ps,labels:{pick:a(e,"docx_pick"),clear:a(e,"docx_clear"),save_download:a(e,"docx_save_download"),hint:a(e,"docx_hint"),placeholder:a(e,"docx_placeholder"),error_read:a(e,"docx_error_read"),error_size:a(e,"docx_error_size"),doc_name_fallback:a(e,"docx_name_fallback"),author:a(e,"docx_author"),seed_empty:a(e,"docx_seed_empty"),seeding:a(e,"docx_seeding")}})})})})]}),s.jsx("div",{className:"cc-review-footer-note",children:a(e,"docx_hint")})]})})]})]})}const Es=document.getElementById("document-app-root");Es&&Ws(Es).render(s.jsx(r.StrictMode,{children:s.jsx(Zs,{})}));

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.