Files
doc_ai_frontend/app.cloud/assets/index-NjWMZQkP.js
2026-01-27 23:44:45 +08:00

192 lines
165 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{j as E,c as Fr,v as Pr,M as $r,r as zr,a as Or}from"./vendor-markdown-C0b4qDwm.js";import{a as Dr,r as H,g as Hr}from"./vendor-react-C6WG4Va-.js";import"./vendor-katex-p018AHG0.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const t of document.querySelectorAll('link[rel="modulepreload"]'))i(t);new MutationObserver(t=>{for(const n of t)if(n.type==="childList")for(const s of n.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&i(s)}).observe(document,{childList:!0,subtree:!0});function a(t){const n={};return t.integrity&&(n.integrity=t.integrity),t.referrerPolicy&&(n.referrerPolicy=t.referrerPolicy),t.crossOrigin==="use-credentials"?n.credentials="include":t.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function i(t){if(t.ep)return;t.ep=!0;const n=a(t);fetch(t.href,n)}})();var Jt,It=Dr;Jt=It.createRoot,It.hydrateRoot;const Ft={development:{apiBaseUrl:"https://cloud.texpixel.com:10443/doc_ai/v1",env:"development"},production:{apiBaseUrl:"https://api.texpixel.com/doc_ai/v1",env:"production"}},Br="development",Wr=Ft[Br]||Ft.development,er=Wr.apiBaseUrl,yt="texpixel_token",rt="texpixel_token_expires",bt="texpixel_user_email",ve={getToken(){return localStorage.getItem(yt)},setToken(e,r,a){localStorage.setItem(yt,e),localStorage.setItem(rt,r.toString()),a&&localStorage.setItem(bt,a)},removeToken(){localStorage.removeItem(yt),localStorage.removeItem(rt),localStorage.removeItem(bt)},getEmail(){return localStorage.getItem(bt)},isTokenValid(){const e=this.getToken(),r=localStorage.getItem(rt);if(!e||!r)return!1;const a=parseInt(r,10)*1e3;return Date.now()<a-5*60*1e3},getExpiresAt(){const e=localStorage.getItem(rt);return e?parseInt(e,10):null}};class Oe extends Error{constructor(r,a,i){super(a),this.code=r,this.requestId=i,this.name="ApiError"}}async function nt(e,r={}){const{skipAuth:a=!1,headers:i,...t}=r,n={"Content-Type":"application/json",...i};if(!a){const l=ve.getToken();l&&(n.Authorization=l)}const s=`${er}${e}`;try{const m=await(await fetch(s,{...t,headers:n})).json();if(m.code!==200)throw new Oe(m.code,m.message,m.request_id);return m}catch(l){throw l instanceof Oe?l:new Oe(-1,"网络错误,请检查网络连接")}}const De={get(e,r){return nt(e,{...r,method:"GET"})},post(e,r,a){return nt(e,{...a,method:"POST",body:r?JSON.stringify(r):void 0})},put(e,r,a){return nt(e,{...a,method:"PUT",body:r?JSON.stringify(r):void 0})},delete(e,r){return nt(e,{...r,method:"DELETE"})}};var we=(e=>(e[e.Pending=0]="Pending",e[e.Processing=1]="Processing",e[e.Completed=2]="Completed",e[e.Failed=3]="Failed",e))(we||{});const qr={200:"操作成功",400:"参数错误",401:"未授权,请先登录",403:"无权限访问",404:"资源不存在",405:"状态无效",500:"服务器错误,请稍后重试",501:"系统错误,请稍后重试",1001:"任务未完成",1002:"记录重复",1003:"验证码错误",1004:"该邮箱已注册",1005:"该邮箱未注册",1006:"密码错误"};function xt(e){try{const a=e.replace("Bearer ","").split(".")[1];return JSON.parse(atob(a))}catch{return null}}const Xe={async login(e){const r=await De.post("/user/login",e,{skipAuth:!0});if(!r.data)throw new Oe(-1,"登录失败,请重试");const{token:a,expires_at:i}=r.data;ve.setToken(a,i,e.email);const t=xt(a);if(!t)throw new Oe(-1,"Token 解析失败");return{user:{...t,email:e.email,id:String(t.user_id)},token:a,expiresAt:i}},async register(e){const r=await De.post("/user/register",e,{skipAuth:!0});if(!r.data)throw new Oe(-1,"注册失败,请重试");const{token:a,expires_at:i}=r.data;ve.setToken(a,i,e.email);const t=xt(a);if(!t)throw new Oe(-1,"Token 解析失败");return{user:{...t,email:e.email,id:String(t.user_id)},token:a,expiresAt:i}},logout(){ve.removeToken()},isAuthenticated(){return ve.isTokenValid()},getToken(){return ve.getToken()},restoreSession(){const e=ve.getToken(),r=ve.getExpiresAt(),a=ve.getEmail();if(!e||!r||!ve.isTokenValid())return ve.removeToken(),null;const i=xt(e);return i?{user:{...i,email:a||"",id:String(i.user_id)},token:e,expiresAt:r}:(ve.removeToken(),null)}},tr=H.createContext(void 0);function Gr({children:e}){const[r,a]=H.useState(()=>{try{const y=Xe.restoreSession();return y?y.user:null}catch{return null}}),[i,t]=H.useState(()=>{try{const y=Xe.restoreSession();return y?y.token:null}catch{return null}}),[n,s]=H.useState(!1),[l,m]=H.useState(!1),p=(y,C)=>{if(y&&typeof y=="object"&&"code"in y){const k=y;return qr[k.code]||k.message||C}return y instanceof Error?y.message:C},o=H.useCallback(async(y,C)=>{s(!0);try{const k=await Xe.login({email:y,password:C});return a(k.user),t(k.token),{error:null}}catch(k){const b=p(k,"登录失败");return{error:new Error(b)}}finally{s(!1)}},[]),u=H.useCallback(async(y,C)=>{s(!0);try{const k=await Xe.register({email:y,password:C});return a(k.user),t(k.token),{error:null}}catch(k){const b=p(k,"注册失败");return{error:new Error(b)}}finally{s(!1)}},[]),c=H.useCallback(async()=>{s(!0);try{Xe.logout(),a(null),t(null)}finally{s(!1)}},[]),f={user:r,token:i,loading:n,initializing:l,signIn:o,signUp:u,signOut:c,isAuthenticated:!!r&&!!i};return E.jsx(tr.Provider,{value:f,children:e})}function Ct(){const e=H.useContext(tr);if(e===void 0)throw new Error("useAuth must be used within an AuthProvider");return e}const Vr={en:{common:{upload:"Upload",history:"History",login:"Login / Register",logout:"Logout",loading:"Loading...",processing:"Processing...",cancel:"Cancel",copy:"Copy",copied:"Copied!",download:"Download",export:"Export",preview:"Preview",email:"Email",contactUs:"Contact Us",reward:"Reward",qqGroup:"QQ Group (Click to Copy)",guide:"User Guide",click:"Click",drop:"Drop",paste:"Paste"},navbar:{rewardTitle:"WeChat Reward",rewardThanks:"Thank you for your support and encouragement ❤️",rewardSubtitle:"Your support is our motivation for continuous updates"},sidebar:{title:"Formula Recognize",subtitle:"Support handwriting and printed formulas",uploadInstruction:"Click, Drop, or Paste a file to start parsing",pleaseLogin:"Please login to view history",noHistory:"No history records",noMore:"No more records",historyHeader:"History"},uploadModal:{title:"Upload File",supportFormats:"Support JPG, PNG, PDF format"},resultPanel:{waitingTitle:"Waiting for recognition result",waitingSubtitle:"After uploading the file, Texpixel will automatically recognize and display the result here",analyzing:"Analyzing...",waitingQueue:"Waiting in queue...",queueSubtitle:"Your file is in the queue, please wait.",processingSubtitle:"Texpixel is processing your file, this may take a moment.",markdown:"Markdown"},auth:{signIn:"Login",signUp:"Register",signInTitle:"Login Account",signUpTitle:"Register Account",email:"Email",password:"Password",error:"Error",genericError:"An error occurred, please try again",hasAccount:"Already have an account? Login",noAccount:"No account? Register"},export:{title:"Export",categories:{code:"Code",image:"Image",file:"File"},failed:"Export failed, please try again",imageFailed:"Failed to generate image"},guide:{next:"Next",prev:"Back",finish:"Finish",skip:"Skip",step1Title:"Upload Area",step1Content:"Click or drag and drop your formula images/PDFs here to start recognition.",step2Title:"File History",step2Content:"Your recognized files will appear here. Login to sync across devices.",step3Title:"Preview Area",step3Content:"The original file you uploaded will be displayed here for comparison.",step4Title:"Recognition Result",step4Content:"The recognition results (Markdown/LaTeX) will be shown here.",stepExportTitle:"Export Result",stepExportContent:"You can export the recognition results to various formats such as Markdown, LaTeX, Word, or Image."},alerts:{taskTimeout:"Task timeout: Recognition took too long.",networkError:"Task timeout or network error.",uploadFailed:"Upload failed"}},zh:{common:{upload:"上传",history:"历史记录",login:"登录 / 注册",logout:"退出登录",loading:"加载中...",processing:"处理中...",cancel:"取消",copy:"复制",copied:"已复制!",download:"下载",export:"导出",preview:"预览",email:"邮箱",contactUs:"联系我们",reward:"赞赏",qqGroup:"QQ 群 (点击复制)",guide:"使用引导",click:"点击",drop:"拖拽",paste:"粘贴"},navbar:{rewardTitle:"微信赞赏码",rewardThanks:"感谢您的支持与鼓励 ❤️",rewardSubtitle:"您的支持是我们持续更新的动力"},sidebar:{title:"文档识别",subtitle:"支持手写和印刷体文档识别",uploadInstruction:"点击、拖拽或粘贴文件开始解析",pleaseLogin:"请登录后查看历史记录",noHistory:"暂无历史记录",noMore:"没有更多记录了",historyHeader:"历史记录"},uploadModal:{title:"上传文件",supportFormats:"支持 JPG, PNG 格式"},resultPanel:{waitingTitle:"等待识别结果",waitingSubtitle:"上传文件后TexPixel 将自动识别并在此显示结果",analyzing:"解析中...",waitingQueue:"排队中...",queueSubtitle:"您的文件正在排队,请稍候。",processingSubtitle:"TexPixel 正在处理您的文件,请稍候。",markdown:"Markdown"},auth:{signIn:"登录",signUp:"注册",signInTitle:"登录账号",signUpTitle:"注册账号",email:"邮箱",password:"密码",error:"错误",genericError:"发生错误,请重试",hasAccount:"已有账号?去登录",noAccount:"没有账号?去注册"},export:{title:"导出",categories:{code:"代码",image:"图片",file:"文件"},failed:"导出失败,请重试",imageFailed:"生成图片失败"},guide:{next:"下一步",prev:"上一步",finish:"完成",skip:"跳过",step1Title:"上传区域",step1Content:"点击此处或将公式/文档图片 粘贴或者拖拽到这里开始识别。",step2Title:"历史记录",step2Content:"识别过的文件会显示在这里。登录后可以跨设备同步。",step3Title:"预览区域",step3Content:"这里会显示您上传的原始文件,方便对比。",step4Title:"识别结果",step4Content:"这里会显示识别出的 Markdown/LaTeX 结果。",stepExportTitle:"导出结果",stepExportContent:"您可以将识别结果导出为多种格式,如 Markdown、LaTeX、Word 或图片。"},alerts:{taskTimeout:"任务超时:识别时间过长。",networkError:"任务超时或网络错误。",uploadFailed:"上传失败"}}};async function Qr(){try{const e=await fetch("https://ipapi.co/json/",{method:"GET",headers:{Accept:"application/json"}});if(!e.ok)return console.warn("IP location detection failed:",e.status),null;const r=await e.json();return r.error||!r.country_code?null:r.country_code.toUpperCase()}catch(e){return console.warn("IP location detection error:",e),null}}function Xr(e){return e&&["CN","TW","HK","MO","SG"].includes(e)?"zh":"en"}async function Zr(){const e=await Qr();return Xr(e)}const rr=H.createContext(void 0),Kr=({children:e})=>{const[r,a]=H.useState(()=>{const n=localStorage.getItem("language");return n==="en"||n==="zh"?n:navigator.language.startsWith("zh")?"zh":"en"});H.useEffect(()=>{const n=localStorage.getItem("language");n==="en"||n==="zh"||Zr().then(s=>{a(s)}).catch(s=>{console.warn("Failed to detect language by IP:",s)})},[]);const i=n=>{a(n),localStorage.setItem("language",n)},t=Vr[r];return E.jsx(rr.Provider,{value:{language:r,setLanguage:i,t},children:e})},_e=()=>{const e=H.useContext(rr);if(e===void 0)throw new Error("useLanguage must be used within a LanguageProvider");return e};function Yr(e,r){return r.forEach(function(a){a&&typeof a!="string"&&!Array.isArray(a)&&Object.keys(a).forEach(function(i){if(i!=="default"&&!(i in e)){var t=Object.getOwnPropertyDescriptor(a,i);Object.defineProperty(e,i,t.get?t:{enumerable:!0,get:function(){return a[i]}})}})}),Object.freeze(e)}function nr(e,r){return new Promise(function(a,i){let t;return Jr(e).then(function(n){try{return t=n,a(new Blob([r.slice(0,2),t,r.slice(2)],{type:"image/jpeg"}))}catch(s){return i(s)}},i)})}const Jr=e=>new Promise((r,a)=>{const i=new FileReader;i.addEventListener("load",({target:{result:t}})=>{const n=new DataView(t);let s=0;if(n.getUint16(s)!==65496)return a("not a valid JPEG");for(s+=2;;){const l=n.getUint16(s);if(l===65498)break;const m=n.getUint16(s+2);if(l===65505&&n.getUint32(s+4)===1165519206){const p=s+10;let o;switch(n.getUint16(p)){case 18761:o=!0;break;case 19789:o=!1;break;default:return a("TIFF header contains invalid endian")}if(n.getUint16(p+2,o)!==42)return a("TIFF header contains invalid version");const u=n.getUint32(p+4,o),c=p+u+2+12*n.getUint16(p+u,o);for(let f=p+u+2;f<c;f+=12)if(n.getUint16(f,o)==274){if(n.getUint16(f+2,o)!==3)return a("Orientation data type is invalid");if(n.getUint32(f+4,o)!==1)return a("Orientation data count is invalid");n.setUint16(f+8,1,o);break}return r(t.slice(s,s+2+m))}s+=2+m}return r(new Blob)}),i.readAsArrayBuffer(e)});var ot={},en={get exports(){return ot},set exports(e){ot=e}};(function(e){var r,a,i={};en.exports=i,i.parse=function(t,n){for(var s=i.bin.readUshort,l=i.bin.readUint,m=0,p={},o=new Uint8Array(t),u=o.length-4;l(o,u)!=101010256;)u--;m=u,m+=4;var c=s(o,m+=4);s(o,m+=2);var f=l(o,m+=2),y=l(o,m+=4);m+=4,m=y;for(var C=0;C<c;C++){l(o,m),m+=4,m+=4,m+=4,l(o,m+=4),f=l(o,m+=4);var k=l(o,m+=4),b=s(o,m+=4),w=s(o,m+2),g=s(o,m+4);m+=6;var h=l(o,m+=8);m+=4,m+=b+w+g,i._readLocal(o,h,p,f,k,n)}return p},i._readLocal=function(t,n,s,l,m,p){var o=i.bin.readUshort,u=i.bin.readUint;u(t,n),o(t,n+=4),o(t,n+=2);var c=o(t,n+=2);u(t,n+=2),u(t,n+=4),n+=4;var f=o(t,n+=8),y=o(t,n+=2);n+=2;var C=i.bin.readUTF8(t,n,f);if(n+=f,n+=y,p)s[C]={size:m,csize:l};else{var k=new Uint8Array(t.buffer,n);if(c==0)s[C]=new Uint8Array(k.buffer.slice(n,n+l));else{if(c!=8)throw"unknown compression method: "+c;var b=new Uint8Array(m);i.inflateRaw(k,b),s[C]=b}}},i.inflateRaw=function(t,n){return i.F.inflate(t,n)},i.inflate=function(t,n){return t[0],t[1],i.inflateRaw(new Uint8Array(t.buffer,t.byteOffset+2,t.length-6),n)},i.deflate=function(t,n){n==null&&(n={level:6});var s=0,l=new Uint8Array(50+Math.floor(1.1*t.length));l[s]=120,l[s+1]=156,s+=2,s=i.F.deflateRaw(t,l,s,n.level);var m=i.adler(t,0,t.length);return l[s+0]=m>>>24&255,l[s+1]=m>>>16&255,l[s+2]=m>>>8&255,l[s+3]=m>>>0&255,new Uint8Array(l.buffer,0,s+4)},i.deflateRaw=function(t,n){n==null&&(n={level:6});var s=new Uint8Array(50+Math.floor(1.1*t.length)),l=i.F.deflateRaw(t,s,l,n.level);return new Uint8Array(s.buffer,0,l)},i.encode=function(t,n){n==null&&(n=!1);var s=0,l=i.bin.writeUint,m=i.bin.writeUshort,p={};for(var o in t){var u=!i._noNeed(o)&&!n,c=t[o],f=i.crc.crc(c,0,c.length);p[o]={cpr:u,usize:c.length,crc:f,file:u?i.deflateRaw(c):c}}for(var o in p)s+=p[o].file.length+30+46+2*i.bin.sizeUTF8(o);s+=22;var y=new Uint8Array(s),C=0,k=[];for(var o in p){var b=p[o];k.push(C),C=i._writeHeader(y,C,o,b,0)}var w=0,g=C;for(var o in p)b=p[o],k.push(C),C=i._writeHeader(y,C,o,b,1,k[w++]);var h=C-g;return l(y,C,101010256),C+=4,m(y,C+=4,w),m(y,C+=2,w),l(y,C+=2,h),l(y,C+=4,g),C+=4,C+=2,y.buffer},i._noNeed=function(t){var n=t.split(".").pop().toLowerCase();return"png,jpg,jpeg,zip".indexOf(n)!=-1},i._writeHeader=function(t,n,s,l,m,p){var o=i.bin.writeUint,u=i.bin.writeUshort,c=l.file;return o(t,n,m==0?67324752:33639248),n+=4,m==1&&(n+=2),u(t,n,20),u(t,n+=2,0),u(t,n+=2,l.cpr?8:0),o(t,n+=2,0),o(t,n+=4,l.crc),o(t,n+=4,c.length),o(t,n+=4,l.usize),u(t,n+=4,i.bin.sizeUTF8(s)),u(t,n+=2,0),n+=2,m==1&&(n+=2,n+=2,o(t,n+=6,p),n+=4),n+=i.bin.writeUTF8(t,n,s),m==0&&(t.set(c,n),n+=c.length),n},i.crc={table:function(){for(var t=new Uint32Array(256),n=0;n<256;n++){for(var s=n,l=0;l<8;l++)1&s?s=3988292384^s>>>1:s>>>=1;t[n]=s}return t}(),update:function(t,n,s,l){for(var m=0;m<l;m++)t=i.crc.table[255&(t^n[s+m])]^t>>>8;return t},crc:function(t,n,s){return 4294967295^i.crc.update(4294967295,t,n,s)}},i.adler=function(t,n,s){for(var l=1,m=0,p=n,o=n+s;p<o;){for(var u=Math.min(p+5552,o);p<u;)m+=l+=t[p++];l%=65521,m%=65521}return m<<16|l},i.bin={readUshort:function(t,n){return t[n]|t[n+1]<<8},writeUshort:function(t,n,s){t[n]=255&s,t[n+1]=s>>8&255},readUint:function(t,n){return 16777216*t[n+3]+(t[n+2]<<16|t[n+1]<<8|t[n])},writeUint:function(t,n,s){t[n]=255&s,t[n+1]=s>>8&255,t[n+2]=s>>16&255,t[n+3]=s>>24&255},readASCII:function(t,n,s){for(var l="",m=0;m<s;m++)l+=String.fromCharCode(t[n+m]);return l},writeASCII:function(t,n,s){for(var l=0;l<s.length;l++)t[n+l]=s.charCodeAt(l)},pad:function(t){return t.length<2?"0"+t:t},readUTF8:function(t,n,s){for(var l,m="",p=0;p<s;p++)m+="%"+i.bin.pad(t[n+p].toString(16));try{l=decodeURIComponent(m)}catch{return i.bin.readASCII(t,n,s)}return l},writeUTF8:function(t,n,s){for(var l=s.length,m=0,p=0;p<l;p++){var o=s.charCodeAt(p);if(!(4294967168&o))t[n+m]=o,m++;else if(!(4294965248&o))t[n+m]=192|o>>6,t[n+m+1]=128|o>>0&63,m+=2;else if(!(4294901760&o))t[n+m]=224|o>>12,t[n+m+1]=128|o>>6&63,t[n+m+2]=128|o>>0&63,m+=3;else{if(4292870144&o)throw"e";t[n+m]=240|o>>18,t[n+m+1]=128|o>>12&63,t[n+m+2]=128|o>>6&63,t[n+m+3]=128|o>>0&63,m+=4}}return m},sizeUTF8:function(t){for(var n=t.length,s=0,l=0;l<n;l++){var m=t.charCodeAt(l);if(!(4294967168&m))s++;else if(!(4294965248&m))s+=2;else if(!(4294901760&m))s+=3;else{if(4292870144&m)throw"e";s+=4}}return s}},i.F={},i.F.deflateRaw=function(t,n,s,l){var m=[[0,0,0,0,0],[4,4,8,4,0],[4,5,16,8,0],[4,6,16,16,0],[4,10,16,32,0],[8,16,32,32,0],[8,16,128,128,0],[8,32,128,256,0],[32,128,258,1024,1],[32,258,258,4096,1]][l],p=i.F.U,o=i.F._goodIndex;i.F._hash;var u=i.F._putsE,c=0,f=s<<3,y=0,C=t.length;if(l==0){for(;c<C;)u(n,f,c+(R=Math.min(65535,C-c))==C?1:0),f=i.F._copyExact(t,c,R,n,f+8),c+=R;return f>>>3}var k=p.lits,b=p.strt,w=p.prev,g=0,h=0,S=0,d=0,I=0,x=0;for(C>2&&(b[x=i.F._hash(t,0)]=0),c=0;c<C;c++){if(I=x,c+1<C-2){x=i.F._hash(t,c+1);var A=c+1&32767;w[A]=b[x],b[x]=A}if(y<=c){(g>14e3||h>26697)&&C-c>100&&(y<c&&(k[g]=c-y,g+=2,y=c),f=i.F._writeBlock(c==C-1||y==C?1:0,k,g,d,t,S,c-S,n,f),g=h=d=0,S=c);var _=0;c<C-2&&(_=i.F._bestMatch(t,c,w,I,Math.min(m[2],C-c),m[3]));var R=_>>>16,T=65535&_;if(_!=0){T=65535&_;var M=o(R=_>>>16,p.of0);p.lhst[257+M]++;var N=o(T,p.df0);p.dhst[N]++,d+=p.exb[M]+p.dxb[N],k[g]=R<<23|c-y,k[g+1]=T<<16|M<<8|N,g+=2,y=c+R}else p.lhst[t[c]]++;h++}}for(S==c&&t.length!=0||(y<c&&(k[g]=c-y,g+=2,y=c),f=i.F._writeBlock(1,k,g,d,t,S,c-S,n,f),g=0,h=0,g=h=d=0,S=c);7&f;)f++;return f>>>3},i.F._bestMatch=function(t,n,s,l,m,p){var o=32767&n,u=s[o],c=o-u+32768&32767;if(u==o||l!=i.F._hash(t,n-c))return 0;for(var f=0,y=0,C=Math.min(32767,n);c<=C&&--p!=0&&u!=o;){if(f==0||t[n+f]==t[n+f-c]){var k=i.F._howLong(t,n,c);if(k>f){if(y=c,(f=k)>=m)break;c+2<k&&(k=c+2);for(var b=0,w=0;w<k-2;w++){var g=n-c+w+32768&32767,h=g-s[g]+32768&32767;h>b&&(b=h,u=g)}}}c+=(o=u)-(u=s[o])+32768&32767}return f<<16|y},i.F._howLong=function(t,n,s){if(t[n]!=t[n-s]||t[n+1]!=t[n+1-s]||t[n+2]!=t[n+2-s])return 0;var l=n,m=Math.min(t.length,n+258);for(n+=3;n<m&&t[n]==t[n-s];)n++;return n-l},i.F._hash=function(t,n){return(t[n]<<8|t[n+1])+(t[n+2]<<4)&65535},i.saved=0,i.F._writeBlock=function(t,n,s,l,m,p,o,u,c){var f,y,C,k,b,w,g,h,S,d=i.F.U,I=i.F._putsF,x=i.F._putsE;d.lhst[256]++,y=(f=i.F.getTrees())[0],C=f[1],k=f[2],b=f[3],w=f[4],g=f[5],h=f[6],S=f[7];var A=32+(c+3&7?8-(c+3&7):0)+(o<<3),_=l+i.F.contSize(d.fltree,d.lhst)+i.F.contSize(d.fdtree,d.dhst),R=l+i.F.contSize(d.ltree,d.lhst)+i.F.contSize(d.dtree,d.dhst);R+=14+3*g+i.F.contSize(d.itree,d.ihst)+(2*d.ihst[16]+3*d.ihst[17]+7*d.ihst[18]);for(var T=0;T<286;T++)d.lhst[T]=0;for(T=0;T<30;T++)d.dhst[T]=0;for(T=0;T<19;T++)d.ihst[T]=0;var M=A<_&&A<R?0:_<R?1:2;if(I(u,c,t),I(u,c+1,M),c+=3,M==0){for(;7&c;)c++;c=i.F._copyExact(m,p,o,u,c)}else{var N,U;if(M==1&&(N=d.fltree,U=d.fdtree),M==2){i.F.makeCodes(d.ltree,y),i.F.revCodes(d.ltree,y),i.F.makeCodes(d.dtree,C),i.F.revCodes(d.dtree,C),i.F.makeCodes(d.itree,k),i.F.revCodes(d.itree,k),N=d.ltree,U=d.dtree,x(u,c,b-257),x(u,c+=5,w-1),x(u,c+=5,g-4),c+=4;for(var j=0;j<g;j++)x(u,c+3*j,d.itree[1+(d.ordr[j]<<1)]);c+=3*g,c=i.F._codeTiny(h,d.itree,u,c),c=i.F._codeTiny(S,d.itree,u,c)}for(var v=p,P=0;P<s;P+=2){for(var L=n[P],$=L>>>23,q=v+(8388607&L);v<q;)c=i.F._writeLit(m[v++],N,u,c);if($!=0){var D=n[P+1],W=D>>16,z=D>>8&255,F=255&D;x(u,c=i.F._writeLit(257+z,N,u,c),$-d.of0[z]),c+=d.exb[z],I(u,c=i.F._writeLit(F,U,u,c),W-d.df0[F]),c+=d.dxb[F],v+=$}}c=i.F._writeLit(256,N,u,c)}return c},i.F._copyExact=function(t,n,s,l,m){var p=m>>>3;return l[p]=s,l[p+1]=s>>>8,l[p+2]=255-l[p],l[p+3]=255-l[p+1],p+=4,l.set(new Uint8Array(t.buffer,n,s),p),m+(s+4<<3)},i.F.getTrees=function(){for(var t=i.F.U,n=i.F._hufTree(t.lhst,t.ltree,15),s=i.F._hufTree(t.dhst,t.dtree,15),l=[],m=i.F._lenCodes(t.ltree,l),p=[],o=i.F._lenCodes(t.dtree,p),u=0;u<l.length;u+=2)t.ihst[l[u]]++;for(u=0;u<p.length;u+=2)t.ihst[p[u]]++;for(var c=i.F._hufTree(t.ihst,t.itree,7),f=19;f>4&&t.itree[1+(t.ordr[f-1]<<1)]==0;)f--;return[n,s,c,m,o,f,l,p]},i.F.getSecond=function(t){for(var n=[],s=0;s<t.length;s+=2)n.push(t[s+1]);return n},i.F.nonZero=function(t){for(var n="",s=0;s<t.length;s+=2)t[s+1]!=0&&(n+=(s>>1)+",");return n},i.F.contSize=function(t,n){for(var s=0,l=0;l<n.length;l++)s+=n[l]*t[1+(l<<1)];return s},i.F._codeTiny=function(t,n,s,l){for(var m=0;m<t.length;m+=2){var p=t[m],o=t[m+1];l=i.F._writeLit(p,n,s,l);var u=p==16?2:p==17?3:7;p>15&&(i.F._putsE(s,l,o,u),l+=u)}return l},i.F._lenCodes=function(t,n){for(var s=t.length;s!=2&&t[s-1]==0;)s-=2;for(var l=0;l<s;l+=2){var m=t[l+1],p=l+3<s?t[l+3]:-1,o=l+5<s?t[l+5]:-1,u=l==0?-1:t[l-1];if(m==0&&p==m&&o==m){for(var c=l+5;c+2<s&&t[c+2]==m;)c+=2;(f=Math.min(c+1-l>>>1,138))<11?n.push(17,f-3):n.push(18,f-11),l+=2*f-2}else if(m==u&&p==m&&o==m){for(c=l+5;c+2<s&&t[c+2]==m;)c+=2;var f=Math.min(c+1-l>>>1,6);n.push(16,f-3),l+=2*f-2}else n.push(m,0)}return s>>>1},i.F._hufTree=function(t,n,s){var l=[],m=t.length,p=n.length,o=0;for(o=0;o<p;o+=2)n[o]=0,n[o+1]=0;for(o=0;o<m;o++)t[o]!=0&&l.push({lit:o,f:t[o]});var u=l.length,c=l.slice(0);if(u==0)return 0;if(u==1){var f=l[0].lit;return c=f==0?1:0,n[1+(f<<1)]=1,n[1+(c<<1)]=1,1}l.sort(function(h,S){return h.f-S.f});var y=l[0],C=l[1],k=0,b=1,w=2;for(l[0]={lit:-1,f:y.f+C.f,l:y,r:C,d:0};b!=u-1;)y=k!=b&&(w==u||l[k].f<l[w].f)?l[k++]:l[w++],C=k!=b&&(w==u||l[k].f<l[w].f)?l[k++]:l[w++],l[b++]={lit:-1,f:y.f+C.f,l:y,r:C};var g=i.F.setDepth(l[b-1],0);for(g>s&&(i.F.restrictDepth(c,s,g),g=s),o=0;o<u;o++)n[1+(c[o].lit<<1)]=c[o].d;return g},i.F.setDepth=function(t,n){return t.lit!=-1?(t.d=n,n):Math.max(i.F.setDepth(t.l,n+1),i.F.setDepth(t.r,n+1))},i.F.restrictDepth=function(t,n,s){var l=0,m=1<<s-n,p=0;for(t.sort(function(u,c){return c.d==u.d?u.f-c.f:c.d-u.d}),l=0;l<t.length&&t[l].d>n;l++){var o=t[l].d;t[l].d=n,p+=m-(1<<s-o)}for(p>>>=s-n;p>0;)(o=t[l].d)<n?(t[l].d++,p-=1<<n-o-1):l++;for(;l>=0;l--)t[l].d==n&&p<0&&(t[l].d--,p++);p!=0&&console.log("debt left")},i.F._goodIndex=function(t,n){var s=0;return n[16|s]<=t&&(s|=16),n[8|s]<=t&&(s|=8),n[4|s]<=t&&(s|=4),n[2|s]<=t&&(s|=2),n[1|s]<=t&&(s|=1),s},i.F._writeLit=function(t,n,s,l){return i.F._putsF(s,l,n[t<<1]),l+n[1+(t<<1)]},i.F.inflate=function(t,n){var s=Uint8Array;if(t[0]==3&&t[1]==0)return n||new s(0);var l=i.F,m=l._bitsF,p=l._bitsE,o=l._decodeTiny,u=l.makeCodes,c=l.codes2map,f=l._get17,y=l.U,C=n==null;C&&(n=new s(t.length>>>2<<3));for(var k,b,w=0,g=0,h=0,S=0,d=0,I=0,x=0,A=0,_=0;w==0;)if(w=m(t,_,1),g=m(t,_+1,2),_+=3,g!=0){if(C&&(n=i.F._check(n,A+(1<<17))),g==1&&(k=y.flmap,b=y.fdmap,I=511,x=31),g==2){h=p(t,_,5)+257,S=p(t,_+5,5)+1,d=p(t,_+10,4)+4,_+=14;for(var R=0;R<38;R+=2)y.itree[R]=0,y.itree[R+1]=0;var T=1;for(R=0;R<d;R++){var M=p(t,_+3*R,3);y.itree[1+(y.ordr[R]<<1)]=M,M>T&&(T=M)}_+=3*d,u(y.itree,T),c(y.itree,T,y.imap),k=y.lmap,b=y.dmap,_=o(y.imap,(1<<T)-1,h+S,t,_,y.ttree);var N=l._copyOut(y.ttree,0,h,y.ltree);I=(1<<N)-1;var U=l._copyOut(y.ttree,h,S,y.dtree);x=(1<<U)-1,u(y.ltree,N),c(y.ltree,N,k),u(y.dtree,U),c(y.dtree,U,b)}for(;;){var j=k[f(t,_)&I];_+=15&j;var v=j>>>4;if(!(v>>>8))n[A++]=v;else{if(v==256)break;var P=A+v-254;if(v>264){var L=y.ldef[v-257];P=A+(L>>>3)+p(t,_,7&L),_+=7&L}var $=b[f(t,_)&x];_+=15&$;var q=$>>>4,D=y.ddef[q],W=(D>>>4)+m(t,_,15&D);for(_+=15&D,C&&(n=i.F._check(n,A+(1<<17)));A<P;)n[A]=n[A++-W],n[A]=n[A++-W],n[A]=n[A++-W],n[A]=n[A++-W];A=P}}}else{7&_&&(_+=8-(7&_));var z=4+(_>>>3),F=t[z-4]|t[z-3]<<8;C&&(n=i.F._check(n,A+F)),n.set(new s(t.buffer,t.byteOffset+z,F),A),_=z+F<<3,A+=F}return n.length==A?n:n.slice(0,A)},i.F._check=function(t,n){var s=t.length;if(n<=s)return t;var l=new Uint8Array(Math.max(s<<1,n));return l.set(t,0),l},i.F._decodeTiny=function(t,n,s,l,m,p){for(var o=i.F._bitsE,u=i.F._get17,c=0;c<s;){var f=t[u(l,m)&n];m+=15&f;var y=f>>>4;if(y<=15)p[c]=y,c++;else{var C=0,k=0;y==16?(k=3+o(l,m,2),m+=2,C=p[c-1]):y==17?(k=3+o(l,m,3),m+=3):y==18&&(k=11+o(l,m,7),m+=7);for(var b=c+k;c<b;)p[c]=C,c++}}return m},i.F._copyOut=function(t,n,s,l){for(var m=0,p=0,o=l.length>>>1;p<s;){var u=t[p+n];l[p<<1]=0,l[1+(p<<1)]=u,u>m&&(m=u),p++}for(;p<o;)l[p<<1]=0,l[1+(p<<1)]=0,p++;return m},i.F.makeCodes=function(t,n){for(var s,l,m,p,o=i.F.U,u=t.length,c=o.bl_count,f=0;f<=n;f++)c[f]=0;for(f=1;f<u;f+=2)c[t[f]]++;var y=o.next_code;for(s=0,c[0]=0,l=1;l<=n;l++)s=s+c[l-1]<<1,y[l]=s;for(m=0;m<u;m+=2)(p=t[m+1])!=0&&(t[m]=y[p],y[p]++)},i.F.codes2map=function(t,n,s){for(var l=t.length,m=i.F.U.rev15,p=0;p<l;p+=2)if(t[p+1]!=0)for(var o=p>>1,u=t[p+1],c=o<<4|u,f=n-u,y=t[p]<<f,C=y+(1<<f);y!=C;)s[m[y]>>>15-n]=c,y++},i.F.revCodes=function(t,n){for(var s=i.F.U.rev15,l=15-n,m=0;m<t.length;m+=2){var p=t[m]<<n-t[m+1];t[m]=s[p]>>>l}},i.F._putsE=function(t,n,s){s<<=7&n;var l=n>>>3;t[l]|=s,t[l+1]|=s>>>8},i.F._putsF=function(t,n,s){s<<=7&n;var l=n>>>3;t[l]|=s,t[l+1]|=s>>>8,t[l+2]|=s>>>16},i.F._bitsE=function(t,n,s){return(t[n>>>3]|t[1+(n>>>3)]<<8)>>>(7&n)&(1<<s)-1},i.F._bitsF=function(t,n,s){return(t[n>>>3]|t[1+(n>>>3)]<<8|t[2+(n>>>3)]<<16)>>>(7&n)&(1<<s)-1},i.F._get17=function(t,n){return(t[n>>>3]|t[1+(n>>>3)]<<8|t[2+(n>>>3)]<<16)>>>(7&n)},i.F._get25=function(t,n){return(t[n>>>3]|t[1+(n>>>3)]<<8|t[2+(n>>>3)]<<16|t[3+(n>>>3)]<<24)>>>(7&n)},i.F.U=(r=Uint16Array,a=Uint32Array,{next_code:new r(16),bl_count:new r(16),ordr:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],of0:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],exb:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],ldef:new r(32),df0:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],dxb:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],ddef:new a(32),flmap:new r(512),fltree:[],fdmap:new r(32),fdtree:[],lmap:new r(32768),ltree:[],ttree:[],dmap:new r(32768),dtree:[],imap:new r(512),itree:[],rev15:new r(32768),lhst:new a(286),dhst:new a(30),ihst:new a(19),lits:new a(15e3),strt:new r(65536),prev:new r(32768)}),function(){for(var t=i.F.U,n=0;n<32768;n++){var s=n;s=(4278255360&(s=(4042322160&(s=(3435973836&(s=(2863311530&s)>>>1|(1431655765&s)<<1))>>>2|(858993459&s)<<2))>>>4|(252645135&s)<<4))>>>8|(16711935&s)<<8,t.rev15[n]=(s>>>16|s<<16)>>>17}function l(m,p,o){for(;p--!=0;)m.push(0,o)}for(n=0;n<32;n++)t.ldef[n]=t.of0[n]<<3|t.exb[n],t.ddef[n]=t.df0[n]<<4|t.dxb[n];l(t.fltree,144,8),l(t.fltree,112,9),l(t.fltree,24,7),l(t.fltree,8,8),i.F.makeCodes(t.fltree,9),i.F.codes2map(t.fltree,9,t.flmap),i.F.revCodes(t.fltree,9),l(t.fdtree,32,5),i.F.makeCodes(t.fdtree,5),i.F.codes2map(t.fdtree,5,t.fdmap),i.F.revCodes(t.fdtree,5),l(t.itree,19,0),l(t.ltree,286,0),l(t.dtree,30,0),l(t.ttree,320,0)}()})();var tn=Yr({__proto__:null,default:ot},[ot]);const Se=function(){var e={nextZero(o,u){for(;o[u]!=0;)u++;return u},readUshort:(o,u)=>o[u]<<8|o[u+1],writeUshort(o,u,c){o[u]=c>>8&255,o[u+1]=255&c},readUint:(o,u)=>16777216*o[u]+(o[u+1]<<16|o[u+2]<<8|o[u+3]),writeUint(o,u,c){o[u]=c>>24&255,o[u+1]=c>>16&255,o[u+2]=c>>8&255,o[u+3]=255&c},readASCII(o,u,c){let f="";for(let y=0;y<c;y++)f+=String.fromCharCode(o[u+y]);return f},writeASCII(o,u,c){for(let f=0;f<c.length;f++)o[u+f]=c.charCodeAt(f)},readBytes(o,u,c){const f=[];for(let y=0;y<c;y++)f.push(o[u+y]);return f},pad:o=>o.length<2?`0${o}`:o,readUTF8(o,u,c){let f,y="";for(let C=0;C<c;C++)y+=`%${e.pad(o[u+C].toString(16))}`;try{f=decodeURIComponent(y)}catch{return e.readASCII(o,u,c)}return f}};function r(o,u,c,f){const y=u*c,C=n(f),k=Math.ceil(u*C/8),b=new Uint8Array(4*y),w=new Uint32Array(b.buffer),{ctype:g}=f,{depth:h}=f,S=e.readUshort;if(g==6){const L=y<<2;if(h==8)for(var d=0;d<L;d+=4)b[d]=o[d],b[d+1]=o[d+1],b[d+2]=o[d+2],b[d+3]=o[d+3];if(h==16)for(d=0;d<L;d++)b[d]=o[d<<1]}else if(g==2){const L=f.tabs.tRNS;if(L==null){if(h==8)for(d=0;d<y;d++){var I=3*d;w[d]=255<<24|o[I+2]<<16|o[I+1]<<8|o[I]}if(h==16)for(d=0;d<y;d++)I=6*d,w[d]=255<<24|o[I+4]<<16|o[I+2]<<8|o[I]}else{var x=L[0];const $=L[1],q=L[2];if(h==8)for(d=0;d<y;d++){var A=d<<2;I=3*d,w[d]=255<<24|o[I+2]<<16|o[I+1]<<8|o[I],o[I]==x&&o[I+1]==$&&o[I+2]==q&&(b[A+3]=0)}if(h==16)for(d=0;d<y;d++)A=d<<2,I=6*d,w[d]=255<<24|o[I+4]<<16|o[I+2]<<8|o[I],S(o,I)==x&&S(o,I+2)==$&&S(o,I+4)==q&&(b[A+3]=0)}}else if(g==3){const L=f.tabs.PLTE,$=f.tabs.tRNS,q=$?$.length:0;if(h==1)for(var _=0;_<c;_++){var R=_*k,T=_*u;for(d=0;d<u;d++){A=T+d<<2;var M=3*(N=o[R+(d>>3)]>>7-((7&d)<<0)&1);b[A]=L[M],b[A+1]=L[M+1],b[A+2]=L[M+2],b[A+3]=N<q?$[N]:255}}if(h==2)for(_=0;_<c;_++)for(R=_*k,T=_*u,d=0;d<u;d++)A=T+d<<2,M=3*(N=o[R+(d>>2)]>>6-((3&d)<<1)&3),b[A]=L[M],b[A+1]=L[M+1],b[A+2]=L[M+2],b[A+3]=N<q?$[N]:255;if(h==4)for(_=0;_<c;_++)for(R=_*k,T=_*u,d=0;d<u;d++)A=T+d<<2,M=3*(N=o[R+(d>>1)]>>4-((1&d)<<2)&15),b[A]=L[M],b[A+1]=L[M+1],b[A+2]=L[M+2],b[A+3]=N<q?$[N]:255;if(h==8)for(d=0;d<y;d++){var N;A=d<<2,M=3*(N=o[d]),b[A]=L[M],b[A+1]=L[M+1],b[A+2]=L[M+2],b[A+3]=N<q?$[N]:255}}else if(g==4){if(h==8)for(d=0;d<y;d++){A=d<<2;var U=o[j=d<<1];b[A]=U,b[A+1]=U,b[A+2]=U,b[A+3]=o[j+1]}if(h==16)for(d=0;d<y;d++){var j;A=d<<2,U=o[j=d<<2],b[A]=U,b[A+1]=U,b[A+2]=U,b[A+3]=o[j+2]}}else if(g==0)for(x=f.tabs.tRNS?f.tabs.tRNS:-1,_=0;_<c;_++){const L=_*k,$=_*u;if(h==1)for(var v=0;v<u;v++){var P=(U=255*(o[L+(v>>>3)]>>>7-(7&v)&1))==255*x?0:255;w[$+v]=P<<24|U<<16|U<<8|U}else if(h==2)for(v=0;v<u;v++)P=(U=85*(o[L+(v>>>2)]>>>6-((3&v)<<1)&3))==85*x?0:255,w[$+v]=P<<24|U<<16|U<<8|U;else if(h==4)for(v=0;v<u;v++)P=(U=17*(o[L+(v>>>1)]>>>4-((1&v)<<2)&15))==17*x?0:255,w[$+v]=P<<24|U<<16|U<<8|U;else if(h==8)for(v=0;v<u;v++)P=(U=o[L+v])==x?0:255,w[$+v]=P<<24|U<<16|U<<8|U;else if(h==16)for(v=0;v<u;v++)U=o[L+(v<<1)],P=S(o,L+(v<<1))==x?0:255,w[$+v]=P<<24|U<<16|U<<8|U}return b}function a(o,u,c,f){const y=n(o),C=Math.ceil(c*y/8),k=new Uint8Array((C+1+o.interlace)*f);return u=o.tabs.CgBI?t(u,k):i(u,k),o.interlace==0?u=s(u,o,0,c,f):o.interlace==1&&(u=function(w,g){const h=g.width,S=g.height,d=n(g),I=d>>3,x=Math.ceil(h*d/8),A=new Uint8Array(S*x);let _=0;const R=[0,0,4,0,2,0,1],T=[0,4,0,2,0,1,0],M=[8,8,8,4,4,2,2],N=[8,8,4,4,2,2,1];let U=0;for(;U<7;){const v=M[U],P=N[U];let L=0,$=0,q=R[U];for(;q<S;)q+=v,$++;let D=T[U];for(;D<h;)D+=P,L++;const W=Math.ceil(L*d/8);s(w,g,_,L,$);let z=0,F=R[U];for(;F<S;){let V=T[U],O=_+z*W<<3;for(;V<h;){var j;if(d==1&&(j=(j=w[O>>3])>>7-(7&O)&1,A[F*x+(V>>3)]|=j<<7-((7&V)<<0)),d==2&&(j=(j=w[O>>3])>>6-(7&O)&3,A[F*x+(V>>2)]|=j<<6-((3&V)<<1)),d==4&&(j=(j=w[O>>3])>>4-(7&O)&15,A[F*x+(V>>1)]|=j<<4-((1&V)<<2)),d>=8){const B=F*x+V*I;for(let G=0;G<I;G++)A[B+G]=w[(O>>3)+G]}O+=d,V+=P}z++,F+=v}L*$!=0&&(_+=$*(1+W)),U+=1}return A}(u,o)),u}function i(o,u){return t(new Uint8Array(o.buffer,2,o.length-6),u)}var t=function(){const o={H:{}};return o.H.N=function(u,c){const f=Uint8Array;let y,C,k=0,b=0,w=0,g=0,h=0,S=0,d=0,I=0,x=0;if(u[0]==3&&u[1]==0)return c||new f(0);const A=o.H,_=A.b,R=A.e,T=A.R,M=A.n,N=A.A,U=A.Z,j=A.m,v=c==null;for(v&&(c=new f(u.length>>>2<<5));k==0;)if(k=_(u,x,1),b=_(u,x+1,2),x+=3,b!=0){if(v&&(c=o.H.W(c,I+(1<<17))),b==1&&(y=j.J,C=j.h,S=511,d=31),b==2){w=R(u,x,5)+257,g=R(u,x+5,5)+1,h=R(u,x+10,4)+4,x+=14;let L=1;for(var P=0;P<38;P+=2)j.Q[P]=0,j.Q[P+1]=0;for(P=0;P<h;P++){const D=R(u,x+3*P,3);j.Q[1+(j.X[P]<<1)]=D,D>L&&(L=D)}x+=3*h,M(j.Q,L),N(j.Q,L,j.u),y=j.w,C=j.d,x=T(j.u,(1<<L)-1,w+g,u,x,j.v);const $=A.V(j.v,0,w,j.C);S=(1<<$)-1;const q=A.V(j.v,w,g,j.D);d=(1<<q)-1,M(j.C,$),N(j.C,$,y),M(j.D,q),N(j.D,q,C)}for(;;){const L=y[U(u,x)&S];x+=15&L;const $=L>>>4;if(!($>>>8))c[I++]=$;else{if($==256)break;{let q=I+$-254;if($>264){const V=j.q[$-257];q=I+(V>>>3)+R(u,x,7&V),x+=7&V}const D=C[U(u,x)&d];x+=15&D;const W=D>>>4,z=j.c[W],F=(z>>>4)+_(u,x,15&z);for(x+=15&z;I<q;)c[I]=c[I++-F],c[I]=c[I++-F],c[I]=c[I++-F],c[I]=c[I++-F];I=q}}}}else{7&x&&(x+=8-(7&x));const L=4+(x>>>3),$=u[L-4]|u[L-3]<<8;v&&(c=o.H.W(c,I+$)),c.set(new f(u.buffer,u.byteOffset+L,$),I),x=L+$<<3,I+=$}return c.length==I?c:c.slice(0,I)},o.H.W=function(u,c){const f=u.length;if(c<=f)return u;const y=new Uint8Array(f<<1);return y.set(u,0),y},o.H.R=function(u,c,f,y,C,k){const b=o.H.e,w=o.H.Z;let g=0;for(;g<f;){const h=u[w(y,C)&c];C+=15&h;const S=h>>>4;if(S<=15)k[g]=S,g++;else{let d=0,I=0;S==16?(I=3+b(y,C,2),C+=2,d=k[g-1]):S==17?(I=3+b(y,C,3),C+=3):S==18&&(I=11+b(y,C,7),C+=7);const x=g+I;for(;g<x;)k[g]=d,g++}}return C},o.H.V=function(u,c,f,y){let C=0,k=0;const b=y.length>>>1;for(;k<f;){const w=u[k+c];y[k<<1]=0,y[1+(k<<1)]=w,w>C&&(C=w),k++}for(;k<b;)y[k<<1]=0,y[1+(k<<1)]=0,k++;return C},o.H.n=function(u,c){const f=o.H.m,y=u.length;let C,k,b,w;const g=f.j;for(var h=0;h<=c;h++)g[h]=0;for(h=1;h<y;h+=2)g[u[h]]++;const S=f.K;for(C=0,g[0]=0,k=1;k<=c;k++)C=C+g[k-1]<<1,S[k]=C;for(b=0;b<y;b+=2)w=u[b+1],w!=0&&(u[b]=S[w],S[w]++)},o.H.A=function(u,c,f){const y=u.length,C=o.H.m.r;for(let k=0;k<y;k+=2)if(u[k+1]!=0){const b=k>>1,w=u[k+1],g=b<<4|w,h=c-w;let S=u[k]<<h;const d=S+(1<<h);for(;S!=d;)f[C[S]>>>15-c]=g,S++}},o.H.l=function(u,c){const f=o.H.m.r,y=15-c;for(let C=0;C<u.length;C+=2){const k=u[C]<<c-u[C+1];u[C]=f[k]>>>y}},o.H.M=function(u,c,f){f<<=7&c;const y=c>>>3;u[y]|=f,u[y+1]|=f>>>8},o.H.I=function(u,c,f){f<<=7&c;const y=c>>>3;u[y]|=f,u[y+1]|=f>>>8,u[y+2]|=f>>>16},o.H.e=function(u,c,f){return(u[c>>>3]|u[1+(c>>>3)]<<8)>>>(7&c)&(1<<f)-1},o.H.b=function(u,c,f){return(u[c>>>3]|u[1+(c>>>3)]<<8|u[2+(c>>>3)]<<16)>>>(7&c)&(1<<f)-1},o.H.Z=function(u,c){return(u[c>>>3]|u[1+(c>>>3)]<<8|u[2+(c>>>3)]<<16)>>>(7&c)},o.H.i=function(u,c){return(u[c>>>3]|u[1+(c>>>3)]<<8|u[2+(c>>>3)]<<16|u[3+(c>>>3)]<<24)>>>(7&c)},o.H.m=function(){const u=Uint16Array,c=Uint32Array;return{K:new u(16),j:new u(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],T:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],q:new u(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],z:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],c:new c(32),J:new u(512),_:[],h:new u(32),$:[],w:new u(32768),C:[],v:[],d:new u(32768),D:[],u:new u(512),Q:[],r:new u(32768),s:new c(286),Y:new c(30),a:new c(19),t:new c(15e3),k:new u(65536),g:new u(32768)}}(),function(){const u=o.H.m;for(var c=0;c<32768;c++){let y=c;y=(2863311530&y)>>>1|(1431655765&y)<<1,y=(3435973836&y)>>>2|(858993459&y)<<2,y=(4042322160&y)>>>4|(252645135&y)<<4,y=(4278255360&y)>>>8|(16711935&y)<<8,u.r[c]=(y>>>16|y<<16)>>>17}function f(y,C,k){for(;C--!=0;)y.push(0,k)}for(c=0;c<32;c++)u.q[c]=u.S[c]<<3|u.T[c],u.c[c]=u.p[c]<<4|u.z[c];f(u._,144,8),f(u._,112,9),f(u._,24,7),f(u._,8,8),o.H.n(u._,9),o.H.A(u._,9,u.J),o.H.l(u._,9),f(u.$,32,5),o.H.n(u.$,5),o.H.A(u.$,5,u.h),o.H.l(u.$,5),f(u.Q,19,0),f(u.C,286,0),f(u.D,30,0),f(u.v,320,0)}(),o.H.N}();function n(o){return[1,null,3,1,2,null,4][o.ctype]*o.depth}function s(o,u,c,f,y){let C=n(u);const k=Math.ceil(f*C/8);let b,w;C=Math.ceil(C/8);let g=o[c],h=0;if(g>1&&(o[c]=[0,0,1][g-2]),g==3)for(h=C;h<k;h++)o[h+1]=o[h+1]+(o[h+1-C]>>>1)&255;for(let S=0;S<y;S++)if(b=c+S*k,w=b+S+1,g=o[w-1],h=0,g==0)for(;h<k;h++)o[b+h]=o[w+h];else if(g==1){for(;h<C;h++)o[b+h]=o[w+h];for(;h<k;h++)o[b+h]=o[w+h]+o[b+h-C]}else if(g==2)for(;h<k;h++)o[b+h]=o[w+h]+o[b+h-k];else if(g==3){for(;h<C;h++)o[b+h]=o[w+h]+(o[b+h-k]>>>1);for(;h<k;h++)o[b+h]=o[w+h]+(o[b+h-k]+o[b+h-C]>>>1)}else{for(;h<C;h++)o[b+h]=o[w+h]+l(0,o[b+h-k],0);for(;h<k;h++)o[b+h]=o[w+h]+l(o[b+h-C],o[b+h-k],o[b+h-C-k])}return o}function l(o,u,c){const f=o+u-c,y=f-o,C=f-u,k=f-c;return y*y<=C*C&&y*y<=k*k?o:C*C<=k*k?u:c}function m(o,u,c){c.width=e.readUint(o,u),u+=4,c.height=e.readUint(o,u),u+=4,c.depth=o[u],u++,c.ctype=o[u],u++,c.compress=o[u],u++,c.filter=o[u],u++,c.interlace=o[u],u++}function p(o,u,c,f,y,C,k,b,w){const g=Math.min(u,y),h=Math.min(c,C);let S=0,d=0;for(let U=0;U<h;U++)for(let j=0;j<g;j++)if(k>=0&&b>=0?(S=U*u+j<<2,d=(b+U)*y+k+j<<2):(S=(-b+U)*u-k+j<<2,d=U*y+j<<2),w==0)f[d]=o[S],f[d+1]=o[S+1],f[d+2]=o[S+2],f[d+3]=o[S+3];else if(w==1){var I=o[S+3]*.00392156862745098,x=o[S]*I,A=o[S+1]*I,_=o[S+2]*I,R=f[d+3]*(1/255),T=f[d]*R,M=f[d+1]*R,N=f[d+2]*R;const v=1-I,P=I+R*v,L=P==0?0:1/P;f[d+3]=255*P,f[d+0]=(x+T*v)*L,f[d+1]=(A+M*v)*L,f[d+2]=(_+N*v)*L}else if(w==2)I=o[S+3],x=o[S],A=o[S+1],_=o[S+2],R=f[d+3],T=f[d],M=f[d+1],N=f[d+2],I==R&&x==T&&A==M&&_==N?(f[d]=0,f[d+1]=0,f[d+2]=0,f[d+3]=0):(f[d]=x,f[d+1]=A,f[d+2]=_,f[d+3]=I);else if(w==3){if(I=o[S+3],x=o[S],A=o[S+1],_=o[S+2],R=f[d+3],T=f[d],M=f[d+1],N=f[d+2],I==R&&x==T&&A==M&&_==N)continue;if(I<220&&R>20)return!1}return!0}return{decode:function(u){const c=new Uint8Array(u);let f=8;const y=e,C=y.readUshort,k=y.readUint,b={tabs:{},frames:[]},w=new Uint8Array(c.length);let g,h=0,S=0;const d=[137,80,78,71,13,10,26,10];for(var I=0;I<8;I++)if(c[I]!=d[I])throw"The input is not a PNG file!";for(;f<c.length;){const U=y.readUint(c,f);f+=4;const j=y.readASCII(c,f,4);if(f+=4,j=="IHDR")m(c,f,b);else if(j=="iCCP"){for(var x=f;c[x]!=0;)x++;y.readASCII(c,f,x-f),c[x+1];const v=c.slice(x+2,f+U);let P=null;try{P=i(v)}catch{P=t(v)}b.tabs[j]=P}else if(j=="CgBI")b.tabs[j]=c.slice(f,f+4);else if(j=="IDAT"){for(I=0;I<U;I++)w[h+I]=c[f+I];h+=U}else if(j=="acTL")b.tabs[j]={num_frames:k(c,f),num_plays:k(c,f+4)},g=new Uint8Array(c.length);else if(j=="fcTL"){S!=0&&((N=b.frames[b.frames.length-1]).data=a(b,g.slice(0,S),N.rect.width,N.rect.height),S=0);const v={x:k(c,f+12),y:k(c,f+16),width:k(c,f+4),height:k(c,f+8)};let P=C(c,f+22);P=C(c,f+20)/(P==0?100:P);const L={rect:v,delay:Math.round(1e3*P),dispose:c[f+24],blend:c[f+25]};b.frames.push(L)}else if(j=="fdAT"){for(I=0;I<U-4;I++)g[S+I]=c[f+I+4];S+=U-4}else if(j=="pHYs")b.tabs[j]=[y.readUint(c,f),y.readUint(c,f+4),c[f+8]];else if(j=="cHRM")for(b.tabs[j]=[],I=0;I<8;I++)b.tabs[j].push(y.readUint(c,f+4*I));else if(j=="tEXt"||j=="zTXt"){b.tabs[j]==null&&(b.tabs[j]={});var A=y.nextZero(c,f),_=y.readASCII(c,f,A-f),R=f+U-A-1;if(j=="tEXt")M=y.readASCII(c,A+1,R);else{var T=i(c.slice(A+2,A+2+R));M=y.readUTF8(T,0,T.length)}b.tabs[j][_]=M}else if(j=="iTXt"){b.tabs[j]==null&&(b.tabs[j]={}),A=0,x=f,A=y.nextZero(c,x),_=y.readASCII(c,x,A-x);const v=c[x=A+1];var M;c[x+1],x+=2,A=y.nextZero(c,x),y.readASCII(c,x,A-x),x=A+1,A=y.nextZero(c,x),y.readUTF8(c,x,A-x),R=U-((x=A+1)-f),v==0?M=y.readUTF8(c,x,R):(T=i(c.slice(x,x+R)),M=y.readUTF8(T,0,T.length)),b.tabs[j][_]=M}else if(j=="PLTE")b.tabs[j]=y.readBytes(c,f,U);else if(j=="hIST"){const v=b.tabs.PLTE.length/3;for(b.tabs[j]=[],I=0;I<v;I++)b.tabs[j].push(C(c,f+2*I))}else if(j=="tRNS")b.ctype==3?b.tabs[j]=y.readBytes(c,f,U):b.ctype==0?b.tabs[j]=C(c,f):b.ctype==2&&(b.tabs[j]=[C(c,f),C(c,f+2),C(c,f+4)]);else if(j=="gAMA")b.tabs[j]=y.readUint(c,f)/1e5;else if(j=="sRGB")b.tabs[j]=c[f];else if(j=="bKGD")b.ctype==0||b.ctype==4?b.tabs[j]=[C(c,f)]:b.ctype==2||b.ctype==6?b.tabs[j]=[C(c,f),C(c,f+2),C(c,f+4)]:b.ctype==3&&(b.tabs[j]=c[f]);else if(j=="IEND")break;f+=U,y.readUint(c,f),f+=4}var N;return S!=0&&((N=b.frames[b.frames.length-1]).data=a(b,g.slice(0,S),N.rect.width,N.rect.height)),b.data=a(b,w,b.width,b.height),delete b.compress,delete b.interlace,delete b.filter,b},toRGBA8:function(u){const c=u.width,f=u.height;if(u.tabs.acTL==null)return[r(u.data,c,f,u).buffer];const y=[];u.frames[0].data==null&&(u.frames[0].data=u.data);const C=c*f*4,k=new Uint8Array(C),b=new Uint8Array(C),w=new Uint8Array(C);for(let h=0;h<u.frames.length;h++){const S=u.frames[h],d=S.rect.x,I=S.rect.y,x=S.rect.width,A=S.rect.height,_=r(S.data,x,A,u);if(h!=0)for(var g=0;g<C;g++)w[g]=k[g];if(S.blend==0?p(_,x,A,k,c,f,d,I,0):S.blend==1&&p(_,x,A,k,c,f,d,I,1),y.push(k.buffer.slice(0)),S.dispose!=0){if(S.dispose==1)p(b,x,A,k,c,f,d,I,0);else if(S.dispose==2)for(g=0;g<C;g++)k[g]=w[g]}}return y},_paeth:l,_copyTile:p,_bin:e}}();(function(){const{_copyTile:e}=Se,{_bin:r}=Se,a=Se._paeth;var i={table:function(){const x=new Uint32Array(256);for(let A=0;A<256;A++){let _=A;for(let R=0;R<8;R++)1&_?_=3988292384^_>>>1:_>>>=1;x[A]=_}return x}(),update(x,A,_,R){for(let T=0;T<R;T++)x=i.table[255&(x^A[_+T])]^x>>>8;return x},crc:(x,A,_)=>4294967295^i.update(4294967295,x,A,_)};function t(x,A,_,R){A[_]+=x[0]*R>>4,A[_+1]+=x[1]*R>>4,A[_+2]+=x[2]*R>>4,A[_+3]+=x[3]*R>>4}function n(x){return Math.max(0,Math.min(255,x))}function s(x,A){const _=x[0]-A[0],R=x[1]-A[1],T=x[2]-A[2],M=x[3]-A[3];return _*_+R*R+T*T+M*M}function l(x,A,_,R,T,M,N){N==null&&(N=1);const U=R.length,j=[];for(var v=0;v<U;v++){const F=R[v];j.push([F>>>0&255,F>>>8&255,F>>>16&255,F>>>24&255])}for(v=0;v<U;v++){let F=4294967295;for(var P=0,L=0;L<U;L++){var $=s(j[v],j[L]);L!=v&&$<F&&(F=$,P=L)}}const q=new Uint32Array(T.buffer),D=new Int16Array(A*_*4),W=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];for(v=0;v<W.length;v++)W[v]=255*((W[v]+.5)/16-.5);for(let F=0;F<_;F++)for(let V=0;V<A;V++){var z;v=4*(F*A+V),N!=2?z=[n(x[v]+D[v]),n(x[v+1]+D[v+1]),n(x[v+2]+D[v+2]),n(x[v+3]+D[v+3])]:($=W[4*(3&F)+(3&V)],z=[n(x[v]+$),n(x[v+1]+$),n(x[v+2]+$),n(x[v+3]+$)]),P=0;let O=16777215;for(L=0;L<U;L++){const Z=s(z,j[L]);Z<O&&(O=Z,P=L)}const B=j[P],G=[z[0]-B[0],z[1]-B[1],z[2]-B[2],z[3]-B[3]];N==1&&(V!=A-1&&t(G,D,v+4,7),F!=_-1&&(V!=0&&t(G,D,v+4*A-4,3),t(G,D,v+4*A,5),V!=A-1&&t(G,D,v+4*A+4,1))),M[v>>2]=P,q[v>>2]=R[P]}}function m(x,A,_,R,T){T==null&&(T={});const{crc:M}=i,N=r.writeUint,U=r.writeUshort,j=r.writeASCII;let v=8;const P=x.frames.length>1;let L,$=!1,q=33+(P?20:0);if(T.sRGB!=null&&(q+=13),T.pHYs!=null&&(q+=21),T.iCCP!=null&&(L=pako.deflate(T.iCCP),q+=21+L.length+4),x.ctype==3){for(var D=x.plte.length,W=0;W<D;W++)x.plte[W]>>>24!=255&&($=!0);q+=8+3*D+4+($?8+1*D+4:0)}for(var z=0;z<x.frames.length;z++)P&&(q+=38),q+=(B=x.frames[z]).cimg.length+12,z!=0&&(q+=4);q+=12;const F=new Uint8Array(q),V=[137,80,78,71,13,10,26,10];for(W=0;W<8;W++)F[W]=V[W];if(N(F,v,13),v+=4,j(F,v,"IHDR"),v+=4,N(F,v,A),v+=4,N(F,v,_),v+=4,F[v]=x.depth,v++,F[v]=x.ctype,v++,F[v]=0,v++,F[v]=0,v++,F[v]=0,v++,N(F,v,M(F,v-17,17)),v+=4,T.sRGB!=null&&(N(F,v,1),v+=4,j(F,v,"sRGB"),v+=4,F[v]=T.sRGB,v++,N(F,v,M(F,v-5,5)),v+=4),T.iCCP!=null){const G=13+L.length;N(F,v,G),v+=4,j(F,v,"iCCP"),v+=4,j(F,v,"ICC profile"),v+=11,v+=2,F.set(L,v),v+=L.length,N(F,v,M(F,v-(G+4),G+4)),v+=4}if(T.pHYs!=null&&(N(F,v,9),v+=4,j(F,v,"pHYs"),v+=4,N(F,v,T.pHYs[0]),v+=4,N(F,v,T.pHYs[1]),v+=4,F[v]=T.pHYs[2],v++,N(F,v,M(F,v-13,13)),v+=4),P&&(N(F,v,8),v+=4,j(F,v,"acTL"),v+=4,N(F,v,x.frames.length),v+=4,N(F,v,T.loop!=null?T.loop:0),v+=4,N(F,v,M(F,v-12,12)),v+=4),x.ctype==3){for(N(F,v,3*(D=x.plte.length)),v+=4,j(F,v,"PLTE"),v+=4,W=0;W<D;W++){const G=3*W,Z=x.plte[W],Q=255&Z,X=Z>>>8&255,K=Z>>>16&255;F[v+G+0]=Q,F[v+G+1]=X,F[v+G+2]=K}if(v+=3*D,N(F,v,M(F,v-3*D-4,3*D+4)),v+=4,$){for(N(F,v,D),v+=4,j(F,v,"tRNS"),v+=4,W=0;W<D;W++)F[v+W]=x.plte[W]>>>24&255;v+=D,N(F,v,M(F,v-D-4,D+4)),v+=4}}let O=0;for(z=0;z<x.frames.length;z++){var B=x.frames[z];P&&(N(F,v,26),v+=4,j(F,v,"fcTL"),v+=4,N(F,v,O++),v+=4,N(F,v,B.rect.width),v+=4,N(F,v,B.rect.height),v+=4,N(F,v,B.rect.x),v+=4,N(F,v,B.rect.y),v+=4,U(F,v,R[z]),v+=2,U(F,v,1e3),v+=2,F[v]=B.dispose,v++,F[v]=B.blend,v++,N(F,v,M(F,v-30,30)),v+=4);const G=B.cimg;N(F,v,(D=G.length)+(z==0?0:4)),v+=4;const Z=v;j(F,v,z==0?"IDAT":"fdAT"),v+=4,z!=0&&(N(F,v,O++),v+=4),F.set(G,v),v+=D,N(F,v,M(F,Z,v-Z)),v+=4}return N(F,v,0),v+=4,j(F,v,"IEND"),v+=4,N(F,v,M(F,v-4,4)),v+=4,F.buffer}function p(x,A,_){for(let R=0;R<x.frames.length;R++){const T=x.frames[R];T.rect.width;const M=T.rect.height,N=new Uint8Array(M*T.bpl+M);T.cimg=f(T.img,M,T.bpp,T.bpl,N,A,_)}}function o(x,A,_,R,T){const M=T[0],N=T[1],U=T[2],j=T[3],v=T[4],P=T[5];let L=6,$=8,q=255;for(var D=0;D<x.length;D++){const ue=new Uint8Array(x[D]);for(var W=ue.length,z=0;z<W;z+=4)q&=ue[z+3]}const F=q!=255,V=function(re,ee,le,fe,ie,ye){const ae=[];for(var te=0;te<re.length;te++){const me=new Uint8Array(re[te]),Ae=new Uint32Array(me.buffer);var be;let Ee=0,ke=0,je=ee,Fe=le,gt=fe?1:0;if(te!=0){const Ur=ye||fe||te==1||ae[te-2].dispose!=0?1:2;let pt=0,Lt=1e9;for(let Ve=0;Ve<Ur;Ve++){var Ne=new Uint8Array(re[te-1-Ve]);const Ir=new Uint32Array(re[te-1-Ve]);let Te=ee,Re=le,Be=-1,Qe=-1;for(let Pe=0;Pe<le;Pe++)for(let $e=0;$e<ee;$e++)Ae[de=Pe*ee+$e]!=Ir[de]&&($e<Te&&(Te=$e),$e>Be&&(Be=$e),Pe<Re&&(Re=Pe),Pe>Qe&&(Qe=Pe));Be==-1&&(Te=Re=Be=Qe=0),ie&&((1&Te)==1&&Te--,(1&Re)==1&&Re--);const Ut=(Be-Te+1)*(Qe-Re+1);Ut<Lt&&(Lt=Ut,pt=Ve,Ee=Te,ke=Re,je=Be-Te+1,Fe=Qe-Re+1)}Ne=new Uint8Array(re[te-1-pt]),pt==1&&(ae[te-1].dispose=2),be=new Uint8Array(je*Fe*4),e(Ne,ee,le,be,je,Fe,-Ee,-ke,0),gt=e(me,ee,le,be,je,Fe,-Ee,-ke,3)?1:0,gt==1?c(me,ee,le,be,{x:Ee,y:ke,width:je,height:Fe}):e(me,ee,le,be,je,Fe,-Ee,-ke,0)}else be=me.slice(0);ae.push({rect:{x:Ee,y:ke,width:je,height:Fe},img:be,blend:gt,dispose:0})}if(fe)for(te=0;te<ae.length;te++){if((Ie=ae[te]).blend==1)continue;const me=Ie.rect,Ae=ae[te-1].rect,Ee=Math.min(me.x,Ae.x),ke=Math.min(me.y,Ae.y),je={x:Ee,y:ke,width:Math.max(me.x+me.width,Ae.x+Ae.width)-Ee,height:Math.max(me.y+me.height,Ae.y+Ae.height)-ke};ae[te-1].dispose=1,te-1!=0&&u(re,ee,le,ae,te-1,je,ie),u(re,ee,le,ae,te,je,ie)}let tt=0;if(re.length!=1)for(var de=0;de<ae.length;de++){var Ie;tt+=(Ie=ae[de]).rect.width*Ie.rect.height}return ae}(x,A,_,M,N,U),O={},B=[],G=[];if(R!=0){const ue=[];for(z=0;z<V.length;z++)ue.push(V[z].img.buffer);const re=function(ie){let ye=0;for(var ae=0;ae<ie.length;ae++)ye+=ie[ae].byteLength;const te=new Uint8Array(ye);let be=0;for(ae=0;ae<ie.length;ae++){const Ne=new Uint8Array(ie[ae]),tt=Ne.length;for(let de=0;de<tt;de+=4){let Ie=Ne[de],me=Ne[de+1],Ae=Ne[de+2];const Ee=Ne[de+3];Ee==0&&(Ie=me=Ae=0),te[be+de]=Ie,te[be+de+1]=me,te[be+de+2]=Ae,te[be+de+3]=Ee}be+=tt}return te.buffer}(ue),ee=C(re,R);for(z=0;z<ee.plte.length;z++)B.push(ee.plte[z].est.rgba);let le=0;for(z=0;z<V.length;z++){const fe=(Q=V[z]).img.length;var Z=new Uint8Array(ee.inds.buffer,le>>2,fe>>2);G.push(Z);const ie=new Uint8Array(ee.abuf,le,fe);P&&l(Q.img,Q.rect.width,Q.rect.height,B,ie,Z),Q.img.set(ie),le+=fe}}else for(D=0;D<V.length;D++){var Q=V[D];const ue=new Uint32Array(Q.img.buffer);var X=Q.rect.width;for(W=ue.length,Z=new Uint8Array(W),G.push(Z),z=0;z<W;z++){const re=ue[z];if(z!=0&&re==ue[z-1])Z[z]=Z[z-1];else if(z>X&&re==ue[z-X])Z[z]=Z[z-X];else{let ee=O[re];if(ee==null&&(O[re]=ee=B.length,B.push(re),B.length>=300))break;Z[z]=ee}}}const K=B.length;for(K<=256&&v==0&&($=K<=2?1:K<=4?2:K<=16?4:8,$=Math.max($,j)),D=0;D<V.length;D++){(Q=V[D]).rect.x,Q.rect.y,X=Q.rect.width;const ue=Q.rect.height;let re=Q.img;new Uint32Array(re.buffer);let ee=4*X,le=4;if(K<=256&&v==0){ee=Math.ceil($*X/8);var ce=new Uint8Array(ee*ue);const fe=G[D];for(let ie=0;ie<ue;ie++){z=ie*ee;const ye=ie*X;if($==8)for(var ne=0;ne<X;ne++)ce[z+ne]=fe[ye+ne];else if($==4)for(ne=0;ne<X;ne++)ce[z+(ne>>1)]|=fe[ye+ne]<<4-4*(1&ne);else if($==2)for(ne=0;ne<X;ne++)ce[z+(ne>>2)]|=fe[ye+ne]<<6-2*(3&ne);else if($==1)for(ne=0;ne<X;ne++)ce[z+(ne>>3)]|=fe[ye+ne]<<7-1*(7&ne)}re=ce,L=3,le=1}else if(F==0&&V.length==1){ce=new Uint8Array(X*ue*3);const fe=X*ue;for(z=0;z<fe;z++){const ie=3*z,ye=4*z;ce[ie]=re[ye],ce[ie+1]=re[ye+1],ce[ie+2]=re[ye+2]}re=ce,L=2,le=3,ee=3*X}Q.img=re,Q.bpl=ee,Q.bpp=le}return{ctype:L,depth:$,plte:B,frames:V}}function u(x,A,_,R,T,M,N){const U=Uint8Array,j=Uint32Array,v=new U(x[T-1]),P=new j(x[T-1]),L=T+1<x.length?new U(x[T+1]):null,$=new U(x[T]),q=new j($.buffer);let D=A,W=_,z=-1,F=-1;for(let O=0;O<M.height;O++)for(let B=0;B<M.width;B++){const G=M.x+B,Z=M.y+O,Q=Z*A+G,X=q[Q];X==0||R[T-1].dispose==0&&P[Q]==X&&(L==null||L[4*Q+3]!=0)||(G<D&&(D=G),G>z&&(z=G),Z<W&&(W=Z),Z>F&&(F=Z))}z==-1&&(D=W=z=F=0),N&&((1&D)==1&&D--,(1&W)==1&&W--),M={x:D,y:W,width:z-D+1,height:F-W+1};const V=R[T];V.rect=M,V.blend=1,V.img=new Uint8Array(M.width*M.height*4),R[T-1].dispose==0?(e(v,A,_,V.img,M.width,M.height,-M.x,-M.y,0),c($,A,_,V.img,M)):e($,A,_,V.img,M.width,M.height,-M.x,-M.y,0)}function c(x,A,_,R,T){e(x,A,_,R,T.width,T.height,-T.x,-T.y,2)}function f(x,A,_,R,T,M,N){const U=[];let j,v=[0,1,2,3,4];M!=-1?v=[M]:(A*R>5e5||_==1)&&(v=[0]),N&&(j={level:0});const P=tn;for(var L=0;L<v.length;L++){for(let D=0;D<A;D++)y(T,x,D,R,_,v[L]);U.push(P.deflate(T,j))}let $,q=1e9;for(L=0;L<U.length;L++)U[L].length<q&&($=L,q=U[L].length);return U[$]}function y(x,A,_,R,T,M){const N=_*R;let U=N+_;if(x[U]=M,U++,M==0)if(R<500)for(var j=0;j<R;j++)x[U+j]=A[N+j];else x.set(new Uint8Array(A.buffer,N,R),U);else if(M==1){for(j=0;j<T;j++)x[U+j]=A[N+j];for(j=T;j<R;j++)x[U+j]=A[N+j]-A[N+j-T]+256&255}else if(_==0){for(j=0;j<T;j++)x[U+j]=A[N+j];if(M==2)for(j=T;j<R;j++)x[U+j]=A[N+j];if(M==3)for(j=T;j<R;j++)x[U+j]=A[N+j]-(A[N+j-T]>>1)+256&255;if(M==4)for(j=T;j<R;j++)x[U+j]=A[N+j]-a(A[N+j-T],0,0)+256&255}else{if(M==2)for(j=0;j<R;j++)x[U+j]=A[N+j]+256-A[N+j-R]&255;if(M==3){for(j=0;j<T;j++)x[U+j]=A[N+j]+256-(A[N+j-R]>>1)&255;for(j=T;j<R;j++)x[U+j]=A[N+j]+256-(A[N+j-R]+A[N+j-T]>>1)&255}if(M==4){for(j=0;j<T;j++)x[U+j]=A[N+j]+256-a(0,A[N+j-R],0)&255;for(j=T;j<R;j++)x[U+j]=A[N+j]+256-a(A[N+j-T],A[N+j-R],A[N+j-T-R])&255}}}function C(x,A){const _=new Uint8Array(x),R=_.slice(0),T=new Uint32Array(R.buffer),M=k(R,A),N=M[0],U=M[1],j=_.length,v=new Uint8Array(j>>2);let P;if(_.length<2e7)for(var L=0;L<j;L+=4)P=b(N,$=_[L]*(1/255),q=_[L+1]*(1/255),D=_[L+2]*(1/255),W=_[L+3]*(1/255)),v[L>>2]=P.ind,T[L>>2]=P.est.rgba;else for(L=0;L<j;L+=4){var $=_[L]*.00392156862745098,q=_[L+1]*(1/255),D=_[L+2]*(1/255),W=_[L+3]*(1/255);for(P=N;P.left;)P=w(P.est,$,q,D,W)<=0?P.left:P.right;v[L>>2]=P.ind,T[L>>2]=P.est.rgba}return{abuf:R.buffer,inds:v,plte:U}}function k(x,A,_){_==null&&(_=1e-4);const R=new Uint32Array(x.buffer),T={i0:0,i1:x.length,bst:null,est:null,tdst:0,left:null,right:null};T.bst=S(x,T.i0,T.i1),T.est=d(T.bst);const M=[T];for(;M.length<A;){let U=0,j=0;for(var N=0;N<M.length;N++)M[N].est.L>U&&(U=M[N].est.L,j=N);if(U<_)break;const v=M[j],P=g(x,R,v.i0,v.i1,v.est.e,v.est.eMq255);if(v.i0>=P||v.i1<=P){v.est.L=0;continue}const L={i0:v.i0,i1:P,bst:null,est:null,tdst:0,left:null,right:null};L.bst=S(x,L.i0,L.i1),L.est=d(L.bst);const $={i0:P,i1:v.i1,bst:null,est:null,tdst:0,left:null,right:null};for($.bst={R:[],m:[],N:v.bst.N-L.bst.N},N=0;N<16;N++)$.bst.R[N]=v.bst.R[N]-L.bst.R[N];for(N=0;N<4;N++)$.bst.m[N]=v.bst.m[N]-L.bst.m[N];$.est=d($.bst),v.left=L,v.right=$,M[j]=L,M.push($)}for(M.sort((U,j)=>j.bst.N-U.bst.N),N=0;N<M.length;N++)M[N].ind=N;return[T,M]}function b(x,A,_,R,T){if(x.left==null)return x.tdst=function(L,$,q,D,W){const z=$-L[0],F=q-L[1],V=D-L[2],O=W-L[3];return z*z+F*F+V*V+O*O}(x.est.q,A,_,R,T),x;const M=w(x.est,A,_,R,T);let N=x.left,U=x.right;M>0&&(N=x.right,U=x.left);const j=b(N,A,_,R,T);if(j.tdst<=M*M)return j;const v=b(U,A,_,R,T);return v.tdst<j.tdst?v:j}function w(x,A,_,R,T){const{e:M}=x;return M[0]*A+M[1]*_+M[2]*R+M[3]*T-x.eMq}function g(x,A,_,R,T,M){for(R-=4;_<R;){for(;h(x,_,T)<=M;)_+=4;for(;h(x,R,T)>M;)R-=4;if(_>=R)break;const N=A[_>>2];A[_>>2]=A[R>>2],A[R>>2]=N,_+=4,R-=4}for(;h(x,_,T)>M;)_-=4;return _+4}function h(x,A,_){return x[A]*_[0]+x[A+1]*_[1]+x[A+2]*_[2]+x[A+3]*_[3]}function S(x,A,_){const R=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],T=[0,0,0,0],M=_-A>>2;for(let N=A;N<_;N+=4){const U=x[N]*.00392156862745098,j=x[N+1]*(1/255),v=x[N+2]*(1/255),P=x[N+3]*(1/255);T[0]+=U,T[1]+=j,T[2]+=v,T[3]+=P,R[0]+=U*U,R[1]+=U*j,R[2]+=U*v,R[3]+=U*P,R[5]+=j*j,R[6]+=j*v,R[7]+=j*P,R[10]+=v*v,R[11]+=v*P,R[15]+=P*P}return R[4]=R[1],R[8]=R[2],R[9]=R[6],R[12]=R[3],R[13]=R[7],R[14]=R[11],{R,m:T,N:M}}function d(x){const{R:A}=x,{m:_}=x,{N:R}=x,T=_[0],M=_[1],N=_[2],U=_[3],j=R==0?0:1/R,v=[A[0]-T*T*j,A[1]-T*M*j,A[2]-T*N*j,A[3]-T*U*j,A[4]-M*T*j,A[5]-M*M*j,A[6]-M*N*j,A[7]-M*U*j,A[8]-N*T*j,A[9]-N*M*j,A[10]-N*N*j,A[11]-N*U*j,A[12]-U*T*j,A[13]-U*M*j,A[14]-U*N*j,A[15]-U*U*j],P=v,L=I;let $=[Math.random(),Math.random(),Math.random(),Math.random()],q=0,D=0;if(R!=0)for(let z=0;z<16&&($=L.multVec(P,$),D=Math.sqrt(L.dot($,$)),$=L.sml(1/D,$),!(z!=0&&Math.abs(D-q)<1e-9));z++)q=D;const W=[T*j,M*j,N*j,U*j];return{Cov:v,q:W,e:$,L:q,eMq255:L.dot(L.sml(255,W),$),eMq:L.dot($,W),rgba:(Math.round(255*W[3])<<24|Math.round(255*W[2])<<16|Math.round(255*W[1])<<8|Math.round(255*W[0])<<0)>>>0}}var I={multVec:(x,A)=>[x[0]*A[0]+x[1]*A[1]+x[2]*A[2]+x[3]*A[3],x[4]*A[0]+x[5]*A[1]+x[6]*A[2]+x[7]*A[3],x[8]*A[0]+x[9]*A[1]+x[10]*A[2]+x[11]*A[3],x[12]*A[0]+x[13]*A[1]+x[14]*A[2]+x[15]*A[3]],dot:(x,A)=>x[0]*A[0]+x[1]*A[1]+x[2]*A[2]+x[3]*A[3],sml:(x,A)=>[x*A[0],x*A[1],x*A[2],x*A[3]]};Se.encode=function(A,_,R,T,M,N,U){T==null&&(T=0),U==null&&(U=!1);const j=o(A,_,R,T,[!1,!1,!1,0,U,!1]);return p(j,-1),m(j,_,R,M,N)},Se.encodeLL=function(A,_,R,T,M,N,U,j){const v={ctype:0+(T==1?0:2)+(M==0?0:4),depth:N,frames:[]},P=(T+M)*N,L=P*_;for(let $=0;$<A.length;$++)v.frames.push({rect:{x:0,y:0,width:_,height:R},img:new Uint8Array(A[$]),blend:0,dispose:1,bpp:Math.ceil(P/8),bpl:Math.ceil(L/8)});return p(v,0,!0),m(v,_,R,U,j)},Se.encode.compress=o,Se.encode.dither=l,Se.quantize=C,Se.quantize.getKDtree=k,Se.quantize.getNearest=b})();const ir={toArrayBuffer(e,r){const a=e.width,i=e.height,t=a<<2,n=e.getContext("2d").getImageData(0,0,a,i),s=new Uint32Array(n.data.buffer),l=(32*a+31)/32<<2,m=l*i,p=122+m,o=new ArrayBuffer(p),u=new DataView(o),c=1<<20;let f,y,C,k,b=c,w=0,g=0,h=0;function S(x){u.setUint16(g,x,!0),g+=2}function d(x){u.setUint32(g,x,!0),g+=4}function I(x){g+=x}S(19778),d(p),I(4),d(122),d(108),d(a),d(-i>>>0),S(1),S(32),d(3),d(m),d(2835),d(2835),I(8),d(16711680),d(65280),d(255),d(4278190080),d(1466527264),function x(){for(;w<i&&b>0;){for(k=122+w*l,f=0;f<t;)b--,y=s[h++],C=y>>>24,u.setUint32(k+f,y<<8|C),f+=4;w++}h<s.length?(b=c,setTimeout(x,ir._dly)):r(o)}()},toBlob(e,r){this.toArrayBuffer(e,a=>{r(new Blob([a],{type:"image/bmp"}))})},_dly:9};var ge={CHROME:"CHROME",FIREFOX:"FIREFOX",DESKTOP_SAFARI:"DESKTOP_SAFARI",IE:"IE",IOS:"IOS",ETC:"ETC"},rn={[ge.CHROME]:16384,[ge.FIREFOX]:11180,[ge.DESKTOP_SAFARI]:16384,[ge.IE]:8192,[ge.IOS]:4096,[ge.ETC]:8192};const kt=typeof window<"u",ar=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,lt=kt&&window.cordova&&window.cordova.require&&window.cordova.require("cordova/modulemapper"),nn=(kt||ar)&&(lt&&lt.getOriginalSymbol(window,"File")||typeof File<"u"&&File),sr=(kt||ar)&&(lt&&lt.getOriginalSymbol(window,"FileReader")||typeof FileReader<"u"&&FileReader);function _t(e,r,a=Date.now()){return new Promise(i=>{const t=e.split(","),n=t[0].match(/:(.*?);/)[1],s=globalThis.atob(t[1]);let l=s.length;const m=new Uint8Array(l);for(;l--;)m[l]=s.charCodeAt(l);const p=new Blob([m],{type:n});p.name=r,p.lastModified=a,i(p)})}function or(e){return new Promise((r,a)=>{const i=new sr;i.onload=()=>r(i.result),i.onerror=t=>a(t),i.readAsDataURL(e)})}function lr(e){return new Promise((r,a)=>{const i=new Image;i.onload=()=>r(i),i.onerror=t=>a(t),i.src=e})}function He(){if(He.cachedResult!==void 0)return He.cachedResult;let e=ge.ETC;const{userAgent:r}=navigator;return/Chrom(e|ium)/i.test(r)?e=ge.CHROME:/iP(ad|od|hone)/i.test(r)&&/WebKit/i.test(r)?e=ge.IOS:/Safari/i.test(r)?e=ge.DESKTOP_SAFARI:/Firefox/i.test(r)?e=ge.FIREFOX:(/MSIE/i.test(r)||document.documentMode)&&(e=ge.IE),He.cachedResult=e,He.cachedResult}function cr(e,r){const a=He(),i=rn[a];let t=e,n=r,s=t*n;const l=t>n?n/t:t/n;for(;s>i*i;){const m=(i+t)/2,p=(i+n)/2;m<p?(n=p,t=p*l):(n=m*l,t=m),s=t*n}return{width:t,height:n}}function ft(e,r){let a,i;try{if(a=new OffscreenCanvas(e,r),i=a.getContext("2d"),i===null)throw new Error("getContext of OffscreenCanvas returns null")}catch{a=document.createElement("canvas"),i=a.getContext("2d")}return a.width=e,a.height=r,[a,i]}function ur(e,r){const{width:a,height:i}=cr(e.width,e.height),[t,n]=ft(a,i);return r&&/jpe?g/.test(r)&&(n.fillStyle="white",n.fillRect(0,0,t.width,t.height)),n.drawImage(e,0,0,t.width,t.height),t}function it(){return it.cachedResult!==void 0||(it.cachedResult=["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&typeof document<"u"&&"ontouchend"in document),it.cachedResult}function ct(e,r={}){return new Promise(function(a,i){let t,n;var s=function(){try{return n=ur(t,r.fileType||e.type),a([t,n])}catch(m){return i(m)}},l=function(m){try{var p=function(o){try{throw o}catch(u){return i(u)}};try{let o;return or(e).then(function(u){try{return o=u,lr(o).then(function(c){try{return t=c,function(){try{return s()}catch(f){return i(f)}}()}catch(f){return p(f)}},p)}catch(c){return p(c)}},p)}catch(o){p(o)}}catch(o){return i(o)}};try{if(it()||[ge.DESKTOP_SAFARI,ge.MOBILE_SAFARI].includes(He()))throw new Error("Skip createImageBitmap on IOS and Safari");return createImageBitmap(e).then(function(m){try{return t=m,s()}catch{return l()}},l)}catch{l()}})}function ut(e,r,a,i,t=1){return new Promise(function(n,s){let l;if(r==="image/png"){let p,o,u;return p=e.getContext("2d"),{data:o}=p.getImageData(0,0,e.width,e.height),u=Se.encode([o.buffer],e.width,e.height,4096*t),l=new Blob([u],{type:r}),l.name=a,l.lastModified=i,m.call(this)}{let p=function(){return m.call(this)};if(r==="image/bmp")return new Promise(o=>ir.toBlob(e,o)).then((function(o){try{return l=o,l.name=a,l.lastModified=i,p.call(this)}catch(u){return s(u)}}).bind(this),s);{let o=function(){return p.call(this)};if(typeof OffscreenCanvas=="function"&&e instanceof OffscreenCanvas)return e.convertToBlob({type:r,quality:t}).then((function(u){try{return l=u,l.name=a,l.lastModified=i,o.call(this)}catch(c){return s(c)}}).bind(this),s);{let u;return u=e.toDataURL(r,t),_t(u,a,i).then((function(c){try{return l=c,o.call(this)}catch(f){return s(f)}}).bind(this),s)}}}function m(){return n(l)}})}function Ce(e){e.width=0,e.height=0}function Ge(){return new Promise(function(e,r){let a,i,t,n;return Ge.cachedResult!==void 0?e(Ge.cachedResult):_t("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/xABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAAAAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q==","test.jpg",Date.now()).then(function(s){try{return a=s,ct(a).then(function(l){try{return i=l[1],ut(i,a.type,a.name,a.lastModified).then(function(m){try{return t=m,Ce(i),ct(t).then(function(p){try{return n=p[0],Ge.cachedResult=n.width===1&&n.height===2,e(Ge.cachedResult)}catch(o){return r(o)}},r)}catch(p){return r(p)}},r)}catch(m){return r(m)}},r)}catch(l){return r(l)}},r)})}function dr(e){return new Promise((r,a)=>{const i=new sr;i.onload=t=>{const n=new DataView(t.target.result);if(n.getUint16(0,!1)!=65496)return r(-2);const s=n.byteLength;let l=2;for(;l<s;){if(n.getUint16(l+2,!1)<=8)return r(-1);const m=n.getUint16(l,!1);if(l+=2,m==65505){if(n.getUint32(l+=2,!1)!=1165519206)return r(-1);const p=n.getUint16(l+=6,!1)==18761;l+=n.getUint32(l+4,p);const o=n.getUint16(l,p);l+=2;for(let u=0;u<o;u++)if(n.getUint16(l+12*u,p)==274)return r(n.getUint16(l+12*u+8,p))}else{if((65280&m)!=65280)break;l+=n.getUint16(l,!1)}}return r(-1)},i.onerror=t=>a(t),i.readAsArrayBuffer(e)})}function hr(e,r){const{width:a}=e,{height:i}=e,{maxWidthOrHeight:t}=r;let n,s=e;return isFinite(t)&&(a>t||i>t)&&([s,n]=ft(a,i),a>i?(s.width=t,s.height=i/a*t):(s.width=a/i*t,s.height=t),n.drawImage(e,0,0,s.width,s.height),Ce(e)),s}function fr(e,r){const{width:a}=e,{height:i}=e,[t,n]=ft(a,i);switch(r>4&&r<9?(t.width=i,t.height=a):(t.width=a,t.height=i),r){case 2:n.transform(-1,0,0,1,a,0);break;case 3:n.transform(-1,0,0,-1,a,i);break;case 4:n.transform(1,0,0,-1,0,i);break;case 5:n.transform(0,1,1,0,0,0);break;case 6:n.transform(0,1,-1,0,i,0);break;case 7:n.transform(0,-1,-1,0,i,a);break;case 8:n.transform(0,-1,1,0,0,a)}return n.drawImage(e,0,0,a,i),Ce(e),t}function Pt(e,r,a=0){return new Promise(function(i,t){let n,s,l,m,p,o,u,c,f,y,C,k,b,w,g,h,S,d,I,x;function A(R=5){if(r.signal&&r.signal.aborted)throw r.signal.reason;n+=R,r.onProgress(Math.min(n,100))}function _(R){if(r.signal&&r.signal.aborted)throw r.signal.reason;n=Math.min(Math.max(R,n),100),r.onProgress(n)}return n=a,s=r.maxIteration||10,l=1024*r.maxSizeMB*1024,A(),ct(e,r).then((function(R){try{return[,m]=R,A(),p=hr(m,r),A(),new Promise(function(T,M){var N;if(!(N=r.exifOrientation))return dr(e).then((function(j){try{return N=j,U.call(this)}catch(v){return M(v)}}).bind(this),M);function U(){return T(N)}return U.call(this)}).then((function(T){try{return o=T,A(),Ge().then((function(M){try{return u=M?p:fr(p,o),A(),c=r.initialQuality||1,f=r.fileType||e.type,ut(u,f,e.name,e.lastModified,c).then((function(N){try{{let j=function(){if(s--&&(g>l||g>b)){let P,L;return P=x?.95*I.width:I.width,L=x?.95*I.height:I.height,[S,d]=ft(P,L),d.drawImage(I,0,0,P,L),c*=f==="image/png"?.85:.95,ut(S,f,e.name,e.lastModified,c).then(function($){try{return h=$,Ce(I),I=S,g=h.size,_(Math.min(99,Math.floor((w-g)/(w-l)*100))),j}catch(q){return t(q)}},t)}return[1]},v=function(){return Ce(I),Ce(S),Ce(p),Ce(u),Ce(m),_(100),i(h)};if(y=N,A(),C=y.size>l,k=y.size>e.size,!C&&!k)return _(100),i(y);var U;return b=e.size,w=y.size,g=w,I=u,x=!r.alwaysKeepResolution&&C,(U=(function(P){for(;P;){if(P.then)return void P.then(U,t);try{if(P.pop){if(P.length)return P.pop()?v.call(this):P;P=j}else P=P.call(this)}catch(L){return t(L)}}}).bind(this))(j)}}catch(j){return t(j)}}).bind(this),t)}catch(N){return t(N)}}).bind(this),t)}catch(M){return t(M)}}).bind(this),t)}catch(T){return t(T)}}).bind(this),t)})}const an=`
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 wt;function sn(e,r){return new Promise((a,i)=>{wt||(wt=function(s){const l=[];return l.push(s),URL.createObjectURL(new Blob(l))}(an));const t=new Worker(wt);t.addEventListener("message",function(s){if(r.signal&&r.signal.aborted)t.terminate();else if(s.data.progress===void 0){if(s.data.error)return i(new Error(s.data.error)),void t.terminate();a(s.data.file),t.terminate()}else r.onProgress(s.data.progress)}),t.addEventListener("error",i),r.signal&&r.signal.addEventListener("abort",()=>{i(r.signal.reason),t.terminate()}),t.postMessage({file:e,imageCompressionLibUrl:r.libURL,options:{...r,onProgress:void 0,signal:void 0}})})}function he(e,r){return new Promise(function(a,i){let t,n,s,l,m,p;if(t={...r},s=0,{onProgress:l}=t,t.maxSizeMB=t.maxSizeMB||Number.POSITIVE_INFINITY,m=typeof t.useWebWorker!="boolean"||t.useWebWorker,delete t.useWebWorker,t.onProgress=f=>{s=f,typeof l=="function"&&l(s)},!(e instanceof Blob||e instanceof nn))return i(new Error("The file given is not an instance of Blob or File"));if(!/^image/.test(e.type))return i(new Error("The file given is not an image"));if(p=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,!m||typeof Worker!="function"||p)return Pt(e,t).then((function(f){try{return n=f,c.call(this)}catch(y){return i(y)}}).bind(this),i);var o=(function(){try{return c.call(this)}catch(f){return i(f)}}).bind(this),u=function(f){try{return Pt(e,t).then(function(y){try{return n=y,o()}catch(C){return i(C)}},i)}catch(y){return i(y)}};try{return t.libURL=t.libURL||"https://cdn.jsdelivr.net/npm/browser-image-compression@2.0.2/dist/browser-image-compression.js",sn(e,t).then(function(f){try{return n=f,o()}catch{return u()}},u)}catch{u()}function c(){try{n.name=e.name,n.lastModified=e.lastModified}catch{}try{t.preserveExif&&e.type==="image/jpeg"&&(!t.fileType||t.fileType&&t.fileType===e.type)&&(n=nr(e,n))}catch{}return a(n)}})}he.getDataUrlFromFile=or,he.getFilefromDataUrl=_t,he.loadImage=lr,he.drawImageInCanvas=ur,he.drawFileInCanvas=ct,he.canvasToFile=ut,he.getExifOrientation=dr,he.handleMaxWidthOrHeight=hr,he.followExifOrientation=fr,he.cleanupCanvasMemory=Ce,he.isAutoOrientationInBrowser=Ge,he.approximateBelowMaximumCanvasSizeOfBrowser=cr,he.copyExifWithoutOrientation=nr,he.getBrowserName=He,he.version="2.0.2";var mr={exports:{}};(function(e,r){(function(a){e.exports=a()})(function(a){var i=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function t(b,w){var g=b[0],h=b[1],S=b[2],d=b[3];g+=(h&S|~h&d)+w[0]-680876936|0,g=(g<<7|g>>>25)+h|0,d+=(g&h|~g&S)+w[1]-389564586|0,d=(d<<12|d>>>20)+g|0,S+=(d&g|~d&h)+w[2]+606105819|0,S=(S<<17|S>>>15)+d|0,h+=(S&d|~S&g)+w[3]-1044525330|0,h=(h<<22|h>>>10)+S|0,g+=(h&S|~h&d)+w[4]-176418897|0,g=(g<<7|g>>>25)+h|0,d+=(g&h|~g&S)+w[5]+1200080426|0,d=(d<<12|d>>>20)+g|0,S+=(d&g|~d&h)+w[6]-1473231341|0,S=(S<<17|S>>>15)+d|0,h+=(S&d|~S&g)+w[7]-45705983|0,h=(h<<22|h>>>10)+S|0,g+=(h&S|~h&d)+w[8]+1770035416|0,g=(g<<7|g>>>25)+h|0,d+=(g&h|~g&S)+w[9]-1958414417|0,d=(d<<12|d>>>20)+g|0,S+=(d&g|~d&h)+w[10]-42063|0,S=(S<<17|S>>>15)+d|0,h+=(S&d|~S&g)+w[11]-1990404162|0,h=(h<<22|h>>>10)+S|0,g+=(h&S|~h&d)+w[12]+1804603682|0,g=(g<<7|g>>>25)+h|0,d+=(g&h|~g&S)+w[13]-40341101|0,d=(d<<12|d>>>20)+g|0,S+=(d&g|~d&h)+w[14]-1502002290|0,S=(S<<17|S>>>15)+d|0,h+=(S&d|~S&g)+w[15]+1236535329|0,h=(h<<22|h>>>10)+S|0,g+=(h&d|S&~d)+w[1]-165796510|0,g=(g<<5|g>>>27)+h|0,d+=(g&S|h&~S)+w[6]-1069501632|0,d=(d<<9|d>>>23)+g|0,S+=(d&h|g&~h)+w[11]+643717713|0,S=(S<<14|S>>>18)+d|0,h+=(S&g|d&~g)+w[0]-373897302|0,h=(h<<20|h>>>12)+S|0,g+=(h&d|S&~d)+w[5]-701558691|0,g=(g<<5|g>>>27)+h|0,d+=(g&S|h&~S)+w[10]+38016083|0,d=(d<<9|d>>>23)+g|0,S+=(d&h|g&~h)+w[15]-660478335|0,S=(S<<14|S>>>18)+d|0,h+=(S&g|d&~g)+w[4]-405537848|0,h=(h<<20|h>>>12)+S|0,g+=(h&d|S&~d)+w[9]+568446438|0,g=(g<<5|g>>>27)+h|0,d+=(g&S|h&~S)+w[14]-1019803690|0,d=(d<<9|d>>>23)+g|0,S+=(d&h|g&~h)+w[3]-187363961|0,S=(S<<14|S>>>18)+d|0,h+=(S&g|d&~g)+w[8]+1163531501|0,h=(h<<20|h>>>12)+S|0,g+=(h&d|S&~d)+w[13]-1444681467|0,g=(g<<5|g>>>27)+h|0,d+=(g&S|h&~S)+w[2]-51403784|0,d=(d<<9|d>>>23)+g|0,S+=(d&h|g&~h)+w[7]+1735328473|0,S=(S<<14|S>>>18)+d|0,h+=(S&g|d&~g)+w[12]-1926607734|0,h=(h<<20|h>>>12)+S|0,g+=(h^S^d)+w[5]-378558|0,g=(g<<4|g>>>28)+h|0,d+=(g^h^S)+w[8]-2022574463|0,d=(d<<11|d>>>21)+g|0,S+=(d^g^h)+w[11]+1839030562|0,S=(S<<16|S>>>16)+d|0,h+=(S^d^g)+w[14]-35309556|0,h=(h<<23|h>>>9)+S|0,g+=(h^S^d)+w[1]-1530992060|0,g=(g<<4|g>>>28)+h|0,d+=(g^h^S)+w[4]+1272893353|0,d=(d<<11|d>>>21)+g|0,S+=(d^g^h)+w[7]-155497632|0,S=(S<<16|S>>>16)+d|0,h+=(S^d^g)+w[10]-1094730640|0,h=(h<<23|h>>>9)+S|0,g+=(h^S^d)+w[13]+681279174|0,g=(g<<4|g>>>28)+h|0,d+=(g^h^S)+w[0]-358537222|0,d=(d<<11|d>>>21)+g|0,S+=(d^g^h)+w[3]-722521979|0,S=(S<<16|S>>>16)+d|0,h+=(S^d^g)+w[6]+76029189|0,h=(h<<23|h>>>9)+S|0,g+=(h^S^d)+w[9]-640364487|0,g=(g<<4|g>>>28)+h|0,d+=(g^h^S)+w[12]-421815835|0,d=(d<<11|d>>>21)+g|0,S+=(d^g^h)+w[15]+530742520|0,S=(S<<16|S>>>16)+d|0,h+=(S^d^g)+w[2]-995338651|0,h=(h<<23|h>>>9)+S|0,g+=(S^(h|~d))+w[0]-198630844|0,g=(g<<6|g>>>26)+h|0,d+=(h^(g|~S))+w[7]+1126891415|0,d=(d<<10|d>>>22)+g|0,S+=(g^(d|~h))+w[14]-1416354905|0,S=(S<<15|S>>>17)+d|0,h+=(d^(S|~g))+w[5]-57434055|0,h=(h<<21|h>>>11)+S|0,g+=(S^(h|~d))+w[12]+1700485571|0,g=(g<<6|g>>>26)+h|0,d+=(h^(g|~S))+w[3]-1894986606|0,d=(d<<10|d>>>22)+g|0,S+=(g^(d|~h))+w[10]-1051523|0,S=(S<<15|S>>>17)+d|0,h+=(d^(S|~g))+w[1]-2054922799|0,h=(h<<21|h>>>11)+S|0,g+=(S^(h|~d))+w[8]+1873313359|0,g=(g<<6|g>>>26)+h|0,d+=(h^(g|~S))+w[15]-30611744|0,d=(d<<10|d>>>22)+g|0,S+=(g^(d|~h))+w[6]-1560198380|0,S=(S<<15|S>>>17)+d|0,h+=(d^(S|~g))+w[13]+1309151649|0,h=(h<<21|h>>>11)+S|0,g+=(S^(h|~d))+w[4]-145523070|0,g=(g<<6|g>>>26)+h|0,d+=(h^(g|~S))+w[11]-1120210379|0,d=(d<<10|d>>>22)+g|0,S+=(g^(d|~h))+w[2]+718787259|0,S=(S<<15|S>>>17)+d|0,h+=(d^(S|~g))+w[9]-343485551|0,h=(h<<21|h>>>11)+S|0,b[0]=g+b[0]|0,b[1]=h+b[1]|0,b[2]=S+b[2]|0,b[3]=d+b[3]|0}function n(b){var w=[],g;for(g=0;g<64;g+=4)w[g>>2]=b.charCodeAt(g)+(b.charCodeAt(g+1)<<8)+(b.charCodeAt(g+2)<<16)+(b.charCodeAt(g+3)<<24);return w}function s(b){var w=[],g;for(g=0;g<64;g+=4)w[g>>2]=b[g]+(b[g+1]<<8)+(b[g+2]<<16)+(b[g+3]<<24);return w}function l(b){var w=b.length,g=[1732584193,-271733879,-1732584194,271733878],h,S,d,I,x,A;for(h=64;h<=w;h+=64)t(g,n(b.substring(h-64,h)));for(b=b.substring(h-64),S=b.length,d=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],h=0;h<S;h+=1)d[h>>2]|=b.charCodeAt(h)<<(h%4<<3);if(d[h>>2]|=128<<(h%4<<3),h>55)for(t(g,d),h=0;h<16;h+=1)d[h]=0;return I=w*8,I=I.toString(16).match(/(.*?)(.{0,8})$/),x=parseInt(I[2],16),A=parseInt(I[1],16)||0,d[14]=x,d[15]=A,t(g,d),g}function m(b){var w=b.length,g=[1732584193,-271733879,-1732584194,271733878],h,S,d,I,x,A;for(h=64;h<=w;h+=64)t(g,s(b.subarray(h-64,h)));for(b=h-64<w?b.subarray(h-64):new Uint8Array(0),S=b.length,d=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],h=0;h<S;h+=1)d[h>>2]|=b[h]<<(h%4<<3);if(d[h>>2]|=128<<(h%4<<3),h>55)for(t(g,d),h=0;h<16;h+=1)d[h]=0;return I=w*8,I=I.toString(16).match(/(.*?)(.{0,8})$/),x=parseInt(I[2],16),A=parseInt(I[1],16)||0,d[14]=x,d[15]=A,t(g,d),g}function p(b){var w="",g;for(g=0;g<4;g+=1)w+=i[b>>g*8+4&15]+i[b>>g*8&15];return w}function o(b){var w;for(w=0;w<b.length;w+=1)b[w]=p(b[w]);return b.join("")}o(l("hello")),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&function(){function b(w,g){return w=w|0||0,w<0?Math.max(w+g,0):Math.min(w,g)}ArrayBuffer.prototype.slice=function(w,g){var h=this.byteLength,S=b(w,h),d=h,I,x,A,_;return g!==a&&(d=b(g,h)),S>d?new ArrayBuffer(0):(I=d-S,x=new ArrayBuffer(I),A=new Uint8Array(x),_=new Uint8Array(this,S,I),A.set(_),x)}}();function u(b){return/[\u0080-\uFFFF]/.test(b)&&(b=unescape(encodeURIComponent(b))),b}function c(b,w){var g=b.length,h=new ArrayBuffer(g),S=new Uint8Array(h),d;for(d=0;d<g;d+=1)S[d]=b.charCodeAt(d);return w?S:h}function f(b){return String.fromCharCode.apply(null,new Uint8Array(b))}function y(b,w,g){var h=new Uint8Array(b.byteLength+w.byteLength);return h.set(new Uint8Array(b)),h.set(new Uint8Array(w),b.byteLength),h}function C(b){var w=[],g=b.length,h;for(h=0;h<g-1;h+=2)w.push(parseInt(b.substr(h,2),16));return String.fromCharCode.apply(String,w)}function k(){this.reset()}return k.prototype.append=function(b){return this.appendBinary(u(b)),this},k.prototype.appendBinary=function(b){this._buff+=b,this._length+=b.length;var w=this._buff.length,g;for(g=64;g<=w;g+=64)t(this._hash,n(this._buff.substring(g-64,g)));return this._buff=this._buff.substring(g-64),this},k.prototype.end=function(b){var w=this._buff,g=w.length,h,S=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],d;for(h=0;h<g;h+=1)S[h>>2]|=w.charCodeAt(h)<<(h%4<<3);return this._finish(S,g),d=o(this._hash),b&&(d=C(d)),this.reset(),d},k.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},k.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},k.prototype.setState=function(b){return this._buff=b.buff,this._length=b.length,this._hash=b.hash,this},k.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},k.prototype._finish=function(b,w){var g=w,h,S,d;if(b[g>>2]|=128<<(g%4<<3),g>55)for(t(this._hash,b),g=0;g<16;g+=1)b[g]=0;h=this._length*8,h=h.toString(16).match(/(.*?)(.{0,8})$/),S=parseInt(h[2],16),d=parseInt(h[1],16)||0,b[14]=S,b[15]=d,t(this._hash,b)},k.hash=function(b,w){return k.hashBinary(u(b),w)},k.hashBinary=function(b,w){var g=l(b),h=o(g);return w?C(h):h},k.ArrayBuffer=function(){this.reset()},k.ArrayBuffer.prototype.append=function(b){var w=y(this._buff.buffer,b),g=w.length,h;for(this._length+=b.byteLength,h=64;h<=g;h+=64)t(this._hash,s(w.subarray(h-64,h)));return this._buff=h-64<g?new Uint8Array(w.buffer.slice(h-64)):new Uint8Array(0),this},k.ArrayBuffer.prototype.end=function(b){var w=this._buff,g=w.length,h=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],S,d;for(S=0;S<g;S+=1)h[S>>2]|=w[S]<<(S%4<<3);return this._finish(h,g),d=o(this._hash),b&&(d=C(d)),this.reset(),d},k.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},k.ArrayBuffer.prototype.getState=function(){var b=k.prototype.getState.call(this);return b.buff=f(b.buff),b},k.ArrayBuffer.prototype.setState=function(b){return b.buff=c(b.buff,!0),k.prototype.setState.call(this,b)},k.ArrayBuffer.prototype.destroy=k.prototype.destroy,k.ArrayBuffer.prototype._finish=k.prototype._finish,k.ArrayBuffer.hash=function(b,w){var g=m(new Uint8Array(b)),h=o(g);return w?C(h):h},k})})(mr);var on=mr.exports;const ln=Hr(on),ze={async uploadFile(e){var t,n;if(!this.validateFile(e))throw new Error("不支持的文件类型或文件大小超过限制");const r=await this.calculateMD5(e);let a=e;if(e.type.startsWith("image/"))try{a=await this.compressImage(e)}catch(s){console.warn("图片压缩失败,尝试使用原文件上传",s)}const i=await this.getOssSignature({file_hash:r,file_name:a.name});if(!((t=i.data)!=null&&t.repeat)&&((n=i.data)!=null&&n.sign_url)&&await this.uploadToOss(i.data.sign_url,a),!i.data)throw new Error("获取上传签名失败");return i.data},async createRecognitionTask(e,r,a){const i={file_url:e,file_hash:r,file_name:a,task_type:"FORMULA"};return De.post("/formula/recognition",i).then(t=>{if(!t.data)throw new Error("创建任务失败: 无返回数据");return t.data})},async getTaskResult(e){return De.get(`/formula/recognition/${e}`).then(r=>{if(!r.data)throw new Error("获取结果失败: 无返回数据");return r.data})},async getTaskList(e="FORMULA",r=1,a=5){return De.get(`/task/list?task_type=${e}&page=${r}&page_size=${a}`).then(i=>{if(!i.data)throw new Error("获取历史记录失败: 无返回数据");return i.data})},validateFile(e){const r=["image/jpeg","image/png","image/jpg"];return!(!e.type.startsWith("image/")&&r.indexOf(e.type)===-1&&!e.name.match(/\.(jpg|jpeg|png)$/i))},async compressImage(e){const r={maxSizeMB:5,maxWidthOrHeight:1920,useWebWorker:!0,initialQuality:.8};try{return await he(e,r)}catch(a){throw console.error("Image compression error:",a),a}},calculateMD5(e){return new Promise((r,a)=>{const i=File.prototype.slice||File.prototype.mozSlice||File.prototype.webkitSlice,t=2097152,n=Math.ceil(e.size/t);let s=0;const l=new ln.ArrayBuffer,m=new FileReader;m.onload=function(o){var u;(u=o.target)!=null&&u.result&&l.append(o.target.result),s++,s<n?p():r(l.end())},m.onerror=function(){a("File read failed")};function p(){const o=s*t,u=o+t>=e.size?e.size:o+t;m.readAsArrayBuffer(i.call(e,o,u))}p()})},async getOssSignature(e){return De.post("/oss/signature_url",e)},async uploadToOss(e,r){try{await fetch(e,{method:"PUT",body:r,headers:{"Content-Type":r.type||"application/octet-stream"}})}catch(a){throw console.error("Upload to OSS failed:",a),new Error("文件上传失败")}}};/**
* @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 cn={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 un=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),Y=(e,r)=>{const a=H.forwardRef(({color:i="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:l="",children:m,...p},o)=>H.createElement("svg",{ref:o,...cn,width:t,height:t,stroke:i,strokeWidth:s?Number(n)*24/Number(t):n,className:["lucide",`lucide-${un(e)}`,l].join(" "),...p},[...r.map(([u,c])=>H.createElement(u,c)),...Array.isArray(m)?m:[m]]));return a.displayName=`${e}`,a};/**
* @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 at=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 $t=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 Nt=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 Tt=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 gr=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 dn=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 pr=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 hn=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 yr=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 st=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 br=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 zt=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 fn=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 mn=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 gn=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 pn=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 yn=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 xr=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 Ot=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 bn=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 xn=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 wn=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 vn=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 wr=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 En=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 At=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 An=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 Ze=Y("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Sn({onClose:e}){const{signIn:r,signUp:a}=Ct(),{t:i}=_e(),[t,n]=H.useState(!1),[s,l]=H.useState(""),[m,p]=H.useState(""),[o,u]=H.useState(!1),[c,f]=H.useState(""),y=async C=>{C.preventDefault(),f(""),u(!0);try{const{error:k}=t?await a(s,m):await r(s,m);k?f(k.message):e()}catch{f("发生错误,请重试")}finally{u(!1)}};return E.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:E.jsxs("div",{className:"bg-white rounded-xl shadow-xl max-w-md w-full p-6",children:[E.jsxs("div",{className:"flex justify-between items-center mb-6",children:[E.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:t?i.auth.signUpTitle:i.auth.signInTitle}),E.jsx("button",{onClick:e,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:E.jsx(Ze,{size:20})})]}),E.jsxs("form",{onSubmit:y,className:"space-y-4",children:[E.jsxs("div",{children:[E.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:i.auth.email}),E.jsx("input",{type:"email",value:s,onChange:C=>l(C.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})]}),E.jsxs("div",{children:[E.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:i.auth.password}),E.jsx("input",{type:"password",value:m,onChange:C=>p(C.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})]}),c&&E.jsxs("div",{className:"p-3 bg-red-100 border border-red-400 text-red-700 rounded-lg text-sm font-medium animate-pulse",children:[i.auth.error,": ",c]}),E.jsx("button",{type:"submit",disabled:o,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:t?i.auth.signUp:i.auth.signIn})]}),E.jsx("div",{className:"mt-4 text-center",children:E.jsx("button",{onClick:()=>n(!t),className:"text-sm text-blue-600 hover:text-blue-700",children:t?i.auth.hasAccount:i.auth.noAccount})})]})})}function jn({files:e,selectedFileId:r,onFileSelect:a,onUploadClick:i,isCollapsed:t,onToggleCollapse:n,onUploadFiles:s,hasMore:l,loadingMore:m,onLoadMore:p}){const{user:o,signOut:u}=Ct(),{t:c}=_e(),[f,y]=H.useState(!1),[C,k]=H.useState(!1),b=H.useRef(null),w=H.useRef(null),g=H.useCallback(()=>{if(!w.current||m||!l)return;const{scrollTop:x,scrollHeight:A,clientHeight:_}=w.current;A-x-_<50&&p()},[m,l,p]);H.useEffect(()=>{if(!l||m||!o||e.length===0)return;const A=setTimeout(()=>{requestAnimationFrame(()=>{if(!w.current)return;const{scrollHeight:_,clientHeight:R}=w.current;_<=R&&l&&!m&&p()})},100);return()=>clearTimeout(A)},[e.length,l,m,p,o]);const h=x=>{x.preventDefault(),k(!0)},S=x=>{x.preventDefault(),k(!1)},d=x=>{x.preventDefault(),k(!1);const _=Array.from(x.dataTransfer.files).filter(R=>R.type.startsWith("image/")||R.type==="application/pdf");_.length>0&&s(_)},I=x=>{x.target.files&&x.target.files.length>0&&s(Array.from(x.target.files)),b.current&&(b.current.value="")};return t?E.jsxs("div",{className:"h-full flex flex-col items-center py-4 bg-gray-50/50",children:[E.jsx("button",{onClick:n,className:"p-2 mb-6 text-gray-500 hover:text-gray-900 hover:bg-gray-200 rounded-md transition-colors",children:E.jsx(Tt,{size:20})}),E.jsx("button",{onClick:i,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:c.common.upload,children:E.jsx(At,{size:20})}),E.jsx("div",{className:"flex-1 w-full flex flex-col items-center gap-4",children:E.jsx("button",{className:"p-2 text-gray-400 hover:text-gray-900 transition-colors",title:c.common.history,children:E.jsx(gn,{size:20})})}),E.jsx("button",{onClick:()=>!o&&y(!0),className:"p-3 rounded-lg text-gray-600 hover:bg-gray-200 transition-colors mt-auto",title:o?"Signed In":c.common.login,children:E.jsx(Ot,{size:20})})]}):E.jsxs(E.Fragment,{children:[E.jsxs("div",{className:"flex flex-col h-full bg-white",children:[E.jsxs("div",{className:"p-6 pb-4",children:[E.jsxs("div",{className:"flex items-start justify-between mb-6",children:[E.jsxs("div",{children:[E.jsx("h2",{className:"text-lg font-bold text-gray-900 leading-tight",children:c.sidebar.title}),E.jsx("p",{className:"text-xs text-gray-500 mt-1",children:c.sidebar.subtitle})]}),E.jsx("button",{onClick:n,className:"p-1.5 -mr-1.5 text-gray-400 hover:text-gray-900 hover:bg-gray-100 rounded-md transition-colors",children:E.jsx(Nt,{size:18})})]}),E.jsx("div",{className:"mb-2",id:"sidebar-upload-area",children:E.jsxs("div",{onDragOver:h,onDragLeave:S,onDrop:d,onClick:()=>{var x;return(x=b.current)==null?void 0:x.click()},className:`
border-2 border-dashed rounded-xl p-6 text-center cursor-pointer transition-all duration-200 group
${C?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-blue-400 hover:bg-gray-50"}
`,children:[E.jsx("input",{type:"file",ref:b,className:"hidden",onChange:I,accept:"image/*",multiple:!0}),E.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:E.jsx(At,{size:24})}),E.jsx("p",{className:"text-xs text-gray-500 mb-2",children:c.sidebar.uploadInstruction}),E.jsxs("div",{className:"flex items-center justify-center gap-4 text-xs text-gray-400",children:[E.jsxs("div",{className:"flex items-center gap-1",children:[E.jsx(wr,{className:"w-3.5 h-3.5"}),E.jsx("span",{children:c.common.click})]}),E.jsxs("div",{className:"flex items-center gap-1",children:[E.jsx(br,{className:"w-3.5 h-3.5"}),E.jsx("span",{children:c.common.drop})]}),E.jsxs("div",{className:"flex items-center gap-1",children:[E.jsx(gr,{className:"w-3.5 h-3.5"}),E.jsx("span",{children:c.common.paste})]})]})]})})]}),E.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col px-4",id:"sidebar-history",children:[E.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-gray-500 uppercase tracking-wider mb-3 px-2",children:[E.jsx(dn,{size:14}),E.jsx("span",{children:c.sidebar.historyHeader})]}),E.jsx("div",{ref:w,onScroll:g,className:"flex-1 overflow-y-auto space-y-1 pr-2 -mr-2 custom-scrollbar",children:o?e.length===0?E.jsxs("div",{className:"text-center py-12 text-gray-400 text-sm",children:[E.jsx("div",{className:"mb-2 opacity-50",children:E.jsx(st,{size:40,className:"mx-auto"})}),c.sidebar.noHistory]}):E.jsxs(E.Fragment,{children:[e.map(x=>E.jsx("button",{onClick:()=>a(x.id),className:`w-full p-3 rounded-lg text-left transition-all border group relative ${r===x.id?"bg-blue-50 border-blue-200 shadow-sm":"bg-white border-transparent hover:bg-gray-50 hover:border-gray-100"}`,children:E.jsxs("div",{className:"flex items-start gap-3",children:[E.jsx("div",{className:`p-2 rounded-lg ${r===x.id?"bg-blue-100 text-blue-600":"bg-gray-100 text-gray-500 group-hover:bg-gray-200"}`,children:E.jsx(st,{size:18})}),E.jsxs("div",{className:"flex-1 min-w-0",children:[E.jsx("p",{className:`text-sm font-medium truncate ${r===x.id?"text-blue-900":"text-gray-700"}`,children:x.filename}),E.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[E.jsx("span",{className:"text-xs text-gray-400",children:new Date(x.created_at).toLocaleDateString()}),E.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${x.status==="completed"?"bg-green-500":x.status==="processing"?"bg-yellow-500":"bg-red-500"}`})]})]})]})},x.id)),m&&E.jsxs("div",{className:"flex items-center justify-center py-3 text-gray-400",children:[E.jsx(xr,{size:18,className:"animate-spin"}),E.jsx("span",{className:"ml-2 text-xs",children:c.common.loading})]}),!l&&e.length>0&&E.jsx("div",{className:"text-center py-3 text-xs text-gray-400",children:c.sidebar.noMore})]}):E.jsxs("div",{className:"text-center py-12 text-gray-400 text-sm",children:[E.jsx("div",{className:"mb-2 opacity-50",children:E.jsx(st,{size:40,className:"mx-auto"})}),c.sidebar.pleaseLogin]})})]}),E.jsx("div",{className:"p-4 border-t border-gray-100 bg-gray-50/30",children:o?E.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg bg-white border border-gray-100 shadow-sm",children:[E.jsx("div",{className:"w-8 h-8 bg-gray-900 rounded-full flex items-center justify-center flex-shrink-0",children:E.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:E.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"})})}),E.jsx("div",{className:"flex-1 min-w-0",children:E.jsx("p",{className:"text-sm font-medium text-gray-900 truncate",children:o.email})}),E.jsx("button",{onClick:()=>u(),className:"p-1.5 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-md transition-colors",title:c.common.logout,children:E.jsx(bn,{size:16})})]}):E.jsxs("button",{onClick:()=>y(!0),className:"w-full py-2.5 px-4 bg-gray-900 text-white rounded-lg hover:bg-gray-800 transition-colors flex items-center justify-center gap-2 text-sm font-medium shadow-lg shadow-gray-900/10",children:[E.jsx(Ot,{size:18}),c.common.login]})})]}),f&&E.jsx(Sn,{onClose:()=>y(!1)})]})}function Cn(){const{language:e,setLanguage:r,t:a}=_e(),[i,t]=H.useState(!1),[n,s]=H.useState(!1),[l,m]=H.useState(!1),[p,o]=H.useState(!1),u=H.useRef(null),c=H.useRef(null),f=async()=>{await navigator.clipboard.writeText("1018282100"),o(!0),setTimeout(()=>o(!1),2e3)};return H.useEffect(()=>{const y=C=>{u.current&&!u.current.contains(C.target)&&t(!1),c.current&&!c.current.contains(C.target)&&m(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]),E.jsxs("div",{className:"h-16 bg-white border-b border-gray-200 flex items-center justify-between px-6 flex-shrink-0 z-[60] relative",children:[E.jsxs("div",{className:"flex items-center gap-2",children:[E.jsx("span",{className:"w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center text-white font-serif italic text-lg shadow-blue-600/30 shadow-md",children:"T"}),E.jsx("span",{className:"text-xl font-bold text-gray-900 tracking-tight",children:"TexPixel"})]}),E.jsxs("div",{className:"flex items-center gap-3",children:[E.jsxs("div",{className:"relative",ref:c,children:[E.jsxs("button",{onClick:()=>m(!l),className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-100 rounded-lg text-gray-700 text-sm font-medium transition-colors",title:"Switch Language",children:[E.jsx(yn,{size:18}),E.jsx("span",{className:"hidden sm:inline",children:e==="en"?"English":"简体中文"}),E.jsx($t,{size:14,className:`transition-transform duration-200 ${l?"rotate-180":""}`})]}),l&&E.jsxs("div",{className:"absolute right-0 top-full mt-2 w-32 bg-white rounded-xl shadow-lg border border-gray-200 py-1 z-50 animate-in fade-in slide-in-from-top-2 duration-200",children:[E.jsxs("button",{onClick:()=>{r("en"),m(!1)},className:`w-full flex items-center justify-between px-4 py-2 text-sm transition-colors hover:bg-gray-50 ${e==="en"?"text-blue-600 font-medium":"text-gray-700"}`,children:["English",e==="en"&&E.jsx(at,{size:14})]}),E.jsxs("button",{onClick:()=>{r("zh"),m(!1)},className:`w-full flex items-center justify-between px-4 py-2 text-sm transition-colors hover:bg-gray-50 ${e==="zh"?"text-blue-600 font-medium":"text-gray-700"}`,children:["简体中文",e==="zh"&&E.jsx(at,{size:14})]})]})]}),E.jsxs("button",{id:"guide-button",className:"flex items-center gap-2 px-3 py-2 hover:bg-gray-100 rounded-lg text-gray-700 text-sm font-medium transition-colors",onClick:()=>{window.dispatchEvent(new CustomEvent("start-user-guide"))},children:[E.jsx(mn,{size:18}),E.jsx("span",{className:"hidden sm:inline",children:a.common.guide})]}),E.jsxs("div",{className:"relative",children:[E.jsxs("button",{onClick:()=>s(!n),className:"flex items-center gap-2 px-4 py-2 bg-gradient-to-r from-rose-500 to-pink-500 hover:from-rose-600 hover:to-pink-600 rounded-lg text-white text-sm font-medium transition-all shadow-sm hover:shadow-md",children:[E.jsx(fn,{size:14,className:"fill-white"}),E.jsx("span",{children:a.common.reward})]}),n&&E.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[70] p-4",onClick:()=>s(!1),children:E.jsxs("div",{className:"bg-white rounded-xl shadow-xl max-w-sm w-full p-6 animate-in fade-in zoom-in-95 duration-200",onClick:y=>y.stopPropagation(),children:[E.jsxs("div",{className:"flex items-center justify-between mb-4",children:[E.jsx("span",{className:"text-lg font-bold text-gray-900",children:a.navbar.rewardTitle}),E.jsx("button",{onClick:()=>s(!1),className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:E.jsx(Ze,{size:20,className:"text-gray-500"})})]}),E.jsxs("div",{className:"flex flex-col items-center",children:[E.jsx("img",{src:"https://cdn.texpixel.com/public/rewardcode.png",alt:a.navbar.rewardTitle,className:"w-64 h-64 object-contain rounded-lg shadow-sm"}),E.jsxs("p",{className:"text-sm text-gray-500 text-center mt-4",children:[a.navbar.rewardThanks,E.jsx("br",{}),E.jsx("span",{className:"text-xs text-gray-400 mt-1 block",children:a.navbar.rewardSubtitle})]})]})]})})]}),E.jsxs("div",{className:"relative",ref:u,children:[E.jsxs("button",{onClick:()=>t(!i),className:"flex items-center gap-2 px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-lg text-gray-700 text-sm font-medium transition-colors",children:[E.jsx(wn,{size:14}),E.jsx("span",{children:a.common.contactUs}),E.jsx($t,{size:14,className:`transition-transform duration-200 ${i?"rotate-180":""}`})]}),i&&E.jsxs("div",{className:"absolute right-0 top-full mt-2 w-64 bg-white rounded-xl shadow-lg border border-gray-200 py-2 z-50 animate-in fade-in slide-in-from-top-2 duration-200",children:[E.jsxs("a",{href:"mailto:yogecoder@gmail.com",className:"flex items-center gap-3 px-4 py-3 hover:bg-gray-50 transition-colors",children:[E.jsx("div",{className:"w-8 h-8 bg-blue-100 rounded-lg flex items-center justify-center",children:E.jsx(xn,{size:16,className:"text-blue-600"})}),E.jsxs("div",{children:[E.jsx("div",{className:"text-xs text-gray-500",children:a.common.email}),E.jsx("div",{className:"text-sm font-medium text-gray-900",children:"yogecoder@gmail.com"})]})]}),E.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 hover:bg-gray-50 transition-all cursor-pointer ${p?"bg-green-50":""}`,onClick:f,children:[E.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center transition-colors ${p?"bg-green-500":"bg-green-100"}`,children:p?E.jsx(at,{size:16,className:"text-white"}):E.jsx(An,{size:16,className:"text-green-600"})}),E.jsxs("div",{children:[E.jsx("div",{className:`text-xs transition-colors ${p?"text-green-600 font-medium":"text-gray-500"}`,children:p?a.common.copied:a.common.qqGroup}),E.jsx("div",{className:"text-sm font-medium text-gray-900",children:"1018282100"})]})]})]})]})]})]})}function kn({file:e}){const{t:r}=_e(),[a,i]=H.useState(100),[t,n]=H.useState(1),s=1,l=()=>i(p=>Math.min(p+10,200)),m=()=>i(p=>Math.max(p-10,50));return e?E.jsxs("div",{className:"flex flex-col h-full bg-gray-100/50",children:[E.jsxs("div",{className:"h-16 flex items-center justify-between px-6 bg-white border-b border-gray-200 z-10 relative",children:[E.jsxs("div",{className:"flex items-center gap-3 overflow-hidden z-20",children:[E.jsx("div",{className:"p-2 bg-blue-50 text-blue-600 rounded-lg",children:E.jsx(zt,{size:18})}),E.jsx("h2",{className:"text-sm font-semibold text-gray-900 truncate max-w-[200px]",title:e.filename,children:e.filename})]}),E.jsxs("div",{className:"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 flex items-center gap-4 z-10",children:[E.jsxs("div",{className:"flex items-center gap-1",children:[E.jsx("button",{onClick:()=>n(p=>Math.max(1,p-1)),disabled:t===1,className:"p-1 hover:bg-white hover:shadow-sm rounded-md text-gray-500 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:shadow-none transition-all",children:E.jsx(Nt,{size:16})}),E.jsxs("span",{className:"text-xs font-medium text-gray-600 px-1 select-none min-w-[3rem] text-center",children:[t," / ",s]}),E.jsx("button",{onClick:()=>n(p=>Math.min(s,p+1)),disabled:t===s,className:"p-1 hover:bg-white hover:shadow-sm rounded-md text-gray-500 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:shadow-none transition-all",children:E.jsx(Tt,{size:16})})]}),E.jsxs("div",{className:"flex items-center gap-1",children:[E.jsx("button",{onClick:m,className:"p-1 hover:bg-white hover:shadow-sm rounded-md text-gray-500 transition-all",title:r.common.preview,children:E.jsx(vn,{size:16})}),E.jsxs("span",{className:"text-xs font-medium text-gray-600 min-w-[2.5rem] text-center select-none",children:[a,"%"]}),E.jsx("button",{onClick:l,className:"p-1 hover:bg-white hover:shadow-sm rounded-md text-gray-500 transition-all",title:r.common.preview,children:E.jsx(En,{size:16})})]})]})]}),E.jsx("div",{className:"flex-1 overflow-auto p-8 relative custom-scrollbar flex items-center justify-center border-r border-gray-200",children:E.jsx("div",{className:"bg-white shadow-2xl shadow-gray-200/50 transition-transform duration-200 ease-out origin-center max-w-full max-h-full flex items-center justify-center",style:{transform:`scale(${a/100})`},children:e.file_type==="application/pdf"?E.jsx("div",{className:"w-[595px] h-[842px] flex items-center justify-center bg-gray-50 border border-gray-100",children:E.jsx("p",{className:"text-gray-400",children:"PDF Preview Not Implemented"})}):E.jsx("img",{src:e.file_path||"https://images.pexels.com/photos/326514/pexels-photo-326514.jpeg?auto=compress&cs=tinysrgb&w=800",alt:e.filename,className:"max-w-full max-h-full object-contain block",draggable:!1})})})]}):E.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-white p-8 text-center border border-white border-solid",id:"file-preview-empty",children:[E.jsx("div",{className:"w-32 h-32 bg-gray-100 rounded-full flex items-center justify-center mb-6 shadow-inner",children:E.jsx(zt,{size:48,className:"text-gray-900"})}),E.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:r.common.upload}),E.jsx("p",{className:"text-gray-500 max-w-xs",children:r.sidebar.uploadInstruction})]})}function _n(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Nn(e,r,a){const t=Fr({}.ignore||[]),n=Tn(r);let s=-1;for(;++s<n.length;)Pr(e,"text",l);function l(p,o){let u=-1,c;for(;++u<o.length;){const f=o[u],y=c?c.children:void 0;if(t(f,y?y.indexOf(f):void 0,c))return;c=f}if(c)return m(p,o)}function m(p,o){const u=o[o.length-1],c=n[s][0],f=n[s][1];let y=0;const k=u.children.indexOf(p);let b=!1,w=[];c.lastIndex=0;let g=c.exec(p.value);for(;g;){const h=g.index,S={index:g.index,input:g.input,stack:[...o,p]};let d=f(...g,S);if(typeof d=="string"&&(d=d.length>0?{type:"text",value:d}:void 0),d===!1?c.lastIndex=h+1:(y!==h&&w.push({type:"text",value:p.value.slice(y,h)}),Array.isArray(d)?w.push(...d):d&&w.push(d),y=h+g[0].length,b=!0),!c.global)break;g=c.exec(p.value)}return b?(y<p.value.length&&w.push({type:"text",value:p.value.slice(y)}),u.children.splice(k,1,...w)):w=[p],k+w.length}}function Tn(e){const r=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const a=!e[0]||Array.isArray(e[0])?e:[e];let i=-1;for(;++i<a.length;){const t=a[i];r.push([Rn(t[0]),Mn(t[1])])}return r}function Rn(e){return typeof e=="string"?new RegExp(_n(e),"g"):e}function Mn(e){return typeof e=="function"?e:function(){return e}}function Ln(e){Nn(e,[/\r?\n|\r/g,Un])}function Un(){return{type:"break"}}function In(){return function(e){Ln(e)}}const Fn=new Uint16Array("Ȁaglq \x1Bɭ\0\0p;䀦os;䀧t;䀾t;䀼uot;䀢".split("").map(e=>e.charCodeAt(0)));var vt;const Pn=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]),$n=(vt=String.fromCodePoint)!==null&&vt!==void 0?vt:function(e){let r="";return e>65535&&(e-=65536,r+=String.fromCharCode(e>>>10&1023|55296),e=56320|e&1023),r+=String.fromCharCode(e),r};function zn(e){var r;return e>=55296&&e<=57343||e>1114111?65533:(r=Pn.get(e))!==null&&r!==void 0?r:e}var oe;(function(e){e[e.NUM=35]="NUM",e[e.SEMI=59]="SEMI",e[e.EQUALS=61]="EQUALS",e[e.ZERO=48]="ZERO",e[e.NINE=57]="NINE",e[e.LOWER_A=97]="LOWER_A",e[e.LOWER_F=102]="LOWER_F",e[e.LOWER_X=120]="LOWER_X",e[e.LOWER_Z=122]="LOWER_Z",e[e.UPPER_A=65]="UPPER_A",e[e.UPPER_F=70]="UPPER_F",e[e.UPPER_Z=90]="UPPER_Z"})(oe||(oe={}));const On=32;var Le;(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"})(Le||(Le={}));function St(e){return e>=oe.ZERO&&e<=oe.NINE}function Dn(e){return e>=oe.UPPER_A&&e<=oe.UPPER_F||e>=oe.LOWER_A&&e<=oe.LOWER_F}function Hn(e){return e>=oe.UPPER_A&&e<=oe.UPPER_Z||e>=oe.LOWER_A&&e<=oe.LOWER_Z||St(e)}function Bn(e){return e===oe.EQUALS||Hn(e)}var se;(function(e){e[e.EntityStart=0]="EntityStart",e[e.NumericStart=1]="NumericStart",e[e.NumericDecimal=2]="NumericDecimal",e[e.NumericHex=3]="NumericHex",e[e.NamedEntity=4]="NamedEntity"})(se||(se={}));var Me;(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(Me||(Me={}));class Wn{constructor(r,a,i){this.decodeTree=r,this.emitCodePoint=a,this.errors=i,this.state=se.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=Me.Strict}startEntity(r){this.decodeMode=r,this.state=se.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(r,a){switch(this.state){case se.EntityStart:return r.charCodeAt(a)===oe.NUM?(this.state=se.NumericStart,this.consumed+=1,this.stateNumericStart(r,a+1)):(this.state=se.NamedEntity,this.stateNamedEntity(r,a));case se.NumericStart:return this.stateNumericStart(r,a);case se.NumericDecimal:return this.stateNumericDecimal(r,a);case se.NumericHex:return this.stateNumericHex(r,a);case se.NamedEntity:return this.stateNamedEntity(r,a)}}stateNumericStart(r,a){return a>=r.length?-1:(r.charCodeAt(a)|On)===oe.LOWER_X?(this.state=se.NumericHex,this.consumed+=1,this.stateNumericHex(r,a+1)):(this.state=se.NumericDecimal,this.stateNumericDecimal(r,a))}addToNumericResult(r,a,i,t){if(a!==i){const n=i-a;this.result=this.result*Math.pow(t,n)+Number.parseInt(r.substr(a,n),t),this.consumed+=n}}stateNumericHex(r,a){const i=a;for(;a<r.length;){const t=r.charCodeAt(a);if(St(t)||Dn(t))a+=1;else return this.addToNumericResult(r,i,a,16),this.emitNumericEntity(t,3)}return this.addToNumericResult(r,i,a,16),-1}stateNumericDecimal(r,a){const i=a;for(;a<r.length;){const t=r.charCodeAt(a);if(St(t))a+=1;else return this.addToNumericResult(r,i,a,10),this.emitNumericEntity(t,2)}return this.addToNumericResult(r,i,a,10),-1}emitNumericEntity(r,a){var i;if(this.consumed<=a)return(i=this.errors)===null||i===void 0||i.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(r===oe.SEMI)this.consumed+=1;else if(this.decodeMode===Me.Strict)return 0;return this.emitCodePoint(zn(this.result),this.consumed),this.errors&&(r!==oe.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(r,a){const{decodeTree:i}=this;let t=i[this.treeIndex],n=(t&Le.VALUE_LENGTH)>>14;for(;a<r.length;a++,this.excess++){const s=r.charCodeAt(a);if(this.treeIndex=Gn(i,t,this.treeIndex+Math.max(1,n),s),this.treeIndex<0)return this.result===0||this.decodeMode===Me.Attribute&&(n===0||Bn(s))?0:this.emitNotTerminatedNamedEntity();if(t=i[this.treeIndex],n=(t&Le.VALUE_LENGTH)>>14,n!==0){if(s===oe.SEMI)return this.emitNamedEntityData(this.treeIndex,n,this.consumed+this.excess);this.decodeMode!==Me.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var r;const{result:a,decodeTree:i}=this,t=(i[a]&Le.VALUE_LENGTH)>>14;return this.emitNamedEntityData(a,t,this.consumed),(r=this.errors)===null||r===void 0||r.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(r,a,i){const{decodeTree:t}=this;return this.emitCodePoint(a===1?t[r]&~Le.VALUE_LENGTH:t[r+1],i),a===3&&this.emitCodePoint(t[r+2],i),i}end(){var r;switch(this.state){case se.NamedEntity:return this.result!==0&&(this.decodeMode!==Me.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case se.NumericDecimal:return this.emitNumericEntity(0,2);case se.NumericHex:return this.emitNumericEntity(0,3);case se.NumericStart:return(r=this.errors)===null||r===void 0||r.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case se.EntityStart:return 0}}}function qn(e){let r="";const a=new Wn(e,i=>r+=$n(i));return function(t,n){let s=0,l=0;for(;(l=t.indexOf("&",l))>=0;){r+=t.slice(s,l),a.startEntity(n);const p=a.write(t,l+1);if(p<0){s=l+a.end();break}s=l+p,l=p===0?s+1:s}const m=r+t.slice(s);return r="",m}}function Gn(e,r,a,i){const t=(r&Le.BRANCH_LENGTH)>>7,n=r&Le.JUMP_TABLE;if(t===0)return n!==0&&i===n?a:-1;if(n){const m=i-n;return m<0||m>=t?-1:e[a+m]-1}let s=a,l=s+t-1;for(;s<=l;){const m=s+l>>>1,p=e[m];if(p<i)s=m+1;else if(p>i)l=m-1;else return e[m+t]}return-1}const Vn=qn(Fn);function Dt(e){return Vn(e,Me.Strict)}const Qn=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function Ht(e){const r={type:"tag",name:"",voidElement:!1,attribs:{},children:[]},a=e.match(/<\/?([^\s]+?)[/\s>]/);if(a&&(r.name=a[1],e.charAt(e.length-2)==="/"&&(r.voidElement=!0),r.name.startsWith("!--"))){const n=e.indexOf("-->");return{type:"comment",comment:n!==-1?e.slice(4,n):""}}const i=new RegExp(Qn);let t=null;for(;t=i.exec(e),t!==null;)if(t[0].trim())if(t[1]){const n=t[1].trim();let s=[n,""];n.indexOf("=")>-1&&(s=n.split("=")),r.attribs[s[0]]=s[1],i.lastIndex--}else t[2]&&(r.attribs[t[2]]=t[3].trim().substring(1,t[3].length-1));return r}const Xn=/<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,Zn=/^\s*$/,Bt=["mtext","mi","mn","mo","ms"];function Kn(e,r={}){const a=[],i=[];let t,n=-1;return e.replace(Xn,(s,l)=>{var f;const m=s.charAt(1)!=="/",p=s.startsWith("<!--"),o=l+s.length,u=e.charAt(o);let c;if(p){const y=Ht(s);return n<0?(a.push(y),a):(c=i[n],c.children.push(y),a)}if(m){if(n++,t=Ht(s),t.type==="tag"&&((f=r.components)!=null&&f[t.name])&&(t.type="component"),Bt.includes(t.name)&&!t.voidElement&&u&&u!=="<"){const y=e.slice(o,e.indexOf("<",o)).trim();t.children.push({type:"text",data:r.disableDecode?y:Dt(y)})}n===0&&a.push(t),c=i[n-1],c&&c.children.push(t),i[n]=t}if((!m||t.voidElement)&&(n>-1&&(t.voidElement||t.name===s.slice(2,-1))&&(n--,t=n===-1?a:i[n]),n>-1&&Bt.includes[i[n].name]&&u!=="<"&&u)){c=i[n].children;const y=e.indexOf("<",o);let C=e.slice(o,y===-1?void 0:y);Zn.test(C)&&(C=" "),(y>-1&&n+c.length>=0||C!==" ")&&c.push({type:"text",data:r.disableDecode?C:Dt(C)})}}),a}function Yn(e){const r=[];for(const a in e)r.push(`${a}="${e[a]}"`);return r.length?` ${r.join(" ")}`:""}function vr(e,r){switch(r.type){case"text":return e+r.data;case"tag":{const a=r.voidElement||!r.children.length&&r.attribs["xml:space"]!=="preserve";return e+=`<${r.name}${r.attribs?Yn(r.attribs):""}${a?"/>":">"}`,a?e:`${e+r.children.reduce(vr,"")}</${r.name}>`}case"comment":return e+=`<!--${r.comment}-->`,e}}function Jn(e){return e.reduce((r,a)=>r+vr("",a),"")}function ei(e,r,a,i,t){return r.name="m:oMath",r.attribs={"xmlns:m":"http://schemas.openxmlformats.org/officeDocument/2006/math","xmlns:w":"http://schemas.openxmlformats.org/wordprocessingml/2006/main"},r.type="tag",r.children=[],r}function ti(e,r,a,i,t){return r}function ri(e,r,a,i,t){var l,m;const n=((m=(l=e.attribs)==null?void 0:l.notation)==null?void 0:m.split(" ")[0])||"longdiv",s={type:"tag",name:"m:e",attribs:{},children:[]};if(n==="longdiv")r.children.push({type:"tag",name:"m:rad",attribs:{},children:[{type:"tag",name:"m:radPr",attribs:{},children:[{type:"tag",name:"m:degHide",attribs:{"m:val":"on"},children:[]}]},{type:"tag",name:"m:deg",attribs:{},children:[]},s]});else{const p={t:{type:"tag",name:"m:hideTop",attribs:{"m:val":"on"},children:[]},b:{type:"tag",name:"m:hideBot",attribs:{"m:val":"on"},children:[]},l:{type:"tag",name:"m:hideLeft",attribs:{"m:val":"on"},children:[]},r:{type:"tag",name:"m:hideRight",attribs:{"m:val":"on"},children:[]}},o={type:"tag",name:"m:borderBoxPr",attribs:{},children:[]},u={type:"tag",name:"m:borderBox",attribs:{},children:[]};switch(n){case"actuarial":case"radical":case"box":u.children=[s];break;case"left":case"roundedbox":o.children=[p.t,p.b,p.r],u.children=[o,s];break;case"right":case"circle":o.children=[p.t,p.b,p.l],u.children=[o,s];break;case"top":o.children=[p.b,p.l,p.r],u.children=[o,s];break;case"bottom":o.children=[p.t,p.l,p.r],u.children=[o,s];break;case"updiagonalstrike":o.children=[p.t,p.b,p.l,p.r,{type:"tag",name:"m:strikeBLTR",attribs:{"m:val":"on"},children:[]}],u.children=[o,s];break;case"downdiagonalstrike":o.children=[p.t,p.b,p.l,p.r,{type:"tag",name:"m:strikeTLBR",attribs:{"m:val":"on"},children:[]}],u.children=[o,s];break;case"verticalstrike":o.children=[p.t,p.b,p.l,p.r,{type:"tag",name:"m:strikeV",attribs:{"m:val":"on"},children:[]}],u.children=[o,s];break;case"horizontalstrike":o.children=[p.t,p.b,p.l,p.r,{type:"tag",name:"m:strikeH",attribs:{"m:val":"on"},children:[]}],u.children=[o,s];break;default:o.children=[p.t,p.b,p.l,p.r],u.children=[o,s];break}r.children.push(u)}return s}function ni(e,r,a,i,t){var o;if(e.children.length!==2)return r;const n=e.children[0],s=e.children[1],l={name:"m:num",type:"tag",attribs:{},children:[]},m={name:"m:den",type:"tag",attribs:{},children:[]};t=[...t],t.unshift(e),J(n,l,!1,!1,t),J(s,m,!1,!1,t);const p=((o=e.attribs)==null?void 0:o.linethickness)==="0"?"noBar":"bar";r.children.push({type:"tag",name:"m:f",attribs:{},children:[{type:"tag",name:"m:fPr",attribs:{},children:[{type:"tag",name:"m:type",attribs:{"m:val":p},children:[]}]},l,m]})}function ii(e,r,a,i,t){var n;(n=e.attribs)!=null&&n.alt&&r.children.push({type:"text",data:e.attribs.alt})}function ai(e,r,a,i,t){if(e.children.length===0)return;const n=e.children[0],s=[],l=[],m=[],p=[],o=e.children.slice(1);let u=!1;o.forEach((y,C)=>{y.name==="mprescripts"?u=!0:y.name!=="none"&&(C%2?u?m.push(y):l.push(y):u?p.push(y):s.push(y))}),t=[...t],t.unshift(e);const c={children:[]};J(n,c,!1,!1,t);let f=c.children[0];if(s.length||l.length){const y={name:"m:sub",type:"tag",attribs:{},children:[]};s.forEach(b=>J(b,y,!1,!1,t));const C={name:"m:sup",type:"tag",attribs:{},children:[]};l.forEach(b=>J(b,C,!1,!1,t));const k={type:"tag",attribs:{},children:[{type:"tag",name:"m:e",attribs:{},children:[f]}]};s.length&&l.length?(k.name="m:sSubSup",k.children.push(y),k.children.push(C)):s.length?(k.name="m:sSub",k.children.push(y)):(k.name="m:sSup",k.children.push(C)),f=k}if(m.length||p.length){const y={name:"m:sub",type:"tag",attribs:{},children:[]};m.forEach(b=>J(b,y,!1,!1,t));const C={name:"m:sup",type:"tag",attribs:{},children:[]};p.forEach(b=>J(b,C,!1,!1,t)),f={name:"m:sPre",type:"tag",attribs:{},children:[{name:"m:e",type:"tag",attribs:{},children:[f]},y,C]}}r.children.push(f)}function si(e,r,a,i,t){if(a.isNary){const n=r.children[r.children.length-1];return n.children[n.children.length-1]}return r}function oi(e,r,a,i,t){r.children.push({name:"m:r",type:"tag",attribs:{},children:[{name:"m:t",type:"tag",attribs:{"xml:space":"preserve"},children:[{type:"text",data:" "}]}]})}function li(e,r,a,i,t){const n={name:"m:e",type:"tag",attribs:{},children:[]};return r.children.push({name:"m:rad",type:"tag",attribs:{},children:[{name:"m:radPr",type:"tag",attribs:{},children:[{name:"m:degHide",type:"tag",attribs:{"m:val":"on"},children:[]}]},{name:"m:deg",type:"tag",attribs:{},children:[]},n]}),n}function ci(e,r,a,i,t){return r}function Ke(e,r=!0){let a="";if(e.type==="text"){let i=e.data.replace(/[\u2062]|[\u200B]/g,"");r&&(i=i.trim()),a+=i}else e.children&&e.children.forEach(i=>{a+=Ke(i,r)});return a}const ui=/^[\u220f-\u2211]|[\u2229-\u2233]|[\u22c0-\u22c3]$/,di=/^\u220f|\u2211|[\u2229-\u222b]|\u222e|\u222f|\u2232|\u2233|[\u22c0-\u22c3]$/;function Ye(e){const r=Ke(e);return ui.test(r)?r:!1}function Je(e,r,a,i=!1,t=!1){var l;const n=(l=r.attribs)==null?void 0:l.stretchy,s=n==="true"?"1":n==="false"?"0":di.test(e)?"1":"0";return{type:"tag",name:"m:nary",attribs:{},children:[{type:"tag",name:"m:naryPr",attribs:{},children:[{type:"tag",name:"m:chr",attribs:{"m:val":e},children:[]},{type:"tag",name:"m:limLoc",attribs:{"m:val":a},children:[]},{type:"tag",name:"m:grow",attribs:{"m:val":s},children:[]},{type:"tag",name:"m:subHide",attribs:{"m:val":i?"on":"off"},children:[]},{type:"tag",name:"m:supHide",attribs:{"m:val":t?"on":"off"},children:[]}]}]}}function hi(e,r){var i,t;const a=(t=(i=r.find(n=>{var s;return(s=n.attribs)==null?void 0:s.scriptlevel}))==null?void 0:i.attribs)==null?void 0:t.scriptlevel;["0","1","2"].includes(a)&&e.children.unshift({type:"tag",name:"m:argPr",attribs:{},children:[{type:"tag",name:"m:scrLvl",attribs:{"m:val":a},children:[]}]})}function fi(e,r,a,i,t){var o,u,c,f;if(e.children.length!==2)return r;t=[...t],t.unshift(e);const n=e.children[0],s=e.children[1];let l;const m=Ye(n);if(m&&((u=(o=e.attribs)==null?void 0:o.accent)==null?void 0:u.toLowerCase())!=="true"&&((f=(c=e.attribs)==null?void 0:c.accentunder)==null?void 0:f.toLowerCase())!=="true")l=Je(m,e,"subSup",!1,!0),e.isNary=!0;else{const y={name:"m:e",type:"tag",attribs:{},children:[]};J(n,y,!1,!1,t),l={type:"tag",name:"m:sSub",attribs:{},children:[{type:"tag",name:"m:sSubPr",attribs:{},children:[{type:"tag",name:"m:ctrlPr",attribs:{},children:[]}]},y]}}const p={name:"m:sub",type:"tag",attribs:{},children:[]};J(s,p,!1,!1,t),l.children.push(p),e.isNary&&(l.children.push({type:"tag",name:"m:sup",attribs:{},children:[]}),l.children.push({type:"tag",name:"m:e",attribs:{},children:[]})),r.children.push(l)}function mi(e,r,a,i,t){var c,f,y,C;if(e.children.length!==3)return r;t=[...t],t.unshift(e);const n=e.children[0],s=e.children[1],l=e.children[2];let m;const p=Ye(n);if(p&&((f=(c=e.attribs)==null?void 0:c.accent)==null?void 0:f.toLowerCase())!=="true"&&((C=(y=e.attribs)==null?void 0:y.accentunder)==null?void 0:C.toLowerCase())!=="true")m=Je(p,e,"subSup"),e.isNary=!0;else{const k={name:"m:e",type:"tag",attribs:{},children:[]};J(n,k,!1,!1,t),m={type:"tag",name:"m:sSubSup",attribs:{},children:[{type:"tag",name:"m:sSubSupPr",attribs:{},children:[{type:"tag",name:"m:ctrlPr",attribs:{},children:[]}]},k]}}const o={name:"m:sub",type:"tag",attribs:{},children:[]},u={name:"m:sup",type:"tag",attribs:{},children:[]};J(s,o,!1,!1,t),J(l,u,!1,!1,t),m.children.push(o),m.children.push(u),e.isNary&&m.children.push({type:"tag",name:"m:e",attribs:{},children:[]}),r.children.push(m)}function gi(e,r,a,i,t){var o,u,c,f;if(e.children.length!==2)return r;t=[...t],t.unshift(e);const n=e.children[0],s=e.children[1];let l;const m=Ye(n);if(m&&((u=(o=e.attribs)==null?void 0:o.accent)==null?void 0:u.toLowerCase())!=="true"&&((f=(c=e.attribs)==null?void 0:c.accentunder)==null?void 0:f.toLowerCase())!=="true")l=Je(m,e,"subSup",!0),e.isNary=!0,l.children.push({type:"tag",name:"m:sub"});else{const y={name:"m:e",type:"tag",attribs:{},children:[]};J(n,y,!1,!1,t),l={type:"tag",name:"m:sSup",attribs:{},children:[{type:"tag",name:"m:sSupPr",attribs:{},children:[{type:"tag",name:"m:ctrlPr",attribs:{},children:[]}]},y]}}const p={name:"m:sup",type:"tag",attribs:{},children:[]};J(s,p,!1,!1,t),l.children.push(p),e.isNary&&l.children.push({type:"tag",name:"m:e",attribs:{},children:[]}),r.children.push(l)}function pi(e,r,a,i,t){const n=Math.max(...e.children.map(l=>l.children.length)),s={name:"m:m",type:"tag",attribs:{},children:[{name:"m:mPr",type:"tag",attribs:{},children:[{name:"m:baseJc",type:"tag",attribs:{"m:val":"center"},children:[]},{name:"m:plcHide",type:"tag",attribs:{"m:val":"on"},children:[]},{name:"m:mcs",type:"tag",attribs:{},children:[{name:"m:mc",type:"tag",attribs:{},children:[{name:"m:mcPr",type:"tag",attribs:{},children:[{name:"m:count",type:"tag",attribs:{"m:val":n.toString()},children:[]},{name:"m:mcJc",type:"tag",attribs:{"m:val":"center"},children:[]}]}]}]}]}]};return r.children.push(s),s}function yi(e,r,a,i,t){const n={name:"m:e",type:"tag",attribs:{},children:[]};return r.children.push(n),n}function bi(e,r,a,i,t){const n={name:"m:mr",type:"tag",attribs:{},children:[]};return r.children.push(n),n}function xi(e,r,a,i,t){var c,f,y,C;if(e.children.length!==3)return r;t=[...t],t.unshift(e);const n=e.children[0],s=e.children[1],l=e.children[2],m=Ye(n);if(m&&((f=(c=e.attributes)==null?void 0:c.accent)==null?void 0:f.toLowerCase())!=="true"&&((C=(y=e.attributes)==null?void 0:y.accentunder)==null?void 0:C.toLowerCase())!=="true"){const k=Je(m,e,"undOvr");e.isNary=!0;const b={name:"m:sub",type:"tag",attribs:{},children:[]},w={name:"m:sup",type:"tag",attribs:{},children:[]};J(s,b,!1,!1,t),J(l,w,!1,!1,t),k.children.push(b),k.children.push(w),k.children.push({type:"tag",name:"m:e",attribs:{},children:[]}),r.children.push(k);return}const p={name:"m:e",type:"tag",attribs:{},children:[]};J(n,p,!1,!1,t);const o={name:"m:lim",type:"tag",attribs:{},children:[]},u={name:"m:lim",type:"tag",attribs:{},children:[]};J(s,o,!1,!1,t),J(l,u,!1,!1,t),r.children.push({type:"tag",name:"m:limUpp",attribs:{},children:[{type:"tag",name:"m:e",attribs:{},children:[{type:"tag",name:"m:limLow",attribs:{},children:[p,o]}]},u]})}function wi(e,r,a={}){var u,c,f,y,C,k,b;const i=e.attribs||{},t=i.mathcolor||((u=r.find(w=>w.name==="mstyle"&&w.attribs&&w.attribs.color))==null?void 0:u.attribs.color)||"",n=i.mathsize||((c=r.find(w=>w.name==="mstyle"&&w.attribs&&w.attribs.mathsize))==null?void 0:c.attribs.mathsize)||"",s=i.scriptlevel||((f=r.find(w=>w.name==="mstyle"&&w.attribs&&w.attribs.scriptlevel))==null?void 0:f.attribs.scriptlevel)||"",l=i.mathbackground||((y=r.find(w=>w.name==="mstyle"&&w.attribs&&w.attribs.mathbackground))==null?void 0:y.attribs.mathbackground)||"";let m=i.mathvariant||((C=r.find(w=>w.name==="mstyle"&&w.attribs&&w.attribs.mathvariant))==null?void 0:C.attribs.mathvariant)||"";m==="b-i"&&(m="bold-italic");const p=i.fontweight||((k=r.find(w=>w.name==="mstyle"&&w.attribs&&w.attribs.fontweight))==null?void 0:k.attribs.fontweight)||"";p==="bold"&&!["bold","bold-italic"].includes(m)?m.includes("italic")?m="bold-italic":m="bold":p==="normal"&&["bold","bold-italic"].includes(m)&&(m.includes("italic")?m="italic":m="");const o=i.fontstyle||((b=r.find(w=>w.name==="mstyle"&&w.attribs&&w.attribs.fontstyle))==null?void 0:b.attribs.fontstyle)||"";if(o==="italic"&&!["italic","bold-italic"].includes(m)?m.includes("bold")?m="bold-italic":m="italic":o==="normal"&&["italic","bold-italic"].includes(m)&&(m.includes("bold")?m="bold":m=""),!i.mathvariant){const w=Ke(e);a.variant===""&&(e.name==="mi"&&w.length>1||e.name==="mn"&&!/^\d+\.\d+$/.test(w))?m="":["mi","mn","mo"].includes(e.name)&&["italic","bold-italic"].includes(a.variant)&&(p==="bold"?m="bold-italic":m="italic")}return{color:t,variant:m,size:n,scriptlevel:s,background:l,fontstyle:o}}const vi={bold:"b",italic:"i","bold-italic":"bi"};function et(e,r,a,i,t,n){var u;if(a.isNary){const c=r.children[r.children.length-1];r=c.children[c.children.length-1]}const s=(u=e.children)==null?void 0:u.find(c=>c.name==="mglyph"),l=wi(e,t,a==null?void 0:a.style);e.style=l,e.hasMglyphChild=s;const m=Object.keys(l).every(c=>{const f=a==null?void 0:a.style;return f&&l[c]===f[c]})&&(a==null?void 0:a.hasMglyphChild)===s,p=n===(a==null?void 0:a.name)||["mi","mn","mo"].includes(n)&&["mi","mn","mo"].includes(a==null?void 0:a.name);let o;if(p&&m&&!s){const c=r.children[r.children.length-1];o=c.children[c.children.length-1]}else{const c={name:"m:r",type:"tag",attribs:{},children:[]};if(l.variant){const f={name:"w:rPr",type:"tag",attribs:{},children:[]};l.variant.includes("bold")&&f.children.push({name:"w:b",type:"tag",attribs:{},children:[]}),l.variant.includes("italic")&&f.children.push({name:"w:i",type:"tag",attribs:{},children:[]}),c.children.push(f);const y={name:"m:rPr",type:"tag",attribs:{},children:[{name:"m:nor",type:"tag",attribs:{},children:[]}]};l.variant!=="italic"&&y.children.push({name:"m:sty",type:"tag",attribs:{"m:val":vi[l.variant]},children:[]}),c.children.push(y)}else s||n==="mtext"?c.children.push({name:"m:rPr",type:"tag",attribs:{},children:[{name:"m:nor",type:"tag",attribs:{},children:[]}]}):(l.fontstyle==="normal"||n==="ms"&&l.fontstyle==="")&&c.children.push({name:"m:rPr",type:"tag",attribs:{},children:[{name:"m:sty",type:"tag",attribs:{"m:val":"p"},children:[]}]});o={name:"m:t",type:"tag",attribs:{"xml:space":"preserve"},children:[]},c.children.push(o),r.children.push(c)}return o}function Ei(e,r,a,i,t){return et(e,r,a,i,t,"mtext")}function Ai(e,r,a,i,t){return et(e,r,a,i,t,"mi")}function Si(e,r,a,i,t){return et(e,r,a,i,t,"mn")}function ji(e,r,a,i,t){return et(e,r,a,i,t,"mo")}function Ci(e,r,a,i,t){return et(e,r,a,i,t,"ms")}const ki={"←":"⃖","⟵":"⃖","→":"⃗","⟶":"⃗","´":"́","˝":"̋","˘":"̆","ˇ":"̌","¸":"̒","^":"̂","¨":"̈","˙":"̇","`":"̀","-":"̅","¯":"̅","":"̅",".":"̇","~":"̃","˜":"̃"};function Er(e,r,a,i,t,n){var c,f,y,C,k,b,w,g,h,S,d,I;if(e.children.length!==2)return r;t=[...t],t.unshift(e);const s=e.children[0],l=e.children[1],m=Ye(s);if(m&&((f=(c=e.attribs)==null?void 0:c.accent)==null?void 0:f.toLowerCase())!=="true"&&((C=(y=e.attribs)==null?void 0:y.accentunder)==null?void 0:C.toLowerCase())!=="true"){const x=Je(m,e,"undOvr",n==="over",n==="under");e.isNary=!0;const A={name:"m:sub",type:"tag",attribs:{},children:[]},_={name:"m:sup",type:"tag",attribs:{},children:[]};J(l,n==="under"?A:_,!1,!1,t),x.children.push(A),x.children.push(_),x.children.push({type:"tag",name:"m:e",attribs:{},children:[]}),r.children.push(x);return}const p=Ke(l),o={name:"m:e",type:"tag",attribs:{},children:[]};if(J(s,o,!1,!1,t),n==="under"&&l.name==="mo"&&["̲","_"].includes(p)||n==="over"&&l.name==="mo"&&["̅","¯"].includes(p)){r.children.push({type:"tag",name:"m:bar",attribs:{},children:[{type:"tag",name:"m:barPr",attribs:{},children:[{type:"tag",name:"m:pos",attribs:{"m:val":n==="under"?"bot":"top"},children:[]}]},{type:"tag",name:"m:e",attribs:{},children:[{type:"tag",name:n==="under"?"m:sSub":"m:sSup",attribs:{},children:[{type:"tag",name:n==="under"?"m:sSubPr":"m:sSupPr",attribs:{},children:[{type:"tag",name:"m:ctrlPr",attribs:{},children:[]}]},o,{type:"tag",name:"m:sub",attribs:{},children:[]}]}]}]});return}if(n==="under"&&((b=(k=e.attribs)==null?void 0:k.accentunder)==null?void 0:b.toLowerCase())==="true"&&l.name==="mo"&&p.length<2||n==="over"&&((g=(w=e.attribs)==null?void 0:w.accent)==null?void 0:g.toLowerCase())==="true"&&l.name==="mo"&&p.length<2){r.children.push({type:"tag",name:"m:acc",attribs:{},children:[{type:"tag",name:"m:accPr",attribs:{},children:[{type:"tag",name:"m:chr",attribs:{"m:val":ki[p]||p},children:[]}]},o]});return}if(((S=(h=e.attribs)==null?void 0:h.accent)==null?void 0:S.toLowerCase())!=="true"&&((I=(d=e.attribs)==null?void 0:d.accentunder)==null?void 0:I.toLowerCase())!=="true"&&l.name==="mo"&&s.name==="mrow"&&p.length===1){r.children.push({type:"tag",name:"m:groupChr",attribs:{},children:[{type:"tag",name:"m:groupChrPr",attribs:{},children:[{type:"tag",name:"m:chr",attribs:{"m:val":p,"m:pos":n==="under"?"bot":"top"},children:[]}]},o]});return}const u={name:"m:lim",type:"tag",attribs:{},children:[]};J(l,u,!1,!1,t),r.children.push({type:"tag",name:n==="under"?"m:limLow":"m:limUpp",attribs:{},children:[o,u]})}function _i(e,r,a,i,t){return Er(e,r,a,i,t,"under")}function Ni(e,r,a,i,t){return Er(e,r,a,i,t,"over")}function Ti(e,r,a,i,t){if(e.children.length!==2)return r;t=[...t],t.unshift(e);const n=e.children[0],s=e.children[1],l={type:"tag",name:"m:e",attribs:{},children:[]};J(n,l,!1,!1,t);const m={type:"tag",name:"m:deg",attribs:{},children:[]};J(s,m,!1,!1,t);const p=Ke(s);r.children.push({type:"tag",name:"m:rad",attribs:{},children:[{type:"tag",name:"m:radPr",attribs:{},children:[{type:"tag",name:"m:degHide",attribs:{"m:val":p.length?"off":"on"},children:[]}]},m,l]})}function Ri(e,r,a,i,t){var s,l;let n=e.data.replace(/[\u2062]|[\u200B]/g,"");if(t.find(m=>["mi","mn","mo"].includes(m.name)))n=n.replace(/\s/g,"");else{const m=t.find(p=>p.name==="ms");m&&(n=(((s=m.attribs)==null?void 0:s.lquote)||'"')+n+(((l=m.attribs)==null?void 0:l.rquote)||'"'))}return n.length&&(r.children.length&&r.children[r.children.length-1].type==="text"?r.children[r.children.length-1].data+=n:r.children.push({type:"text",data:n})),r}var Wt=Object.freeze({__proto__:null,math:ei,menclose:ri,mfrac:ni,mglyph:ii,mi:Ai,mmultiscripts:ai,mn:Si,mo:ji,mover:Ni,mroot:Ti,mrow:si,ms:Ci,mspace:oi,msqrt:li,mstyle:ci,msub:fi,msubsup:mi,msup:gi,mtable:pi,mtd:yi,mtext:Ei,mtr:bi,munder:_i,munderover:xi,semantics:ti,text:Ri});function J(e,r,a=!1,i=!1,t=[]){var l;!a&&["m:deg","m:den","m:e","m:fName","m:lim","m:num","m:sub","m:sup"].includes(r.name)&&hi(r,t);let n;const s=e.name||e.type;if(Wt[s]?n=Wt[s](e,r,a,i,t):(s&&s!=="root"&&console.warn(`Type not supported: ${s}`),n=r),!!n&&(l=e.children)!=null&&l.length){t=[...t],t.unshift(e);for(let m=0;m<e.children.length;m++)J(e.children[m],n,e.children[m-1],e.children[m+1],t)}}class Mi{constructor(r,a={}){this.inString=r,this.inXML=Kn(r,a),this.outXML=!1,this.outString=!1}run(){const r={};J({children:this.inXML,type:"root"},r),this.outXML=r}getResult(){return this.outString=Jn([this.outXML]),this.outString}}const Li=(e,r)=>{const a=new Mi(e,r);return a.run(),a.getResult()};function Ui(e){return e.replace(/<m:sty m:val="undefined"\/>/g,"").replace(/<m:ctrlPr\/>/g,"").replace(/<w:rPr\/>/g,"").replace(/ xmlns:m="[^"]*"/g,"").replace(/ xmlns:w="[^"]*"/g,"")}async function Ii(e){try{const r=Li(e);return Ui(r)}catch(r){return console.error("MathML to OMML conversion failed:",r),""}}function Fi(e){return`<?xml version="1.0" encoding="UTF-8"?>
<m:oMath xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
${e.replace(/<m:oMath[^>]*>/g,"").replace(/<\/m:oMath>/g,"")}
</m:oMath>`}function Pi(e,r){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const a=document.implementation.createHTMLDocument(),i=a.createElement("base"),t=a.createElement("a");return a.head.appendChild(i),a.body.appendChild(t),r&&(i.href=r),t.href=e,t.href}const $i=(()=>{let e=0;const r=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${r()}${e}`)})();function Ue(e){const r=[];for(let a=0,i=e.length;a<i;a++)r.push(e[a]);return r}let We=null;function Ar(e={}){return We||(e.includeStyleProperties?(We=e.includeStyleProperties,We):(We=Ue(window.getComputedStyle(document.documentElement)),We))}function dt(e,r){const i=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(r);return i?parseFloat(i.replace("px","")):0}function zi(e){const r=dt(e,"border-left-width"),a=dt(e,"border-right-width");return e.clientWidth+r+a}function Oi(e){const r=dt(e,"border-top-width"),a=dt(e,"border-bottom-width");return e.clientHeight+r+a}function Sr(e,r={}){const a=r.width||zi(e),i=r.height||Oi(e);return{width:a,height:i}}function Di(){let e,r;try{r=process}catch{}const a=r&&r.env?r.env.devicePixelRatio:null;return a&&(e=parseInt(a,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}const xe=16384;function Hi(e){(e.width>xe||e.height>xe)&&(e.width>xe&&e.height>xe?e.width>e.height?(e.height*=xe/e.width,e.width=xe):(e.width*=xe/e.height,e.height=xe):e.width>xe?(e.height*=xe/e.width,e.width=xe):(e.width*=xe/e.height,e.height=xe))}function Bi(e,r={}){return e.toBlob?new Promise(a=>{e.toBlob(a,r.type?r.type:"image/png",r.quality?r.quality:1)}):new Promise(a=>{const i=window.atob(e.toDataURL(r.type?r.type:void 0,r.quality?r.quality:void 0).split(",")[1]),t=i.length,n=new Uint8Array(t);for(let s=0;s<t;s+=1)n[s]=i.charCodeAt(s);a(new Blob([n],{type:r.type?r.type:"image/png"}))})}function ht(e){return new Promise((r,a)=>{const i=new Image;i.onload=()=>{i.decode().then(()=>{requestAnimationFrame(()=>r(i))})},i.onerror=a,i.crossOrigin="anonymous",i.decoding="async",i.src=e})}async function Wi(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(r=>`data:image/svg+xml;charset=utf-8,${r}`)}async function qi(e,r,a){const i="http://www.w3.org/2000/svg",t=document.createElementNS(i,"svg"),n=document.createElementNS(i,"foreignObject");return t.setAttribute("width",`${r}`),t.setAttribute("height",`${a}`),t.setAttribute("viewBox",`0 0 ${r} ${a}`),n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("x","0"),n.setAttribute("y","0"),n.setAttribute("externalResourcesRequired","true"),t.appendChild(n),n.appendChild(e),Wi(t)}const pe=(e,r)=>{if(e instanceof r)return!0;const a=Object.getPrototypeOf(e);return a===null?!1:a.constructor.name===r.name||pe(a,r)};function Gi(e){const r=e.getPropertyValue("content");return`${e.cssText} content: '${r.replace(/'|"/g,"")}';`}function Vi(e,r){return Ar(r).map(a=>{const i=e.getPropertyValue(a),t=e.getPropertyPriority(a);return`${a}: ${i}${t?" !important":""};`}).join(" ")}function Qi(e,r,a,i){const t=`.${e}:${r}`,n=a.cssText?Gi(a):Vi(a,i);return document.createTextNode(`${t}{${n}}`)}function qt(e,r,a,i){const t=window.getComputedStyle(e,a),n=t.getPropertyValue("content");if(n===""||n==="none")return;const s=$i();try{r.className=`${r.className} ${s}`}catch{return}const l=document.createElement("style");l.appendChild(Qi(s,a,t,i)),r.appendChild(l)}function Xi(e,r,a){qt(e,r,":before",a),qt(e,r,":after",a)}const Gt="application/font-woff",Vt="image/jpeg",Zi={woff:Gt,woff2:Gt,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Vt,jpeg:Vt,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function Ki(e){const r=/\.([^./]*?)$/g.exec(e);return r?r[1]:""}function Rt(e){const r=Ki(e).toLowerCase();return Zi[r]||""}function Yi(e){return e.split(/,/)[1]}function jt(e){return e.search(/^(data:)/)!==-1}function Ji(e,r){return`data:${r};base64,${e}`}async function jr(e,r,a){const i=await fetch(e,r);if(i.status===404)throw new Error(`Resource "${i.url}" not found`);const t=await i.blob();return new Promise((n,s)=>{const l=new FileReader;l.onerror=s,l.onloadend=()=>{try{n(a({res:i,result:l.result}))}catch(m){s(m)}},l.readAsDataURL(t)})}const Et={};function ea(e,r,a){let i=e.replace(/\?.*/,"");return a&&(i=e),/ttf|otf|eot|woff2?/i.test(i)&&(i=i.replace(/.*\//,"")),r?`[${r}]${i}`:i}async function Mt(e,r,a){const i=ea(e,r,a.includeQueryParams);if(Et[i]!=null)return Et[i];a.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let t;try{const n=await jr(e,a.fetchRequestInit,({res:s,result:l})=>(r||(r=s.headers.get("Content-Type")||""),Yi(l)));t=Ji(n,r)}catch(n){t=a.imagePlaceholder||"";let s=`Failed to fetch resource: ${e}`;n&&(s=typeof n=="string"?n:n.message),s&&console.warn(s)}return Et[i]=t,t}async function ta(e){const r=e.toDataURL();return r==="data:,"?e.cloneNode(!1):ht(r)}async function ra(e,r){if(e.currentSrc){const n=document.createElement("canvas"),s=n.getContext("2d");n.width=e.clientWidth,n.height=e.clientHeight,s==null||s.drawImage(e,0,0,n.width,n.height);const l=n.toDataURL();return ht(l)}const a=e.poster,i=Rt(a),t=await Mt(a,i,r);return ht(t)}async function na(e,r){var a;try{if(!((a=e==null?void 0:e.contentDocument)===null||a===void 0)&&a.body)return await mt(e.contentDocument.body,r,!0)}catch{}return e.cloneNode(!1)}async function ia(e,r){return pe(e,HTMLCanvasElement)?ta(e):pe(e,HTMLVideoElement)?ra(e,r):pe(e,HTMLIFrameElement)?na(e,r):e.cloneNode(Cr(e))}const aa=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",Cr=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function sa(e,r,a){var i,t;if(Cr(r))return r;let n=[];return aa(e)&&e.assignedNodes?n=Ue(e.assignedNodes()):pe(e,HTMLIFrameElement)&&(!((i=e.contentDocument)===null||i===void 0)&&i.body)?n=Ue(e.contentDocument.body.childNodes):n=Ue(((t=e.shadowRoot)!==null&&t!==void 0?t:e).childNodes),n.length===0||pe(e,HTMLVideoElement)||await n.reduce((s,l)=>s.then(()=>mt(l,a)).then(m=>{m&&r.appendChild(m)}),Promise.resolve()),r}function oa(e,r,a){const i=r.style;if(!i)return;const t=window.getComputedStyle(e);t.cssText?(i.cssText=t.cssText,i.transformOrigin=t.transformOrigin):Ar(a).forEach(n=>{let s=t.getPropertyValue(n);n==="font-size"&&s.endsWith("px")&&(s=`${Math.floor(parseFloat(s.substring(0,s.length-2)))-.1}px`),pe(e,HTMLIFrameElement)&&n==="display"&&s==="inline"&&(s="block"),n==="d"&&r.getAttribute("d")&&(s=`path(${r.getAttribute("d")})`),i.setProperty(n,s,t.getPropertyPriority(n))})}function la(e,r){pe(e,HTMLTextAreaElement)&&(r.innerHTML=e.value),pe(e,HTMLInputElement)&&r.setAttribute("value",e.value)}function ca(e,r){if(pe(e,HTMLSelectElement)){const a=r,i=Array.from(a.children).find(t=>e.value===t.getAttribute("value"));i&&i.setAttribute("selected","")}}function ua(e,r,a){return pe(r,Element)&&(oa(e,r,a),Xi(e,r,a),la(e,r),ca(e,r)),r}async function da(e,r){const a=e.querySelectorAll?e.querySelectorAll("use"):[];if(a.length===0)return e;const i={};for(let n=0;n<a.length;n++){const l=a[n].getAttribute("xlink:href");if(l){const m=e.querySelector(l),p=document.querySelector(l);!m&&p&&!i[l]&&(i[l]=await mt(p,r,!0))}}const t=Object.values(i);if(t.length){const n="http://www.w3.org/1999/xhtml",s=document.createElementNS(n,"svg");s.setAttribute("xmlns",n),s.style.position="absolute",s.style.width="0",s.style.height="0",s.style.overflow="hidden",s.style.display="none";const l=document.createElementNS(n,"defs");s.appendChild(l);for(let m=0;m<t.length;m++)l.appendChild(t[m]);e.appendChild(s)}return e}async function mt(e,r,a){return!a&&r.filter&&!r.filter(e)?null:Promise.resolve(e).then(i=>ia(i,r)).then(i=>sa(e,i,r)).then(i=>ua(e,i,r)).then(i=>da(i,r))}const kr=/url\((['"]?)([^'"]+?)\1\)/g,ha=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,fa=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function ma(e){const r=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${r})(['"]?\\))`,"g")}function ga(e){const r=[];return e.replace(kr,(a,i,t)=>(r.push(t),a)),r.filter(a=>!jt(a))}async function pa(e,r,a,i,t){try{const n=a?Pi(r,a):r,s=Rt(r);let l;return t||(l=await Mt(n,s,i)),e.replace(ma(r),`$1${l}$3`)}catch{}return e}function ya(e,{preferredFontFormat:r}){return r?e.replace(fa,a=>{for(;;){const[i,,t]=ha.exec(a)||[];if(!t)return"";if(t===r)return`src: ${i};`}}):e}function _r(e){return e.search(kr)!==-1}async function Nr(e,r,a){if(!_r(e))return e;const i=ya(e,a);return ga(i).reduce((n,s)=>n.then(l=>pa(l,s,r,a)),Promise.resolve(i))}async function qe(e,r,a){var i;const t=(i=r.style)===null||i===void 0?void 0:i.getPropertyValue(e);if(t){const n=await Nr(t,null,a);return r.style.setProperty(e,n,r.style.getPropertyPriority(e)),!0}return!1}async function ba(e,r){await qe("background",e,r)||await qe("background-image",e,r),await qe("mask",e,r)||await qe("-webkit-mask",e,r)||await qe("mask-image",e,r)||await qe("-webkit-mask-image",e,r)}async function xa(e,r){const a=pe(e,HTMLImageElement);if(!(a&&!jt(e.src))&&!(pe(e,SVGImageElement)&&!jt(e.href.baseVal)))return;const i=a?e.src:e.href.baseVal,t=await Mt(i,Rt(i),r);await new Promise((n,s)=>{e.onload=n,e.onerror=r.onImageErrorHandler?(...m)=>{try{n(r.onImageErrorHandler(...m))}catch(p){s(p)}}:s;const l=e;l.decode&&(l.decode=n),l.loading==="lazy"&&(l.loading="eager"),a?(e.srcset="",e.src=t):e.href.baseVal=t})}async function wa(e,r){const i=Ue(e.childNodes).map(t=>Tr(t,r));await Promise.all(i).then(()=>e)}async function Tr(e,r){pe(e,Element)&&(await ba(e,r),await xa(e,r),await wa(e,r))}function va(e,r){const{style:a}=e;r.backgroundColor&&(a.backgroundColor=r.backgroundColor),r.width&&(a.width=`${r.width}px`),r.height&&(a.height=`${r.height}px`);const i=r.style;return i!=null&&Object.keys(i).forEach(t=>{a[t]=i[t]}),e}const Qt={};async function Xt(e){let r=Qt[e];if(r!=null)return r;const i=await(await fetch(e)).text();return r={url:e,cssText:i},Qt[e]=r,r}async function Zt(e,r){let a=e.cssText;const i=/url\(["']?([^"')]+)["']?\)/g,n=(a.match(/url\([^)]+\)/g)||[]).map(async s=>{let l=s.replace(i,"$1");return l.startsWith("https://")||(l=new URL(l,e.url).href),jr(l,r.fetchRequestInit,({result:m})=>(a=a.replace(s,`url(${m})`),[s,m]))});return Promise.all(n).then(()=>a)}function Kt(e){if(e==null)return[];const r=[],a=/(\/\*[\s\S]*?\*\/)/gi;let i=e.replace(a,"");const t=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const m=t.exec(i);if(m===null)break;r.push(m[0])}i=i.replace(t,"");const n=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,s="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",l=new RegExp(s,"gi");for(;;){let m=n.exec(i);if(m===null){if(m=l.exec(i),m===null)break;n.lastIndex=l.lastIndex}else l.lastIndex=n.lastIndex;r.push(m[0])}return r}async function Ea(e,r){const a=[],i=[];return e.forEach(t=>{if("cssRules"in t)try{Ue(t.cssRules||[]).forEach((n,s)=>{if(n.type===CSSRule.IMPORT_RULE){let l=s+1;const m=n.href,p=Xt(m).then(o=>Zt(o,r)).then(o=>Kt(o).forEach(u=>{try{t.insertRule(u,u.startsWith("@import")?l+=1:t.cssRules.length)}catch(c){console.error("Error inserting rule from remote css",{rule:u,error:c})}})).catch(o=>{console.error("Error loading remote css",o.toString())});i.push(p)}})}catch(n){const s=e.find(l=>l.href==null)||document.styleSheets[0];t.href!=null&&i.push(Xt(t.href).then(l=>Zt(l,r)).then(l=>Kt(l).forEach(m=>{s.insertRule(m,s.cssRules.length)})).catch(l=>{console.error("Error loading remote stylesheet",l)})),console.error("Error inlining remote css file",n)}}),Promise.all(i).then(()=>(e.forEach(t=>{if("cssRules"in t)try{Ue(t.cssRules||[]).forEach(n=>{a.push(n)})}catch(n){console.error(`Error while reading CSS rules from ${t.href}`,n)}}),a))}function Aa(e){return e.filter(r=>r.type===CSSRule.FONT_FACE_RULE).filter(r=>_r(r.style.getPropertyValue("src")))}async function Sa(e,r){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const a=Ue(e.ownerDocument.styleSheets),i=await Ea(a,r);return Aa(i)}function Rr(e){return e.trim().replace(/["']/g,"")}function ja(e){const r=new Set;function a(i){(i.style.fontFamily||getComputedStyle(i).fontFamily).split(",").forEach(n=>{r.add(Rr(n))}),Array.from(i.children).forEach(n=>{n instanceof HTMLElement&&a(n)})}return a(e),r}async function Ca(e,r){const a=await Sa(e,r),i=ja(e);return(await Promise.all(a.filter(n=>i.has(Rr(n.style.fontFamily))).map(n=>{const s=n.parentStyleSheet?n.parentStyleSheet.href:null;return Nr(n.cssText,s,r)}))).join(`
`)}async function ka(e,r){const a=r.fontEmbedCSS!=null?r.fontEmbedCSS:r.skipFonts?null:await Ca(e,r);if(a){const i=document.createElement("style"),t=document.createTextNode(a);i.appendChild(t),e.firstChild?e.insertBefore(i,e.firstChild):e.appendChild(i)}}async function Mr(e,r={}){const{width:a,height:i}=Sr(e,r),t=await mt(e,r,!0);return await ka(t,r),await Tr(t,r),va(t,r),await qi(t,a,i)}async function Lr(e,r={}){const{width:a,height:i}=Sr(e,r),t=await Mr(e,r),n=await ht(t),s=document.createElement("canvas"),l=s.getContext("2d"),m=r.pixelRatio||Di(),p=r.canvasWidth||a,o=r.canvasHeight||i;return s.width=p*m,s.height=o*m,r.skipAutoScale||Hi(s),s.style.width=`${p}`,s.style.height=`${o}`,r.backgroundColor&&(l.fillStyle=r.backgroundColor,l.fillRect(0,0,s.width,s.height)),l.drawImage(n,0,0,s.width,s.height),s}async function _a(e,r={}){return(await Lr(e,r)).toDataURL()}async function Na(e,r={}){const a=await Lr(e,r);return await Bi(a)}const Ta={backgroundColor:"#ffffff",padding:20,fontSize:20,scale:2,format:"png"};async function Ra(){const e=["KaTeX_Main","KaTeX_Math","KaTeX_Size1","KaTeX_Size2","KaTeX_Size3","KaTeX_Size4"];await document.fonts.ready;const r=()=>e.some(i=>{try{return document.fonts.check(`16px ${i}`)}catch{return!1}}),a=20;for(let i=0;i<a;i++){if(r())return;await new Promise(t=>setTimeout(t,100))}}async function Ma(e,r={}){const a=document.getElementById(e);if(!a)throw new Error(`Element with ID "${e}" not found`);const i={...Ta,...r};await Ra(),await new Promise(s=>setTimeout(s,100));const t={backgroundColor:i.backgroundColor,pixelRatio:i.scale,cacheBust:!0,width:a.scrollWidth+i.padding*2,height:a.scrollHeight+i.padding*2,style:{padding:`${i.padding}px`,transform:"none",overflow:"visible",visibility:"visible",display:"block",height:"auto",maxHeight:"none"},skipFonts:!1};let n;try{switch(i.format){case"svg":n=await Mr(a,t);break;case"blob":n=await Na(a,t);break;case"png":default:n=await _a(a,t);break}return n}catch(s){throw console.error("Element image generation failed:",s),s}}async function La(e){let r;typeof e=="string"?r=await(await fetch(e)).blob():r=e,await navigator.clipboard.write([new ClipboardItem({[r.type]:r})])}const Ua=(e,r,a)=>{try{const i={task_no:e,event_name:"export_selected_event",properties:{option:a,selected:r},meta_data:{task_no:e},device_info:{ip:"","use-agent":navigator.userAgent,browser:Ia()}};De.post("/analytics/track",i).catch(t=>{console.debug("Analytics tracking failed:",t)})}catch(i){console.debug("Analytics error:",i)}};function Ia(){const e=navigator.userAgent;return e.match(/chrome|chromium|crios/i)?"Chrome":e.match(/firefox|fxios/i)?"Firefox":e.match(/safari/i)?"Safari":e.match(/opr\//i)?"Opera":e.match(/edg/i)?"Edge":"Unknown"}const Fa=e=>{try{const a=new DOMParser().parseFromString(e,"application/xml");if(a.getElementsByTagName("parsererror").length>0)return null;const t=document.implementation.createDocument("http://www.w3.org/1998/Math/MathML","mml:math",null),n=t.documentElement,s=a.documentElement.getAttribute("display");s&&n.setAttribute("display",s);const l=(o,u)=>{if(o.nodeType===Node.ELEMENT_NODE){const c=o,f=t.createElementNS("http://www.w3.org/1998/Math/MathML","mml:"+c.localName);for(let y=0;y<c.attributes.length;y++){const C=c.attributes[y];C.name.startsWith("xmlns")||f.setAttributeNS(C.namespaceURI,C.name,C.value)}Array.from(c.childNodes).forEach(y=>{l(y,f)}),u.appendChild(f)}else o.nodeType===Node.TEXT_NODE&&u.appendChild(t.createTextNode(o.nodeValue||""))};Array.from(a.documentElement.childNodes).forEach(o=>{l(o,n)});let p=new XMLSerializer().serializeToString(t);return p=p.replace(/ xmlns(:mml)?="[^"]*"/g,""),p=p.replace(/<mml:math>/,'<mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML">'),p}catch(r){return console.error("Failed to process MathML:",r),null}};function Pa({isOpen:e,onClose:r,result:a}){const{t:i}=_e(),[t,n]=H.useState(null),[s,l]=H.useState(null);if(!a)return null;const m=[{id:"markdown",label:"Markdown",category:"Code",getContent:f=>f.markdown_content},{id:"latex_inline",label:"LaTeX (Inline)",category:"Code",getContent:f=>f.latex_content?`\\(${f.latex_content.replace(/^\\\[/,"").replace(/\\\]$/,"").trim()}\\)`:null},{id:"latex_display",label:"LaTeX (Display)",category:"Code",getContent:f=>f.latex_content},{id:"mathml",label:"MathML",category:"Code",getContent:f=>f.mathml_content},{id:"mathml_mml",label:"MathML (MML)",category:"Code",getContent:f=>f.mathml_content?Fa(f.mathml_content):null},{id:"mathml_word",label:"Word MathML",category:"Code",getContent:f=>f.mathml_word_content},{id:"rendered_image",label:"Rendered Image",category:"Image",getContent:f=>f.markdown_content},{id:"docx",label:"DOCX",category:"File",getContent:f=>f.markdown_content,isDownload:!0,extension:"docx"}],p=async f=>{if(a!=null&&a.id){l(f);try{const y=ve.getToken(),C=await fetch(`${er}/task/export`,{method:"POST",headers:{"Content-Type":"application/json",...y?{Authorization:y}:{}},body:JSON.stringify({task_no:a.id,type:f})});if(!C.ok)throw new Error(`Export failed: ${C.statusText}`);const k=await C.blob(),b=URL.createObjectURL(k),w=document.createElement("a");w.href=b,w.download=`export.${f}`,document.body.appendChild(w),w.click(),document.body.removeChild(w),URL.revokeObjectURL(b),n(f),setTimeout(()=>{n(null),r()},1e3)}catch(y){console.error("Export failed:",y),alert(i.export.failed)}finally{l(null)}}},o=async f=>{const y="markdown-preview-content";l("rendered_image");try{const C=await Ma(y,{format:"png",scale:2,padding:24});f==="copy"&&await La(C),n("rendered_image"),setTimeout(()=>{n(null),r()},1e3)}catch(C){console.error("Failed to generate image:",C),alert(`${i.export.imageFailed}: ${C}`)}finally{l(null)}},u=async f=>{if(a!=null&&a.id&&Ua(a.id,f.id,m.map(C=>C.id)),f.id==="docx"){await p("docx");return}if(f.id==="rendered_image"){await o("copy");return}let y=f.getContent(a);if(f.id==="mathml_word"&&!y&&a.mathml_content)try{const C=await Ii(a.mathml_content);C&&(y=Fi(C))}catch(C){console.error("Failed to convert MathML to OMML:",C)}if(y){l(f.id);try{if(f.isDownload){const C=new Blob([y],{type:"text/plain"}),k=URL.createObjectURL(C),b=document.createElement("a");b.href=k,b.download=`export.${f.extension}`,document.body.appendChild(b),b.click(),document.body.removeChild(b),URL.revokeObjectURL(k)}else await navigator.clipboard.writeText(y);n(f.id),setTimeout(()=>{n(null),r()},1e3)}catch(C){console.error("Action failed:",C)}finally{l(null)}}},c=[{id:"Code",icon:pr,label:i.export.categories.code},{id:"Image",icon:pn,label:i.export.categories.image},{id:"File",icon:st,label:i.export.categories.file}];return E.jsxs(E.Fragment,{children:[e&&E.jsx("div",{className:"absolute inset-0 bg-black/20 backdrop-blur-[1px] z-40 transition-opacity",onClick:r}),E.jsxs("div",{className:`
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
${e?"translate-x-0":"translate-x-full"}
`,children:[E.jsxs("div",{className:"flex items-center justify-between px-6 py-5 border-b border-gray-100 shrink-0",children:[E.jsx("h2",{className:"text-lg font-bold text-gray-900",children:i.export.title}),E.jsx("button",{onClick:r,className:"p-2 hover:bg-gray-100 rounded-full transition-colors",children:E.jsx(Ze,{size:20,className:"text-gray-500"})})]}),E.jsx("div",{className:"flex-1 overflow-y-auto p-6 space-y-8",children:c.map(f=>E.jsxs("div",{className:"space-y-3",children:[E.jsxs("div",{className:"flex items-center gap-2 text-gray-400 px-1",children:[E.jsx(f.icon,{size:16}),E.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider",children:f.label})]}),E.jsx("div",{className:"space-y-2",children:m.filter(y=>y.category===f.id).map(y=>E.jsxs("button",{onClick:()=>u(y),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:[E.jsx("span",{className:"text-sm font-medium text-gray-700 group-hover:text-blue-700",children:y.label}),E.jsx("div",{className:"text-gray-400 group-hover:text-blue-600",children:s===y.id?E.jsx(xr,{size:16,className:"animate-spin text-blue-500"}):t===y.id?E.jsx(at,{size:16,className:"text-green-500"}):y.isDownload?E.jsx(yr,{size:16}):E.jsx(hn,{size:16,className:"opacity-0 group-hover:opacity-100 transition-opacity"})})]},y.id))})]},f.id))})]})]})}function $a(e){if(!e)return"";let r=e;return r=r.replace(/\$\$\s*\\\[/g,"$$$$"),r=r.replace(/\\\]\s*\$\$/g,"$$$$"),r=r.replace(new RegExp("(?<!\\$)\\\\\\[(?!\\$)","g"),"$$$$"),r=r.replace(new RegExp("(?<!\\$)\\\\\\](?!\\$)","g"),"$$$$"),r=r.replace(/\$\$([^\n$])/g,`$$$$
$1`),r=r.replace(/([^\n$])\$\$/g,`$1
$$$$`),r=r.replace(/\\left\s+\\/g,"\\left\\"),r=r.replace(/\\left\s+\{/g,"\\left\\{"),r=r.replace(/\\left\s+\[/g,"\\left["),r=r.replace(/\\left\s+\(/g,"\\left("),r=r.replace(/\\right\s+\\/g,"\\right\\"),r=r.replace(/\\right\s+\}/g,"\\right\\}"),r=r.replace(/\\right\s+\]/g,"\\right]"),r=r.replace(/\\right\s+\)/g,"\\right)"),r=r.replace(/\\left\(([^)]*?)\\right\.\s*(\\text\{[^}]*\})\s*\\right\)/g,"($1\\right. $2)"),r}function za({result:e,fileStatus:r}){const{t:a}=_e(),[i,t]=H.useState(!1);return e?E.jsxs("div",{className:"flex flex-col h-full bg-white relative overflow-hidden",id:"result-panel-content",children:[E.jsxs("div",{className:"h-16 px-6 border-b border-gray-200 flex items-center justify-between bg-white shrink-0 z-10",children:[E.jsx("div",{className:"flex items-center gap-4",children:E.jsx("h2",{className:"text-lg font-bold text-gray-900",children:a.resultPanel.markdown})}),E.jsxs("button",{id:"export-button",onClick:()=>t(!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 ${i?"opacity-0 pointer-events-none":""}`,children:[E.jsx(yr,{size:16}),a.common.export]})]}),E.jsx("div",{className:"flex-1 overflow-auto p-8 custom-scrollbar flex justify-center",children:E.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:E.jsx($r,{remarkPlugins:[zr,In],rehypePlugins:[[Or,{throwOnError:!1,errorColor:"#cc0000",strict:!1}]],children:$a(e.markdown_content||"")})})}),E.jsx(Pa,{isOpen:i,onClose:()=>t(!1),result:e})]}):r==="processing"||r==="pending"?E.jsxs("div",{className:"h-full flex flex-col items-center justify-center bg-white text-center p-8",children:[E.jsx("div",{className:"w-16 h-16 border-4 border-blue-600 border-t-transparent rounded-full animate-spin mb-6"}),E.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:r==="pending"?a.resultPanel.waitingQueue:a.resultPanel.analyzing}),E.jsx("p",{className:"text-gray-500 max-w-sm",children:r==="pending"?a.resultPanel.queueSubtitle:a.resultPanel.processingSubtitle})]}):E.jsxs("div",{className:"h-full flex flex-col items-center justify-center bg-white text-center p-8",id:"result-empty-state",children:[E.jsx("div",{className:"w-32 h-32 bg-gray-100 rounded-full flex items-center justify-center mb-6 shadow-inner",children:E.jsx(pr,{size:48,className:"text-gray-900"})}),E.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:a.resultPanel.waitingTitle}),E.jsx("p",{className:"text-gray-500 max-w-sm",children:a.resultPanel.waitingSubtitle})]})}function Oa({onClose:e,onUpload:r}){const{t:a}=_e(),[i,t]=H.useState(!1),n=H.useRef(null);H.useEffect(()=>{const p=o=>{var f;const u=(f=o.clipboardData)==null?void 0:f.items;if(!u)return;const c=[];for(let y=0;y<u.length;y++)if(u[y].type.startsWith("image/")||u[y].type==="application/pdf"){const C=u[y].getAsFile();C&&c.push(C)}c.length>0&&(r(c),e())};return document.addEventListener("paste",p),()=>document.removeEventListener("paste",p)},[r,e]);const s=H.useCallback(p=>{p.preventDefault(),p.stopPropagation(),p.type==="dragenter"||p.type==="dragover"?t(!0):p.type==="dragleave"&&t(!1)},[]),l=H.useCallback(p=>{p.preventDefault(),p.stopPropagation(),t(!1);const o=Array.from(p.dataTransfer.files).filter(u=>u.type.startsWith("image/")||u.type==="application/pdf");o.length>0&&(r(o),e())},[r,e]),m=p=>{if(p.target.files){const o=Array.from(p.target.files).filter(u=>u.type.startsWith("image/")||u.type==="application/pdf");o.length>0&&(r(o),e())}};return E.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:E.jsxs("div",{className:"bg-white rounded-xl shadow-xl max-w-2xl w-full p-6",children:[E.jsxs("div",{className:"flex justify-between items-center mb-6",children:[E.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:a.uploadModal.title}),E.jsx("button",{onClick:e,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:E.jsx(Ze,{size:20})})]}),E.jsxs("div",{onDragEnter:s,onDragLeave:s,onDragOver:s,onDrop:l,onClick:()=>{var p;return(p=n.current)==null?void 0:p.click()},className:`border-2 border-dashed rounded-xl p-12 text-center transition-colors cursor-pointer group ${i?"border-blue-500 bg-blue-50":"border-gray-300 hover:border-blue-400 hover:bg-gray-50"}`,children:[E.jsx("div",{className:"w-16 h-16 bg-gray-100 text-gray-600 rounded-full flex items-center justify-center mx-auto mb-4 group-hover:scale-110 transition-transform",children:E.jsx(At,{size:32})}),E.jsx("p",{className:"text-sm text-gray-600 mb-1",children:a.sidebar.uploadInstruction}),E.jsx("input",{ref:n,type:"file",multiple:!0,accept:"image/*,application/pdf",onChange:m,className:"hidden"}),E.jsx("p",{className:"text-xs text-gray-500 mb-4",children:a.uploadModal.supportFormats}),E.jsxs("div",{className:"flex items-center justify-center gap-4 mt-6 text-xs text-gray-400",children:[E.jsxs("div",{className:"flex items-center gap-1",children:[E.jsx(wr,{className:"w-3.5 h-3.5"}),E.jsx("span",{children:a.common.click})]}),E.jsxs("div",{className:"flex items-center gap-1",children:[E.jsx(br,{className:"w-3.5 h-3.5"}),E.jsx("span",{children:a.common.drop})]}),E.jsxs("div",{className:"flex items-center gap-1",children:[E.jsx(gr,{className:"w-3.5 h-3.5"}),E.jsx("span",{children:a.common.paste})]})]})]})]})})}function Da({isOpen:e,onClose:r}){const{t:a}=_e(),[i,t]=H.useState(0),[n,s]=H.useState({}),l=[{id:"sidebar-upload-area",title:a.guide.step1Title,content:a.guide.step1Content,position:"right"},{id:"sidebar-history",title:a.guide.step2Title,content:a.guide.step2Content,position:"right"},{id:"file-preview-empty",title:a.guide.step3Title,content:a.guide.step3Content,position:"right"},{id:"result-empty-state",title:a.guide.step4Title,content:a.guide.step4Content,position:"left"},{id:"export-button",title:a.guide.stepExportTitle,content:a.guide.stepExportContent,position:"left"}],m=H.useCallback(()=>{if(!e||l.length===0)return;const u=document.getElementById(l[i].id);if(u){const c=u.getBoundingClientRect();s({top:c.top-8,left:c.left-8,width:c.width+16,height:c.height+16,opacity:1}),u.scrollIntoView({behavior:"smooth",block:"center"})}else s({opacity:0})},[i,e,l,a.guide]);if(H.useEffect(()=>(e&&(m(),window.addEventListener("resize",m)),()=>window.removeEventListener("resize",m)),[e,m]),!e)return null;const p=()=>{i<l.length-1?t(i+1):(r(),t(0))},o=()=>{i>0&&t(i-1)};return E.jsxs("div",{className:"fixed inset-0 z-[100] pointer-events-none",children:[E.jsx("div",{className:"absolute inset-0 bg-black/60 pointer-events-auto",onClick:r,style:{clipPath:n.top!==void 0?`polygon(
0% 0%, 0% 100%,
${n.left}px 100%,
${n.left}px ${n.top}px,
${n.left+n.width}px ${n.top}px,
${n.left+n.width}px ${n.top+n.height}px,
${n.left}px ${n.top+n.height}px,
${n.left}px 100%,
100% 100%, 100% 0%
)`:"none"}}),E.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:n}),E.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:n.top!==void 0?{top:l[i].position==="bottom"?n.top+n.height+16:l[i].position==="top"?n.top-200:n.top,left:l[i].position==="right"?n.left+n.width+16:l[i].position==="left"?n.left-336:n.left}:{top:"50%",left:"50%",transform:"translate(-50%, -50%)"},children:[E.jsx("button",{onClick:r,className:"absolute top-4 right-4 text-gray-400 hover:text-gray-600",children:E.jsx(Ze,{size:18})}),E.jsxs("div",{className:"mb-4",children:[E.jsxs("span",{className:"text-xs font-bold text-blue-600 uppercase tracking-wider",children:["Step ",i+1," of ",l.length]}),E.jsx("h3",{className:"text-lg font-bold text-gray-900 mt-1",children:l[i].title}),E.jsx("p",{className:"text-sm text-gray-600 mt-2 leading-relaxed",children:l[i].content})]}),E.jsxs("div",{className:"flex items-center justify-between mt-6",children:[E.jsxs("button",{onClick:o,disabled:i===0,className:`flex items-center gap-1 text-sm font-medium ${i===0?"text-gray-300 cursor-not-allowed":"text-gray-600 hover:text-gray-900"}`,children:[E.jsx(Nt,{size:16}),a.guide.prev]}),E.jsxs("button",{onClick:p,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:[i===l.length-1?a.guide.finish:a.guide.next,i<l.length-1&&E.jsx(Tt,{size:16})]})]})]})]})}const Yt=6;function Ha(){const{user:e,initializing:r}=Ct(),{t:a}=_e(),[i,t]=H.useState([]),[n,s]=H.useState(null),[l,m]=H.useState(null),[p,o]=H.useState(!1),[u,c]=H.useState(!1),[f,y]=H.useState(!1),[C,k]=H.useState(1),[b,w]=H.useState(!1),[g,h]=H.useState(!1),[S,d]=H.useState(320),[I,x]=H.useState(!1),[A,_]=H.useState(!1),R=H.useRef(null),T=H.useRef({}),M=H.useRef(null),N=H.useRef({}),U=H.useRef(!1),j=i.find(O=>O.id===n)||null;H.useEffect(()=>{const O=()=>c(!0);return window.addEventListener("start-user-guide",O),localStorage.getItem("hasSeenGuide")||(setTimeout(()=>c(!0),1500),localStorage.setItem("hasSeenGuide","true")),()=>window.removeEventListener("start-user-guide",O)},[]),H.useEffect(()=>{!r&&e&&!U.current&&(U.current=!0,D()),e||(U.current=!1,t([]),s(null),k(1),w(!1))},[r,e]),H.useEffect(()=>{M.current=n,n?z(n):m(null)},[n]),H.useEffect(()=>()=>{Object.values(T.current).forEach(clearInterval),T.current={}},[]),H.useEffect(()=>{const O=B=>{var Q;if(p)return;const G=(Q=B.clipboardData)==null?void 0:Q.items;if(!G)return;const Z=[];for(let X=0;X<G.length;X++)if(G[X].type.startsWith("image/")||G[X].type==="application/pdf"){const K=G[X].getAsFile();K&&Z.push(K)}Z.length>0&&V(Z)};return document.addEventListener("paste",O),()=>document.removeEventListener("paste",O)},[e,p]);const v=H.useCallback(O=>{O.preventDefault(),x(!0)},[]),P=H.useCallback(()=>{x(!1)},[]),L=H.useCallback(O=>{if(I){const B=O.clientX;B>=280&&B<=400&&d(B)}},[I]);H.useEffect(()=>(window.addEventListener("mousemove",L),window.addEventListener("mouseup",P),()=>{window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",P)}),[L,P]);const $=O=>{const B={[we.Pending]:"pending",[we.Processing]:"processing",[we.Completed]:"completed",[we.Failed]:"failed"};return{id:O.task_id,user_id:(e==null?void 0:e.id)||null,filename:O.file_name,file_path:O.origin_url,file_type:"image/jpeg",file_size:0,thumbnail_path:null,status:B[O.status]||"pending",created_at:O.created_at,updated_at:O.created_at}},q=O=>({id:O.task_id,file_id:O.task_id,markdown_content:O.markdown,latex_content:O.latex,mathml_content:O.mathml,mathml_word_content:O.mathml_mw,rendered_image_path:O.image_blob||null,created_at:O.created_at}),D=async()=>{if(e){y(!0);try{const O=await ze.getTaskList("FORMULA",1,Yt),B=O.task_list||[],G=O.total||0;if(k(1),w(B.length<G),B.length>0){const Z=B.map($);t(Z),B.forEach(Q=>{Q.status===we.Completed&&(N.current[Q.task_id]=q(Q))}),n||s(Z[0].id)}else t([])}catch(O){console.error("Error loading files:",O),t([])}finally{y(!1)}}},W=async()=>{if(!(!e||g||!b)){h(!0);try{const O=C+1,B=await ze.getTaskList("FORMULA",O,Yt),G=B.task_list||[],Z=B.total||0;if(G.length>0){const Q=G.map($);t(X=>{const K=[...X,...Q];return w(K.length<Z),K}),G.forEach(X=>{X.status===we.Completed&&(N.current[X.task_id]=q(X))}),k(O)}else w(!1)}catch(O){console.error("Error loading more files:",O)}finally{h(!1)}}},z=async O=>{try{const B=N.current[O];if(B){m(B);return}try{const G=await ze.getTaskResult(O);if(G.status===we.Completed){const Z={id:O,file_id:O,markdown_content:G.markdown,latex_content:G.latex,mathml_content:G.mathml,mathml_word_content:G.mathml_mw,rendered_image_path:G.image_blob||null,created_at:new Date().toISOString()};N.current[O]=Z,m(Z)}else m(null)}catch{m(null)}}catch(B){console.error("Error loading result:",B),m(null)}},F=(O,B)=>{if(T.current[O])return;let G=0;const Z=30;T.current[O]=setInterval(async()=>{G++;try{const Q=await ze.getTaskResult(O);if(t(X=>X.map(K=>{if(K.id===B){let ce="processing";return Q.status===we.Completed?ce="completed":Q.status===we.Failed&&(ce="failed"),{...K,status:ce}}return K})),Q.status===we.Completed||Q.status===we.Failed){if(clearInterval(T.current[O]),delete T.current[O],Q.status===we.Completed){const X={id:B,file_id:B,markdown_content:Q.markdown,latex_content:Q.latex,mathml_content:Q.mathml,mathml_word_content:Q.mathml_mw,rendered_image_path:Q.image_blob||null,created_at:new Date().toISOString()};N.current[B]=X,M.current===B&&m(X)}}else G>=Z&&(clearInterval(T.current[O]),delete T.current[O],t(X=>X.map(K=>K.id===B?{...K,status:"failed"}:K)),alert(a.alerts.taskTimeout))}catch(Q){console.error("Polling error:",Q),G>=Z&&(clearInterval(T.current[O]),delete T.current[O],t(X=>X.map(K=>K.id===B?{...K,status:"failed"}:K)),alert(a.alerts.networkError))}},2e3)},V=async O=>{y(!0);try{for(const B of O){const G=await ze.calculateMD5(B),Z=await ze.uploadFile(B),Q=await ze.createRecognitionTask(Z.path,G,B.name),X=Q.task_no||crypto.randomUUID(),K={id:X,user_id:(e==null?void 0:e.id)||null,filename:B.name,file_path:URL.createObjectURL(B),file_type:B.type,file_size:B.size,thumbnail_path:null,status:"processing",created_at:new Date().toISOString(),updated_at:new Date().toISOString()};t(ce=>[K,...ce]),s(K.id),Q.task_no&&F(Q.task_no,X)}}catch(B){console.error("Error uploading files:",B),alert(`${a.alerts.uploadFailed}: `+(B instanceof Error?B.message:"Unknown error"))}finally{y(!1)}};return r?E.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:E.jsxs("div",{className:"text-center",children:[E.jsx("div",{className:"w-16 h-16 border-4 border-blue-600 border-t-transparent rounded-full animate-spin mx-auto mb-4"}),E.jsx("p",{className:"text-gray-600",children:a.common.loading})]})}):E.jsxs("div",{className:"h-screen flex flex-col bg-gray-50 font-sans text-gray-900 overflow-hidden",children:[E.jsx(Cn,{}),E.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[E.jsxs("div",{ref:R,className:"flex-shrink-0 bg-white border-r border-gray-200 relative transition-all duration-300 ease-in-out",style:{width:A?64:S},children:[E.jsx(jn,{files:i,selectedFileId:n,onFileSelect:s,onUploadClick:()=>o(!0),isCollapsed:A,onToggleCollapse:()=>_(!A),onUploadFiles:V,hasMore:b,loadingMore:g,onLoadMore:W}),!A&&E.jsx("div",{className:"absolute right-0 top-0 w-1 h-full cursor-col-resize hover:bg-blue-400 z-50 opacity-0 hover:opacity-100 transition-opacity",onMouseDown:v})]}),E.jsx("div",{className:"flex-1 flex min-w-0 flex-col bg-gray-100/50",children:E.jsx(kn,{file:j})}),E.jsx("div",{className:"flex-1 flex min-w-0 flex-col bg-white",children:E.jsx(za,{result:l,fileStatus:j==null?void 0:j.status})}),p&&E.jsx(Oa,{onClose:()=>o(!1),onUpload:V}),E.jsx(Da,{isOpen:u,onClose:()=>c(!1)}),f&&E.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-30 flex items-center justify-center z-50",children:E.jsxs("div",{className:"bg-white rounded-xl shadow-xl p-8",children:[E.jsx("div",{className:"w-16 h-16 border-4 border-blue-600 border-t-transparent rounded-full animate-spin mx-auto mb-4"}),E.jsx("p",{className:"text-gray-900 font-medium",children:a.common.processing})]})})]}),E.jsx("div",{className:"flex-shrink-0 bg-white border-t border-gray-200 py-2 px-4 text-center",children:E.jsx("a",{href:"https://beian.miit.gov.cn",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-gray-500 hover:text-gray-700 transition-colors",children:"京ICP备2025152973号"})})]})}Jt(document.getElementById("root")).render(E.jsx(H.StrictMode,{children:E.jsx(Gr,{children:E.jsx(Kr,{children:E.jsx(Ha,{})})})}));