keel-agent 0.124.0 → 0.125.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/packages/keel/src/adapters/sdk/prompt-render.js +5 -2
- package/dist/packages/keel/src/app/core-engine.js +16 -0
- package/dist/packages/keel/src/app/engine-dismiss.js +44 -0
- package/dist/packages/keel/src/app/session-registry.js +7 -1
- package/dist/packages/keel/src/app/subagent-runtime.js +8 -1
- package/dist/packages/keel/src/tool-catalog.js +5 -5
- package/dist/server/core-settings-adapter.js +48 -13
- package/dist/server/device-center/bot-chat.js +25 -0
- package/dist/server/device-center/bot-home.js +6 -0
- package/dist/server/device-center/bot-prompt.js +110 -0
- package/dist/server/device-center/bots.js +12 -0
- package/dist/server/device-center/execution-system-prompt.js +28 -13
- package/dist/server/device-center/local.js +126 -2
- package/dist/server/index.js +1 -0
- package/dist/server/universal/universal-session.js +8 -1
- package/package.json +1 -1
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/{BgTasksModal-D9NVLipp.js → BgTasksModal-B58Pn34o.js} +1 -1
- package/web/dist/assets/{BgTasksModal-CeowQkSk.js → BgTasksModal-DlRMULTX.js} +1 -1
- package/web/dist/assets/{BottomDock-DnXJHyg7.js → BottomDock-ix2rdS6N.js} +1 -1
- package/web/dist/assets/{CanvasStudio-D_RAeDdS.js → CanvasStudio-BRCkVMbW.js} +1 -1
- package/web/dist/assets/{CanvasStudio-BRWqZIVu.js → CanvasStudio-Cjxb3q3B.js} +1 -1
- package/web/dist/assets/{DeviceCenter-USAoAkin.js → DeviceCenter-BWMmB-CF.js} +1 -1
- package/web/dist/assets/{DeviceCenter-d49w4XXm.js → DeviceCenter-DfLlGGBZ.js} +1 -1
- package/web/dist/assets/{DeviceExecutionSettings-2hoZaBQ0.js → DeviceExecutionSettings-BjduyZOy.js} +1 -1
- package/web/dist/assets/DeviceGroupSection-B98LzFoj.js +7 -0
- package/web/dist/assets/DeviceGroupSection-BD3CKMFH.js +7 -0
- package/web/dist/assets/{DeviceGroups-BPE61M6w.js → DeviceGroups-C_lcfK5h.js} +1 -1
- package/web/dist/assets/DeviceGroups-ob27f-Ha.js +1 -0
- package/web/dist/assets/{Dropdown-DAiTWOzs.js → Dropdown-C8yx9mqF.js} +1 -1
- package/web/dist/assets/{FilePreview-CtSZWiJB.js → FilePreview-OxK_pI6p.js} +1 -1
- package/web/dist/assets/{FilePreview-xePo9QMY.js → FilePreview-inPVGc1j.js} +1 -1
- package/web/dist/assets/{GlobalSearchModal-CQhENYtf.js → GlobalSearchModal-3g1PplIg.js} +1 -1
- package/web/dist/assets/GlobalSearchModal-DG-HC0vV.js +1 -0
- package/web/dist/assets/{GroupConversation-DXDC1d3x.js → GroupConversation-BJnwTtT2.js} +2 -2
- package/web/dist/assets/{GroupConversation-CFv2RYwI.js → GroupConversation-Clt5o_lo.js} +1 -1
- package/web/dist/assets/{GroupWorkItems-BeZvaxV9.js → GroupWorkItems-7yTbAr_f.js} +1 -1
- package/web/dist/assets/{ModelConfigModal-drDDlawe.js → ModelConfigModal-CNnEGfep.js} +1 -1
- package/web/dist/assets/{ModelConfigModal-BI6ekcG4.js → ModelConfigModal-CYqDNXap.js} +1 -1
- package/web/dist/assets/{NativeCliPanel-B029dN9l.js → NativeCliPanel-B407C4qC.js} +1 -1
- package/web/dist/assets/{NativeCliPanel-BsehkHXc.js → NativeCliPanel-CVbFXUSf.js} +1 -1
- package/web/dist/assets/{PiSetupModal-D46ea4Wb.js → PiSetupModal-CrjDf0j6.js} +1 -1
- package/web/dist/assets/{ProviderOAuthControls-t8myaqZa.js → ProviderOAuthControls-Crhc6icP.js} +1 -1
- package/web/dist/assets/{SCMPanel-DUrKyvGV.js → SCMPanel-DuRJx0nl.js} +1 -1
- package/web/dist/assets/{SCMPanel-BKgGm9au.js → SCMPanel-rUAKnxBo.js} +1 -1
- package/web/dist/assets/SettingsModal-B3Q5EoVC.js +29 -0
- package/web/dist/assets/{SettingsModal-Bn0GTNgo.js → SettingsModal-CnJsUyvi.js} +1 -1
- package/web/dist/assets/{TermXterm-2oOzNy1G.js → TermXterm-BDLmWqim.js} +1 -1
- package/web/dist/assets/{TermXterm-D_VbvSyY.js → TermXterm-DhbhRp0B.js} +1 -1
- package/web/dist/assets/{TerminalPanel-CJ4ykxfy.js → TerminalPanel-D6oMxabb.js} +1 -1
- package/web/dist/assets/{TerminalPanel-mTL87sXL.js → TerminalPanel-Ds_hnvxz.js} +1 -1
- package/web/dist/assets/{ThemeMarketModal-B55xZq9j.js → ThemeMarketModal-5lH7k1in.js} +1 -1
- package/web/dist/assets/{ThemeMarketModal-EahvoJAf.js → ThemeMarketModal-WSOd5c6j.js} +1 -1
- package/web/dist/assets/{TuiOverlayModal-B2B5yRVf.js → TuiOverlayModal-Dh_HsAvo.js} +1 -1
- package/web/dist/assets/{TuiOverlayModal-C1uwsm1r.js → TuiOverlayModal-dKDCTdt8.js} +1 -1
- package/web/dist/assets/{api-client-CGqoOWHJ.js → api-client-BbDlV0jR.js} +1 -1
- package/web/dist/assets/{canvas-client-LIotRrYf.js → canvas-client-OwhfLxJx.js} +1 -1
- package/web/dist/assets/{desktop-BHN7gNP2.js → desktop-D1lGoY5p.js} +1 -1
- package/web/dist/assets/{fi-DjvtEEnZ.js → fi-CcqqfamG.js} +6 -6
- package/web/dist/assets/index-BQb8EOhk.js +410 -0
- package/web/dist/assets/index-Dbv9RJwm.js +410 -0
- package/web/dist/assets/index-xAdOV6os.css +1 -0
- package/web/dist/assets/{plugin-host-VdvQxFkv.js → plugin-host-DjGRLyyK.js} +1 -1
- package/web/dist/assets/{theme-DGfXszyo.js → theme-Dl8KLbt-.js} +1 -1
- package/web/dist/assets/use-copy-feedback-B3di-fnu.js +1 -0
- package/web/dist/index.html +11 -10
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/DeviceGroupSection-CRdMGDwE.js +0 -7
- package/web/dist/assets/GlobalSearchModal-DpHvykpb.js +0 -1
- package/web/dist/assets/SettingsModal-ComFBXCj.js +0 -29
- package/web/dist/assets/index-4-PoF3xB.css +0 -1
- package/web/dist/assets/index-CXTnvcJF.js +0 -409
- package/web/dist/assets/index-Y0yKgBrc.js +0 -409
package/web/dist/assets/{ProviderOAuthControls-t8myaqZa.js → ProviderOAuthControls-Crhc6icP.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{vn as t}from"./fi-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{vn as t}from"./fi-CcqqfamG.js";import{i as n,t as r}from"./react-CR5VJ85Q.js";import{t as i}from"./app-globals-wu8LLlnA.js";var a=e(n(),1),o=r();function s({provider:e,flow:n,result:r}){let s=t(),c=n?.event,l=e.oauthName??e.name,[u,d]=(0,a.useState)(``);return(0,a.useEffect)(()=>d(``),[n?.promptId]),e.usingOAuth?(0,o.jsxs)(`div`,{className:`provider-oauth`,children:[(0,o.jsx)(`span`,{className:`provider-oauth-status`,children:s(`oauthConnected`,{name:l})}),(0,o.jsx)(`button`,{type:`button`,className:`btn sm danger`,"data-provider-oauth-logout":e.id,onClick:()=>i({type:`provider_oauth_logout`,provider:e.id}),children:s(`oauthLogout`)}),r?.error&&(0,o.jsx)(`div`,{className:`provider-oauth-error`,children:r.error})]}):(0,o.jsxs)(`div`,{className:`provider-oauth`,children:[n?(0,o.jsxs)(o.Fragment,{children:[c?.type===`device_code`&&(0,o.jsxs)(`div`,{className:`provider-oauth-device`,children:[(0,o.jsx)(`div`,{children:s(`oauthDeviceCode`)}),(0,o.jsx)(`code`,{"data-oauth-device-code":!0,children:c.userCode}),(0,o.jsx)(`a`,{"data-oauth-verification-url":!0,href:c.verificationUri,target:`_blank`,rel:`noreferrer`,children:s(`oauthOpenVerification`)})]}),c?.type===`auth_url`&&(0,o.jsxs)(`div`,{className:`provider-oauth-event`,children:[c.instructions&&(0,o.jsx)(`div`,{children:c.instructions}),(0,o.jsx)(`a`,{href:c.url,target:`_blank`,rel:`noreferrer`,children:s(`oauthOpenVerification`)})]}),c?.type===`progress`&&(0,o.jsx)(`div`,{className:`provider-oauth-message`,children:c.message}),c?.type===`info`&&(0,o.jsxs)(`div`,{className:`provider-oauth-event`,children:[(0,o.jsx)(`div`,{children:c.message}),c.links?.map(e=>(0,o.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.label??e.url},e.url))]}),n.prompt&&(0,o.jsx)(`div`,{className:`provider-oauth-message`,children:n.prompt.message}),n.prompt?.type===`select`&&n.promptId&&(0,o.jsx)(`div`,{className:`provider-oauth-options`,children:n.prompt.options.map(e=>(0,o.jsx)(`button`,{type:`button`,className:`btn sm`,"data-oauth-option":e.id,onClick:()=>i({type:`provider_oauth_reply`,flowId:n.flowId,promptId:n.promptId,value:e.id}),children:e.label},e.id))}),n.prompt&&n.prompt.type!==`select`&&n.promptId&&(0,o.jsxs)(`form`,{className:`provider-oauth-prompt`,onSubmit:e=>{e.preventDefault(),u.trim()&&i({type:`provider_oauth_reply`,flowId:n.flowId,promptId:n.promptId,value:u.trim()})},children:[(0,o.jsx)(`input`,{"data-oauth-prompt-input":!0,type:n.prompt.type===`secret`?`password`:`text`,className:`key-input`,placeholder:n.prompt.placeholder,value:u,onChange:e=>d(e.target.value)}),(0,o.jsx)(`button`,{type:`submit`,className:`btn primary sm`,"data-oauth-prompt-submit":!0,disabled:!u.trim(),children:s(`oauthContinue`)})]}),(0,o.jsx)(`button`,{type:`button`,className:`btn sm danger`,"data-oauth-cancel":n.flowId,onClick:()=>i({type:`provider_oauth_cancel`,flowId:n.flowId}),children:s(`cancel`)})]}):(0,o.jsx)(`button`,{type:`button`,className:`btn primary sm`,"data-provider-oauth-login":e.id,onClick:()=>i({type:`provider_oauth_start`,provider:e.id}),children:s(`oauthLogin`,{name:l})}),r?.error&&(0,o.jsx)(`div`,{className:`provider-oauth-error`,children:r.error})]})}export{s as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,$t as n,C as r,Ft as i,L as a,Pt as o,Tn as s,Tt as c,Zt as l,b as u,cn as d,d as f,gn as p,j as m,s as h,sn as g,vn as ee,w as te,zt as _}from"./fi-DjvtEEnZ.js";import{i as v,t as y}from"./react-CR5VJ85Q.js";import{t as b}from"./overlay-stack-BHdOmj3G.js";import{t as x}from"./shortcut-stack-hhrDyRBn.js";import{t as ne}from"./uuid-BzDIGCwP.js";import{t as re}from"./Dropdown-DAiTWOzs.js";import{i as ie,t as ae}from"./app-globals-wu8LLlnA.js";import{F as S}from"./index-CXTnvcJF.js";var C=e(v(),1),oe=e=>`'${e.replace(/'/g,`'\\''`)}'`,se=`pi-web-ui:scm-sidebar-width`;function ce(e,t=0){if(!Number.isFinite(e))return 300;let n=Math.max(200,Math.min(720,t>0?t-220:720));return Math.min(n,Math.max(200,Math.round(e)))}function le(e){return e===null||e.trim()===``?300:ce(Number(e))}function ue(e,t){let n=t.toLowerCase();return e.subject.toLowerCase().includes(n)||e.author.toLowerCase().includes(n)||e.shortHash.toLowerCase().includes(n)||e.hash.toLowerCase().includes(n)||e.decorations!==void 0&&e.decorations.toLowerCase().includes(n)}function de(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?e:e.filter(e=>n.every(t=>ue(e,t)))}function fe(e){if(e.x===`?`&&e.y===`?`)return`untracked`;let t=e.x!==` `&&e.x!==`?`,n=e.y!==` `&&e.y!==`?`;return t&&n?`both`:t?`staged`:`unstaged`}function pe(e){let t=fe(e);return t===`staged`||t===`both`}function me(e){let t=fe(e);return t===`unstaged`||t===`untracked`||t===`both`}function he(e){let t=[],n=[];for(let r of e)pe(r)&&t.push(r),me(r)&&n.push(r);return{staged:t,unstaged:n}}function ge(e){let t=e.x!==` `&&e.x!==`?`?e.x:e.y;return!t||t===` `||t===`?`?`U`:t}function _e(e,t){let n=0,r=0;for(let i of e){let e=t.get(i.path);e&&(n+=e.add,r+=e.del)}return{count:e.length,add:n,del:r}}var ve=30;function ye(e){let{t,status:n,handlers:r,notRepo:i}=e,a=!!n?.upstream&&!n.upstreamGone,o=!!n?.detached,s=e.commitMsg.trim().length>0,c=[],l=t(`scmGroupSync`);c.push({id:`sync.pull`,group:l,label:t(`scmPull`),hint:`git pull`,badge:n&&n.behind>0?`↓${n.behind}`:void 0,disabled:i||!a||o,run:r.pull},{id:`sync.push`,group:l,label:t(`scmPush`),hint:`git push`,badge:n&&n.ahead>0?`↑${n.ahead}`:void 0,disabled:i||!a||o,run:r.push},{id:`sync.fetch`,group:l,label:t(`scmPaletteFetchAll`),hint:`git fetch --all --prune`,disabled:i,run:r.fetch});let u=t(`scmGroupBranch`);c.push({id:`branch.create`,group:u,label:t(`scmBranchNew`),hint:`git checkout -b <name>`,disabled:i,run:r.branchCreate},{id:`branch.rename`,group:u,label:t(`scmBranchRename`),hint:`git branch -m <name>`,disabled:i||o||!n?.branch,run:r.branchRename});let d=w(e,Math.min(e.branches.length,ve));c.push(...d);let f=t(`scmGroupCommit`);c.push({id:`commit.staged`,group:f,label:t(`scmCommit`),hint:`git commit -m "…"`,badge:e.stagedCount>0?String(e.stagedCount):void 0,disabled:i||!s||e.stagedCount===0,run:r.commit},{id:`commit.all`,group:f,label:t(`scmCommitAll`),hint:`git add -A && git commit`,disabled:i||!s||e.fileCount===0,run:r.commitAll},{id:`commit.amend`,group:f,label:t(`scmAmend`),hint:`git commit --amend`,disabled:i,run:r.amend},{id:`commit.generate`,group:f,label:t(`scmGenMsg`),disabled:i,run:r.genMessage});let p=t(`scmGroupChange`);c.push({id:`change.stage-all`,group:p,label:t(`scmStageAll`),hint:`git add -A`,disabled:i||e.fileCount===0,run:r.stageAll},{id:`change.unstage-all`,group:p,label:t(`scmUnstageAll`),hint:`git reset HEAD`,disabled:i||e.stagedCount===0,run:r.unstageAll},{id:`change.stash`,group:p,label:t(`scmStashSave`),hint:`git stash push`,disabled:i,run:()=>r.stashSave(!1)},{id:`change.stash-untracked`,group:p,label:t(`scmStashIncludeUntracked`),hint:`git stash push -u`,disabled:i,run:()=>r.stashSave(!0)},{id:`change.stash-open`,group:p,label:t(`scmStashOpenList`),disabled:i,run:r.stashOpen}),e.selectedPath&&c.push({id:`change.discard-selected`,group:p,label:t(`scmDiscardSelected`),hint:e.selectedPath,tone:`danger`,disabled:i,run:r.discardSelected});let m=t(`scmGroupView`);c.push({id:`view.blame`,group:m,label:e.showBlame?t(`scmBlameHide`):t(`scmBlameShow`),hint:e.selectedPath??void 0,disabled:i||!e.selectedPath,run:r.toggleBlame},{id:`view.terminal`,group:m,label:t(`scmViewTerminal`),disabled:!1,run:r.openTerminal},{id:`view.refresh`,group:m,label:t(`bgTaskRefresh`),hint:t(`scmRefreshTip`),disabled:!1,run:r.refresh});let h=t(`scmGroupRemote`);return c.push({id:`remote.tag-create`,group:h,label:t(`scmTagCreate`),hint:`git tag <name>`,disabled:i,run:r.createTag},{id:`remote.tag-push`,group:h,label:t(`scmTagPush`),hint:`git push --tags`,disabled:i||!(n?.upstream||e.branches.some(e=>e.remote)),run:r.pushTags}),c}function w(e,t){let{t:n,handlers:r}=e,i=n(`scmPaletteCheckout`);return e.branches.slice(0,t).map(t=>({id:`branch.checkout.${t.name}`,group:i,label:t.name,hint:t.remote?n(`scmPaletteRemote`):n(`scmPaletteLocal`),badge:t.current?n(`scmPaletteCurrent`):void 0,disabled:e.notRepo||t.current,run:()=>r.branchCheckout(t.name)}))}var be=`scm-commit-history`;function xe(e=localStorage){try{let t=e.getItem(be);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0):[]}catch{return[]}}function Se(e,t=localStorage){let n=e.trim();if(!n)return xe(t);let r=[n,...xe(t).filter(e=>e!==n)].slice(0,20);try{t.setItem(be,JSON.stringify(r))}catch{}return r}var T={idx:-1,draft:``};function Ce(e,t,n,r){return e.length===0?null:r===`up`?t.idx>=e.length-1?null:t.idx===-1?{state:{idx:0,draft:n},text:e[0]}:{state:{idx:t.idx+1,draft:t.draft},text:e[t.idx+1]}:t.idx===-1?null:t.idx===0?{state:T,text:t.draft}:{state:{idx:t.idx-1,draft:t.draft},text:e[t.idx-1]}}var E=y(),D={A:`green`,U:`green`,D:`red`,R:`accent`,M:`amber`};function we(e){return D[ge(e)]??`amber`}function Te({files:e,stats:t,selectedPath:n,notRepo:r,pending:i,connected:a,onSelect:s,onStage:l,onUnstage:u,onDiscard:d,onStageAll:f,onUnstageAll:p}){let m=ee(),[h,te]=(0,C.useState)(``),v=(0,C.useMemo)(()=>{let t=h.trim().toLowerCase();return t?e.filter(e=>e.path.toLowerCase().includes(t)):[...e]},[e,h]),y=(0,C.useMemo)(()=>he(v),[v]),b=(0,C.useMemo)(()=>_e(y.staged,t),[y.staged,t]),x=(0,C.useMemo)(()=>_e(y.unstaged,t),[y.unstaged,t]),ne=y.unstaged.length>0;return(0,E.jsxs)(`div`,{className:`scm-files`,children:[(0,E.jsxs)(`div`,{className:`scm-files-header`,children:[(0,E.jsx)(`span`,{children:m(`scmChanges`)}),(0,E.jsxs)(`span`,{className:`scm-files-head-actions`,children:[e.length>0&&(0,E.jsx)(`span`,{className:`scm-files-count`,children:e.length}),(0,E.jsx)(`button`,{type:`button`,className:`scm-act`,title:m(`scmStageAllTip`),"aria-label":m(`scmStageAllTip`),disabled:r||!ne,onClick:f,children:(0,E.jsx)(o,{})}),(0,E.jsx)(`button`,{type:`button`,className:`scm-act`,title:m(`scmUnstageAllTip`),"aria-label":m(`scmUnstageAllTip`),disabled:r||y.staged.length===0,onClick:p,children:(0,E.jsx)(c,{})})]})]}),!r&&e.length>0&&(0,E.jsxs)(`div`,{className:`scm-filter`,children:[(0,E.jsx)(_,{"aria-hidden":`true`}),(0,E.jsx)(`input`,{value:h,placeholder:m(`scmFilterFiles`),title:m(`scmFilterFilesTip`),"aria-label":m(`scmFilterFilesTip`),onChange:e=>te(e.target.value),spellCheck:!1}),h&&(0,E.jsx)(`button`,{type:`button`,className:`scm-filter-clear`,"aria-label":m(`close`),onClick:()=>te(``),children:(0,E.jsx)(g,{})})]}),(0,E.jsx)(`div`,{className:`scm-files-list`,children:r?(0,E.jsx)(`div`,{className:`scm-empty`,children:m(`scmNotGitRepo`)}):i?(0,E.jsx)(`div`,{className:`scm-empty`,children:m(a?`scmLoading`:`scmConnecting`)}):e.length===0?(0,E.jsx)(`div`,{className:`scm-empty`,children:m(`scmNoChanges`)}):v.length===0?(0,E.jsx)(`div`,{className:`scm-empty`,children:m(`scmFilterEmpty`)}):(0,E.jsxs)(E.Fragment,{children:[y.staged.length>0&&(0,E.jsxs)(`div`,{className:`scm-group`,"data-group":`staged`,children:[(0,E.jsxs)(`div`,{className:`scm-group-head`,children:[(0,E.jsx)(`span`,{className:`scm-group-title`,children:m(`scmStaged`)}),(0,E.jsx)(`span`,{className:`scm-group-count`,children:y.staged.length}),b.add>0&&(0,E.jsxs)(`span`,{className:`scm-group-stat add`,children:[`+`,b.add]}),b.del>0&&(0,E.jsxs)(`span`,{className:`scm-group-stat del`,children:[`-`,b.del]})]}),y.staged.map(e=>(0,E.jsx)(Ee,{f:e,stagedRow:!0,stat:t.get(e.path),selected:n===e.path,onSelect:s,onStage:l,onUnstage:u,onDiscard:d},`staged:${e.path}`))]}),y.unstaged.length>0&&(0,E.jsxs)(`div`,{className:`scm-group`,"data-group":`changes`,children:[(0,E.jsxs)(`div`,{className:`scm-group-head`,children:[(0,E.jsx)(`span`,{className:`scm-group-title`,children:m(`scmChanges`)}),(0,E.jsx)(`span`,{className:`scm-group-count`,children:y.unstaged.length}),x.add>0&&(0,E.jsxs)(`span`,{className:`scm-group-stat add`,children:[`+`,x.add]}),x.del>0&&(0,E.jsxs)(`span`,{className:`scm-group-stat del`,children:[`-`,x.del]})]}),y.unstaged.map(e=>(0,E.jsx)(Ee,{f:e,stagedRow:!1,stat:t.get(e.path),selected:n===e.path,onSelect:s,onStage:l,onUnstage:u,onDiscard:d},`changes:${e.path}`))]})]})})]})}function Ee({f:e,stagedRow:t,stat:r,selected:i,onSelect:a,onStage:s,onUnstage:l,onDiscard:d}){let f=ee(),p=fe(e),m=p===`both`,h=f(t?m?`scmStagedUnstaged`:`scmStaged`:p===`untracked`?`scmUntracked`:m?`scmStagedUnstaged`:`scmUnstaged`),g=f(t?`scmUnstageTip`:`scmStageTip`,{path:e.path});return(0,E.jsxs)(`div`,{className:`scm-file${i?` active`:``}${t?` staged`:``}`,title:`${h} · ${e.path}`,onClick:()=>a(e),children:[(0,E.jsxs)(`label`,{className:`scm-file-tick`,title:g,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,E.jsx)(`input`,{type:`checkbox`,checked:t,"aria-label":g,onChange:()=>t?l(e):s(e)}),(0,E.jsx)(`span`,{className:`scm-file-box`,"aria-hidden":`true`,children:(0,E.jsx)(u,{})})]}),(0,E.jsx)(`span`,{className:`scm-file-letter ${we(e)}`,children:ge(e)}),(0,E.jsx)(`span`,{className:`scm-file-path`,children:e.path}),r&&(r.add>0||r.del>0)&&(0,E.jsxs)(`span`,{className:`scm-file-stat`,children:[r.add>0&&(0,E.jsxs)(`span`,{className:`add`,children:[`+`,r.add]}),r.del>0&&(0,E.jsxs)(`span`,{className:`del`,children:[`-`,r.del]})]}),(0,E.jsxs)(`span`,{className:`scm-file-actions`,children:[t?(0,E.jsx)(`button`,{type:`button`,className:`scm-act`,title:f(`scmUnstageTip`,{path:e.path}),"aria-label":f(`scmUnstageTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),l(e)},children:(0,E.jsx)(c,{})}):(0,E.jsx)(`button`,{type:`button`,className:`scm-act`,title:f(`scmStageTip`,{path:e.path}),"aria-label":f(`scmStageTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),s(e)},children:(0,E.jsx)(o,{})}),!t&&(0,E.jsx)(`button`,{type:`button`,className:`scm-act`,title:f(p===`untracked`?`scmDiscardUntrackedTip`:`scmDiscardTip`,{path:e.path}),"aria-label":f(p===`untracked`?`scmDiscardUntrackedTip`:`scmDiscardTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),d(e)},children:(0,E.jsx)(n,{})})]})]})}function De(e,t){return!t||`${e.label} ${e.hint??``} ${e.group} ${e.id}`.toLowerCase().includes(t)}function Oe({open:e,onClose:t,labels:n,actions:r}){let i=b(e),[a,o]=(0,C.useState)(``),[s,c]=(0,C.useState)(0),l=(0,C.useRef)(null),u=(0,C.useRef)(null),d=(0,C.useRef)(``);x(t,e),(0,C.useEffect)(()=>{if(!e)return;o(``),c(0),d.current=``;let t=window.setTimeout(()=>l.current?.focus(),0);return()=>window.clearTimeout(t)},[e]);let f=a.trim().toLowerCase(),p=(0,C.useMemo)(()=>r.filter(e=>De(e,f)),[r,f]);(0,C.useEffect)(()=>{if(!e)return;let t=d.current!==f;d.current=f,c(e=>{if(!t){let t=p[e];if(t&&!t.disabled)return e}let n=p.findIndex(e=>!e.disabled);return n<0?0:n})},[e,f,p]);let m=(0,C.useMemo)(()=>{let e=[],t=new Map;return p.forEach((n,r)=>{t.has(n.group)||(t.set(n.group,[]),e.push(n.group)),t.get(n.group)?.push({action:n,index:r})}),e.map(e=>({group:e,items:t.get(e)??[]}))},[p]);if((0,C.useEffect)(()=>{e&&(u.current?.querySelector(`[data-idx="${s}"]`))?.scrollIntoView({block:`nearest`})},[s,e]),!e)return null;let h=e=>{e&&!e.disabled&&(t(),e.run())},g=e=>{p.length!==0&&c(t=>{let n=t;for(let t=0;t<p.length;t++)if(n+=e,n<0&&(n=p.length-1),n>=p.length&&(n=0),!p[n].disabled)return n;return t})};return(0,E.jsx)(`div`,{className:`scm-pal-backdrop`,role:`dialog`,"aria-modal":`true`,"aria-label":n.title,style:{zIndex:i},onMouseDown:e=>{e.target===e.currentTarget&&t()},onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),g(1)):e.key===`ArrowUp`?(e.preventDefault(),g(-1)):e.key===`Enter`&&(e.preventDefault(),h(p[s]))},children:(0,E.jsxs)(`div`,{className:`scm-pal`,children:[(0,E.jsxs)(`div`,{className:`scm-pal-head`,children:[(0,E.jsx)(_,{"aria-hidden":`true`}),(0,E.jsx)(`input`,{ref:l,value:a,placeholder:n.placeholder,"aria-label":n.placeholder,onChange:e=>o(e.target.value),autoComplete:`off`,spellCheck:!1}),(0,E.jsx)(`span`,{className:`scm-pal-kbd`,children:`Esc`})]}),(0,E.jsx)(`div`,{className:`scm-pal-list`,ref:u,role:`listbox`,"aria-label":n.title,children:p.length===0?(0,E.jsx)(`div`,{className:`scm-pal-empty`,children:n.empty}):m.map(e=>(0,E.jsxs)(`div`,{className:`scm-pal-group`,children:[(0,E.jsx)(`div`,{className:`scm-pal-group-title`,children:e.group}),e.items.map(({action:e,index:t})=>(0,E.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===s,"data-idx":t,disabled:e.disabled,className:`scm-pal-row${t===s?` on`:``}${e.tone===`danger`?` danger`:``}`,onMouseMove:()=>c(t),onClick:()=>h(e),title:e.hint??e.label,children:[(0,E.jsxs)(`span`,{className:`scm-pal-row-main`,children:[(0,E.jsx)(`span`,{className:`scm-pal-row-label`,children:e.label}),e.hint&&(0,E.jsx)(`span`,{className:`scm-pal-row-hint`,children:e.hint})]}),e.badge&&(0,E.jsx)(`span`,{className:`scm-pal-badge`,children:e.badge})]},e.id))]},e.group))}),(0,E.jsxs)(`div`,{className:`scm-pal-foot`,children:[(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`span`,{className:`scm-pal-kbd`,children:`↑`}),(0,E.jsx)(`span`,{className:`scm-pal-kbd`,children:`↓`}),n.move]}),(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`span`,{className:`scm-pal-kbd`,children:`⏎`}),n.run]}),(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`span`,{className:`scm-pal-kbd`,children:`Esc`}),n.close]}),(0,E.jsx)(`span`,{className:`scm-pal-count`,children:n.count(p.length)})]})]})})}var ke=8e3;function Ae(e){e.current&&clearTimeout(e.current),e.current=null}function je(e){return e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`new file`)||e.startsWith(`deleted file`)||e.startsWith(`old mode`)||e.startsWith(`new mode`)||e.startsWith(`similarity index`)||e.startsWith(`rename `)||e.startsWith(`copy `)||e.startsWith(`Binary files`)||e.startsWith(`---`)||e.startsWith(`+++`)}function Me(e){let t=0,n=0,r=0;for(let i of e.split(`
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,$t as n,C as r,Ft as i,L as a,Pt as o,Tn as s,Tt as c,Zt as l,b as u,cn as d,d as f,gn as p,j as m,s as h,sn as g,vn as ee,w as te,zt as _}from"./fi-CcqqfamG.js";import{i as v,t as y}from"./react-CR5VJ85Q.js";import{t as b}from"./overlay-stack-BHdOmj3G.js";import{t as x}from"./shortcut-stack-hhrDyRBn.js";import{t as ne}from"./uuid-BzDIGCwP.js";import{t as re}from"./Dropdown-C8yx9mqF.js";import{i as ie,t as ae}from"./app-globals-wu8LLlnA.js";import{F as S}from"./index-BQb8EOhk.js";var C=e(v(),1),oe=e=>`'${e.replace(/'/g,`'\\''`)}'`,se=`pi-web-ui:scm-sidebar-width`;function ce(e,t=0){if(!Number.isFinite(e))return 300;let n=Math.max(200,Math.min(720,t>0?t-220:720));return Math.min(n,Math.max(200,Math.round(e)))}function le(e){return e===null||e.trim()===``?300:ce(Number(e))}function ue(e,t){let n=t.toLowerCase();return e.subject.toLowerCase().includes(n)||e.author.toLowerCase().includes(n)||e.shortHash.toLowerCase().includes(n)||e.hash.toLowerCase().includes(n)||e.decorations!==void 0&&e.decorations.toLowerCase().includes(n)}function de(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?e:e.filter(e=>n.every(t=>ue(e,t)))}function fe(e){if(e.x===`?`&&e.y===`?`)return`untracked`;let t=e.x!==` `&&e.x!==`?`,n=e.y!==` `&&e.y!==`?`;return t&&n?`both`:t?`staged`:`unstaged`}function pe(e){let t=fe(e);return t===`staged`||t===`both`}function me(e){let t=fe(e);return t===`unstaged`||t===`untracked`||t===`both`}function he(e){let t=[],n=[];for(let r of e)pe(r)&&t.push(r),me(r)&&n.push(r);return{staged:t,unstaged:n}}function ge(e){let t=e.x!==` `&&e.x!==`?`?e.x:e.y;return!t||t===` `||t===`?`?`U`:t}function _e(e,t){let n=0,r=0;for(let i of e){let e=t.get(i.path);e&&(n+=e.add,r+=e.del)}return{count:e.length,add:n,del:r}}var ve=30;function ye(e){let{t,status:n,handlers:r,notRepo:i}=e,a=!!n?.upstream&&!n.upstreamGone,o=!!n?.detached,s=e.commitMsg.trim().length>0,c=[],l=t(`scmGroupSync`);c.push({id:`sync.pull`,group:l,label:t(`scmPull`),hint:`git pull`,badge:n&&n.behind>0?`↓${n.behind}`:void 0,disabled:i||!a||o,run:r.pull},{id:`sync.push`,group:l,label:t(`scmPush`),hint:`git push`,badge:n&&n.ahead>0?`↑${n.ahead}`:void 0,disabled:i||!a||o,run:r.push},{id:`sync.fetch`,group:l,label:t(`scmPaletteFetchAll`),hint:`git fetch --all --prune`,disabled:i,run:r.fetch});let u=t(`scmGroupBranch`);c.push({id:`branch.create`,group:u,label:t(`scmBranchNew`),hint:`git checkout -b <name>`,disabled:i,run:r.branchCreate},{id:`branch.rename`,group:u,label:t(`scmBranchRename`),hint:`git branch -m <name>`,disabled:i||o||!n?.branch,run:r.branchRename});let d=w(e,Math.min(e.branches.length,ve));c.push(...d);let f=t(`scmGroupCommit`);c.push({id:`commit.staged`,group:f,label:t(`scmCommit`),hint:`git commit -m "…"`,badge:e.stagedCount>0?String(e.stagedCount):void 0,disabled:i||!s||e.stagedCount===0,run:r.commit},{id:`commit.all`,group:f,label:t(`scmCommitAll`),hint:`git add -A && git commit`,disabled:i||!s||e.fileCount===0,run:r.commitAll},{id:`commit.amend`,group:f,label:t(`scmAmend`),hint:`git commit --amend`,disabled:i,run:r.amend},{id:`commit.generate`,group:f,label:t(`scmGenMsg`),disabled:i,run:r.genMessage});let p=t(`scmGroupChange`);c.push({id:`change.stage-all`,group:p,label:t(`scmStageAll`),hint:`git add -A`,disabled:i||e.fileCount===0,run:r.stageAll},{id:`change.unstage-all`,group:p,label:t(`scmUnstageAll`),hint:`git reset HEAD`,disabled:i||e.stagedCount===0,run:r.unstageAll},{id:`change.stash`,group:p,label:t(`scmStashSave`),hint:`git stash push`,disabled:i,run:()=>r.stashSave(!1)},{id:`change.stash-untracked`,group:p,label:t(`scmStashIncludeUntracked`),hint:`git stash push -u`,disabled:i,run:()=>r.stashSave(!0)},{id:`change.stash-open`,group:p,label:t(`scmStashOpenList`),disabled:i,run:r.stashOpen}),e.selectedPath&&c.push({id:`change.discard-selected`,group:p,label:t(`scmDiscardSelected`),hint:e.selectedPath,tone:`danger`,disabled:i,run:r.discardSelected});let m=t(`scmGroupView`);c.push({id:`view.blame`,group:m,label:e.showBlame?t(`scmBlameHide`):t(`scmBlameShow`),hint:e.selectedPath??void 0,disabled:i||!e.selectedPath,run:r.toggleBlame},{id:`view.terminal`,group:m,label:t(`scmViewTerminal`),disabled:!1,run:r.openTerminal},{id:`view.refresh`,group:m,label:t(`bgTaskRefresh`),hint:t(`scmRefreshTip`),disabled:!1,run:r.refresh});let h=t(`scmGroupRemote`);return c.push({id:`remote.tag-create`,group:h,label:t(`scmTagCreate`),hint:`git tag <name>`,disabled:i,run:r.createTag},{id:`remote.tag-push`,group:h,label:t(`scmTagPush`),hint:`git push --tags`,disabled:i||!(n?.upstream||e.branches.some(e=>e.remote)),run:r.pushTags}),c}function w(e,t){let{t:n,handlers:r}=e,i=n(`scmPaletteCheckout`);return e.branches.slice(0,t).map(t=>({id:`branch.checkout.${t.name}`,group:i,label:t.name,hint:t.remote?n(`scmPaletteRemote`):n(`scmPaletteLocal`),badge:t.current?n(`scmPaletteCurrent`):void 0,disabled:e.notRepo||t.current,run:()=>r.branchCheckout(t.name)}))}var be=`scm-commit-history`;function xe(e=localStorage){try{let t=e.getItem(be);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0):[]}catch{return[]}}function Se(e,t=localStorage){let n=e.trim();if(!n)return xe(t);let r=[n,...xe(t).filter(e=>e!==n)].slice(0,20);try{t.setItem(be,JSON.stringify(r))}catch{}return r}var T={idx:-1,draft:``};function Ce(e,t,n,r){return e.length===0?null:r===`up`?t.idx>=e.length-1?null:t.idx===-1?{state:{idx:0,draft:n},text:e[0]}:{state:{idx:t.idx+1,draft:t.draft},text:e[t.idx+1]}:t.idx===-1?null:t.idx===0?{state:T,text:t.draft}:{state:{idx:t.idx-1,draft:t.draft},text:e[t.idx-1]}}var E=y(),D={A:`green`,U:`green`,D:`red`,R:`accent`,M:`amber`};function we(e){return D[ge(e)]??`amber`}function Te({files:e,stats:t,selectedPath:n,notRepo:r,pending:i,connected:a,onSelect:s,onStage:l,onUnstage:u,onDiscard:d,onStageAll:f,onUnstageAll:p}){let m=ee(),[h,te]=(0,C.useState)(``),v=(0,C.useMemo)(()=>{let t=h.trim().toLowerCase();return t?e.filter(e=>e.path.toLowerCase().includes(t)):[...e]},[e,h]),y=(0,C.useMemo)(()=>he(v),[v]),b=(0,C.useMemo)(()=>_e(y.staged,t),[y.staged,t]),x=(0,C.useMemo)(()=>_e(y.unstaged,t),[y.unstaged,t]),ne=y.unstaged.length>0;return(0,E.jsxs)(`div`,{className:`scm-files`,children:[(0,E.jsxs)(`div`,{className:`scm-files-header`,children:[(0,E.jsx)(`span`,{children:m(`scmChanges`)}),(0,E.jsxs)(`span`,{className:`scm-files-head-actions`,children:[e.length>0&&(0,E.jsx)(`span`,{className:`scm-files-count`,children:e.length}),(0,E.jsx)(`button`,{type:`button`,className:`scm-act`,title:m(`scmStageAllTip`),"aria-label":m(`scmStageAllTip`),disabled:r||!ne,onClick:f,children:(0,E.jsx)(o,{})}),(0,E.jsx)(`button`,{type:`button`,className:`scm-act`,title:m(`scmUnstageAllTip`),"aria-label":m(`scmUnstageAllTip`),disabled:r||y.staged.length===0,onClick:p,children:(0,E.jsx)(c,{})})]})]}),!r&&e.length>0&&(0,E.jsxs)(`div`,{className:`scm-filter`,children:[(0,E.jsx)(_,{"aria-hidden":`true`}),(0,E.jsx)(`input`,{value:h,placeholder:m(`scmFilterFiles`),title:m(`scmFilterFilesTip`),"aria-label":m(`scmFilterFilesTip`),onChange:e=>te(e.target.value),spellCheck:!1}),h&&(0,E.jsx)(`button`,{type:`button`,className:`scm-filter-clear`,"aria-label":m(`close`),onClick:()=>te(``),children:(0,E.jsx)(g,{})})]}),(0,E.jsx)(`div`,{className:`scm-files-list`,children:r?(0,E.jsx)(`div`,{className:`scm-empty`,children:m(`scmNotGitRepo`)}):i?(0,E.jsx)(`div`,{className:`scm-empty`,children:m(a?`scmLoading`:`scmConnecting`)}):e.length===0?(0,E.jsx)(`div`,{className:`scm-empty`,children:m(`scmNoChanges`)}):v.length===0?(0,E.jsx)(`div`,{className:`scm-empty`,children:m(`scmFilterEmpty`)}):(0,E.jsxs)(E.Fragment,{children:[y.staged.length>0&&(0,E.jsxs)(`div`,{className:`scm-group`,"data-group":`staged`,children:[(0,E.jsxs)(`div`,{className:`scm-group-head`,children:[(0,E.jsx)(`span`,{className:`scm-group-title`,children:m(`scmStaged`)}),(0,E.jsx)(`span`,{className:`scm-group-count`,children:y.staged.length}),b.add>0&&(0,E.jsxs)(`span`,{className:`scm-group-stat add`,children:[`+`,b.add]}),b.del>0&&(0,E.jsxs)(`span`,{className:`scm-group-stat del`,children:[`-`,b.del]})]}),y.staged.map(e=>(0,E.jsx)(Ee,{f:e,stagedRow:!0,stat:t.get(e.path),selected:n===e.path,onSelect:s,onStage:l,onUnstage:u,onDiscard:d},`staged:${e.path}`))]}),y.unstaged.length>0&&(0,E.jsxs)(`div`,{className:`scm-group`,"data-group":`changes`,children:[(0,E.jsxs)(`div`,{className:`scm-group-head`,children:[(0,E.jsx)(`span`,{className:`scm-group-title`,children:m(`scmChanges`)}),(0,E.jsx)(`span`,{className:`scm-group-count`,children:y.unstaged.length}),x.add>0&&(0,E.jsxs)(`span`,{className:`scm-group-stat add`,children:[`+`,x.add]}),x.del>0&&(0,E.jsxs)(`span`,{className:`scm-group-stat del`,children:[`-`,x.del]})]}),y.unstaged.map(e=>(0,E.jsx)(Ee,{f:e,stagedRow:!1,stat:t.get(e.path),selected:n===e.path,onSelect:s,onStage:l,onUnstage:u,onDiscard:d},`changes:${e.path}`))]})]})})]})}function Ee({f:e,stagedRow:t,stat:r,selected:i,onSelect:a,onStage:s,onUnstage:l,onDiscard:d}){let f=ee(),p=fe(e),m=p===`both`,h=f(t?m?`scmStagedUnstaged`:`scmStaged`:p===`untracked`?`scmUntracked`:m?`scmStagedUnstaged`:`scmUnstaged`),g=f(t?`scmUnstageTip`:`scmStageTip`,{path:e.path});return(0,E.jsxs)(`div`,{className:`scm-file${i?` active`:``}${t?` staged`:``}`,title:`${h} · ${e.path}`,onClick:()=>a(e),children:[(0,E.jsxs)(`label`,{className:`scm-file-tick`,title:g,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,E.jsx)(`input`,{type:`checkbox`,checked:t,"aria-label":g,onChange:()=>t?l(e):s(e)}),(0,E.jsx)(`span`,{className:`scm-file-box`,"aria-hidden":`true`,children:(0,E.jsx)(u,{})})]}),(0,E.jsx)(`span`,{className:`scm-file-letter ${we(e)}`,children:ge(e)}),(0,E.jsx)(`span`,{className:`scm-file-path`,children:e.path}),r&&(r.add>0||r.del>0)&&(0,E.jsxs)(`span`,{className:`scm-file-stat`,children:[r.add>0&&(0,E.jsxs)(`span`,{className:`add`,children:[`+`,r.add]}),r.del>0&&(0,E.jsxs)(`span`,{className:`del`,children:[`-`,r.del]})]}),(0,E.jsxs)(`span`,{className:`scm-file-actions`,children:[t?(0,E.jsx)(`button`,{type:`button`,className:`scm-act`,title:f(`scmUnstageTip`,{path:e.path}),"aria-label":f(`scmUnstageTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),l(e)},children:(0,E.jsx)(c,{})}):(0,E.jsx)(`button`,{type:`button`,className:`scm-act`,title:f(`scmStageTip`,{path:e.path}),"aria-label":f(`scmStageTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),s(e)},children:(0,E.jsx)(o,{})}),!t&&(0,E.jsx)(`button`,{type:`button`,className:`scm-act`,title:f(p===`untracked`?`scmDiscardUntrackedTip`:`scmDiscardTip`,{path:e.path}),"aria-label":f(p===`untracked`?`scmDiscardUntrackedTip`:`scmDiscardTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),d(e)},children:(0,E.jsx)(n,{})})]})]})}function De(e,t){return!t||`${e.label} ${e.hint??``} ${e.group} ${e.id}`.toLowerCase().includes(t)}function Oe({open:e,onClose:t,labels:n,actions:r}){let i=b(e),[a,o]=(0,C.useState)(``),[s,c]=(0,C.useState)(0),l=(0,C.useRef)(null),u=(0,C.useRef)(null),d=(0,C.useRef)(``);x(t,e),(0,C.useEffect)(()=>{if(!e)return;o(``),c(0),d.current=``;let t=window.setTimeout(()=>l.current?.focus(),0);return()=>window.clearTimeout(t)},[e]);let f=a.trim().toLowerCase(),p=(0,C.useMemo)(()=>r.filter(e=>De(e,f)),[r,f]);(0,C.useEffect)(()=>{if(!e)return;let t=d.current!==f;d.current=f,c(e=>{if(!t){let t=p[e];if(t&&!t.disabled)return e}let n=p.findIndex(e=>!e.disabled);return n<0?0:n})},[e,f,p]);let m=(0,C.useMemo)(()=>{let e=[],t=new Map;return p.forEach((n,r)=>{t.has(n.group)||(t.set(n.group,[]),e.push(n.group)),t.get(n.group)?.push({action:n,index:r})}),e.map(e=>({group:e,items:t.get(e)??[]}))},[p]);if((0,C.useEffect)(()=>{e&&(u.current?.querySelector(`[data-idx="${s}"]`))?.scrollIntoView({block:`nearest`})},[s,e]),!e)return null;let h=e=>{e&&!e.disabled&&(t(),e.run())},g=e=>{p.length!==0&&c(t=>{let n=t;for(let t=0;t<p.length;t++)if(n+=e,n<0&&(n=p.length-1),n>=p.length&&(n=0),!p[n].disabled)return n;return t})};return(0,E.jsx)(`div`,{className:`scm-pal-backdrop`,role:`dialog`,"aria-modal":`true`,"aria-label":n.title,style:{zIndex:i},onMouseDown:e=>{e.target===e.currentTarget&&t()},onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),g(1)):e.key===`ArrowUp`?(e.preventDefault(),g(-1)):e.key===`Enter`&&(e.preventDefault(),h(p[s]))},children:(0,E.jsxs)(`div`,{className:`scm-pal`,children:[(0,E.jsxs)(`div`,{className:`scm-pal-head`,children:[(0,E.jsx)(_,{"aria-hidden":`true`}),(0,E.jsx)(`input`,{ref:l,value:a,placeholder:n.placeholder,"aria-label":n.placeholder,onChange:e=>o(e.target.value),autoComplete:`off`,spellCheck:!1}),(0,E.jsx)(`span`,{className:`scm-pal-kbd`,children:`Esc`})]}),(0,E.jsx)(`div`,{className:`scm-pal-list`,ref:u,role:`listbox`,"aria-label":n.title,children:p.length===0?(0,E.jsx)(`div`,{className:`scm-pal-empty`,children:n.empty}):m.map(e=>(0,E.jsxs)(`div`,{className:`scm-pal-group`,children:[(0,E.jsx)(`div`,{className:`scm-pal-group-title`,children:e.group}),e.items.map(({action:e,index:t})=>(0,E.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===s,"data-idx":t,disabled:e.disabled,className:`scm-pal-row${t===s?` on`:``}${e.tone===`danger`?` danger`:``}`,onMouseMove:()=>c(t),onClick:()=>h(e),title:e.hint??e.label,children:[(0,E.jsxs)(`span`,{className:`scm-pal-row-main`,children:[(0,E.jsx)(`span`,{className:`scm-pal-row-label`,children:e.label}),e.hint&&(0,E.jsx)(`span`,{className:`scm-pal-row-hint`,children:e.hint})]}),e.badge&&(0,E.jsx)(`span`,{className:`scm-pal-badge`,children:e.badge})]},e.id))]},e.group))}),(0,E.jsxs)(`div`,{className:`scm-pal-foot`,children:[(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`span`,{className:`scm-pal-kbd`,children:`↑`}),(0,E.jsx)(`span`,{className:`scm-pal-kbd`,children:`↓`}),n.move]}),(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`span`,{className:`scm-pal-kbd`,children:`⏎`}),n.run]}),(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`span`,{className:`scm-pal-kbd`,children:`Esc`}),n.close]}),(0,E.jsx)(`span`,{className:`scm-pal-count`,children:n.count(p.length)})]})]})})}var ke=8e3;function Ae(e){e.current&&clearTimeout(e.current),e.current=null}function je(e){return e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`new file`)||e.startsWith(`deleted file`)||e.startsWith(`old mode`)||e.startsWith(`new mode`)||e.startsWith(`similarity index`)||e.startsWith(`rename `)||e.startsWith(`copy `)||e.startsWith(`Binary files`)||e.startsWith(`---`)||e.startsWith(`+++`)}function Me(e){let t=0,n=0,r=0;for(let i of e.split(`
|
|
2
2
|
`))if(i.startsWith(`@@`))r+=1;else if(i.startsWith(`+++`)||i.startsWith(`---`))continue;else i.startsWith(`+`)?t+=1:i.startsWith(`-`)&&(n+=1);return{add:t,del:n,hunks:r}}function Ne(e){let t=0,n=0,r=0;for(let i of e){if(!i)continue;let e=Me(i);t+=e.add,n+=e.del,r+=e.hunks}return{add:t,del:n,hunks:r}}function Pe(e){return e.replace(/\x1b\][^\x07\x1b]*(\x07|\x1b\\)/g,``).replace(/\x1b\[[0-9;?]*[a-zA-Z]/g,``).replace(/\x1b\(B/g,``).replace(/\x1b[=>NO78c]/g,``).replace(/\x1b/g,``).replace(/\r/g,``)}function Fe(e){let t=[];for(let n of Pe(e).split(`
|
|
3
3
|
`)){let e=n.trim();if(!e)continue;let r=/^(stash@\{\d+\}):\s*(.*)$/.exec(e);r&&t.push({ref:r[1],message:r[2]})}return t}function Ie(e){if(!Number.isFinite(e)||e<=0)return``;try{return new Date(e*1e3).toISOString().slice(0,10)}catch{return``}}function Le(e){let t=Pe(e).split(`
|
|
4
4
|
`),n=[],r=``,i=``,a=0,o=0,s=0,c=!1,l=e=>{if(!c||s<=0)return;let t=o+u.value;n.push({hash:r,shortHash:/^[0]+$/.test(r)?`0000000`:r.slice(0,7),author:i||`?`,date:Ie(a),lineNo:t,content:e}),u.value+=1},u={value:0};for(let e of t){let t=e.endsWith(`\r`)?e.slice(0,-1):e,n=/^([0-9a-f]{40}|0{40}) \d+ (\d+) (\d+)$/.exec(t);if(n){r=n[1],i=``,a=0,o=Number(n[2]),s=Number(n[3]),u.value=0,c=!0;continue}if(c){if(t.startsWith(`author `)&&!t.startsWith(`author-mail`)&&!t.startsWith(`author-time`)){i=t.slice(7);continue}if(t.startsWith(`author-time `)){a=Number(t.slice(12).trim());continue}if(t.startsWith(` `)){l(t.slice(1)),u.value>=s&&(c=!1);continue}t.startsWith(`filename `)||t.startsWith(`boundary`)}}return n.slice(0,3e3)}function Re(e){return!e||e.length>200||/\s/.test(e)||e.includes(`..`)||/[~^:?*\\[\]]/.test(e)||e.startsWith(`/`)||e.endsWith(`/`)||e.includes(`//`)||e.endsWith(`.lock`)||e.endsWith(`.`)||e.startsWith(`-`)||e.includes(`@{`)?!1:/^[A-Za-z0-9._/-]+$/.test(e)}function ze(e){let t=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(e);return t?{oldStart:Number(t[1]),newStart:Number(t[2])}:null}function Be(e){let t=[],n=0,r=0,i=!1,a=[],o=[],s=()=>{let e=Math.max(a.length,o.length);for(let n=0;n<e;n++){let e=a[n],r=o[n];t.push({kind:`pair`,left:e?{no:e.no,text:e.text,kind:`del`}:{no:null,text:``,kind:`empty`},right:r?{no:r.no,text:r.text,kind:`add`}:{no:null,text:``,kind:`empty`}})}a=[],o=[]};for(let c of e.split(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,$t as n,C as r,Ft as i,L as a,Pt as o,Tn as s,Tt as c,Zt as l,b as u,cn as d,d as f,gn as p,j as m,s as h,sn as g,vn as ee,w as te,zt as _}from"./fi-DjvtEEnZ.js";import{i as v,t as y}from"./react-CR5VJ85Q.js";import{t as b}from"./overlay-stack-BHdOmj3G.js";import{t as x}from"./shortcut-stack-hhrDyRBn.js";import{t as ne}from"./uuid-BzDIGCwP.js";import{t as re}from"./Dropdown-DAiTWOzs.js";import{i as ie,t as ae}from"./app-globals-wu8LLlnA.js";import{F as S}from"./index-Y0yKgBrc.js";var C=e(v(),1),oe=e=>`'${e.replace(/'/g,`'\\''`)}'`,se=`pi-web-ui:scm-sidebar-width`;function ce(e,t=0){if(!Number.isFinite(e))return 300;let n=Math.max(200,Math.min(720,t>0?t-220:720));return Math.min(n,Math.max(200,Math.round(e)))}function le(e){return e===null||e.trim()===``?300:ce(Number(e))}function ue(e,t){let n=t.toLowerCase();return e.subject.toLowerCase().includes(n)||e.author.toLowerCase().includes(n)||e.shortHash.toLowerCase().includes(n)||e.hash.toLowerCase().includes(n)||e.decorations!==void 0&&e.decorations.toLowerCase().includes(n)}function de(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?e:e.filter(e=>n.every(t=>ue(e,t)))}function fe(e){if(e.x===`?`&&e.y===`?`)return`untracked`;let t=e.x!==` `&&e.x!==`?`,n=e.y!==` `&&e.y!==`?`;return t&&n?`both`:t?`staged`:`unstaged`}function pe(e){let t=fe(e);return t===`staged`||t===`both`}function me(e){let t=fe(e);return t===`unstaged`||t===`untracked`||t===`both`}function he(e){let t=[],n=[];for(let r of e)pe(r)&&t.push(r),me(r)&&n.push(r);return{staged:t,unstaged:n}}function ge(e){let t=e.x!==` `&&e.x!==`?`?e.x:e.y;return!t||t===` `||t===`?`?`U`:t}function _e(e,t){let n=0,r=0;for(let i of e){let e=t.get(i.path);e&&(n+=e.add,r+=e.del)}return{count:e.length,add:n,del:r}}var ve=30;function ye(e){let{t,status:n,handlers:r,notRepo:i}=e,a=!!n?.upstream&&!n.upstreamGone,o=!!n?.detached,s=e.commitMsg.trim().length>0,c=[],l=t(`scmGroupSync`);c.push({id:`sync.pull`,group:l,label:t(`scmPull`),hint:`git pull`,badge:n&&n.behind>0?`↓${n.behind}`:void 0,disabled:i||!a||o,run:r.pull},{id:`sync.push`,group:l,label:t(`scmPush`),hint:`git push`,badge:n&&n.ahead>0?`↑${n.ahead}`:void 0,disabled:i||!a||o,run:r.push},{id:`sync.fetch`,group:l,label:t(`scmPaletteFetchAll`),hint:`git fetch --all --prune`,disabled:i,run:r.fetch});let u=t(`scmGroupBranch`);c.push({id:`branch.create`,group:u,label:t(`scmBranchNew`),hint:`git checkout -b <name>`,disabled:i,run:r.branchCreate},{id:`branch.rename`,group:u,label:t(`scmBranchRename`),hint:`git branch -m <name>`,disabled:i||o||!n?.branch,run:r.branchRename});let d=w(e,Math.min(e.branches.length,ve));c.push(...d);let f=t(`scmGroupCommit`);c.push({id:`commit.staged`,group:f,label:t(`scmCommit`),hint:`git commit -m "…"`,badge:e.stagedCount>0?String(e.stagedCount):void 0,disabled:i||!s||e.stagedCount===0,run:r.commit},{id:`commit.all`,group:f,label:t(`scmCommitAll`),hint:`git add -A && git commit`,disabled:i||!s||e.fileCount===0,run:r.commitAll},{id:`commit.amend`,group:f,label:t(`scmAmend`),hint:`git commit --amend`,disabled:i,run:r.amend},{id:`commit.generate`,group:f,label:t(`scmGenMsg`),disabled:i,run:r.genMessage});let p=t(`scmGroupChange`);c.push({id:`change.stage-all`,group:p,label:t(`scmStageAll`),hint:`git add -A`,disabled:i||e.fileCount===0,run:r.stageAll},{id:`change.unstage-all`,group:p,label:t(`scmUnstageAll`),hint:`git reset HEAD`,disabled:i||e.stagedCount===0,run:r.unstageAll},{id:`change.stash`,group:p,label:t(`scmStashSave`),hint:`git stash push`,disabled:i,run:()=>r.stashSave(!1)},{id:`change.stash-untracked`,group:p,label:t(`scmStashIncludeUntracked`),hint:`git stash push -u`,disabled:i,run:()=>r.stashSave(!0)},{id:`change.stash-open`,group:p,label:t(`scmStashOpenList`),disabled:i,run:r.stashOpen}),e.selectedPath&&c.push({id:`change.discard-selected`,group:p,label:t(`scmDiscardSelected`),hint:e.selectedPath,tone:`danger`,disabled:i,run:r.discardSelected});let m=t(`scmGroupView`);c.push({id:`view.blame`,group:m,label:e.showBlame?t(`scmBlameHide`):t(`scmBlameShow`),hint:e.selectedPath??void 0,disabled:i||!e.selectedPath,run:r.toggleBlame},{id:`view.terminal`,group:m,label:t(`scmViewTerminal`),disabled:!1,run:r.openTerminal},{id:`view.refresh`,group:m,label:t(`bgTaskRefresh`),hint:t(`scmRefreshTip`),disabled:!1,run:r.refresh});let h=t(`scmGroupRemote`);return c.push({id:`remote.tag-create`,group:h,label:t(`scmTagCreate`),hint:`git tag <name>`,disabled:i,run:r.createTag},{id:`remote.tag-push`,group:h,label:t(`scmTagPush`),hint:`git push --tags`,disabled:i||!(n?.upstream||e.branches.some(e=>e.remote)),run:r.pushTags}),c}function w(e,t){let{t:n,handlers:r}=e,i=n(`scmPaletteCheckout`);return e.branches.slice(0,t).map(t=>({id:`branch.checkout.${t.name}`,group:i,label:t.name,hint:t.remote?n(`scmPaletteRemote`):n(`scmPaletteLocal`),badge:t.current?n(`scmPaletteCurrent`):void 0,disabled:e.notRepo||t.current,run:()=>r.branchCheckout(t.name)}))}var be=`scm-commit-history`;function xe(e=localStorage){try{let t=e.getItem(be);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0):[]}catch{return[]}}function Se(e,t=localStorage){let n=e.trim();if(!n)return xe(t);let r=[n,...xe(t).filter(e=>e!==n)].slice(0,20);try{t.setItem(be,JSON.stringify(r))}catch{}return r}var T={idx:-1,draft:``};function Ce(e,t,n,r){return e.length===0?null:r===`up`?t.idx>=e.length-1?null:t.idx===-1?{state:{idx:0,draft:n},text:e[0]}:{state:{idx:t.idx+1,draft:t.draft},text:e[t.idx+1]}:t.idx===-1?null:t.idx===0?{state:T,text:t.draft}:{state:{idx:t.idx-1,draft:t.draft},text:e[t.idx-1]}}var E=y(),D={A:`green`,U:`green`,D:`red`,R:`accent`,M:`amber`};function we(e){return D[ge(e)]??`amber`}function Te({files:e,stats:t,selectedPath:n,notRepo:r,pending:i,connected:a,onSelect:s,onStage:l,onUnstage:u,onDiscard:d,onStageAll:f,onUnstageAll:p}){let m=ee(),[h,te]=(0,C.useState)(``),v=(0,C.useMemo)(()=>{let t=h.trim().toLowerCase();return t?e.filter(e=>e.path.toLowerCase().includes(t)):[...e]},[e,h]),y=(0,C.useMemo)(()=>he(v),[v]),b=(0,C.useMemo)(()=>_e(y.staged,t),[y.staged,t]),x=(0,C.useMemo)(()=>_e(y.unstaged,t),[y.unstaged,t]),ne=y.unstaged.length>0;return(0,E.jsxs)(`div`,{className:`scm-files`,children:[(0,E.jsxs)(`div`,{className:`scm-files-header`,children:[(0,E.jsx)(`span`,{children:m(`scmChanges`)}),(0,E.jsxs)(`span`,{className:`scm-files-head-actions`,children:[e.length>0&&(0,E.jsx)(`span`,{className:`scm-files-count`,children:e.length}),(0,E.jsx)(`button`,{type:`button`,className:`scm-act`,title:m(`scmStageAllTip`),"aria-label":m(`scmStageAllTip`),disabled:r||!ne,onClick:f,children:(0,E.jsx)(o,{})}),(0,E.jsx)(`button`,{type:`button`,className:`scm-act`,title:m(`scmUnstageAllTip`),"aria-label":m(`scmUnstageAllTip`),disabled:r||y.staged.length===0,onClick:p,children:(0,E.jsx)(c,{})})]})]}),!r&&e.length>0&&(0,E.jsxs)(`div`,{className:`scm-filter`,children:[(0,E.jsx)(_,{"aria-hidden":`true`}),(0,E.jsx)(`input`,{value:h,placeholder:m(`scmFilterFiles`),title:m(`scmFilterFilesTip`),"aria-label":m(`scmFilterFilesTip`),onChange:e=>te(e.target.value),spellCheck:!1}),h&&(0,E.jsx)(`button`,{type:`button`,className:`scm-filter-clear`,"aria-label":m(`close`),onClick:()=>te(``),children:(0,E.jsx)(g,{})})]}),(0,E.jsx)(`div`,{className:`scm-files-list`,children:r?(0,E.jsx)(`div`,{className:`scm-empty`,children:m(`scmNotGitRepo`)}):i?(0,E.jsx)(`div`,{className:`scm-empty`,children:m(a?`scmLoading`:`scmConnecting`)}):e.length===0?(0,E.jsx)(`div`,{className:`scm-empty`,children:m(`scmNoChanges`)}):v.length===0?(0,E.jsx)(`div`,{className:`scm-empty`,children:m(`scmFilterEmpty`)}):(0,E.jsxs)(E.Fragment,{children:[y.staged.length>0&&(0,E.jsxs)(`div`,{className:`scm-group`,"data-group":`staged`,children:[(0,E.jsxs)(`div`,{className:`scm-group-head`,children:[(0,E.jsx)(`span`,{className:`scm-group-title`,children:m(`scmStaged`)}),(0,E.jsx)(`span`,{className:`scm-group-count`,children:y.staged.length}),b.add>0&&(0,E.jsxs)(`span`,{className:`scm-group-stat add`,children:[`+`,b.add]}),b.del>0&&(0,E.jsxs)(`span`,{className:`scm-group-stat del`,children:[`-`,b.del]})]}),y.staged.map(e=>(0,E.jsx)(Ee,{f:e,stagedRow:!0,stat:t.get(e.path),selected:n===e.path,onSelect:s,onStage:l,onUnstage:u,onDiscard:d},`staged:${e.path}`))]}),y.unstaged.length>0&&(0,E.jsxs)(`div`,{className:`scm-group`,"data-group":`changes`,children:[(0,E.jsxs)(`div`,{className:`scm-group-head`,children:[(0,E.jsx)(`span`,{className:`scm-group-title`,children:m(`scmChanges`)}),(0,E.jsx)(`span`,{className:`scm-group-count`,children:y.unstaged.length}),x.add>0&&(0,E.jsxs)(`span`,{className:`scm-group-stat add`,children:[`+`,x.add]}),x.del>0&&(0,E.jsxs)(`span`,{className:`scm-group-stat del`,children:[`-`,x.del]})]}),y.unstaged.map(e=>(0,E.jsx)(Ee,{f:e,stagedRow:!1,stat:t.get(e.path),selected:n===e.path,onSelect:s,onStage:l,onUnstage:u,onDiscard:d},`changes:${e.path}`))]})]})})]})}function Ee({f:e,stagedRow:t,stat:r,selected:i,onSelect:a,onStage:s,onUnstage:l,onDiscard:d}){let f=ee(),p=fe(e),m=p===`both`,h=f(t?m?`scmStagedUnstaged`:`scmStaged`:p===`untracked`?`scmUntracked`:m?`scmStagedUnstaged`:`scmUnstaged`),g=f(t?`scmUnstageTip`:`scmStageTip`,{path:e.path});return(0,E.jsxs)(`div`,{className:`scm-file${i?` active`:``}${t?` staged`:``}`,title:`${h} · ${e.path}`,onClick:()=>a(e),children:[(0,E.jsxs)(`label`,{className:`scm-file-tick`,title:g,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,E.jsx)(`input`,{type:`checkbox`,checked:t,"aria-label":g,onChange:()=>t?l(e):s(e)}),(0,E.jsx)(`span`,{className:`scm-file-box`,"aria-hidden":`true`,children:(0,E.jsx)(u,{})})]}),(0,E.jsx)(`span`,{className:`scm-file-letter ${we(e)}`,children:ge(e)}),(0,E.jsx)(`span`,{className:`scm-file-path`,children:e.path}),r&&(r.add>0||r.del>0)&&(0,E.jsxs)(`span`,{className:`scm-file-stat`,children:[r.add>0&&(0,E.jsxs)(`span`,{className:`add`,children:[`+`,r.add]}),r.del>0&&(0,E.jsxs)(`span`,{className:`del`,children:[`-`,r.del]})]}),(0,E.jsxs)(`span`,{className:`scm-file-actions`,children:[t?(0,E.jsx)(`button`,{type:`button`,className:`scm-act`,title:f(`scmUnstageTip`,{path:e.path}),"aria-label":f(`scmUnstageTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),l(e)},children:(0,E.jsx)(c,{})}):(0,E.jsx)(`button`,{type:`button`,className:`scm-act`,title:f(`scmStageTip`,{path:e.path}),"aria-label":f(`scmStageTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),s(e)},children:(0,E.jsx)(o,{})}),!t&&(0,E.jsx)(`button`,{type:`button`,className:`scm-act`,title:f(p===`untracked`?`scmDiscardUntrackedTip`:`scmDiscardTip`,{path:e.path}),"aria-label":f(p===`untracked`?`scmDiscardUntrackedTip`:`scmDiscardTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),d(e)},children:(0,E.jsx)(n,{})})]})]})}function De(e,t){return!t||`${e.label} ${e.hint??``} ${e.group} ${e.id}`.toLowerCase().includes(t)}function Oe({open:e,onClose:t,labels:n,actions:r}){let i=b(e),[a,o]=(0,C.useState)(``),[s,c]=(0,C.useState)(0),l=(0,C.useRef)(null),u=(0,C.useRef)(null),d=(0,C.useRef)(``);x(t,e),(0,C.useEffect)(()=>{if(!e)return;o(``),c(0),d.current=``;let t=window.setTimeout(()=>l.current?.focus(),0);return()=>window.clearTimeout(t)},[e]);let f=a.trim().toLowerCase(),p=(0,C.useMemo)(()=>r.filter(e=>De(e,f)),[r,f]);(0,C.useEffect)(()=>{if(!e)return;let t=d.current!==f;d.current=f,c(e=>{if(!t){let t=p[e];if(t&&!t.disabled)return e}let n=p.findIndex(e=>!e.disabled);return n<0?0:n})},[e,f,p]);let m=(0,C.useMemo)(()=>{let e=[],t=new Map;return p.forEach((n,r)=>{t.has(n.group)||(t.set(n.group,[]),e.push(n.group)),t.get(n.group)?.push({action:n,index:r})}),e.map(e=>({group:e,items:t.get(e)??[]}))},[p]);if((0,C.useEffect)(()=>{e&&(u.current?.querySelector(`[data-idx="${s}"]`))?.scrollIntoView({block:`nearest`})},[s,e]),!e)return null;let h=e=>{e&&!e.disabled&&(t(),e.run())},g=e=>{p.length!==0&&c(t=>{let n=t;for(let t=0;t<p.length;t++)if(n+=e,n<0&&(n=p.length-1),n>=p.length&&(n=0),!p[n].disabled)return n;return t})};return(0,E.jsx)(`div`,{className:`scm-pal-backdrop`,role:`dialog`,"aria-modal":`true`,"aria-label":n.title,style:{zIndex:i},onMouseDown:e=>{e.target===e.currentTarget&&t()},onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),g(1)):e.key===`ArrowUp`?(e.preventDefault(),g(-1)):e.key===`Enter`&&(e.preventDefault(),h(p[s]))},children:(0,E.jsxs)(`div`,{className:`scm-pal`,children:[(0,E.jsxs)(`div`,{className:`scm-pal-head`,children:[(0,E.jsx)(_,{"aria-hidden":`true`}),(0,E.jsx)(`input`,{ref:l,value:a,placeholder:n.placeholder,"aria-label":n.placeholder,onChange:e=>o(e.target.value),autoComplete:`off`,spellCheck:!1}),(0,E.jsx)(`span`,{className:`scm-pal-kbd`,children:`Esc`})]}),(0,E.jsx)(`div`,{className:`scm-pal-list`,ref:u,role:`listbox`,"aria-label":n.title,children:p.length===0?(0,E.jsx)(`div`,{className:`scm-pal-empty`,children:n.empty}):m.map(e=>(0,E.jsxs)(`div`,{className:`scm-pal-group`,children:[(0,E.jsx)(`div`,{className:`scm-pal-group-title`,children:e.group}),e.items.map(({action:e,index:t})=>(0,E.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===s,"data-idx":t,disabled:e.disabled,className:`scm-pal-row${t===s?` on`:``}${e.tone===`danger`?` danger`:``}`,onMouseMove:()=>c(t),onClick:()=>h(e),title:e.hint??e.label,children:[(0,E.jsxs)(`span`,{className:`scm-pal-row-main`,children:[(0,E.jsx)(`span`,{className:`scm-pal-row-label`,children:e.label}),e.hint&&(0,E.jsx)(`span`,{className:`scm-pal-row-hint`,children:e.hint})]}),e.badge&&(0,E.jsx)(`span`,{className:`scm-pal-badge`,children:e.badge})]},e.id))]},e.group))}),(0,E.jsxs)(`div`,{className:`scm-pal-foot`,children:[(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`span`,{className:`scm-pal-kbd`,children:`↑`}),(0,E.jsx)(`span`,{className:`scm-pal-kbd`,children:`↓`}),n.move]}),(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`span`,{className:`scm-pal-kbd`,children:`⏎`}),n.run]}),(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`span`,{className:`scm-pal-kbd`,children:`Esc`}),n.close]}),(0,E.jsx)(`span`,{className:`scm-pal-count`,children:n.count(p.length)})]})]})})}var ke=8e3;function Ae(e){e.current&&clearTimeout(e.current),e.current=null}function je(e){return e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`new file`)||e.startsWith(`deleted file`)||e.startsWith(`old mode`)||e.startsWith(`new mode`)||e.startsWith(`similarity index`)||e.startsWith(`rename `)||e.startsWith(`copy `)||e.startsWith(`Binary files`)||e.startsWith(`---`)||e.startsWith(`+++`)}function Me(e){let t=0,n=0,r=0;for(let i of e.split(`
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,$t as n,C as r,Ft as i,L as a,Pt as o,Tn as s,Tt as c,Zt as l,b as u,cn as d,d as f,gn as p,j as m,s as h,sn as g,vn as ee,w as te,zt as _}from"./fi-CcqqfamG.js";import{i as v,t as y}from"./react-CR5VJ85Q.js";import{t as b}from"./overlay-stack-BHdOmj3G.js";import{t as x}from"./shortcut-stack-hhrDyRBn.js";import{t as ne}from"./uuid-BzDIGCwP.js";import{t as re}from"./Dropdown-C8yx9mqF.js";import{i as ie,t as ae}from"./app-globals-wu8LLlnA.js";import{F as S}from"./index-Dbv9RJwm.js";var C=e(v(),1),oe=e=>`'${e.replace(/'/g,`'\\''`)}'`,se=`pi-web-ui:scm-sidebar-width`;function ce(e,t=0){if(!Number.isFinite(e))return 300;let n=Math.max(200,Math.min(720,t>0?t-220:720));return Math.min(n,Math.max(200,Math.round(e)))}function le(e){return e===null||e.trim()===``?300:ce(Number(e))}function ue(e,t){let n=t.toLowerCase();return e.subject.toLowerCase().includes(n)||e.author.toLowerCase().includes(n)||e.shortHash.toLowerCase().includes(n)||e.hash.toLowerCase().includes(n)||e.decorations!==void 0&&e.decorations.toLowerCase().includes(n)}function de(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?e:e.filter(e=>n.every(t=>ue(e,t)))}function fe(e){if(e.x===`?`&&e.y===`?`)return`untracked`;let t=e.x!==` `&&e.x!==`?`,n=e.y!==` `&&e.y!==`?`;return t&&n?`both`:t?`staged`:`unstaged`}function pe(e){let t=fe(e);return t===`staged`||t===`both`}function me(e){let t=fe(e);return t===`unstaged`||t===`untracked`||t===`both`}function he(e){let t=[],n=[];for(let r of e)pe(r)&&t.push(r),me(r)&&n.push(r);return{staged:t,unstaged:n}}function ge(e){let t=e.x!==` `&&e.x!==`?`?e.x:e.y;return!t||t===` `||t===`?`?`U`:t}function _e(e,t){let n=0,r=0;for(let i of e){let e=t.get(i.path);e&&(n+=e.add,r+=e.del)}return{count:e.length,add:n,del:r}}var ve=30;function ye(e){let{t,status:n,handlers:r,notRepo:i}=e,a=!!n?.upstream&&!n.upstreamGone,o=!!n?.detached,s=e.commitMsg.trim().length>0,c=[],l=t(`scmGroupSync`);c.push({id:`sync.pull`,group:l,label:t(`scmPull`),hint:`git pull`,badge:n&&n.behind>0?`↓${n.behind}`:void 0,disabled:i||!a||o,run:r.pull},{id:`sync.push`,group:l,label:t(`scmPush`),hint:`git push`,badge:n&&n.ahead>0?`↑${n.ahead}`:void 0,disabled:i||!a||o,run:r.push},{id:`sync.fetch`,group:l,label:t(`scmPaletteFetchAll`),hint:`git fetch --all --prune`,disabled:i,run:r.fetch});let u=t(`scmGroupBranch`);c.push({id:`branch.create`,group:u,label:t(`scmBranchNew`),hint:`git checkout -b <name>`,disabled:i,run:r.branchCreate},{id:`branch.rename`,group:u,label:t(`scmBranchRename`),hint:`git branch -m <name>`,disabled:i||o||!n?.branch,run:r.branchRename});let d=w(e,Math.min(e.branches.length,ve));c.push(...d);let f=t(`scmGroupCommit`);c.push({id:`commit.staged`,group:f,label:t(`scmCommit`),hint:`git commit -m "…"`,badge:e.stagedCount>0?String(e.stagedCount):void 0,disabled:i||!s||e.stagedCount===0,run:r.commit},{id:`commit.all`,group:f,label:t(`scmCommitAll`),hint:`git add -A && git commit`,disabled:i||!s||e.fileCount===0,run:r.commitAll},{id:`commit.amend`,group:f,label:t(`scmAmend`),hint:`git commit --amend`,disabled:i,run:r.amend},{id:`commit.generate`,group:f,label:t(`scmGenMsg`),disabled:i,run:r.genMessage});let p=t(`scmGroupChange`);c.push({id:`change.stage-all`,group:p,label:t(`scmStageAll`),hint:`git add -A`,disabled:i||e.fileCount===0,run:r.stageAll},{id:`change.unstage-all`,group:p,label:t(`scmUnstageAll`),hint:`git reset HEAD`,disabled:i||e.stagedCount===0,run:r.unstageAll},{id:`change.stash`,group:p,label:t(`scmStashSave`),hint:`git stash push`,disabled:i,run:()=>r.stashSave(!1)},{id:`change.stash-untracked`,group:p,label:t(`scmStashIncludeUntracked`),hint:`git stash push -u`,disabled:i,run:()=>r.stashSave(!0)},{id:`change.stash-open`,group:p,label:t(`scmStashOpenList`),disabled:i,run:r.stashOpen}),e.selectedPath&&c.push({id:`change.discard-selected`,group:p,label:t(`scmDiscardSelected`),hint:e.selectedPath,tone:`danger`,disabled:i,run:r.discardSelected});let m=t(`scmGroupView`);c.push({id:`view.blame`,group:m,label:e.showBlame?t(`scmBlameHide`):t(`scmBlameShow`),hint:e.selectedPath??void 0,disabled:i||!e.selectedPath,run:r.toggleBlame},{id:`view.terminal`,group:m,label:t(`scmViewTerminal`),disabled:!1,run:r.openTerminal},{id:`view.refresh`,group:m,label:t(`bgTaskRefresh`),hint:t(`scmRefreshTip`),disabled:!1,run:r.refresh});let h=t(`scmGroupRemote`);return c.push({id:`remote.tag-create`,group:h,label:t(`scmTagCreate`),hint:`git tag <name>`,disabled:i,run:r.createTag},{id:`remote.tag-push`,group:h,label:t(`scmTagPush`),hint:`git push --tags`,disabled:i||!(n?.upstream||e.branches.some(e=>e.remote)),run:r.pushTags}),c}function w(e,t){let{t:n,handlers:r}=e,i=n(`scmPaletteCheckout`);return e.branches.slice(0,t).map(t=>({id:`branch.checkout.${t.name}`,group:i,label:t.name,hint:t.remote?n(`scmPaletteRemote`):n(`scmPaletteLocal`),badge:t.current?n(`scmPaletteCurrent`):void 0,disabled:e.notRepo||t.current,run:()=>r.branchCheckout(t.name)}))}var be=`scm-commit-history`;function xe(e=localStorage){try{let t=e.getItem(be);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0):[]}catch{return[]}}function Se(e,t=localStorage){let n=e.trim();if(!n)return xe(t);let r=[n,...xe(t).filter(e=>e!==n)].slice(0,20);try{t.setItem(be,JSON.stringify(r))}catch{}return r}var T={idx:-1,draft:``};function Ce(e,t,n,r){return e.length===0?null:r===`up`?t.idx>=e.length-1?null:t.idx===-1?{state:{idx:0,draft:n},text:e[0]}:{state:{idx:t.idx+1,draft:t.draft},text:e[t.idx+1]}:t.idx===-1?null:t.idx===0?{state:T,text:t.draft}:{state:{idx:t.idx-1,draft:t.draft},text:e[t.idx-1]}}var E=y(),D={A:`green`,U:`green`,D:`red`,R:`accent`,M:`amber`};function we(e){return D[ge(e)]??`amber`}function Te({files:e,stats:t,selectedPath:n,notRepo:r,pending:i,connected:a,onSelect:s,onStage:l,onUnstage:u,onDiscard:d,onStageAll:f,onUnstageAll:p}){let m=ee(),[h,te]=(0,C.useState)(``),v=(0,C.useMemo)(()=>{let t=h.trim().toLowerCase();return t?e.filter(e=>e.path.toLowerCase().includes(t)):[...e]},[e,h]),y=(0,C.useMemo)(()=>he(v),[v]),b=(0,C.useMemo)(()=>_e(y.staged,t),[y.staged,t]),x=(0,C.useMemo)(()=>_e(y.unstaged,t),[y.unstaged,t]),ne=y.unstaged.length>0;return(0,E.jsxs)(`div`,{className:`scm-files`,children:[(0,E.jsxs)(`div`,{className:`scm-files-header`,children:[(0,E.jsx)(`span`,{children:m(`scmChanges`)}),(0,E.jsxs)(`span`,{className:`scm-files-head-actions`,children:[e.length>0&&(0,E.jsx)(`span`,{className:`scm-files-count`,children:e.length}),(0,E.jsx)(`button`,{type:`button`,className:`scm-act`,title:m(`scmStageAllTip`),"aria-label":m(`scmStageAllTip`),disabled:r||!ne,onClick:f,children:(0,E.jsx)(o,{})}),(0,E.jsx)(`button`,{type:`button`,className:`scm-act`,title:m(`scmUnstageAllTip`),"aria-label":m(`scmUnstageAllTip`),disabled:r||y.staged.length===0,onClick:p,children:(0,E.jsx)(c,{})})]})]}),!r&&e.length>0&&(0,E.jsxs)(`div`,{className:`scm-filter`,children:[(0,E.jsx)(_,{"aria-hidden":`true`}),(0,E.jsx)(`input`,{value:h,placeholder:m(`scmFilterFiles`),title:m(`scmFilterFilesTip`),"aria-label":m(`scmFilterFilesTip`),onChange:e=>te(e.target.value),spellCheck:!1}),h&&(0,E.jsx)(`button`,{type:`button`,className:`scm-filter-clear`,"aria-label":m(`close`),onClick:()=>te(``),children:(0,E.jsx)(g,{})})]}),(0,E.jsx)(`div`,{className:`scm-files-list`,children:r?(0,E.jsx)(`div`,{className:`scm-empty`,children:m(`scmNotGitRepo`)}):i?(0,E.jsx)(`div`,{className:`scm-empty`,children:m(a?`scmLoading`:`scmConnecting`)}):e.length===0?(0,E.jsx)(`div`,{className:`scm-empty`,children:m(`scmNoChanges`)}):v.length===0?(0,E.jsx)(`div`,{className:`scm-empty`,children:m(`scmFilterEmpty`)}):(0,E.jsxs)(E.Fragment,{children:[y.staged.length>0&&(0,E.jsxs)(`div`,{className:`scm-group`,"data-group":`staged`,children:[(0,E.jsxs)(`div`,{className:`scm-group-head`,children:[(0,E.jsx)(`span`,{className:`scm-group-title`,children:m(`scmStaged`)}),(0,E.jsx)(`span`,{className:`scm-group-count`,children:y.staged.length}),b.add>0&&(0,E.jsxs)(`span`,{className:`scm-group-stat add`,children:[`+`,b.add]}),b.del>0&&(0,E.jsxs)(`span`,{className:`scm-group-stat del`,children:[`-`,b.del]})]}),y.staged.map(e=>(0,E.jsx)(Ee,{f:e,stagedRow:!0,stat:t.get(e.path),selected:n===e.path,onSelect:s,onStage:l,onUnstage:u,onDiscard:d},`staged:${e.path}`))]}),y.unstaged.length>0&&(0,E.jsxs)(`div`,{className:`scm-group`,"data-group":`changes`,children:[(0,E.jsxs)(`div`,{className:`scm-group-head`,children:[(0,E.jsx)(`span`,{className:`scm-group-title`,children:m(`scmChanges`)}),(0,E.jsx)(`span`,{className:`scm-group-count`,children:y.unstaged.length}),x.add>0&&(0,E.jsxs)(`span`,{className:`scm-group-stat add`,children:[`+`,x.add]}),x.del>0&&(0,E.jsxs)(`span`,{className:`scm-group-stat del`,children:[`-`,x.del]})]}),y.unstaged.map(e=>(0,E.jsx)(Ee,{f:e,stagedRow:!1,stat:t.get(e.path),selected:n===e.path,onSelect:s,onStage:l,onUnstage:u,onDiscard:d},`changes:${e.path}`))]})]})})]})}function Ee({f:e,stagedRow:t,stat:r,selected:i,onSelect:a,onStage:s,onUnstage:l,onDiscard:d}){let f=ee(),p=fe(e),m=p===`both`,h=f(t?m?`scmStagedUnstaged`:`scmStaged`:p===`untracked`?`scmUntracked`:m?`scmStagedUnstaged`:`scmUnstaged`),g=f(t?`scmUnstageTip`:`scmStageTip`,{path:e.path});return(0,E.jsxs)(`div`,{className:`scm-file${i?` active`:``}${t?` staged`:``}`,title:`${h} · ${e.path}`,onClick:()=>a(e),children:[(0,E.jsxs)(`label`,{className:`scm-file-tick`,title:g,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,E.jsx)(`input`,{type:`checkbox`,checked:t,"aria-label":g,onChange:()=>t?l(e):s(e)}),(0,E.jsx)(`span`,{className:`scm-file-box`,"aria-hidden":`true`,children:(0,E.jsx)(u,{})})]}),(0,E.jsx)(`span`,{className:`scm-file-letter ${we(e)}`,children:ge(e)}),(0,E.jsx)(`span`,{className:`scm-file-path`,children:e.path}),r&&(r.add>0||r.del>0)&&(0,E.jsxs)(`span`,{className:`scm-file-stat`,children:[r.add>0&&(0,E.jsxs)(`span`,{className:`add`,children:[`+`,r.add]}),r.del>0&&(0,E.jsxs)(`span`,{className:`del`,children:[`-`,r.del]})]}),(0,E.jsxs)(`span`,{className:`scm-file-actions`,children:[t?(0,E.jsx)(`button`,{type:`button`,className:`scm-act`,title:f(`scmUnstageTip`,{path:e.path}),"aria-label":f(`scmUnstageTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),l(e)},children:(0,E.jsx)(c,{})}):(0,E.jsx)(`button`,{type:`button`,className:`scm-act`,title:f(`scmStageTip`,{path:e.path}),"aria-label":f(`scmStageTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),s(e)},children:(0,E.jsx)(o,{})}),!t&&(0,E.jsx)(`button`,{type:`button`,className:`scm-act`,title:f(p===`untracked`?`scmDiscardUntrackedTip`:`scmDiscardTip`,{path:e.path}),"aria-label":f(p===`untracked`?`scmDiscardUntrackedTip`:`scmDiscardTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),d(e)},children:(0,E.jsx)(n,{})})]})]})}function De(e,t){return!t||`${e.label} ${e.hint??``} ${e.group} ${e.id}`.toLowerCase().includes(t)}function Oe({open:e,onClose:t,labels:n,actions:r}){let i=b(e),[a,o]=(0,C.useState)(``),[s,c]=(0,C.useState)(0),l=(0,C.useRef)(null),u=(0,C.useRef)(null),d=(0,C.useRef)(``);x(t,e),(0,C.useEffect)(()=>{if(!e)return;o(``),c(0),d.current=``;let t=window.setTimeout(()=>l.current?.focus(),0);return()=>window.clearTimeout(t)},[e]);let f=a.trim().toLowerCase(),p=(0,C.useMemo)(()=>r.filter(e=>De(e,f)),[r,f]);(0,C.useEffect)(()=>{if(!e)return;let t=d.current!==f;d.current=f,c(e=>{if(!t){let t=p[e];if(t&&!t.disabled)return e}let n=p.findIndex(e=>!e.disabled);return n<0?0:n})},[e,f,p]);let m=(0,C.useMemo)(()=>{let e=[],t=new Map;return p.forEach((n,r)=>{t.has(n.group)||(t.set(n.group,[]),e.push(n.group)),t.get(n.group)?.push({action:n,index:r})}),e.map(e=>({group:e,items:t.get(e)??[]}))},[p]);if((0,C.useEffect)(()=>{e&&(u.current?.querySelector(`[data-idx="${s}"]`))?.scrollIntoView({block:`nearest`})},[s,e]),!e)return null;let h=e=>{e&&!e.disabled&&(t(),e.run())},g=e=>{p.length!==0&&c(t=>{let n=t;for(let t=0;t<p.length;t++)if(n+=e,n<0&&(n=p.length-1),n>=p.length&&(n=0),!p[n].disabled)return n;return t})};return(0,E.jsx)(`div`,{className:`scm-pal-backdrop`,role:`dialog`,"aria-modal":`true`,"aria-label":n.title,style:{zIndex:i},onMouseDown:e=>{e.target===e.currentTarget&&t()},onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),g(1)):e.key===`ArrowUp`?(e.preventDefault(),g(-1)):e.key===`Enter`&&(e.preventDefault(),h(p[s]))},children:(0,E.jsxs)(`div`,{className:`scm-pal`,children:[(0,E.jsxs)(`div`,{className:`scm-pal-head`,children:[(0,E.jsx)(_,{"aria-hidden":`true`}),(0,E.jsx)(`input`,{ref:l,value:a,placeholder:n.placeholder,"aria-label":n.placeholder,onChange:e=>o(e.target.value),autoComplete:`off`,spellCheck:!1}),(0,E.jsx)(`span`,{className:`scm-pal-kbd`,children:`Esc`})]}),(0,E.jsx)(`div`,{className:`scm-pal-list`,ref:u,role:`listbox`,"aria-label":n.title,children:p.length===0?(0,E.jsx)(`div`,{className:`scm-pal-empty`,children:n.empty}):m.map(e=>(0,E.jsxs)(`div`,{className:`scm-pal-group`,children:[(0,E.jsx)(`div`,{className:`scm-pal-group-title`,children:e.group}),e.items.map(({action:e,index:t})=>(0,E.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===s,"data-idx":t,disabled:e.disabled,className:`scm-pal-row${t===s?` on`:``}${e.tone===`danger`?` danger`:``}`,onMouseMove:()=>c(t),onClick:()=>h(e),title:e.hint??e.label,children:[(0,E.jsxs)(`span`,{className:`scm-pal-row-main`,children:[(0,E.jsx)(`span`,{className:`scm-pal-row-label`,children:e.label}),e.hint&&(0,E.jsx)(`span`,{className:`scm-pal-row-hint`,children:e.hint})]}),e.badge&&(0,E.jsx)(`span`,{className:`scm-pal-badge`,children:e.badge})]},e.id))]},e.group))}),(0,E.jsxs)(`div`,{className:`scm-pal-foot`,children:[(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`span`,{className:`scm-pal-kbd`,children:`↑`}),(0,E.jsx)(`span`,{className:`scm-pal-kbd`,children:`↓`}),n.move]}),(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`span`,{className:`scm-pal-kbd`,children:`⏎`}),n.run]}),(0,E.jsxs)(`span`,{children:[(0,E.jsx)(`span`,{className:`scm-pal-kbd`,children:`Esc`}),n.close]}),(0,E.jsx)(`span`,{className:`scm-pal-count`,children:n.count(p.length)})]})]})})}var ke=8e3;function Ae(e){e.current&&clearTimeout(e.current),e.current=null}function je(e){return e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`new file`)||e.startsWith(`deleted file`)||e.startsWith(`old mode`)||e.startsWith(`new mode`)||e.startsWith(`similarity index`)||e.startsWith(`rename `)||e.startsWith(`copy `)||e.startsWith(`Binary files`)||e.startsWith(`---`)||e.startsWith(`+++`)}function Me(e){let t=0,n=0,r=0;for(let i of e.split(`
|
|
2
2
|
`))if(i.startsWith(`@@`))r+=1;else if(i.startsWith(`+++`)||i.startsWith(`---`))continue;else i.startsWith(`+`)?t+=1:i.startsWith(`-`)&&(n+=1);return{add:t,del:n,hunks:r}}function Ne(e){let t=0,n=0,r=0;for(let i of e){if(!i)continue;let e=Me(i);t+=e.add,n+=e.del,r+=e.hunks}return{add:t,del:n,hunks:r}}function Pe(e){return e.replace(/\x1b\][^\x07\x1b]*(\x07|\x1b\\)/g,``).replace(/\x1b\[[0-9;?]*[a-zA-Z]/g,``).replace(/\x1b\(B/g,``).replace(/\x1b[=>NO78c]/g,``).replace(/\x1b/g,``).replace(/\r/g,``)}function Fe(e){let t=[];for(let n of Pe(e).split(`
|
|
3
3
|
`)){let e=n.trim();if(!e)continue;let r=/^(stash@\{\d+\}):\s*(.*)$/.exec(e);r&&t.push({ref:r[1],message:r[2]})}return t}function Ie(e){if(!Number.isFinite(e)||e<=0)return``;try{return new Date(e*1e3).toISOString().slice(0,10)}catch{return``}}function Le(e){let t=Pe(e).split(`
|
|
4
4
|
`),n=[],r=``,i=``,a=0,o=0,s=0,c=!1,l=e=>{if(!c||s<=0)return;let t=o+u.value;n.push({hash:r,shortHash:/^[0]+$/.test(r)?`0000000`:r.slice(0,7),author:i||`?`,date:Ie(a),lineNo:t,content:e}),u.value+=1},u={value:0};for(let e of t){let t=e.endsWith(`\r`)?e.slice(0,-1):e,n=/^([0-9a-f]{40}|0{40}) \d+ (\d+) (\d+)$/.exec(t);if(n){r=n[1],i=``,a=0,o=Number(n[2]),s=Number(n[3]),u.value=0,c=!0;continue}if(c){if(t.startsWith(`author `)&&!t.startsWith(`author-mail`)&&!t.startsWith(`author-time`)){i=t.slice(7);continue}if(t.startsWith(`author-time `)){a=Number(t.slice(12).trim());continue}if(t.startsWith(` `)){l(t.slice(1)),u.value>=s&&(c=!1);continue}t.startsWith(`filename `)||t.startsWith(`boundary`)}}return n.slice(0,3e3)}function Re(e){return!e||e.length>200||/\s/.test(e)||e.includes(`..`)||/[~^:?*\\[\]]/.test(e)||e.startsWith(`/`)||e.endsWith(`/`)||e.includes(`//`)||e.endsWith(`.lock`)||e.endsWith(`.`)||e.startsWith(`-`)||e.includes(`@{`)?!1:/^[A-Za-z0-9._/-]+$/.test(e)}function ze(e){let t=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(e);return t?{oldStart:Number(t[1]),newStart:Number(t[2])}:null}function Be(e){let t=[],n=0,r=0,i=!1,a=[],o=[],s=()=>{let e=Math.max(a.length,o.length);for(let n=0;n<e;n++){let e=a[n],r=o[n];t.push({kind:`pair`,left:e?{no:e.no,text:e.text,kind:`del`}:{no:null,text:``,kind:`empty`},right:r?{no:r.no,text:r.text,kind:`add`}:{no:null,text:``,kind:`empty`}})}a=[],o=[]};for(let c of e.split(`
|