texlite 0.9.4 → 0.11.0

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 (58) hide show
  1. package/DESIGN.md +12 -14
  2. package/OPERATIONS.md +12 -6
  3. package/README.md +70 -41
  4. package/README.zh-CN.md +59 -34
  5. package/dist/client/assets/{AdminUsers-B12FJUMy.js → AdminUsers-BExOMZsW.js} +1 -1
  6. package/dist/client/assets/{CitationLibraryDialog-BTmnCP4V.js → CitationLibraryDialog-tVD3i2gg.js} +1 -1
  7. package/dist/client/assets/Dashboard-DRt4rjKP.js +2 -0
  8. package/dist/client/assets/{GitDialog--MoUIW0n.js → GitDialog-CjDCi1uh.js} +1 -1
  9. package/dist/client/assets/{HistoryDialog-LgKbjsTZ.js → HistoryDialog-Pa9mK3Ky.js} +1 -1
  10. package/dist/client/assets/{LatexEditor-Dj2zIaQm.js → LatexEditor-8r486VeG.js} +2 -2
  11. package/dist/client/assets/PdfPreview-CMkO72I5.js +1 -0
  12. package/dist/client/assets/{ProjectIconPickerDialog-GzRuM0oQ.js → ProjectIconPickerDialog-B52xbSyr.js} +1 -1
  13. package/dist/client/assets/{ProjectNavigationDialogs-BiArHmQ9.js → ProjectNavigationDialogs-isGMXCfG.js} +1 -1
  14. package/dist/client/assets/ProjectSettings-Br_kJ113.js +1 -0
  15. package/dist/client/assets/ProjectWorkspace-CcbrdCy8.js +32 -0
  16. package/dist/client/assets/{SelectionHistoryDialog-Bpv6nvrC.js → SelectionHistoryDialog-ZvAhIJMy.js} +2 -2
  17. package/dist/client/assets/{SystemMetricsDialog-hJQATmd4.js → SystemMetricsDialog-D4ouU4HI.js} +1 -1
  18. package/dist/client/assets/{TagManagementDialog-BHC8qULq.js → TagManagementDialog-qhZfHgTr.js} +1 -1
  19. package/dist/client/assets/{WordCountDialog-DZhhO94k.js → WordCountDialog-tFhMCGyn.js} +1 -1
  20. package/dist/client/assets/check-DKIW1zpR.js +1 -0
  21. package/dist/client/assets/chktex-tM1XXPk2.js +3 -0
  22. package/dist/client/assets/{hard-drive-BWZnOgnm.js → hard-drive-CkIPwUSV.js} +1 -1
  23. package/dist/client/assets/index-90X2GUd_.css +1 -0
  24. package/dist/client/assets/index-CqBmQAzW.js +10 -0
  25. package/dist/client/assets/{index-kTamGfTl.js → index-DTYEGzB7.js} +1 -1
  26. package/dist/client/assets/{key-round-CoDwyVJc.js → key-round-BEnQo7IM.js} +1 -1
  27. package/dist/client/assets/{minimize-2-D100opW2.js → minimize-2-CLuDohEf.js} +1 -1
  28. package/dist/client/assets/{minus-DDTYB-Oz.js → minus-BpuvzV2m.js} +1 -1
  29. package/dist/client/assets/{plus-BVXOlQXP.js → plus-BFr75l91.js} +1 -1
  30. package/dist/client/assets/{refresh-cw-LtwnqlWh.js → refresh-cw-DyA4NKh7.js} +1 -1
  31. package/dist/client/assets/{search-DXo_aAp0.js → search-Nu4OcY_n.js} +1 -1
  32. package/dist/client/assets/{sigma-BgvHGPto.js → sigma-B-wjepsY.js} +1 -1
  33. package/dist/client/assets/{spellCheck-BtRppKcC.js → spellCheck-C-bNJsIU.js} +1 -1
  34. package/dist/client/assets/{tags-m9kppdi0.js → tags-BSA08jK3.js} +1 -1
  35. package/dist/client/assets/{type-YO4aprqE.js → type-BCdIbDmF.js} +1 -1
  36. package/dist/client/assets/{user-plus-MRmKeDtX.js → user-plus-gFwY-NA3.js} +1 -1
  37. package/dist/client/assets/{x-eisRQJv_.js → x-Cspw_pa4.js} +1 -1
  38. package/dist/client/index.html +2 -2
  39. package/dist/server/app.js +8 -0
  40. package/dist/server/chktex.js +377 -0
  41. package/dist/server/collaboration.js +6 -0
  42. package/dist/server/db.js +6 -1
  43. package/dist/server/environment.js +1 -0
  44. package/dist/server/history.js +4 -4
  45. package/dist/server/i18n.js +12 -2
  46. package/dist/server/projectImportUploads.js +133 -0
  47. package/dist/server/routes/projectFiles.js +3 -0
  48. package/dist/server/routes/projectShared.js +1 -0
  49. package/dist/server/routes/projects.js +87 -15
  50. package/dist/shared/writingChecks.js +4 -0
  51. package/package.json +1 -1
  52. package/dist/client/assets/Dashboard-JA5_M3TK.js +0 -2
  53. package/dist/client/assets/PdfPreview-C_W7w360.js +0 -1
  54. package/dist/client/assets/ProjectSettings-DgJohWUv.js +0 -1
  55. package/dist/client/assets/ProjectWorkspace-C6sYiBF2.js +0 -32
  56. package/dist/client/assets/check-C1db8iNn.js +0 -1
  57. package/dist/client/assets/index-BiwJj0Np.css +0 -1
  58. package/dist/client/assets/index-p1NHkGGG.js +0 -12
