texlite 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/DESIGN.md +7 -0
  2. package/OPERATIONS.md +70 -3
  3. package/README.md +5 -0
  4. package/README.zh-CN.md +5 -0
  5. package/THIRD_PARTY_NOTICES.md +29 -0
  6. package/dist/client/assets/{AdminUsers-3CHb5012.js → AdminUsers-Buf5ZclR.js} +1 -1
  7. package/dist/client/assets/{CitationLibraryDialog-zPpsUhWJ.js → CitationLibraryDialog-DrKbIlD-.js} +1 -1
  8. package/dist/client/assets/Dashboard-DLk2j3oq.js +2 -0
  9. package/dist/client/assets/GitDialog-CTWAU8q6.js +3 -0
  10. package/dist/client/assets/HistoryDialog-Mo4p8HEg.js +7 -0
  11. package/dist/client/assets/LatexEditor-CwvakYva.js +135 -0
  12. package/dist/client/assets/{PdfPreview-BFVNczSk.js → PdfPreview-BUpELZd-.js} +1 -1
  13. package/dist/client/assets/{ProjectIconPickerDialog-Cf0zBf8u.js → ProjectIconPickerDialog-BiWSwDdt.js} +1 -1
  14. package/dist/client/assets/{ProjectNavigationDialogs-TPbe11iR.js → ProjectNavigationDialogs-CpjkXZTz.js} +1 -1
  15. package/dist/client/assets/{ProjectSettings-CDQvIlQ4.js → ProjectSettings-DoxitHbX.js} +1 -1
  16. package/dist/client/assets/ProjectWorkspace-iNqXZlsj.js +29 -0
  17. package/dist/client/assets/SelectionHistoryDialog-9FWlc3Rb.js +3 -0
  18. package/dist/client/assets/{SystemMetricsDialog-CuqHPUnn.js → SystemMetricsDialog-24kifZO6.js} +1 -1
  19. package/dist/client/assets/TagManagementDialog-BHIA0vEA.js +1 -0
  20. package/dist/client/assets/{WordCountDialog-B4PI0vEk.js → WordCountDialog-DFIWvLrP.js} +1 -1
  21. package/dist/client/assets/check-C3GZh6a1.js +1 -0
  22. package/dist/client/assets/chevron-left-l1oupvGO.js +1 -0
  23. package/dist/client/assets/editor-3rgn4IYh.js +14 -0
  24. package/dist/client/assets/{hard-drive-6uYFyezl.js → hard-drive-B-NSDVVA.js} +1 -1
  25. package/dist/client/assets/{index-BRT5O-Hg.js → index-CNTGCh7t.js} +1 -1
  26. package/dist/client/assets/index-CrlfruX_.css +1 -0
  27. package/dist/client/assets/index-DIM_KiG2.js +12 -0
  28. package/dist/client/assets/katex-D9PXdmFF.css +1 -0
  29. package/dist/client/assets/{key-round-DOAxDSfz.js → key-round-BjL9H8-H.js} +1 -1
  30. package/dist/client/assets/{latexFormatterWorker-DYkYtcFy.js → latexFormatterWorker-BRmsns8a.js} +2 -2
  31. package/dist/client/assets/minimize-2-DDCq8c49.js +1 -0
  32. package/dist/client/assets/{minus-9eVJnugf.js → minus-DgKZCT9F.js} +1 -1
  33. package/dist/client/assets/{pdf-BB1XvBIF.js → pdf-DUYcbPMK.js} +1 -1
  34. package/dist/client/assets/{plus-BGXipRoG.js → plus-CezUzSIZ.js} +1 -1
  35. package/dist/client/assets/{refresh-cw-Dvp3O90f.js → refresh-cw-CDFNL-qu.js} +1 -1
  36. package/dist/client/assets/{search-b1ORp1k8.js → search-CrDJjHoj.js} +1 -1
  37. package/dist/client/assets/{sigma-Bk0_MzWi.js → sigma-DOcJr7VG.js} +1 -1
  38. package/dist/client/assets/spellCheck-BgWyesvf.js +1 -0
  39. package/dist/client/assets/{tags-JAkbmWns.js → tags-BedQ75lh.js} +1 -1
  40. package/dist/client/assets/{type-CE2DYkPH.js → type-glZNdzZR.js} +1 -1
  41. package/dist/client/assets/{user-plus-CKalKSsw.js → user-plus-gQ6q5Nom.js} +1 -1
  42. package/dist/client/assets/{x-Bq29njHL.js → x-CSzFikn2.js} +1 -1
  43. package/dist/client/index.html +6 -4
  44. package/dist/server/app.js +130 -83
  45. package/dist/server/cli.js +4 -2
  46. package/dist/server/compileArtifacts.js +3 -2
  47. package/dist/server/config.js +27 -0
  48. package/dist/server/harper.js +205 -8
  49. package/dist/server/history.js +53 -3
  50. package/dist/server/i18n.js +8 -0
  51. package/dist/server/index.js +4 -2
  52. package/dist/server/instanceLock.js +4 -2
  53. package/dist/server/latexCompletion.js +126 -63
  54. package/dist/server/latexDocumentGraph.js +106 -0
  55. package/dist/server/latexSpellMask.js +196 -43
  56. package/dist/server/pm2.js +3 -2
  57. package/dist/server/projectReferences.js +109 -0
  58. package/dist/server/routes/auth.js +5 -2
  59. package/dist/server/routes/comments.js +13 -1
  60. package/dist/server/routes/compile.js +2 -2
  61. package/dist/server/routes/projectFiles.js +12 -3
  62. package/dist/server/routes/projectHistory.js +13 -1
  63. package/dist/server/routes/projectReferences.js +36 -0
  64. package/dist/server/routes/projects.js +41 -4
  65. package/dist/server/routes/system.js +1 -0
  66. package/dist/server/zip.js +2 -16
  67. package/dist/shared/basePath.js +44 -0
  68. package/dist/shared/bibtexReferences.js +135 -0
  69. package/dist/shared/latexCommandSnippets.js +91 -0
  70. package/dist/shared/latexDependencies.js +71 -0
  71. package/dist/shared/latexLiterals.js +215 -0
  72. package/dist/shared/latexReferenceCommands.js +75 -0
  73. package/dist/shared/latexReferences.js +193 -0
  74. package/dist/shared/latexRoot.js +21 -0
  75. package/dist/shared/latexScanner.js +183 -0
  76. package/dist/shared/writingChecks.js +4 -0
  77. package/package.json +11 -4
  78. package/texlite.config.example.json +2 -4
  79. package/dist/client/assets/Dashboard-CWfSLzD3.js +0 -2
  80. package/dist/client/assets/GitDialog-BUU2U_LV.js +0 -3
  81. package/dist/client/assets/HistoryDialog-B6aopsrw.js +0 -7
  82. package/dist/client/assets/LatexEditor-CM445Tk0.js +0 -65
  83. package/dist/client/assets/ProjectWorkspace-C6GrvKN6.js +0 -27
  84. package/dist/client/assets/SelectionHistoryDialog-CyE0_YDs.js +0 -3
  85. package/dist/client/assets/TagManagementDialog-gRLM3lLx.js +0 -1
  86. package/dist/client/assets/check-BXvzrdoz.js +0 -1
  87. package/dist/client/assets/chevron-left-BB5MYb7g.js +0 -1
  88. package/dist/client/assets/editor-CiK7TK0p.js +0 -14
  89. package/dist/client/assets/index-C0t11tlT.js +0 -14
  90. package/dist/client/assets/index-DXWp2bzM.css +0 -1
  91. package/dist/client/assets/katex-CEK31ho9.css +0 -1
  92. package/dist/client/assets/minimize-2-BWtbag2I.js +0 -1
  93. package/dist/client/assets/spellCheck-BJjWgnef.js +0 -1
