texlite 0.3.7 → 0.4.1

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.
@@ -1,3 +1,3 @@
1
- import{u as ye,r as n,j as e}from"./react-CsO_xvbl.js";import{i as h,M as H,L as p,G as q,C as ie,j as ne,T as ke,R as be,k as l}from"./index-DtGvC-Uo.js";import{M as ve,P as Ce,a as Ne}from"./plus-4Hi_FYu_.js";const we=h("CloudUpload",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]]);const ae=h("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const G=h("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const oe=h("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]);const W=h("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);const ze=h("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);const Se=h("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);const Ee=h("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);const Te=h("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);function Ue({open:g,project:o,onOpenChange:y,onBeforeMutation:r}){const{t:s,i18n:E}=ye(),[i,m]=n.useState(null),[J,V]=n.useState([]),[T,k]=n.useState(""),[F,K]=n.useState(()=>re(o.name)),[_,ce]=n.useState(!0),[D,Z]=n.useState(""),[b,M]=n.useState(null),[f,j]=n.useState(null),[R,U]=n.useState(!1),[le,v]=n.useState(!1),[$,L]=n.useState(!0),[P,A]=n.useState(!0),[a,C]=n.useState(""),[Q,N]=n.useState(""),[X,B]=n.useState(""),[u,x]=n.useState(!1),[w,Y]=n.useState(10),O=n.useRef(null),z=async(t=!1)=>{const c=await l(`/api/projects/${o.id}/git`);if(m(c.status),t&&(L(!c.status.tokenConfigured),A(!c.status.remoteUrl)),c.status.initialized&&c.status.latestCommit){const S=await l(`/api/projects/${o.id}/git/history`);V(S.commits)}else V([])};n.useEffect(()=>{if(!g){document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),x(!1),k("");return}N(""),B(""),M(null),x(!1),K(re(o.name)),C("load"),r().then(()=>z(!0)).catch(t=>N(t instanceof Error?t.message:s("errors.generic"))).finally(()=>C(""))},[g,o.id]),n.useEffect(()=>{const t=()=>x(document.fullscreenElement===O.current);return document.addEventListener("fullscreenchange",t),()=>document.removeEventListener("fullscreenchange",t)},[]),n.useEffect(()=>{if(!u)return;const t=c=>{c.key==="Escape"&&!document.fullscreenElement&&x(!1)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[u]);const d=async(t,c,S,ee)=>{C(t),N(""),B("");try{await c(),S&&B(S)}catch(se){const te=se instanceof Error?se.message:s("errors.generic");N(ee?`${ee}: ${te}`:te)}finally{C("")}},de=()=>d("token",async()=>{const t=await l(`/api/projects/${o.id}/git/token`,{method:"PUT",body:JSON.stringify({token:T})});m(t.status),k(""),L(!1)},s("git.tokenSaved")),he=()=>d("remove-token",async()=>{const t=await l(`/api/projects/${o.id}/git/token`,{method:"DELETE"});m(t.status),k("")},s("git.tokenRemoved")),ge=()=>d("repository",async()=>{const t=await l(`/api/projects/${o.id}/git/repository`,{method:"POST",body:JSON.stringify({name:F,private:_})});m(t.status),A(!1)},s("git.repositoryCreated")),ue=()=>d("commit",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));const t=await l(`/api/projects/${o.id}/git/commit`,{method:"POST",body:JSON.stringify({message:D})});m(t.status),Z(""),M(null),await z()},s("git.committed")),me=()=>d("push",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));const t=await l(`/api/projects/${o.id}/git/push`,{method:"POST"});m(t.status),await z()},s("git.pushed"),s("git.pushFailed")),I=t=>d("diff",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));const c=t?`?revision=${encodeURIComponent(t)}`:"";M(await l(`/api/projects/${o.id}/git/diff${c}`))}),fe=async()=>{if(u){document.fullscreenElement&&await document.exitFullscreen().catch(()=>{}),x(!1);return}const t=O.current;if(t?.requestFullscreen)try{await t.requestFullscreen()}catch{}x(!0)},xe=()=>{const t=f;t&&(j(null),d("checkout",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));await l(`/api/projects/${o.id}/git/checkout`,{method:"POST",body:JSON.stringify({revision:t==="branch"?null:t.sha,force:R})}),window.location.reload()}))},pe=()=>{v(!1),d("discard",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));await l(`/api/projects/${o.id}/git/discard`,{method:"POST"}),window.location.reload()})},je=a==="load"&&!i;return e.jsxs(e.Fragment,{children:[e.jsx(H,{open:g,extraWide:!0,className:u?"git-dialog-modal-fullscreen":void 0,title:s("git.title"),description:s("git.description"),onOpenChange:y,footer:e.jsx("button",{onClick:()=>y(!1),children:s("common.close")}),children:e.jsxs("div",{className:"git-dialog",children:[je&&e.jsxs("div",{className:"git-loading",children:[e.jsx(p,{className:"spin",size:22}),s("common.loading")]}),Q&&e.jsx("p",{className:"git-message error",children:Q}),X&&e.jsxs("p",{className:"git-message success",children:[e.jsx(q,{size:14}),X]}),i&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"git-section",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":$,onClick:()=>L(t=>!t),children:[e.jsxs("span",{className:"git-section-heading",children:[e.jsx(ze,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:s("git.authentication")}),e.jsx("small",{children:i.tokenConfigured?s("git.connectedAs",{login:i.githubLogin}):s("git.authenticationHint")})]})]}),$?e.jsx(ie,{size:16}):e.jsx(ne,{size:16})]}),$&&e.jsxs("div",{className:"git-section-content",children:[e.jsxs("div",{className:"git-token-guidance",children:[e.jsx("strong",{children:s("git.recommendedAccessTitle")}),e.jsx("span",{children:s("git.recommendedAccess")})]}),i.tokenConfigured&&e.jsxs("div",{className:"git-account",children:[e.jsx(W,{size:17}),e.jsx("span",{children:s("git.connectedAs",{login:i.githubLogin})}),e.jsxs("button",{className:"danger-text",disabled:!!a,onClick:he,children:[e.jsx(ke,{size:14}),s("git.removeToken")]})]}),e.jsxs("label",{className:"form-field",children:[i.tokenConfigured?s("git.replaceToken"):s("git.token"),e.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",value:T,placeholder:s("git.tokenPlaceholder"),onChange:t=>k(t.target.value)})]}),e.jsxs("div",{className:"git-inline-actions",children:[e.jsxs("a",{href:"https://github.com/settings/personal-access-tokens/new",target:"_blank",rel:"noreferrer",children:[s("git.createToken"),e.jsx(ae,{size:12})]}),e.jsxs("button",{disabled:!!a||T.trim().length<20,onClick:de,children:[a==="token"&&e.jsx(p,{className:"spin",size:13}),s("git.saveToken")]})]})]})]}),e.jsxs("section",{className:"git-section",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":P,onClick:()=>A(t=>!t),children:[e.jsxs("span",{className:"git-section-heading",children:[e.jsx(W,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:s("git.repository")}),e.jsx("small",{children:i.remoteUrl?i.repositoryName??i.remoteUrl:i.initialized?s("git.localReady"):s("git.localPending")})]})]}),P?e.jsx(ie,{size:16}):e.jsx(ne,{size:16})]}),P&&e.jsx("div",{className:"git-section-content",children:i.remoteUrl?e.jsxs("div",{className:"git-repository-card",children:[e.jsxs("div",{children:[e.jsx("strong",{children:i.repositoryName??s("git.origin")}),e.jsxs("small",{children:[i.branch??s("git.detachedAt",{revision:i.latestCommit?.shortSha??"HEAD"})," · ",i.dirty?s("git.changedFiles",{count:i.changedFiles}):s("git.clean")]})]}),i.repositoryHtmlUrl&&e.jsxs("a",{href:i.repositoryHtmlUrl,target:"_blank",rel:"noreferrer",children:[e.jsx(ae,{size:14}),s("git.openGitHub")]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"form-field",children:[s("git.repositoryName"),e.jsx("input",{value:F,onChange:t=>K(t.target.value)})]}),e.jsxs("label",{className:"checkbox-field",children:[e.jsx("input",{type:"checkbox",checked:_,onChange:t=>ce(t.target.checked)}),s("git.privateRepository")]}),e.jsxs("button",{className:"git-primary-action",disabled:!!a||!i.tokenConfigured||!F.trim(),onClick:ge,children:[a==="repository"?e.jsx(p,{className:"spin",size:14}):e.jsx(W,{size:14}),s("git.createRepository")]})]})})]}),i.initialized&&e.jsxs("section",{className:"git-section",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(oe,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:s("git.commitAndPush")}),e.jsx("small",{children:i.branch?s("git.identity",{username:o.ownerUsername}):s("git.detachedHead")})]})]}),e.jsxs("label",{className:"form-field",children:[s("git.commitMessage"),e.jsx("textarea",{rows:3,value:D,placeholder:s("git.commitPlaceholder"),onChange:t=>Z(t.target.value)})]}),e.jsxs("div",{className:"git-action-row",children:[e.jsxs("button",{title:i.dirty?void 0:s("git.noChangesToCommit"),disabled:!!a||!i.branch||!i.dirty||!D.trim(),onClick:ue,children:[a==="commit"?e.jsx(p,{className:"spin",size:14}):e.jsx(oe,{size:14}),s("git.commit")]}),e.jsxs("button",{disabled:!!a||!i.branch||!i.tokenConfigured||!i.remoteUrl||!i.latestCommit,onClick:me,children:[a==="push"?e.jsx(p,{className:"spin",size:14}):e.jsx(we,{size:14}),s("git.push"),i.ahead>0&&e.jsx("span",{className:"git-count",children:i.ahead})]}),e.jsxs("button",{disabled:!!a||!i.latestCommit,onClick:()=>{I()},children:[a==="diff"?e.jsx(p,{className:"spin",size:14}):e.jsx(G,{size:14}),s("git.workingDiff")]}),e.jsxs("button",{className:"git-discard-button",title:i.restorable?s("git.discardChanges"):s("git.noChangesToDiscard"),disabled:!!a||!i.latestCommit||!i.restorable,onClick:()=>v(!0),children:[e.jsx(be,{size:14}),s("git.discardChanges")]}),!i.branch&&e.jsxs("button",{disabled:!!a,onClick:()=>{U(!1),j("branch")},children:[e.jsx(q,{size:14}),s("git.returnToBranch",{branch:i.defaultBranch})]}),e.jsxs("button",{disabled:!!a,onClick:()=>{d("refresh",z)},children:[e.jsx(Ee,{className:a==="refresh"?"spin":"",size:14}),s("git.refresh")]})]})]}),b&&e.jsxs("section",{ref:O,className:`git-section git-diff-section${u?" is-fullscreen":""}`,children:[e.jsxs("div",{className:"git-diff-heading",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(G,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:s("git.diffTitle")}),e.jsxs("small",{children:[b.title,b.truncated?` · ${s("git.diffTruncated")}`:""]})]})]}),e.jsxs("div",{className:"git-diff-controls",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:w<=8,title:s("git.diffFontDecrease"),"aria-label":s("git.diffFontDecrease"),onClick:()=>Y(t=>Math.max(8,t-1)),children:e.jsx(ve,{size:14})}),e.jsxs("span",{className:"git-diff-font-value","aria-live":"polite",children:[w,"px"]}),e.jsx("button",{type:"button",className:"git-diff-font-button",disabled:w>=24,title:s("git.diffFontIncrease"),"aria-label":s("git.diffFontIncrease"),onClick:()=>Y(t=>Math.min(24,t+1)),children:e.jsx(Ce,{size:14})})]}),e.jsx("button",{type:"button",className:"git-diff-fullscreen",title:s(u?"git.exitFullscreenDiff":"git.fullscreenDiff"),"aria-label":s(u?"git.exitFullscreenDiff":"git.fullscreenDiff"),onClick:()=>{fe()},children:u?e.jsx(Se,{size:15}):e.jsx(Ne,{size:15})})]})]}),e.jsx(Fe,{content:b.diff,empty:s("git.noChanges"),fontSize:w})]}),i.initialized&&e.jsxs("section",{className:"git-section",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(q,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:s("git.history")}),e.jsx("small",{children:s("git.historyHint")})]})]}),e.jsxs("div",{className:"git-history",children:[J.map(t=>e.jsxs("article",{children:[e.jsx("code",{children:t.shortSha}),e.jsxs("div",{children:[e.jsx("strong",{children:t.message}),e.jsxs("small",{children:[t.authorName," · ",new Date(t.authoredAt).toLocaleString(E.resolvedLanguage)]})]}),e.jsxs("span",{children:[e.jsx("button",{title:s("git.viewCommitDiff"),disabled:!!a,onClick:()=>{I(t.sha)},children:e.jsx(G,{size:14})}),e.jsx("button",{title:s("git.checkoutVersion"),disabled:!!a,onClick:()=>{U(!1),j(t)},children:e.jsx(Te,{size:14})})]})]},t.sha)),J.length===0&&e.jsx("p",{className:"muted",children:s("git.noCommits")})]})]})]})]})}),e.jsx(H,{open:!!f,title:s(f==="branch"?"git.returnTitle":"git.checkoutTitle"),description:f==="branch"?s("git.returnDescription",{branch:i?.defaultBranch??"main"}):s("git.checkoutDescription",{revision:f?.shortSha??"",message:f?.message??""}),onOpenChange:t=>{t||j(null)},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>j(null),children:s("common.cancel")}),e.jsx("button",{className:R?"danger":"primary",onClick:xe,children:s("git.checkout")})]}),children:e.jsxs("label",{className:"git-force-checkout",children:[e.jsx("input",{type:"checkbox",checked:R,onChange:t=>U(t.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:s("git.forceCheckout")}),e.jsx("small",{children:s("git.forceCheckoutDescription")})]})]})}),e.jsx(H,{open:le,title:s("git.discardTitle"),description:s("git.discardDescription"),onOpenChange:v,footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>v(!1),children:s("common.cancel")}),e.jsx("button",{className:"danger",onClick:pe,children:s("git.discardConfirm")})]}),children:e.jsx(e.Fragment,{})})]})}function Fe({content:g,empty:o,fontSize:y}){return g.trim()?e.jsx("pre",{className:"git-diff",style:{fontSize:`${y}px`},children:g.split(`
1
+ import{u as ye,r as n,j as e}from"./react-CsO_xvbl.js";import{i as h,M as H,L as p,G as q,C as ie,j as ne,T as ke,R as be,k as l}from"./index-BI4dns2b.js";import{M as ve,P as Ce,a as Ne}from"./plus-CvyFTTaw.js";const we=h("CloudUpload",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]]);const ae=h("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const G=h("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const oe=h("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]);const W=h("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);const ze=h("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);const Se=h("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);const Ee=h("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);const Te=h("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);function Ue({open:g,project:o,onOpenChange:y,onBeforeMutation:r}){const{t:s,i18n:E}=ye(),[i,m]=n.useState(null),[J,V]=n.useState([]),[T,k]=n.useState(""),[F,K]=n.useState(()=>re(o.name)),[_,ce]=n.useState(!0),[D,Z]=n.useState(""),[b,M]=n.useState(null),[f,j]=n.useState(null),[R,U]=n.useState(!1),[le,v]=n.useState(!1),[$,L]=n.useState(!0),[P,A]=n.useState(!0),[a,C]=n.useState(""),[Q,N]=n.useState(""),[X,B]=n.useState(""),[u,x]=n.useState(!1),[w,Y]=n.useState(10),O=n.useRef(null),z=async(t=!1)=>{const c=await l(`/api/projects/${o.id}/git`);if(m(c.status),t&&(L(!c.status.tokenConfigured),A(!c.status.remoteUrl)),c.status.initialized&&c.status.latestCommit){const S=await l(`/api/projects/${o.id}/git/history`);V(S.commits)}else V([])};n.useEffect(()=>{if(!g){document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),x(!1),k("");return}N(""),B(""),M(null),x(!1),K(re(o.name)),C("load"),r().then(()=>z(!0)).catch(t=>N(t instanceof Error?t.message:s("errors.generic"))).finally(()=>C(""))},[g,o.id]),n.useEffect(()=>{const t=()=>x(document.fullscreenElement===O.current);return document.addEventListener("fullscreenchange",t),()=>document.removeEventListener("fullscreenchange",t)},[]),n.useEffect(()=>{if(!u)return;const t=c=>{c.key==="Escape"&&!document.fullscreenElement&&x(!1)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[u]);const d=async(t,c,S,ee)=>{C(t),N(""),B("");try{await c(),S&&B(S)}catch(se){const te=se instanceof Error?se.message:s("errors.generic");N(ee?`${ee}: ${te}`:te)}finally{C("")}},de=()=>d("token",async()=>{const t=await l(`/api/projects/${o.id}/git/token`,{method:"PUT",body:JSON.stringify({token:T})});m(t.status),k(""),L(!1)},s("git.tokenSaved")),he=()=>d("remove-token",async()=>{const t=await l(`/api/projects/${o.id}/git/token`,{method:"DELETE"});m(t.status),k("")},s("git.tokenRemoved")),ge=()=>d("repository",async()=>{const t=await l(`/api/projects/${o.id}/git/repository`,{method:"POST",body:JSON.stringify({name:F,private:_})});m(t.status),A(!1)},s("git.repositoryCreated")),ue=()=>d("commit",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));const t=await l(`/api/projects/${o.id}/git/commit`,{method:"POST",body:JSON.stringify({message:D})});m(t.status),Z(""),M(null),await z()},s("git.committed")),me=()=>d("push",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));const t=await l(`/api/projects/${o.id}/git/push`,{method:"POST"});m(t.status),await z()},s("git.pushed"),s("git.pushFailed")),I=t=>d("diff",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));const c=t?`?revision=${encodeURIComponent(t)}`:"";M(await l(`/api/projects/${o.id}/git/diff${c}`))}),fe=async()=>{if(u){document.fullscreenElement&&await document.exitFullscreen().catch(()=>{}),x(!1);return}const t=O.current;if(t?.requestFullscreen)try{await t.requestFullscreen()}catch{}x(!0)},xe=()=>{const t=f;t&&(j(null),d("checkout",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));await l(`/api/projects/${o.id}/git/checkout`,{method:"POST",body:JSON.stringify({revision:t==="branch"?null:t.sha,force:R})}),window.location.reload()}))},pe=()=>{v(!1),d("discard",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));await l(`/api/projects/${o.id}/git/discard`,{method:"POST"}),window.location.reload()})},je=a==="load"&&!i;return e.jsxs(e.Fragment,{children:[e.jsx(H,{open:g,extraWide:!0,className:u?"git-dialog-modal-fullscreen":void 0,title:s("git.title"),description:s("git.description"),onOpenChange:y,footer:e.jsx("button",{onClick:()=>y(!1),children:s("common.close")}),children:e.jsxs("div",{className:"git-dialog",children:[je&&e.jsxs("div",{className:"git-loading",children:[e.jsx(p,{className:"spin",size:22}),s("common.loading")]}),Q&&e.jsx("p",{className:"git-message error",children:Q}),X&&e.jsxs("p",{className:"git-message success",children:[e.jsx(q,{size:14}),X]}),i&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"git-section",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":$,onClick:()=>L(t=>!t),children:[e.jsxs("span",{className:"git-section-heading",children:[e.jsx(ze,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:s("git.authentication")}),e.jsx("small",{children:i.tokenConfigured?s("git.connectedAs",{login:i.githubLogin}):s("git.authenticationHint")})]})]}),$?e.jsx(ie,{size:16}):e.jsx(ne,{size:16})]}),$&&e.jsxs("div",{className:"git-section-content",children:[e.jsxs("div",{className:"git-token-guidance",children:[e.jsx("strong",{children:s("git.recommendedAccessTitle")}),e.jsx("span",{children:s("git.recommendedAccess")})]}),i.tokenConfigured&&e.jsxs("div",{className:"git-account",children:[e.jsx(W,{size:17}),e.jsx("span",{children:s("git.connectedAs",{login:i.githubLogin})}),e.jsxs("button",{className:"danger-text",disabled:!!a,onClick:he,children:[e.jsx(ke,{size:14}),s("git.removeToken")]})]}),e.jsxs("label",{className:"form-field",children:[i.tokenConfigured?s("git.replaceToken"):s("git.token"),e.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",value:T,placeholder:s("git.tokenPlaceholder"),onChange:t=>k(t.target.value)})]}),e.jsxs("div",{className:"git-inline-actions",children:[e.jsxs("a",{href:"https://github.com/settings/personal-access-tokens/new",target:"_blank",rel:"noreferrer",children:[s("git.createToken"),e.jsx(ae,{size:12})]}),e.jsxs("button",{disabled:!!a||T.trim().length<20,onClick:de,children:[a==="token"&&e.jsx(p,{className:"spin",size:13}),s("git.saveToken")]})]})]})]}),e.jsxs("section",{className:"git-section",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":P,onClick:()=>A(t=>!t),children:[e.jsxs("span",{className:"git-section-heading",children:[e.jsx(W,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:s("git.repository")}),e.jsx("small",{children:i.remoteUrl?i.repositoryName??i.remoteUrl:i.initialized?s("git.localReady"):s("git.localPending")})]})]}),P?e.jsx(ie,{size:16}):e.jsx(ne,{size:16})]}),P&&e.jsx("div",{className:"git-section-content",children:i.remoteUrl?e.jsxs("div",{className:"git-repository-card",children:[e.jsxs("div",{children:[e.jsx("strong",{children:i.repositoryName??s("git.origin")}),e.jsxs("small",{children:[i.branch??s("git.detachedAt",{revision:i.latestCommit?.shortSha??"HEAD"})," · ",i.dirty?s("git.changedFiles",{count:i.changedFiles}):s("git.clean")]})]}),i.repositoryHtmlUrl&&e.jsxs("a",{href:i.repositoryHtmlUrl,target:"_blank",rel:"noreferrer",children:[e.jsx(ae,{size:14}),s("git.openGitHub")]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"form-field",children:[s("git.repositoryName"),e.jsx("input",{value:F,onChange:t=>K(t.target.value)})]}),e.jsxs("label",{className:"checkbox-field",children:[e.jsx("input",{type:"checkbox",checked:_,onChange:t=>ce(t.target.checked)}),s("git.privateRepository")]}),e.jsxs("button",{className:"git-primary-action",disabled:!!a||!i.tokenConfigured||!F.trim(),onClick:ge,children:[a==="repository"?e.jsx(p,{className:"spin",size:14}):e.jsx(W,{size:14}),s("git.createRepository")]})]})})]}),i.initialized&&e.jsxs("section",{className:"git-section",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(oe,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:s("git.commitAndPush")}),e.jsx("small",{children:i.branch?s("git.identity",{username:o.ownerUsername}):s("git.detachedHead")})]})]}),e.jsxs("label",{className:"form-field",children:[s("git.commitMessage"),e.jsx("textarea",{rows:3,value:D,placeholder:s("git.commitPlaceholder"),onChange:t=>Z(t.target.value)})]}),e.jsxs("div",{className:"git-action-row",children:[e.jsxs("button",{title:i.dirty?void 0:s("git.noChangesToCommit"),disabled:!!a||!i.branch||!i.dirty||!D.trim(),onClick:ue,children:[a==="commit"?e.jsx(p,{className:"spin",size:14}):e.jsx(oe,{size:14}),s("git.commit")]}),e.jsxs("button",{disabled:!!a||!i.branch||!i.tokenConfigured||!i.remoteUrl||!i.latestCommit,onClick:me,children:[a==="push"?e.jsx(p,{className:"spin",size:14}):e.jsx(we,{size:14}),s("git.push"),i.ahead>0&&e.jsx("span",{className:"git-count",children:i.ahead})]}),e.jsxs("button",{disabled:!!a||!i.latestCommit,onClick:()=>{I()},children:[a==="diff"?e.jsx(p,{className:"spin",size:14}):e.jsx(G,{size:14}),s("git.workingDiff")]}),e.jsxs("button",{className:"git-discard-button",title:i.restorable?s("git.discardChanges"):s("git.noChangesToDiscard"),disabled:!!a||!i.latestCommit||!i.restorable,onClick:()=>v(!0),children:[e.jsx(be,{size:14}),s("git.discardChanges")]}),!i.branch&&e.jsxs("button",{disabled:!!a,onClick:()=>{U(!1),j("branch")},children:[e.jsx(q,{size:14}),s("git.returnToBranch",{branch:i.defaultBranch})]}),e.jsxs("button",{disabled:!!a,onClick:()=>{d("refresh",z)},children:[e.jsx(Ee,{className:a==="refresh"?"spin":"",size:14}),s("git.refresh")]})]})]}),b&&e.jsxs("section",{ref:O,className:`git-section git-diff-section${u?" is-fullscreen":""}`,children:[e.jsxs("div",{className:"git-diff-heading",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(G,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:s("git.diffTitle")}),e.jsxs("small",{children:[b.title,b.truncated?` · ${s("git.diffTruncated")}`:""]})]})]}),e.jsxs("div",{className:"git-diff-controls",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:w<=8,title:s("git.diffFontDecrease"),"aria-label":s("git.diffFontDecrease"),onClick:()=>Y(t=>Math.max(8,t-1)),children:e.jsx(ve,{size:14})}),e.jsxs("span",{className:"git-diff-font-value","aria-live":"polite",children:[w,"px"]}),e.jsx("button",{type:"button",className:"git-diff-font-button",disabled:w>=24,title:s("git.diffFontIncrease"),"aria-label":s("git.diffFontIncrease"),onClick:()=>Y(t=>Math.min(24,t+1)),children:e.jsx(Ce,{size:14})})]}),e.jsx("button",{type:"button",className:"git-diff-fullscreen",title:s(u?"git.exitFullscreenDiff":"git.fullscreenDiff"),"aria-label":s(u?"git.exitFullscreenDiff":"git.fullscreenDiff"),onClick:()=>{fe()},children:u?e.jsx(Se,{size:15}):e.jsx(Ne,{size:15})})]})]}),e.jsx(Fe,{content:b.diff,empty:s("git.noChanges"),fontSize:w})]}),i.initialized&&e.jsxs("section",{className:"git-section",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(q,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:s("git.history")}),e.jsx("small",{children:s("git.historyHint")})]})]}),e.jsxs("div",{className:"git-history",children:[J.map(t=>e.jsxs("article",{children:[e.jsx("code",{children:t.shortSha}),e.jsxs("div",{children:[e.jsx("strong",{children:t.message}),e.jsxs("small",{children:[t.authorName," · ",new Date(t.authoredAt).toLocaleString(E.resolvedLanguage)]})]}),e.jsxs("span",{children:[e.jsx("button",{title:s("git.viewCommitDiff"),disabled:!!a,onClick:()=>{I(t.sha)},children:e.jsx(G,{size:14})}),e.jsx("button",{title:s("git.checkoutVersion"),disabled:!!a,onClick:()=>{U(!1),j(t)},children:e.jsx(Te,{size:14})})]})]},t.sha)),J.length===0&&e.jsx("p",{className:"muted",children:s("git.noCommits")})]})]})]})]})}),e.jsx(H,{open:!!f,title:s(f==="branch"?"git.returnTitle":"git.checkoutTitle"),description:f==="branch"?s("git.returnDescription",{branch:i?.defaultBranch??"main"}):s("git.checkoutDescription",{revision:f?.shortSha??"",message:f?.message??""}),onOpenChange:t=>{t||j(null)},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>j(null),children:s("common.cancel")}),e.jsx("button",{className:R?"danger":"primary",onClick:xe,children:s("git.checkout")})]}),children:e.jsxs("label",{className:"git-force-checkout",children:[e.jsx("input",{type:"checkbox",checked:R,onChange:t=>U(t.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:s("git.forceCheckout")}),e.jsx("small",{children:s("git.forceCheckoutDescription")})]})]})}),e.jsx(H,{open:le,title:s("git.discardTitle"),description:s("git.discardDescription"),onOpenChange:v,footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>v(!1),children:s("common.cancel")}),e.jsx("button",{className:"danger",onClick:pe,children:s("git.discardConfirm")})]}),children:e.jsx(e.Fragment,{})})]})}function Fe({content:g,empty:o,fontSize:y}){return g.trim()?e.jsx("pre",{className:"git-diff",style:{fontSize:`${y}px`},children:g.split(`
2
2
  `).map((r,s)=>{const E=r.startsWith("+")&&!r.startsWith("+++")?"addition":r.startsWith("-")&&!r.startsWith("---")?"deletion":r.startsWith("@@")?"hunk":r.startsWith("diff ")?"header":"";return e.jsxs("span",{className:E,children:[r,`
3
3
  `]},s)})}):e.jsx("div",{className:"git-diff-empty",children:o})}function re(g){return g.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._-]/g,"-").replace(/-+/g,"-").replace(/^[.-]+|[.-]+$/g,"").slice(0,100)||"texlite-project"}export{Ue as GitDialog};
@@ -1 +1 @@
1
- import{u as Z,r as a,j as e}from"./react-CsO_xvbl.js";import{d as ee}from"./index-rBWMBTI-.js";import{i as T,k as j,M as se,L as D,T as _,R as I,S as te,F as ie,l as q}from"./index-DtGvC-Uo.js";const re=T("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]);const F=T("FileClock",[["path",{d:"M16 22h2a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"37hlfg"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"8",cy:"16",r:"6",key:"10v15b"}],["path",{d:"M9.5 17.5 8 16.25V14",key:"1o80t2"}]]);const ae=T("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);const oe=T("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 de({open:r,project:c,onOpenChange:M,onBeforeMutation:V}){const{t,i18n:L}=Z(),[v,N]=a.useState([]),[l,z]=a.useState(null),[x,S]=a.useState(""),[o,b]=a.useState(null),[C,P]=a.useState(""),[u,p]=a.useState(null),[B,H]=a.useState(""),[k,w]=a.useState(null),[m,$]=a.useState(null),[y,n]=a.useState(""),[R,d]=a.useState(""),E=c.permission!=="read",U=c.permission==="owner";a.useEffect(()=>{if(!r)return;const s=new AbortController;return n("load"),d(""),p(null),j(`/api/projects/${c.id}/history`,{signal:s.signal}).then(i=>{N(i.versions),z(i.stats),S(h=>i.versions.some(g=>g.id===h)?h:i.versions[0]?.id??"")}).catch(i=>{J(i)||d(f(i))}).finally(()=>{s.signal.aborted||n("")}),()=>s.abort()},[r,c.id]),a.useEffect(()=>{if(!r||!x){b(null);return}const s=new AbortController;return n("detail"),p(null),j(`/api/projects/${c.id}/history/${x}`,{signal:s.signal}).then(i=>{b(i),H(i.version.label??"");const h=i.version.changedPaths.find(g=>i.files.some(A=>A.path===g))??i.files[0]?.path??"";P(h)}).catch(i=>{J(i)||d(f(i))}).finally(()=>{s.signal.aborted||n("")}),()=>s.abort()},[r,c.id,x]);const G=async(s=C)=>{if(s){n("compare"),d("");try{p(await j(`/api/projects/${c.id}/history/${x}/file?path=${encodeURIComponent(s)}`))}catch(i){d(f(i))}finally{n("")}}},K=async()=>{if(o){n("label"),d("");try{const s=await j(`/api/projects/${c.id}/history/${o.version.id}`,{method:"PATCH",body:JSON.stringify({label:B.trim()||null})});b(i=>i&&{...i,version:s.version}),N(i=>i.map(h=>h.id===s.version.id?s.version:h)),z(s.stats)}catch(s){d(f(s))}finally{n("")}}},W=async()=>{const s=m;if(s){$(null),n("delete"),d("");try{if(!await V())throw new Error(t("errors.collaborationUnavailable"));const i=s==="all"?`/api/projects/${c.id}/history`:`/api/projects/${c.id}/history/${s.id}`,h=await j(i,{method:"DELETE"});if(z(h.stats),s==="all")N([]),S(""),b(null),p(null);else{const g=v.filter(A=>A.id!==s.id);N(g),x===s.id&&(S(g[0]?.id??""),b(null),p(null))}}catch(i){d(f(i))}finally{n("")}}},Q=async()=>{const s=k;if(!(!s||!o)){w(null),n("restore"),d("");try{if(!await V())throw new Error(t("errors.collaborationUnavailable"));await j(`/api/projects/${c.id}/history/${o.version.id}/restore`,{method:"POST",body:JSON.stringify(s==="project"?{}:{path:s})}),window.location.reload()}catch(i){d(f(i)),n("")}}},X=a.useMemo(()=>{if(!u)return[];const s=new ee;s.Diff_Timeout=1;const i=s.diff_main(u.historical,u.comparison,!0);return s.diff_cleanupSemantic(i),i},[u]),Y=m&&m!=="all"?m.label||new Date(m.createdAt).toLocaleString(L.resolvedLanguage):"";return e.jsxs(e.Fragment,{children:[e.jsx(se,{open:r,extraWide:!0,className:"history-dialog-modal",title:t("history.title"),description:t("history.description"),onOpenChange:M,footer:e.jsx("button",{onClick:()=>M(!1),children:t("common.close")}),children:e.jsxs("div",{className:"history-dialog",children:[R&&e.jsx("p",{className:"error history-message",children:R}),y==="load"&&v.length===0?e.jsxs("div",{className:"history-loading",children:[e.jsx(D,{className:"spin",size:22}),t("common.loading")]}):e.jsxs(e.Fragment,{children:[e.jsxs("aside",{className:"history-timeline",children:[U&&l&&e.jsxs("div",{className:`history-stats${l.storageLimitExceeded?" exceeded":""}`,children:[e.jsxs("header",{children:[e.jsxs("span",{children:[e.jsx(ae,{size:14}),t("history.storage")]}),e.jsx("button",{type:"button",disabled:!!y||v.length===0,title:t("history.clearAll"),"aria-label":t("history.clearAll"),onClick:()=>$("all"),children:e.jsx(_,{size:13})})]}),e.jsx("strong",{children:t("history.storageUsage",{used:O(l.objectBytes),limit:O(l.maxStorageBytes)})}),e.jsx("progress",{max:l.maxStorageBytes,value:Math.min(l.objectBytes,l.maxStorageBytes)}),e.jsxs("small",{children:[t("history.versionUsage",{count:l.ordinaryVersionCount,limit:l.maxVersions}),l.labeledVersionCount>0?` · ${t("history.protectedVersions",{count:l.labeledVersionCount})}`:""]}),l.storageLimitExceeded&&e.jsx("small",{className:"history-storage-warning",children:t("history.storageExceeded")})]}),v.map(s=>e.jsxs("button",{className:s.id===x?"active":"",onClick:()=>S(s.id),children:[e.jsx(F,{size:15}),e.jsxs("span",{children:[e.jsx("strong",{children:s.label||t(`history.reasons.${s.reason}`)}),e.jsx("small",{children:new Date(s.createdAt).toLocaleString(L.resolvedLanguage)}),e.jsxs("small",{children:[s.author?.name??t("editor.deletedUser")," · ",t("history.changedCount",{count:s.changedPaths.length})]})]})]},s.id)),v.length===0&&e.jsx("p",{className:"muted padded",children:t("history.empty")})]}),e.jsx("section",{className:"history-detail",children:o&&e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:"history-detail-header",children:[e.jsxs("div",{children:[e.jsx("strong",{children:o.version.label||t(`history.reasons.${o.version.reason}`)}),e.jsxs("small",{children:[e.jsx(re,{size:12}),new Date(o.version.createdAt).toLocaleString(L.resolvedLanguage)," · ",t("history.fileCount",{count:o.version.fileCount})]})]}),e.jsxs("span",{className:"history-detail-actions",children:[U&&e.jsxs("button",{className:"danger-text",disabled:!!y,onClick:()=>$(o.version),children:[e.jsx(_,{size:14}),t("history.deleteVersion")]}),E&&e.jsxs("button",{className:"danger-text",disabled:!!y,onClick:()=>w("project"),children:[e.jsx(I,{size:14}),t("history.restoreProject")]})]})]}),E&&e.jsxs("div",{className:"history-label",children:[e.jsxs("label",{children:[e.jsx(oe,{size:14}),e.jsx("input",{value:B,maxLength:80,placeholder:t("history.labelPlaceholder"),onChange:s=>H(s.target.value)})]}),e.jsxs("button",{disabled:y==="label"||B.trim()===(o.version.label??""),onClick:()=>{K()},children:[y==="label"?e.jsx(D,{className:"spin",size:13}):e.jsx(te,{size:13}),t("history.saveLabel")]})]}),e.jsxs("div",{className:"history-files",children:[e.jsx("div",{className:"history-file-list",children:o.files.map(s=>{const i=o.version.changedPaths.includes(s.path);return e.jsxs("button",{className:s.path===C?"active":"",title:s.path,onClick:()=>{P(s.path),p(null)},children:[e.jsx(ie,{size:13}),e.jsx("span",{children:s.path}),i&&e.jsx("small",{children:t("history.changed")})]},s.path)})}),e.jsxs("div",{className:"history-file-actions",children:[e.jsxs("button",{disabled:!C||!!y,onClick:()=>{G()},children:[y==="compare"?e.jsx(D,{className:"spin",size:13}):e.jsx(F,{size:13}),t("history.compareCurrent")]}),E&&e.jsxs("button",{disabled:!C||!!y,onClick:()=>w(C),children:[e.jsx(I,{size:13}),t("history.restoreFile")]})]})]}),e.jsx("div",{className:"history-comparison",children:u?e.jsxs(e.Fragment,{children:[e.jsxs("header",{children:[e.jsx("strong",{children:u.path}),e.jsx("small",{children:t("history.comparingCurrent")})]}),e.jsx("pre",{children:X.map(([s,i],h)=>e.jsx("span",{className:s<0?"history-removed":s>0?"history-added":"",children:i},h))})]}):e.jsxs("div",{className:"history-comparison-empty",children:[e.jsx(F,{size:25}),e.jsx("span",{children:t("history.chooseFile")})]})})]})})]})]})}),e.jsx(q,{open:!!k,title:t(k==="project"?"history.restoreProjectTitle":"history.restoreFileTitle"),description:k==="project"?t("history.restoreProjectDescription"):t("history.restoreFileDescription",{path:k??""}),confirmLabel:t("history.restore"),danger:!0,onCancel:()=>w(null),onConfirm:()=>{Q()}}),e.jsx(q,{open:!!m,title:t(m==="all"?"history.clearAllTitle":"history.deleteVersionTitle"),description:m==="all"?t("history.clearAllDescription"):t("history.deleteVersionDescription",{name:Y}),confirmLabel:t(m==="all"?"history.clearAll":"history.deleteVersion"),danger:!0,onCancel:()=>$(null),onConfirm:()=>{W()}})]})}function O(r){return r<1024?`${r} B`:r<1024*1024?`${Math.round(r/102.4)/10} KB`:r<1024*1024*1024?`${Math.round(r/(1024*1024)*10)/10} MB`:`${Math.round(r/(1024*1024*1024)*10)/10} GB`}function f(r){return r instanceof Error?r.message:String(r)}function J(r){return r instanceof Error&&r.name==="AbortError"}export{de as HistoryDialog};
1
+ import{u as Z,r as a,j as e}from"./react-CsO_xvbl.js";import{d as ee}from"./index-rBWMBTI-.js";import{i as T,k as j,M as se,L as D,T as _,R as I,S as te,F as ie,l as q}from"./index-BI4dns2b.js";const re=T("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]);const F=T("FileClock",[["path",{d:"M16 22h2a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"37hlfg"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"8",cy:"16",r:"6",key:"10v15b"}],["path",{d:"M9.5 17.5 8 16.25V14",key:"1o80t2"}]]);const ae=T("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);const oe=T("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 de({open:r,project:c,onOpenChange:M,onBeforeMutation:V}){const{t,i18n:L}=Z(),[v,N]=a.useState([]),[l,z]=a.useState(null),[x,S]=a.useState(""),[o,b]=a.useState(null),[C,P]=a.useState(""),[u,p]=a.useState(null),[B,H]=a.useState(""),[k,w]=a.useState(null),[m,$]=a.useState(null),[y,n]=a.useState(""),[R,d]=a.useState(""),E=c.permission!=="read",U=c.permission==="owner";a.useEffect(()=>{if(!r)return;const s=new AbortController;return n("load"),d(""),p(null),j(`/api/projects/${c.id}/history`,{signal:s.signal}).then(i=>{N(i.versions),z(i.stats),S(h=>i.versions.some(g=>g.id===h)?h:i.versions[0]?.id??"")}).catch(i=>{J(i)||d(f(i))}).finally(()=>{s.signal.aborted||n("")}),()=>s.abort()},[r,c.id]),a.useEffect(()=>{if(!r||!x){b(null);return}const s=new AbortController;return n("detail"),p(null),j(`/api/projects/${c.id}/history/${x}`,{signal:s.signal}).then(i=>{b(i),H(i.version.label??"");const h=i.version.changedPaths.find(g=>i.files.some(A=>A.path===g))??i.files[0]?.path??"";P(h)}).catch(i=>{J(i)||d(f(i))}).finally(()=>{s.signal.aborted||n("")}),()=>s.abort()},[r,c.id,x]);const G=async(s=C)=>{if(s){n("compare"),d("");try{p(await j(`/api/projects/${c.id}/history/${x}/file?path=${encodeURIComponent(s)}`))}catch(i){d(f(i))}finally{n("")}}},K=async()=>{if(o){n("label"),d("");try{const s=await j(`/api/projects/${c.id}/history/${o.version.id}`,{method:"PATCH",body:JSON.stringify({label:B.trim()||null})});b(i=>i&&{...i,version:s.version}),N(i=>i.map(h=>h.id===s.version.id?s.version:h)),z(s.stats)}catch(s){d(f(s))}finally{n("")}}},W=async()=>{const s=m;if(s){$(null),n("delete"),d("");try{if(!await V())throw new Error(t("errors.collaborationUnavailable"));const i=s==="all"?`/api/projects/${c.id}/history`:`/api/projects/${c.id}/history/${s.id}`,h=await j(i,{method:"DELETE"});if(z(h.stats),s==="all")N([]),S(""),b(null),p(null);else{const g=v.filter(A=>A.id!==s.id);N(g),x===s.id&&(S(g[0]?.id??""),b(null),p(null))}}catch(i){d(f(i))}finally{n("")}}},Q=async()=>{const s=k;if(!(!s||!o)){w(null),n("restore"),d("");try{if(!await V())throw new Error(t("errors.collaborationUnavailable"));await j(`/api/projects/${c.id}/history/${o.version.id}/restore`,{method:"POST",body:JSON.stringify(s==="project"?{}:{path:s})}),window.location.reload()}catch(i){d(f(i)),n("")}}},X=a.useMemo(()=>{if(!u)return[];const s=new ee;s.Diff_Timeout=1;const i=s.diff_main(u.historical,u.comparison,!0);return s.diff_cleanupSemantic(i),i},[u]),Y=m&&m!=="all"?m.label||new Date(m.createdAt).toLocaleString(L.resolvedLanguage):"";return e.jsxs(e.Fragment,{children:[e.jsx(se,{open:r,extraWide:!0,className:"history-dialog-modal",title:t("history.title"),description:t("history.description"),onOpenChange:M,footer:e.jsx("button",{onClick:()=>M(!1),children:t("common.close")}),children:e.jsxs("div",{className:"history-dialog",children:[R&&e.jsx("p",{className:"error history-message",children:R}),y==="load"&&v.length===0?e.jsxs("div",{className:"history-loading",children:[e.jsx(D,{className:"spin",size:22}),t("common.loading")]}):e.jsxs(e.Fragment,{children:[e.jsxs("aside",{className:"history-timeline",children:[U&&l&&e.jsxs("div",{className:`history-stats${l.storageLimitExceeded?" exceeded":""}`,children:[e.jsxs("header",{children:[e.jsxs("span",{children:[e.jsx(ae,{size:14}),t("history.storage")]}),e.jsx("button",{type:"button",disabled:!!y||v.length===0,title:t("history.clearAll"),"aria-label":t("history.clearAll"),onClick:()=>$("all"),children:e.jsx(_,{size:13})})]}),e.jsx("strong",{children:t("history.storageUsage",{used:O(l.objectBytes),limit:O(l.maxStorageBytes)})}),e.jsx("progress",{max:l.maxStorageBytes,value:Math.min(l.objectBytes,l.maxStorageBytes)}),e.jsxs("small",{children:[t("history.versionUsage",{count:l.ordinaryVersionCount,limit:l.maxVersions}),l.labeledVersionCount>0?` · ${t("history.protectedVersions",{count:l.labeledVersionCount})}`:""]}),l.storageLimitExceeded&&e.jsx("small",{className:"history-storage-warning",children:t("history.storageExceeded")})]}),v.map(s=>e.jsxs("button",{className:s.id===x?"active":"",onClick:()=>S(s.id),children:[e.jsx(F,{size:15}),e.jsxs("span",{children:[e.jsx("strong",{children:s.label||t(`history.reasons.${s.reason}`)}),e.jsx("small",{children:new Date(s.createdAt).toLocaleString(L.resolvedLanguage)}),e.jsxs("small",{children:[s.author?.name??t("editor.deletedUser")," · ",t("history.changedCount",{count:s.changedPaths.length})]})]})]},s.id)),v.length===0&&e.jsx("p",{className:"muted padded",children:t("history.empty")})]}),e.jsx("section",{className:"history-detail",children:o&&e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:"history-detail-header",children:[e.jsxs("div",{children:[e.jsx("strong",{children:o.version.label||t(`history.reasons.${o.version.reason}`)}),e.jsxs("small",{children:[e.jsx(re,{size:12}),new Date(o.version.createdAt).toLocaleString(L.resolvedLanguage)," · ",t("history.fileCount",{count:o.version.fileCount})]})]}),e.jsxs("span",{className:"history-detail-actions",children:[U&&e.jsxs("button",{className:"danger-text",disabled:!!y,onClick:()=>$(o.version),children:[e.jsx(_,{size:14}),t("history.deleteVersion")]}),E&&e.jsxs("button",{className:"danger-text",disabled:!!y,onClick:()=>w("project"),children:[e.jsx(I,{size:14}),t("history.restoreProject")]})]})]}),E&&e.jsxs("div",{className:"history-label",children:[e.jsxs("label",{children:[e.jsx(oe,{size:14}),e.jsx("input",{value:B,maxLength:80,placeholder:t("history.labelPlaceholder"),onChange:s=>H(s.target.value)})]}),e.jsxs("button",{disabled:y==="label"||B.trim()===(o.version.label??""),onClick:()=>{K()},children:[y==="label"?e.jsx(D,{className:"spin",size:13}):e.jsx(te,{size:13}),t("history.saveLabel")]})]}),e.jsxs("div",{className:"history-files",children:[e.jsx("div",{className:"history-file-list",children:o.files.map(s=>{const i=o.version.changedPaths.includes(s.path);return e.jsxs("button",{className:s.path===C?"active":"",title:s.path,onClick:()=>{P(s.path),p(null)},children:[e.jsx(ie,{size:13}),e.jsx("span",{children:s.path}),i&&e.jsx("small",{children:t("history.changed")})]},s.path)})}),e.jsxs("div",{className:"history-file-actions",children:[e.jsxs("button",{disabled:!C||!!y,onClick:()=>{G()},children:[y==="compare"?e.jsx(D,{className:"spin",size:13}):e.jsx(F,{size:13}),t("history.compareCurrent")]}),E&&e.jsxs("button",{disabled:!C||!!y,onClick:()=>w(C),children:[e.jsx(I,{size:13}),t("history.restoreFile")]})]})]}),e.jsx("div",{className:"history-comparison",children:u?e.jsxs(e.Fragment,{children:[e.jsxs("header",{children:[e.jsx("strong",{children:u.path}),e.jsx("small",{children:t("history.comparingCurrent")})]}),e.jsx("pre",{children:X.map(([s,i],h)=>e.jsx("span",{className:s<0?"history-removed":s>0?"history-added":"",children:i},h))})]}):e.jsxs("div",{className:"history-comparison-empty",children:[e.jsx(F,{size:25}),e.jsx("span",{children:t("history.chooseFile")})]})})]})})]})]})}),e.jsx(q,{open:!!k,title:t(k==="project"?"history.restoreProjectTitle":"history.restoreFileTitle"),description:k==="project"?t("history.restoreProjectDescription"):t("history.restoreFileDescription",{path:k??""}),confirmLabel:t("history.restore"),danger:!0,onCancel:()=>w(null),onConfirm:()=>{Q()}}),e.jsx(q,{open:!!m,title:t(m==="all"?"history.clearAllTitle":"history.deleteVersionTitle"),description:m==="all"?t("history.clearAllDescription"):t("history.deleteVersionDescription",{name:Y}),confirmLabel:t(m==="all"?"history.clearAll":"history.deleteVersion"),danger:!0,onCancel:()=>$(null),onConfirm:()=>{W()}})]})}function O(r){return r<1024?`${r} B`:r<1024*1024?`${Math.round(r/102.4)/10} KB`:r<1024*1024*1024?`${Math.round(r/(1024*1024)*10)/10} MB`:`${Math.round(r/(1024*1024*1024)*10)/10} GB`}function f(r){return r instanceof Error?r.message:String(r)}function J(r){return r instanceof Error&&r.name==="AbortError"}export{de as HistoryDialog};
@@ -1,4 +1,4 @@
1
- import{u as li,r as re,j as vt}from"./react-CsO_xvbl.js";import{s as zr,E as se,V as lt,D as G,a as Bt,R as ci,P as Qr,S as ct,b as Se,f as fi,M as Jr,m as Er,i as ui,c as hi,d as di,e as pi,g as vi,h as gi,j as Or,k as Zr,l as ft,n as mi,o as yi,p as Ci,q as ki,r as wi,t as xi,u as Si,v as bi,w as Mi,x as Li,y as Xe,F as jt,A as Wt,z as Ai,W as qr,B as Ei,C as Rr,G as Tr,H as It,I as Oi,J as Ri,K as Ti,L as Ii,N as Ni,O as Bi,Q as Pi,T as Di,U as _i,X as Ki,Y as $i,Z as Fi,_ as Hi,$ as Vi,a0 as ji,a1 as Wi,a2 as Ui,a3 as zi,a4 as Qi,a5 as Ut,a6 as Ji,a7 as Zi,a8 as qi,a9 as Yi,aa as xe,ab as Xi,ac as Gi}from"./editor-DMLs-XWi.js";import{r as Ir,c as st,U as zt,a as Pt,b as Dt,d as Nr,m as eo,e as to,f as Nt,t as gt,g as mt,h as ro}from"./index-DtGvC-Uo.js";function no(s){var i=s.Pos;function l(e,t,r){if(t.line===r.line&&t.ch>=r.ch-1){var n=e.getLine(t.line),o=n.charCodeAt(t.ch);55296<=o&&o<=55551&&(r.ch+=1)}return{start:t,end:r}}var f=[{keys:"<Left>",type:"keyToKey",toKeys:"h"},{keys:"<Right>",type:"keyToKey",toKeys:"l"},{keys:"<Up>",type:"keyToKey",toKeys:"k"},{keys:"<Down>",type:"keyToKey",toKeys:"j"},{keys:"g<Up>",type:"keyToKey",toKeys:"gk"},{keys:"g<Down>",type:"keyToKey",toKeys:"gj"},{keys:"<Space>",type:"keyToKey",toKeys:"l"},{keys:"<BS>",type:"keyToKey",toKeys:"h"},{keys:"<Del>",type:"keyToKey",toKeys:"x"},{keys:"<C-Space>",type:"keyToKey",toKeys:"W"},{keys:"<C-BS>",type:"keyToKey",toKeys:"B"},{keys:"<S-Space>",type:"keyToKey",toKeys:"w"},{keys:"<S-BS>",type:"keyToKey",toKeys:"b"},{keys:"<C-n>",type:"keyToKey",toKeys:"j"},{keys:"<C-p>",type:"keyToKey",toKeys:"k"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"c",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"VdO",context:"visual"},{keys:"<Home>",type:"keyToKey",toKeys:"0"},{keys:"<End>",type:"keyToKey",toKeys:"$"},{keys:"<PageUp>",type:"keyToKey",toKeys:"<C-b>"},{keys:"<PageDown>",type:"keyToKey",toKeys:"<C-f>"},{keys:"<CR>",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"<Ins>",type:"keyToKey",toKeys:"i",context:"normal"},{keys:"<Ins>",type:"action",action:"toggleOverwrite",context:"insert"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"(",type:"motion",motion:"moveBySentence",motionArgs:{forward:!1}},{keys:")",type:"motion",motion:"moveBySentence",motionArgs:{forward:!0}},{keys:"<C-f>",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"<C-b>",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"<C-d>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"<C-u>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"g$",type:"motion",motion:"moveToEndOfDisplayLine"},{keys:"g^",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"g0",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'<register>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`<register>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:"=",type:"operator",operator:"indentAuto"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},isEdit:!0},{keys:"gc",type:"operator",operator:"toggleComment",isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"gn",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!0}},{keys:"gN",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!1}},{keys:"gq",type:"operator",operator:"hardWrap"},{keys:"gw",type:"operator",operator:"hardWrap",operatorArgs:{keepCursor:!0}},{keys:"g?",type:"operator",operator:"rot13"},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"expandToLine",motionArgs:{linewise:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"<C-u>",type:"operatorMotion",operator:"delete",motion:"moveToStartOfLine",context:"insert"},{keys:"<C-w>",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"<C-w>",type:"idle",context:"normal"},{keys:"<C-i>",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"<C-o>",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"<C-e>",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"<C-y>",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"gi",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"lastEdit"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"gI",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"bol"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"<C-v>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"<C-q>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"gJ",type:"action",action:"joinLines",actionArgs:{keepSpaces:!0},isEdit:!0},{keys:"p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r<character>",type:"action",action:"replace",isEdit:!0},{keys:"@<register>",type:"action",action:"replayMacro"},{keys:"q<register>",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0},context:"normal"},{keys:"R",type:"operator",operator:"change",operatorArgs:{linewise:!0,fullLine:!0},context:"visual",exitVisualBlock:!0},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"<C-r>",type:"action",action:"redo"},{keys:"m<register>",type:"action",action:"setMark"},{keys:'"<register>',type:"action",action:"setRegister"},{keys:"<C-r><register>",type:"action",action:"insertRegister",context:"insert",isEdit:!0},{keys:"<C-o>",type:"action",action:"oneNormalCommand",context:"insert"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z<CR>",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"<C-a>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"<C-x>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"<C-t>",type:"action",action:"indent",actionArgs:{indentRight:!0},context:"insert"},{keys:"<C-d>",type:"action",action:"indent",actionArgs:{indentRight:!1},context:"insert"},{keys:"a<register>",type:"motion",motion:"textObjectManipulation"},{keys:"i<register>",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:":",type:"ex"}],d=Object.create(null),g=f.length,w=[{name:"colorscheme",shortName:"colo"},{name:"map"},{name:"imap",shortName:"im"},{name:"nmap",shortName:"nm"},{name:"vmap",shortName:"vm"},{name:"omap",shortName:"om"},{name:"noremap",shortName:"no"},{name:"nnoremap",shortName:"nn"},{name:"vnoremap",shortName:"vn"},{name:"inoremap",shortName:"ino"},{name:"onoremap",shortName:"ono"},{name:"unmap"},{name:"mapclear",shortName:"mapc"},{name:"nmapclear",shortName:"nmapc"},{name:"vmapclear",shortName:"vmapc"},{name:"imapclear",shortName:"imapc"},{name:"omapclear",shortName:"omapc"},{name:"write",shortName:"w"},{name:"undo",shortName:"u"},{name:"redo",shortName:"red"},{name:"set",shortName:"se"},{name:"setlocal",shortName:"setl"},{name:"setglobal",shortName:"setg"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:!0},{name:"startinsert",shortName:"start"},{name:"nohlsearch",shortName:"noh"},{name:"yank",shortName:"y"},{name:"put",shortName:"pu"},{name:"delmarks",shortName:"delm"},{name:"marks",excludeFromCommandHistory:!0},{name:"registers",shortName:"reg",excludeFromCommandHistory:!0},{name:"vglobal",shortName:"v"},{name:"delete",shortName:"d"},{name:"join",shortName:"j"},{name:"normal",shortName:"norm"},{name:"global",shortName:"g"}],x=qt("");function S(e){e.setOption("disableInput",!0),e.setOption("showCursorWhenSelecting",!1),s.signal(e,"vim-mode-change",{mode:"normal"}),e.on("cursorActivity",xr),ee(e),s.on(e.getInputField(),"paste",R(e))}function B(e){e.setOption("disableInput",!1),e.off("cursorActivity",xr),s.off(e.getInputField(),"paste",R(e)),e.state.vim=null,ot&&clearTimeout(ot)}function R(e){var t=e.state.vim;return t.onPasteFn||(t.onPasteFn=function(){t.insertMode||(e.setCursor(oe(e.getCursor(),0,1)),We.enterInsertMode(e,{},t))}),t.onPasteFn}var A=/[\d]/,_=[s.isWordChar,function(e){return e&&!s.isWordChar(e)&&!/\s/.test(e)}],L=[function(e){return/\S/.test(e)}],O=["<",">"],P=["-",'"',".",":","_","/","+"],$=/^\w$/,K=/^[A-Z]$/;try{K=new RegExp("^[\\p{Lu}]$","u")}catch{}function D(e,t){return t>=e.firstLine()&&t<=e.lastLine()}function H(e){return/^[a-z]$/.test(e)}function J(e){return"()[]{}".indexOf(e)!=-1}function Z(e){return A.test(e)}function me(e){return K.test(e)}function le(e){return/^\s*$/.test(e)}function _e(e){return".?!".indexOf(e)!=-1}function Qe(e,t){for(var r=0;r<t.length;r++)if(t[r]==e)return!0;return!1}var be={};function Ke(e,t,r,n,o){if(t===void 0&&!o)throw Error("defaultValue is required unless callback is provided");if(r||(r="string"),be[e]={type:r,defaultValue:t,callback:o},n)for(var a=0;a<n.length;a++)be[n[a]]=be[e];t&&Te(e,t)}function Te(e,t,r,n){var o=be[e];n=n||{};var a=n.scope;if(!o)return new Error("Unknown option: "+e);if(o.type=="boolean"){if(t&&t!==!0)return new Error("Invalid argument: "+e+"="+t);t!==!1&&(t=!0)}o.callback?(a!=="local"&&o.callback(t,void 0),a!=="global"&&r&&o.callback(t,r)):(a!=="local"&&(o.value=o.type=="boolean"?!!t:t),a!=="global"&&r&&(r.state.vim.options[e]={value:t}))}function pe(e,t,r){var n=be[e];r=r||{};var o=r.scope;if(!n)return new Error("Unknown option: "+e);if(n.callback){let a=t&&n.callback(void 0,t);return o!=="global"&&a!==void 0?a:o!=="local"?n.callback():void 0}else return(o!=="global"&&t&&t.state.vim.options[e]||o!=="local"&&n||{}).value}Ke("filetype",void 0,"string",["ft"],function(e,t){if(t!==void 0)if(e===void 0){let r=t.getOption("mode");return r=="null"?"":r}else{let r=e==""?"null":e;t.setOption("mode",r)}}),Ke("textwidth",80,"number",["tw"],function(e,t){if(t!==void 0)if(e===void 0){var r=t.getOption("textwidth");return r}else{var n=Math.round(e);n>1&&t.setOption("textwidth",n)}});var et=function(){var e=100,t=-1,r=0,n=0,o=new Array(e);function a(h,p,v){var y=t%e,C=o[y];function k(b){var E=++t%e,N=o[E];N&&N.clear(),o[E]=h.setBookmark(b)}if(C){var m=C.find();m&&!Le(m,p)&&k(p)}else k(p);k(v),r=t,n=t-e+1,n<0&&(n=0)}function c(h,p){t+=p,t>r?t=r:t<n&&(t=n);var v=o[(e+t)%e];if(v&&!v.find()){var y=p>0?1:-1,C,k=h.getCursor();do if(t+=y,v=o[(e+t)%e],v&&(C=v.find())&&!Le(k,C))break;while(t<r&&t>n)}return v}function u(h,p){var v=t,y=c(h,p);return t=v,y&&y.find()}return{cachedCursor:void 0,add:a,find:u,move:c}},tt=function(e){return e?{changes:e.changes,expectCursorActivityForChange:e.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};class j{constructor(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=tt()}exitMacroRecordMode(){var t=M.macroModeState;t.onRecordingDone&&t.onRecordingDone(),t.onRecordingDone=void 0,t.isRecording=!1}enterMacroRecordMode(t,r){var n=M.registerController.getRegister(r);if(n){if(n.clear(),this.latestRegister=r,t.openDialog){var o=Oe("span",{class:"cm-vim-message"},"recording @"+r);this.onRecordingDone=t.openDialog(o,function(){},{bottom:!0})}this.isRecording=!0}}}function ee(e){return e.state.vim||(e.state.vim={inputState:new Yt,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},insertMode:!1,insertModeReturn:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:void 0,sel:{anchor:new i(0,0),head:new i(0,0)},options:{},expectLiteralNext:!1,status:""}),e.state.vim}var M;function ne(){M={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:et(),macroModeState:new j,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new yn({}),searchHistoryController:new Xt,exCommandHistoryController:new Xt};for(var e in be){var t=be[e];t.value=t.defaultValue}}class q{constructor(t,r){this.keyName=t,this.key=r.key,this.ctrlKey=r.ctrlKey,this.altKey=r.altKey,this.metaKey=r.metaKey,this.shiftKey=r.shiftKey}}var Me,ke={enterVimMode:S,leaveVimMode:B,buildKeyMap:function(){},getRegisterController:function(){return M.registerController},resetVimGlobalState_:ne,getVimGlobalState_:function(){return M},maybeInitVimState_:ee,suppressErrorLogging:!1,InsertModeKey:q,map:function(e,t,r){ye.map(e,t,r)},unmap:function(e,t){return ye.unmap(e,t)},noremap:function(e,t,r){ye.map(e,t,r,!0)},mapclear:function(e){var t=f.length,r=g,n=f.slice(0,t-r);if(f=f.slice(t-r),e)for(var o=n.length-1;o>=0;o--){var a=n[o];if(e!==a.context)if(a.context)this._mapCommand(a);else{var c=["normal","insert","visual"];for(var u in c)if(c[u]!==e){var h=Object.assign({},a);h.context=c[u],this._mapCommand(h)}}}},langmap:Zt,vimKeyFromEvent:nt,setOption:Te,getOption:pe,defineOption:Ke,defineEx:function(e,t,r){if(!t)t=e;else if(e.indexOf(t)!==0)throw new Error('(Vim.defineEx) "'+t+'" is not a prefix of "'+e+'", command not registered');kr[e]=r,ye.commandMap_[t]={name:e,shortName:t,type:"api"}},handleKey:function(e,t,r){var n=this.findKey(e,t,r);if(typeof n=="function")return n()},multiSelectHandleKey:si,findKey:function(e,t,r){var n=ee(e),o=e;function a(){var v=M.macroModeState;if(v.isRecording){if(t=="q")return v.exitMacroRecordMode(),ce(o),!0;r!="mapping"&&ii(v,t)}}function c(){if(t=="<Esc>"){if(n.visualMode)Be(o);else if(n.insertMode)He(o);else return;return ce(o),!0}}function u(){if(c())return!0;n.inputState.keyBuffer.push(t);var v=n.inputState.keyBuffer.join(""),y=t.length==1,C=je.matchCommand(v,f,n.inputState,"insert"),k=n.inputState.changeQueue;if(C.type=="none")return ce(o),!1;if(C.type=="partial"){if(C.expectLiteralNext&&(n.expectLiteralNext=!0),Me&&window.clearTimeout(Me),Me=y&&window.setTimeout(function(){n.insertMode&&n.inputState.keyBuffer.length&&ce(o)},pe("insertModeEscKeysTimeout")),y){var m=o.listSelections();(!k||k.removed.length!=m.length)&&(k=n.inputState.changeQueue=new gn),k.inserted+=t;for(var b=0;b<m.length;b++){var E=ge(m[b].anchor,m[b].head),N=Fe(m[b].anchor,m[b].head),T=o.getRange(E,o.state.overwrite?oe(N,0,1):N);k.removed[b]=(k.removed[b]||"")+T}}return!y}else C.type=="full"&&(n.inputState.keyBuffer.length=0);if(n.expectLiteralNext=!1,Me&&window.clearTimeout(Me),C.command&&k){for(var m=o.listSelections(),b=0;b<m.length;b++){var I=m[b].head;o.replaceRange(k.removed[b]||"",oe(I,0,-k.inserted.length),I,"+input")}M.macroModeState.lastInsertModeChanges.changes.pop()}return C.command||ce(o),C.command}function h(){if(a()||c())return!0;n.inputState.keyBuffer.push(t);var v=n.inputState.keyBuffer.join("");if(/^[1-9]\d*$/.test(v))return!0;var y=/^(\d*)(.*)$/.exec(v);if(!y)return ce(o),!1;var C=n.visualMode?"visual":"normal",k=y[2]||y[1];n.inputState.operatorShortcut&&n.inputState.operatorShortcut.slice(-1)==k&&(k=n.inputState.operatorShortcut);var m=je.matchCommand(k,f,n.inputState,C);return m.type=="none"?(ce(o),!1):m.type=="partial"?(m.expectLiteralNext&&(n.expectLiteralNext=!0),!0):m.type=="clear"?(ce(o),!0):(n.expectLiteralNext=!1,n.inputState.keyBuffer.length=0,y=/^(\d*)(.*)$/.exec(v),y&&y[1]&&y[1]!="0"&&n.inputState.pushRepeatDigit(y[1]),m.command)}var p=n.insertMode?u():h();if(p===!1)return!n.insertMode&&(t.length===1||s.isMac&&/<A-.>/.test(t))?function(){return!0}:void 0;if(p===!0)return function(){return!0};if(p)return function(){return o.operation(function(){o.curOp.isVimOp=!0;try{if(typeof p!="object")return;p.type=="keyToKey"?rt(o,p.toKeys,p):je.processCommand(o,n,p)}catch(v){throw o.state.vim=void 0,ee(o),ke.suppressErrorLogging||console.log(v),v}return!0})}},handleEx:function(e,t){ye.processCommand(e,t)},defineMotion:Cn,defineAction:wn,defineOperator:kn,mapCommand:ri,_mapCommand:Et,defineRegister:mn,exitVisualMode:Be,exitInsertMode:He},Je=[],ut=!1,ie;function pn(e){if(!ie)throw new Error("No prompt to send key to");if(e[0]=="<"){var t=e.toLowerCase().slice(1,-1),r=t.split("-");if(t=r.pop()||"",t=="lt")e="<";else if(t=="space")e=" ";else if(t=="cr")e=`
1
+ import{u as li,r as re,j as vt}from"./react-CsO_xvbl.js";import{s as zr,E as se,V as lt,D as G,a as Bt,R as ci,P as Qr,S as ct,b as Se,f as fi,M as Jr,m as Er,i as ui,c as hi,d as di,e as pi,g as vi,h as gi,j as Or,k as Zr,l as ft,n as mi,o as yi,p as Ci,q as ki,r as wi,t as xi,u as Si,v as bi,w as Mi,x as Li,y as Xe,F as jt,A as Wt,z as Ai,W as qr,B as Ei,C as Rr,G as Tr,H as It,I as Oi,J as Ri,K as Ti,L as Ii,N as Ni,O as Bi,Q as Pi,T as Di,U as _i,X as Ki,Y as $i,Z as Fi,_ as Hi,$ as Vi,a0 as ji,a1 as Wi,a2 as Ui,a3 as zi,a4 as Qi,a5 as Ut,a6 as Ji,a7 as Zi,a8 as qi,a9 as Yi,aa as xe,ab as Xi,ac as Gi}from"./editor-DMLs-XWi.js";import{r as Ir,c as st,U as zt,a as Pt,b as Dt,d as Nr,m as eo,e as to,f as Nt,t as gt,g as mt,h as ro}from"./index-BI4dns2b.js";function no(s){var i=s.Pos;function l(e,t,r){if(t.line===r.line&&t.ch>=r.ch-1){var n=e.getLine(t.line),o=n.charCodeAt(t.ch);55296<=o&&o<=55551&&(r.ch+=1)}return{start:t,end:r}}var f=[{keys:"<Left>",type:"keyToKey",toKeys:"h"},{keys:"<Right>",type:"keyToKey",toKeys:"l"},{keys:"<Up>",type:"keyToKey",toKeys:"k"},{keys:"<Down>",type:"keyToKey",toKeys:"j"},{keys:"g<Up>",type:"keyToKey",toKeys:"gk"},{keys:"g<Down>",type:"keyToKey",toKeys:"gj"},{keys:"<Space>",type:"keyToKey",toKeys:"l"},{keys:"<BS>",type:"keyToKey",toKeys:"h"},{keys:"<Del>",type:"keyToKey",toKeys:"x"},{keys:"<C-Space>",type:"keyToKey",toKeys:"W"},{keys:"<C-BS>",type:"keyToKey",toKeys:"B"},{keys:"<S-Space>",type:"keyToKey",toKeys:"w"},{keys:"<S-BS>",type:"keyToKey",toKeys:"b"},{keys:"<C-n>",type:"keyToKey",toKeys:"j"},{keys:"<C-p>",type:"keyToKey",toKeys:"k"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"c",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"VdO",context:"visual"},{keys:"<Home>",type:"keyToKey",toKeys:"0"},{keys:"<End>",type:"keyToKey",toKeys:"$"},{keys:"<PageUp>",type:"keyToKey",toKeys:"<C-b>"},{keys:"<PageDown>",type:"keyToKey",toKeys:"<C-f>"},{keys:"<CR>",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"<Ins>",type:"keyToKey",toKeys:"i",context:"normal"},{keys:"<Ins>",type:"action",action:"toggleOverwrite",context:"insert"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"(",type:"motion",motion:"moveBySentence",motionArgs:{forward:!1}},{keys:")",type:"motion",motion:"moveBySentence",motionArgs:{forward:!0}},{keys:"<C-f>",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"<C-b>",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"<C-d>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"<C-u>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"g$",type:"motion",motion:"moveToEndOfDisplayLine"},{keys:"g^",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"g0",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'<register>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`<register>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:"=",type:"operator",operator:"indentAuto"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},isEdit:!0},{keys:"gc",type:"operator",operator:"toggleComment",isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"gn",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!0}},{keys:"gN",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!1}},{keys:"gq",type:"operator",operator:"hardWrap"},{keys:"gw",type:"operator",operator:"hardWrap",operatorArgs:{keepCursor:!0}},{keys:"g?",type:"operator",operator:"rot13"},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"expandToLine",motionArgs:{linewise:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"<C-u>",type:"operatorMotion",operator:"delete",motion:"moveToStartOfLine",context:"insert"},{keys:"<C-w>",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"<C-w>",type:"idle",context:"normal"},{keys:"<C-i>",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"<C-o>",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"<C-e>",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"<C-y>",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"gi",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"lastEdit"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"gI",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"bol"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"<C-v>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"<C-q>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"gJ",type:"action",action:"joinLines",actionArgs:{keepSpaces:!0},isEdit:!0},{keys:"p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r<character>",type:"action",action:"replace",isEdit:!0},{keys:"@<register>",type:"action",action:"replayMacro"},{keys:"q<register>",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0},context:"normal"},{keys:"R",type:"operator",operator:"change",operatorArgs:{linewise:!0,fullLine:!0},context:"visual",exitVisualBlock:!0},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"<C-r>",type:"action",action:"redo"},{keys:"m<register>",type:"action",action:"setMark"},{keys:'"<register>',type:"action",action:"setRegister"},{keys:"<C-r><register>",type:"action",action:"insertRegister",context:"insert",isEdit:!0},{keys:"<C-o>",type:"action",action:"oneNormalCommand",context:"insert"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z<CR>",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"<C-a>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"<C-x>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"<C-t>",type:"action",action:"indent",actionArgs:{indentRight:!0},context:"insert"},{keys:"<C-d>",type:"action",action:"indent",actionArgs:{indentRight:!1},context:"insert"},{keys:"a<register>",type:"motion",motion:"textObjectManipulation"},{keys:"i<register>",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:":",type:"ex"}],d=Object.create(null),g=f.length,w=[{name:"colorscheme",shortName:"colo"},{name:"map"},{name:"imap",shortName:"im"},{name:"nmap",shortName:"nm"},{name:"vmap",shortName:"vm"},{name:"omap",shortName:"om"},{name:"noremap",shortName:"no"},{name:"nnoremap",shortName:"nn"},{name:"vnoremap",shortName:"vn"},{name:"inoremap",shortName:"ino"},{name:"onoremap",shortName:"ono"},{name:"unmap"},{name:"mapclear",shortName:"mapc"},{name:"nmapclear",shortName:"nmapc"},{name:"vmapclear",shortName:"vmapc"},{name:"imapclear",shortName:"imapc"},{name:"omapclear",shortName:"omapc"},{name:"write",shortName:"w"},{name:"undo",shortName:"u"},{name:"redo",shortName:"red"},{name:"set",shortName:"se"},{name:"setlocal",shortName:"setl"},{name:"setglobal",shortName:"setg"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:!0},{name:"startinsert",shortName:"start"},{name:"nohlsearch",shortName:"noh"},{name:"yank",shortName:"y"},{name:"put",shortName:"pu"},{name:"delmarks",shortName:"delm"},{name:"marks",excludeFromCommandHistory:!0},{name:"registers",shortName:"reg",excludeFromCommandHistory:!0},{name:"vglobal",shortName:"v"},{name:"delete",shortName:"d"},{name:"join",shortName:"j"},{name:"normal",shortName:"norm"},{name:"global",shortName:"g"}],x=qt("");function S(e){e.setOption("disableInput",!0),e.setOption("showCursorWhenSelecting",!1),s.signal(e,"vim-mode-change",{mode:"normal"}),e.on("cursorActivity",xr),ee(e),s.on(e.getInputField(),"paste",R(e))}function B(e){e.setOption("disableInput",!1),e.off("cursorActivity",xr),s.off(e.getInputField(),"paste",R(e)),e.state.vim=null,ot&&clearTimeout(ot)}function R(e){var t=e.state.vim;return t.onPasteFn||(t.onPasteFn=function(){t.insertMode||(e.setCursor(oe(e.getCursor(),0,1)),We.enterInsertMode(e,{},t))}),t.onPasteFn}var A=/[\d]/,_=[s.isWordChar,function(e){return e&&!s.isWordChar(e)&&!/\s/.test(e)}],L=[function(e){return/\S/.test(e)}],O=["<",">"],P=["-",'"',".",":","_","/","+"],$=/^\w$/,K=/^[A-Z]$/;try{K=new RegExp("^[\\p{Lu}]$","u")}catch{}function D(e,t){return t>=e.firstLine()&&t<=e.lastLine()}function H(e){return/^[a-z]$/.test(e)}function J(e){return"()[]{}".indexOf(e)!=-1}function Z(e){return A.test(e)}function me(e){return K.test(e)}function le(e){return/^\s*$/.test(e)}function _e(e){return".?!".indexOf(e)!=-1}function Qe(e,t){for(var r=0;r<t.length;r++)if(t[r]==e)return!0;return!1}var be={};function Ke(e,t,r,n,o){if(t===void 0&&!o)throw Error("defaultValue is required unless callback is provided");if(r||(r="string"),be[e]={type:r,defaultValue:t,callback:o},n)for(var a=0;a<n.length;a++)be[n[a]]=be[e];t&&Te(e,t)}function Te(e,t,r,n){var o=be[e];n=n||{};var a=n.scope;if(!o)return new Error("Unknown option: "+e);if(o.type=="boolean"){if(t&&t!==!0)return new Error("Invalid argument: "+e+"="+t);t!==!1&&(t=!0)}o.callback?(a!=="local"&&o.callback(t,void 0),a!=="global"&&r&&o.callback(t,r)):(a!=="local"&&(o.value=o.type=="boolean"?!!t:t),a!=="global"&&r&&(r.state.vim.options[e]={value:t}))}function pe(e,t,r){var n=be[e];r=r||{};var o=r.scope;if(!n)return new Error("Unknown option: "+e);if(n.callback){let a=t&&n.callback(void 0,t);return o!=="global"&&a!==void 0?a:o!=="local"?n.callback():void 0}else return(o!=="global"&&t&&t.state.vim.options[e]||o!=="local"&&n||{}).value}Ke("filetype",void 0,"string",["ft"],function(e,t){if(t!==void 0)if(e===void 0){let r=t.getOption("mode");return r=="null"?"":r}else{let r=e==""?"null":e;t.setOption("mode",r)}}),Ke("textwidth",80,"number",["tw"],function(e,t){if(t!==void 0)if(e===void 0){var r=t.getOption("textwidth");return r}else{var n=Math.round(e);n>1&&t.setOption("textwidth",n)}});var et=function(){var e=100,t=-1,r=0,n=0,o=new Array(e);function a(h,p,v){var y=t%e,C=o[y];function k(b){var E=++t%e,N=o[E];N&&N.clear(),o[E]=h.setBookmark(b)}if(C){var m=C.find();m&&!Le(m,p)&&k(p)}else k(p);k(v),r=t,n=t-e+1,n<0&&(n=0)}function c(h,p){t+=p,t>r?t=r:t<n&&(t=n);var v=o[(e+t)%e];if(v&&!v.find()){var y=p>0?1:-1,C,k=h.getCursor();do if(t+=y,v=o[(e+t)%e],v&&(C=v.find())&&!Le(k,C))break;while(t<r&&t>n)}return v}function u(h,p){var v=t,y=c(h,p);return t=v,y&&y.find()}return{cachedCursor:void 0,add:a,find:u,move:c}},tt=function(e){return e?{changes:e.changes,expectCursorActivityForChange:e.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};class j{constructor(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=tt()}exitMacroRecordMode(){var t=M.macroModeState;t.onRecordingDone&&t.onRecordingDone(),t.onRecordingDone=void 0,t.isRecording=!1}enterMacroRecordMode(t,r){var n=M.registerController.getRegister(r);if(n){if(n.clear(),this.latestRegister=r,t.openDialog){var o=Oe("span",{class:"cm-vim-message"},"recording @"+r);this.onRecordingDone=t.openDialog(o,function(){},{bottom:!0})}this.isRecording=!0}}}function ee(e){return e.state.vim||(e.state.vim={inputState:new Yt,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},insertMode:!1,insertModeReturn:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:void 0,sel:{anchor:new i(0,0),head:new i(0,0)},options:{},expectLiteralNext:!1,status:""}),e.state.vim}var M;function ne(){M={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:et(),macroModeState:new j,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new yn({}),searchHistoryController:new Xt,exCommandHistoryController:new Xt};for(var e in be){var t=be[e];t.value=t.defaultValue}}class q{constructor(t,r){this.keyName=t,this.key=r.key,this.ctrlKey=r.ctrlKey,this.altKey=r.altKey,this.metaKey=r.metaKey,this.shiftKey=r.shiftKey}}var Me,ke={enterVimMode:S,leaveVimMode:B,buildKeyMap:function(){},getRegisterController:function(){return M.registerController},resetVimGlobalState_:ne,getVimGlobalState_:function(){return M},maybeInitVimState_:ee,suppressErrorLogging:!1,InsertModeKey:q,map:function(e,t,r){ye.map(e,t,r)},unmap:function(e,t){return ye.unmap(e,t)},noremap:function(e,t,r){ye.map(e,t,r,!0)},mapclear:function(e){var t=f.length,r=g,n=f.slice(0,t-r);if(f=f.slice(t-r),e)for(var o=n.length-1;o>=0;o--){var a=n[o];if(e!==a.context)if(a.context)this._mapCommand(a);else{var c=["normal","insert","visual"];for(var u in c)if(c[u]!==e){var h=Object.assign({},a);h.context=c[u],this._mapCommand(h)}}}},langmap:Zt,vimKeyFromEvent:nt,setOption:Te,getOption:pe,defineOption:Ke,defineEx:function(e,t,r){if(!t)t=e;else if(e.indexOf(t)!==0)throw new Error('(Vim.defineEx) "'+t+'" is not a prefix of "'+e+'", command not registered');kr[e]=r,ye.commandMap_[t]={name:e,shortName:t,type:"api"}},handleKey:function(e,t,r){var n=this.findKey(e,t,r);if(typeof n=="function")return n()},multiSelectHandleKey:si,findKey:function(e,t,r){var n=ee(e),o=e;function a(){var v=M.macroModeState;if(v.isRecording){if(t=="q")return v.exitMacroRecordMode(),ce(o),!0;r!="mapping"&&ii(v,t)}}function c(){if(t=="<Esc>"){if(n.visualMode)Be(o);else if(n.insertMode)He(o);else return;return ce(o),!0}}function u(){if(c())return!0;n.inputState.keyBuffer.push(t);var v=n.inputState.keyBuffer.join(""),y=t.length==1,C=je.matchCommand(v,f,n.inputState,"insert"),k=n.inputState.changeQueue;if(C.type=="none")return ce(o),!1;if(C.type=="partial"){if(C.expectLiteralNext&&(n.expectLiteralNext=!0),Me&&window.clearTimeout(Me),Me=y&&window.setTimeout(function(){n.insertMode&&n.inputState.keyBuffer.length&&ce(o)},pe("insertModeEscKeysTimeout")),y){var m=o.listSelections();(!k||k.removed.length!=m.length)&&(k=n.inputState.changeQueue=new gn),k.inserted+=t;for(var b=0;b<m.length;b++){var E=ge(m[b].anchor,m[b].head),N=Fe(m[b].anchor,m[b].head),T=o.getRange(E,o.state.overwrite?oe(N,0,1):N);k.removed[b]=(k.removed[b]||"")+T}}return!y}else C.type=="full"&&(n.inputState.keyBuffer.length=0);if(n.expectLiteralNext=!1,Me&&window.clearTimeout(Me),C.command&&k){for(var m=o.listSelections(),b=0;b<m.length;b++){var I=m[b].head;o.replaceRange(k.removed[b]||"",oe(I,0,-k.inserted.length),I,"+input")}M.macroModeState.lastInsertModeChanges.changes.pop()}return C.command||ce(o),C.command}function h(){if(a()||c())return!0;n.inputState.keyBuffer.push(t);var v=n.inputState.keyBuffer.join("");if(/^[1-9]\d*$/.test(v))return!0;var y=/^(\d*)(.*)$/.exec(v);if(!y)return ce(o),!1;var C=n.visualMode?"visual":"normal",k=y[2]||y[1];n.inputState.operatorShortcut&&n.inputState.operatorShortcut.slice(-1)==k&&(k=n.inputState.operatorShortcut);var m=je.matchCommand(k,f,n.inputState,C);return m.type=="none"?(ce(o),!1):m.type=="partial"?(m.expectLiteralNext&&(n.expectLiteralNext=!0),!0):m.type=="clear"?(ce(o),!0):(n.expectLiteralNext=!1,n.inputState.keyBuffer.length=0,y=/^(\d*)(.*)$/.exec(v),y&&y[1]&&y[1]!="0"&&n.inputState.pushRepeatDigit(y[1]),m.command)}var p=n.insertMode?u():h();if(p===!1)return!n.insertMode&&(t.length===1||s.isMac&&/<A-.>/.test(t))?function(){return!0}:void 0;if(p===!0)return function(){return!0};if(p)return function(){return o.operation(function(){o.curOp.isVimOp=!0;try{if(typeof p!="object")return;p.type=="keyToKey"?rt(o,p.toKeys,p):je.processCommand(o,n,p)}catch(v){throw o.state.vim=void 0,ee(o),ke.suppressErrorLogging||console.log(v),v}return!0})}},handleEx:function(e,t){ye.processCommand(e,t)},defineMotion:Cn,defineAction:wn,defineOperator:kn,mapCommand:ri,_mapCommand:Et,defineRegister:mn,exitVisualMode:Be,exitInsertMode:He},Je=[],ut=!1,ie;function pn(e){if(!ie)throw new Error("No prompt to send key to");if(e[0]=="<"){var t=e.toLowerCase().slice(1,-1),r=t.split("-");if(t=r.pop()||"",t=="lt")e="<";else if(t=="space")e=" ";else if(t=="cr")e=`
2
2
  `;else if(Ze[t]){var n=ie.value||"",o={key:Ze[t],target:{value:n,selectionEnd:n.length,selectionStart:n.length}};ie.onKeyDown&&ie.onKeyDown(o,ie.value,c),ie&&ie.onKeyUp&&ie.onKeyUp(o,ie.value,c);return}}if(e==`
3
3
  `){var a=ie;ie=null,a.onClose&&a.onClose(a.value)}else ie.value=(ie.value||"")+e;function c(u){ie&&(typeof u=="string"?ie.value=u:ie=null)}}function rt(e,t,r){var n=ut;if(r){if(Je.indexOf(r)!=-1)return;Je.push(r),ut=r.noremap!=!1}try{for(var o=ee(e),a=/<(?:[CSMA]-)*\w+>|./gi,c;c=a.exec(t);){var u=c[0],h=o.insertMode;if(ie){pn(u);continue}var p=ke.handleKey(e,u,"mapping");if(!p&&h&&o.insertMode){if(u[0]=="<"){var v=u.toLowerCase().slice(1,-1),y=v.split("-");if(v=y.pop()||"",v=="lt")u="<";else if(v=="space")u=" ";else if(v=="cr")u=`
4
4
  `;else if(Ze.hasOwnProperty(v)){u=Ze[v],Lr(e,u);continue}else u=u[0],a.lastIndex=c.index+1}e.replaceSelection(u)}}}finally{if(Je.pop(),ut=Je.length?n:!1,!Je.length&&ie){var C=ie;ie=null,dt(e,C)}}}var kt={Return:"CR",Backspace:"BS",Delete:"Del",Escape:"Esc",Insert:"Ins",ArrowLeft:"Left",ArrowRight:"Right",ArrowUp:"Up",ArrowDown:"Down",Enter:"CR"," ":"Space"},vn={Shift:1,Alt:1,Command:1,Control:1,CapsLock:1,AltGraph:1,Dead:1,Unidentified:1},Ze={};"Left|Right|Up|Down|End|Home".split("|").concat(Object.keys(kt)).forEach(function(e){Ze[(kt[e]||"").toLowerCase()]=Ze[e.toLowerCase()]=e});function nt(e,t){var r=e.key;if(!vn[r]){r.length>1&&r[0]=="n"&&(r=r.replace("Numpad","")),r=kt[r]||r;var n="";if(e.ctrlKey&&(n+="C-"),e.altKey&&(n+="A-"),e.metaKey&&(n+="M-"),s.isMac&&n=="A-"&&r.length==1&&(n=n.slice(2)),(n||r.length>1)&&e.shiftKey&&(n+="S-"),t&&!t.expectLiteralNext&&r.length==1){if(x.keymap&&r in x.keymap)(x.remapCtrl!=!1||!n)&&(r=x.keymap[r]);else if(r.charCodeAt(0)>128&&!d[r]){var o=e.code?.slice(-1)||"";e.shiftKey||(o=o.toLowerCase()),o&&(r=o,!n&&e.altKey&&(n="A-"))}}return n+=r,n.length>1&&(n="<"+n+">"),n}}function Zt(e,t){x.string!==e&&(x=qt(e)),x.remapCtrl=t}function qt(e){let t={};if(!e)return{keymap:t,string:""};function r(n){return n.split(/\\?(.)/).filter(Boolean)}return e.split(/((?:[^\\,]|\\.)+),/).map(n=>{if(!n)return;const o=n.split(/((?:[^\\;]|\\.)+);/);if(o.length==3){const a=r(o[1]),c=r(o[2]);if(a.length!==c.length)return;for(let u=0;u<a.length;++u)t[a[u]]=c[u]}else if(o.length==1){const a=r(n);if(a.length%2!==0)return;for(let c=0;c<a.length;c+=2)t[a[c]]=a[c+1]}}),{keymap:t,string:e}}Ke("langmap",void 0,"string",["lmap"],function(e,t){if(e===void 0)return x.string;Zt(e)});class Yt{constructor(){this.prefixRepeat=[],this.motionRepeat=[],this.operator=null,this.operatorArgs=null,this.motion=null,this.motionArgs=null,this.keyBuffer=[],this.registerName=void 0,this.changeQueue=null}pushRepeatDigit(t){this.operator?this.motionRepeat=this.motionRepeat.concat(t):this.prefixRepeat=this.prefixRepeat.concat(t)}getRepeat(){var t=0;return(this.prefixRepeat.length>0||this.motionRepeat.length>0)&&(t=1,this.prefixRepeat.length>0&&(t*=parseInt(this.prefixRepeat.join(""),10)),this.motionRepeat.length>0&&(t*=parseInt(this.motionRepeat.join(""),10))),t}}function ce(e,t){e.state.vim.inputState=new Yt,e.state.vim.expectLiteralNext=!1,s.signal(e,"vim-command-done",t)}function gn(){this.removed=[],this.inserted=""}class Ie{constructor(t,r,n){this.clear(),this.keyBuffer=[t||""],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!!r,this.blockwise=!!n}setText(t,r,n){this.keyBuffer=[t||""],this.linewise=!!r,this.blockwise=!!n}pushText(t,r){r&&(this.linewise||this.keyBuffer.push(`
@@ -58,4 +58,4 @@ mark line col
58
58
  `+w+`
59
59
  `+w+"\\end{"+x+"}",B=f+x.length+1+1+w.length+1,R=i.state.sliceDoc(d,d+1)==="}"?1:0;i.dispatch({changes:{from:f,to:d+R,insert:S},selection:{anchor:B},annotations:[Xi.of(l),Ut.userEvent.of("input.complete")]})}}}function ha(s,i,l,f,d){const g=Yo(s.state.doc.toString(),i,l,f);if(!g)return!1;s.dispatch(d());const w=i+f.length;return s.dispatch({changes:{from:w,insert:g.insert},selection:{anchor:w+g.cursorOffset},annotations:Ut.userEvent.of("input.complete")}),!0}function da(s,i,l){if(fa(s))return null;const f=sa(s),d=s.matchBefore(/\\[A-Za-z@0-9:_]*$/);if(d||s.explicit)return{from:d?.from??s.pos,options:Hr(ze(i,f.commands,l?.commands??[],oa())),validFor:/^\\[A-Za-z@0-9:_]*$/};const g=ca(s);if(g){const A=ze(i,Vr(f.environments),Vr(l?.environments??[]));return{from:g.from,options:Hr(g.command==="begin"?A.map(ua):A),validFor:/^[A-Za-z0-9*:_-]*$/}}const w=Ge(s,/\\(?:ref|pageref|autoref|nameref|cref|Cref|eqref|vref)\s*(?:\[[^]]*\])?\{([^{}]*)$/)??Ge(s,/\\hyperref\[([^\[\]]*)$/);if(w)return{from:w.from,options:ze(i,f.labels,l?.labels??[]),validFor:/^[^{}]*$/};const x=Ge(s,/\\(?:cite|citep|citet|parencite|textcite|autocite|footcite)(?:\w*)?(?:\[[^]]*\])?\{([^{}]*)$/);if(x)return{from:x.from,options:ze(i,f.citations,l?.citations??[]),validFor:/^[^{}]*$/};const S=Ge(s,/\\(?:input|include|subfile|includegraphics|bibliography|addbibresource)\s*(?:\[[^]]*\])?\{([^{}]*)$/);if(S)return{from:S.from,options:ze(i,f.files,l?.files??[]),validFor:/^[^{}]*$/};const B=Ge(s,/\\(?:usepackage|RequirePackage)\s*(?:\[[^]]*\])?\{([^{}]*)$/);if(B)return{from:B.from,options:ze(i,f.packages,l?.packages??[]),validFor:/^[^{}]*$/};const R=Ge(s,/\\documentclass\s*(?:\[[^]]*\])?\{([^{}]*)$/);return R?{from:R.from,options:ze(i,l?.files??[]),validFor:/^[^{}]*$/}:null}const pa=Zi.of((s,i)=>{const l=s.doc.lineAt(i),f=l.text.match(/\\begin\{([^}]+)\}/);if(f){let g=1;for(let w=l.number+1;w<=s.doc.lines;w+=1){const x=s.doc.line(w),S=f[1].replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(g+=(x.text.match(new RegExp(`\\\\begin\\{${S}\\}`,"g"))??[]).length,g-=(x.text.match(new RegExp(`\\\\end\\{${S}\\}`,"g"))??[]).length,g===0&&x.from>l.to)return{from:l.to,to:x.from}}}const d=l.text.match(/^\s*\\(part|chapter|section|subsection|subsubsection)\*?/);if(d){const g={part:0,chapter:0,section:1,subsection:2,subsubsection:3},w=g[d[1]];for(let x=l.number+1;x<=s.doc.lines;x+=1){const S=s.doc.line(x),B=S.text.match(/^\s*\\(part|chapter|section|subsection|subsubsection)\*?/);if(B&&g[B[1]]<=w)return{from:l.to,to:Math.max(l.to,S.from-1)}}if(l.to<s.doc.length)return{from:l.to,to:s.doc.length}}return null});function Sa({value:s,readOnly:i,comments:l,focusComment:f,preferences:d,completionIndex:g,jumpTo:w,searchRequest:x,spellCheckWords:S,spellCheckIssues:B,spellCheckJump:R,collaboration:A,onChange:_,onSelection:L,onCommentClick:O,onCursor:P}){const{t:$,i18n:K}=li(),D=re.useRef(null),H=re.useRef(null),J=re.useRef(_),Z=re.useRef(L),me=re.useRef(O),le=re.useRef(P),_e=re.useRef(x),Qe=re.useRef(g),be=re.useRef(new Tr),Ke=re.useRef(new Tr),Te=re.useRef(null),[pe,et]=re.useState(d.vimMode?"NORMAL":"");J.current=_,Z.current=L,me.current=O,le.current=P,Qe.current=g;const tt=(j,ee)=>{if(Te.current?.(),Te.current=null,!ee){et("");return}const M=an(j);if(!M){et("NORMAL");return}const ne=()=>{const q=M.state.vim?.mode??(M.state.vim?.insertMode?"insert":"normal");et(q.toUpperCase())};ne(),M.on("vim-mode-change",ne),Te.current=()=>M.off("vim-mode-change",ne)};return re.useEffect(()=>{if(!D.current)return;const j=A&&!i?new zt(A.text):null,ee=It.create({doc:A?.text.toString()??s,extensions:[Oi(),Ri(),...A?[]:[Ti()],Ii(),Ni(),Bi(),Zo,Pi(Yi),Di(),Qr.high(se.inputHandler.of(ha)),_i(),Ki(),pa,ea,ta,ra,ia,$i({top:!0}),ga($),It.phrases.of(va($)),Fi({override:[M=>da(M,$,Qe.current)],activateOnTyping:!0}),...j?[Jt.of({undo:()=>j.undo()!==null,redo:()=>j.redo()!==null})]:[],Ke.current.of(d.vimMode?_r():[]),Hi.of([...Vi,...ji,...Wi,...Ui,...A&&!i?jo:[],...zi,...A?[]:Qi]),...A?[Wo(A.text,A.awareness,{undoManager:j??!1})]:[],It.readOnly.of(i),be.current.of(jr(d)),se.domEventHandlers({click(M){const ne=M.target.closest("[data-comment-id]");return ne?.dataset.commentId&&me.current(ne.dataset.commentId),!1},blur(M,ne){const q=ne.state.selection.main;return Z.current(ne.state.sliceDoc(q.from,q.to),q.from,q.to),A?.awareness.setLocalStateField("cursor",null),!1}}),se.updateListener.of(M=>{const ne=M.transactions.some(q=>q.annotation(Kr));if(M.docChanged&&!ne&&J.current(M.state.doc.toString()),M.selectionSet&&!M.docChanged&&M.transactions.some(q=>q.isUserEvent("input"))){const q=M.state.selection.main.head,Me=Xo(M.state.doc.toString(),q);Me&&M.view.dispatch({changes:{from:q,insert:Me.insert},selection:{anchor:q+Me.cursorOffset},annotations:Ut.userEvent.of("input.complete")})}if(M.selectionSet||M.docChanged){const q=M.state.selection.main;Z.current(M.state.sliceDoc(q.from,q.to),q.from,q.to);const Me=M.state.doc.lineAt(q.head);le.current(Me.number,q.head-Me.from+1)}})]});return H.current=new se({state:ee,parent:D.current}),tt(H.current,d.vimMode),H.current.dispatch({effects:Ht.of(Ur(l))}),()=>{Te.current?.(),Te.current=null,H.current?.destroy(),H.current=null}},[i,K.resolvedLanguage,A?.text]),re.useEffect(()=>{const j=H.current;j&&(j.dispatch({effects:[be.current.reconfigure(jr(d)),Ke.current.reconfigure(d.vimMode?_r():[])]}),tt(j,d.vimMode))},[d]),re.useEffect(()=>{H.current?.dispatch({effects:hn.of(S)})},[S]),re.useEffect(()=>{const j=H.current;if(!j)return;const ee=j.state.doc.toString(),M=B.filter(ne=>ne.from>=0&&ne.to<=ee.length&&ne.to>ne.from);j.dispatch({effects:[dn.of(M),Vt.of(null)]})},[B]),re.useEffect(()=>{const j=H.current;A||!j||j.state.doc.toString()===s||j.dispatch({changes:{from:0,to:j.state.doc.length,insert:s},annotations:Kr.of(!0)})},[s,A]),re.useEffect(()=>{H.current?.dispatch({effects:Ht.of(Ur(l))})},[l]),re.useEffect(()=>{const j=H.current;if(!j||!f||f.orphaned)return;const ee=Math.min(f.startOffset,j.state.doc.length),M=Math.min(Math.max(ee,f.endOffset),j.state.doc.length);j.dispatch({selection:{anchor:ee,head:M},effects:se.scrollIntoView(ee,{y:"center"})}),j.focus()},[f]),re.useEffect(()=>{const j=H.current;if(!j||!w)return;const ee=Math.max(1,Math.min(j.state.doc.lines,w.line)),M=j.state.doc.line(ee),ne=Math.min(M.to,M.from+Math.max(0,w.column-1));j.dispatch({selection:{anchor:M.from,head:M.to},effects:se.scrollIntoView(ne,{y:"center",yMargin:60})}),j.focus()},[w?.nonce]),re.useEffect(()=>{const j=H.current;if(!j||!R)return;const ee=Math.max(0,Math.min(R.from,j.state.doc.length)),M=Math.max(ee,Math.min(R.to,j.state.doc.length));j.dispatch({selection:{anchor:ee},effects:[Vt.of({from:ee,to:M}),se.scrollIntoView(ee,{y:"center",yMargin:60})]}),j.focus()},[R?.nonce]),re.useEffect(()=>{const j=H.current;!j||x===0||x===_e.current||(_e.current=x,Ji(j))},[x]),vt.jsxs("div",{className:"editor-shell",style:{fontFamily:ro(d.font),fontSize:`${d.fontSize}px`,lineHeight:d.lineHeight},children:[vt.jsx("div",{className:"editor-host",ref:D}),d.vimMode&&vt.jsx("div",{className:"vim-editor-status",role:"status","aria-live":"polite",children:vt.jsxs("span",{children:["--",pe||"NORMAL","--"]})})]})}function va(s){return{Find:s("editor.search.find"),Replace:s("editor.search.replace"),next:s("editor.search.next"),previous:s("editor.search.previous"),all:s("editor.search.all"),"match case":s("editor.search.matchCase"),regexp:s("editor.search.regexp"),"by word":s("editor.search.wholeWord"),replace:s("editor.search.replaceNext"),"replace all":s("editor.search.replaceAll"),close:s("common.close"),"current match":s("editor.search.currentMatch"),"on line":s("editor.search.onLine"),"replaced match on line $":s("editor.search.replacedMatchOnLine"),"replaced $ matches":s("editor.search.replacedMatches"),"Go to line":s("editor.search.goToLine"),go:s("editor.search.go")}}function ga(s){return lt.fromClass(class{constructor(i){this.view=i,this.document=i.state.doc,this.schedule()}view;frame=null;document;signature="";count=0;update(){this.schedule()}destroy(){this.frame!==null&&cancelAnimationFrame(this.frame)}schedule(){this.frame!==null&&cancelAnimationFrame(this.frame),this.frame=requestAnimationFrame(()=>{this.frame=null,this.render()})}render(){if(!qi(this.view.state))return;const i=this.view.dom.querySelector(".cm-panel.cm-search");if(!i)return;let l=i.querySelector(".cm-search-count");if(!l){l=document.createElement("span"),l.className="cm-search-count",l.setAttribute("role","status"),l.setAttribute("aria-live","polite");const g=i.querySelector("[name=close]");i.insertBefore(l,g)}const f=Gi(this.view.state),d=zo(f);(this.document!==this.view.state.doc||this.signature!==d)&&(this.document=this.view.state.doc,this.signature=d,this.count=Uo(this.view.state,f)),l.textContent=f.search?f.valid?this.count===0?s("editor.search.noMatches"):s("editor.search.matchCount",{count:this.count}):s("editor.search.invalidQuery"):""}})}function jr(s){return[se.contentAttributes.of({spellcheck:"false",autocorrect:"off",autocapitalize:"off",autocomplete:"off",lang:"en-US"}),se.theme({"&":{fontSize:`${s.fontSize}px`},".cm-scroller":{fontFamily:"inherit",lineHeight:"inherit"},".cm-content":{fontFamily:"inherit",fontSize:"inherit"},".cm-gutters":{fontFamily:"inherit",fontSize:"inherit"}}),s.lineWrapping?se.lineWrapping:[]]}function Ve(s,i,l,f){if(s[i]!==l)return null;let d=0;for(let g=i;g<s.length;g+=1){const w=s[g-1]==="\\"&&s[g-2]!=="\\";if(!w&&s[g]===l&&(d+=1),!w&&s[g]===f&&(d-=1,d===0))return{from:i,to:g+1,end:g+1}}return null}function Wr(s,i){const l=[],f=(L,O)=>{O>L&&l.push({from:L,to:O})},d=L=>{for(const O of s.matchAll(L))O.index!==void 0&&f(O.index,O.index+O[0].length)},g=new Set(["tabular","tabularx","tabulary","longtable","array","matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix"]),w=new Set(["documentclass","usepackage","RequirePackage","includegraphics","tikzset","pgfplotsset","hypersetup","lstset","definecolor","colorlet","setlength","setcounter","draw","path","fill","filldraw","shade","node","addplot","color","textcolor","colorbox","pagecolor"]),x=new Set(["label","hypertarget","ref","pageref","autoref","nameref","hyperref","index","gls","Gls","glspl","Glspl","cite","citep","citet","citeauthor","citeyear","citenum","parencite","textcite","autocite","footcite"]),S=L=>/[=,!/]/.test(L)||/\b(?:colorbar|legend|width|height|draw|fill|style|domain|samples|anchor|at|axis)\b/.test(L),B=L=>x.has(L)||/^cite[A-Za-z]*/.test(L),R=L=>{let O=L;for(;O<s.length&&/[ \t\r\n]/.test(s[O]);)O+=1;return O},A=L=>{if(s[L]!=="%")return!1;let O=0;for(let P=L-1;P>=0&&s[P]==="\\";P-=1)O+=1;return O%2===0};for(let L=0;L<s.length;L+=1){if(A(L)){const D=s.indexOf(`
60
60
  `,L);f(L,D<0?s.length:D),L=D<0?s.length:D;continue}if(s[L]!=="\\")continue;const O=L;let P=L+1;if(/[A-Za-z@]/.test(s[P]??""))for(;P<s.length&&/[A-Za-z@0-9:_]/.test(s[P]);)P+=1;else P<s.length&&(P+=1);const $=s.slice(L+1,P);f(O,P);let K=R(P);if($==="begin"||$==="end"){const D=Ve(s,K,"{","}");if(D){f(D.from,D.to);const H=s.slice(D.from+1,D.to-1).trim();if(K=R(D.end),$==="begin"){const J=Ve(s,K,"[","]");if(J&&(f(J.from,J.to),K=R(J.end)),g.has(H)){const Z=Ve(s,K,"{","}");Z&&f(Z.from,Z.to)}}}L=P-1;continue}if(B($))for(s[K]==="*"&&(K=R(K+1));;){const D=Ve(s,K,"[","]")??Ve(s,K,"{","}");if(!D)break;f(D.from,D.to),K=R(D.end)}else{const D=Ve(s,K,"[","]");if(D&&(w.has($)||S(s.slice(D.from+1,D.to-1)))&&(f(D.from,D.to),K=R(D.end)),w.has($)){const H=$==="definecolor"||$==="colorlet"?3:1;for(let J=0;J<H;J+=1){const Z=Ve(s,K,"{","}");if(!Z)break;f(Z.from,Z.to),K=R(Z.end)}}}L=P-1}for(let L=s.indexOf("=");L>=0;L=s.indexOf("=",L+1)){const P=Math.max(...[`
61
- `,"[","{","]","}",",",";"].map(J=>s.lastIndexOf(J,L-1)+1)),K=s.slice(P,L).match(/([A-Za-z][A-Za-z0-9_.:/-]*(?:\s+[A-Za-z][A-Za-z0-9_.:/-]*){0,7})\s*$/);K?.index!==void 0&&f(P+K.index,L);let D=L+1;for(;D<s.length&&/\s/.test(s[D]);)D+=1;let H=D;if(s[D]==="{")H=Ve(s,D,"{","}")?.end??D;else for(;H<s.length&&!/[,\]\}\n]/.test(s[H]);)H+=1;f(D,H)}d(/(?:https?|ftp):\/\/[^\s]+/gi),d(/\b[A-Z][A-Za-z0-9']*\b/g);for(const L of i){if(!L)continue;const O=L.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),P=new RegExp(`(^|[^A-Za-z0-9_])(${O})(?=$|[^A-Za-z0-9_])`,"gi");for(const $ of s.matchAll(P)){if($.index===void 0)continue;const K=$.index+($[1]?.length??0);l.push({from:K,to:K+($[2]?.length??0)})}}l.sort((L,O)=>L.from-O.from||L.to-O.to);const _=[];for(const L of l){const O=_.at(-1);O&&L.from<=O.to?O.to=Math.max(O.to,L.to):_.push({...L})}return G.set(_.map(L=>G.mark({attributes:{spellcheck:"false"}}).range(L.from,L.to)),!0)}function ma(s,i){const l=s.map(f=>({from:Math.max(0,Math.min(i,f.from)),to:Math.max(0,Math.min(i,f.to)),word:f.word})).filter(f=>f.to>f.from).sort((f,d)=>f.from-d.from||f.to-d.to);return G.set(l.map(f=>G.mark({class:"cm-spell-error",attributes:{title:f.word}}).range(f.from,f.to)),!0)}function Ur(s){return s.map(i=>({id:i.id,from:i.startOffset,to:i.endOffset,resolved:i.resolved,orphaned:i.orphaned}))}function ya(s,i){const l=s.filter(f=>!f.orphaned).map(f=>{const d=Math.max(0,Math.min(i,f.from)),g=Math.max(d,Math.min(i,f.to)),w=`cm-source-comment${f.resolved?" cm-source-comment-resolved":""}`;return d===g?G.widget({widget:new Ca(f.id,w),side:1}).range(d):G.mark({class:w,attributes:{"data-comment-id":f.id}}).range(d,g)});return G.set(l,!0)}class Ca extends qr{constructor(i,l){super(),this.id=i,this.className=l}id;className;toDOM(){const i=document.createElement("span");return i.className=`${this.className} cm-comment-pin`,i.dataset.commentId=this.id,i.textContent="●",i}}export{Sa as LatexEditor};
61
+ `,"[","{","]","}",",",";"].map(J=>s.lastIndexOf(J,L-1)+1)),K=s.slice(P,L).match(/([A-Za-z][A-Za-z0-9_.:/-]*(?:\s+[A-Za-z][A-Za-z0-9_.:/-]*){0,7})\s*$/);K?.index!==void 0&&f(P+K.index,L);let D=L+1;for(;D<s.length&&/\s/.test(s[D]);)D+=1;let H=D;if(s[D]==="{")H=Ve(s,D,"{","}")?.end??D;else for(;H<s.length&&!/[,\]\}\n]/.test(s[H]);)H+=1;f(D,H)}d(/(?:https?|ftp):\/\/[^\s]+/gi);for(const L of i){if(!L)continue;const O=L.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),P=new RegExp(`(^|[^A-Za-z0-9_])(${O})(?=$|[^A-Za-z0-9_])`,"gi");for(const $ of s.matchAll(P)){if($.index===void 0)continue;const K=$.index+($[1]?.length??0);l.push({from:K,to:K+($[2]?.length??0)})}}l.sort((L,O)=>L.from-O.from||L.to-O.to);const _=[];for(const L of l){const O=_.at(-1);O&&L.from<=O.to?O.to=Math.max(O.to,L.to):_.push({...L})}return G.set(_.map(L=>G.mark({attributes:{spellcheck:"false"}}).range(L.from,L.to)),!0)}function ma(s,i){const l=s.map(f=>({from:Math.max(0,Math.min(i,f.from)),to:Math.max(0,Math.min(i,f.to)),word:f.word})).filter(f=>f.to>f.from).sort((f,d)=>f.from-d.from||f.to-d.to);return G.set(l.map(f=>G.mark({class:"cm-spell-error",attributes:{title:f.word}}).range(f.from,f.to)),!0)}function Ur(s){return s.map(i=>({id:i.id,from:i.startOffset,to:i.endOffset,resolved:i.resolved,orphaned:i.orphaned}))}function ya(s,i){const l=s.filter(f=>!f.orphaned).map(f=>{const d=Math.max(0,Math.min(i,f.from)),g=Math.max(d,Math.min(i,f.to)),w=`cm-source-comment${f.resolved?" cm-source-comment-resolved":""}`;return d===g?G.widget({widget:new Ca(f.id,w),side:1}).range(d):G.mark({class:w,attributes:{"data-comment-id":f.id}}).range(d,g)});return G.set(l,!0)}class Ca extends qr{constructor(i,l){super(),this.id=i,this.className=l}id;className;toDOM(){const i=document.createElement("span");return i.className=`${this.className} cm-comment-pin`,i.dataset.commentId=this.id,i.textContent="●",i}}export{Sa as LatexEditor};
@@ -1 +1 @@
1
- import{u as I,r as s,j as r}from"./react-CsO_xvbl.js";import{g as L,P as O,w as V,G as $}from"./pdf-DPnwNQHb.js";import{M as D,P as F,a as A}from"./plus-4Hi_FYu_.js";import{L as H}from"./index-DtGvC-Uo.js";$.workerSrc=V;const T=new O;function U({url:j,target:l,compiling:M=!1,onViewportLocation:S}){const{t:n}=I(),c=s.useRef(null),[h,d]=s.useState(null),[u,w]=s.useState(0),[a,p]=s.useState(100),[N,m]=s.useState(""),x=()=>{const e=c.current;if(!e)return;const t=e.getBoundingClientRect(),o=t.left+t.width/2,i=t.top+t.height/2,g=[...e.querySelectorAll(".pdf-page")],v=g.find(P=>{const b=P.getBoundingClientRect();return i>=b.top&&i<=b.bottom})??g.reduce((P,b)=>{if(!P)return b;const Z=Math.abs(b.getBoundingClientRect().top-i),B=Math.abs(P.getBoundingClientRect().top-i);return Z<B?b:P},null);if(!v)return;const f=v.getBoundingClientRect(),y=Number(v.dataset.scale)||1,E=Number(v.dataset.page),k=Math.max(0,Math.min(f.width,o-f.left))/y,W=Math.max(0,Math.min(f.height,i-f.top))/y;E&&S(E,k,W)};s.useEffect(()=>{const e=c.current;if(!e)return;const t=()=>w(e.clientWidth);t();const o=new ResizeObserver(t);return o.observe(e),()=>o.disconnect()},[]),s.useEffect(()=>{let e=!1;d(null),m("");const t=L({url:j,worker:T});return t.promise.then(o=>{e||d(o)}).catch(()=>{e||m(n("editor.pdfLoadFailed"))}),()=>{e=!0,t.destroy()}},[j]),s.useEffect(()=>{a>100||!c.current||(c.current.scrollLeft=0)},[a,u,h]);const z=e=>p(t=>Math.min(200,Math.max(50,t+e))),C=()=>{c.current&&(c.current.scrollLeft=0),p(100)},R=e=>{!e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY)||(e.preventDefault(),e.currentTarget.scrollLeft+=e.deltaY,x())};return r.jsxs("div",{className:"pdf-viewer",children:[r.jsxs("div",{className:"pdf-toolbar",role:"toolbar","aria-label":n("editor.pdfZoomControls"),children:[r.jsx("button",{disabled:a<=50,title:n("editor.pdfZoomOut"),"aria-label":n("editor.pdfZoomOut"),onClick:()=>z(-10),children:r.jsx(D,{size:14})}),r.jsxs("span",{className:"pdf-zoom-value","aria-live":"polite",children:[a,"%"]}),r.jsx("button",{disabled:a>=200,title:n("editor.pdfZoomIn"),"aria-label":n("editor.pdfZoomIn"),onClick:()=>z(10),children:r.jsx(F,{size:14})}),r.jsxs("button",{className:"pdf-fit-width",title:n("editor.pdfFitWidth"),onClick:C,children:[r.jsx(A,{size:13}),n("editor.pdfFitWidth")]})]}),M&&r.jsxs("div",{className:"pdf-compiling-overlay",role:"status","aria-live":"polite",children:[r.jsx(H,{className:"spin",size:20}),r.jsx("span",{children:n("editor.compiling")})]}),r.jsx("div",{className:"pdf-document",ref:c,onScroll:x,onWheel:R,children:r.jsxs("div",{className:"pdf-pages",style:{width:`${Math.max(1,u-28)*Math.max(1,a/100)}px`},children:[N&&r.jsx("div",{className:"preview-empty",children:r.jsx("strong",{children:N})}),h&&u>0&&Array.from({length:h.numPages},(e,t)=>r.jsx(Y,{document:h,pageNumber:t+1,availableWidth:u-28,zoom:a/100,target:l?.page===t+1?l:null,onReady:x},t+1))]})})]})}function Y({document:j,pageNumber:l,availableWidth:M,zoom:S,target:n,onReady:c}){const h=s.useRef(null),d=s.useRef(null),u=s.useRef(null),[w,a]=s.useState(1),[p,N]=s.useState({width:0,height:0}),[m,x]=s.useState(l===1),[z,C]=s.useState(!1);s.useEffect(()=>{const t=h.current;if(!t||m)return;if(!("IntersectionObserver"in window)){x(!0);return}const o=new IntersectionObserver(i=>{i.some(g=>g.isIntersecting)&&(x(!0),o.disconnect())},{rootMargin:"900px 0px"});return o.observe(t),()=>o.disconnect()},[m]),s.useEffect(()=>{n&&x(!0)},[n?.nonce]),s.useEffect(()=>{if(!m)return;let t=!1,o=null;return C(!1),j.getPage(l).then(i=>{if(t)return;const g=i.getViewport({scale:1}),v=M/g.width,f=Math.min(3.3,Math.max(.175,v*S)),y=i.getViewport({scale:f});if(a(f),N({width:y.width,height:y.height}),!d.current)return;const E=Math.max(1,window.devicePixelRatio||1),k=i.getViewport({scale:f*E});return d.current.width=Math.floor(k.width),d.current.height=Math.floor(k.height),o=i.render({canvas:d.current,viewport:k}),o.promise.then(()=>{t||(C(!0),window.requestAnimationFrame(c))})}).catch(()=>{}),()=>{t=!0,o?.cancel()}},[j,l,M,S,m]),s.useEffect(()=>{!n||!u.current||u.current.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})},[n?.nonce,w]);const R=Math.max(1,M*S),e=R*(792/612);return r.jsxs("figure",{ref:h,className:`pdf-page${z?" rendered":" loading"}`,"data-page":l,"data-scale":w,style:{width:`${p.width||R}px`,minHeight:`${p.height||e}px`},children:[r.jsx("canvas",{ref:d,style:{width:`${p.width||R}px`,height:`${p.height||e}px`}}),n&&r.jsx("span",{ref:u,className:"pdf-sync-marker",style:{left:n.x*w,top:n.y*w}}),r.jsx("figcaption",{children:l})]})}export{U as PdfPreview};
1
+ import{u as I,r as s,j as r}from"./react-CsO_xvbl.js";import{g as L,P as O,w as V,G as $}from"./pdf-DPnwNQHb.js";import{M as D,P as F,a as A}from"./plus-CvyFTTaw.js";import{L as H}from"./index-BI4dns2b.js";$.workerSrc=V;const T=new O;function U({url:j,target:l,compiling:M=!1,onViewportLocation:S}){const{t:n}=I(),c=s.useRef(null),[h,d]=s.useState(null),[u,w]=s.useState(0),[a,p]=s.useState(100),[N,m]=s.useState(""),x=()=>{const e=c.current;if(!e)return;const t=e.getBoundingClientRect(),o=t.left+t.width/2,i=t.top+t.height/2,g=[...e.querySelectorAll(".pdf-page")],v=g.find(P=>{const b=P.getBoundingClientRect();return i>=b.top&&i<=b.bottom})??g.reduce((P,b)=>{if(!P)return b;const Z=Math.abs(b.getBoundingClientRect().top-i),B=Math.abs(P.getBoundingClientRect().top-i);return Z<B?b:P},null);if(!v)return;const f=v.getBoundingClientRect(),y=Number(v.dataset.scale)||1,E=Number(v.dataset.page),k=Math.max(0,Math.min(f.width,o-f.left))/y,W=Math.max(0,Math.min(f.height,i-f.top))/y;E&&S(E,k,W)};s.useEffect(()=>{const e=c.current;if(!e)return;const t=()=>w(e.clientWidth);t();const o=new ResizeObserver(t);return o.observe(e),()=>o.disconnect()},[]),s.useEffect(()=>{let e=!1;d(null),m("");const t=L({url:j,worker:T});return t.promise.then(o=>{e||d(o)}).catch(()=>{e||m(n("editor.pdfLoadFailed"))}),()=>{e=!0,t.destroy()}},[j]),s.useEffect(()=>{a>100||!c.current||(c.current.scrollLeft=0)},[a,u,h]);const z=e=>p(t=>Math.min(200,Math.max(50,t+e))),C=()=>{c.current&&(c.current.scrollLeft=0),p(100)},R=e=>{!e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY)||(e.preventDefault(),e.currentTarget.scrollLeft+=e.deltaY,x())};return r.jsxs("div",{className:"pdf-viewer",children:[r.jsxs("div",{className:"pdf-toolbar",role:"toolbar","aria-label":n("editor.pdfZoomControls"),children:[r.jsx("button",{disabled:a<=50,title:n("editor.pdfZoomOut"),"aria-label":n("editor.pdfZoomOut"),onClick:()=>z(-10),children:r.jsx(D,{size:14})}),r.jsxs("span",{className:"pdf-zoom-value","aria-live":"polite",children:[a,"%"]}),r.jsx("button",{disabled:a>=200,title:n("editor.pdfZoomIn"),"aria-label":n("editor.pdfZoomIn"),onClick:()=>z(10),children:r.jsx(F,{size:14})}),r.jsxs("button",{className:"pdf-fit-width",title:n("editor.pdfFitWidth"),onClick:C,children:[r.jsx(A,{size:13}),n("editor.pdfFitWidth")]})]}),M&&r.jsxs("div",{className:"pdf-compiling-overlay",role:"status","aria-live":"polite",children:[r.jsx(H,{className:"spin",size:20}),r.jsx("span",{children:n("editor.compiling")})]}),r.jsx("div",{className:"pdf-document",ref:c,onScroll:x,onWheel:R,children:r.jsxs("div",{className:"pdf-pages",style:{width:`${Math.max(1,u-28)*Math.max(1,a/100)}px`},children:[N&&r.jsx("div",{className:"preview-empty",children:r.jsx("strong",{children:N})}),h&&u>0&&Array.from({length:h.numPages},(e,t)=>r.jsx(Y,{document:h,pageNumber:t+1,availableWidth:u-28,zoom:a/100,target:l?.page===t+1?l:null,onReady:x},t+1))]})})]})}function Y({document:j,pageNumber:l,availableWidth:M,zoom:S,target:n,onReady:c}){const h=s.useRef(null),d=s.useRef(null),u=s.useRef(null),[w,a]=s.useState(1),[p,N]=s.useState({width:0,height:0}),[m,x]=s.useState(l===1),[z,C]=s.useState(!1);s.useEffect(()=>{const t=h.current;if(!t||m)return;if(!("IntersectionObserver"in window)){x(!0);return}const o=new IntersectionObserver(i=>{i.some(g=>g.isIntersecting)&&(x(!0),o.disconnect())},{rootMargin:"900px 0px"});return o.observe(t),()=>o.disconnect()},[m]),s.useEffect(()=>{n&&x(!0)},[n?.nonce]),s.useEffect(()=>{if(!m)return;let t=!1,o=null;return C(!1),j.getPage(l).then(i=>{if(t)return;const g=i.getViewport({scale:1}),v=M/g.width,f=Math.min(3.3,Math.max(.175,v*S)),y=i.getViewport({scale:f});if(a(f),N({width:y.width,height:y.height}),!d.current)return;const E=Math.max(1,window.devicePixelRatio||1),k=i.getViewport({scale:f*E});return d.current.width=Math.floor(k.width),d.current.height=Math.floor(k.height),o=i.render({canvas:d.current,viewport:k}),o.promise.then(()=>{t||(C(!0),window.requestAnimationFrame(c))})}).catch(()=>{}),()=>{t=!0,o?.cancel()}},[j,l,M,S,m]),s.useEffect(()=>{!n||!u.current||u.current.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})},[n?.nonce,w]);const R=Math.max(1,M*S),e=R*(792/612);return r.jsxs("figure",{ref:h,className:`pdf-page${z?" rendered":" loading"}`,"data-page":l,"data-scale":w,style:{width:`${p.width||R}px`,minHeight:`${p.height||e}px`},children:[r.jsx("canvas",{ref:d,style:{width:`${p.width||R}px`,height:`${p.height||e}px`}}),n&&r.jsx("span",{ref:u,className:"pdf-sync-marker",style:{left:n.x*w,top:n.y*w}}),r.jsx("figcaption",{children:l})]})}export{U as PdfPreview};
@@ -1 +1 @@
1
- import{u as A,r,j as e}from"./react-CsO_xvbl.js";import{i as B,k as R,M as F,n as $,L as I,o as J,l as K,F as V,p as G}from"./index-DtGvC-Uo.js";const L=B("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 Z({open:i,files:u,onOpenChange:l,onOpenFile:p}){const{t:a}=A(),[n,m]=r.useState(""),[d,o]=r.useState(0),f=r.useRef(null),h=r.useMemo(()=>u.filter(t=>t.type==="file").map(t=>({entry:t,score:H(t.path,n)})).filter(t=>t.score>=0).sort((t,c)=>c.score-t.score||t.entry.path.localeCompare(c.entry.path)).slice(0,100),[u,n]);r.useEffect(()=>{i&&(m(""),o(0),window.setTimeout(()=>f.current?.focus(),0))},[i]),r.useEffect(()=>o(t=>Math.min(t,Math.max(0,h.length-1))),[h.length]);const x=t=>{p(t),l(!1)};return e.jsx(F,{open:i,wide:!0,title:a("navigation.quickOpen"),description:a("navigation.quickOpenDescription"),onOpenChange:l,children:e.jsxs("div",{className:"quick-open-dialog",children:[e.jsxs("label",{children:[e.jsx($,{size:16}),e.jsx("input",{ref:f,value:n,placeholder:a("navigation.filePlaceholder"),onChange:t=>{m(t.target.value),o(0)},onKeyDown:t=>{t.key==="ArrowDown"&&(t.preventDefault(),o(c=>Math.min(h.length-1,c+1))),t.key==="ArrowUp"&&(t.preventDefault(),o(c=>Math.max(0,c-1))),t.key==="Enter"&&h[d]&&(t.preventDefault(),x(h[d].entry.path))}})]}),e.jsxs("div",{className:"quick-open-results",children:[h.map(({entry:t},c)=>e.jsxs("button",{className:c===d?"active":"",onMouseEnter:()=>o(c),onClick:()=>x(t.path),children:[e.jsx(V,{size:14}),e.jsx("span",{children:t.path}),c===d&&e.jsx(G,{size:13})]},t.path)),h.length===0&&e.jsx("p",{className:"muted padded",children:a("navigation.noFiles")})]})]})})}function _({open:i,project:u,onOpenChange:l,onJump:p}){const{t:a}=A(),[n,m]=r.useState(""),[d,o]=r.useState(""),[f,h]=r.useState(!1),[x,t]=r.useState(!1),[c,w]=r.useState([]),[v,C]=r.useState(0),[P,D]=r.useState(!1),[b,S]=r.useState(!1),[W,N]=r.useState(!1),[z,M]=r.useState(""),[q,k]=r.useState(""),[O,Q]=r.useState(0),y=r.useRef(null);r.useEffect(()=>{if(!i){y.current?.abort();return}if(M(""),k(""),!n.trim()){w([]),C(0),D(!1);return}const s=window.setTimeout(()=>{y.current?.abort();const j=new AbortController;y.current=j,S(!0);const E=new URLSearchParams({q:n});f&&E.set("caseSensitive","1"),x&&E.set("wholeWord","1"),R(`/api/projects/${u.id}/search?${E}`,{signal:j.signal}).then(g=>{w(g.matches),C(g.total),D(g.truncated)}).catch(g=>{g instanceof DOMException&&g.name==="AbortError"||k(T(g))}).finally(()=>{y.current===j&&(y.current=null,S(!1))})},250);return()=>window.clearTimeout(s)},[i,u.id,n,f,x,O]);const U=async()=>{N(!1),S(!0),k(""),M("");try{const s=await R(`/api/projects/${u.id}/search/replace`,{method:"POST",body:JSON.stringify({query:n,replacement:d,caseSensitive:f,wholeWord:x})});M(a("navigation.replaced",{count:s.replacements,files:s.files.length})),w([]),C(0),Q(j=>j+1)}catch(s){k(T(s))}finally{S(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(F,{open:i,extraWide:!0,title:a("navigation.projectSearch"),description:a("navigation.projectSearchDescription"),onOpenChange:l,footer:e.jsx("button",{onClick:()=>l(!1),children:a("common.close")}),children:e.jsxs("div",{className:"project-search-dialog",children:[q&&e.jsx("p",{className:"error",children:q}),z&&e.jsx("p",{className:"success",children:z}),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:s=>m(s.target.value)})]}),u.permission!=="read"&&e.jsxs("label",{className:"project-search-query",children:[e.jsx(L,{size:16}),e.jsx("input",{value:d,placeholder:a("navigation.replacePlaceholder"),onChange:s=>o(s.target.value)})]}),e.jsxs("div",{className:"project-search-options",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:f,onChange:s=>h(s.target.checked)}),a("editor.search.matchCase")]}),e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:x,onChange:s=>t(s.target.checked)}),a("editor.search.wholeWord")]}),u.permission!=="read"&&e.jsxs("button",{className:"danger-text",disabled:!n.trim()||v===0||b,onClick:()=>N(!0),children:[e.jsx(L,{size:13}),a("navigation.replaceAll",{count:v})]})]})]}),e.jsxs("div",{className:"project-search-summary",children:[e.jsx("span",{children:b?e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"spin",size:13}),a("common.loading")]}):a("navigation.matchSummary",{count:v})}),P&&e.jsx("small",{children:a("navigation.truncated",{count:c.length})})]}),e.jsxs("div",{className:"project-search-results",children:[c.map((s,j)=>e.jsxs("button",{onClick:()=>{p(s.path,s.line,s.column),l(!1)},children:[e.jsx(J,{size:14}),e.jsxs("span",{children:[e.jsxs("strong",{children:[s.path,e.jsxs("small",{children:[":",s.line,":",s.column]})]}),e.jsxs("code",{children:[s.preview.slice(0,s.matchStart),e.jsx("mark",{children:s.preview.slice(s.matchStart,s.matchEnd)}),s.preview.slice(s.matchEnd)]})]})]},`${s.path}-${s.line}-${s.column}-${j}`)),!b&&n.trim()&&c.length===0&&e.jsx("p",{className:"muted padded",children:a("editor.search.noMatches")})]})]})}),e.jsx(K,{open:W,title:a("navigation.replaceConfirmTitle"),description:a("navigation.replaceConfirmDescription",{count:v}),confirmLabel:a("navigation.replaceAll",{count:v}),danger:!0,onCancel:()=>N(!1),onConfirm:()=>{U()}})]})}function H(i,u){const l=i.toLocaleLowerCase(),p=u.trim().toLocaleLowerCase();if(!p)return 1;const a=l.indexOf(p);if(a>=0)return 1e4-a-l.length;let n=0,m=0;for(const d of p){const o=l.indexOf(d,n);if(o<0)return-1;m+=o===n?5:1,n=o+1}return m-l.length/100}function T(i){return i instanceof Error?i.message:String(i)}export{_ as ProjectSearchDialog,Z as QuickOpenDialog};
1
+ import{u as A,r,j as e}from"./react-CsO_xvbl.js";import{i as B,k as R,M as F,n as $,L as I,o as J,l as K,F as V,p as G}from"./index-BI4dns2b.js";const L=B("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 Z({open:i,files:u,onOpenChange:l,onOpenFile:p}){const{t:a}=A(),[n,m]=r.useState(""),[d,o]=r.useState(0),f=r.useRef(null),h=r.useMemo(()=>u.filter(t=>t.type==="file").map(t=>({entry:t,score:H(t.path,n)})).filter(t=>t.score>=0).sort((t,c)=>c.score-t.score||t.entry.path.localeCompare(c.entry.path)).slice(0,100),[u,n]);r.useEffect(()=>{i&&(m(""),o(0),window.setTimeout(()=>f.current?.focus(),0))},[i]),r.useEffect(()=>o(t=>Math.min(t,Math.max(0,h.length-1))),[h.length]);const x=t=>{p(t),l(!1)};return e.jsx(F,{open:i,wide:!0,title:a("navigation.quickOpen"),description:a("navigation.quickOpenDescription"),onOpenChange:l,children:e.jsxs("div",{className:"quick-open-dialog",children:[e.jsxs("label",{children:[e.jsx($,{size:16}),e.jsx("input",{ref:f,value:n,placeholder:a("navigation.filePlaceholder"),onChange:t=>{m(t.target.value),o(0)},onKeyDown:t=>{t.key==="ArrowDown"&&(t.preventDefault(),o(c=>Math.min(h.length-1,c+1))),t.key==="ArrowUp"&&(t.preventDefault(),o(c=>Math.max(0,c-1))),t.key==="Enter"&&h[d]&&(t.preventDefault(),x(h[d].entry.path))}})]}),e.jsxs("div",{className:"quick-open-results",children:[h.map(({entry:t},c)=>e.jsxs("button",{className:c===d?"active":"",onMouseEnter:()=>o(c),onClick:()=>x(t.path),children:[e.jsx(V,{size:14}),e.jsx("span",{children:t.path}),c===d&&e.jsx(G,{size:13})]},t.path)),h.length===0&&e.jsx("p",{className:"muted padded",children:a("navigation.noFiles")})]})]})})}function _({open:i,project:u,onOpenChange:l,onJump:p}){const{t:a}=A(),[n,m]=r.useState(""),[d,o]=r.useState(""),[f,h]=r.useState(!1),[x,t]=r.useState(!1),[c,w]=r.useState([]),[v,C]=r.useState(0),[P,D]=r.useState(!1),[b,S]=r.useState(!1),[W,N]=r.useState(!1),[z,M]=r.useState(""),[q,k]=r.useState(""),[O,Q]=r.useState(0),y=r.useRef(null);r.useEffect(()=>{if(!i){y.current?.abort();return}if(M(""),k(""),!n.trim()){w([]),C(0),D(!1);return}const s=window.setTimeout(()=>{y.current?.abort();const j=new AbortController;y.current=j,S(!0);const E=new URLSearchParams({q:n});f&&E.set("caseSensitive","1"),x&&E.set("wholeWord","1"),R(`/api/projects/${u.id}/search?${E}`,{signal:j.signal}).then(g=>{w(g.matches),C(g.total),D(g.truncated)}).catch(g=>{g instanceof DOMException&&g.name==="AbortError"||k(T(g))}).finally(()=>{y.current===j&&(y.current=null,S(!1))})},250);return()=>window.clearTimeout(s)},[i,u.id,n,f,x,O]);const U=async()=>{N(!1),S(!0),k(""),M("");try{const s=await R(`/api/projects/${u.id}/search/replace`,{method:"POST",body:JSON.stringify({query:n,replacement:d,caseSensitive:f,wholeWord:x})});M(a("navigation.replaced",{count:s.replacements,files:s.files.length})),w([]),C(0),Q(j=>j+1)}catch(s){k(T(s))}finally{S(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(F,{open:i,extraWide:!0,title:a("navigation.projectSearch"),description:a("navigation.projectSearchDescription"),onOpenChange:l,footer:e.jsx("button",{onClick:()=>l(!1),children:a("common.close")}),children:e.jsxs("div",{className:"project-search-dialog",children:[q&&e.jsx("p",{className:"error",children:q}),z&&e.jsx("p",{className:"success",children:z}),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:s=>m(s.target.value)})]}),u.permission!=="read"&&e.jsxs("label",{className:"project-search-query",children:[e.jsx(L,{size:16}),e.jsx("input",{value:d,placeholder:a("navigation.replacePlaceholder"),onChange:s=>o(s.target.value)})]}),e.jsxs("div",{className:"project-search-options",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:f,onChange:s=>h(s.target.checked)}),a("editor.search.matchCase")]}),e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:x,onChange:s=>t(s.target.checked)}),a("editor.search.wholeWord")]}),u.permission!=="read"&&e.jsxs("button",{className:"danger-text",disabled:!n.trim()||v===0||b,onClick:()=>N(!0),children:[e.jsx(L,{size:13}),a("navigation.replaceAll",{count:v})]})]})]}),e.jsxs("div",{className:"project-search-summary",children:[e.jsx("span",{children:b?e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"spin",size:13}),a("common.loading")]}):a("navigation.matchSummary",{count:v})}),P&&e.jsx("small",{children:a("navigation.truncated",{count:c.length})})]}),e.jsxs("div",{className:"project-search-results",children:[c.map((s,j)=>e.jsxs("button",{onClick:()=>{p(s.path,s.line,s.column),l(!1)},children:[e.jsx(J,{size:14}),e.jsxs("span",{children:[e.jsxs("strong",{children:[s.path,e.jsxs("small",{children:[":",s.line,":",s.column]})]}),e.jsxs("code",{children:[s.preview.slice(0,s.matchStart),e.jsx("mark",{children:s.preview.slice(s.matchStart,s.matchEnd)}),s.preview.slice(s.matchEnd)]})]})]},`${s.path}-${s.line}-${s.column}-${j}`)),!b&&n.trim()&&c.length===0&&e.jsx("p",{className:"muted padded",children:a("editor.search.noMatches")})]})]})}),e.jsx(K,{open:W,title:a("navigation.replaceConfirmTitle"),description:a("navigation.replaceConfirmDescription",{count:v}),confirmLabel:a("navigation.replaceAll",{count:v}),danger:!0,onCancel:()=>N(!1),onConfirm:()=>{U()}})]})}function H(i,u){const l=i.toLocaleLowerCase(),p=u.trim().toLocaleLowerCase();if(!p)return 1;const a=l.indexOf(p);if(a>=0)return 1e4-a-l.length;let n=0,m=0;for(const d of p){const o=l.indexOf(d,n);if(o<0)return-1;m+=o===n?5:1,n=o+1}return m-l.length/100}function T(i){return i instanceof Error?i.message:String(i)}export{_ as ProjectSearchDialog,Z as QuickOpenDialog};
@@ -1 +1 @@
1
- import{u as f,r as n,j as e}from"./react-CsO_xvbl.js";import{i as y,k as M,M as b,A as v}from"./index-DtGvC-Uo.js";const $=y("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);function k({open:t,onOpenChange:c}){const{t:s}=f(),[r,p]=n.useState(null),[u,x]=n.useState(!1),[m,j]=n.useState(""),o=n.useCallback(async()=>{x(!0);try{p(await M("/api/health/metrics")),j("")}catch(i){j(i instanceof Error?i.message:s("errors.generic"))}finally{x(!1)}},[s]);return n.useEffect(()=>{if(!t)return;o();const i=window.setInterval(()=>{o()},5e3);return()=>window.clearInterval(i)},[t,o]),e.jsxs(b,{open:t,onOpenChange:c,wide:!0,title:s("metrics.title"),description:s("metrics.description"),footer:e.jsxs("button",{onClick:()=>{o()},disabled:u,children:[e.jsx($,{size:14,className:u?"spin":""}),s("metrics.refresh")]}),children:[m&&e.jsx("p",{className:"error",children:m}),!r&&!m&&e.jsx("p",{className:"muted",children:s("common.loading")}),r&&e.jsxs("div",{className:"system-metrics",children:[e.jsxs("div",{className:"metric-summary-grid",children:[e.jsx(l,{label:s("metrics.uptime"),value:g(r.uptimeSeconds)}),e.jsx(l,{label:s("metrics.memory"),value:`${h(r.memory.rssBytes)} RSS`,detail:`${h(r.memory.heapUsedBytes)} / ${h(r.memory.heapTotalBytes)} ${s("metrics.heap")}`}),e.jsx(l,{label:s("metrics.compileQueue"),value:`${r.compileQueue.running} / ${r.compileQueue.concurrency}`,detail:s("metrics.pending",{count:r.compileQueue.pending})}),e.jsx(l,{label:s("metrics.collaboration"),value:s("metrics.sessions",{count:r.collaboration.sessions}),detail:s("metrics.roomsAndDirty",{rooms:r.collaboration.rooms,dirty:r.collaboration.dirtyFiles})})]}),e.jsxs("section",{className:"metric-section",children:[e.jsxs("h3",{children:[e.jsx(v,{size:15}),s("metrics.eventLoop")]}),e.jsx("p",{children:s("metrics.latencySummary",r.eventLoopDelay)})]}),e.jsxs("section",{className:"metric-section",children:[e.jsx("h3",{children:s("metrics.operationDurations")}),Object.keys(r.durationsMs).length===0?e.jsx("p",{className:"muted",children:s("metrics.noSamples")}):e.jsx("div",{className:"metric-table-wrap",children:e.jsxs("table",{className:"metric-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:s("metrics.operation")}),e.jsx("th",{children:s("metrics.samples")}),e.jsx("th",{children:s("metrics.last")}),e.jsx("th",{children:"P50"}),e.jsx("th",{children:"P95"}),e.jsx("th",{children:s("metrics.max")})]})}),e.jsx("tbody",{children:Object.entries(r.durationsMs).sort(([i],[a])=>i.localeCompare(a)).map(([i,a])=>e.jsxs("tr",{children:[e.jsx("td",{children:N(i,s)}),e.jsx("td",{children:a.count}),e.jsx("td",{children:d(a.last)}),e.jsx("td",{children:d(a.p50)}),e.jsx("td",{children:d(a.p95)}),e.jsx("td",{children:d(a.max)})]},i))})]})})]})]})]})}function l({label:t,value:c,detail:s}){return e.jsxs("article",{className:"metric-card",children:[e.jsx("span",{children:t}),e.jsx("strong",{children:c}),s&&e.jsx("small",{children:s})]})}function h(t){return`${Math.round(t/1024/1024*10)/10} MB`}function g(t){const c=Math.floor(t/86400),s=Math.floor(t%86400/3600),r=Math.floor(t%3600/60);return c?`${c}d ${s}h`:s?`${s}h ${r}m`:`${r}m`}function d(t){return t>=1e3?`${Math.round(t/100)/10}s`:`${Math.round(t*10)/10}ms`}function N(t,c){return c(`metrics.operations.${t}`,{defaultValue:t})}export{k as SystemMetricsDialog};
1
+ import{u as f,r as n,j as e}from"./react-CsO_xvbl.js";import{i as y,k as M,M as b,A as v}from"./index-BI4dns2b.js";const $=y("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);function k({open:t,onOpenChange:c}){const{t:s}=f(),[r,p]=n.useState(null),[u,x]=n.useState(!1),[m,j]=n.useState(""),o=n.useCallback(async()=>{x(!0);try{p(await M("/api/health/metrics")),j("")}catch(i){j(i instanceof Error?i.message:s("errors.generic"))}finally{x(!1)}},[s]);return n.useEffect(()=>{if(!t)return;o();const i=window.setInterval(()=>{o()},5e3);return()=>window.clearInterval(i)},[t,o]),e.jsxs(b,{open:t,onOpenChange:c,wide:!0,title:s("metrics.title"),description:s("metrics.description"),footer:e.jsxs("button",{onClick:()=>{o()},disabled:u,children:[e.jsx($,{size:14,className:u?"spin":""}),s("metrics.refresh")]}),children:[m&&e.jsx("p",{className:"error",children:m}),!r&&!m&&e.jsx("p",{className:"muted",children:s("common.loading")}),r&&e.jsxs("div",{className:"system-metrics",children:[e.jsxs("div",{className:"metric-summary-grid",children:[e.jsx(l,{label:s("metrics.uptime"),value:g(r.uptimeSeconds)}),e.jsx(l,{label:s("metrics.memory"),value:`${h(r.memory.rssBytes)} RSS`,detail:`${h(r.memory.heapUsedBytes)} / ${h(r.memory.heapTotalBytes)} ${s("metrics.heap")}`}),e.jsx(l,{label:s("metrics.compileQueue"),value:`${r.compileQueue.running} / ${r.compileQueue.concurrency}`,detail:s("metrics.pending",{count:r.compileQueue.pending})}),e.jsx(l,{label:s("metrics.collaboration"),value:s("metrics.sessions",{count:r.collaboration.sessions}),detail:s("metrics.roomsAndDirty",{rooms:r.collaboration.rooms,dirty:r.collaboration.dirtyFiles})})]}),e.jsxs("section",{className:"metric-section",children:[e.jsxs("h3",{children:[e.jsx(v,{size:15}),s("metrics.eventLoop")]}),e.jsx("p",{children:s("metrics.latencySummary",r.eventLoopDelay)})]}),e.jsxs("section",{className:"metric-section",children:[e.jsx("h3",{children:s("metrics.operationDurations")}),Object.keys(r.durationsMs).length===0?e.jsx("p",{className:"muted",children:s("metrics.noSamples")}):e.jsx("div",{className:"metric-table-wrap",children:e.jsxs("table",{className:"metric-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:s("metrics.operation")}),e.jsx("th",{children:s("metrics.samples")}),e.jsx("th",{children:s("metrics.last")}),e.jsx("th",{children:"P50"}),e.jsx("th",{children:"P95"}),e.jsx("th",{children:s("metrics.max")})]})}),e.jsx("tbody",{children:Object.entries(r.durationsMs).sort(([i],[a])=>i.localeCompare(a)).map(([i,a])=>e.jsxs("tr",{children:[e.jsx("td",{children:N(i,s)}),e.jsx("td",{children:a.count}),e.jsx("td",{children:d(a.last)}),e.jsx("td",{children:d(a.p50)}),e.jsx("td",{children:d(a.p95)}),e.jsx("td",{children:d(a.max)})]},i))})]})})]})]})]})}function l({label:t,value:c,detail:s}){return e.jsxs("article",{className:"metric-card",children:[e.jsx("span",{children:t}),e.jsx("strong",{children:c}),s&&e.jsx("small",{children:s})]})}function h(t){return`${Math.round(t/1024/1024*10)/10} MB`}function g(t){const c=Math.floor(t/86400),s=Math.floor(t%86400/3600),r=Math.floor(t%3600/60);return c?`${c}d ${s}h`:s?`${s}h ${r}m`:`${r}m`}function d(t){return t>=1e3?`${Math.round(t/100)/10}s`:`${Math.round(t*10)/10}ms`}function N(t,c){return c(`metrics.operations.${t}`,{defaultValue:t})}export{k as SystemMetricsDialog};