@@ -0,0 +1 @@
1
+ import{u as Q,r as t,j as e}from"./react-BVUjbTTn.js";import{P as de,g as fe,w as he,G as me}from"./pdf-DUYcbPMK.js";import{M as pe,a as ge}from"./minus-BpuvzV2m.js";import{P as xe}from"./plus-BFr75l91.js";import{d as G}from"./index-CqBmQAzW.js";import{R as J}from"./refresh-cw-DyA4NKh7.js";me.workerSrc=he;const se=new de,re=2,S=new Map;async function Ee(){await se.promise}function ie(i,r){const n=`${r}:${i}`,a=S.get(n);if(a)return a.lastUsed=Date.now(),a;const m=fe({url:i,worker:se,disableRange:r==="full"}),o={task:m,promise:m.promise,consumers:0,settled:!1,retired:!1,lastUsed:Date.now()};return S.set(n,o),o.promise.then(()=>{o.settled=!0,oe()},()=>{o.settled=!0,S.get(n)===o&&S.delete(n),o.retired||(o.retired=!0,o.consumers===0&&o.task.destroy())}),o}function we(i,r){const n=`${r}:${i}`,a=S.get(n);a&&(S.delete(n),a.retired=!0,a.consumers===0&&a.task.destroy())}function oe(){if(S.size<=re)return;const i=[...S.entries()].filter(([,r])=>r.consumers===0&&r.settled).sort((r,n)=>r[1].lastUsed-n[1].lastUsed);for(;S.size>re&&i.length;){const[r,n]=i.shift();S.get(r)===n&&(S.delete(r),n.retired=!0,n.task.destroy())}}function Se(i,r){if(!i)return;ie(i,r).promise.catch(()=>{})}function ye(i,r){const n=ie(i,r);n.consumers+=1,n.lastUsed=Date.now();let a=!1;return{promise:n.promise,release:()=>{a||(a=!0,n.consumers=Math.max(0,n.consumers-1),n.lastUsed=Date.now(),n.retired&&n.consumers===0&&n.task.destroy(),oe())}}}function Ce({url:i,loadingMode:r,target:n,compiling:a=!1,onViewportLocation:m,onDoubleClickLocation:o,onDisplayedUrlChange:U}){const{t:d}=Q(),v=t.useRef(null),[p,$]=t.useState(null),[f,R]=t.useState(""),[k,N]=t.useState(0),[M,C]=t.useState(100),[P,b]=t.useState(""),[y,z]=t.useState(0),j=t.useRef(new Map),D=t.useRef(null),A=t.useRef(null),E=t.useRef(null),L=t.useRef(m);L.current=m;const F=t.useRef(U);F.current=U;const T=t.useRef(0),B=()=>{we(i,r),F.current?.(""),b(""),z(s=>s+1)},W=t.useCallback((s,c)=>{c?j.current.set(s,c):j.current.delete(s)},[]),_=async s=>{if(!p||s==null)return;let c=s;if(typeof s=="string"&&(c=await p.getDestination(s).catch(()=>null)),!Array.isArray(c)||c.length===0)return;const u=c[0];let w=null;if(typeof u=="number"&&Number.isInteger(u))w=u;else if(u!=null)try{w=await p.getPageIndex(u)}catch{return}w==null||w<0||w>=p.numPages||j.current.get(w+1)?.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},l=t.useCallback(()=>{D.current=null;const s=v.current;if(!s)return;const c=s.getBoundingClientRect(),u=c.left+c.width/2,w=c.top+c.height/2,q=[...s.querySelectorAll(".pdf-page")],H=q.find(Y=>{const V=Y.getBoundingClientRect();return w>=V.top&&w<=V.bottom})??q.reduce((Y,V)=>{if(!Y)return V;const ae=Math.abs(V.getBoundingClientRect().top-w),ue=Math.abs(Y.getBoundingClientRect().top-w);return ae<ue?V:Y},null);if(!H)return;const K=H.getBoundingClientRect(),ee=Number(H.dataset.scale)||1,te=Number(H.dataset.page),ce=Math.max(0,Math.min(K.width,u-K.left))/ee,le=Math.max(0,Math.min(K.height,w-K.top))/ee;te&&L.current(te,ce,le)},[]),x=t.useCallback(()=>{D.current===null&&(D.current=window.requestAnimationFrame(l))},[l]);t.useEffect(()=>()=>{D.current!==null&&window.cancelAnimationFrame(D.current),D.current=null},[]),t.useEffect(()=>{const s=v.current;if(!s)return;const c=()=>N(s.clientWidth);c();const u=new ResizeObserver(c);return u.observe(s),()=>u.disconnect()},[]),t.useEffect(()=>{const s=A.current;if(s?.url===i&&s.loadingMode===r&&T.current===y){b("");return}let c=!1;b("");const u=ye(i,r);return E.current=u,u.promise.then(w=>{if(c)return;const q=A.current;A.current={...u,url:i,loadingMode:r},T.current=y,E.current===u&&(E.current=null),$(w),R(i),q?.release()}).catch(()=>{c||(E.current===u&&(E.current=null),u.release(),b(d("editor.pdfLoadFailed")))}),()=>{c=!0,E.current===u&&(E.current=null,u.release())}},[i,r,y,d]),t.useEffect(()=>()=>{F.current?.(""),E.current?.release(),E.current=null,A.current?.release(),A.current=null},[]),t.useEffect(()=>{M>100||!v.current||(v.current.scrollLeft=0)},[M,k,p]);const h=s=>C(c=>Math.min(200,Math.max(50,c+s))),g=()=>{v.current&&(v.current.scrollLeft=0),C(100)},O=s=>{!s.shiftKey||Math.abs(s.deltaX)>Math.abs(s.deltaY)||(s.preventDefault(),s.currentTarget.scrollLeft+=s.deltaY,x())},Z=!!(p&&f!==i&&!P),I=f===i?n:null,X=()=>{f===i&&F.current?.(i),x()};return e.jsxs("div",{className:"pdf-viewer",children:[e.jsxs("div",{className:"pdf-toolbar",role:"toolbar","aria-label":d("editor.pdfZoomControls"),children:[e.jsx("button",{disabled:M<=50,title:d("editor.pdfZoomOut"),"aria-label":d("editor.pdfZoomOut"),onClick:()=>h(-10),children:e.jsx(pe,{size:14})}),e.jsxs("span",{className:"pdf-zoom-value","aria-live":"polite",children:[M,"%"]}),e.jsx("button",{disabled:M>=200,title:d("editor.pdfZoomIn"),"aria-label":d("editor.pdfZoomIn"),onClick:()=>h(10),children:e.jsx(xe,{size:14})}),e.jsxs("button",{className:"pdf-fit-width",title:d("editor.pdfFitWidth"),onClick:g,children:[e.jsx(ge,{size:13}),d("editor.pdfFitWidth")]})]}),a&&e.jsxs("div",{className:"pdf-compiling-overlay",role:"status","aria-live":"polite",children:[e.jsx(G,{className:"spin",size:16}),e.jsx("span",{children:d("editor.compiling")})]}),Z&&!a&&e.jsxs("div",{className:"pdf-loading-overlay",role:"status","aria-live":"polite",children:[e.jsx(G,{className:"spin",size:16}),e.jsx("span",{children:d("editor.loadingPdf")})]}),p&&P&&e.jsxs("div",{className:"pdf-load-error-overlay",role:"status","aria-live":"polite",children:[e.jsx("span",{children:P}),e.jsxs("button",{type:"button",onClick:B,children:[e.jsx(J,{size:13}),d("common.retry")]})]}),e.jsx("div",{className:"pdf-document",ref:v,onScroll:x,onWheel:O,children:e.jsxs("div",{className:"pdf-pages",style:{width:`${Math.max(1,k-28)*Math.max(1,M/100)}px`},children:[!p&&!P&&e.jsxs("div",{className:"pdf-loading",role:"status","aria-live":"polite",children:[e.jsx(G,{className:"spin",size:24}),e.jsx("span",{children:d("editor.loadingPdf")})]}),P&&!p&&e.jsxs("div",{className:"preview-empty",children:[e.jsx("strong",{children:P}),e.jsxs("button",{type:"button",onClick:B,children:[e.jsx(J,{size:14}),d("common.retry")]})]}),p&&k>0&&Array.from({length:p.numPages},(s,c)=>e.jsx(ve,{document:p,pageNumber:c+1,availableWidth:k-28,zoom:M/100,target:I?.page===c+1?I:null,onReady:X,onPageElement:W,onInternalLink:_,onDoubleClickLocation:f===i?o:void 0,onRetryDocument:B},`${f}:${c+1}`))]})})]})}function ve({document:i,pageNumber:r,availableWidth:n,zoom:a,target:m,onReady:o,onPageElement:U,onInternalLink:d,onDoubleClickLocation:v,onRetryDocument:p}){const{t:$}=Q(),f=t.useRef(null),R=t.useRef(null),k=t.useRef(null),[N,M]=t.useState(1),[C,P]=t.useState({width:0,height:0}),[b,y]=t.useState(r===1),[z,j]=t.useState(!1),[D,A]=t.useState(null),[E,L]=t.useState([]),[F,T]=t.useState(!1);t.useEffect(()=>{const l=f.current;if(!l||b)return;if(!("IntersectionObserver"in window)){y(!0);return}const x=new IntersectionObserver(h=>{h.some(g=>g.isIntersecting)&&(y(!0),x.disconnect())},{rootMargin:"900px 0px"});return x.observe(l),()=>x.disconnect()},[b]),t.useEffect(()=>{m&&y(!0)},[m?.nonce]),t.useEffect(()=>{if(!b)return;let l=!1,x=null,h=null;return j(!1),A(null),L([]),T(!1),i.getPage(r).then(g=>{if(l)return;const O=g.getViewport({scale:1}),Z=n/O.width,I=Math.min(3.3,Math.max(.175,Z*a)),X=g.getViewport({scale:I});if(M(I),P({width:X.width,height:X.height}),A(X),g.getAnnotations({intent:"display"}).then(u=>{l||L(u)}).catch(()=>{l||L([])}),!R.current)return;const s=Math.max(1,window.devicePixelRatio||1),c=g.getViewport({scale:I*s});return R.current.width=Math.floor(c.width),R.current.height=Math.floor(c.height),x=g.render({canvas:R.current,viewport:c}),x.promise.then(()=>{l||(j(!0),h=window.requestAnimationFrame(()=>{l||o()}))})}).catch(g=>{!l&&!(g instanceof Error&&g.name==="RenderingCancelledException")&&T(!0)}),()=>{l=!0,h!==null&&window.cancelAnimationFrame(h),x?.cancel()}},[i,r,n,a,b]),t.useEffect(()=>{!m||!k.current||k.current.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})},[m?.nonce,N]);const B=l=>{if(!v||!z||l.target instanceof HTMLElement&&l.target.closest("a"))return;const x=R.current;if(!x)return;const h=x.getBoundingClientRect();if(l.clientX<h.left||l.clientX>h.right||l.clientY<h.top||l.clientY>h.bottom)return;const g=N||1,O=Math.max(0,Math.min(h.width,l.clientX-h.left))/g,Z=Math.max(0,Math.min(h.height,l.clientY-h.top))/g;v(r,O,Z)},W=Math.max(1,n*a),_=W*(792/612);return e.jsxs("figure",{ref:l=>{f.current=l,U(r,l)},onDoubleClick:B,className:`pdf-page${z?" rendered":" loading"}`,"data-page":r,"data-scale":N,style:{width:`${C.width||W}px`,minHeight:`${C.height||_}px`},children:[e.jsx("canvas",{ref:R,style:{width:`${C.width||W}px`,height:`${C.height||_}px`}}),F&&e.jsxs("div",{className:"pdf-page-error",role:"alert",children:[e.jsx("span",{children:$("editor.pdfPageLoadFailed",{page:r})}),e.jsxs("button",{type:"button",onClick:p,children:[e.jsx(J,{size:14}),$("common.retry")]})]}),z&&D&&e.jsx(be,{annotations:E,viewport:D,onInternalLink:d}),m&&e.jsx("span",{ref:k,className:"pdf-sync-marker",style:{left:m.x*N,top:m.y*N}}),e.jsx("figcaption",{children:r})]})}function be({annotations:i,viewport:r,onInternalLink:n}){const{t:a}=Q(),m=a("editor.pdfLink");return e.jsx("div",{className:"pdf-annotation-layer","aria-label":a("editor.pdfLinks"),children:i.filter(o=>o.subtype==="Link"&&Array.isArray(o.rect)&&o.rect.length>=4).map((o,U)=>{const[d,v]=r.convertToViewportPoint(o.rect[0],o.rect[1]),[p,$]=r.convertToViewportPoint(o.rect[2],o.rect[3]),f=[d,v,p,$],R=Math.min(f[0],f[2]),k=Math.min(f[1],f[3]),N=Math.abs(f[2]-f[0]),M=Math.abs(f[3]-f[1]),C=typeof o.title=="string"?o.title.trim():"",P=typeof o.unsafeUrl=="string"?o.unsafeUrl.trim():"",b=typeof o.url=="string"?o.url.trim():"",y=ne(b)?b:ne(P)?P:"",z=o.dest;if(!y&&z==null)return null;const j=!!y;return e.jsx("a",{className:"pdf-annotation-link",href:y||"#",target:j?"_blank":void 0,rel:j?"noreferrer":void 0,title:C||(j?y:m),"aria-label":C||(j?y:m),style:{left:R,top:k,width:N,height:M},onClick:j?void 0:D=>{D.preventDefault(),n(z)}},`${U}-${R}-${k}`)})})}function ne(i){return/^(?:https?|mailto|ftp):/i.test(i)}export{Ce as PdfPreview,Se as preloadPdf,Ee as preloadPdfRuntime};
@@ -1 +1 @@
1
- import{u as E,r as t,j as e}from"./react-BVUjbTTn.js";import{M as $,h as M}from"./index-p1NHkGGG.js";import{i as z,p as b,P as h,a as L,n as F}from"./Dashboard-JA5_M3TK.js";import{S as q}from"./search-DXo_aAp0.js";import"./hard-drive-BWZnOgnm.js";import"./x-eisRQJv_.js";import"./sigma-BgvHGPto.js";import"./tags-m9kppdi0.js";function y(o){return o.trim().toLocaleLowerCase()}function H({project:o,open:l,onOpenChange:d,onSave:g}){const{t:s,i18n:k}=E(),[i,x]=t.useState(""),[n,p]=t.useState(null),[I,u]=t.useState(""),[r,j]=t.useState(!1),[f,m]=t.useState("");t.useEffect(()=>{l&&(x(""),p(o?.icon??null),u(o?.icon&&!z(o.icon)?o.icon:""),j(!1),m(""))},[l,o?.id,o?.icon]);const v=t.useMemo(()=>{const c=y(i);return c?b.filter(({name:a})=>[a,s(`projectIcons.icons.${a}.name`),s(`projectIcons.icons.${a}.keywords`)].some(P=>y(P).includes(c))):b},[k.resolvedLanguage,i,s]),C=async()=>{if(!(!o||r)){j(!0),m("");try{await g(o.id,n),d(!1)}catch(c){m(M(c))}finally{j(!1)}}},S=n!==(o?.icon??null),N=c=>{p(c),u("")},w=c=>{u(c);const a=c.trim();p(a?F(a)??a:null)};return e.jsx($,{open:l,wide:!0,className:"project-icon-picker-modal",title:s("projectIcons.title"),description:o?s("projectIcons.description",{project:o.name}):void 0,onOpenChange:c=>{r||d(c)},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",disabled:r,onClick:()=>d(!1),children:s("common.cancel")}),e.jsx("button",{type:"button",className:"primary",disabled:r||!S,"aria-busy":r,onClick:()=>{C()},children:s("projectIcons.save")})]}),children:e.jsxs("div",{className:"project-icon-picker",children:[f&&e.jsx("p",{className:"error dialog-error",role:"alert",children:f}),e.jsxs("label",{className:"project-icon-search",children:[e.jsx(q,{"aria-hidden":"true",size:16}),e.jsx("span",{className:"sr-only",children:s("projectIcons.search")}),e.jsx("input",{autoFocus:!0,value:i,placeholder:s("projectIcons.search"),onChange:c=>x(c.target.value)})]}),e.jsxs("div",{className:"project-icon-options","aria-label":s("projectIcons.title"),children:[e.jsxs("button",{type:"button","aria-pressed":n===null,className:`project-icon-option project-icon-reset${n===null?" selected":""}`,title:s("projectIcons.useInitial"),onClick:()=>N(null),children:[e.jsx("span",{className:"project-icon-option-glyph",children:e.jsx(h,{fallback:L(o?.name??"")})}),e.jsx("span",{children:s("projectIcons.useInitial")})]}),v.map(({name:c})=>e.jsxs("button",{type:"button","aria-pressed":n===c,className:`project-icon-option${n===c?" selected":""}`,title:s(`projectIcons.icons.${c}.name`),onClick:()=>N(c),children:[e.jsx("span",{className:"project-icon-option-glyph",children:e.jsx(h,{icon:c,fallback:"?"})}),e.jsx("span",{children:s(`projectIcons.icons.${c}.name`)})]},c))]}),v.length===0&&e.jsx("p",{className:"project-icon-picker-empty",children:s("projectIcons.noMatches",{query:i})}),e.jsxs("div",{className:"project-icon-advanced",children:[e.jsx("label",{htmlFor:"project-icon-advanced-name",children:s("projectIcons.advancedName")}),e.jsxs("div",{className:"project-icon-advanced-input",children:[e.jsx("input",{id:"project-icon-advanced-name",value:I,placeholder:s("projectIcons.advancedNamePlaceholder"),onChange:c=>w(c.target.value),spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"}),I.trim()&&e.jsx("span",{className:"project-icon-advanced-preview","aria-label":s("projectIcons.advancedPreview"),children:e.jsx(h,{icon:n,fallback:"?"})})]}),e.jsxs("p",{children:[s("projectIcons.advancedNameDescription")," ",e.jsx("a",{href:"https://icon-sets.iconify.design/lucide/",target:"_blank",rel:"noreferrer",children:s("projectIcons.browse")})]})]})]})})}export{H as ProjectIconPickerDialog};
1
+ import{u as E,r as t,j as e}from"./react-BVUjbTTn.js";import{M as $,h as M}from"./index-CqBmQAzW.js";import{i as z,p as b,P as h,a as L,n as F}from"./Dashboard-DRt4rjKP.js";import{S as q}from"./search-Nu4OcY_n.js";import"./hard-drive-CkIPwUSV.js";import"./x-Cspw_pa4.js";import"./sigma-B-wjepsY.js";import"./tags-BSA08jK3.js";function y(o){return o.trim().toLocaleLowerCase()}function H({project:o,open:l,onOpenChange:d,onSave:g}){const{t:s,i18n:k}=E(),[i,x]=t.useState(""),[n,p]=t.useState(null),[I,u]=t.useState(""),[r,j]=t.useState(!1),[f,m]=t.useState("");t.useEffect(()=>{l&&(x(""),p(o?.icon??null),u(o?.icon&&!z(o.icon)?o.icon:""),j(!1),m(""))},[l,o?.id,o?.icon]);const v=t.useMemo(()=>{const c=y(i);return c?b.filter(({name:a})=>[a,s(`projectIcons.icons.${a}.name`),s(`projectIcons.icons.${a}.keywords`)].some(P=>y(P).includes(c))):b},[k.resolvedLanguage,i,s]),C=async()=>{if(!(!o||r)){j(!0),m("");try{await g(o.id,n),d(!1)}catch(c){m(M(c))}finally{j(!1)}}},S=n!==(o?.icon??null),N=c=>{p(c),u("")},w=c=>{u(c);const a=c.trim();p(a?F(a)??a:null)};return e.jsx($,{open:l,wide:!0,className:"project-icon-picker-modal",title:s("projectIcons.title"),description:o?s("projectIcons.description",{project:o.name}):void 0,onOpenChange:c=>{r||d(c)},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",disabled:r,onClick:()=>d(!1),children:s("common.cancel")}),e.jsx("button",{type:"button",className:"primary",disabled:r||!S,"aria-busy":r,onClick:()=>{C()},children:s("projectIcons.save")})]}),children:e.jsxs("div",{className:"project-icon-picker",children:[f&&e.jsx("p",{className:"error dialog-error",role:"alert",children:f}),e.jsxs("label",{className:"project-icon-search",children:[e.jsx(q,{"aria-hidden":"true",size:16}),e.jsx("span",{className:"sr-only",children:s("projectIcons.search")}),e.jsx("input",{autoFocus:!0,value:i,placeholder:s("projectIcons.search"),onChange:c=>x(c.target.value)})]}),e.jsxs("div",{className:"project-icon-options","aria-label":s("projectIcons.title"),children:[e.jsxs("button",{type:"button","aria-pressed":n===null,className:`project-icon-option project-icon-reset${n===null?" selected":""}`,title:s("projectIcons.useInitial"),onClick:()=>N(null),children:[e.jsx("span",{className:"project-icon-option-glyph",children:e.jsx(h,{fallback:L(o?.name??"")})}),e.jsx("span",{children:s("projectIcons.useInitial")})]}),v.map(({name:c})=>e.jsxs("button",{type:"button","aria-pressed":n===c,className:`project-icon-option${n===c?" selected":""}`,title:s(`projectIcons.icons.${c}.name`),onClick:()=>N(c),children:[e.jsx("span",{className:"project-icon-option-glyph",children:e.jsx(h,{icon:c,fallback:"?"})}),e.jsx("span",{children:s(`projectIcons.icons.${c}.name`)})]},c))]}),v.length===0&&e.jsx("p",{className:"project-icon-picker-empty",children:s("projectIcons.noMatches",{query:i})}),e.jsxs("div",{className:"project-icon-advanced",children:[e.jsx("label",{htmlFor:"project-icon-advanced-name",children:s("projectIcons.advancedName")}),e.jsxs("div",{className:"project-icon-advanced-input",children:[e.jsx("input",{id:"project-icon-advanced-name",value:I,placeholder:s("projectIcons.advancedNamePlaceholder"),onChange:c=>w(c.target.value),spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"}),I.trim()&&e.jsx("span",{className:"project-icon-advanced-preview","aria-label":s("projectIcons.advancedPreview"),children:e.jsx(h,{icon:n,fallback:"?"})})]}),e.jsxs("p",{children:[s("projectIcons.advancedNameDescription")," ",e.jsx("a",{href:"https://icon-sets.iconify.design/lucide/",target:"_blank",rel:"noreferrer",children:s("projectIcons.browse")})]})]})]})})}export{H as ProjectIconPickerDialog};
@@ -1 +1 @@
1
- import{u as A,r,j as e}from"./react-BVUjbTTn.js";import{c as U,g as q,M as F,d as V,C as B}from"./index-p1NHkGGG.js";import{S as $}from"./search-DXo_aAp0.js";import{F as J,e as K}from"./x-eisRQJv_.js";import{C as G}from"./check-C1db8iNn.js";const T=U("Replace",[["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a3 3 0 0 1 3-3h1",key:"3y3t5z"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);function te({open:c,files:h,onOpenChange:u,onOpenFile:p}){const{t:a}=A(),[n,f]=r.useState(""),[d,o]=r.useState(0),m=r.useRef(null),y=r.useRef(null),l=r.useMemo(()=>h.filter(s=>s.type==="file").map(s=>({entry:s,score:H(s.path,n)})).filter(s=>s.score>=0).sort((s,i)=>i.score-s.score||s.entry.path.localeCompare(i.entry.path)).slice(0,100),[h,n]);r.useEffect(()=>{c&&(f(""),o(0),window.setTimeout(()=>m.current?.focus(),0))},[c]),r.useEffect(()=>o(s=>Math.min(s,Math.max(0,l.length-1))),[l.length]),r.useEffect(()=>{c&&y.current?.scrollIntoView({block:"nearest"})},[c,d]);const S=s=>{p(s),u(!1)};return e.jsx(F,{open:c,wide:!0,title:a("navigation.quickOpen"),description:a("navigation.quickOpenDescription"),onOpenChange:u,children:e.jsxs("div",{className:"quick-open-dialog",children:[e.jsxs("label",{children:[e.jsx($,{size:16}),e.jsx("input",{ref:m,value:n,placeholder:a("navigation.filePlaceholder"),onChange:s=>{f(s.target.value),o(0)},onKeyDown:s=>{s.key==="ArrowDown"&&(s.preventDefault(),o(i=>Math.min(l.length-1,i+1))),s.key==="ArrowUp"&&(s.preventDefault(),o(i=>Math.max(0,i-1))),s.key==="Enter"&&l[d]&&(s.preventDefault(),S(l[d].entry.path))}})]}),e.jsxs("div",{className:"quick-open-results",children:[l.map(({entry:s},i)=>e.jsxs("button",{ref:i===d?y:void 0,className:i===d?"active":"",onMouseEnter:()=>o(i),onClick:()=>S(s.path),children:[e.jsx(K,{size:14}),e.jsx("span",{children:s.path}),i===d&&e.jsx(G,{size:13})]},s.path)),l.length===0&&e.jsx("p",{className:"muted padded",children:a("navigation.noFiles")})]})]})})}function se({open:c,project:h,onOpenChange:u,onJump:p}){const{t:a}=A(),[n,f]=r.useState(""),[d,o]=r.useState(""),[m,y]=r.useState(!1),[l,S]=r.useState(!1),[s,i]=r.useState([]),[g,C]=r.useState(0),[P,D]=r.useState(!1),[b,k]=r.useState(!1),[W,N]=r.useState(!1),[R,M]=r.useState(""),[z,w]=r.useState(""),[O,Q]=r.useState(0),v=r.useRef(null);r.useEffect(()=>{if(!c){v.current?.abort();return}if(M(""),w(""),!n.trim()){i([]),C(0),D(!1);return}const t=window.setTimeout(()=>{v.current?.abort();const x=new AbortController;v.current=x,k(!0);const E=new URLSearchParams({q:n});m&&E.set("caseSensitive","1"),l&&E.set("wholeWord","1"),q(`/api/projects/${h.id}/search?${E}`,{signal:x.signal}).then(j=>{i(j.matches),C(j.total),D(j.truncated)}).catch(j=>{j instanceof DOMException&&j.name==="AbortError"||w(L(j))}).finally(()=>{v.current===x&&(v.current=null,k(!1))})},250);return()=>window.clearTimeout(t)},[c,h.id,n,m,l,O]);const I=async()=>{N(!1),k(!0),w(""),M("");try{const t=await q(`/api/projects/${h.id}/search/replace`,{method:"POST",body:JSON.stringify({query:n,replacement:d,caseSensitive:m,wholeWord:l})});M(a("navigation.replaced",{count:t.replacements,files:t.files.length})),i([]),C(0),Q(x=>x+1)}catch(t){w(L(t))}finally{k(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(F,{open:c,extraWide:!0,title:a("navigation.projectSearch"),description:a("navigation.projectSearchDescription"),onOpenChange:u,footer:e.jsx("button",{onClick:()=>u(!1),children:a("common.close")}),children:e.jsxs("div",{className:"project-search-dialog",children:[z&&e.jsx("p",{className:"error",children:z}),R&&e.jsx("p",{className:"success",children:R}),e.jsxs("div",{className:"project-search-form",children:[e.jsxs("label",{className:"project-search-query",children:[e.jsx($,{size:16}),e.jsx("input",{autoFocus:!0,value:n,placeholder:a("navigation.searchPlaceholder"),onChange:t=>f(t.target.value)})]}),h.permission!=="read"&&e.jsxs("label",{className:"project-search-query",children:[e.jsx(T,{size:16}),e.jsx("input",{value:d,placeholder:a("navigation.replacePlaceholder"),onChange:t=>o(t.target.value)})]}),e.jsxs("div",{className:"project-search-options",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:m,onChange:t=>y(t.target.checked)}),a("editor.search.matchCase")]}),e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:l,onChange:t=>S(t.target.checked)}),a("editor.search.wholeWord")]}),h.permission!=="read"&&e.jsxs("button",{className:"danger-text",disabled:!n.trim()||g===0||b,onClick:()=>N(!0),children:[e.jsx(T,{size:13}),a("navigation.replaceAll",{count:g})]})]})]}),e.jsxs("div",{className:"project-search-summary",children:[e.jsx("span",{children:b?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"spin",size:13}),a("common.loading")]}):a("navigation.matchSummary",{count:g})}),P&&e.jsx("small",{children:a("navigation.truncated",{count:s.length})})]}),e.jsxs("div",{className:"project-search-results",children:[s.map((t,x)=>e.jsxs("button",{onClick:()=>{p(t.path,t.line,t.column),u(!1)},children:[e.jsx(J,{size:14}),e.jsxs("span",{children:[e.jsxs("strong",{children:[t.path,e.jsxs("small",{children:[":",t.line,":",t.column]})]}),e.jsxs("code",{children:[t.preview.slice(0,t.matchStart),e.jsx("mark",{children:t.preview.slice(t.matchStart,t.matchEnd)}),t.preview.slice(t.matchEnd)]})]})]},`${t.path}-${t.line}-${t.column}-${x}`)),!b&&n.trim()&&s.length===0&&e.jsx("p",{className:"muted padded",children:a("editor.search.noMatches")})]})]})}),e.jsx(B,{open:W,title:a("navigation.replaceConfirmTitle"),description:a("navigation.replaceConfirmDescription",{count:g}),confirmLabel:a("navigation.replaceAll",{count:g}),danger:!0,onCancel:()=>N(!1),onConfirm:()=>{I()}})]})}function H(c,h){const u=c.toLocaleLowerCase(),p=h.trim().toLocaleLowerCase();if(!p)return 1;const a=u.indexOf(p);if(a>=0)return 1e4-a-u.length;let n=0,f=0;for(const d of p){const o=u.indexOf(d,n);if(o<0)return-1;f+=o===n?5:1,n=o+1}return f-u.length/100}function L(c){return c instanceof Error?c.message:String(c)}export{se as ProjectSearchDialog,te as QuickOpenDialog};
1
+ import{u as A,r,j as e}from"./react-BVUjbTTn.js";import{c as U,g as q,M as F,d as V,C as B}from"./index-CqBmQAzW.js";import{S as $}from"./search-Nu4OcY_n.js";import{F as J,e as K}from"./x-Cspw_pa4.js";import{C as G}from"./check-DKIW1zpR.js";const T=U("Replace",[["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a3 3 0 0 1 3-3h1",key:"3y3t5z"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);function te({open:c,files:h,onOpenChange:u,onOpenFile:p}){const{t:a}=A(),[n,f]=r.useState(""),[d,o]=r.useState(0),m=r.useRef(null),y=r.useRef(null),l=r.useMemo(()=>h.filter(s=>s.type==="file").map(s=>({entry:s,score:H(s.path,n)})).filter(s=>s.score>=0).sort((s,i)=>i.score-s.score||s.entry.path.localeCompare(i.entry.path)).slice(0,100),[h,n]);r.useEffect(()=>{c&&(f(""),o(0),window.setTimeout(()=>m.current?.focus(),0))},[c]),r.useEffect(()=>o(s=>Math.min(s,Math.max(0,l.length-1))),[l.length]),r.useEffect(()=>{c&&y.current?.scrollIntoView({block:"nearest"})},[c,d]);const S=s=>{p(s),u(!1)};return e.jsx(F,{open:c,wide:!0,title:a("navigation.quickOpen"),description:a("navigation.quickOpenDescription"),onOpenChange:u,children:e.jsxs("div",{className:"quick-open-dialog",children:[e.jsxs("label",{children:[e.jsx($,{size:16}),e.jsx("input",{ref:m,value:n,placeholder:a("navigation.filePlaceholder"),onChange:s=>{f(s.target.value),o(0)},onKeyDown:s=>{s.key==="ArrowDown"&&(s.preventDefault(),o(i=>Math.min(l.length-1,i+1))),s.key==="ArrowUp"&&(s.preventDefault(),o(i=>Math.max(0,i-1))),s.key==="Enter"&&l[d]&&(s.preventDefault(),S(l[d].entry.path))}})]}),e.jsxs("div",{className:"quick-open-results",children:[l.map(({entry:s},i)=>e.jsxs("button",{ref:i===d?y:void 0,className:i===d?"active":"",onMouseEnter:()=>o(i),onClick:()=>S(s.path),children:[e.jsx(K,{size:14}),e.jsx("span",{children:s.path}),i===d&&e.jsx(G,{size:13})]},s.path)),l.length===0&&e.jsx("p",{className:"muted padded",children:a("navigation.noFiles")})]})]})})}function se({open:c,project:h,onOpenChange:u,onJump:p}){const{t:a}=A(),[n,f]=r.useState(""),[d,o]=r.useState(""),[m,y]=r.useState(!1),[l,S]=r.useState(!1),[s,i]=r.useState([]),[g,C]=r.useState(0),[P,D]=r.useState(!1),[b,k]=r.useState(!1),[W,N]=r.useState(!1),[R,M]=r.useState(""),[z,w]=r.useState(""),[O,Q]=r.useState(0),v=r.useRef(null);r.useEffect(()=>{if(!c){v.current?.abort();return}if(M(""),w(""),!n.trim()){i([]),C(0),D(!1);return}const t=window.setTimeout(()=>{v.current?.abort();const x=new AbortController;v.current=x,k(!0);const E=new URLSearchParams({q:n});m&&E.set("caseSensitive","1"),l&&E.set("wholeWord","1"),q(`/api/projects/${h.id}/search?${E}`,{signal:x.signal}).then(j=>{i(j.matches),C(j.total),D(j.truncated)}).catch(j=>{j instanceof DOMException&&j.name==="AbortError"||w(L(j))}).finally(()=>{v.current===x&&(v.current=null,k(!1))})},250);return()=>window.clearTimeout(t)},[c,h.id,n,m,l,O]);const I=async()=>{N(!1),k(!0),w(""),M("");try{const t=await q(`/api/projects/${h.id}/search/replace`,{method:"POST",body:JSON.stringify({query:n,replacement:d,caseSensitive:m,wholeWord:l})});M(a("navigation.replaced",{count:t.replacements,files:t.files.length})),i([]),C(0),Q(x=>x+1)}catch(t){w(L(t))}finally{k(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(F,{open:c,extraWide:!0,title:a("navigation.projectSearch"),description:a("navigation.projectSearchDescription"),onOpenChange:u,footer:e.jsx("button",{onClick:()=>u(!1),children:a("common.close")}),children:e.jsxs("div",{className:"project-search-dialog",children:[z&&e.jsx("p",{className:"error",children:z}),R&&e.jsx("p",{className:"success",children:R}),e.jsxs("div",{className:"project-search-form",children:[e.jsxs("label",{className:"project-search-query",children:[e.jsx($,{size:16}),e.jsx("input",{autoFocus:!0,value:n,placeholder:a("navigation.searchPlaceholder"),onChange:t=>f(t.target.value)})]}),h.permission!=="read"&&e.jsxs("label",{className:"project-search-query",children:[e.jsx(T,{size:16}),e.jsx("input",{value:d,placeholder:a("navigation.replacePlaceholder"),onChange:t=>o(t.target.value)})]}),e.jsxs("div",{className:"project-search-options",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:m,onChange:t=>y(t.target.checked)}),a("editor.search.matchCase")]}),e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:l,onChange:t=>S(t.target.checked)}),a("editor.search.wholeWord")]}),h.permission!=="read"&&e.jsxs("button",{className:"danger-text",disabled:!n.trim()||g===0||b,onClick:()=>N(!0),children:[e.jsx(T,{size:13}),a("navigation.replaceAll",{count:g})]})]})]}),e.jsxs("div",{className:"project-search-summary",children:[e.jsx("span",{children:b?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"spin",size:13}),a("common.loading")]}):a("navigation.matchSummary",{count:g})}),P&&e.jsx("small",{children:a("navigation.truncated",{count:s.length})})]}),e.jsxs("div",{className:"project-search-results",children:[s.map((t,x)=>e.jsxs("button",{onClick:()=>{p(t.path,t.line,t.column),u(!1)},children:[e.jsx(J,{size:14}),e.jsxs("span",{children:[e.jsxs("strong",{children:[t.path,e.jsxs("small",{children:[":",t.line,":",t.column]})]}),e.jsxs("code",{children:[t.preview.slice(0,t.matchStart),e.jsx("mark",{children:t.preview.slice(t.matchStart,t.matchEnd)}),t.preview.slice(t.matchEnd)]})]})]},`${t.path}-${t.line}-${t.column}-${x}`)),!b&&n.trim()&&s.length===0&&e.jsx("p",{className:"muted padded",children:a("editor.search.noMatches")})]})]})}),e.jsx(B,{open:W,title:a("navigation.replaceConfirmTitle"),description:a("navigation.replaceConfirmDescription",{count:g}),confirmLabel:a("navigation.replaceAll",{count:g}),danger:!0,onCancel:()=>N(!1),onConfirm:()=>{I()}})]})}function H(c,h){const u=c.toLocaleLowerCase(),p=h.trim().toLocaleLowerCase();if(!p)return 1;const a=u.indexOf(p);if(a>=0)return 1e4-a-u.length;let n=0,f=0;for(const d of p){const o=u.indexOf(d,n);if(o<0)return-1;f+=o===n?5:1,n=o+1}return f-u.length/100}function L(c){return c instanceof Error?c.message:String(c)}export{se as ProjectSearchDialog,te as QuickOpenDialog};
@@ -0,0 +1 @@
1
+ import{u as Se,r,j as e}from"./react-BVUjbTTn.js";import{c as u,g as M,h as O,d as B}from"./index-CqBmQAzW.js";import{E as F,G as Ne,S as q,I as oe,J as Ce,K as we,B as Fe,L as Ee}from"./ProjectWorkspace-CcbrdCy8.js";import{X as pe,i as Te,C as ze,d as Me,k as Oe}from"./x-Cspw_pa4.js";import{T as de}from"./type-BCdIbDmF.js";import{S as Le}from"./sigma-B-wjepsY.js";import{R as he}from"./refresh-cw-DyA4NKh7.js";import"./check-DKIW1zpR.js";import"./search-Nu4OcY_n.js";import"./user-plus-gFwY-NA3.js";const De=u("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);const Re=u("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);const Ae=u("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const Pe=u("FileCheck2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3 15 2 2 4-4",key:"1lhrkk"}]]);const $e=u("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["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"}]]);const He=u("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]);const We=u("SpellCheck2",[["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M4 21c1.1 0 1.1-1 2.3-1s1.1 1 2.3 1c1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1",key:"8mdmtu"}]]);const qe=u("WrapText",[["line",{x1:"3",x2:"21",y1:"6",y2:"6",key:"4m8b97"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["polyline",{points:"16 16 14 18 16 20",key:"1jznyi"}],["line",{x1:"3",x2:"10",y1:"18",y2:"18",key:"1h33wv"}]]);function Be(b,i){const p=b.filter(a=>a.type==="file"&&["latexmkrc",".latexmkrc"].includes(a.path.split("/").at(-1)??"")).map(a=>a.path);i&&b.some(a=>a.type==="file"&&a.path===i)&&!p.includes(i)&&p.push(i);const o=a=>a==="latexmkrc"?0:a===".latexmkrc"?1:a.includes("/")?3:2;return p.sort((a,k)=>o(a)-o(k)||a.localeCompare(k))}function _e({name:b,state:i,label:p,reloadLabel:o,onReload:a,compact:k=!1}){const y=i.status==="loading"?e.jsx(B,{className:"spin",size:14}):i.status==="working"?e.jsx(Fe,{size:14}):e.jsx(Ae,{size:14}),S=e.jsxs(e.Fragment,{children:[y,e.jsx("strong",{children:b}),e.jsx("span",{children:p}),i.status==="error"&&e.jsxs("button",{type:"button",className:"browser-tool-reload",title:o,"aria-label":o,onClick:a,children:[e.jsx(he,{size:12}),o]})]});return k?e.jsxs("span",{className:`browser-tool-status compact ${i.status}`,role:"status","aria-live":"polite","aria-label":`${b}: ${p}`,title:i.error||void 0,children:[y,e.jsx("span",{children:p}),i.status==="error"&&e.jsx("button",{type:"button",className:"browser-tool-reload",title:o,"aria-label":o,onClick:a,children:e.jsx(he,{size:12})})]}):e.jsx("div",{className:`browser-tool-status ${i.status}`,title:i.error||void 0,children:S})}function et({onClose:b,project:i,projectId:p,site:o,files:a,dictionaryWords:k,onDictionaryChange:y,editorPreferences:S,onEditorPreferences:xe,spellCheckCount:m,spellCheckUniqueCount:me,spellCheckIndex:f,onSpellCheckNavigate:E,onProject:_}){const{t}=Se(),[L,V]=r.useState(i.engine),[D,R]=r.useState(!!i.latexmkrc),[A,J]=r.useState(i.name),[v,K]=r.useState(i.mainFile),[P,Q]=r.useState(i.chktexEnabled),[x,U]=r.useState(!1),T=r.useRef(null),N=r.useRef(!0),X=r.useRef({name:i.name,mainFile:i.mainFile,engine:i.engine,latexmkrc:i.latexmkrc,chktexEnabled:i.chktexEnabled}),[C,G]=r.useState(null),[Z,$]=r.useState(""),[H,I]=r.useState(""),[Y,z]=r.useState(""),[d,ee]=r.useState("appearance"),[n,h]=r.useState(S),te=r.useSyncExternalStore(F.subscribe,F.getSnapshot,F.getSnapshot),j=i.permission==="owner",se=i.permission!=="read",ie=i.permission!=="read";r.useEffect(()=>h(S),[S]),r.useEffect(()=>(N.current=!0,()=>{N.current=!1}),[]),r.useEffect(()=>{Ne().catch(F.failed)},[p]);const je=()=>{Ee().catch(F.failed)},w=Be(a,i.latexmkrc),ne=i.latexmkrc&&w.includes(i.latexmkrc)?i.latexmkrc:w[0]??"",ae=a.length>0&&i.latexmkrc!==null&&!w.includes(i.latexmkrc);r.useEffect(()=>{ae&&R(!1)},[ae]),r.useEffect(()=>{if(d!=="compiler")return;const s=new AbortController;return G(null),M(`/api/projects/${p}/main-files`,{signal:s.signal}).then(c=>G(c.mainFiles)).catch(c=>{c instanceof Error&&c.name==="AbortError"||$(O(c))}),()=>s.abort()},[p,a,d]);const ge=C??[i.mainFile],ue=C!==null&&!C.includes(v),re=async()=>{if(T.current)return;const s=a.length===0&&i.latexmkrc&&o.allowProjectLatexmkrc!==!1?i.latexmkrc:D&&o.allowProjectLatexmkrc!==!1&&ne||null,c=X.current,g={};if(A!==c.name&&(g.name=A),v!==c.mainFile&&(g.mainFile=v),L!==c.engine&&(g.engine=L),s!==c.latexmkrc&&(g.latexmkrc=s),P!==c.chktexEnabled&&(g.chktexEnabled=P),Object.keys(g).length===0)return;const ye=Object.fromEntries(Object.keys(g).map(l=>[l,c[l]])),W=new AbortController;T.current=W,U(!0);try{$("");const l=await M(`/api/projects/${p}`,{method:"PATCH",signal:W.signal,body:JSON.stringify({...g,expectedSettings:ye})});if(!N.current){_(l.project);return}X.current={name:l.project.name,mainFile:l.project.mainFile,engine:l.project.engine,latexmkrc:l.project.latexmkrc,chktexEnabled:l.project.chktexEnabled},J(l.project.name),K(l.project.mainFile),V(l.project.engine),Q(l.project.chktexEnabled),R(!!l.project.latexmkrc),_(l.project)}catch(l){N.current&&$(O(l))}finally{T.current===W&&(T.current=null,N.current&&U(!1))}},ce=()=>xe(n),be=()=>{if(d==="appearance")return ce();j&&re()},ke=t(d==="appearance"?"projectSettings.saveAppearance":"projectSettings.saveCompiler"),fe=d==="appearance"||j,le=async()=>{const s=H.trim();if(s)try{const c=await M(`/api/projects/${p}/dictionary`,{method:"POST",body:JSON.stringify({word:s})});y(c.words),I(""),z("")}catch(c){z(O(c))}},ve=async s=>{try{const c=await M(`/api/projects/${p}/dictionary/${encodeURIComponent(s)}`,{method:"DELETE"});y(c.words),z("")}catch(c){z(O(c))}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"drawer-title settings-drawer-title",children:[e.jsx("strong",{children:t("editor.projectSettings")}),e.jsxs("div",{className:"drawer-title-actions",children:[fe&&e.jsxs("button",{type:"button",className:"drawer-settings-save",disabled:d==="compiler"&&x,"aria-busy":d==="compiler"&&x,onClick:be,children:[d==="compiler"&&x?e.jsx(B,{className:"spin",size:14}):e.jsx(q,{size:14}),e.jsx("span",{children:ke})]}),e.jsx("button",{type:"button","aria-label":t("common.close"),onClick:b,children:e.jsx(pe,{size:17})})]})]}),e.jsxs("div",{className:"settings padded",children:[Z&&e.jsx("p",{className:"error",children:Z}),e.jsxs("div",{className:"settings-tabs",role:"tablist","aria-label":t("common.settings"),children:[e.jsxs("button",{id:"settings-tab-appearance",type:"button",role:"tab","aria-selected":d==="appearance","aria-controls":"settings-panel-appearance",className:`settings-tab${d==="appearance"?" active":""}`,onClick:()=>ee("appearance"),children:[e.jsx(de,{size:15}),t("projectSettings.editorTab")]}),e.jsxs("button",{id:"settings-tab-compiler",type:"button",role:"tab","aria-selected":d==="compiler","aria-controls":"settings-panel-compiler",className:`settings-tab${d==="compiler"?" active":""}`,onClick:()=>ee("compiler"),children:[e.jsx(oe,{size:15}),t("projectSettings.compilerTab")]})]}),d==="appearance"?e.jsxs("section",{id:"settings-panel-appearance",role:"tabpanel","aria-labelledby":"settings-tab-appearance",children:[e.jsxs("div",{className:"settings-section-title",children:[e.jsx(de,{size:15}),e.jsx("strong",{children:t("projectSettings.editorAppearance")})]}),e.jsx("p",{className:"settings-description appearance-description",children:t("projectSettings.editorAppearanceDescription")}),e.jsxs("label",{children:[t("projectSettings.fontFamily"),e.jsx("select",{value:n.font,onChange:s=>h({...n,font:s.target.value}),children:Ce.map(s=>e.jsx("option",{value:s.id,children:t(s.labelKey)},s.id))})]}),e.jsxs("label",{children:[t("projectSettings.fontSize"),e.jsx("select",{value:n.fontSize,onChange:s=>h({...n,fontSize:Number(s.target.value)}),children:[12,13,14,15,16,18,20].map(s=>e.jsxs("option",{value:s,children:[s," px"]},s))})]}),e.jsxs("label",{children:[t("projectSettings.lineHeight"),e.jsxs("select",{value:n.lineHeight,onChange:s=>h({...n,lineHeight:Number(s.target.value)}),children:[e.jsx("option",{value:1.45,children:t("projectSettings.lineHeightCompact")}),e.jsx("option",{value:1.65,children:t("projectSettings.lineHeightNormal")}),e.jsx("option",{value:1.85,children:t("projectSettings.lineHeightRelaxed")})]})]}),e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:n.lineWrapping,onChange:s=>h({...n,lineWrapping:s.target.checked})}),e.jsx(qe,{size:15}),e.jsx("span",{children:t("projectSettings.lineWrapping")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:n.showTooltips,onChange:s=>h({...n,showTooltips:s.target.checked})}),e.jsx($e,{size:15}),e.jsx("span",{children:t("projectSettings.showTooltips")})]}),e.jsx("p",{className:"field-hint",children:t("projectSettings.showTooltipsDescription")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:n.mathPreviewOnHover,onChange:s=>h({...n,mathPreviewOnHover:s.target.checked})}),e.jsx(Le,{size:15}),e.jsx("span",{children:t("projectSettings.mathPreviewOnHover")})]}),e.jsx("p",{className:"field-hint",children:t("projectSettings.mathPreviewOnHoverDescription")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:n.spellCheck,onChange:s=>h({...n,spellCheck:s.target.checked})}),e.jsx("span",{children:t("projectSettings.spellCheck")})]}),e.jsxs("p",{className:"field-hint",children:[t("projectSettings.writingCheckDescription")," ",e.jsx("a",{href:"https://writewithharper.com/docs/integrations/language-server",target:"_blank",rel:"noreferrer",children:"Harper"})]})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:n.vimMode,onChange:s=>h({...n,vimMode:s.target.checked})}),e.jsx("span",{children:t("projectSettings.vimMode")})]}),e.jsxs("p",{className:"field-hint",children:[t("projectSettings.vimModeDescription")," ",e.jsx("a",{href:"https://replit-codemirror-vim.mintlify.app/",target:"_blank",rel:"noreferrer",children:t("projectSettings.vimHelp")})]})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:n.openFilesInTabs,onChange:s=>h({...n,openFilesInTabs:s.target.checked})}),e.jsx(He,{size:15}),e.jsx("span",{children:t("projectSettings.openFilesInTabs")})]}),e.jsx("p",{className:"field-hint",children:t("projectSettings.openFilesInTabsDescription")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",disabled:!se,checked:n.formatOnCompile,onChange:s=>h({...n,formatOnCompile:s.target.checked})}),e.jsx(we,{size:15}),e.jsx("span",{children:t("projectSettings.formatOnCompile")})]}),e.jsxs("p",{className:"field-hint",children:[t(se?"projectSettings.formatOnCompileDescription":"projectSettings.formatRequiresWrite")," ",t("projectSettings.formatterDescription")," ",e.jsx("a",{href:"https://www.npmjs.com/package/tex-fmt",target:"_blank",rel:"noreferrer",children:t("projectSettings.formatterInstall")})," · ",e.jsx("a",{href:"https://github.com/FlamingTempura/bibtex-tidy",target:"_blank",rel:"noreferrer",children:t("projectSettings.bibtexTidyInstall")})]})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"tex-fmt-options-field",children:[e.jsxs("span",{className:"tex-fmt-options-heading",children:[e.jsx("span",{children:t("projectSettings.texFmtOptions")}),e.jsx(_e,{compact:!0,name:"tex-fmt",state:te,label:t(`projectSettings.toolStatus.${te.status}`),reloadLabel:t("projectSettings.reloadTool"),onReload:je})]}),e.jsx("textarea",{className:"tex-fmt-options-editor",rows:6,maxLength:16*1024,spellCheck:!1,value:n.texFmtConfig,placeholder:t("projectSettings.texFmtOptionsPlaceholder"),onChange:s=>h({...n,texFmtConfig:s.target.value})})]}),e.jsx("p",{className:"field-hint",children:t("projectSettings.texFmtOptionsDescription")})]}),m!==null&&e.jsxs("div",{className:`spell-check-result${m?" has-issues":""}`,role:"status","aria-live":"polite",children:[e.jsx(We,{size:14}),e.jsx("span",{children:m?t("projectSettings.writingIssues",{count:m,uniqueCount:me??0}):t("chktex.noIssues")}),m>0&&e.jsxs("span",{className:"spell-check-controls",children:[e.jsx("button",{type:"button",title:t("projectSettings.spellCheckFirst"),"aria-label":t("projectSettings.spellCheckFirst"),disabled:f<=0,onClick:()=>E(0),children:e.jsx(De,{size:14})}),e.jsx("button",{type:"button",title:t("projectSettings.spellCheckPrevious"),"aria-label":t("projectSettings.spellCheckPrevious"),disabled:f<=0,onClick:()=>E(f-1),children:e.jsx(Te,{size:14})}),e.jsx("span",{className:"spell-check-position",children:t("projectSettings.spellCheckPosition",{current:Math.min(f+1,m),total:m})}),e.jsx("button",{type:"button",title:t("projectSettings.spellCheckNext"),"aria-label":t("projectSettings.spellCheckNext"),disabled:f>=m-1,onClick:()=>E(f+1),children:e.jsx(ze,{size:14})}),e.jsx("button",{type:"button",title:t("projectSettings.spellCheckLast"),"aria-label":t("projectSettings.spellCheckLast"),disabled:f>=m-1,onClick:()=>E(m-1),children:e.jsx(Re,{size:14})})]})]}),e.jsxs("div",{className:"settings-section-title",children:[e.jsx(Me,{size:15}),e.jsx("strong",{children:t("projectSettings.dictionary")})]}),e.jsx("p",{className:"settings-description",children:t("projectSettings.dictionaryDescription")}),Y&&e.jsx("p",{className:"error dictionary-error",children:Y}),ie&&e.jsxs("div",{className:"dictionary-add",children:[e.jsx("input",{value:H,placeholder:t("projectSettings.dictionaryPlaceholder"),onChange:s=>I(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),le())}}),e.jsx("button",{type:"button",disabled:!H.trim(),onClick:()=>{le()},children:t("projectSettings.addWord")})]}),e.jsxs("div",{className:"dictionary-words",children:[k.map(s=>e.jsxs("span",{className:"dictionary-word",children:[e.jsx("code",{children:s}),ie&&e.jsx("button",{type:"button",title:t("common.delete"),"aria-label":`${t("common.delete")} ${s}`,onClick:()=>{ve(s)},children:e.jsx(pe,{size:13})})]},s)),k.length===0&&e.jsx("span",{className:"dictionary-empty",children:t("projectSettings.dictionaryEmpty")})]}),e.jsx("div",{className:"settings-actions",children:e.jsxs("button",{className:"settings-save",onClick:ce,children:[e.jsx(q,{size:15}),t("projectSettings.saveAppearance")]})})]}):e.jsxs("section",{id:"settings-panel-compiler",role:"tabpanel","aria-labelledby":"settings-tab-compiler",children:[e.jsxs("div",{className:"settings-section-title",children:[e.jsx(oe,{size:15}),e.jsx("strong",{children:t("projectSettings.compilerTab")})]}),e.jsx("p",{className:"settings-description compiler-description",children:t("projectSettings.compilerDescription")}),e.jsxs("label",{children:[t("projects.name"),e.jsx("input",{disabled:!j||x,value:A,onChange:s=>J(s.target.value)})]}),e.jsxs("label",{children:[t("projectSettings.mainFile"),e.jsxs("select",{disabled:!j||x||C===null||C.length===0,value:v,onChange:s=>K(s.target.value),children:[ue&&e.jsx("option",{value:v,disabled:!0,children:t("projectSettings.invalidMainFileOption",{path:v})}),ge.map(s=>e.jsx("option",{value:s,children:s},s))]})]}),e.jsxs("label",{children:[t(D&&w.length>0&&o.allowProjectLatexmkrc!==!1?"projectSettings.defaultEngine":"projectSettings.engine"),e.jsx("select",{disabled:!j||x,value:L,onChange:s=>V(s.target.value),children:(o.allowedEngines??["pdflatex","xelatex","lualatex"]).map(s=>e.jsx("option",{children:s},s))})]}),e.jsxs("div",{className:"editor-preference compiler-check-option",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",disabled:!j||x,checked:P,onChange:s=>Q(s.target.checked)}),e.jsx(Pe,{size:15}),e.jsx("span",{children:t("chktex.enabled")})]}),e.jsxs("p",{className:"field-hint",children:[t("chktex.description")," ",e.jsx("a",{href:"https://www.nongnu.org/chktex/",target:"_blank",rel:"noreferrer",children:"ChkTeX"})]})]}),w.length>0&&e.jsxs("div",{className:"editor-preference latexmkrc-setting",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",disabled:!j||x||o.allowProjectLatexmkrc===!1,checked:D&&o.allowProjectLatexmkrc!==!1,onChange:s=>R(s.target.checked)}),e.jsx("span",{children:t("projectSettings.enableLatexmkrc")})]}),e.jsx("p",{className:"field-hint",children:t("projectSettings.latexmkrcSource",{path:ne})}),o.allowProjectLatexmkrc===!1?e.jsx("p",{className:"field-hint",children:t("projectSettings.latexmkrcUnavailable")}):e.jsxs("p",{className:"field-hint latexmkrc-warning",children:[e.jsx(Oe,{size:14,"aria-hidden":"true"}),e.jsx("span",{children:t("projectSettings.latexmkrcWarning")})]})]}),e.jsx("div",{className:"settings-actions",children:j&&e.jsxs("button",{className:"settings-save",disabled:x,"aria-busy":x,onClick:()=>{re()},children:[x?e.jsx(B,{className:"spin",size:15}):e.jsx(q,{size:15}),t("projectSettings.saveCompiler")]})})]})]})]})}export{et as ProjectSettings};