195 lines
140 KiB
JavaScript
195 lines
140 KiB
JavaScript
|
|
import{j as b,c as vr,v as Ar,M as jr,r as Cr,a as kr}from"./vendor-markdown-C0b4qDwm.js";import{a as Sr,r as H,g as Er}from"./vendor-react-C6WG4Va-.js";import"./vendor-katex-p018AHG0.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))s(e);new MutationObserver(e=>{for(const r of e)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function f(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),e.crossOrigin==="use-credentials"?r.credentials="include":e.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function s(e){if(e.ep)return;e.ep=!0;const r=f(e);fetch(e.href,r)}})();var Dt,St=Sr;Dt=St.createRoot,St.hydrateRoot;const Et={development:{apiBaseUrl:"https://cloud.texpixel.com:10443/doc_ai/v1",env:"development"},production:{apiBaseUrl:"https://api.texpixel.com/doc_ai/v1",env:"production"}},_r="development",Tr=Et[_r]||Et.development,Ot=Tr.apiBaseUrl,ct="texpixel_token",Qe="texpixel_token_expires",ut="texpixel_user_email",ye={getToken(){return localStorage.getItem(ct)},setToken(t,n,f){localStorage.setItem(ct,t),localStorage.setItem(Qe,n.toString()),f&&localStorage.setItem(ut,f)},removeToken(){localStorage.removeItem(ct),localStorage.removeItem(Qe),localStorage.removeItem(ut)},getEmail(){return localStorage.getItem(ut)},isTokenValid(){const t=this.getToken(),n=localStorage.getItem(Qe);if(!t||!n)return!1;const f=parseInt(n,10)*1e3;return Date.now()<f-5*60*1e3},getExpiresAt(){const t=localStorage.getItem(Qe);return t?parseInt(t,10):null}};class Me extends Error{constructor(n,f,s){super(f),this.code=n,this.requestId=s,this.name="ApiError"}}async function Ve(t,n={}){const{skipAuth:f=!1,headers:s,...e}=n,r={"Content-Type":"application/json",...s};if(!f){const c=ye.getToken();c&&(r.Authorization=c)}const o=`${Ot}${t}`;try{const w=await(await fetch(o,{...e,headers:r})).json();if(w.code!==200)throw new Me(w.code,w.message,w.request_id);return w}catch(c){throw c instanceof Me?c:new Me(-1,"网络错误,请检查网络连接")}}const Pe={get(t,n){return Ve(t,{...n,method:"GET"})},post(t,n,f){return Ve(t,{...f,method:"POST",body:n?JSON.stringify(n):void 0})},put(t,n,f){return Ve(t,{...f,method:"PUT",body:n?JSON.stringify(n):void 0})},delete(t,n){return Ve(t,{...n,method:"DELETE"})}};var xe=(t=>(t[t.Pending=0]="Pending",t[t.Processing=1]="Processing",t[t.Completed=2]="Completed",t[t.Failed=3]="Failed",t))(xe||{});const Ur={200:"操作成功",400:"参数错误",401:"未授权,请先登录",403:"无权限访问",404:"资源不存在",405:"状态无效",500:"服务器错误,请稍后重试",501:"系统错误,请稍后重试",1001:"任务未完成",1002:"记录重复",1003:"验证码错误",1004:"该邮箱已注册",1005:"该邮箱未注册",1006:"密码错误"};function dt(t){try{const f=t.replace("Bearer ","").split(".")[1];return JSON.parse(atob(f))}catch{return null}}const qe={async login(t){const n=await Pe.post("/user/login",t,{skipAuth:!0});if(!n.data)throw new Me(-1,"登录失败,请重试");const{token:f,expires_at:s}=n.data;ye.setToken(f,s,t.email);const e=dt(f);if(!e)throw new Me(-1,"Token 解析失败");return{user:{...e,email:t.email,id:String(e.user_id)},token:f,expiresAt:s}},async register(t){const n=await Pe.post("/user/register",t,{skipAuth:!0});if(!n.data)throw new Me(-1,"注册失败,请重试");const{token:f,expires_at:s}=n.data;ye.setToken(f,s,t.email);const e=dt(f);if(!e)throw new Me(-1,"Token 解析失败");return{user:{...e,email:t.email,id:String(e.user_id)},token:f,expiresAt:s}},logout(){ye.removeToken()},isAuthenticated(){return ye.isTokenValid()},getToken(){return ye.getToken()},restoreSession(){const t=ye.getToken(),n=ye.getExpiresAt(),f=ye.getEmail();if(!t||!n||!ye.isTokenValid())return ye.removeToken(),null;const s=dt(t);return s?{user:{...s,email:f||"",id:String(s.user_id)},token:t,e
|
||
|
|
let scriptImported = false
|
||
|
|
self.addEventListener('message', async (e) => {
|
||
|
|
const { file, id, imageCompressionLibUrl, options } = e.data
|
||
|
|
options.onProgress = (progress) => self.postMessage({ progress, id })
|
||
|
|
try {
|
||
|
|
if (!scriptImported) {
|
||
|
|
// console.log('[worker] importScripts', imageCompressionLibUrl)
|
||
|
|
self.importScripts(imageCompressionLibUrl)
|
||
|
|
scriptImported = true
|
||
|
|
}
|
||
|
|
// console.log('[worker] self', self)
|
||
|
|
const compressedFile = await imageCompression(file, options)
|
||
|
|
self.postMessage({ file: compressedFile, id })
|
||
|
|
} catch (e) {
|
||
|
|
// console.error('[worker] error', e)
|
||
|
|
self.postMessage({ error: e.message + '\\n' + e.stack, id })
|
||
|
|
}
|
||
|
|
})
|
||
|
|
`;let ft;function Wr(t,n){return new Promise((f,s)=>{ft||(ft=function(o){const c=[];return c.push(o),URL.createObjectURL(new Blob(c))}(qr));const e=new Worker(ft);e.addEventListener("message",function(o){if(n.signal&&n.signal.aborted)e.terminate();else if(o.data.progress===void 0){if(o.data.error)return s(new Error(o.data.error)),void e.terminate();f(o.data.file),e.terminate()}else n.onProgress(o.data.progress)}),e.addEventListener("error",s),n.signal&&n.signal.addEventListener("abort",()=>{s(n.signal.reason),e.terminate()}),e.postMessage({file:t,imageCompressionLibUrl:n.libURL,options:{...n,onProgress:void 0,signal:void 0}})})}function ce(t,n){return new Promise(function(f,s){let e,r,o,c,w,C;if(e={...n},o=0,{onProgress:c}=e,e.maxSizeMB=e.maxSizeMB||Number.POSITIVE_INFINITY,w=typeof e.useWebWorker!="boolean"||e.useWebWorker,delete e.useWebWorker,e.onProgress=g=>{o=g,typeof c=="function"&&c(o)},!(t instanceof Blob||t instanceof Br))return s(new Error("The file given is not an instance of Blob or File"));if(!/^image/.test(t.type))return s(new Error("The file given is not an image"));if(C=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,!w||typeof Worker!="function"||C)return _t(t,e).then((function(g){try{return r=g,i.call(this)}catch(x){return s(x)}}).bind(this),s);var a=(function(){try{return i.call(this)}catch(g){return s(g)}}).bind(this),u=function(g){try{return _t(t,e).then(function(x){try{return r=x,a()}catch(S){return s(S)}},s)}catch(x){return s(x)}};try{return e.libURL=e.libURL||"https://cdn.jsdelivr.net/npm/browser-image-compression@2.0.2/dist/browser-image-compression.js",Wr(t,e).then(function(g){try{return r=g,a()}catch{return u()}},u)}catch{u()}function i(){try{r.name=t.name,r.lastModified=t.lastModified}catch{}try{e.preserveExif&&t.type==="image/jpeg"&&(!e.fileType||e.fileType&&e.fileType===t.type)&&(r=qt(t,r))}catch{}return f(r)}})}ce.getDataUrlFromFile=Vt,ce.getFilefromDataUrl=bt,ce.loadImage=Kt,ce.drawImageInCanvas=Zt,ce.drawFileInCanvas=tt,ce.canvasToFile=rt,ce.getExifOrientation=Yt,ce.handleMaxWidthOrHeight=Jt,ce.followExifOrientation=er,ce.cleanupCanvasMemory=je,ce.isAutoOrientationInBrowser=Oe,ce.approximateBelowMaximumCanvasSizeOfBrowser=Xt,ce.copyExifWithoutOrientation=qt,ce.getBrowserName=Le,ce.version="2.0.2";var tr={exports:{}};(function(t,n){(function(f){t.exports=f()})(function(f){var s=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function e(m,k){var h=m[0],d=m[1],A=m[2],l=m[3];h+=(d&A|~d&l)+k[0]-680876936|0,h=(h<<7|h>>>25)+d|0,l+=(h&d|~h&A)+k[1]-389564586|0,l=(l<<12|l>>>20)+h|0,A+=(l&h|~l&d)+k[2]+606105819|0,A=(A<<17|A>>>15)+l|0,d+=(A&l|~A&h)+k[3]-1044525330|0,d=(d<<22|d>>>10)+A|0,h+=(d&A|~d&l)+k[4]-176418897|0,h=(h<<7|h>>>25)+d|0,l+=(h&d|~h&A)+k[5]+1200080426|0,l=(l<<12|l>>>20)+h|0,A+=(l&h|~l&d)+k[6]-1473231341|0,A=(A<<17|A>>>15)+l|0,d+=(A&l|~A&h)+k[7]-45705983|0,d=(d<<22|d>>>10)+A|0,h+=(d&A|~d&l)+k[8]+1770035416|0,h=(h<<7|h>>>25)+d|0,l+=(h&d|~h&A)+k[9]-1958414417|0,l=(l<<12|l>>>20)+h|0,A+=(l&h|~l&d)+k[10]-42063|0,A=(A<<17|A>>>15)+l|0,d+=(A&l|~A&h)+k[11]-1990404162|0,d=(d<<22|d>>>10)+A|0,h+=(d&A|~d&l)+k[12]+1804603682|0,h=(h<<7|h>>>25)+d|0,l+=(h&d|~h&A)+k[13]-40341101|0,l=(l<<12|l>>>20)+h|0,A+=(l&h|~l&d)+k[14]-1502002290|0,A=(A<<17|A>>>15)+l|0,d+=(A&l|~A&h)+k[15]+1236535329|0,d=(d<<22|d>>>10)+A|0,h+=(d&l|A&~l)+k[1]-165796510|0,h=(h<<5|h>>>27)+d|0,l+=(h&A|d&~A)+k[6]-1069501632|0,l=(l<<9|l>>>23)+h|0,A+=(l&d|h&~d)+k[11]+643717713|0,A=(A<<14|A>>>18)+l|0,d+=(A&h|l&~h)+k[0]-373897302|0,d=(d<<20|d>>>12)+A|0,h+=(d&l|A&~l)+k[5]-701558691|0,h=(h<<5|h>>>27)+d|0,l+=(h&A|d&~A)+k[10]+38016083|0,l=(l<<9|l>>>23)+h|0,A+=(l&d|h&~d)+k[15]-660478335|0,A=(A<<14|A>>>18)+l|0,d+=(A&h|l&~h)+k[4]-405537848|0,d=(d<<20|d>>>12)+A|0,h+=(d&l|A&~l)+k[9]+568446438|0,h=(h<<5|h>>>27)+d|0,l+=(h&A|d&~A)+k[14]-1019803690|0,l=(l<<9|l>>>23)+h|0,A+=(l&d|h&~d)+k[3]-187363961|0,A=(A<<14|A>>>18)+l|0,d+=(A&h|l&~h)+k[8]+1163531501|0,d=(d<<20|d>>>12)+A|0,h+=(d&l|A&~l)+k[13]-1444681467|0,h=(h<<5|h>>>27)+d|0,l+=(h&A|d&~A)+k[2]-51403784|0,l=(l<<9|l>>>23)+h|0,A+=(l&d|h&~d)+k[7]+1735328473|0,A=(A<<14|A>>>18)+l
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/var Vr={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const Kr=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),Y=(t,n)=>{const f=H.forwardRef(({color:s="currentColor",size:e=24,strokeWidth:r=2,absoluteStrokeWidth:o,className:c="",children:w,...C},a)=>H.createElement("svg",{ref:a,...Vr,width:e,height:e,stroke:s,strokeWidth:o?Number(r)*24/Number(e):r,className:["lucide",`lucide-${Kr(t)}`,c].join(" "),...C},[...n.map(([u,i])=>H.createElement(u,i)),...Array.isArray(w)?w:[w]]));return f.displayName=`${t}`,f};/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const Ze=Y("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const Tt=Y("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const wt=Y("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const vt=Y("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const rr=Y("ClipboardPaste",[["path",{d:"M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z",key:"1pp7kr"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2M11 14h10",key:"2ik1ml"}],["path",{d:"m17 10 4 4-4 4",key:"vp2hj1"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const Xr=Y("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const nr=Y("Code2",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const Zr=Y("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const sr=Y("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const Ye=Y("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const ir=Y("FileUp",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const Ut=Y("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const Yr=Y("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const Jr=Y("HelpCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const en=Y("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const tn=Y("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const rn=Y("Languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const ar=Y("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const Nt=Y("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const nn=Y("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const sn=Y("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const an=Y("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const on=Y("MinusCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const or=Y("MousePointerClick",[["path",{d:"m9 9 5 12 1.8-5.2L21 14Z",key:"1b76lo"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const ln=Y("PlusCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const gt=Y("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const cn=Y("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/**
|
||
|
|
* @license lucide-react v0.344.0 - ISC
|
||
|
|
*
|
||
|
|
* This source code is licensed under the ISC license.
|
||
|
|
* See the LICENSE file in the root directory of this source tree.
|
||
|
|
*/const We=Y("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function un({onClose:t}){const{signIn:n,signUp:f}=xt(),{t:s}=ke(),[e,r]=H.useState(!1),[o,c]=H.useState(""),[w,C]=H.useState(""),[a,u]=H.useState(!1),[i,g]=H.useState(""),x=async S=>{S.preventDefault(),g(""),u(!0);try{const{error:E}=e?await f(o,w):await n(o,w);E?g(E.message):t()}catch{g("发生错误,请重试")}finally{u(!1)}};return b.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:b.jsxs("div",{className:"bg-white rounded-xl shadow-xl max-w-md w-full p-6",children:[b.jsxs("div",{className:"flex justify-between items-center mb-6",children:[b.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:e?s.auth.signUpTitle:s.auth.signInTitle}),b.jsx("button",{onClick:t,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:b.jsx(We,{size:20})})]}),b.jsxs("form",{onSubmit:x,className:"space-y-4",children:[b.jsxs("div",{children:[b.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s.auth.email}),b.jsx("input",{type:"email",value:o,onChange:S=>c(S.target.value),className:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"your@email.com",required:!0})]}),b.jsxs("div",{children:[b.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:s.auth.password}),b.jsx("input",{type:"password",value:w,onChange:S=>C(S.target.value),className:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"••••••••",required:!0,minLength:6})]}),i&&b.jsxs("div",{className:"p-3 bg-red-100 border border-red-400 text-red-700 rounded-lg text-sm font-medium animate-pulse",children:[s.auth.error,": ",i]}),b.jsx("button",{type:"submit",disabled:a,className:"w-full py-3 px-4 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors font-medium disabled:opacity-80 disabled:cursor-wait",children:e?s.auth.signUp:s.auth.signIn})]}),b.jsx("div",{className:"mt-4 text-center",children:b.jsx("button",{onClick:()=>r(!e),className:"text-sm text-blue-600 hover:text-blue-700",children:e?s.auth.hasAccount:s.auth.noAccount})})]})})}function dn({files:t,selectedFileId:n,onFileSelect:f,onUploadClick:s,isCollapsed:e,onToggleCollapse:r,onUploadFiles:o,hasMore:c,loadingMore:w,onLoadMore:C}){const{user:a,signOut:u}=xt(),{t:i}=ke(),[g,x]=H.useState(!1),[S,E]=H.useState(!1),m=H.useRef(null),k=H.useRef(null),h=H.useCallback(()=>{if(!k.current||w||!c)return;const{scrollTop:p,scrollHeight:v,clientHeight:_}=k.current;v-p-_<50&&C()},[w,c,C]);H.useEffect(()=>{if(!c||w||!a||t.length===0)return;const v=setTimeout(()=>{requestAnimationFrame(()=>{if(!k.current)return;const{scrollHeight:_,clientHeight:N}=k.current;_<=N&&c&&!w&&C()})},100);return()=>clearTimeout(v)},[t.length,c,w,C,a]);const d=p=>{p.preventDefault(),E(!0)},A=p=>{p.preventDefault(),E(!1)},l=p=>{p.preventDefault(),E(!1);const _=Array.from(p.dataTransfer.files).filter(N=>N.type.startsWith("image/")||N.type==="application/pdf");_.length>0&&o(_)},M=p=>{p.target.files&&p.target.files.length>0&&o(Array.from(p.target.files)),m.current&&(m.current.value="")};return e?b.jsxs("div",{className:"h-full flex flex-col items-center py-4 bg-gray-50/50",children:[b.jsx("button",{onClick:r,className:"p-2 mb-6 text-gray-500 hover:text-gray-900 hover:bg-gray-200 rounded-md transition-colors",children:b.jsx(vt,{size:20})}),b.jsx("button",{onClick:s,className:"p-3 rounded-xl bg-blue-600 text-white hover:bg-blue-700 shadow-lg shadow-blue-600/20 transition-all mb-6",title:i.common.upload,children:b.jsx(gt,{size:20})}),b.jsx("div",{className:"flex-1 w-full flex flex-col items-center gap-4",children:b.jsx("button",{className:"p-2 text-gray-400 hover:text-gray-900 transition-colors",title:i.common.history,children:b.jsx(en,{size:20})})}),b.jsx("button",{onClick:()=>!a&&x(!0),className:"p-3 rounded-lg text-gray-600 hover:bg-gray-200 transition-colors
|
||
|
|
border-2 border-dashed rounded-xl p-6 text-center cursor-pointer transition-all duration-200 group
|
||
|
|
${S?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-blue-400 hover:bg-gray-50"}
|
||
|
|
`,children:[b.jsx("input",{type:"file",ref:m,className:"hidden",onChange:M,accept:"image/*",multiple:!0}),b.jsx("div",{className:"w-12 h-12 bg-gray-100 text-gray-600 rounded-full flex items-center justify-center mx-auto mb-3 group-hover:scale-110 transition-transform",children:b.jsx(gt,{size:24})}),b.jsx("p",{className:"text-xs text-gray-500 mb-2",children:i.sidebar.uploadInstruction}),b.jsxs("div",{className:"flex items-center justify-center gap-4 text-xs text-gray-400",children:[b.jsxs("div",{className:"flex items-center gap-1",children:[b.jsx(or,{className:"w-3.5 h-3.5"}),b.jsx("span",{children:i.common.click})]}),b.jsxs("div",{className:"flex items-center gap-1",children:[b.jsx(ir,{className:"w-3.5 h-3.5"}),b.jsx("span",{children:i.common.drop})]}),b.jsxs("div",{className:"flex items-center gap-1",children:[b.jsx(rr,{className:"w-3.5 h-3.5"}),b.jsx("span",{children:i.common.paste})]})]})]})})]}),b.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col px-4",id:"sidebar-history",children:[b.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3 px-2",children:[b.jsx(Xr,{size:14}),b.jsx("span",{children:i.sidebar.historyHeader})]}),b.jsx("div",{ref:k,onScroll:h,className:"flex-1 overflow-y-auto space-y-1 pr-2 -mr-2 custom-scrollbar",children:a?t.length===0?b.jsxs("div",{className:"text-center py-12 text-gray-400 text-sm",children:[b.jsx("div",{className:"mb-2 opacity-50",children:b.jsx(Ye,{size:40,className:"mx-auto"})}),i.sidebar.noHistory]}):b.jsxs(b.Fragment,{children:[t.map(p=>b.jsx("button",{onClick:()=>f(p.id),className:`w-full p-3 rounded-lg text-left transition-all border group relative ${n===p.id?"bg-blue-50 border-blue-200 shadow-sm":"bg-white border-transparent hover:bg-gray-50 hover:border-gray-100"}`,children:b.jsxs("div",{className:"flex items-start gap-3",children:[b.jsx("div",{className:`p-2 rounded-lg ${n===p.id?"bg-blue-100 text-blue-600":"bg-gray-100 text-gray-500 group-hover:bg-gray-200"}`,children:b.jsx(Ye,{size:18})}),b.jsxs("div",{className:"flex-1 min-w-0",children:[b.jsx("p",{className:`text-sm font-medium truncate ${n===p.id?"text-blue-900":"text-gray-700"}`,children:p.filename}),b.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[b.jsx("span",{className:"text-xs text-gray-400",children:new Date(p.created_at).toLocaleDateString()}),b.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${p.status==="completed"?"bg-green-500":p.status==="processing"?"bg-yellow-500":"bg-red-500"}`})]})]})]})},p.id)),w&&b.jsxs("div",{className:"flex items-center justify-center py-3 text-gray-400",children:[b.jsx(ar,{size:18,className:"animate-spin"}),b.jsx("span",{className:"ml-2 text-xs",children:i.common.loading})]}),!c&&t.length>0&&b.jsx("div",{className:"text-center py-3 text-xs text-gray-400",children:i.sidebar.noMore})]}):b.jsxs("div",{className:"text-center py-12 text-gray-400 text-sm",children:[b.jsx("div",{className:"mb-2 opacity-50",children:b.jsx(Ye,{size:40,className:"mx-auto"})}),i.sidebar.pleaseLogin]})})]}),b.jsx("div",{className:"p-4 border-t border-gray-100 bg-gray-50/30",children:a?b.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg bg-white border border-gray-100 shadow-sm",children:[b.jsx("div",{className:"w-8 h-8 bg-gray-900 rounded-full flex items-center justify-center flex-shrink-0",children:b.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:b.jsx("path",{d:"M12 12C14.21 12 16 10.21 16 8C16 5.79 14.21 4 12 4C9.79 4 8 5.79 8 8C8 10.21 9.79 12 12 12ZM12 14C9.33 14 4 15.34 4 18V20H20V18C20 15.34 14.67 14 12 14Z",fill:"white"})})}),b.jsx("div",{className:"flex-1 min-w-0",children:b.jsx("p",{className:"text-sm font-medium text-gray-900 truncate",children:a.email})}),b.jsx("button",{onClick:()=>u(),className:"p-1.5 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-md transition-colors",title:i.common.logout,children:b.jsx(nn,{size:16})})]}):b.jsxs("button",{onClick:()=>x(!0),className:"w-full py-2.5 px-4 bg-gray-900 text-white roun
|
||
|
|
`)}async function fs(t,n){const f=n.fontEmbedCSS!=null?n.fontEmbedCSS:n.skipFonts?null:await ds(t,n);if(f){const s=document.createElement("style"),e=document.createTextNode(f);s.appendChild(e),t.firstChild?t.insertBefore(s,t.firstChild):t.appendChild(s)}}async function xr(t,n={}){const{width:f,height:s}=cr(t,n),e=await at(t,n,!0);return await fs(e,n),await mr(e,n),as(e,n),await Un(e,f,s)}async function yr(t,n={}){const{width:f,height:s}=cr(t,n),e=await xr(t,n),r=await st(e),o=document.createElement("canvas"),c=o.getContext("2d"),w=n.pixelRatio||Sn(),C=n.canvasWidth||f,a=n.canvasHeight||s;return o.width=C*w,o.height=a*w,n.skipAutoScale||En(o),o.style.width=`${C}`,o.style.height=`${a}`,n.backgroundColor&&(c.fillStyle=n.backgroundColor,c.fillRect(0,0,o.width,o.height)),c.drawImage(r,0,0,o.width,o.height),o}async function hs(t,n={}){return(await yr(t,n)).toDataURL()}async function gs(t,n={}){const f=await yr(t,n);return await _n(f)}const ms={backgroundColor:"#ffffff",padding:20,fontSize:20,scale:2,format:"png"};async function ps(){const t=["KaTeX_Main","KaTeX_Math","KaTeX_Size1","KaTeX_Size2","KaTeX_Size3","KaTeX_Size4"];await document.fonts.ready;const n=()=>t.some(s=>{try{return document.fonts.check(`16px ${s}`)}catch{return!1}}),f=20;for(let s=0;s<f;s++){if(n())return;await new Promise(e=>setTimeout(e,100))}}async function xs(t,n={}){const f=document.getElementById(t);if(!f)throw new Error(`Element with ID "${t}" not found`);const s={...ms,...n};await ps(),await new Promise(o=>setTimeout(o,100));const e={backgroundColor:s.backgroundColor,pixelRatio:s.scale,cacheBust:!0,width:f.scrollWidth+s.padding*2,height:f.scrollHeight+s.padding*2,style:{padding:`${s.padding}px`,transform:"none",overflow:"visible",visibility:"visible",display:"block",height:"auto",maxHeight:"none"},skipFonts:!1};let r;try{switch(s.format){case"svg":r=await xr(f,e);break;case"blob":r=await gs(f,e);break;case"png":default:r=await hs(f,e);break}return r}catch(o){throw console.error("Element image generation failed:",o),o}}async function ys(t){let n;typeof t=="string"?n=await(await fetch(t)).blob():n=t,await navigator.clipboard.write([new ClipboardItem({[n.type]:n})])}const bs=(t,n,f)=>{try{const s={task_no:t,event_name:"export_selected_event",properties:{option:f,selected:n},meta_data:{task_no:t},device_info:{ip:"","use-agent":navigator.userAgent,browser:ws()}};Pe.post("/analytics/track",s).catch(e=>{console.debug("Analytics tracking failed:",e)})}catch(s){console.debug("Analytics error:",s)}};function ws(){const t=navigator.userAgent;return t.match(/chrome|chromium|crios/i)?"Chrome":t.match(/firefox|fxios/i)?"Firefox":t.match(/safari/i)?"Safari":t.match(/opr\//i)?"Opera":t.match(/edg/i)?"Edge":"Unknown"}function vs({isOpen:t,onClose:n,result:f}){const{t:s}=ke(),[e,r]=H.useState(null),[o,c]=H.useState(null);if(!f)return null;const w=[{id:"markdown",label:"Markdown",category:"Code",getContent:g=>g.markdown_content},{id:"latex_inline",label:"LaTeX (Inline)",category:"Code",getContent:g=>g.latex_content?`\\(${g.latex_content.replace(/^\\\[/,"").replace(/\\\]$/,"").trim()}\\)`:null},{id:"latex_display",label:"LaTeX (Display)",category:"Code",getContent:g=>g.latex_content},{id:"mathml",label:"MathML",category:"Code",getContent:g=>g.mathml_content},{id:"mathml_mml",label:"MathML (MML)",category:"Code",getContent:g=>g.mml},{id:"rendered_image",label:"Rendered Image",category:"Image",getContent:g=>g.markdown_content},{id:"docx",label:"DOCX",category:"File",getContent:g=>g.markdown_content,isDownload:!0,extension:"docx"}],C=async g=>{if(f!=null&&f.id){c(g);try{const x=ye.getToken(),S=await fetch(`${Ot}/task/export`,{method:"POST",headers:{"Content-Type":"application/json",...x?{Authorization:x}:{}},body:JSON.stringify({task_no:f.id,type:g})});if(!S.ok)throw new Error(`Export failed: ${S.statusText}`);const E=await S.blob(),m=URL.createObjectURL(E),k=document.createElement("a");k.href=m,k.download=`export.${g}`,document.body.appendChild(k),k.click(),document.body.removeChild(k),URL.revokeObjectURL(m),r(g),setTimeout(()=>{r(null),n()},1e3)}catch(x){console.error("E
|
||
|
|
absolute top-0 right-0 bottom-0 w-80 bg-white shadow-2xl z-50 transform transition-transform duration-300 ease-in-out border-l border-gray-100 flex flex-col
|
||
|
|
${t?"translate-x-0":"translate-x-full"}
|
||
|
|
`,children:[b.jsxs("div",{className:"flex items-center justify-between px-6 py-5 border-b border-gray-100 shrink-0",children:[b.jsx("h2",{className:"text-lg font-bold text-gray-900",children:s.export.title}),b.jsx("button",{onClick:n,className:"p-2 hover:bg-gray-100 rounded-full transition-colors",children:b.jsx(We,{size:20,className:"text-gray-500"})})]}),b.jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-8",children:i.map(g=>b.jsxs("div",{className:"space-y-3",children:[b.jsxs("div",{className:"flex items-center gap-2 text-gray-400 px-1",children:[b.jsx(g.icon,{size:16}),b.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider",children:g.label})]}),b.jsx("div",{className:"space-y-2",children:w.filter(x=>x.category===g.id).map(x=>b.jsxs("button",{onClick:()=>u(x),className:"w-full flex items-center justify-between p-3 bg-gray-50 hover:bg-blue-50 hover:text-blue-600 border border-transparent hover:border-blue-200 rounded-lg group transition-all text-left",children:[b.jsx("span",{className:"text-sm font-medium text-gray-700 group-hover:text-blue-700",children:x.label}),b.jsx("div",{className:"text-gray-400 group-hover:text-blue-600",children:o===x.id?b.jsx(ar,{size:16,className:"animate-spin text-blue-500"}):e===x.id?b.jsx(Ze,{size:16,className:"text-green-500"}):x.isDownload?b.jsx(sr,{size:16}):b.jsx(Zr,{size:16,className:"opacity-0 group-hover:opacity-100 transition-opacity"})})]},x.id))})]},g.id))})]})]})}function As(t){if(!t)return"";let n=t;return n=n.replace(/\$\$\s*\\\[/g,"$$$$"),n=n.replace(/\\\]\s*\$\$/g,"$$$$"),n=n.replace(new RegExp("(?<!\\$)\\\\\\[(?!\\$)","g"),"$$$$"),n=n.replace(new RegExp("(?<!\\$)\\\\\\](?!\\$)","g"),"$$$$"),n=n.replace(/\$\$([^\n$])/g,`$$$$
|
||
|
|
$1`),n=n.replace(/([^\n$])\$\$/g,`$1
|
||
|
|
$$$$`),n=n.replace(/\\left\s+\\/g,"\\left\\"),n=n.replace(/\\left\s+\{/g,"\\left\\{"),n=n.replace(/\\left\s+\[/g,"\\left["),n=n.replace(/\\left\s+\(/g,"\\left("),n=n.replace(/\\right\s+\\/g,"\\right\\"),n=n.replace(/\\right\s+\}/g,"\\right\\}"),n=n.replace(/\\right\s+\]/g,"\\right]"),n=n.replace(/\\right\s+\)/g,"\\right)"),n=n.replace(/\\left\(([^)]*?)\\right\.\s*(\\text\{[^}]*\})\s*\\right\)/g,"($1\\right. $2)"),n}function js({result:t,fileStatus:n}){const{t:f}=ke(),[s,e]=H.useState(!1);return t?b.jsxs("div",{className:"flex flex-col h-full bg-white relative overflow-hidden",id:"result-panel-content",children:[b.jsxs("div",{className:"h-16 px-6 border-b border-gray-200 flex items-center justify-between bg-white shrink-0 z-10",children:[b.jsx("div",{className:"flex items-center gap-4",children:b.jsx("h2",{className:"text-lg font-bold text-gray-900",children:f.resultPanel.markdown})}),b.jsxs("button",{id:"export-button",onClick:()=>e(!0),className:`px-4 py-2 bg-gray-900 text-white text-sm font-medium rounded-lg hover:bg-gray-800 transition-colors flex items-center gap-2 shadow-sm ${s?"opacity-0 pointer-events-none":""}`,children:[b.jsx(sr,{size:16}),f.common.export]})]}),b.jsx("div",{className:"flex-1 overflow-auto p-8 custom-scrollbar flex justify-center",children:b.jsx("div",{id:"markdown-preview-content",className:"prose prose-blue max-w-3xl w-full prose-headings:font-bold prose-h1:text-2xl prose-h2:text-xl prose-p:leading-relaxed prose-pre:bg-gray-50 prose-pre:border prose-pre:border-gray-100 [&_.katex-display]:text-center bg-white p-4",children:b.jsx(jr,{remarkPlugins:[Cr,vn],rehypePlugins:[[kr,{throwOnError:!1,errorColor:"#cc0000",strict:!1}]],children:As(t.markdown_content||"")})})}),b.jsx(vs,{isOpen:s,onClose:()=>e(!1),result:t})]}):n==="processing"||n==="pending"?b.jsxs("div",{className:"h-full flex flex-col items-center justify-center bg-white text-center p-8",children:[b.jsx("div",{className:"w-16 h-16 border-4 border-blue-600 border-t-transparent rounded-full animate-spin mb-6"}),b.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:n==="pending"?f.resultPanel.waitingQueue:f.resultPanel.analyzing}),b.jsx("p",{className:"text-gray-500 max-w-sm",children:n==="pending"?f.resultPanel.queueSubtitle:f.resultPanel.processingSubtitle})]}):b.jsxs("div",{className:"h-full flex flex-col items-center justify-center bg-white text-center p-8",id:"result-empty-state",children:[b.jsx("div",{className:"w-32 h-32 bg-gray-100 rounded-full flex items-center justify-center mb-6 shadow-inner",children:b.jsx(nr,{size:48,className:"text-gray-900"})}),b.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:f.resultPanel.waitingTitle}),b.jsx("p",{className:"text-gray-500 max-w-sm",children:f.resultPanel.waitingSubtitle})]})}function Cs({onClose:t,onUpload:n}){const{t:f}=ke(),[s,e]=H.useState(!1),r=H.useRef(null);H.useEffect(()=>{const C=a=>{var g;const u=(g=a.clipboardData)==null?void 0:g.items;if(!u)return;const i=[];for(let x=0;x<u.length;x++)if(u[x].type.startsWith("image/")||u[x].type==="application/pdf"){const S=u[x].getAsFile();S&&i.push(S)}i.length>0&&(n(i),t())};return document.addEventListener("paste",C),()=>document.removeEventListener("paste",C)},[n,t]);const o=H.useCallback(C=>{C.preventDefault(),C.stopPropagation(),C.type==="dragenter"||C.type==="dragover"?e(!0):C.type==="dragleave"&&e(!1)},[]),c=H.useCallback(C=>{C.preventDefault(),C.stopPropagation(),e(!1);const a=Array.from(C.dataTransfer.files).filter(u=>u.type.startsWith("image/")||u.type==="application/pdf");a.length>0&&(n(a),t())},[n,t]),w=C=>{if(C.target.files){const a=Array.from(C.target.files).filter(u=>u.type.startsWith("image/")||u.type==="application/pdf");a.length>0&&(n(a),t())}};return b.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:b.jsxs("div",{className:"bg-white rounded-xl shadow-xl max-w-2xl w-full p-6",children:[b.jsxs("div",{className:"flex justify-between items-center mb-6",children:[b.jsx("h2",{className:"text-2xl font-bold text-gray-900",children
|
||
|
|
0% 0%, 0% 100%,
|
||
|
|
${r.left}px 100%,
|
||
|
|
${r.left}px ${r.top}px,
|
||
|
|
${r.left+r.width}px ${r.top}px,
|
||
|
|
${r.left+r.width}px ${r.top+r.height}px,
|
||
|
|
${r.left}px ${r.top+r.height}px,
|
||
|
|
${r.left}px 100%,
|
||
|
|
100% 100%, 100% 0%
|
||
|
|
)`:"none"}}),b.jsx("div",{className:"absolute border-2 border-blue-500 rounded-xl transition-all duration-300 shadow-[0_0_0_9999px_rgba(0,0,0,0.5)]",style:r}),b.jsxs("div",{className:"absolute pointer-events-auto bg-white rounded-xl shadow-2xl p-6 w-80 transition-all duration-300 animate-in fade-in zoom-in-95",style:r.top!==void 0?{top:c[s].position==="bottom"?r.top+r.height+16:c[s].position==="top"?r.top-200:r.top,left:c[s].position==="right"?r.left+r.width+16:c[s].position==="left"?r.left-336:r.left}:{top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:[b.jsx("button",{onClick:n,className:"absolute top-4 right-4 text-gray-400 hover:text-gray-600",children:b.jsx(We,{size:18})}),b.jsxs("div",{className:"mb-4",children:[b.jsxs("span",{className:"text-xs font-bold text-blue-600 uppercase tracking-wider",children:["Step ",s+1," of ",c.length]}),b.jsx("h3",{className:"text-lg font-bold text-gray-900 mt-1",children:c[s].title}),b.jsx("p",{className:"text-sm text-gray-600 mt-2 leading-relaxed",children:c[s].content})]}),b.jsxs("div",{className:"flex items-center justify-between mt-6",children:[b.jsxs("button",{onClick:a,disabled:s===0,className:`flex items-center gap-1 text-sm font-medium ${s===0?"text-gray-300 cursor-not-allowed":"text-gray-600 hover:text-gray-900"}`,children:[b.jsx(wt,{size:16}),f.guide.prev]}),b.jsxs("button",{onClick:C,className:"px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 transition-colors flex items-center gap-1",children:[s===c.length-1?f.guide.finish:f.guide.next,s<c.length-1&&b.jsx(vt,{size:16})]})]})]})]})}const $t=6;function Ss(){const{user:t,initializing:n}=xt(),{t:f}=ke(),[s,e]=H.useState([]),[r,o]=H.useState(null),[c,w]=H.useState(null),[C,a]=H.useState(!1),[u,i]=H.useState(!1),[g,x]=H.useState(!1),[S,E]=H.useState(1),[m,k]=H.useState(!1),[h,d]=H.useState(!1),[A,l]=H.useState(320),[M,p]=H.useState(!1),[v,_]=H.useState(!1),N=H.useRef(null),U=H.useRef({}),F=H.useRef(null),T=H.useRef({}),I=H.useRef(!1),j=s.find(D=>D.id===r)||null;H.useEffect(()=>{const D=()=>i(!0);return window.addEventListener("start-user-guide",D),localStorage.getItem("hasSeenGuide")||(setTimeout(()=>i(!0),1500),localStorage.setItem("hasSeenGuide","true")),()=>window.removeEventListener("start-user-guide",D)},[]),H.useEffect(()=>{!n&&t&&!I.current&&(I.current=!0,O()),t||(I.current=!1,e([]),o(null),E(1),k(!1))},[n,t]),H.useEffect(()=>{F.current=r,r?$(r):w(null)},[r]),H.useEffect(()=>()=>{Object.values(U.current).forEach(clearInterval),U.current={}},[]),H.useEffect(()=>{const D=B=>{var V;if(C)return;const G=(V=B.clipboardData)==null?void 0:V.items;if(!G)return;const X=[];for(let K=0;K<G.length;K++)if(G[K].type.startsWith("image/")||G[K].type==="application/pdf"){const Z=G[K].getAsFile();Z&&X.push(Z)}X.length>0&&Q(X)};return document.addEventListener("paste",D),()=>document.removeEventListener("paste",D)},[t,C]);const y=H.useCallback(D=>{D.preventDefault(),p(!0)},[]),L=H.useCallback(()=>{p(!1)},[]),R=H.useCallback(D=>{if(M){const B=D.clientX;B>=280&&B<=400&&l(B)}},[M]);H.useEffect(()=>(window.addEventListener("mousemove",R),window.addEventListener("mouseup",L),()=>{window.removeEventListener("mousemove",R),window.removeEventListener("mouseup",L)}),[R,L]);const z=D=>{const B={[xe.Pending]:"pending",[xe.Processing]:"processing",[xe.Completed]:"completed",[xe.Failed]:"failed"};return{id:D.task_id,user_id:(t==null?void 0:t.id)||null,filename:D.file_name,file_path:D.origin_url,file_type:"image/jpeg",file_size:0,thumbnail_path:null,status:B[D.status]||"pending",created_at:D.created_at,updated_at:D.created_at}},W=D=>({id:D.task_id,file_id:D.task_id,markdown_content:D.markdown,latex_content:D.latex,mathml_content:D.mathml,mml:D.mml,rendered_image_path:D.image_blob||null,created_at:D.created_at}),O=async()=>{if(t){x(!0);try{const D=await Ie.getTaskList("FORMULA",1,$t),B=D.task_list||[],G=D.total||0;if(E(1),k(B.length<G),B.length>0){const X=B.map(z);e(X),B.forEach(V=>{V.status===xe.Completed&&(T.current[V.task_id]=W(V))}),r||o(X[0].id)}else e([])}catch(D){console.error("Error loading
|
||
|
|
<div style="padding: 20px; font-family: sans-serif;">
|
||
|
|
<h1>应用启动失败</h1>
|
||
|
|
<p>错误信息: ${t instanceof Error?t.message:String(t)}</p>
|
||
|
|
<p>请检查浏览器控制台获取更多信息。</p>
|
||
|
|
</div>
|
||
|
|
`}
|