@@ -0,0 +1,7 @@
1
+ import{u as Ae,r as o,j as e}from"./react-BVUjbTTn.js";import{c as Pe,g as _,M as Me,d as le,C as be,A as ve}from"./index-DIM_KiG2.js";import{d as He,C as Ne}from"./index-CNTGCh7t.js";import{H as Be,F as Ve}from"./hard-drive-B-NSDVVA.js";import{T as Ce,d as _e}from"./x-CSzFikn2.js";import{F as we,R as $e,S as Ie,u as Oe}from"./ProjectWorkspace-iNqXZlsj.js";import{M as Ue,a as We}from"./minus-DgKZCT9F.js";import{P as Ye}from"./plus-CezUzSIZ.js";import{M as qe}from"./minimize-2-DDCq8c49.js";import"./check-C3GZh6a1.js";import"./search-CrDJjHoj.js";import"./user-plus-gQ6q5Nom.js";import"./refresh-cw-CDFNL-qu.js";const Ge=Pe("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);function Se(i,c,C,y="历史版本",s="当前版本",f=3){const S=c.replace(/\r\n/g,`
2
+ `),R=C.replace(/\r\n/g,`
3
+ `);if(S===R)return{diffText:"",additions:0,deletions:0,hasChanges:!1};const h=new He,k=h.diff_linesToChars_(S,R),x=h.diff_main(k.chars1,k.chars2,!1);h.diff_charsToLines_(x,k.lineArray);const w=[];let n=1,T=1,m=0,z=0;for(const[d,v]of x){if(!v)continue;const u=v.split(`
4
+ `);u[u.length-1]===""&&u.pop();for(const P of u)d===0?w.push({op:0,text:P,oldNum:n++,newNum:T++}):d===-1?(z++,w.push({op:-1,text:P,oldNum:n++,newNum:T})):d===1&&(m++,w.push({op:1,text:P,oldNum:n,newNum:T++}))}if(m===0&&z===0)return{diffText:"",additions:0,deletions:0,hasChanges:!1};const j=[];let b=-1,A=-1;for(let d=0;d<w.length;d++)if(w[d].op!==0){const v=Math.max(0,d-f),u=Math.min(w.length-1,d+f);b===-1?(b=v,A=u):v<=A+1?A=Math.max(A,u):(j.push({start:b,end:A}),b=v,A=u)}b!==-1&&j.push({start:b,end:A});const G=[`--- a/${i} (${y})`,`+++ b/${i} (${s})`];for(const d of j){const v=w.slice(d.start,d.end+1),u=v.filter($=>$.op<=0).length,P=v.filter($=>$.op>=0).length,E=v[0],O=u===0?0:E.oldNum,J=P===0?0:E.newNum;G.push(`@@ -${O},${u} +${J},${P} @@`);for(const $ of v){const U=$.op===-1?"-":$.op===1?"+":" ";G.push(`${U}${$.text}`)}}return{diffText:G.join(`
5
+ `),additions:m,deletions:z,hasChanges:!0}}function ue(i,c){try{const C=new Date(i);if(Number.isNaN(C.getTime()))return i;const y=new Date;return C.getFullYear()===y.getFullYear()&&C.getMonth()===y.getMonth()&&C.getDate()===y.getDate()?C.toLocaleTimeString(c,{hour:"2-digit",minute:"2-digit"}):C.toLocaleString(c,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return i}}function he(i,c,C){if(i.label)return i.label;const y=ue(i.createdAt,C);if(i.changedPaths.length===1)return`${i.changedPaths[0].split("/").pop()||i.changedPaths[0]} (${y})`;if(i.changedPaths.length===2){const f=i.changedPaths[0].split("/").pop()||i.changedPaths[0],S=i.changedPaths[1].split("/").pop()||i.changedPaths[1];return`${f}, ${S} (${y})`}if(i.changedPaths.length>2)return`${i.changedPaths[0].split("/").pop()||i.changedPaths[0]} +${i.changedPaths.length-1} (${y})`;const s=i.author?.name||i.author?.username;return s?`${s} @ ${y}`:`${c} (${y})`}const Te=100;function lt({open:i,project:c,onOpenChange:C,onBeforeMutation:y}){const{t:s,i18n:f}=Ae(),[S,R]=o.useState([]),[h,k]=o.useState(null),[x,w]=o.useState(""),[n,T]=o.useState(null),[m,z]=o.useState(""),[j,b]=o.useState(null),[A,G]=o.useState(0),[d,v]=o.useState("commit"),[u,P]=o.useState(11),[E,O]=o.useState(!1),[J,$]=o.useState(""),[U,te]=o.useState(null),[M,se]=o.useState(null),[K,p]=o.useState(""),[fe,re]=o.useState(null),[Z,ie]=o.useState(!1),[me,g]=o.useState(""),ce=o.useRef(null),F=o.useRef(null),L=o.useRef(null),pe=o.useRef(x),ge=o.useRef(c.id),ne=o.useRef(!1),H=o.useRef(null);pe.current=x,ge.current=c.id;const oe=c.permission!=="read",de=c.permission==="owner",W=!!K||Z;o.useEffect(()=>{if(!i){L.current?.abort(),L.current=null,H.current!==null&&window.clearTimeout(H.current),H.current=null,F.current?.abort(),F.current=null,ie(!1),document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),O(!1);return}F.current?.abort(),F.current=null;const t=new AbortController;return p("load"),g(""),b(null),re(null),ie(!1),_(`/api/projects/${c.id}/history?limit=${Te}`,{signal:t.signal}).then(r=>{R(r.versions),k(r.stats),re(r.nextCursor),w(a=>r.versions.some(l=>l.id===a)?a:r.versions[0]?.id??"")}).catch(r=>{q(r)||g(I(r))}).finally(()=>{t.signal.aborted||p("")}),()=>t.abort()},[i,c.id]),o.useEffect(()=>()=>{F.current?.abort(),F.current=null,L.current?.abort(),L.current=null,H.current!==null&&window.clearTimeout(H.current)},[c.id]),o.useEffect(()=>{L.current?.abort(),L.current=null},[x]);const Ee=async()=>{const t=fe;if(!t||Z||K)return;F.current?.abort();const r=new AbortController;F.current=r,ie(!0),g("");try{const a=new URLSearchParams({limit:String(Te),before:t}),l=await _(`/api/projects/${c.id}/history?${a.toString()}`,{signal:r.signal});if(r.signal.aborted)return;R(N=>{const V=new Set(N.map(D=>D.id));return[...N,...l.versions.filter(D=>!V.has(D.id))]}),k(l.stats),re(l.nextCursor)}catch(a){q(a)||g(I(a))}finally{F.current===r&&(F.current=null,ie(!1))}};o.useEffect(()=>{const t=()=>O(document.fullscreenElement===ce.current);return document.addEventListener("fullscreenchange",t),()=>document.removeEventListener("fullscreenchange",t)},[]),o.useEffect(()=>{if(!E)return;const t=r=>{r.key==="Escape"&&!document.fullscreenElement&&O(!1)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[E]),o.useEffect(()=>{if(!i||!x){T(null);return}const t=new AbortController;return p("detail"),b(null),_(`/api/projects/${c.id}/history/${x}`,{signal:t.signal}).then(r=>{T(r),$(r.version.label??"");const a=r.version.changedPaths.find(l=>r.files.some(N=>N.path===l))??"";z(a)}).catch(r=>{q(r)||g(I(r))}).finally(()=>{t.signal.aborted||p("")}),()=>t.abort()},[i,c.id,x]);const Y=j?.previousVersion??null;o.useEffect(()=>{if(!i||!x||!m){ne.current=!1,b(null);return}const t=new AbortController;p("compare");const r=ne.current;ne.current=!1,r||g("");const a=d==="commit"?"&against=__previous__":"";return _(`/api/projects/${c.id}/history/${x}/file?path=${encodeURIComponent(m)}${a}`,{signal:t.signal}).then(l=>{b(l)}).catch(l=>{q(l)||g(I(l))}).finally(()=>{t.signal.aborted||p(l=>l==="compare"?"":l)}),()=>t.abort()},[i,c.id,x,m,d,A]);const B=o.useMemo(()=>{if(!n)return[];const t=new Set(n.version.changedPaths);return n.files.filter(r=>t.has(r.path))},[n]);o.useEffect(()=>{B.length>0&&!B.some(t=>t.path===m)?z(B[0].path):B.length===0&&m&&z("")},[B,m]);const Fe=async()=>{if(E){document.fullscreenElement&&await document.exitFullscreen().catch(()=>{}),O(!1);return}const t=ce.current;if(t?.requestFullscreen)try{await t.requestFullscreen()}catch{}O(!0)},ye=async(t,r=!1)=>{const a=c.id;L.current?.abort();const l=new AbortController;L.current=l;try{const N=await _(`/api/projects/${a}/history/${t}`,{signal:l.signal});return l.signal.aborted||ge.current!==a||pe.current!==t?!1:(T(N),$(N.version.label??""),z(V=>V&&N.files.some(D=>D.path===V)?V:N.version.changedPaths.find(D=>N.files.some(ze=>ze.path===D))??""),b(null),r&&(ne.current=!0),G(V=>V+1),R(V=>V.map(D=>D.id===N.version.id?N.version:D)),!0)}finally{L.current===l&&(L.current=null)}},Le=async()=>{if(n){p("label"),g("");try{const t=await _(`/api/projects/${c.id}/history/${n.version.id}`,{method:"PATCH",body:JSON.stringify({label:J.trim()||null,snapshotHash:n.version.snapshotHash})});T(r=>r&&{...r,version:t.version}),R(r=>r.map(a=>a.id===t.version.id?t.version:a)),k(t.stats),t.retentionScheduled&&(H.current!==null&&window.clearTimeout(H.current),H.current=window.setTimeout(()=>{H.current=null,_(`/api/projects/${c.id}/history?limit=1`).then(r=>{k(r.stats)}).catch(()=>{})},t.retentionRefreshAfterMs))}catch(t){if(t instanceof ve&&t.code==="HISTORY_VERSION_CHANGED")try{if(!await ye(n.version.id,!0))return}catch(r){if(q(r))return;g(I(r));return}g(I(t))}finally{p("")}}},De=async()=>{const t=M;if(t){se(null),p("delete"),g("");try{if(!await y())throw new Error(s("errors.collaborationUnavailable"));const r=t==="all"?`/api/projects/${c.id}/history`:`/api/projects/${c.id}/history/${t.id}`,a=await _(r,{method:"DELETE"});if(k(a.stats),t==="all")R([]),w(""),T(null),b(null),re(null);else{const l=S.filter(N=>N.id!==t.id);R(l),x===t.id&&(w(l[0]?.id??""),T(null),b(null))}}catch(r){g(I(r))}finally{p("")}}},Re=async()=>{const t=U;if(!(!t||!n)){te(null),p("restore"),g("");try{if(!await y())throw new Error(s("errors.collaborationUnavailable"));await _(`/api/projects/${c.id}/history/${n.version.id}/restore`,{method:"POST",body:JSON.stringify(t==="project"?{snapshotHash:n.version.snapshotHash}:{path:t,snapshotHash:n.version.snapshotHash})}),window.location.reload()}catch(r){if(r instanceof ve&&r.code==="HISTORY_VERSION_CHANGED")try{if(!await ye(n.version.id,!0)){p("");return}}catch(a){if(q(a)){p("");return}g(I(a)),p("");return}g(I(r)),p("")}}},ae=n?.version.author?.name||n?.version.author?.username||(n?.version.reason==="autosave"?s("history.reasons.autosave"):s("editor.deletedUser")),Q=n?ue(n.version.createdAt,f.resolvedLanguage):"",X=o.useMemo(()=>{if(!j||!n)return{diffText:"",additions:0,deletions:0,hasChanges:!1};if(d==="commit"){const t=j.comparison,r=j.historical,a=Y?`${Y.label||s(`history.reasons.${Y.reason}`)} (${ue(Y.createdAt,f.resolvedLanguage)})`:"/dev/null",l=`${ae} @ ${Q}`;return Se(j.path,t,r,a,l)}else{const t=j.historical,r=j.comparison,a=`${n.version.label||s(`history.reasons.${n.version.reason}`)} (${Q})`,l=s("history.currentVersion");return Se(j.path,t,r,a,l)}},[j,n,d,Y,ae,Q,s,f.resolvedLanguage]),xe=n?s(`history.reasons.${n.version.reason}`):"",je=n?he(n.version,xe,f.resolvedLanguage):"",ke=M&&M!=="all"?he(M,s(`history.reasons.${M.reason}`),f.resolvedLanguage):"";return e.jsxs(e.Fragment,{children:[e.jsx(Me,{open:i,extraWide:!0,draggable:!0,className:"history-dialog-modal",title:s("history.projectSnapshots"),description:s("history.description"),onOpenChange:C,footer:e.jsx("button",{onClick:()=>C(!1),children:s("common.close")}),children:e.jsxs("div",{className:"history-dialog",children:[me&&e.jsx("p",{className:"error history-message",children:me}),K==="load"&&S.length===0?e.jsxs("div",{className:"history-loading",children:[e.jsx(le,{className:"spin",size:22}),s("common.loading")]}):e.jsxs("div",{className:"history-dialog-layout",children:[e.jsxs("aside",{className:"history-timeline",children:[de&&h&&e.jsxs("div",{className:`history-stats${h.storageLimitExceeded?" exceeded":""}`,children:[e.jsxs("header",{children:[e.jsxs("span",{children:[e.jsx(Be,{size:14}),s("history.storage")]}),e.jsx("button",{type:"button",disabled:W||S.length===0,title:s("history.clearAll"),"aria-label":s("history.clearAll"),onClick:()=>se("all"),children:e.jsx(Ce,{size:13})})]}),e.jsx("strong",{children:s("history.storageUsage",{used:ee(h.totalBytes),limit:ee(h.maxStorageBytes)})}),e.jsx("progress",{max:h.maxStorageBytes,value:Math.min(h.totalBytes,h.maxStorageBytes)}),e.jsx("small",{children:s("history.storageBreakdown",{objects:ee(h.objectBytes),metadata:ee(h.metadataBytes),protected:ee(h.protectedBytes)})}),e.jsxs("small",{children:[s("history.versionUsage",{count:h.ordinaryVersionCount,limit:h.maxVersions>0?h.maxVersions:"∞"}),h.labeledVersionCount>0?` · ${s("history.protectedVersions",{count:h.labeledVersionCount})}`:""]}),h.storageLimitExceeded&&e.jsx("small",{className:"history-storage-warning",children:s("history.storageExceeded")})]}),S.map(t=>{const r=s(`history.reasons.${t.reason}`),a=he(t,r,f.resolvedLanguage),l=t.author?.name||t.author?.username||(t.reason==="autosave"?s("history.reasons.autosave"):s("editor.deletedUser"));return e.jsxs("button",{className:t.id===x?"active":"",onClick:()=>w(t.id),children:[e.jsx(we,{size:15}),e.jsxs("span",{children:[e.jsxs("div",{className:"history-item-heading",children:[e.jsx("strong",{title:a,children:a}),e.jsx("span",{className:`history-reason-badge reason-${t.reason}`,children:r})]}),e.jsx("small",{children:new Date(t.createdAt).toLocaleString(f.resolvedLanguage)}),e.jsxs("small",{children:[l," · ",s("history.changedCount",{count:t.changedPaths.length})]})]})]},t.id)}),fe&&e.jsx("div",{className:"history-load-more",children:e.jsxs("button",{type:"button",disabled:W,"aria-busy":Z,onClick:()=>{Ee()},children:[Z?e.jsx(le,{className:"spin",size:13}):e.jsx(Ne,{size:13}),s(Z?"common.loading":"history.loadOlder")]})}),S.length===0&&e.jsx("p",{className:"muted padded",children:s("history.empty")})]}),e.jsx("section",{className:"history-detail",children:n&&e.jsxs(e.Fragment,{children:[e.jsx("header",{className:"history-detail-header",children:e.jsxs("div",{children:[e.jsxs("div",{className:"history-detail-title-row",children:[e.jsx("strong",{title:je,children:je}),e.jsx("span",{className:`history-reason-badge reason-${n.version.reason}`,children:xe})]}),e.jsxs("small",{children:[e.jsx(Ne,{size:12}),new Date(n.version.createdAt).toLocaleString(f.resolvedLanguage)," · ",ae," · ",s("history.fileCount",{count:n.version.fileCount})]})]})}),(de||oe)&&e.jsxs("div",{className:"history-snapshot-actions",children:[de&&e.jsxs("button",{type:"button",className:"history-delete-action",disabled:W,title:s("history.deleteVersionTitle"),onClick:()=>se(n.version),children:[e.jsx(Ce,{size:14}),s("history.deleteVersion")]}),oe&&e.jsxs("button",{type:"button",className:"history-restore-project",disabled:W,title:s("history.restoreProjectTitle"),onClick:()=>te("project"),children:[e.jsx($e,{size:14}),s("history.restoreProject")]})]}),oe&&e.jsxs("div",{className:"history-label",children:[e.jsxs("label",{children:[e.jsx(Ge,{size:14}),e.jsx("input",{value:J,maxLength:80,placeholder:s("history.labelPlaceholder"),onChange:t=>$(t.target.value)})]}),e.jsxs("button",{disabled:W||J.trim()===(n.version.label??""),onClick:()=>{Le()},children:[K==="label"?e.jsx(le,{className:"spin",size:13}):e.jsx(Ie,{size:13}),s("history.saveLabel")]})]}),e.jsxs("div",{className:"history-files",children:[e.jsx("div",{className:"history-files-toolbar",children:e.jsxs("div",{className:"history-files-heading",children:[e.jsx(Ve,{size:13}),e.jsx("span",{children:s("history.changedFilesHeading",{count:B.length})})]})}),B.length>0?e.jsxs("div",{className:"history-file-tabs-row",children:[e.jsx("div",{className:"history-file-list",children:B.map(t=>e.jsxs("button",{type:"button",className:t.path===m?"active":"",title:t.path,onClick:()=>z(t.path),children:[e.jsx(_e,{size:13}),e.jsx("span",{children:t.path})]},t.path))}),oe&&e.jsx("div",{className:"history-file-actions",children:e.jsxs("button",{type:"button",disabled:!m||W,title:s("history.restoreFileTitle"),onClick:()=>te(m),children:[e.jsx($e,{size:13}),s("history.restoreFile")]})})]}):e.jsx("p",{className:"muted padded-small",children:s("history.noChangedFiles")})]}),e.jsx("div",{ref:ce,className:`history-comparison${E?" is-fullscreen":""}`,children:m?e.jsxs(e.Fragment,{children:[e.jsxs("header",{children:[e.jsxs("div",{className:"history-comparison-meta",children:[e.jsx("strong",{children:m}),e.jsxs("small",{className:"history-commit-summary",children:[d==="commit"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"history-commit-author",children:ae}),e.jsx("span",{children:Y?s("history.changedAt",{time:Q}):s("history.createdAt",{time:Q})})]}):e.jsx("span",{children:s("history.comparingCurrent")}),X.hasChanges&&e.jsxs("span",{className:"history-diff-stats",children:[e.jsxs("span",{className:"addition",children:["+",X.additions]})," ",e.jsxs("span",{className:"deletion",children:["-",X.deletions]})]})]})]}),e.jsxs("div",{className:"history-diff-controls",children:[e.jsx("div",{className:"history-diff-control-group",children:e.jsxs("div",{className:"history-mode-toggle",role:"group","aria-label":s("history.diffMode"),children:[e.jsx("button",{type:"button",className:d==="commit"?"active":"","aria-pressed":d==="commit",onClick:()=>v("commit"),title:s("history.diffModeCommitHint"),children:e.jsx("span",{children:s("history.diffModeCommit")})}),e.jsx("button",{type:"button",className:d==="current"?"active":"","aria-pressed":d==="current",onClick:()=>v("current"),title:s("history.diffModeCurrentHint"),children:e.jsx("span",{children:s("history.diffModeCurrent")})})]})}),e.jsx("span",{className:"history-diff-control-divider","aria-hidden":"true"}),e.jsx("div",{className:"history-diff-control-group",children:e.jsxs("div",{className:"git-diff-font-controls",role:"group","aria-label":s("git.diffFontSize"),children:[e.jsx("button",{type:"button",className:"git-diff-font-button",disabled:u<=8,title:s("git.diffFontDecrease"),"aria-label":s("git.diffFontDecrease"),onClick:()=>P(t=>Math.max(8,t-1)),children:e.jsx(Ue,{size:14})}),e.jsxs("span",{className:"git-diff-font-value","aria-live":"polite",children:[u,"px"]}),e.jsx("button",{type:"button",className:"git-diff-font-button",disabled:u>=24,title:s("git.diffFontIncrease"),"aria-label":s("git.diffFontIncrease"),onClick:()=>P(t=>Math.min(24,t+1)),children:e.jsx(Ye,{size:14})})]})}),e.jsx("span",{className:"history-diff-control-divider","aria-hidden":"true"}),e.jsx("div",{className:"history-diff-control-group",children:e.jsx("button",{type:"button",className:"git-diff-fullscreen",title:s(E?"git.exitFullscreenDiff":"git.fullscreenDiff"),"aria-label":s(E?"git.exitFullscreenDiff":"git.fullscreenDiff"),onClick:()=>{Fe()},children:E?e.jsx(qe,{size:15}):e.jsx(We,{size:15})})})]})]}),K==="compare"&&!j?e.jsxs("div",{className:"history-comparison-empty",children:[e.jsx(le,{className:"spin",size:24}),e.jsx("span",{children:s("common.loading")})]}):X.hasChanges?e.jsx("pre",{className:"git-diff history-git-diff",style:{fontSize:`${u}px`},children:X.diffText.split(`
6
+ `).map((t,r)=>{const a=t.startsWith("+")&&!t.startsWith("+++")?"addition":t.startsWith("-")&&!t.startsWith("---")?"deletion":t.startsWith("@@")?"hunk":t.startsWith("diff ")||t.startsWith("---")||t.startsWith("+++")?"header":"";return e.jsxs("span",{className:a,children:[t,`
7
+ `]},r)})}):e.jsxs("div",{className:"git-diff-empty history-diff-empty",children:[e.jsx(Oe,{size:24}),e.jsx("span",{children:s(d==="commit"?"history.noDifferencesInCommit":"history.noDifferences")})]})]}):e.jsxs("div",{className:"history-comparison-empty",children:[e.jsx(we,{size:25}),e.jsx("span",{children:B.length===0?s("history.noChangedFiles"):s("history.chooseFile")})]})})]})})]})]})}),e.jsx(be,{open:!!U,title:s(U==="project"?"history.restoreProjectTitle":"history.restoreFileTitle"),description:U==="project"?s("history.restoreProjectDescription"):s("history.restoreFileDescription",{path:U??""}),confirmLabel:s("history.restore"),danger:!0,onCancel:()=>te(null),onConfirm:()=>{Re()}}),e.jsx(be,{open:!!M,title:s(M==="all"?"history.clearAllTitle":"history.deleteVersionTitle"),description:M==="all"?s("history.clearAllDescription"):s("history.deleteVersionDescription",{name:ke}),confirmLabel:s(M==="all"?"history.clearAll":"history.deleteVersion"),danger:!0,onCancel:()=>se(null),onConfirm:()=>{De()}})]})}function ee(i){return i<1024?`${i} B`:i<1024*1024?`${Math.round(i/102.4)/10} KB`:i<1024*1024*1024?`${Math.round(i/(1024*1024)*10)/10} MB`:`${Math.round(i/(1024*1024*1024)*10)/10} GB`}function I(i){return i instanceof Error?i.message:String(i)}function q(i){return i instanceof Error&&i.name==="AbortError"}export{lt as HistoryDialog};