@aiworker/web 1.23.2 → 1.23.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/assets/{CodeMirrorCommentWidgets-COGJG0Iv.js → CodeMirrorCommentWidgets-pFeKzADY.js} +1 -1
  2. package/dist/assets/{DiffView-BviYY3zL.js → DiffView-BYwAHIlW.js} +3 -3
  3. package/dist/assets/{DirtyBranchSwitchDialog-C26DvfVJ.js → DirtyBranchSwitchDialog-BeyJczAi.js} +1 -1
  4. package/dist/assets/{FilesView-D0ZU_nCt.js → FilesView-lrP5OlzK.js} +6 -6
  5. package/dist/assets/{GitView-CYgiDRH-.js → GitView-CCUK73JL.js} +4 -4
  6. package/dist/assets/{JsonTreeView-GsV9UScz.js → JsonTreeView-CqUi8Ytj.js} +1 -1
  7. package/dist/assets/{LinearIssuesView-shqUS8nl.js → LinearIssuesView-C0WwIDQN.js} +1 -1
  8. package/dist/assets/{MarkdownImageGallery-CQSTFp6m.js → MarkdownImageGallery-0NXPad4K.js} +1 -1
  9. package/dist/assets/{MarkdownRendererImpl-DJWP3A8X.js → MarkdownRendererImpl-q-rUxBkU.js} +4 -4
  10. package/dist/assets/{OnboardingScreen-CTuu4lgo.js → OnboardingScreen-Cy6xZ-IQ.js} +1 -1
  11. package/dist/assets/{PatchDiff-Dp53v2pl.js → PatchDiff-DuYWs-7m.js} +1 -1
  12. package/dist/assets/{PierreDiffViewer-B5l0djPS.js → PierreDiffViewer-C51SEtjJ.js} +1 -1
  13. package/dist/assets/{PlanView-CLUWkGiG.js → PlanView-k63mHfFF.js} +1 -1
  14. package/dist/assets/SettingsView-DNJXHPYC.js +28 -0
  15. package/dist/assets/{SettingsWindow-DbgEnZ6T.js → SettingsWindow-DFMJqIkx.js} +1 -1
  16. package/dist/assets/{ToolOutputDialog-Du-RZj-a.js → ToolOutputDialog-B4kBDjLK.js} +4 -4
  17. package/dist/assets/{ToolPartDiffPreview-HBLSokoe.js → ToolPartDiffPreview-DhVBmwis.js} +2 -2
  18. package/dist/assets/{VirtualizedFileDiff-Bzp3hClU.js → VirtualizedFileDiff-C-MFNoKo.js} +1 -1
  19. package/dist/assets/{WalkthroughView-CpgA4s9w.js → WalkthroughView-hmnM70S9.js} +1 -1
  20. package/dist/assets/{computeVirtualFileMetrics-CI1PC_z2.js → computeVirtualFileMetrics-Bv64vrxY.js} +1 -1
  21. package/dist/assets/{de-BX8b4hDD.js → de-i-51iOMQ.js} +2 -2
  22. package/dist/assets/{es-e98cS-yM.js → es-CNkqJISC.js} +3 -3
  23. package/dist/assets/{fr-BOiqxJAs.js → fr-a9t4bHWo.js} +3 -3
  24. package/dist/assets/index-BvwlOZOg.js +40 -0
  25. package/dist/assets/{index-Cmn74sw-.js → index-C-KjDH6t.js} +1 -1
  26. package/dist/assets/index-n5p3SnES.css +1 -0
  27. package/dist/assets/{isDiffPlainText-DVralkU-.js → isDiffPlainText-B0pMS3gs.js} +1 -1
  28. package/dist/assets/{isFilePlainText-CgTREsRX.js → isFilePlainText-IXDeiXmH.js} +1 -1
  29. package/dist/assets/{ja-aoO55hGu.js → ja-C2HQKC-_.js} +3 -3
  30. package/dist/assets/{ko-BGzFLogk.js → ko-CvVt6P_Q.js} +3 -3
  31. package/dist/assets/main-6ZT1mvpO.js +930 -0
  32. package/dist/assets/{main-BgfXQ-4g.js → main-BeWvA5d9.js} +2 -2
  33. package/dist/assets/markdownCore-DTW1POUM.js +5 -0
  34. package/dist/assets/{miniChat-DHKXp-_I.js → miniChat-DzMGD1Hv.js} +2 -2
  35. package/dist/assets/{mobile-lXQ08VnX.js → mobile-CrDSF4dQ.js} +2 -2
  36. package/dist/assets/{patchFileDiff-i1lTtNbn.js → patchFileDiff-DHG-znZQ.js} +3 -3
  37. package/dist/assets/{pl-B5x19laq.js → pl-CQi2SXLP.js} +3 -3
  38. package/dist/assets/{pt-BR-C3oU51Il.js → pt-BR-FdnmJOe8.js} +3 -3
  39. package/dist/assets/{renderElectronMiniChatApp-CuO4ue6B.js → renderElectronMiniChatApp-BuaS0XYk.js} +2 -2
  40. package/dist/assets/renderMobileApp-hxXJf_Db.js +25 -0
  41. package/dist/assets/runtimeEndpointReset-DB4KI-ED.js +41 -0
  42. package/dist/assets/{scheduledTasksApi-BEuUF_cj.js → scheduledTasksApi-DZaxQ19y.js} +1 -1
  43. package/dist/assets/{shikiHighlight-ctlcPvvx.js → shikiHighlight-B1goMnV6.js} +1 -1
  44. package/dist/assets/{tr-C0QQa7et.js → tr-BwD9HLzh.js} +2 -2
  45. package/dist/assets/{uk-CqLSe9wT.js → uk-BWNCwGJO.js} +3 -3
  46. package/dist/assets/{useAppFontEffects-B6OfEypo.js → useAppFontEffects-cYK1WODe.js} +130 -130
  47. package/dist/assets/useGitComparison-DIetwQtj.js +1 -0
  48. package/dist/assets/{useInlineCommentController-CgbrpEWu.js → useInlineCommentController-DscFZWyI.js} +2 -2
  49. package/dist/assets/{useRootScrollLock-Me41OjBT.js → useRootScrollLock-CE3HJBOu.js} +1 -1
  50. package/dist/assets/{vendor-codemirror-language-data-SJuFp0a0.js → vendor-codemirror-language-data-CsvoASYk.js} +2 -2
  51. package/dist/assets/{vendor-remixicon-react-Dil0zKKT.js → vendor-remixicon-react-BDmGmFCA.js} +1 -1
  52. package/dist/assets/{web-components-D8GS8Ork.js → web-components-HM6S8xyb.js} +1 -1
  53. package/dist/assets/{zh-CN-iJEie4d6.js → zh-CN-CH6L_7cX.js} +3 -3
  54. package/dist/assets/{zh-TW-CyslEwlK.js → zh-TW--py9VFnc.js} +3 -3
  55. package/dist/index.html +3 -3
  56. package/dist/mini-chat.html +3 -3
  57. package/dist/mobile.html +3 -3
  58. package/package.json +2 -2
  59. package/server/lib/opencode/DOCUMENTATION.md +14 -0
  60. package/server/lib/opencode/openchamber-routes.js +72 -14
  61. package/server/lib/opencode/openchamber-routes.test.js +71 -3
  62. package/server/lib/opencode/settings-helpers.js +5 -0
  63. package/server/lib/opencode/settings-helpers.test.js +13 -1
  64. package/server/lib/opencode/settings-registry.json +3 -0
  65. package/dist/assets/SettingsView-CojPQVHx.js +0 -28
  66. package/dist/assets/index-BD8ILbxF.js +0 -40
  67. package/dist/assets/index-zhgg-SDz.css +0 -1
  68. package/dist/assets/main-DGYUWmIt.js +0 -930
  69. package/dist/assets/markdownCore-BesaNs_G.js +0 -5
  70. package/dist/assets/renderMobileApp-B3zFlHy4.js +0 -25
  71. package/dist/assets/runtimeEndpointReset-BLzrtrmj.js +0 -41
  72. package/dist/assets/useGitComparison-BXZXEAW6.js +0 -1
@@ -1 +1 @@
1
- import{j as a}from"./vendor-react-BUCujlKS.js";import{I as l,a as I}from"./useInlineCommentController-CgbrpEWu.js";function E(g){const{drafts:x,editingDraftId:d,commentText:o,onTextChange:r,selection:n,isDragging:u,fileLabel:s,newWidgetId:f,mapDraftToRange:p,onSave:m,onCancel:c,onEdit:C,onDelete:h}=g,t=[];for(const e of x){const i=p(e);if(e.id===d){t.push({afterLine:i.end,id:`edit-${e.id}`,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:i,isEditing:!0,onSave:m,onCancel:c},`edit-${e.id}`)});continue}t.push({afterLine:i.end,id:`card-${e.id}`,content:a.jsx(I,{draft:e,onEdit:()=>C(e),onDelete:()=>h(e)},`card-${e.id}`)})}if(n&&!d&&!u){const e={...n,start:Math.min(n.start,n.end),end:Math.max(n.start,n.end)};t.push({afterLine:e.end,id:f,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:e,isEditing:!1,onSave:m,onCancel:c},f)})}return t}export{E as b};
1
+ import{j as a}from"./vendor-react-BUCujlKS.js";import{I as l,a as I}from"./useInlineCommentController-DscFZWyI.js";function E(g){const{drafts:x,editingDraftId:d,commentText:o,onTextChange:r,selection:n,isDragging:u,fileLabel:s,newWidgetId:f,mapDraftToRange:p,onSave:m,onCancel:c,onEdit:C,onDelete:h}=g,t=[];for(const e of x){const i=p(e);if(e.id===d){t.push({afterLine:i.end,id:`edit-${e.id}`,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:i,isEditing:!0,onSave:m,onCancel:c},`edit-${e.id}`)});continue}t.push({afterLine:i.end,id:`card-${e.id}`,content:a.jsx(I,{draft:e,onEdit:()=>C(e),onDelete:()=>h(e)},`card-${e.id}`)})}if(n&&!d&&!u){const e={...n,start:Math.min(n.start,n.end),end:Math.max(n.start,n.end)};t.push({afterLine:e.end,id:f,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:e,isEditing:!1,onSave:m,onCancel:c},f)})}return t}export{E as b};
@@ -1,4 +1,4 @@
1
- import{R as i,f as Ye,j as t}from"./vendor-react-BUCujlKS.js";import{u as le,K as Fe,a as De}from"./index-BD8ILbxF.js";import{c as Fn,b as Dn,u as An,a as Vn,B as En,C as Ln,P as Tt,h as Tn,e as Mn,g as Bn,i as In,f as Pn}from"./patchFileDiff-i1lTtNbn.js";import{c as On,b as zn,i as _n,u as Kn,a as Hn,d as Gn}from"./useGitComparison-BXZXEAW6.js";import{f as Pe,B as he,I as V,h as je,Y as $t,ae as $n,J as ee,af as qn,bd as Wn,H as Un,ag as Jn,ai as Xn,y as Mt,k as Yn,cO as qt,t as Je,ic as Qn,av as Xe,a9 as Zn,aa as es,ab as ts,i2 as Wt,id as ns,aw as Ut,f_ as ss,at as Ue,au as rs,bT as Jt,ap as is,ar as os,as,ao as ls}from"./useAppFontEffects-B6OfEypo.js";import{d as cs,b as us}from"./runtimeEndpointReset-BLzrtrmj.js";import{P as fs}from"./PierreDiffViewer-B5l0djPS.js";import{u as ds,v as ms,g as ps,W as hs}from"./main-DGYUWmIt.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-B6551dwG.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./VirtualizedFileDiff-Bzp3hClU.js";import"./web-components-D8GS8Ork.js";import"./computeVirtualFileMetrics-CI1PC_z2.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isDiffPlainText-DVralkU-.js";import"./vendor-diff-C3JhlQdm.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-BY_5qla_.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-BdA6bdky.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-SJuFp0a0.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-CgbrpEWu.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./useRootScrollLock-Me41OjBT.js";import"./scheduledTasksApi-BEuUF_cj.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";const gs=i.memo(function(e){const s=Ye.c(13),{index:u,staged:h,busyHunk:m,disabled:x,onAction:j}=e,{t:C}=Pe();let c;s[0]!==h?(c=h?["unstage"]:["discard","stage"],s[0]=h,s[1]=c):c=s[1];const w=c;let v;s[2]===Symbol.for("react.memo_cache_sentinel")?(v={top:"var(--oc-hunk-action-offset, 0.25rem)"},s[2]=v):v=s[2];let d;s[3]!==w||s[4]!==m||s[5]!==x||s[6]!==u||s[7]!==j||s[8]!==C?(d=t.jsx("div",{className:"pointer-events-auto flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:w.map(b=>{const _=C(b==="stage"?"diffView.hunk.stageTitle":b==="unstage"?"diffView.hunk.unstageTitle":"diffView.hunk.discardTitle",{index:u+1}),P=m?.index===u&&m.action===b;return t.jsx(he,{variant:"ghost",size:"xs",className:je("rounded-full bg-transparent text-muted-foreground hover:bg-transparent hover:text-foreground",b==="discard"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",b==="stage"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:x||m!==null,title:_,"aria-label":_,onPointerDown:xs,onClick:f=>{f.stopPropagation(),j(u,b)},children:t.jsx(V,{name:P?"loader-4":b==="stage"?"add":"arrow-go-back",className:je(b==="stage"?"size-4":"size-3.5",P&&"animate-spin")})},b)})}),s[3]=w,s[4]=m,s[5]=x,s[6]=u,s[7]=j,s[8]=C,s[9]=d):d=s[9];let E;return s[10]!==u||s[11]!==d?(E=t.jsx("div",{className:"pointer-events-none absolute right-3 z-20",style:v,"data-hunk-actions":u,children:d}),s[10]=u,s[11]=d,s[12]=E):E=s[12],E});function xs(o){return o.stopPropagation()}const Bt=(o,e)=>{if(e.length===0)return null;let s=null,u=null;for(const m of e)m.top<=o?(!s||m.top>s.top)&&(s=m):(!u||m.top<u.top)&&(u=m);const h=s??u;return h?{path:h.path,topOffset:h.top-o}:null},ys=(o,e,s,u)=>Math.min(Math.max(0,u),Math.max(0,o+s-e)),It=o=>{if(!o)return null;const e=o.split(`
2
- `);let s=null;for(const u of e){const h=u.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(h){const m=Number.parseInt(h[1]??"",10);s=Number.isFinite(m)&&m>=1?m:null;continue}if(s!==null){if(u.startsWith(" ")){s+=1;continue}if(u.startsWith("+"))return s;if(u.startsWith("-"))return Math.max(1,s)}}return null},ws=1100,bs=15e3,Pt=500,Ot=300,Xt=1e6,xt=3,js=o=>o<=6?o:o<=12?6:o<=25?4:2,zt={status:"loading"},vs=3,Ss=i.memo(()=>{const o=Ye.c(4),{t:e}=Pe();let s;o[0]!==e?(s=e("diffView.binary.unavailable"),o[0]=e,o[1]=s):s=o[1];let u;return o[2]!==s?(u=t.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:t.jsx("div",{className:"typography-meta text-muted-foreground",children:s})}),o[2]=s,o[3]=u):u=o[3],u}),Yt={"?":{code:"?",color:"var(--status-info)",descriptionKey:"diffView.change.untracked"},A:{code:"A",color:"var(--status-success)",descriptionKey:"diffView.change.new"},D:{code:"D",color:"var(--status-error)",descriptionKey:"diffView.change.deleted"},R:{code:"R",color:"var(--status-info)",descriptionKey:"diffView.change.renamed"},C:{code:"C",color:"var(--status-info)",descriptionKey:"diffView.change.copied"},M:{code:"M",color:"var(--status-warning)",descriptionKey:"diffView.change.modified"}},Ns=Yt.M,ks=o=>{const e=o.index?.trim(),s=o.working_dir?.trim();return e&&e!=="?"?e.charAt(0):s?s.charAt(0):e?.charAt(0)||s?.charAt(0)||"M"},Qt=o=>{const e=ks(o);return Yt[e]??Ns},Cs=o=>{const{index:e,working_dir:s}=o;return e==="A"||s==="A"||e==="?"||s==="?"},_t=o=>{const e=o.index?.trim();return!!(e&&e!=="?")},Kt=o=>!!o.working_dir?.trim()||o.index==="?",Rs=(o,e)=>ss(o,e),Ht=o=>(o||"").replace(/\\/g,"/").replace(/\/+$/,""),Gt=(o,e)=>{const s=o.split(`
1
+ import{R as i,f as Ye,j as t}from"./vendor-react-BUCujlKS.js";import{u as le,L as Fe,a as De}from"./index-BvwlOZOg.js";import{c as Fn,b as Dn,u as An,a as Vn,B as En,C as Ln,P as Tt,h as Tn,e as Mn,g as Bn,i as Pn,f as In}from"./patchFileDiff-DHG-znZQ.js";import{c as zn,b as On,i as _n,u as Hn,a as Kn,d as Gn}from"./useGitComparison-DIetwQtj.js";import{f as Ie,B as he,I as V,h as je,Y as $t,ae as $n,J as ee,af as qn,be as Wn,H as Un,ag as Jn,ai as Xn,y as Mt,k as Yn,cP as qt,t as Je,id as Qn,av as Xe,a9 as Zn,aa as es,ab as ts,i3 as Wt,ie as ns,aw as Ut,g0 as ss,at as Ue,au as rs,bU as Jt,ap as is,ar as os,as,ao as ls}from"./useAppFontEffects-cYK1WODe.js";import{f as cs,d as us}from"./runtimeEndpointReset-DB4KI-ED.js";import{P as fs}from"./PierreDiffViewer-C51SEtjJ.js";import{u as ds,v as ms,g as ps,W as hs}from"./main-6ZT1mvpO.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-B6551dwG.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./VirtualizedFileDiff-C-MFNoKo.js";import"./web-components-HM6S8xyb.js";import"./computeVirtualFileMetrics-Bv64vrxY.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isDiffPlainText-B0pMS3gs.js";import"./vendor-diff-C3JhlQdm.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-BY_5qla_.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-BdA6bdky.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CsvoASYk.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-DscFZWyI.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./useRootScrollLock-CE3HJBOu.js";import"./scheduledTasksApi-DZaxQ19y.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";const gs=i.memo(function(e){const s=Ye.c(13),{index:u,staged:h,busyHunk:m,disabled:x,onAction:j}=e,{t:C}=Ie();let c;s[0]!==h?(c=h?["unstage"]:["discard","stage"],s[0]=h,s[1]=c):c=s[1];const w=c;let v;s[2]===Symbol.for("react.memo_cache_sentinel")?(v={top:"var(--oc-hunk-action-offset, 0.25rem)"},s[2]=v):v=s[2];let d;s[3]!==w||s[4]!==m||s[5]!==x||s[6]!==u||s[7]!==j||s[8]!==C?(d=t.jsx("div",{className:"pointer-events-auto flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:w.map(b=>{const _=C(b==="stage"?"diffView.hunk.stageTitle":b==="unstage"?"diffView.hunk.unstageTitle":"diffView.hunk.discardTitle",{index:u+1}),I=m?.index===u&&m.action===b;return t.jsx(he,{variant:"ghost",size:"xs",className:je("rounded-full bg-transparent text-muted-foreground hover:bg-transparent hover:text-foreground",b==="discard"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",b==="stage"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:x||m!==null,title:_,"aria-label":_,onPointerDown:xs,onClick:f=>{f.stopPropagation(),j(u,b)},children:t.jsx(V,{name:I?"loader-4":b==="stage"?"add":"arrow-go-back",className:je(b==="stage"?"size-4":"size-3.5",I&&"animate-spin")})},b)})}),s[3]=w,s[4]=m,s[5]=x,s[6]=u,s[7]=j,s[8]=C,s[9]=d):d=s[9];let E;return s[10]!==u||s[11]!==d?(E=t.jsx("div",{className:"pointer-events-none absolute right-3 z-20",style:v,"data-hunk-actions":u,children:d}),s[10]=u,s[11]=d,s[12]=E):E=s[12],E});function xs(o){return o.stopPropagation()}const Bt=(o,e)=>{if(e.length===0)return null;let s=null,u=null;for(const m of e)m.top<=o?(!s||m.top>s.top)&&(s=m):(!u||m.top<u.top)&&(u=m);const h=s??u;return h?{path:h.path,topOffset:h.top-o}:null},ys=(o,e,s,u)=>Math.min(Math.max(0,u),Math.max(0,o+s-e)),Pt=o=>{if(!o)return null;const e=o.split(`
2
+ `);let s=null;for(const u of e){const h=u.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(h){const m=Number.parseInt(h[1]??"",10);s=Number.isFinite(m)&&m>=1?m:null;continue}if(s!==null){if(u.startsWith(" ")){s+=1;continue}if(u.startsWith("+"))return s;if(u.startsWith("-"))return Math.max(1,s)}}return null},ws=1100,bs=15e3,It=500,zt=300,Xt=1e6,xt=3,js=o=>o<=6?o:o<=12?6:o<=25?4:2,Ot={status:"loading"},vs=3,Ss=i.memo(()=>{const o=Ye.c(4),{t:e}=Ie();let s;o[0]!==e?(s=e("diffView.binary.unavailable"),o[0]=e,o[1]=s):s=o[1];let u;return o[2]!==s?(u=t.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:t.jsx("div",{className:"typography-meta text-muted-foreground",children:s})}),o[2]=s,o[3]=u):u=o[3],u}),Yt={"?":{code:"?",color:"var(--status-info)",descriptionKey:"diffView.change.untracked"},A:{code:"A",color:"var(--status-success)",descriptionKey:"diffView.change.new"},D:{code:"D",color:"var(--status-error)",descriptionKey:"diffView.change.deleted"},R:{code:"R",color:"var(--status-info)",descriptionKey:"diffView.change.renamed"},C:{code:"C",color:"var(--status-info)",descriptionKey:"diffView.change.copied"},M:{code:"M",color:"var(--status-warning)",descriptionKey:"diffView.change.modified"}},Ns=Yt.M,ks=o=>{const e=o.index?.trim(),s=o.working_dir?.trim();return e&&e!=="?"?e.charAt(0):s?s.charAt(0):e?.charAt(0)||s?.charAt(0)||"M"},Qt=o=>{const e=ks(o);return Yt[e]??Ns},Cs=o=>{const{index:e,working_dir:s}=o;return e==="A"||s==="A"||e==="?"||s==="?"},_t=o=>{const e=o.index?.trim();return!!(e&&e!=="?")},Ht=o=>!!o.working_dir?.trim()||o.index==="?",Rs=(o,e)=>ss(o,e),Kt=o=>(o||"").replace(/\\/g,"/").replace(/\/+$/,""),Gt=(o,e)=>{const s=o.split(`
3
3
  `),u=e.split(`
4
- `),h=Math.min(s.length,u.length);for(let m=0;m<h;m+=1)if(s[m]!==u[m])return m+1;return u.length>s.length?s.length+1:s.length>u.length?Math.max(1,u.length):1},Fs=o=>Array.isArray(o)?o.filter(e=>!e||typeof e!="object"?!1:typeof e.file=="string"):[],Ds=o=>o==="added"?"A":o==="deleted"?"D":"M",yt=(o,e,s)=>In(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:s}:{original:"",modified:"",patch:e,fileDiff:Pn(o,e),contextMode:s},Zt=(o,e,s)=>{const u=o??0,h=e??0;return!u&&!h?null:t.jsxs("span",{className:je("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",s?.className),children:[u?t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",u]}):null,h?t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",h]}):null]})},As=i.memo(o=>{const e=Ye.c(68),{scope:s,workingCount:u,stagedCount:h,turnCount:m,branchCount:x,commitCount:j,prCount:C,showCommitOption:c,showBranchOption:w,onScopeChange:v}=o,{t:d}=Pe(),[E,b]=i.useState(!1),_=s==="pr"?C??0:s==="staged"?h:s==="turn"?m:s==="branch"?x??0:s==="commit"?j??0:u;let P;e[0]!==s||e[1]!==d?(P=d(s==="pr"?"session.githubIntegration.tabs.pullRequests":s==="staged"?"diffView.scope.staged":s==="turn"?"diffView.scope.lastTurn":s==="branch"?"diffView.scope.branch":s==="commit"?"commitComparison.mode":"diffView.scope.changed"),e[0]=s,e[1]=d,e[2]=P):P=e[2];const f=P;let ge;e[3]!==d?(ge=d("diffView.scope.selectorAria"),e[3]=d,e[4]=ge):ge=e[4];let xe;e[5]!==_?(xe=t.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",_]}),e[5]=_,e[6]=xe):xe=e[6];let Y;e[7]!==f||e[8]!==xe?(Y=t.jsxs("span",{className:"whitespace-nowrap",children:[f,xe]}),e[7]=f,e[8]=xe,e[9]=Y):Y=e[9];let F;e[10]===Symbol.for("react.memo_cache_sentinel")?(F=t.jsx(V,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=F):F=e[10];let L;e[11]!==ge||e[12]!==Y?(L=t.jsx(is,{asChild:!0,children:t.jsxs("button",{type:"button",className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring","aria-label":ge,children:[Y,F]})}),e[11]=ge,e[12]=Y,e[13]=L):L=e[13];let S;e[14]!==v?(S=J=>{(J==="working"||J==="staged"||J==="turn"||J==="branch"||J==="commit"||J==="pr")&&(v?.(J),b(!1))},e[14]=v,e[15]=S):S=e[15];let te;e[16]!==d?(te=d("diffView.scope.changed"),e[16]=d,e[17]=te):te=e[17];let ne;e[18]!==te?(ne=t.jsx("span",{children:te}),e[18]=te,e[19]=ne):ne=e[19];let ce;e[20]!==u?(ce=t.jsx("span",{className:"typography-meta text-muted-foreground",children:u}),e[20]=u,e[21]=ce):ce=e[21];let se;e[22]!==ce||e[23]!==ne?(se=t.jsx(Ue,{value:"working",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[ne,ce]})}),e[22]=ce,e[23]=ne,e[24]=se):se=e[24];let ue;e[25]!==d?(ue=d("diffView.scope.staged"),e[25]=d,e[26]=ue):ue=e[26];let Q;e[27]!==ue?(Q=t.jsx("span",{children:ue}),e[27]=ue,e[28]=Q):Q=e[28];let W;e[29]!==h?(W=t.jsx("span",{className:"typography-meta text-muted-foreground",children:h}),e[29]=h,e[30]=W):W=e[30];let fe;e[31]!==Q||e[32]!==W?(fe=t.jsx(Ue,{value:"staged",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[Q,W]})}),e[31]=Q,e[32]=W,e[33]=fe):fe=e[33];let T;e[34]!==d?(T=d("diffView.scope.lastTurn"),e[34]=d,e[35]=T):T=e[35];let A;e[36]!==T?(A=t.jsx("span",{children:T}),e[36]=T,e[37]=A):A=e[37];let $;e[38]!==m?($=t.jsx("span",{className:"typography-meta text-muted-foreground",children:m}),e[38]=m,e[39]=$):$=e[39];let K;e[40]!==A||e[41]!==$?(K=t.jsx(Ue,{value:"turn",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[A,$]})}),e[40]=A,e[41]=$,e[42]=K):K=e[42];let de;e[43]!==x||e[44]!==w||e[45]!==d?(de=w?t.jsx(Ue,{value:"branch",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:d("diffView.scope.branch")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:x??"…"})]})}):null,e[43]=x,e[44]=w,e[45]=d,e[46]=de):de=e[46];let U;e[47]!==j||e[48]!==c||e[49]!==d?(U=c&&t.jsx(Ue,{value:"commit",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:d("commitComparison.mode")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:j??"…"})]})}),e[47]=j,e[48]=c,e[49]=d,e[50]=U):U=e[50];let O;e[51]!==C||e[52]!==c||e[53]!==d?(O=c&&t.jsx(Ue,{value:"pr",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:d("session.githubIntegration.tabs.pullRequests")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:C??"…"})]})}),e[51]=C,e[52]=c,e[53]=d,e[54]=O):O=e[54];let q;e[55]!==s||e[56]!==se||e[57]!==fe||e[58]!==K||e[59]!==de||e[60]!==U||e[61]!==O||e[62]!==S?(q=t.jsx(os,{align:"start",className:"w-40",children:t.jsxs(as,{value:s,onValueChange:S,children:[se,fe,K,de,U,O]})}),e[55]=s,e[56]=se,e[57]=fe,e[58]=K,e[59]=de,e[60]=U,e[61]=O,e[62]=S,e[63]=q):q=e[63];let ve;return e[64]!==E||e[65]!==q||e[66]!==L?(ve=t.jsxs(ls,{open:E,onOpenChange:b,children:[L,q]}),e[64]=E,e[65]=q,e[66]=L,e[67]=ve):ve=e[67],ve}),Vs=i.memo(o=>{const e=Ye.c(11),{changedFiles:s,selectedFile:u,onSelectFile:h}=o,{t:m}=Pe();if(s.length===0)return null;let x;if(e[0]!==s||e[1]!==h||e[2]!==u||e[3]!==m){let C;e[5]!==h||e[6]!==u||e[7]!==m?(C=c=>{const w=Qt(c),v=u===c.path;return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>h(c.path),className:je("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",v?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[t.jsx(Ut,{filePath:c.path,className:"h-3.5 w-3.5 flex-shrink-0"}),t.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:w.color},title:m(w.descriptionKey),"aria-label":m(w.descriptionKey),children:w.code}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:c.path,children:c.path}),Zt(c.insertions,c.deletions)]})},c.path)},e[5]=h,e[6]=u,e[7]=m,e[8]=C):C=e[8],x=s.map(C),e[0]=s,e[1]=h,e[2]=u,e[3]=m,e[4]=x}else x=e[4];let j;return e[9]!==x?(j=t.jsx(Jt,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:t.jsx("ul",{className:"flex flex-col gap-1",children:x})}),e[9]=x,e[10]=j):j=e[10],j}),Es=i.memo(o=>{const e=Ye.c(20),{filePath:s,diff:u,renderSideBySide:h}=o,{t:m}=Pe(),x=u.original.length>0,j=u.modified.length>0,C=h?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",c=h?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={contain:"layout"},e[0]=w):w=e[0];let v;e[1]!==u.original||e[2]!==s||e[3]!==x||e[4]!==c||e[5]!==h||e[6]!==m?(v=x&&t.jsxs("div",{className:c,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:m("diffView.image.original")}),t.jsx("img",{src:u.original,alt:m("diffView.image.originalAlt",{path:s}),className:h?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=u.original,e[2]=s,e[3]=x,e[4]=c,e[5]=h,e[6]=m,e[7]=v):v=e[7];let d;e[8]!==u.modified||e[9]!==s||e[10]!==j||e[11]!==x||e[12]!==c||e[13]!==h||e[14]!==m?(d=j&&t.jsxs("div",{className:c,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:m(x?"diffView.image.modified":"diffView.image.new")}),t.jsx("img",{src:u.modified,alt:m("diffView.image.modifiedAlt",{path:s}),className:h?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=u.modified,e[9]=s,e[10]=j,e[11]=x,e[12]=c,e[13]=h,e[14]=m,e[15]=d):d=e[15];let E;return e[16]!==C||e[17]!==v||e[18]!==d?(E=t.jsx("div",{className:"w-full overflow-auto p-4",style:w,children:t.jsxs("div",{className:C,children:[v,d]})}),e[16]=C,e[17]=v,e[18]=d,e[19]=E):E=e[19],E}),Ls=i.memo(o=>{const e=Ye.c(17),{filePath:s,diff:u,renderSideBySide:h,wrapLines:m,hunkActions:x}=o;let j;e[0]!==s?(j=rs(s)||"text",e[0]=s,e[1]=j):j=e[1];const C=j;if(u.isBinary){let v;return e[2]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(Ss,{}),e[2]=v):v=e[2],v}if(Xe(s)){let v;return e[3]!==u||e[4]!==s||e[5]!==h?(v=t.jsx(Es,{filePath:s,diff:u,renderSideBySide:h}),e[3]=u,e[4]=s,e[5]=h,e[6]=v):v=e[6],v}let c;e[7]===Symbol.for("react.memo_cache_sentinel")?(c={contain:"layout"},e[7]=c):c=e[7];let w;return e[8]!==u.fileDiff||e[9]!==u.modified||e[10]!==u.original||e[11]!==s||e[12]!==x||e[13]!==C||e[14]!==h||e[15]!==m?(w=t.jsx("div",{className:"w-full",style:c,children:t.jsx(fs,{original:u.original,modified:u.modified,fileDiff:u.fileDiff,language:C,fileName:s,renderSideBySide:h,wrapLines:m,layout:"inline",hunkActions:x})}),e[8]=u.fileDiff,e[9]=u.modified,e[10]=u.original,e[11]=s,e[12]=x,e[13]=C,e[14]=h,e[15]=m,e[16]=w):w=e[16],w}),Ts=i.memo(({visible:o=!0,directory:e,file:s,layout:u,wrapLines:h,isSelected:m,isExpanded:x,isMounted:j,onSelect:C,onExpandedChange:c,registerSectionRef:w,showOpenInEditorAction:v=!1,isOpeningInEditor:d=!1,onOpenInEditor:E,staged:b=!1,loadFullFiles:_=!1,initialDiffData:P=null,comparisonDiff:f,onRetryComparisonDiff:ge,readOnlyActions:xe=!1,hunkActionsEnabled:Y=!1})=>{const{t:F}=Pe(),{git:L}=$t(),S=ee(i.useCallback(g=>g.directories.get(e)?.diffCache.get(s.path)??null,[e,s.path])),te=ee(g=>g.setDiff),ne=ee(g=>g.fetchStatus),ce=le(g=>g.setDiffFileLayout),[se,ue]=i.useState(0),[Q,W]=i.useState(null),[fe,T]=i.useState(!1),A=f?f.status==="error"?f.message:null:Q,$=f?f.status==="loading":fe,[K,de]=i.useState(null),U=i.useRef(!1),[O,q]=i.useState(null),[ve,J]=i.useState(!1),[re,Qe]=i.useState(null),[it,Ae]=i.useState(null),ye=i.useRef(null),ut=i.useRef(null),Oe=i.useMemo(()=>Qt(s),[s]),ze=u==="side-by-side",Ve=_?"full":"patch",we=`${s.index}:${s.working_dir}:${s.insertions}:${s.deletions}`,a=Y&&!xe&&!P&&!f&&!Xe(s.path),Se=JSON.stringify([De(),e,s.path,b,we,se]),z=O?.scope===Se?O.patch:null,me=i.useMemo(()=>f?f.status==="ready"?f.data:null:P||(b?it:re||(S?{original:S.original,modified:S.modified,isBinary:S.isBinary,contextMode:"full"}:null)),[f,S,P,re,b,it]),Ne=me?.contextMode===Ve,ot=i.useCallback(g=>{ut.current=g,w(s.path,g)},[s.path,w]),_e=i.useCallback(g=>{c(s.path,g)},[s.path,c]),Ze=i.useCallback(()=>{C(s.path)},[s.path,C]),et=i.useRef({fileStatusKey:we,staged:b});i.useEffect(()=>{if(!o)return;const g=et.current;g.fileStatusKey===we&&g.staged===b||(et.current={fileStatusKey:we,staged:b},b?Ae(null):Qe(null),W(null),ye.current=null)},[we,b,o]),i.useEffect(()=>{if(!o||!x||!j||Q)return;if(!e||f||P||me&&Ne&&(!a||z!==null)){ye.current=null,T(!1);return}const g=`${e}::${s.path}::${b?"staged":"unstaged"}::${we}::${Ve}::${se}`;if(ye.current===g)return;ye.current=g,W(null),T(!0);let M=!1;const ie=De(),Ge=_?Xt:xt,X=Xe(s.path)?L.getGitFileDiff(e,{path:s.path,staged:b}):!_&&z!==null?Promise.resolve({diff:z}):L.getGitDiff(e,{path:s.path,staged:b,contextLines:Ge}),ft=a&&_&&z===null?L.getGitDiff(e,{path:s.path,staged:b,contextLines:xt}).then(R=>R.diff):Promise.resolve(z),Ee=Promise.all([X,ft]),Le=bs;let pe;const H=new Promise((R,oe)=>{pe=setTimeout(()=>oe(new Error(`Timed out after ${Le}ms`)),Le)});return Promise.race([Ee,H]).then(([R,oe])=>{if(M||ie!==De())return;const ke="diff"in R&&!_?R.diff:oe;if(a&&_&&ke!==null&&/^@@\s/m.test(ke)&&"diff"in R&&R.diff!==ke&&!Tn(R.diff,ke))throw q(null),new Error(F("diffView.hunk.unavailable"));if(a&&ke!==null&&q({scope:Se,patch:ke}),"diff"in R){const Ce=yt(s.path,R.diff,Ve);b?Ae(Ce):Qe(Ce)}else{const Ce={original:R.original??"",modified:R.modified??"",isBinary:R.isBinary,contextMode:"full"};b?Ae(Ce):te(e,s.path,Ce,ie)}T(!1)}).catch(R=>{if(M||ie!==De())return;const oe=R instanceof Error?R.message:String(R);W(oe),T(!1)}).finally(()=>clearTimeout(pe)),()=>{M=!0,clearTimeout(pe),ye.current===g&&(ye.current=null)}},[z,a,Se,f,Ve,me,Ne,se,e,s.path,we,L,P,x,j,_,Q,te,b,F,o]);const tt=i.useCallback(()=>{_e(!x),Ze()},[_e,Ze,x]),Ke=i.useCallback(()=>{W(null),q(null),Qe(null),Ae(null),ye.current=null,ue(g=>g+1)},[]),nt=i.useCallback(async(g,M)=>{if(!e||!a||$||A||U.current||K!==null)return;const ie=z?Mn(z,g):null;if(!ie){Je.error(F("diffView.hunk.unavailable"));return}if(b&&M!=="unstage"||!b&&M==="unstage")return;U.current=!0;const Ge=De();de({index:g,action:M});try{const X=M==="stage"?L.stageGitHunk:M==="unstage"?L.unstageGitHunk:L.revertGitHunk;if(!X){Je.error(F("diffView.hunk.unsupported"));return}if(await X(e,s.path,ie),Ge!==De())return;Ke(),qt.requestGitRefresh({directory:e,paths:[s.path]}),await ne(e,L)}catch(X){if(Ge!==De())return;Ke(),Je.error(X instanceof Error&&X.message?X.message:F("diffView.hunk.unavailable"))}finally{U.current=!1,de(X=>X?.index===g&&X.action===M?null:X)}},[z,a,$,A,e,ne,s.path,L,K,Ke,b,F]),be=i.useMemo(()=>a&&z!==null?Bn(z):[],[z,a]),He=i.useCallback(g=>t.jsx(gs,{index:g,staged:b,busyHunk:K,disabled:$||!!A,onAction:nt}),[A,nt,K,$,b]),st=i.useMemo(()=>be.length>0?{anchors:be,render:He}:void 0,[be,He]);return t.jsxs("div",{ref:ot,className:"scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0",children:[t.jsx("div",{className:"sticky top-0 z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80",children:t.jsxs("div",{role:"button",tabIndex:0,onClick:tt,onKeyDown:g=>{g.target===g.currentTarget&&(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),tt())},className:je("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",m?"bg-[var(--interactive-selection)]/35":null),children:[t.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),t.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:x?t.jsx(V,{name:"arrow-down-s",className:"size-4"}):t.jsx(V,{name:"arrow-right-s",className:"size-4"})}),t.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:Oe.color},title:F(Oe.descriptionKey),"aria-label":F(Oe.descriptionKey),children:Oe.code}),t.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:s.path,children:t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ut,{filePath:s.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const g=s.path.lastIndexOf("/");if(g===-1)return t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:s.path});const M=s.path.slice(0,g),ie=s.path.slice(g+1);return t.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:M}),t.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[t.jsx("span",{className:"text-muted-foreground",children:"/"}),t.jsx("span",{className:"text-foreground",children:ie})]})]})})()]})})]}),t.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[Zt(s.insertions,s.deletions),v&&E?t.jsx(he,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:F("diffView.actions.openFileInEditorAtChange"),onClick:g=>{g.stopPropagation(),E(s.path,me)},disabled:d,children:d?t.jsx(V,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(V,{name:"edit",className:"size-3.5"})}):null,t.jsx(Wt,{mode:ze?"side-by-side":"unified",onModeChange:g=>{const M=g==="side-by-side"?"side-by-side":"inline";ce(s.path,M)},className:"opacity-70"})]})]})}),x&&t.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!j&&!A?t.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,A?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:F("diffView.state.failedToLoadDiff")}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:A}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>f?ge?.():Ke(),children:F("diffView.actions.retry")})]}):null,j&&$&&!me&&!A?t.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}),F("diffView.state.loadingDiff")]}):null,j&&me&&!ve&&s.insertions+s.deletions>Pt?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:F("diffView.state.largeDiff",{count:s.insertions+s.deletions})}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:F("diffView.state.largeDiffDescription")}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>J(!0),children:F("diffView.actions.renderAnyway")})]}):null,j&&me&&(ve||s.insertions+s.deletions<=Pt)?t.jsx(t.Fragment,{children:t.jsx(Ls,{filePath:s.path,diff:me,renderSideBySide:ze,wrapLines:h,hunkActions:st})}):null]})]})}),Yi=({visible:o=!0,hideStackedFileSidebar:e=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:u=!1,showOpenInEditorAction:h=!1,diffScope:m="all",onDiffScopeChange:x,targetFilePath:j=null,flushContent:C=!1})=>{const{t:c}=Pe(),{git:w,files:v}=$t(),d=$n(),E=ee(n=>n.runtimeKey),{rootIsGitRepo:b,gitDirectory:_,nestedRepos:P}=qn(d??null,{enabled:o}),f=_??d,ge=le(n=>n.openContextSurface),xe=ds(n=>n.requestSource),{screenWidth:Y,isMobile:F}=Wn(),L=Un(f??null),S=Jn(f??null),te=Xn(f??null),ne=ee(n=>n.setActiveDirectory),ce=ee(n=>n.ensureStatus),se=ee(n=>n.selectNestedRepo),ue=ee(n=>n.fetchStatus),Q=ee(n=>n.fetchBranches),W=ee(n=>n.clearDiffCache),fe=ee(n=>n.setDiff),[T,A]=i.useState(null),[$,K]=i.useState(!1),[de,U]=i.useState(null),[O,q]=i.useState(()=>new Set),[ve,J]=i.useState(()=>new Set),[re,Qe]=i.useState(!1),[it,Ae]=i.useState(0),[ye,ut]=i.useState(()=>new Map),[Oe,ze]=i.useState(!1),[Ve,we]=i.useState(!1),[a,Se]=i.useState(m);i.useEffect(()=>{Se(m)},[m]);const z=le(n=>n.pendingDiffFile),me=le(n=>n.pendingDiffStaged),Ne=le(n=>n.pendingDiffScope),ot=le(n=>n.setPendingDiffFile),_e=le(n=>n.diffLayoutPreference),Ze=le(n=>n.diffFileLayout),et=le(n=>n.setDiffFileLayout),tt=le(n=>n.diffWrapLines),Ke=le(n=>n.setDiffWrapLines),nt=le(n=>n.openContextFileAtLine),be=Mt(n=>n.currentSessionId),He=Yn(a==="turn"?be??"":"",d??void 0),st=tt,g=a==="staged"?!0:a==="working"?!1:null,M=g??$,ie=F||Y<=768,Ge=!!be&&a!=="turn"&&a!=="commit"&&a!=="pr"&&!ie&&!Fe(),X=a!=="turn"&&!ie&&!Fe(),ft=!e&&!ie&&Y>=1024,Ee=i.useRef(null),Le=i.useRef(new Map),pe=i.useRef(null),H=i.useRef(null),R=i.useRef(!1),oe=i.useRef(null),ke=i.useRef(null),Ce=i.useRef(null),dt=i.useRef(null),wt=i.useCallback(()=>{const n=Ee.current;if(!n)return null;const r=n.getBoundingClientRect().top,l=[];for(const[p,y]of Le.current)y&&l.push({path:p,top:y.getBoundingClientRect().top});return Bt(r,l)},[]),$e=i.useCallback(()=>{pe.current=null,R.current=!1,U(null),H.current!==null&&(window.cancelAnimationFrame(H.current),H.current=null)},[]),qe=i.useCallback(n=>{q(r=>{if(r.has(n))return r;const l=new Set(r);return l.add(n),l})},[]),rt=i.useMemo(()=>{for(let n=He.length-1;n>=0;n-=1){const r=He[n];if(r.role==="user")return Fs(r.summary?.diffs)}return[]},[He]),en=i.useMemo(()=>{const n=new Map;for(const r of rt)if(r.file){if(typeof r.patch=="string"){n.set(r.file,yt(r.file,r.patch,"patch"));continue}n.set(r.file,{original:r.before??"",modified:r.after??"",contextMode:"full"})}return n},[rt]),tn=i.useMemo(()=>S?.files?S.files.filter(Kt).length:0,[S]),nn=i.useMemo(()=>S?.files?S.files.filter(_t).length:0,[S]),sn=rt.length,G=S?.current??null,Te=Fn(f??null,G,o&&a==="pr"&&!Fe()),Me=Te.selectedSource,Be=Dn(f??null,G,o&&a==="commit"&&!Fe()),Ie=Be.selectedCommit?.hash??null;i.useEffect(()=>{(a==="commit"||a==="pr")&&Fe()&&(Se("working"),x?.("working"))},[a,x]);const We=ee(n=>f?n.directories.get(f)?.branches??null:null),rn=ee(n=>f?n.directories.get(f)?.isLoadingBranches??!1:!1),on=i.useCallback(()=>{f&&Q(f,w)},[f,Q,w]),an=On(f??null,o&&L!==!1,rn,!!We,on,vs),bt=i.useMemo(()=>{const n=S?.tracking?.trim().split("/")[0];return(n&&We?.defaultBranches?.[n])??We?.defaultBranches?.origin??null},[We,S?.tracking]),jt=!Fe()&&zn(G,bt),ln=S!==null,vt=Fe()||an||_n(G,bt,ln,We!==null),cn=An(n=>n.setOverride),{base:Re,resolved:un,revision:St}=Vn(f??null,G,o&&jt&&a==="branch"),[fn,dn]=i.useState(0);i.useEffect(()=>{const n=Gn(a,!vt);n!==a&&(Se(n),n==="working"&&x?.("working"))},[a,vt,x]);const mn=i.useMemo(()=>a==="pr"?Me:a==="commit"&&Ie?{kind:"commit",hash:Ie}:a==="branch"&&Re&&G?{kind:"branch",baseRef:Re,headRef:G}:null,[a,Re,G,Ie,Me]),D=Kn(f??null,mn,o&&!Fe(),a==="branch"?St:""),{fetchDiff:Nt}=D,kt=a==="commit"?D.files:null,Ct=a==="commit"?D.error:null,at=a==="branch"?D.files:null,Rt=a==="branch"?D.error:null,Ft=D.files?a==="pr"?JSON.stringify([D.key,D.revision]):D.key:null,pn=i.useMemo(()=>a==="branch"||a==="commit"||a==="pr"?Array.from(O).sort().join("\0"):"",[a,O]),hn=i.useCallback(async n=>{try{const r=re&&a!=="pr",l=await Nt(n,r?Xt:xt);return{status:"ready",data:yt(n,l.diff,r?"full":"patch")}}catch(r){return{status:"error",message:r instanceof Error?r.message:c("diffView.state.failedToLoadDiff")}}},[a,Nt,re,c]),gn=Hn(Ft,o?pn:"",Ft?hn:null,zt,JSON.stringify([a==="branch"?St:"",a==="pr"?D.revision:0,fn,re])),xn=at?.length??null,N=i.useMemo(()=>{if(a==="commit"||a==="pr")return(D.files??[]).map(l=>({path:l.path,index:"",working_dir:l.status,insertions:l.insertions,deletions:l.deletions,isNew:l.status==="A"}));if(a==="branch")return(at??[]).map(l=>({path:l.path,index:"",working_dir:l.status,insertions:0,deletions:0,isNew:l.status==="A"})).sort((l,p)=>l.path.localeCompare(p.path));if(a==="turn")return rt.map(l=>({path:l.file??"",index:"",working_dir:Ds(l.status),insertions:l.additions??0,deletions:l.deletions??0,isNew:l.status==="added"})).filter(l=>l.path).sort((l,p)=>l.path.localeCompare(p.path));if(!S?.files)return[];const n=S.diffStats??{},r=a==="staged"?_t:a==="working"?Kt:()=>!0;return S.files.filter(r).map(l=>({...l,insertions:n[l.path]?.insertions??0,deletions:n[l.path]?.deletions??0,isNew:Cs(l)})).sort((l,p)=>l.path.localeCompare(p.path))},[a,at,D.files,rt,S]),mt=i.useMemo(()=>N.map(n=>n.path).join("\0"),[N]);i.useEffect(()=>{const n=mt?mt.split("\0"):[],r=new Set(n),l=`${f??""}:${a}:${s?"collapsed":"default"}`,p=ke.current!==l;ke.current=l,q(y=>{if(p){const I=s?0:js(n.length);return new Set(n.slice(0,I))}let B=!1;const k=new Set;for(const I of y){if(!r.has(I)){B=!0;continue}k.add(I)}return B?k:y}),J(y=>{if(p)return new Set;let B=!1;const k=new Set;for(const I of y){if(!r.has(I)){B=!0;continue}k.add(I)}return B?k:y})},[a,mt,f,s]);const Dt=i.useCallback(()=>{if(oe.current=null,!o)return;const n=Ee.current;if(!n)return;const r=n.getBoundingClientRect(),l=r.top-Ot,p=r.bottom+Ot,y={},B=[];for(const[k,I]of Le.current){if(!I)continue;const Z=I.getBoundingClientRect();B.push({path:k,top:Z.top}),O.has(k)&&(Z.bottom<l||Z.top>p||(y[k]=!0))}Ce.current=Bt(r.top,B),J(k=>{let I=!1;const Z=new Set(k);for(const Lt of Object.keys(y))Z.has(Lt)||(Z.add(Lt),I=!0);return I?Z:k})},[O,o]),ae=i.useCallback(()=>{o&&(typeof window>"u"||oe.current===null&&(oe.current=window.requestAnimationFrame(Dt)))},[Dt,o]);i.useEffect(()=>{const n=Ee.current;if(!(!o||!n))return ae(),n.addEventListener("scroll",ae,{passive:!0}),window.addEventListener("resize",ae),()=>{n.removeEventListener("scroll",ae),window.removeEventListener("resize",ae),oe.current!==null&&(window.cancelAnimationFrame(oe.current),oe.current=null)}},[N,O,ae,o]);const pt=i.useCallback(n=>{const r=Ze[n.path];if(r)return r;if(_e==="inline")return"inline";if(_e==="side-by-side")return"side-by-side";const l=Y<ws;return n.isNew||l?"inline":"side-by-side"},[Ze,_e,Y]),At=i.useMemo(()=>N.length===0?null:N.every(n=>pt(n)==="side-by-side")?"side-by-side":"inline",[N,pt]);i.useEffect(()=>{o&&f&&(ne(f),ce(f,w))},[f,ne,ce,w,o]);const lt=JSON.stringify([E,f]),ht=i.useRef({scope:lt,paths:new Set,dirty:!1}),Vt=i.useRef(o);i.useEffect(()=>{const n=o&&!Vt.current;if(Vt.current=o,ht.current.scope!==lt&&(ht.current={scope:lt,paths:new Set,dirty:!1}),!f)return;const r=p=>{p?.length&&(dt.current=wt()??Ce.current,W(f,p),ut(y=>{const B=new Map(y);for(const k of p)B.set(k,(B.get(k)??0)+1);return B})),ue(f,w,{silent:!0})},l=ht.current;return o&&(n||l.dirty)&&(r([...l.paths]),l.paths.clear(),l.dirty=!1),qt.onGitRefreshHint(p=>{if(Ht(p.directory)===Ht(f)){if(!o){l.dirty=!0;for(const y of p.paths??[])l.paths.add(y);return}r(p.paths)}})},[wt,W,f,ue,w,lt,o]),i.useLayoutEffect(()=>{const n=dt.current;if(!n)return;dt.current=null;const r=Ee.current,l=Le.current.get(n.path);if(!r||!l)return;const p=r.getBoundingClientRect().top,y=l.getBoundingClientRect().top-p;r.scrollTop=ys(r.scrollTop,n.topOffset,y,r.scrollHeight-r.clientHeight),Ce.current=n},[ye]),i.useEffect(()=>{!o||a!=="all"&&!Ne||z&&(Ne&&Se(Ne),A(z),K(Ne==="staged"||!Ne&&me),ot(null),R.current=!0,pe.current=z,qe(z),Ae(n=>n+1))},[a,qe,z,Ne,me,ot,o]),i.useEffect(()=>{if(a==="all")return;const n=j?.trim();n&&(A(n),K(a==="staged"),R.current=!0,pe.current=n,qe(n),Ae(r=>r+1))},[a,qe,j]),i.useEffect(()=>{if(!T)return;N.some(r=>r.path===T)||(A(null),K(!1))},[N,T]);const yn=i.useCallback((n,r)=>{const l=Le.current;r?l.set(n,r):l.delete(n),ae()},[ae]),wn=i.useCallback((n,r)=>{$e(),q(l=>{const p=l.has(n);if(r===p)return l;const y=new Set(l);return r?y.add(n):y.delete(n),y}),r||J(l=>{if(!l.has(n))return l;const p=new Set(l);return p.delete(n),p}),ae()},[$e,ae]),bn=i.useCallback(()=>{$e(),q(n=>n.size>0?new Set:new Set(N.map(r=>r.path))),J(new Set),ae()},[$e,N,ae]),jn=i.useCallback(async n=>{if(!be)return;const r=Mt.getState().getDirectoryForSession(be)||d||"";if(!r){Je.error(c("diffView.reviewDialog.toast.noSessionDirectory"));return}we(!0);try{await Qn({originalSessionID:be,directory:r,providerID:n.providerID,modelID:n.modelID,agent:n.agent||void 0,variant:n.variant||void 0,generateHandoff:n.generateHandoff,returnAfterHandoffRequest:n.generateHandoff,autoReview:n.autoReview}),ze(!1)}catch(l){console.error("[review-flow] failed to start review flow",l),Je.error(l instanceof Error?l.message:c("diffView.reviewDialog.toast.startFailed"))}finally{we(!1)}},[be,d,c]),ct=i.useCallback(n=>{const r=Le.current.get(n),l=Ee.current;if(!r||!l)return!1;const p=r.getBoundingClientRect().top-l.getBoundingClientRect().top;return l.scrollTo({top:l.scrollTop+p,behavior:"auto"}),!0},[]);i.useEffect(()=>{const n=pe.current;if(!o||!n)return;let r=0;const l=20;let p=!1;const y=(k=!0)=>{p||(p=!0,pe.current=null,R.current=!1,k&&U(null),H.current!==null&&(window.cancelAnimationFrame(H.current),H.current=null))},B=()=>{if(p){H.current=null;return}const k=pe.current;if(!k){y(),H.current=null;return}if(!ct(k)){r+=1,r<l?H.current=window.requestAnimationFrame(B):(y(),H.current=null);return}if(u&&R.current){U(k),y(!1);return}y()};return H.current=window.requestAnimationFrame(B),()=>{p=!0,H.current!==null&&(window.cancelAnimationFrame(H.current),H.current=null)}},[u,it,ct,o]);const vn=i.useCallback(n=>{},[]),gt=i.useCallback(n=>{$e(),A(n),K(!1),R.current=!0,pe.current=n,qe(n),Ae(r=>r+1),ct(n)},[$e,qe,ct]);i.useEffect(()=>{const n=r=>{if(!o||!r.altKey||r.metaKey||r.ctrlKey||r.shiftKey||r.key!=="ArrowDown"&&r.key!=="ArrowUp")return;const l=r.target;if(l instanceof HTMLElement&&(l.isContentEditable||l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.closest('[role="dialog"]'))||N.length===0)return;const p=r.key==="ArrowDown"?1:-1,y=T?N.findIndex(I=>I.path===T):-1,B=y===-1?p>0?0:N.length-1:y+p,k=N[B];k&&(r.preventDefault(),gt(k.path))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[N,T,gt,o]);const Sn=i.useCallback(n=>{const r=n==="side-by-side"?"side-by-side":"inline";N.forEach(l=>{et(l.path,r)})},[N,et]),[Nn,Et]=i.useState(null),kn=i.useCallback(async(n,r)=>{if(!f||!n)return;Et(n);const l=De();try{let p=null;if(r?.patch&&!r.isBinary&&!Xe(n)?p=It(r.patch):r&&r.contextMode==="full"&&!r.isBinary&&!Xe(n)&&(p=Gt(r.original,r.modified)),p===null)try{const Z=await w.getGitDiff(f,{path:n,staged:M,contextLines:3});p=It(Z.diff)}catch{p=null}let y=r;if(p===null||!y){const Z=await w.getGitFileDiff(f,{path:n,staged:M});y={original:Z.original??"",modified:Z.modified??"",isBinary:Z.isBinary},M||fe(f,n,y,l)}const B=p??(y.isBinary||Xe(n)?1:Gt(y.original,y.modified)),k=Rs(f,n),I=await ms(v,k,{directory:f});if(!I.ok){Je.error(ps(I.reason));return}nt(f,k,B,1)}finally{Et(p=>p===n?null:p)}},[M,f,v,w,nt,fe]),Cn=()=>{if(!f)return null;const n=r=>g!==null?g:$&&r===T;return t.jsxs("div",{className:je("flex min-w-0 flex-1 min-h-0 h-full",C?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[ft&&t.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[t.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:c("diffView.section.files")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:N.length})]}),t.jsx(Vs,{changedFiles:N,selectedFile:null,onSelectFile:gt})]}),t.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:t.jsx(Jt,{ref:Ee,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:t.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:N.map(r=>t.jsx(Ts,{visible:o,directory:f,file:r,layout:pt(r),wrapLines:st,isSelected:!1,isExpanded:O.has(r.path),isMounted:ve.has(r.path)||r.path===de,onSelect:vn,onExpandedChange:wn,registerSectionRef:yn,showOpenInEditorAction:h&&a!=="turn",isOpeningInEditor:Nn===r.path,onOpenInEditor:(l,p)=>{kn(l,p)},staged:n(r.path),loadFullFiles:re&&a!=="pr",readOnlyActions:a==="branch"||a==="commit"||a==="pr",hunkActionsEnabled:a==="all"||a==="working"||a==="staged",comparisonDiff:a==="branch"||a==="commit"||a==="pr"?gn.get(r.path)??zt:void 0,onRetryComparisonDiff:()=>dn(l=>l+1),initialDiffData:a==="turn"?en.get(r.path)??null:null},`${De()}:${f}:${r.path}:${ye.get(r.path)??0}`))})})})]})},Rn=()=>{if(!f)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:c("diffView.state.selectSessionDirectory")});if(a!=="turn"&&te&&!S)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.state.loadingRepositoryStatus")]});if(a!=="turn"&&L===!1)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:c("diffView.state.notGitRepository")});if(a==="pr"){if(!Me||D.error)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:D.error??Te.error??(Te.loading?c("session.githubPrPicker.loading.pullRequests"):c("pullRequestComparison.select"))}),(D.error||Te.error)&&t.jsx(he,{variant:"outline",size:"sm",onClick:()=>{Me?D.refresh():Te.refresh()},children:c("diffView.actions.retry")}),!Me&&!Te.loading&&t.jsx(Tt,{comparison:Te})]});if(!D.files)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 typography-meta text-muted-foreground",children:[t.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.state.loadingDiff")]})}if(a==="commit"){if(Ct)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:Ct}),t.jsx(he,{variant:"outline",size:"sm",onClick:()=>{D.refresh()},children:c("diffView.actions.retry")})]});if(!Ie&&!Be.loading)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:Be.error??c("commitComparison.noCommits")});if(!kt)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.state.loadingDiff")]})}if(a==="branch"){if(!un)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.branch.resolvingBase")]});if(!Re)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(V,{name:"git-branch",className:"size-6 text-muted-foreground"}),t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:c("diffView.branch.noBaseTitle")}),t.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:c("gitView.pr.toast.baseBranchRequired")})]});if(Rt)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:c("diffView.branch.loadError")}),t.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Rt}),t.jsx(he,{variant:"outline",size:"sm",onClick:()=>{D.refresh()},children:c("diffView.actions.retry")})]});if(at===null)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.branch.loadingFiles")]})}return N.length===0?t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:a==="turn"?c("diffView.state.noLastTurnChanges"):a==="pr"?c("walkthrough.blocked.emptyDiff.description"):a==="commit"?c("commitComparison.emptyDiff"):a==="branch"&&Re?c("diffView.branch.empty",{base:us(Re)}):c("diffView.state.cleanWorkingTree")}):Cn()};return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[t.jsxs("div",{className:"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[b===!1&&Array.isArray(P)&&P.length>0?t.jsx(cs,{repositories:P,selectedRepository:_??null,onSelectRepository:n=>{d&&se(d,n)},repositoryRoot:d??void 0}):null,!F&&(a!=="all"?t.jsx(As,{scope:a,workingCount:tn,stagedCount:nn,turnCount:sn,branchCount:xn,commitCount:a==="commit"?kt?.length??null:null,prCount:a==="pr"?D.files?.length??null:null,showCommitOption:!Fe(),showBranchOption:jt,onScopeChange:n=>{Se(n),x?.(n)}}):t.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:t.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:te&&!S?c("diffView.state.loadingChanges"):N.length===1?c("diffView.summary.changedFilesSingle",{count:N.length}):c("diffView.summary.changedFilesPlural",{count:N.length})})})),a==="branch"&&t.jsx(En,{branches:We?.all??[],currentBranch:G,base:Re,onSelect:n=>{f&&G&&cn(f,G,n)}},JSON.stringify([f,G])),a==="commit"&&t.jsx(Ln,{commits:Be.commits,selectedHash:Ie,loading:Be.loading,error:Be.error,onSelect:Be.select,onRefresh:()=>{Be.refresh()}},JSON.stringify([f,G])),a==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(Tt,{comparison:Te},JSON.stringify([E,f,G])),Me&&t.jsx(he,{variant:"ghost",size:"sm",disabled:D.loading,"aria-label":c("session.githubIssuePicker.actions.refresh"),title:c("session.githubIssuePicker.actions.refresh"),onClick:()=>{D.refresh()},children:t.jsx(V,{name:"refresh",className:"size-4"})})]}),N.length>0&&t.jsxs(he,{variant:"ghost",size:"sm",onClick:bn,className:je("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:O.size>0?c("diffView.actions.collapseAll"):c("diffView.actions.expandAll"),children:[t.jsx(V,{name:"expand-up-down",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:O.size>0?c("diffView.actions.collapseAll"):c("diffView.actions.expandAll")})]}),N.length>0&&Ge&&t.jsxs(he,{variant:"default",size:"sm",onClick:()=>ze(!0),disabled:Ve,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":c("diffView.actions.reviewAria"),children:[Ve?t.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(V,{name:"search-eye",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:c("diffView.actions.review")})]}),N.length>0&&X&&t.jsxs(he,{variant:"outline",size:"sm",onClick:()=>{const n=f??"";xe(n,a==="pr"&&Me?Me:a==="commit"&&Ie?{kind:"commit",hash:Ie}:a==="branch"&&Re&&G?{kind:"branch",baseRef:Re,headRef:G}:{kind:"working-tree",scope:a==="staged"||a==="working"?a:"all"}),ge(d??n,"walkthrough")},className:je("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",hs),"aria-label":c("walkthrough.action.open"),children:[t.jsx(V,{name:"route",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:c("walkthrough.action.open")})]}),N.length>0&&a!=="pr"&&t.jsxs(Zn,{children:[t.jsx(es,{asChild:!0,children:t.jsx(he,{variant:"ghost",size:"sm",onClick:()=>Qe(n=>!n),"aria-pressed":re,"aria-label":c(re?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles"),className:je("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",re&&"bg-interactive-selection text-interactive-selection-foreground"),children:t.jsx(V,{name:"file-download",className:"size-4"})})}),t.jsx(ts,{children:t.jsx("p",{children:c(re?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles")})})]}),N.length>0&&t.jsx(he,{variant:"ghost",size:"sm",onClick:()=>Ke(!tt),className:je("h-5 w-5 p-0 transition-opacity",st?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:c(st?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:t.jsx(V,{name:"text-wrap",className:"size-4"})}),At&&t.jsx(Wt,{mode:At==="side-by-side"?"side-by-side":"unified",onModeChange:Sn})]}),t.jsx(ns,{open:Oe,onOpenChange:ze,projectDirectory:f??null,submitting:Ve,onConfirm:jn}),Rn()]})};export{Yi as DiffView,Ts as MultiFileDiffEntry};
4
+ `),h=Math.min(s.length,u.length);for(let m=0;m<h;m+=1)if(s[m]!==u[m])return m+1;return u.length>s.length?s.length+1:s.length>u.length?Math.max(1,u.length):1},Fs=o=>Array.isArray(o)?o.filter(e=>!e||typeof e!="object"?!1:typeof e.file=="string"):[],Ds=o=>o==="added"?"A":o==="deleted"?"D":"M",yt=(o,e,s)=>Pn(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:s}:{original:"",modified:"",patch:e,fileDiff:In(o,e),contextMode:s},Zt=(o,e,s)=>{const u=o??0,h=e??0;return!u&&!h?null:t.jsxs("span",{className:je("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",s?.className),children:[u?t.jsxs("span",{style:{color:"var(--status-success)"},children:["+",u]}):null,h?t.jsxs("span",{style:{color:"var(--status-error)"},children:["-",h]}):null]})},As=i.memo(o=>{const e=Ye.c(68),{scope:s,workingCount:u,stagedCount:h,turnCount:m,branchCount:x,commitCount:j,prCount:C,showCommitOption:c,showBranchOption:w,onScopeChange:v}=o,{t:d}=Ie(),[E,b]=i.useState(!1),_=s==="pr"?C??0:s==="staged"?h:s==="turn"?m:s==="branch"?x??0:s==="commit"?j??0:u;let I;e[0]!==s||e[1]!==d?(I=d(s==="pr"?"session.githubIntegration.tabs.pullRequests":s==="staged"?"diffView.scope.staged":s==="turn"?"diffView.scope.lastTurn":s==="branch"?"diffView.scope.branch":s==="commit"?"commitComparison.mode":"diffView.scope.changed"),e[0]=s,e[1]=d,e[2]=I):I=e[2];const f=I;let ge;e[3]!==d?(ge=d("diffView.scope.selectorAria"),e[3]=d,e[4]=ge):ge=e[4];let xe;e[5]!==_?(xe=t.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",_]}),e[5]=_,e[6]=xe):xe=e[6];let Y;e[7]!==f||e[8]!==xe?(Y=t.jsxs("span",{className:"whitespace-nowrap",children:[f,xe]}),e[7]=f,e[8]=xe,e[9]=Y):Y=e[9];let F;e[10]===Symbol.for("react.memo_cache_sentinel")?(F=t.jsx(V,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=F):F=e[10];let L;e[11]!==ge||e[12]!==Y?(L=t.jsx(is,{asChild:!0,children:t.jsxs("button",{type:"button",className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring","aria-label":ge,children:[Y,F]})}),e[11]=ge,e[12]=Y,e[13]=L):L=e[13];let S;e[14]!==v?(S=J=>{(J==="working"||J==="staged"||J==="turn"||J==="branch"||J==="commit"||J==="pr")&&(v?.(J),b(!1))},e[14]=v,e[15]=S):S=e[15];let te;e[16]!==d?(te=d("diffView.scope.changed"),e[16]=d,e[17]=te):te=e[17];let ne;e[18]!==te?(ne=t.jsx("span",{children:te}),e[18]=te,e[19]=ne):ne=e[19];let ce;e[20]!==u?(ce=t.jsx("span",{className:"typography-meta text-muted-foreground",children:u}),e[20]=u,e[21]=ce):ce=e[21];let se;e[22]!==ce||e[23]!==ne?(se=t.jsx(Ue,{value:"working",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[ne,ce]})}),e[22]=ce,e[23]=ne,e[24]=se):se=e[24];let ue;e[25]!==d?(ue=d("diffView.scope.staged"),e[25]=d,e[26]=ue):ue=e[26];let Q;e[27]!==ue?(Q=t.jsx("span",{children:ue}),e[27]=ue,e[28]=Q):Q=e[28];let W;e[29]!==h?(W=t.jsx("span",{className:"typography-meta text-muted-foreground",children:h}),e[29]=h,e[30]=W):W=e[30];let fe;e[31]!==Q||e[32]!==W?(fe=t.jsx(Ue,{value:"staged",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[Q,W]})}),e[31]=Q,e[32]=W,e[33]=fe):fe=e[33];let T;e[34]!==d?(T=d("diffView.scope.lastTurn"),e[34]=d,e[35]=T):T=e[35];let A;e[36]!==T?(A=t.jsx("span",{children:T}),e[36]=T,e[37]=A):A=e[37];let $;e[38]!==m?($=t.jsx("span",{className:"typography-meta text-muted-foreground",children:m}),e[38]=m,e[39]=$):$=e[39];let H;e[40]!==A||e[41]!==$?(H=t.jsx(Ue,{value:"turn",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[A,$]})}),e[40]=A,e[41]=$,e[42]=H):H=e[42];let de;e[43]!==x||e[44]!==w||e[45]!==d?(de=w?t.jsx(Ue,{value:"branch",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:d("diffView.scope.branch")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:x??"…"})]})}):null,e[43]=x,e[44]=w,e[45]=d,e[46]=de):de=e[46];let U;e[47]!==j||e[48]!==c||e[49]!==d?(U=c&&t.jsx(Ue,{value:"commit",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:d("commitComparison.mode")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:j??"…"})]})}),e[47]=j,e[48]=c,e[49]=d,e[50]=U):U=e[50];let z;e[51]!==C||e[52]!==c||e[53]!==d?(z=c&&t.jsx(Ue,{value:"pr",children:t.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[t.jsx("span",{children:d("session.githubIntegration.tabs.pullRequests")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:C??"…"})]})}),e[51]=C,e[52]=c,e[53]=d,e[54]=z):z=e[54];let q;e[55]!==s||e[56]!==se||e[57]!==fe||e[58]!==H||e[59]!==de||e[60]!==U||e[61]!==z||e[62]!==S?(q=t.jsx(os,{align:"start",className:"w-40",children:t.jsxs(as,{value:s,onValueChange:S,children:[se,fe,H,de,U,z]})}),e[55]=s,e[56]=se,e[57]=fe,e[58]=H,e[59]=de,e[60]=U,e[61]=z,e[62]=S,e[63]=q):q=e[63];let ve;return e[64]!==E||e[65]!==q||e[66]!==L?(ve=t.jsxs(ls,{open:E,onOpenChange:b,children:[L,q]}),e[64]=E,e[65]=q,e[66]=L,e[67]=ve):ve=e[67],ve}),Vs=i.memo(o=>{const e=Ye.c(11),{changedFiles:s,selectedFile:u,onSelectFile:h}=o,{t:m}=Ie();if(s.length===0)return null;let x;if(e[0]!==s||e[1]!==h||e[2]!==u||e[3]!==m){let C;e[5]!==h||e[6]!==u||e[7]!==m?(C=c=>{const w=Qt(c),v=u===c.path;return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>h(c.path),className:je("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",v?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[t.jsx(Ut,{filePath:c.path,className:"h-3.5 w-3.5 flex-shrink-0"}),t.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:w.color},title:m(w.descriptionKey),"aria-label":m(w.descriptionKey),children:w.code}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:c.path,children:c.path}),Zt(c.insertions,c.deletions)]})},c.path)},e[5]=h,e[6]=u,e[7]=m,e[8]=C):C=e[8],x=s.map(C),e[0]=s,e[1]=h,e[2]=u,e[3]=m,e[4]=x}else x=e[4];let j;return e[9]!==x?(j=t.jsx(Jt,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:t.jsx("ul",{className:"flex flex-col gap-1",children:x})}),e[9]=x,e[10]=j):j=e[10],j}),Es=i.memo(o=>{const e=Ye.c(20),{filePath:s,diff:u,renderSideBySide:h}=o,{t:m}=Ie(),x=u.original.length>0,j=u.modified.length>0,C=h?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",c=h?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={contain:"layout"},e[0]=w):w=e[0];let v;e[1]!==u.original||e[2]!==s||e[3]!==x||e[4]!==c||e[5]!==h||e[6]!==m?(v=x&&t.jsxs("div",{className:c,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:m("diffView.image.original")}),t.jsx("img",{src:u.original,alt:m("diffView.image.originalAlt",{path:s}),className:h?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=u.original,e[2]=s,e[3]=x,e[4]=c,e[5]=h,e[6]=m,e[7]=v):v=e[7];let d;e[8]!==u.modified||e[9]!==s||e[10]!==j||e[11]!==x||e[12]!==c||e[13]!==h||e[14]!==m?(d=j&&t.jsxs("div",{className:c,children:[t.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:m(x?"diffView.image.modified":"diffView.image.new")}),t.jsx("img",{src:u.modified,alt:m("diffView.image.modifiedAlt",{path:s}),className:h?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=u.modified,e[9]=s,e[10]=j,e[11]=x,e[12]=c,e[13]=h,e[14]=m,e[15]=d):d=e[15];let E;return e[16]!==C||e[17]!==v||e[18]!==d?(E=t.jsx("div",{className:"w-full overflow-auto p-4",style:w,children:t.jsxs("div",{className:C,children:[v,d]})}),e[16]=C,e[17]=v,e[18]=d,e[19]=E):E=e[19],E}),Ls=i.memo(o=>{const e=Ye.c(17),{filePath:s,diff:u,renderSideBySide:h,wrapLines:m,hunkActions:x}=o;let j;e[0]!==s?(j=rs(s)||"text",e[0]=s,e[1]=j):j=e[1];const C=j;if(u.isBinary){let v;return e[2]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(Ss,{}),e[2]=v):v=e[2],v}if(Xe(s)){let v;return e[3]!==u||e[4]!==s||e[5]!==h?(v=t.jsx(Es,{filePath:s,diff:u,renderSideBySide:h}),e[3]=u,e[4]=s,e[5]=h,e[6]=v):v=e[6],v}let c;e[7]===Symbol.for("react.memo_cache_sentinel")?(c={contain:"layout"},e[7]=c):c=e[7];let w;return e[8]!==u.fileDiff||e[9]!==u.modified||e[10]!==u.original||e[11]!==s||e[12]!==x||e[13]!==C||e[14]!==h||e[15]!==m?(w=t.jsx("div",{className:"w-full",style:c,children:t.jsx(fs,{original:u.original,modified:u.modified,fileDiff:u.fileDiff,language:C,fileName:s,renderSideBySide:h,wrapLines:m,layout:"inline",hunkActions:x})}),e[8]=u.fileDiff,e[9]=u.modified,e[10]=u.original,e[11]=s,e[12]=x,e[13]=C,e[14]=h,e[15]=m,e[16]=w):w=e[16],w}),Ts=i.memo(({visible:o=!0,directory:e,file:s,layout:u,wrapLines:h,isSelected:m,isExpanded:x,isMounted:j,onSelect:C,onExpandedChange:c,registerSectionRef:w,showOpenInEditorAction:v=!1,isOpeningInEditor:d=!1,onOpenInEditor:E,staged:b=!1,loadFullFiles:_=!1,initialDiffData:I=null,comparisonDiff:f,onRetryComparisonDiff:ge,readOnlyActions:xe=!1,hunkActionsEnabled:Y=!1})=>{const{t:F}=Ie(),{git:L}=$t(),S=ee(i.useCallback(g=>g.directories.get(e)?.diffCache.get(s.path)??null,[e,s.path])),te=ee(g=>g.setDiff),ne=ee(g=>g.fetchStatus),ce=le(g=>g.setDiffFileLayout),[se,ue]=i.useState(0),[Q,W]=i.useState(null),[fe,T]=i.useState(!1),A=f?f.status==="error"?f.message:null:Q,$=f?f.status==="loading":fe,[H,de]=i.useState(null),U=i.useRef(!1),[z,q]=i.useState(null),[ve,J]=i.useState(!1),[re,Qe]=i.useState(null),[it,Ae]=i.useState(null),ye=i.useRef(null),ut=i.useRef(null),ze=i.useMemo(()=>Qt(s),[s]),Oe=u==="side-by-side",Ve=_?"full":"patch",we=`${s.index}:${s.working_dir}:${s.insertions}:${s.deletions}`,a=Y&&!xe&&!I&&!f&&!Xe(s.path),Se=JSON.stringify([De(),e,s.path,b,we,se]),O=z?.scope===Se?z.patch:null,me=i.useMemo(()=>f?f.status==="ready"?f.data:null:I||(b?it:re||(S?{original:S.original,modified:S.modified,isBinary:S.isBinary,contextMode:"full"}:null)),[f,S,I,re,b,it]),Ne=me?.contextMode===Ve,ot=i.useCallback(g=>{ut.current=g,w(s.path,g)},[s.path,w]),_e=i.useCallback(g=>{c(s.path,g)},[s.path,c]),Ze=i.useCallback(()=>{C(s.path)},[s.path,C]),et=i.useRef({fileStatusKey:we,staged:b});i.useEffect(()=>{if(!o)return;const g=et.current;g.fileStatusKey===we&&g.staged===b||(et.current={fileStatusKey:we,staged:b},b?Ae(null):Qe(null),W(null),ye.current=null)},[we,b,o]),i.useEffect(()=>{if(!o||!x||!j||Q)return;if(!e||f||I||me&&Ne&&(!a||O!==null)){ye.current=null,T(!1);return}const g=`${e}::${s.path}::${b?"staged":"unstaged"}::${we}::${Ve}::${se}`;if(ye.current===g)return;ye.current=g,W(null),T(!0);let M=!1;const ie=De(),Ge=_?Xt:xt,X=Xe(s.path)?L.getGitFileDiff(e,{path:s.path,staged:b}):!_&&O!==null?Promise.resolve({diff:O}):L.getGitDiff(e,{path:s.path,staged:b,contextLines:Ge}),ft=a&&_&&O===null?L.getGitDiff(e,{path:s.path,staged:b,contextLines:xt}).then(R=>R.diff):Promise.resolve(O),Ee=Promise.all([X,ft]),Le=bs;let pe;const K=new Promise((R,oe)=>{pe=setTimeout(()=>oe(new Error(`Timed out after ${Le}ms`)),Le)});return Promise.race([Ee,K]).then(([R,oe])=>{if(M||ie!==De())return;const ke="diff"in R&&!_?R.diff:oe;if(a&&_&&ke!==null&&/^@@\s/m.test(ke)&&"diff"in R&&R.diff!==ke&&!Tn(R.diff,ke))throw q(null),new Error(F("diffView.hunk.unavailable"));if(a&&ke!==null&&q({scope:Se,patch:ke}),"diff"in R){const Ce=yt(s.path,R.diff,Ve);b?Ae(Ce):Qe(Ce)}else{const Ce={original:R.original??"",modified:R.modified??"",isBinary:R.isBinary,contextMode:"full"};b?Ae(Ce):te(e,s.path,Ce,ie)}T(!1)}).catch(R=>{if(M||ie!==De())return;const oe=R instanceof Error?R.message:String(R);W(oe),T(!1)}).finally(()=>clearTimeout(pe)),()=>{M=!0,clearTimeout(pe),ye.current===g&&(ye.current=null)}},[O,a,Se,f,Ve,me,Ne,se,e,s.path,we,L,I,x,j,_,Q,te,b,F,o]);const tt=i.useCallback(()=>{_e(!x),Ze()},[_e,Ze,x]),He=i.useCallback(()=>{W(null),q(null),Qe(null),Ae(null),ye.current=null,ue(g=>g+1)},[]),nt=i.useCallback(async(g,M)=>{if(!e||!a||$||A||U.current||H!==null)return;const ie=O?Mn(O,g):null;if(!ie){Je.error(F("diffView.hunk.unavailable"));return}if(b&&M!=="unstage"||!b&&M==="unstage")return;U.current=!0;const Ge=De();de({index:g,action:M});try{const X=M==="stage"?L.stageGitHunk:M==="unstage"?L.unstageGitHunk:L.revertGitHunk;if(!X){Je.error(F("diffView.hunk.unsupported"));return}if(await X(e,s.path,ie),Ge!==De())return;He(),qt.requestGitRefresh({directory:e,paths:[s.path]}),await ne(e,L)}catch(X){if(Ge!==De())return;He(),Je.error(X instanceof Error&&X.message?X.message:F("diffView.hunk.unavailable"))}finally{U.current=!1,de(X=>X?.index===g&&X.action===M?null:X)}},[O,a,$,A,e,ne,s.path,L,H,He,b,F]),be=i.useMemo(()=>a&&O!==null?Bn(O):[],[O,a]),Ke=i.useCallback(g=>t.jsx(gs,{index:g,staged:b,busyHunk:H,disabled:$||!!A,onAction:nt}),[A,nt,H,$,b]),st=i.useMemo(()=>be.length>0?{anchors:be,render:Ke}:void 0,[be,Ke]);return t.jsxs("div",{ref:ot,className:"scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0",children:[t.jsx("div",{className:"sticky top-0 z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80",children:t.jsxs("div",{role:"button",tabIndex:0,onClick:tt,onKeyDown:g=>{g.target===g.currentTarget&&(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),tt())},className:je("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",m?"bg-[var(--interactive-selection)]/35":null),children:[t.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),t.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:x?t.jsx(V,{name:"arrow-down-s",className:"size-4"}):t.jsx(V,{name:"arrow-right-s",className:"size-4"})}),t.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:ze.color},title:F(ze.descriptionKey),"aria-label":F(ze.descriptionKey),children:ze.code}),t.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:s.path,children:t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ut,{filePath:s.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const g=s.path.lastIndexOf("/");if(g===-1)return t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:s.path});const M=s.path.slice(0,g),ie=s.path.slice(g+1);return t.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[t.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:M}),t.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[t.jsx("span",{className:"text-muted-foreground",children:"/"}),t.jsx("span",{className:"text-foreground",children:ie})]})]})})()]})})]}),t.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[Zt(s.insertions,s.deletions),v&&E?t.jsx(he,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:F("diffView.actions.openFileInEditorAtChange"),onClick:g=>{g.stopPropagation(),E(s.path,me)},disabled:d,children:d?t.jsx(V,{name:"loader-4",className:"size-3.5 animate-spin"}):t.jsx(V,{name:"edit",className:"size-3.5"})}):null,t.jsx(Wt,{mode:Oe?"side-by-side":"unified",onModeChange:g=>{const M=g==="side-by-side"?"side-by-side":"inline";ce(s.path,M)},className:"opacity-70"})]})]})}),x&&t.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!j&&!A?t.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,A?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:F("diffView.state.failedToLoadDiff")}),t.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:A}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>f?ge?.():He(),children:F("diffView.actions.retry")})]}):null,j&&$&&!me&&!A?t.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}),F("diffView.state.loadingDiff")]}):null,j&&me&&!ve&&s.insertions+s.deletions>It?t.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:F("diffView.state.largeDiff",{count:s.insertions+s.deletions})}),t.jsx("div",{className:"typography-meta text-muted-foreground",children:F("diffView.state.largeDiffDescription")}),t.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>J(!0),children:F("diffView.actions.renderAnyway")})]}):null,j&&me&&(ve||s.insertions+s.deletions<=It)?t.jsx(t.Fragment,{children:t.jsx(Ls,{filePath:s.path,diff:me,renderSideBySide:Oe,wrapLines:h,hunkActions:st})}):null]})]})}),Yi=({visible:o=!0,hideStackedFileSidebar:e=!1,stackedDefaultCollapsedAll:s=!1,pinSelectedFileHeaderToTopOnNavigate:u=!1,showOpenInEditorAction:h=!1,diffScope:m="all",onDiffScopeChange:x,targetFilePath:j=null,flushContent:C=!1})=>{const{t:c}=Ie(),{git:w,files:v}=$t(),d=$n(),E=ee(n=>n.runtimeKey),{rootIsGitRepo:b,gitDirectory:_,nestedRepos:I}=qn(d??null,{enabled:o}),f=_??d,ge=le(n=>n.openContextSurface),xe=ds(n=>n.requestSource),{screenWidth:Y,isMobile:F}=Wn(),L=Un(f??null),S=Jn(f??null),te=Xn(f??null),ne=ee(n=>n.setActiveDirectory),ce=ee(n=>n.ensureStatus),se=ee(n=>n.selectNestedRepo),ue=ee(n=>n.fetchStatus),Q=ee(n=>n.fetchBranches),W=ee(n=>n.clearDiffCache),fe=ee(n=>n.setDiff),[T,A]=i.useState(null),[$,H]=i.useState(!1),[de,U]=i.useState(null),[z,q]=i.useState(()=>new Set),[ve,J]=i.useState(()=>new Set),[re,Qe]=i.useState(!1),[it,Ae]=i.useState(0),[ye,ut]=i.useState(()=>new Map),[ze,Oe]=i.useState(!1),[Ve,we]=i.useState(!1),[a,Se]=i.useState(m);i.useEffect(()=>{Se(m)},[m]);const O=le(n=>n.pendingDiffFile),me=le(n=>n.pendingDiffStaged),Ne=le(n=>n.pendingDiffScope),ot=le(n=>n.setPendingDiffFile),_e=le(n=>n.diffLayoutPreference),Ze=le(n=>n.diffFileLayout),et=le(n=>n.setDiffFileLayout),tt=le(n=>n.diffWrapLines),He=le(n=>n.setDiffWrapLines),nt=le(n=>n.openContextFileAtLine),be=Mt(n=>n.currentSessionId),Ke=Yn(a==="turn"?be??"":"",d??void 0),st=tt,g=a==="staged"?!0:a==="working"?!1:null,M=g??$,ie=F||Y<=768,Ge=!!be&&a!=="turn"&&a!=="commit"&&a!=="pr"&&!ie&&!Fe(),X=a!=="turn"&&!ie&&!Fe(),ft=!e&&!ie&&Y>=1024,Ee=i.useRef(null),Le=i.useRef(new Map),pe=i.useRef(null),K=i.useRef(null),R=i.useRef(!1),oe=i.useRef(null),ke=i.useRef(null),Ce=i.useRef(null),dt=i.useRef(null),wt=i.useCallback(()=>{const n=Ee.current;if(!n)return null;const r=n.getBoundingClientRect().top,l=[];for(const[p,y]of Le.current)y&&l.push({path:p,top:y.getBoundingClientRect().top});return Bt(r,l)},[]),$e=i.useCallback(()=>{pe.current=null,R.current=!1,U(null),K.current!==null&&(window.cancelAnimationFrame(K.current),K.current=null)},[]),qe=i.useCallback(n=>{q(r=>{if(r.has(n))return r;const l=new Set(r);return l.add(n),l})},[]),rt=i.useMemo(()=>{for(let n=Ke.length-1;n>=0;n-=1){const r=Ke[n];if(r.role==="user")return Fs(r.summary?.diffs)}return[]},[Ke]),en=i.useMemo(()=>{const n=new Map;for(const r of rt)if(r.file){if(typeof r.patch=="string"){n.set(r.file,yt(r.file,r.patch,"patch"));continue}n.set(r.file,{original:r.before??"",modified:r.after??"",contextMode:"full"})}return n},[rt]),tn=i.useMemo(()=>S?.files?S.files.filter(Ht).length:0,[S]),nn=i.useMemo(()=>S?.files?S.files.filter(_t).length:0,[S]),sn=rt.length,G=S?.current??null,Te=Fn(f??null,G,o&&a==="pr"&&!Fe()),Me=Te.selectedSource,Be=Dn(f??null,G,o&&a==="commit"&&!Fe()),Pe=Be.selectedCommit?.hash??null;i.useEffect(()=>{(a==="commit"||a==="pr")&&Fe()&&(Se("working"),x?.("working"))},[a,x]);const We=ee(n=>f?n.directories.get(f)?.branches??null:null),rn=ee(n=>f?n.directories.get(f)?.isLoadingBranches??!1:!1),on=i.useCallback(()=>{f&&Q(f,w)},[f,Q,w]),an=zn(f??null,o&&L!==!1,rn,!!We,on,vs),bt=i.useMemo(()=>{const n=S?.tracking?.trim().split("/")[0];return(n&&We?.defaultBranches?.[n])??We?.defaultBranches?.origin??null},[We,S?.tracking]),jt=!Fe()&&On(G,bt),ln=S!==null,vt=Fe()||an||_n(G,bt,ln,We!==null),cn=An(n=>n.setOverride),{base:Re,resolved:un,revision:St}=Vn(f??null,G,o&&jt&&a==="branch"),[fn,dn]=i.useState(0);i.useEffect(()=>{const n=Gn(a,!vt);n!==a&&(Se(n),n==="working"&&x?.("working"))},[a,vt,x]);const mn=i.useMemo(()=>a==="pr"?Me:a==="commit"&&Pe?{kind:"commit",hash:Pe}:a==="branch"&&Re&&G?{kind:"branch",baseRef:Re,headRef:G}:null,[a,Re,G,Pe,Me]),D=Hn(f??null,mn,o&&!Fe(),a==="branch"?St:""),{fetchDiff:Nt}=D,kt=a==="commit"?D.files:null,Ct=a==="commit"?D.error:null,at=a==="branch"?D.files:null,Rt=a==="branch"?D.error:null,Ft=D.files?a==="pr"?JSON.stringify([D.key,D.revision]):D.key:null,pn=i.useMemo(()=>a==="branch"||a==="commit"||a==="pr"?Array.from(z).sort().join("\0"):"",[a,z]),hn=i.useCallback(async n=>{try{const r=re&&a!=="pr",l=await Nt(n,r?Xt:xt);return{status:"ready",data:yt(n,l.diff,r?"full":"patch")}}catch(r){return{status:"error",message:r instanceof Error?r.message:c("diffView.state.failedToLoadDiff")}}},[a,Nt,re,c]),gn=Kn(Ft,o?pn:"",Ft?hn:null,Ot,JSON.stringify([a==="branch"?St:"",a==="pr"?D.revision:0,fn,re])),xn=at?.length??null,N=i.useMemo(()=>{if(a==="commit"||a==="pr")return(D.files??[]).map(l=>({path:l.path,index:"",working_dir:l.status,insertions:l.insertions,deletions:l.deletions,isNew:l.status==="A"}));if(a==="branch")return(at??[]).map(l=>({path:l.path,index:"",working_dir:l.status,insertions:0,deletions:0,isNew:l.status==="A"})).sort((l,p)=>l.path.localeCompare(p.path));if(a==="turn")return rt.map(l=>({path:l.file??"",index:"",working_dir:Ds(l.status),insertions:l.additions??0,deletions:l.deletions??0,isNew:l.status==="added"})).filter(l=>l.path).sort((l,p)=>l.path.localeCompare(p.path));if(!S?.files)return[];const n=S.diffStats??{},r=a==="staged"?_t:a==="working"?Ht:()=>!0;return S.files.filter(r).map(l=>({...l,insertions:n[l.path]?.insertions??0,deletions:n[l.path]?.deletions??0,isNew:Cs(l)})).sort((l,p)=>l.path.localeCompare(p.path))},[a,at,D.files,rt,S]),mt=i.useMemo(()=>N.map(n=>n.path).join("\0"),[N]);i.useEffect(()=>{const n=mt?mt.split("\0"):[],r=new Set(n),l=`${f??""}:${a}:${s?"collapsed":"default"}`,p=ke.current!==l;ke.current=l,q(y=>{if(p){const P=s?0:js(n.length);return new Set(n.slice(0,P))}let B=!1;const k=new Set;for(const P of y){if(!r.has(P)){B=!0;continue}k.add(P)}return B?k:y}),J(y=>{if(p)return new Set;let B=!1;const k=new Set;for(const P of y){if(!r.has(P)){B=!0;continue}k.add(P)}return B?k:y})},[a,mt,f,s]);const Dt=i.useCallback(()=>{if(oe.current=null,!o)return;const n=Ee.current;if(!n)return;const r=n.getBoundingClientRect(),l=r.top-zt,p=r.bottom+zt,y={},B=[];for(const[k,P]of Le.current){if(!P)continue;const Z=P.getBoundingClientRect();B.push({path:k,top:Z.top}),z.has(k)&&(Z.bottom<l||Z.top>p||(y[k]=!0))}Ce.current=Bt(r.top,B),J(k=>{let P=!1;const Z=new Set(k);for(const Lt of Object.keys(y))Z.has(Lt)||(Z.add(Lt),P=!0);return P?Z:k})},[z,o]),ae=i.useCallback(()=>{o&&(typeof window>"u"||oe.current===null&&(oe.current=window.requestAnimationFrame(Dt)))},[Dt,o]);i.useEffect(()=>{const n=Ee.current;if(!(!o||!n))return ae(),n.addEventListener("scroll",ae,{passive:!0}),window.addEventListener("resize",ae),()=>{n.removeEventListener("scroll",ae),window.removeEventListener("resize",ae),oe.current!==null&&(window.cancelAnimationFrame(oe.current),oe.current=null)}},[N,z,ae,o]);const pt=i.useCallback(n=>{const r=Ze[n.path];if(r)return r;if(_e==="inline")return"inline";if(_e==="side-by-side")return"side-by-side";const l=Y<ws;return n.isNew||l?"inline":"side-by-side"},[Ze,_e,Y]),At=i.useMemo(()=>N.length===0?null:N.every(n=>pt(n)==="side-by-side")?"side-by-side":"inline",[N,pt]);i.useEffect(()=>{o&&f&&(ne(f),ce(f,w))},[f,ne,ce,w,o]);const lt=JSON.stringify([E,f]),ht=i.useRef({scope:lt,paths:new Set,dirty:!1}),Vt=i.useRef(o);i.useEffect(()=>{const n=o&&!Vt.current;if(Vt.current=o,ht.current.scope!==lt&&(ht.current={scope:lt,paths:new Set,dirty:!1}),!f)return;const r=p=>{p?.length&&(dt.current=wt()??Ce.current,W(f,p),ut(y=>{const B=new Map(y);for(const k of p)B.set(k,(B.get(k)??0)+1);return B})),ue(f,w,{silent:!0})},l=ht.current;return o&&(n||l.dirty)&&(r([...l.paths]),l.paths.clear(),l.dirty=!1),qt.onGitRefreshHint(p=>{if(Kt(p.directory)===Kt(f)){if(!o){l.dirty=!0;for(const y of p.paths??[])l.paths.add(y);return}r(p.paths)}})},[wt,W,f,ue,w,lt,o]),i.useLayoutEffect(()=>{const n=dt.current;if(!n)return;dt.current=null;const r=Ee.current,l=Le.current.get(n.path);if(!r||!l)return;const p=r.getBoundingClientRect().top,y=l.getBoundingClientRect().top-p;r.scrollTop=ys(r.scrollTop,n.topOffset,y,r.scrollHeight-r.clientHeight),Ce.current=n},[ye]),i.useEffect(()=>{!o||a!=="all"&&!Ne||O&&(Ne&&Se(Ne),A(O),H(Ne==="staged"||!Ne&&me),ot(null),R.current=!0,pe.current=O,qe(O),Ae(n=>n+1))},[a,qe,O,Ne,me,ot,o]),i.useEffect(()=>{if(a==="all")return;const n=j?.trim();n&&(A(n),H(a==="staged"),R.current=!0,pe.current=n,qe(n),Ae(r=>r+1))},[a,qe,j]),i.useEffect(()=>{if(!T)return;N.some(r=>r.path===T)||(A(null),H(!1))},[N,T]);const yn=i.useCallback((n,r)=>{const l=Le.current;r?l.set(n,r):l.delete(n),ae()},[ae]),wn=i.useCallback((n,r)=>{$e(),q(l=>{const p=l.has(n);if(r===p)return l;const y=new Set(l);return r?y.add(n):y.delete(n),y}),r||J(l=>{if(!l.has(n))return l;const p=new Set(l);return p.delete(n),p}),ae()},[$e,ae]),bn=i.useCallback(()=>{$e(),q(n=>n.size>0?new Set:new Set(N.map(r=>r.path))),J(new Set),ae()},[$e,N,ae]),jn=i.useCallback(async n=>{if(!be)return;const r=Mt.getState().getDirectoryForSession(be)||d||"";if(!r){Je.error(c("diffView.reviewDialog.toast.noSessionDirectory"));return}we(!0);try{await Qn({originalSessionID:be,directory:r,providerID:n.providerID,modelID:n.modelID,agent:n.agent||void 0,variant:n.variant||void 0,generateHandoff:n.generateHandoff,returnAfterHandoffRequest:n.generateHandoff,autoReview:n.autoReview}),Oe(!1)}catch(l){console.error("[review-flow] failed to start review flow",l),Je.error(l instanceof Error?l.message:c("diffView.reviewDialog.toast.startFailed"))}finally{we(!1)}},[be,d,c]),ct=i.useCallback(n=>{const r=Le.current.get(n),l=Ee.current;if(!r||!l)return!1;const p=r.getBoundingClientRect().top-l.getBoundingClientRect().top;return l.scrollTo({top:l.scrollTop+p,behavior:"auto"}),!0},[]);i.useEffect(()=>{const n=pe.current;if(!o||!n)return;let r=0;const l=20;let p=!1;const y=(k=!0)=>{p||(p=!0,pe.current=null,R.current=!1,k&&U(null),K.current!==null&&(window.cancelAnimationFrame(K.current),K.current=null))},B=()=>{if(p){K.current=null;return}const k=pe.current;if(!k){y(),K.current=null;return}if(!ct(k)){r+=1,r<l?K.current=window.requestAnimationFrame(B):(y(),K.current=null);return}if(u&&R.current){U(k),y(!1);return}y()};return K.current=window.requestAnimationFrame(B),()=>{p=!0,K.current!==null&&(window.cancelAnimationFrame(K.current),K.current=null)}},[u,it,ct,o]);const vn=i.useCallback(n=>{},[]),gt=i.useCallback(n=>{$e(),A(n),H(!1),R.current=!0,pe.current=n,qe(n),Ae(r=>r+1),ct(n)},[$e,qe,ct]);i.useEffect(()=>{const n=r=>{if(!o||!r.altKey||r.metaKey||r.ctrlKey||r.shiftKey||r.key!=="ArrowDown"&&r.key!=="ArrowUp")return;const l=r.target;if(l instanceof HTMLElement&&(l.isContentEditable||l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.closest('[role="dialog"]'))||N.length===0)return;const p=r.key==="ArrowDown"?1:-1,y=T?N.findIndex(P=>P.path===T):-1,B=y===-1?p>0?0:N.length-1:y+p,k=N[B];k&&(r.preventDefault(),gt(k.path))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[N,T,gt,o]);const Sn=i.useCallback(n=>{const r=n==="side-by-side"?"side-by-side":"inline";N.forEach(l=>{et(l.path,r)})},[N,et]),[Nn,Et]=i.useState(null),kn=i.useCallback(async(n,r)=>{if(!f||!n)return;Et(n);const l=De();try{let p=null;if(r?.patch&&!r.isBinary&&!Xe(n)?p=Pt(r.patch):r&&r.contextMode==="full"&&!r.isBinary&&!Xe(n)&&(p=Gt(r.original,r.modified)),p===null)try{const Z=await w.getGitDiff(f,{path:n,staged:M,contextLines:3});p=Pt(Z.diff)}catch{p=null}let y=r;if(p===null||!y){const Z=await w.getGitFileDiff(f,{path:n,staged:M});y={original:Z.original??"",modified:Z.modified??"",isBinary:Z.isBinary},M||fe(f,n,y,l)}const B=p??(y.isBinary||Xe(n)?1:Gt(y.original,y.modified)),k=Rs(f,n),P=await ms(v,k,{directory:f});if(!P.ok){Je.error(ps(P.reason));return}nt(f,k,B,1)}finally{Et(p=>p===n?null:p)}},[M,f,v,w,nt,fe]),Cn=()=>{if(!f)return null;const n=r=>g!==null?g:$&&r===T;return t.jsxs("div",{className:je("flex min-w-0 flex-1 min-h-0 h-full",C?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[ft&&t.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[t.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:c("diffView.section.files")}),t.jsx("span",{className:"typography-meta text-muted-foreground",children:N.length})]}),t.jsx(Vs,{changedFiles:N,selectedFile:null,onSelectFile:gt})]}),t.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:t.jsx(Jt,{ref:Ee,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:t.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:N.map(r=>t.jsx(Ts,{visible:o,directory:f,file:r,layout:pt(r),wrapLines:st,isSelected:!1,isExpanded:z.has(r.path),isMounted:ve.has(r.path)||r.path===de,onSelect:vn,onExpandedChange:wn,registerSectionRef:yn,showOpenInEditorAction:h&&a!=="turn",isOpeningInEditor:Nn===r.path,onOpenInEditor:(l,p)=>{kn(l,p)},staged:n(r.path),loadFullFiles:re&&a!=="pr",readOnlyActions:a==="branch"||a==="commit"||a==="pr",hunkActionsEnabled:a==="all"||a==="working"||a==="staged",comparisonDiff:a==="branch"||a==="commit"||a==="pr"?gn.get(r.path)??Ot:void 0,onRetryComparisonDiff:()=>dn(l=>l+1),initialDiffData:a==="turn"?en.get(r.path)??null:null},`${De()}:${f}:${r.path}:${ye.get(r.path)??0}`))})})})]})},Rn=()=>{if(!f)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:c("diffView.state.selectSessionDirectory")});if(a!=="turn"&&te&&!S)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.state.loadingRepositoryStatus")]});if(a!=="turn"&&L===!1)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:c("diffView.state.notGitRepository")});if(a==="pr"){if(!Me||D.error)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:D.error??Te.error??(Te.loading?c("session.githubPrPicker.loading.pullRequests"):c("pullRequestComparison.select"))}),(D.error||Te.error)&&t.jsx(he,{variant:"outline",size:"sm",onClick:()=>{Me?D.refresh():Te.refresh()},children:c("diffView.actions.retry")}),!Me&&!Te.loading&&t.jsx(Tt,{comparison:Te})]});if(!D.files)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 typography-meta text-muted-foreground",children:[t.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.state.loadingDiff")]})}if(a==="commit"){if(Ct)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:Ct}),t.jsx(he,{variant:"outline",size:"sm",onClick:()=>{D.refresh()},children:c("diffView.actions.retry")})]});if(!Pe&&!Be.loading)return t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:Be.error??c("commitComparison.noCommits")});if(!kt)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.state.loadingDiff")]})}if(a==="branch"){if(!un)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.branch.resolvingBase")]});if(!Re)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(V,{name:"git-branch",className:"size-6 text-muted-foreground"}),t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:c("diffView.branch.noBaseTitle")}),t.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:c("gitView.pr.toast.baseBranchRequired")})]});if(Rt)return t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:c("diffView.branch.loadError")}),t.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:Rt}),t.jsx(he,{variant:"outline",size:"sm",onClick:()=>{D.refresh()},children:c("diffView.actions.retry")})]});if(at===null)return t.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[t.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}),c("diffView.branch.loadingFiles")]})}return N.length===0?t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:a==="turn"?c("diffView.state.noLastTurnChanges"):a==="pr"?c("walkthrough.blocked.emptyDiff.description"):a==="commit"?c("commitComparison.emptyDiff"):a==="branch"&&Re?c("diffView.branch.empty",{base:us(Re)}):c("diffView.state.cleanWorkingTree")}):Cn()};return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[t.jsxs("div",{className:"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[b===!1&&Array.isArray(I)&&I.length>0?t.jsx(cs,{repositories:I,selectedRepository:_??null,onSelectRepository:n=>{d&&se(d,n)},repositoryRoot:d??void 0}):null,!F&&(a!=="all"?t.jsx(As,{scope:a,workingCount:tn,stagedCount:nn,turnCount:sn,branchCount:xn,commitCount:a==="commit"?kt?.length??null:null,prCount:a==="pr"?D.files?.length??null:null,showCommitOption:!Fe(),showBranchOption:jt,onScopeChange:n=>{Se(n),x?.(n)}}):t.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:t.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:te&&!S?c("diffView.state.loadingChanges"):N.length===1?c("diffView.summary.changedFilesSingle",{count:N.length}):c("diffView.summary.changedFilesPlural",{count:N.length})})})),a==="branch"&&t.jsx(En,{branches:We?.all??[],currentBranch:G,base:Re,onSelect:n=>{f&&G&&cn(f,G,n)}},JSON.stringify([f,G])),a==="commit"&&t.jsx(Ln,{commits:Be.commits,selectedHash:Pe,loading:Be.loading,error:Be.error,onSelect:Be.select,onRefresh:()=>{Be.refresh()}},JSON.stringify([f,G])),a==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(Tt,{comparison:Te},JSON.stringify([E,f,G])),Me&&t.jsx(he,{variant:"ghost",size:"sm",disabled:D.loading,"aria-label":c("session.githubIssuePicker.actions.refresh"),title:c("session.githubIssuePicker.actions.refresh"),onClick:()=>{D.refresh()},children:t.jsx(V,{name:"refresh",className:"size-4"})})]}),N.length>0&&t.jsxs(he,{variant:"ghost",size:"sm",onClick:bn,className:je("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:z.size>0?c("diffView.actions.collapseAll"):c("diffView.actions.expandAll"),children:[t.jsx(V,{name:"expand-up-down",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:z.size>0?c("diffView.actions.collapseAll"):c("diffView.actions.expandAll")})]}),N.length>0&&Ge&&t.jsxs(he,{variant:"default",size:"sm",onClick:()=>Oe(!0),disabled:Ve,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":c("diffView.actions.reviewAria"),children:[Ve?t.jsx(V,{name:"loader-4",className:"size-4 animate-spin"}):t.jsx(V,{name:"search-eye",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:c("diffView.actions.review")})]}),N.length>0&&X&&t.jsxs(he,{variant:"outline",size:"sm",onClick:()=>{const n=f??"";xe(n,a==="pr"&&Me?Me:a==="commit"&&Pe?{kind:"commit",hash:Pe}:a==="branch"&&Re&&G?{kind:"branch",baseRef:Re,headRef:G}:{kind:"working-tree",scope:a==="staged"||a==="working"?a:"all"}),ge(d??n,"walkthrough")},className:je("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",hs),"aria-label":c("walkthrough.action.open"),children:[t.jsx(V,{name:"route",className:"size-4"}),t.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:c("walkthrough.action.open")})]}),N.length>0&&a!=="pr"&&t.jsxs(Zn,{children:[t.jsx(es,{asChild:!0,children:t.jsx(he,{variant:"ghost",size:"sm",onClick:()=>Qe(n=>!n),"aria-pressed":re,"aria-label":c(re?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles"),className:je("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",re&&"bg-interactive-selection text-interactive-selection-foreground"),children:t.jsx(V,{name:"file-download",className:"size-4"})})}),t.jsx(ts,{children:t.jsx("p",{children:c(re?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles")})})]}),N.length>0&&t.jsx(he,{variant:"ghost",size:"sm",onClick:()=>He(!tt),className:je("h-5 w-5 p-0 transition-opacity",st?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:c(st?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:t.jsx(V,{name:"text-wrap",className:"size-4"})}),At&&t.jsx(Wt,{mode:At==="side-by-side"?"side-by-side":"unified",onModeChange:Sn})]}),t.jsx(ns,{open:ze,onOpenChange:Oe,projectDirectory:f??null,submitting:Ve,onConfirm:jn}),Rn()]})};export{Yi as DiffView,Ts as MultiFileDiffEntry};
@@ -1 +1 @@
1
- import{R as N,f as oe,j as s}from"./vendor-react-BUCujlKS.js";import{u as ze}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{f as J,aw as Ee,a9 as be,aa as ye,I as E,ab as we,h as Z,B as Y,a4 as Te,hn as Ie,bN as fe,bO as ue,bP as pe,bQ as ge,bR as xe,bS as ve,bd as Me,c9 as Re,t as ae}from"./useAppFontEffects-B6OfEypo.js";import{u as ke}from"./index-BD8ILbxF.js";const Se={"?":{code:"?",color:"var(--status-info)",description:"Untracked file"},A:{code:"A",color:"var(--status-success)",description:"New file"},D:{code:"D",color:"var(--status-error)",description:"Deleted file"},R:{code:"R",color:"var(--status-info)",description:"Renamed file"},C:{code:"C",color:"var(--status-info)",description:"Copied file"},M:{code:"M",color:"var(--status-warning)",description:"Modified file"}},Pe=Se.M;function Fe(p){const e=p.index?.trim(),t=p.working_dir?.trim();return e&&e!=="?"?e.charAt(0):t?t.charAt(0):e?.charAt(0)||t?.charAt(0)||"M"}function He(p){const e=Fe(p);return Se[e]??Pe}const $e=N.memo(function(e){const t=oe.c(58),{file:r,actionLabel:w,actionSymbol:x,onAction:g,onViewDiff:d,onRevert:a,isReverting:h,stats:S,rowPaddingClassName:f,indentPx:b,actionAtStart:V,showRevert:k}=e,v=b===void 0?0:b,o=V===void 0?!1:V,j=k===void 0?!0:k;let c;t[0]!==r?(c=He(r),t[0]=r,t[1]=c):c=t[1];const u=c,{t:I}=J(),H=u.description,P=S?.insertions??0,A=S?.deletions??0;let z;t[2]!==g||t[3]!==d?(z=U=>{U.key===" "?(U.preventDefault(),g()):U.key==="Enter"&&(U.preventDefault(),d())},t[2]=g,t[3]=d,t[4]=z):z=t[4];const T=z;let M;t[5]!==g?(M=U=>{U.preventDefault(),U.stopPropagation(),g()},t[5]=g,t[6]=M):M=t[6];const y=M;let $;t[7]!==a?($=U=>{U.preventDefault(),U.stopPropagation(),a()},t[7]=a,t[8]=$):$=t[8];const W=$;let L;t[9]!==w||t[10]!==x||t[11]!==y?(L=s.jsx("button",{type:"button",onClick:y,className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":w,title:w,children:x}),t[9]=w,t[10]=x,t[11]=y,t[12]=L):L=t[12];const F=L,X=`group flex items-center gap-2 py-1.5 cursor-pointer ${f??"px-3"}`;let R;t[13]!==v?(R=v>0?{paddingLeft:`${v}px`}:void 0,t[13]=v,t[14]=R):R=t[14];const q=o?F:null;let K;t[15]!==u.color?(K={color:u.color},t[15]=u.color,t[16]=K):K=t[16];let O;t[17]!==u.code||t[18]!==H||t[19]!==K?(O=s.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:K,title:H,"aria-label":H,children:u.code}),t[17]=u.code,t[18]=H,t[19]=K,t[20]=O):O=t[20];let G;t[21]!==r.path?(G=s.jsx(Ee,{filePath:r.path,className:"h-3.5 w-3.5 shrink-0"}),t[21]=r.path,t[22]=G):G=t[22];let _;if(t[23]!==r.path){e:{const U=r.path.lastIndexOf("/");if(U===-1){let ne;t[25]===Symbol.for("react.memo_cache_sentinel")?(ne={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[25]=ne):ne=t[25],_=s.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:ne,title:r.path,children:r.path});break e}const Ae=r.path.slice(0,U),De=r.path.slice(U);let te;t[26]===Symbol.for("react.memo_cache_sentinel")?(te={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[26]=te):te=t[26];let se;t[27]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx("span",{className:"text-muted-foreground",children:"/"}),t[27]=se):se=t[27];const ce=s.jsx("span",{className:"text-foreground",children:De.slice(1)});let ie;t[28]!==ce?(ie=s.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[se,ce]}),t[28]=ce,t[29]=ie):ie=t[29],_=s.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:r.path,children:[s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:te,children:Ae}),ie]})}t[23]=r.path,t[24]=_}else _=t[24];let Q;t[30]===Symbol.for("react.memo_cache_sentinel")?(Q={color:"var(--status-success)"},t[30]=Q):Q=t[30];let i;t[31]!==P?(i=s.jsxs("span",{style:Q,children:["+",P]}),t[31]=P,t[32]=i):i=t[32];let n,l;t[33]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),l={color:"var(--status-error)"},t[33]=n,t[34]=l):(n=t[33],l=t[34]);let m;t[35]!==A?(m=s.jsxs("span",{style:l,children:["-",A]}),t[35]=A,t[36]=m):m=t[36];let D;t[37]!==i||t[38]!==m?(D=s.jsxs("span",{className:"shrink-0 typography-micro",children:[i,n,m]}),t[37]=i,t[38]=m,t[39]=D):D=t[39];let C;t[40]!==r.path||t[41]!==W||t[42]!==h||t[43]!==j||t[44]!==I?(C=j?s.jsxs(be,{children:[s.jsx(ye,{asChild:!0,children:s.jsx("button",{type:"button",onClick:W,disabled:h,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50","aria-label":I("gitView.changes.revertFileAria",{path:r.path}),children:h?s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(E,{name:"arrow-go-back",className:"size-3.5"})})}),s.jsx(we,{sideOffset:8,children:I("gitView.changes.revertFileTooltip")})]}):null,t[40]=r.path,t[41]=W,t[42]=h,t[43]=j,t[44]=I,t[45]=C):C=t[45];const B=o?null:F;let ee;return t[46]!==T||t[47]!==d||t[48]!==R||t[49]!==q||t[50]!==O||t[51]!==G||t[52]!==_||t[53]!==D||t[54]!==C||t[55]!==B||t[56]!==X?(ee=s.jsxs("div",{className:X,role:"button",tabIndex:0,onClick:d,onKeyDown:T,style:R,children:[q,O,G,_,D,C,B]}),t[46]=T,t[47]=d,t[48]=R,t[49]=q,t[50]=O,t[51]=G,t[52]=_,t[53]=D,t[54]=C,t[55]=B,t[56]=X,t[57]=ee):ee=t[57],ee}),je=14,Ve=p=>p.replace(/\\/g,"/").replace(/^\/+/,"").trim(),Ne=(p,e)=>({id:`dir:${p}`,path:p,name:e,children:new Map,directFiles:[],files:[]}),Le=p=>{const e=Ne("","");for(const t of p){const r=Ve(t.path);if(!r)continue;const x=r.split("/").filter(Boolean).slice(0,-1);let g=e;if(g.files.push(t),x.length>0){let d="";for(const a of x){d=d?`${d}/${a}`:a;const h=g.children.get(a);if(h){h.files.push(t),g=h;continue}const S=Ne(d,a);S.files.push(t),g.children.set(a,S),g=S}}g.directFiles.push(t)}return e},Oe=(p,e)=>{const t=[],r=(w,x)=>{const g=Array.from(w.children.values()).sort((a,h)=>a.path.localeCompare(h.path));for(const a of g)t.push({key:a.id,kind:"directory",depth:x,directory:a}),e.has(a.path)&&r(a,x+1);const d=[...w.directFiles].sort((a,h)=>a.path.localeCompare(h.path));for(const a of d)t.push({key:`file:${Ve(a.path)}`,kind:"file",depth:x,file:a})};return r(p,0),t},Ge=1e3,Ce=34,de=30,le="pl-0 pr-2",me=(p,e)=>`${p} ${e}`,Qe=({groups:p,diffStats:e,revertingPaths:t,isRevertingAll:r=!1,headerBackgroundClassName:w="bg-sidebar",onVisiblePathsChange:x,onRevertAll:g,onRevertDirectory:d})=>{const{t:a}=J(),h=N.useRef(null),f=ke(i=>i.gitChangesViewMode)==="tree",b=N.useMemo(()=>p.filter(i=>i.entries.length>0),[p]),[V,k]=N.useState(new Set),[v,o]=N.useState(new Set),[j,c]=N.useState(!1),[u,I]=N.useState(null),H=N.useMemo(()=>b.map(i=>Le(i.entries)),[b]),P=N.useMemo(()=>{const i=[];return b.forEach((n,l)=>{Array.from(H[l]?.children.values()??[]).forEach(m=>{i.push(me(n.id,m.path))})}),i},[H,b]);N.useEffect(()=>{f&&o(i=>{const n=new Set,l=new Set(P);return i.forEach(m=>{(m.slice(m.indexOf(" ")+1).includes("/")||l.has(m))&&n.add(m)}),P.forEach(m=>n.add(m)),n})},[f,P]);const A=N.useMemo(()=>{const i=[];return b.forEach((n,l)=>{if(i.push({type:"header",key:`header:${n.id}`,groupIndex:l}),!V.has(n.id)){if(f){const m=new Set;v.forEach(C=>{C.startsWith(`${n.id} `)&&m.add(C.slice(n.id.length+1))}),Oe(H[l],m).forEach(C=>{C.kind==="file"?i.push({type:"file",key:`${n.id}:${C.key}`,groupIndex:l,file:C.file,depth:C.depth}):i.push({type:"directory",key:`${n.id}:${C.key}`,groupIndex:l,directory:C.directory,depth:C.depth})});return}n.entries.forEach(m=>{i.push({type:"file",key:`${n.id}:file:${m.path}`,groupIndex:l,file:m,depth:0})})}}),g&&b.length>0&&i.push({type:"revert-all",key:"revert-all"}),i},[V,v,f,g,H,b]),z=A.length,T=z>=Ge,M=ze({count:z,enabled:T,getScrollElement:()=>h.current,estimateSize:()=>Ce,overscan:12,getItemKey:i=>A[i]?.key??i}),y=M.getVirtualItems(),$=N.useMemo(()=>{if(!T)return 0;const i=h.current?.scrollTop??0;return y.find(l=>l.end>i)?.index??0},[T,y,h]);N.useEffect(()=>{if(!x)return;const i=n=>n&&n.type==="file"?n.file.path:null;if(z===0){x([]);return}if(!T){const n=[];for(const l of A)if(l.type==="file"&&(n.push(l.file.path),n.length>=de))break;x(n);return}x(A.slice($,$+Math.ceil((h.current?.clientHeight??0)/Ce)+de).map(n=>i(n)).filter(n=>!!n).slice(0,de))},[x,z,A,T,$]);const W=N.useCallback(i=>{k(n=>{const l=new Set(n);return l.has(i)?l.delete(i):l.add(i),l})},[]),L=N.useCallback((i,n)=>{o(l=>{const m=new Set(l),D=me(i,n);return m.has(D)?m.delete(D):m.add(D),m})},[]),F=N.useMemo(()=>{const i=new Set;return b.forEach(n=>n.entries.forEach(l=>i.add(l.path))),Array.from(i)},[b]),X=F.length,R=u?r||u.paths.some(i=>t.has(i)):!1,q=N.useCallback(async()=>{!g||r||F.length===0||(await g(F),c(!1))},[F,r,g]),K=N.useCallback(async()=>{!d||!u||R||(await d(u.paths),I(null))},[R,d,u]),O=N.useCallback((i,n)=>{const l=V.has(i.id),m=i.entries.length;return s.jsxs("div",{className:Z("sticky top-0 z-10 flex items-center gap-2 py-2",w,le,!n&&"mt-1 border-t border-border/40"),children:[s.jsx("button",{type:"button",onClick:()=>i.onActionAll(i.entries.map(D=>D.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":i.actionAllLabel,title:i.actionAllLabel,children:i.actionSymbol}),s.jsxs("button",{type:"button",onClick:()=>W(i.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-expanded":!l,children:[s.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:i.title}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:m}),s.jsx(E,{name:"arrow-down-s",className:Z("size-3.5 shrink-0 text-muted-foreground transition-transform",l&&"-rotate-90")})]})]})},[V,w,W]),G=N.useCallback((i,n,l)=>{const m=v.has(me(i.id,n.path)),D=n.files.map(B=>B.path),C=r||D.some(B=>t.has(B));return s.jsxs("div",{className:Z("group flex items-center gap-2 py-1.5",le),style:{paddingLeft:`${l*je}px`},children:[s.jsxs("button",{type:"button",onClick:()=>L(i.id,n.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":m?a("gitView.changes.collapseDirectoryAria",{path:n.path}):a("gitView.changes.expandDirectoryAria",{path:n.path}),children:[m?s.jsx(E,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):s.jsx(E,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:n.path,children:n.name}),s.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:n.files.length})]}),i.showRevertActions!==!1&&d?s.jsx("button",{type:"button",onClick:()=>I({path:n.path,paths:D,count:D.length}),disabled:C,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":a("gitView.changes.revertDirectoryAria",{path:n.path}),title:a("gitView.changes.revertDirectoryTooltip"),children:C?s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(E,{name:"arrow-go-back",className:"size-3.5"})}):null,s.jsx("button",{type:"button",onClick:()=>i.onActionAll(n.files.map(B=>B.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":a(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),title:a(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),children:i.actionSymbol})]})},[v,r,d,t,a,L]),_=N.useCallback((i,n)=>{if(i.type==="revert-all")return s.jsx("div",{className:Z("flex justify-end py-2",le),children:s.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>c(!0),disabled:r,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[s.jsx(E,{name:"arrow-go-back",className:"size-3.5"}),a("gitView.changes.revertAll")]})});const l=b[i.groupIndex];if(!l)return null;if(i.type==="header")return O(l,n);if(i.type==="directory")return G(l,i.directory,i.depth);const m=i.file;return s.jsx($e,{file:m,actionLabel:l.getActionLabel(m.path),actionSymbol:l.actionSymbol,onAction:()=>l.onActionFile(m.path),stats:e?.[m.path],onViewDiff:()=>l.onViewDiff(m.path),onRevert:()=>l.onRevertFile(m.path),isReverting:t.has(m.path)||r,rowPaddingClassName:le,indentPx:i.depth*je,actionAtStart:!f,showRevert:l.showRevertActions!==!1})},[e,r,f,G,O,t,a,b]),Q=N.useCallback(i=>{const n=A[i],l=A[i-1];return!n||!l||n.type!=="file"&&n.type!=="directory"||l.type!=="file"&&l.type!=="directory"?!1:l.groupIndex===n.groupIndex},[A]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[s.jsx(Te,{ref:h,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:T?s.jsx("div",{style:{height:M.getTotalSize(),position:"relative"},children:y.map(i=>{const n=A[i.index];return n?s.jsx("div",{"data-index":i.index,ref:M.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${i.start}px)`},className:Z(Q(i.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:_(n,i.index===0)},n.key):null})}):s.jsx("div",{role:"list","aria-label":a("gitView.changes.changedFilesAria"),children:A.map((i,n)=>s.jsx("div",{className:Z("relative",Q(n)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:_(i,n===0)},i.key))})}),s.jsx(Ie,{containerRef:h,disableHorizontal:!0})]}),s.jsx(fe,{open:j,onOpenChange:i=>{!r&&!i&&c(!1)},children:s.jsxs(ue,{className:"max-w-md",children:[s.jsxs(pe,{children:[s.jsx(ge,{children:a("gitView.changes.revertAllDialogTitle")}),s.jsx(xe,{children:X===1?a("gitView.changes.revertAllDescriptionSingle",{count:X}):a("gitView.changes.revertAllDescriptionPlural",{count:X})})]}),s.jsxs(ve,{children:[s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>c(!1),disabled:r,children:a("gitView.common.cancel")}),s.jsx(Y,{variant:"destructive",size:"sm",onClick:()=>{q()},disabled:r,children:a(r?"gitView.changes.reverting":"gitView.changes.revertAll")})]})]})}),s.jsx(fe,{open:!!u,onOpenChange:i=>{!R&&!i&&I(null)},children:s.jsxs(ue,{className:"max-w-md",children:[s.jsxs(pe,{children:[s.jsx(ge,{children:a("gitView.changes.revertDirectoryDialogTitle")}),s.jsx(xe,{children:u?u.count===1?a("gitView.changes.revertDirectoryDescriptionSingle",{count:u.count,path:u.path}):a("gitView.changes.revertDirectoryDescriptionPlural",{count:u.count,path:u.path}):null})]}),s.jsxs(ve,{children:[s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>I(null),disabled:R,children:a("gitView.common.cancel")}),s.jsx(Y,{variant:"destructive",size:"sm",onClick:()=>{K()},disabled:R||!u,children:a(R?"gitView.changes.reverting":"gitView.changes.revertDirectory")})]})]})})]})},he=38,re=200,Ke=p=>{const e=oe.c(23),{value:t,onChange:r,onSubmit:w,placeholder:x,disabled:g,hasTouchInput:d,isMobile:a}=p,h=g===void 0?!1:g,S=d===void 0?!1:d,f=a===void 0?!1:a,{t:b}=J(),V=N.useRef(null),k=ke(_e);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{const y=V.current;if(!y)return;const $=document.activeElement===y,W=()=>{y.style.height=`${he}px`;const F=y.scrollHeight,X=Math.min(Math.max(F,he),re);y.style.height=`${X}px`,y.style.overflowY=F>re?"auto":"hidden",F>re&&!$&&(y.scrollTop=y.scrollHeight)};W();const L=window.requestAnimationFrame(W);return()=>{window.cancelAnimationFrame(L)}},e[0]=v):v=e[0];let o;e[1]!==t?(o=[t],e[1]=t,e[2]=o):o=e[2],N.useLayoutEffect(v,o);let j;e[3]!==r?(j=y=>r(y.target.value),e[3]=r,e[4]=j):j=e[4];let c;e[5]!==w?(c=y=>{y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&!y.shiftKey&&!y.altKey&&(y.preventDefault(),w?.())},e[5]=w,e[6]=c):c=e[6];let u;e[7]!==x||e[8]!==b?(u=x??b("gitView.commit.messagePlaceholder"),e[7]=x,e[8]=b,e[9]=u):u=e[9];const I=S?"on":"off",H=S?"sentences":"off",P=f||k,A=h&&"opacity-50";let z;e[10]!==A?(z=Z("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",A),e[10]=A,e[11]=z):z=e[11];let T;e[12]===Symbol.for("react.memo_cache_sentinel")?(T={minHeight:he,maxHeight:re},e[12]=T):T=e[12];let M;return e[13]!==h||e[14]!==H||e[15]!==P||e[16]!==z||e[17]!==j||e[18]!==c||e[19]!==u||e[20]!==I||e[21]!==t?(M=s.jsx("textarea",{ref:V,value:t,onChange:j,onKeyDown:c,placeholder:u,rows:1,disabled:h,autoCorrect:I,autoCapitalize:H,spellCheck:P,className:z,style:T}),e[13]=h,e[14]=H,e[15]=P,e[16]=z,e[17]=j,e[18]=c,e[19]=u,e[20]=I,e[21]=t,e[22]=M):M=e[22],M};function _e(p){return p.inputSpellcheckEnabled}const Be=p=>{const e=oe.c(30),{highlights:t,onInsert:r}=p,{t:w}=J();if(t.length===0)return null;let x;e[0]!==t||e[1]!==r?(x=()=>{r(t)},e[0]=t,e[1]=r,e[2]=x):x=e[2];const g=x;let d;e[3]!==w?(d=w("gitView.commit.aiHighlights.title"),e[3]=w,e[4]=d):d=e[4];let a;e[5]!==d?(a=s.jsx("p",{className:"typography-micro text-muted-foreground",children:d}),e[5]=d,e[6]=a):a=e[6];let h;e[7]!==w?(h=w("gitView.commit.aiHighlights.insertAria"),e[7]=w,e[8]=h):h=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(E,{name:"arrow-down",className:"size-4"}),e[9]=S):S=e[9];let f;e[10]!==g||e[11]!==h?(f=s.jsx(ye,{asChild:!0,children:s.jsx(Y,{variant:"ghost",size:"icon",className:"size-6",onClick:g,"aria-label":h,children:S})}),e[10]=g,e[11]=h,e[12]=f):f=e[12];let b;e[13]!==w?(b=w("gitView.commit.aiHighlights.insertTooltip"),e[13]=w,e[14]=b):b=e[14];let V;e[15]!==b?(V=s.jsx(we,{sideOffset:8,children:b}),e[15]=b,e[16]=V):V=e[16];let k;e[17]!==f||e[18]!==V?(k=s.jsxs(be,{children:[f,V]}),e[17]=f,e[18]=V,e[19]=k):k=e[19];let v;e[20]!==a||e[21]!==k?(v=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a,k]}),e[20]=a,e[21]=k,e[22]=v):v=e[22];let o;e[23]!==t?(o=t.map(Ue),e[23]=t,e[24]=o):o=e[24];let j;e[25]!==o?(j=s.jsx("ul",{className:"space-y-1",children:o}),e[25]=o,e[26]=j):j=e[26];let c;return e[27]!==v||e[28]!==j?(c=s.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[v,j]}),e[27]=v,e[28]=j,e[29]=c):c=e[29],c};function Ue(p,e){return s.jsx("li",{className:"typography-meta text-foreground",children:p},`${p}-${e}`)}const Ze=p=>{const e=oe.c(80),{stagedCount:t,commitMessage:r,onCommitMessageChange:w,generatedHighlights:x,onInsertHighlights:g,onGenerateMessage:d,isGeneratingMessage:a,onCommit:h,onCommitAndPush:S,commitAction:f,hasPendingIndexMutation:b,gitmojiEnabled:V,onOpenGitmojiPicker:k}=p,v=b===void 0?!1:b,{t:o}=J(),j=t>0;let c;e[0]!==f||e[1]!==r||e[2]!==v||e[3]!==j?(c=r.trim()&&j&&f===null&&!v,e[0]=f,e[1]=r,e[2]=v,e[3]=j,e[4]=c):c=e[4];const u=c,{isMobile:I,hasTouchInput:H}=Me();let P;e[5]!==o?(P=o("gitView.commit.title"),e[5]=o,e[6]=P):P=e[6];let A;e[7]!==P?(A=s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:P}),e[7]=P,e[8]=A):A=e[8];let z;e[9]!==j||e[10]!==o?(z=j?null:s.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:o("gitView.commit.stageFilesHint")}),e[9]=j,e[10]=o,e[11]=z):z=e[11];let T;e[12]!==A||e[13]!==z?(T=s.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[A,z]}),e[12]=A,e[13]=z,e[14]=T):T=e[14];let M;e[15]!==x||e[16]!==g?(M=s.jsx(Be,{highlights:x,onInsert:g}),e[15]=x,e[16]=g,e[17]=M):M=e[17];let y;e[18]!==u||e[19]!==a||e[20]!==h?(y=()=>{u&&!a&&h()},e[18]=u,e[19]=a,e[20]=h,e[21]=y):y=e[21];let $;e[22]!==o?($=o("gitView.commit.messagePlaceholder"),e[22]=o,e[23]=$):$=e[23];const W=f!==null;let L;e[24]!==r||e[25]!==H||e[26]!==I||e[27]!==w||e[28]!==W||e[29]!==y||e[30]!==$?(L=s.jsx(Ke,{value:r,onChange:w,onSubmit:y,placeholder:$,disabled:W,hasTouchInput:H,isMobile:I}),e[24]=r,e[25]=H,e[26]=I,e[27]=w,e[28]=W,e[29]=y,e[30]=$,e[31]=L):L=e[31];let F;e[32]!==V||e[33]!==k||e[34]!==o?(F=V&&s.jsxs(Y,{variant:"outline",size:"sm",onClick:k,className:"w-fit",type:"button",children:[s.jsx(E,{name:"emotion-happy",className:"size-4"}),o("gitView.commit.addGitmoji")]}),e[32]=V,e[33]=k,e[34]=o,e[35]=F):F=e[35];const X=a||f!==null||v||t===0;let R;e[36]!==o?(R=o("gitView.commit.generateAria"),e[36]=o,e[37]=R):R=e[37];let q;e[38]!==a?(q=a?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4 text-primary"}),e[38]=a,e[39]=q):q=e[39];let K;e[40]!==o?(K=o("gitView.commit.generate"),e[40]=o,e[41]=K):K=e[41];let O;e[42]!==K?(O=s.jsx("span",{className:"commit-actions__label",children:K}),e[42]=K,e[43]=O):O=e[43];let G;e[44]!==d||e[45]!==X||e[46]!==R||e[47]!==q||e[48]!==O?(G=s.jsxs(Y,{variant:"outline",size:"sm",onClick:d,disabled:X,type:"button","aria-label":R,className:"commit-actions__btn",children:[q,O]}),e[44]=d,e[45]=X,e[46]=R,e[47]=q,e[48]=O,e[49]=G):G=e[49];let _;e[50]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx("div",{className:"flex-1"}),e[50]=_):_=e[50];const Q=!u||a;let i;e[51]!==o?(i=o("gitView.commit.commitAria"),e[51]=o,e[52]=i):i=e[52];let n;e[53]!==f||e[54]!==o?(n=f==="commit"?s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.committing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"git-commit",className:"size-4"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.commit")})]}),e[53]=f,e[54]=o,e[55]=n):n=e[55];let l;e[56]!==h||e[57]!==Q||e[58]!==i||e[59]!==n?(l=s.jsx(Y,{size:"sm",variant:"outline",onClick:h,disabled:Q,className:"commit-actions__btn whitespace-nowrap","aria-label":i,children:n}),e[56]=h,e[57]=Q,e[58]=i,e[59]=n,e[60]=l):l=e[60];let m;e[61]!==u||e[62]!==f||e[63]!==a||e[64]!==I||e[65]!==S||e[66]!==o?(m=I?s.jsxs(be,{children:[s.jsx(ye,{asChild:!0,children:s.jsx(Y,{variant:"default",size:"sm",onClick:()=>S(),disabled:!u||a,className:"h-7 w-7 p-0","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"arrow-up",className:"size-3.5"})})}),s.jsx(we,{side:"top",children:s.jsx("p",{children:o("gitView.commit.push")})})]}):s.jsx(Y,{size:"sm",variant:"default",onClick:()=>S(),disabled:!u||a,className:"commit-actions__btn","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.pushing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"arrow-up",className:"size-3.5"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.push")})]})}),e[61]=u,e[62]=f,e[63]=a,e[64]=I,e[65]=S,e[66]=o,e[67]=m):m=e[67];let D;e[68]!==G||e[69]!==l||e[70]!==m?(D=s.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[G,_,l,m]}),e[68]=G,e[69]=l,e[70]=m,e[71]=D):D=e[71];let C;e[72]!==L||e[73]!==F||e[74]!==D||e[75]!==M?(C=s.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[M,L,F,D]}),e[72]=L,e[73]=F,e[74]=D,e[75]=M,e[76]=C):C=e[76];let B;return e[77]!==C||e[78]!==T?(B=s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[T,C]}),e[77]=C,e[78]=T,e[79]=B):B=e[79],B},Je=({open:p,onOpenChange:e,targetBranch:t,changedFileCount:r,onCommitAndSwitch:w,onGenerateMessage:x,onRevertAndSwitch:g})=>{const{t:d}=J(),[a,h]=N.useState(""),[S,f]=N.useState(null),[b,V]=N.useState(!1),k=S!==null;N.useEffect(()=>{p||(h(""),V(!1))},[p]);const v=async()=>{f("generate");try{const c=await x();c&&h(c)}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}},o=async()=>{f("commit");try{let c=a.trim();if(!c){if(c=(await x()).trim(),!c){ae.error(d("gitView.toast.enterCommitMessage"));return}h(c)}await w(c,b)}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}},j=async()=>{f("revert");try{await g()}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}};return s.jsx(fe,{open:p,onOpenChange:c=>{k||e(c)},children:s.jsx(ue,{className:"max-w-md w-[calc(100vw-2rem)]",children:s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsxs(pe,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(E,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),s.jsx(ge,{children:d("gitView.dirtySwitch.title")})]}),s.jsx(xe,{children:r===1?d("gitView.dirtySwitch.descriptionSingle",{branch:t}):d("gitView.dirtySwitch.descriptionPlural",{branch:t,count:r})})]}),s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border/60 px-3 py-2 focus-within:border-border",children:[s.jsx("input",{value:a,onChange:c=>h(c.target.value),placeholder:d("gitView.commit.messagePlaceholder"),disabled:k,onKeyDown:c=>{c.key==="Enter"&&!k&&(c.preventDefault(),o())},className:"min-w-0 flex-1 bg-transparent typography-meta text-foreground outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"button",onClick:()=>{v()},disabled:k,"aria-label":d("gitView.commit.generate"),title:d("gitView.commit.generate"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:S==="generate"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4 text-primary"})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Re,{checked:b,onChange:V,disabled:k,ariaLabel:d("gitView.dirtySwitch.pushAfterCommit")}),s.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!k&&V(!b),children:d("gitView.dirtySwitch.pushAfterCommit")})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[s.jsxs(Y,{variant:"destructive",size:"sm",onClick:()=>{j()},disabled:k,className:"gap-2",children:[S==="revert"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):null,d("gitView.dirtySwitch.revertAndSwitch")]}),s.jsxs(Y,{variant:"default",size:"sm",onClick:()=>{o()},disabled:k,className:"gap-2",children:[S==="commit"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):null,d("gitView.dirtySwitch.commitAndSwitch")]})]})]})})})};export{Qe as C,Je as D,Ze as a};
1
+ import{R as N,f as oe,j as s}from"./vendor-react-BUCujlKS.js";import{u as ze}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{f as J,aw as Ee,a9 as be,aa as ye,I as E,ab as we,h as Z,B as Y,a4 as Te,ho as Ie,bO as fe,bP as ue,bQ as pe,bR as ge,bS as xe,bT as ve,be as Me,ca as Re,t as ae}from"./useAppFontEffects-cYK1WODe.js";import{u as ke}from"./index-BvwlOZOg.js";const Se={"?":{code:"?",color:"var(--status-info)",description:"Untracked file"},A:{code:"A",color:"var(--status-success)",description:"New file"},D:{code:"D",color:"var(--status-error)",description:"Deleted file"},R:{code:"R",color:"var(--status-info)",description:"Renamed file"},C:{code:"C",color:"var(--status-info)",description:"Copied file"},M:{code:"M",color:"var(--status-warning)",description:"Modified file"}},Pe=Se.M;function Fe(p){const e=p.index?.trim(),t=p.working_dir?.trim();return e&&e!=="?"?e.charAt(0):t?t.charAt(0):e?.charAt(0)||t?.charAt(0)||"M"}function He(p){const e=Fe(p);return Se[e]??Pe}const $e=N.memo(function(e){const t=oe.c(58),{file:r,actionLabel:w,actionSymbol:x,onAction:g,onViewDiff:d,onRevert:a,isReverting:h,stats:S,rowPaddingClassName:f,indentPx:b,actionAtStart:V,showRevert:k}=e,v=b===void 0?0:b,o=V===void 0?!1:V,j=k===void 0?!0:k;let c;t[0]!==r?(c=He(r),t[0]=r,t[1]=c):c=t[1];const u=c,{t:I}=J(),H=u.description,P=S?.insertions??0,A=S?.deletions??0;let z;t[2]!==g||t[3]!==d?(z=U=>{U.key===" "?(U.preventDefault(),g()):U.key==="Enter"&&(U.preventDefault(),d())},t[2]=g,t[3]=d,t[4]=z):z=t[4];const T=z;let M;t[5]!==g?(M=U=>{U.preventDefault(),U.stopPropagation(),g()},t[5]=g,t[6]=M):M=t[6];const y=M;let $;t[7]!==a?($=U=>{U.preventDefault(),U.stopPropagation(),a()},t[7]=a,t[8]=$):$=t[8];const W=$;let L;t[9]!==w||t[10]!==x||t[11]!==y?(L=s.jsx("button",{type:"button",onClick:y,className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":w,title:w,children:x}),t[9]=w,t[10]=x,t[11]=y,t[12]=L):L=t[12];const F=L,X=`group flex items-center gap-2 py-1.5 cursor-pointer ${f??"px-3"}`;let R;t[13]!==v?(R=v>0?{paddingLeft:`${v}px`}:void 0,t[13]=v,t[14]=R):R=t[14];const q=o?F:null;let K;t[15]!==u.color?(K={color:u.color},t[15]=u.color,t[16]=K):K=t[16];let O;t[17]!==u.code||t[18]!==H||t[19]!==K?(O=s.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:K,title:H,"aria-label":H,children:u.code}),t[17]=u.code,t[18]=H,t[19]=K,t[20]=O):O=t[20];let G;t[21]!==r.path?(G=s.jsx(Ee,{filePath:r.path,className:"h-3.5 w-3.5 shrink-0"}),t[21]=r.path,t[22]=G):G=t[22];let _;if(t[23]!==r.path){e:{const U=r.path.lastIndexOf("/");if(U===-1){let ne;t[25]===Symbol.for("react.memo_cache_sentinel")?(ne={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[25]=ne):ne=t[25],_=s.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:ne,title:r.path,children:r.path});break e}const Ae=r.path.slice(0,U),De=r.path.slice(U);let te;t[26]===Symbol.for("react.memo_cache_sentinel")?(te={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[26]=te):te=t[26];let se;t[27]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx("span",{className:"text-muted-foreground",children:"/"}),t[27]=se):se=t[27];const ce=s.jsx("span",{className:"text-foreground",children:De.slice(1)});let ie;t[28]!==ce?(ie=s.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[se,ce]}),t[28]=ce,t[29]=ie):ie=t[29],_=s.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:r.path,children:[s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:te,children:Ae}),ie]})}t[23]=r.path,t[24]=_}else _=t[24];let Q;t[30]===Symbol.for("react.memo_cache_sentinel")?(Q={color:"var(--status-success)"},t[30]=Q):Q=t[30];let i;t[31]!==P?(i=s.jsxs("span",{style:Q,children:["+",P]}),t[31]=P,t[32]=i):i=t[32];let n,l;t[33]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),l={color:"var(--status-error)"},t[33]=n,t[34]=l):(n=t[33],l=t[34]);let m;t[35]!==A?(m=s.jsxs("span",{style:l,children:["-",A]}),t[35]=A,t[36]=m):m=t[36];let D;t[37]!==i||t[38]!==m?(D=s.jsxs("span",{className:"shrink-0 typography-micro",children:[i,n,m]}),t[37]=i,t[38]=m,t[39]=D):D=t[39];let C;t[40]!==r.path||t[41]!==W||t[42]!==h||t[43]!==j||t[44]!==I?(C=j?s.jsxs(be,{children:[s.jsx(ye,{asChild:!0,children:s.jsx("button",{type:"button",onClick:W,disabled:h,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50","aria-label":I("gitView.changes.revertFileAria",{path:r.path}),children:h?s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(E,{name:"arrow-go-back",className:"size-3.5"})})}),s.jsx(we,{sideOffset:8,children:I("gitView.changes.revertFileTooltip")})]}):null,t[40]=r.path,t[41]=W,t[42]=h,t[43]=j,t[44]=I,t[45]=C):C=t[45];const B=o?null:F;let ee;return t[46]!==T||t[47]!==d||t[48]!==R||t[49]!==q||t[50]!==O||t[51]!==G||t[52]!==_||t[53]!==D||t[54]!==C||t[55]!==B||t[56]!==X?(ee=s.jsxs("div",{className:X,role:"button",tabIndex:0,onClick:d,onKeyDown:T,style:R,children:[q,O,G,_,D,C,B]}),t[46]=T,t[47]=d,t[48]=R,t[49]=q,t[50]=O,t[51]=G,t[52]=_,t[53]=D,t[54]=C,t[55]=B,t[56]=X,t[57]=ee):ee=t[57],ee}),je=14,Ve=p=>p.replace(/\\/g,"/").replace(/^\/+/,"").trim(),Ne=(p,e)=>({id:`dir:${p}`,path:p,name:e,children:new Map,directFiles:[],files:[]}),Le=p=>{const e=Ne("","");for(const t of p){const r=Ve(t.path);if(!r)continue;const x=r.split("/").filter(Boolean).slice(0,-1);let g=e;if(g.files.push(t),x.length>0){let d="";for(const a of x){d=d?`${d}/${a}`:a;const h=g.children.get(a);if(h){h.files.push(t),g=h;continue}const S=Ne(d,a);S.files.push(t),g.children.set(a,S),g=S}}g.directFiles.push(t)}return e},Oe=(p,e)=>{const t=[],r=(w,x)=>{const g=Array.from(w.children.values()).sort((a,h)=>a.path.localeCompare(h.path));for(const a of g)t.push({key:a.id,kind:"directory",depth:x,directory:a}),e.has(a.path)&&r(a,x+1);const d=[...w.directFiles].sort((a,h)=>a.path.localeCompare(h.path));for(const a of d)t.push({key:`file:${Ve(a.path)}`,kind:"file",depth:x,file:a})};return r(p,0),t},Ge=1e3,Ce=34,de=30,le="pl-0 pr-2",me=(p,e)=>`${p} ${e}`,Qe=({groups:p,diffStats:e,revertingPaths:t,isRevertingAll:r=!1,headerBackgroundClassName:w="bg-sidebar",onVisiblePathsChange:x,onRevertAll:g,onRevertDirectory:d})=>{const{t:a}=J(),h=N.useRef(null),f=ke(i=>i.gitChangesViewMode)==="tree",b=N.useMemo(()=>p.filter(i=>i.entries.length>0),[p]),[V,k]=N.useState(new Set),[v,o]=N.useState(new Set),[j,c]=N.useState(!1),[u,I]=N.useState(null),H=N.useMemo(()=>b.map(i=>Le(i.entries)),[b]),P=N.useMemo(()=>{const i=[];return b.forEach((n,l)=>{Array.from(H[l]?.children.values()??[]).forEach(m=>{i.push(me(n.id,m.path))})}),i},[H,b]);N.useEffect(()=>{f&&o(i=>{const n=new Set,l=new Set(P);return i.forEach(m=>{(m.slice(m.indexOf(" ")+1).includes("/")||l.has(m))&&n.add(m)}),P.forEach(m=>n.add(m)),n})},[f,P]);const A=N.useMemo(()=>{const i=[];return b.forEach((n,l)=>{if(i.push({type:"header",key:`header:${n.id}`,groupIndex:l}),!V.has(n.id)){if(f){const m=new Set;v.forEach(C=>{C.startsWith(`${n.id} `)&&m.add(C.slice(n.id.length+1))}),Oe(H[l],m).forEach(C=>{C.kind==="file"?i.push({type:"file",key:`${n.id}:${C.key}`,groupIndex:l,file:C.file,depth:C.depth}):i.push({type:"directory",key:`${n.id}:${C.key}`,groupIndex:l,directory:C.directory,depth:C.depth})});return}n.entries.forEach(m=>{i.push({type:"file",key:`${n.id}:file:${m.path}`,groupIndex:l,file:m,depth:0})})}}),g&&b.length>0&&i.push({type:"revert-all",key:"revert-all"}),i},[V,v,f,g,H,b]),z=A.length,T=z>=Ge,M=ze({count:z,enabled:T,getScrollElement:()=>h.current,estimateSize:()=>Ce,overscan:12,getItemKey:i=>A[i]?.key??i}),y=M.getVirtualItems(),$=N.useMemo(()=>{if(!T)return 0;const i=h.current?.scrollTop??0;return y.find(l=>l.end>i)?.index??0},[T,y,h]);N.useEffect(()=>{if(!x)return;const i=n=>n&&n.type==="file"?n.file.path:null;if(z===0){x([]);return}if(!T){const n=[];for(const l of A)if(l.type==="file"&&(n.push(l.file.path),n.length>=de))break;x(n);return}x(A.slice($,$+Math.ceil((h.current?.clientHeight??0)/Ce)+de).map(n=>i(n)).filter(n=>!!n).slice(0,de))},[x,z,A,T,$]);const W=N.useCallback(i=>{k(n=>{const l=new Set(n);return l.has(i)?l.delete(i):l.add(i),l})},[]),L=N.useCallback((i,n)=>{o(l=>{const m=new Set(l),D=me(i,n);return m.has(D)?m.delete(D):m.add(D),m})},[]),F=N.useMemo(()=>{const i=new Set;return b.forEach(n=>n.entries.forEach(l=>i.add(l.path))),Array.from(i)},[b]),X=F.length,R=u?r||u.paths.some(i=>t.has(i)):!1,q=N.useCallback(async()=>{!g||r||F.length===0||(await g(F),c(!1))},[F,r,g]),K=N.useCallback(async()=>{!d||!u||R||(await d(u.paths),I(null))},[R,d,u]),O=N.useCallback((i,n)=>{const l=V.has(i.id),m=i.entries.length;return s.jsxs("div",{className:Z("sticky top-0 z-10 flex items-center gap-2 py-2",w,le,!n&&"mt-1 border-t border-border/40"),children:[s.jsx("button",{type:"button",onClick:()=>i.onActionAll(i.entries.map(D=>D.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":i.actionAllLabel,title:i.actionAllLabel,children:i.actionSymbol}),s.jsxs("button",{type:"button",onClick:()=>W(i.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-expanded":!l,children:[s.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:i.title}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:m}),s.jsx(E,{name:"arrow-down-s",className:Z("size-3.5 shrink-0 text-muted-foreground transition-transform",l&&"-rotate-90")})]})]})},[V,w,W]),G=N.useCallback((i,n,l)=>{const m=v.has(me(i.id,n.path)),D=n.files.map(B=>B.path),C=r||D.some(B=>t.has(B));return s.jsxs("div",{className:Z("group flex items-center gap-2 py-1.5",le),style:{paddingLeft:`${l*je}px`},children:[s.jsxs("button",{type:"button",onClick:()=>L(i.id,n.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":m?a("gitView.changes.collapseDirectoryAria",{path:n.path}):a("gitView.changes.expandDirectoryAria",{path:n.path}),children:[m?s.jsx(E,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):s.jsx(E,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:n.path,children:n.name}),s.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:n.files.length})]}),i.showRevertActions!==!1&&d?s.jsx("button",{type:"button",onClick:()=>I({path:n.path,paths:D,count:D.length}),disabled:C,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":a("gitView.changes.revertDirectoryAria",{path:n.path}),title:a("gitView.changes.revertDirectoryTooltip"),children:C?s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(E,{name:"arrow-go-back",className:"size-3.5"})}):null,s.jsx("button",{type:"button",onClick:()=>i.onActionAll(n.files.map(B=>B.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":a(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),title:a(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),children:i.actionSymbol})]})},[v,r,d,t,a,L]),_=N.useCallback((i,n)=>{if(i.type==="revert-all")return s.jsx("div",{className:Z("flex justify-end py-2",le),children:s.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>c(!0),disabled:r,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[s.jsx(E,{name:"arrow-go-back",className:"size-3.5"}),a("gitView.changes.revertAll")]})});const l=b[i.groupIndex];if(!l)return null;if(i.type==="header")return O(l,n);if(i.type==="directory")return G(l,i.directory,i.depth);const m=i.file;return s.jsx($e,{file:m,actionLabel:l.getActionLabel(m.path),actionSymbol:l.actionSymbol,onAction:()=>l.onActionFile(m.path),stats:e?.[m.path],onViewDiff:()=>l.onViewDiff(m.path),onRevert:()=>l.onRevertFile(m.path),isReverting:t.has(m.path)||r,rowPaddingClassName:le,indentPx:i.depth*je,actionAtStart:!f,showRevert:l.showRevertActions!==!1})},[e,r,f,G,O,t,a,b]),Q=N.useCallback(i=>{const n=A[i],l=A[i-1];return!n||!l||n.type!=="file"&&n.type!=="directory"||l.type!=="file"&&l.type!=="directory"?!1:l.groupIndex===n.groupIndex},[A]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[s.jsx(Te,{ref:h,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:T?s.jsx("div",{style:{height:M.getTotalSize(),position:"relative"},children:y.map(i=>{const n=A[i.index];return n?s.jsx("div",{"data-index":i.index,ref:M.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${i.start}px)`},className:Z(Q(i.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:_(n,i.index===0)},n.key):null})}):s.jsx("div",{role:"list","aria-label":a("gitView.changes.changedFilesAria"),children:A.map((i,n)=>s.jsx("div",{className:Z("relative",Q(n)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:_(i,n===0)},i.key))})}),s.jsx(Ie,{containerRef:h,disableHorizontal:!0})]}),s.jsx(fe,{open:j,onOpenChange:i=>{!r&&!i&&c(!1)},children:s.jsxs(ue,{className:"max-w-md",children:[s.jsxs(pe,{children:[s.jsx(ge,{children:a("gitView.changes.revertAllDialogTitle")}),s.jsx(xe,{children:X===1?a("gitView.changes.revertAllDescriptionSingle",{count:X}):a("gitView.changes.revertAllDescriptionPlural",{count:X})})]}),s.jsxs(ve,{children:[s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>c(!1),disabled:r,children:a("gitView.common.cancel")}),s.jsx(Y,{variant:"destructive",size:"sm",onClick:()=>{q()},disabled:r,children:a(r?"gitView.changes.reverting":"gitView.changes.revertAll")})]})]})}),s.jsx(fe,{open:!!u,onOpenChange:i=>{!R&&!i&&I(null)},children:s.jsxs(ue,{className:"max-w-md",children:[s.jsxs(pe,{children:[s.jsx(ge,{children:a("gitView.changes.revertDirectoryDialogTitle")}),s.jsx(xe,{children:u?u.count===1?a("gitView.changes.revertDirectoryDescriptionSingle",{count:u.count,path:u.path}):a("gitView.changes.revertDirectoryDescriptionPlural",{count:u.count,path:u.path}):null})]}),s.jsxs(ve,{children:[s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>I(null),disabled:R,children:a("gitView.common.cancel")}),s.jsx(Y,{variant:"destructive",size:"sm",onClick:()=>{K()},disabled:R||!u,children:a(R?"gitView.changes.reverting":"gitView.changes.revertDirectory")})]})]})})]})},he=38,re=200,Ke=p=>{const e=oe.c(23),{value:t,onChange:r,onSubmit:w,placeholder:x,disabled:g,hasTouchInput:d,isMobile:a}=p,h=g===void 0?!1:g,S=d===void 0?!1:d,f=a===void 0?!1:a,{t:b}=J(),V=N.useRef(null),k=ke(_e);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{const y=V.current;if(!y)return;const $=document.activeElement===y,W=()=>{y.style.height=`${he}px`;const F=y.scrollHeight,X=Math.min(Math.max(F,he),re);y.style.height=`${X}px`,y.style.overflowY=F>re?"auto":"hidden",F>re&&!$&&(y.scrollTop=y.scrollHeight)};W();const L=window.requestAnimationFrame(W);return()=>{window.cancelAnimationFrame(L)}},e[0]=v):v=e[0];let o;e[1]!==t?(o=[t],e[1]=t,e[2]=o):o=e[2],N.useLayoutEffect(v,o);let j;e[3]!==r?(j=y=>r(y.target.value),e[3]=r,e[4]=j):j=e[4];let c;e[5]!==w?(c=y=>{y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&!y.shiftKey&&!y.altKey&&(y.preventDefault(),w?.())},e[5]=w,e[6]=c):c=e[6];let u;e[7]!==x||e[8]!==b?(u=x??b("gitView.commit.messagePlaceholder"),e[7]=x,e[8]=b,e[9]=u):u=e[9];const I=S?"on":"off",H=S?"sentences":"off",P=f||k,A=h&&"opacity-50";let z;e[10]!==A?(z=Z("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",A),e[10]=A,e[11]=z):z=e[11];let T;e[12]===Symbol.for("react.memo_cache_sentinel")?(T={minHeight:he,maxHeight:re},e[12]=T):T=e[12];let M;return e[13]!==h||e[14]!==H||e[15]!==P||e[16]!==z||e[17]!==j||e[18]!==c||e[19]!==u||e[20]!==I||e[21]!==t?(M=s.jsx("textarea",{ref:V,value:t,onChange:j,onKeyDown:c,placeholder:u,rows:1,disabled:h,autoCorrect:I,autoCapitalize:H,spellCheck:P,className:z,style:T}),e[13]=h,e[14]=H,e[15]=P,e[16]=z,e[17]=j,e[18]=c,e[19]=u,e[20]=I,e[21]=t,e[22]=M):M=e[22],M};function _e(p){return p.inputSpellcheckEnabled}const Be=p=>{const e=oe.c(30),{highlights:t,onInsert:r}=p,{t:w}=J();if(t.length===0)return null;let x;e[0]!==t||e[1]!==r?(x=()=>{r(t)},e[0]=t,e[1]=r,e[2]=x):x=e[2];const g=x;let d;e[3]!==w?(d=w("gitView.commit.aiHighlights.title"),e[3]=w,e[4]=d):d=e[4];let a;e[5]!==d?(a=s.jsx("p",{className:"typography-micro text-muted-foreground",children:d}),e[5]=d,e[6]=a):a=e[6];let h;e[7]!==w?(h=w("gitView.commit.aiHighlights.insertAria"),e[7]=w,e[8]=h):h=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(E,{name:"arrow-down",className:"size-4"}),e[9]=S):S=e[9];let f;e[10]!==g||e[11]!==h?(f=s.jsx(ye,{asChild:!0,children:s.jsx(Y,{variant:"ghost",size:"icon",className:"size-6",onClick:g,"aria-label":h,children:S})}),e[10]=g,e[11]=h,e[12]=f):f=e[12];let b;e[13]!==w?(b=w("gitView.commit.aiHighlights.insertTooltip"),e[13]=w,e[14]=b):b=e[14];let V;e[15]!==b?(V=s.jsx(we,{sideOffset:8,children:b}),e[15]=b,e[16]=V):V=e[16];let k;e[17]!==f||e[18]!==V?(k=s.jsxs(be,{children:[f,V]}),e[17]=f,e[18]=V,e[19]=k):k=e[19];let v;e[20]!==a||e[21]!==k?(v=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a,k]}),e[20]=a,e[21]=k,e[22]=v):v=e[22];let o;e[23]!==t?(o=t.map(Ue),e[23]=t,e[24]=o):o=e[24];let j;e[25]!==o?(j=s.jsx("ul",{className:"space-y-1",children:o}),e[25]=o,e[26]=j):j=e[26];let c;return e[27]!==v||e[28]!==j?(c=s.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[v,j]}),e[27]=v,e[28]=j,e[29]=c):c=e[29],c};function Ue(p,e){return s.jsx("li",{className:"typography-meta text-foreground",children:p},`${p}-${e}`)}const Ze=p=>{const e=oe.c(80),{stagedCount:t,commitMessage:r,onCommitMessageChange:w,generatedHighlights:x,onInsertHighlights:g,onGenerateMessage:d,isGeneratingMessage:a,onCommit:h,onCommitAndPush:S,commitAction:f,hasPendingIndexMutation:b,gitmojiEnabled:V,onOpenGitmojiPicker:k}=p,v=b===void 0?!1:b,{t:o}=J(),j=t>0;let c;e[0]!==f||e[1]!==r||e[2]!==v||e[3]!==j?(c=r.trim()&&j&&f===null&&!v,e[0]=f,e[1]=r,e[2]=v,e[3]=j,e[4]=c):c=e[4];const u=c,{isMobile:I,hasTouchInput:H}=Me();let P;e[5]!==o?(P=o("gitView.commit.title"),e[5]=o,e[6]=P):P=e[6];let A;e[7]!==P?(A=s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:P}),e[7]=P,e[8]=A):A=e[8];let z;e[9]!==j||e[10]!==o?(z=j?null:s.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:o("gitView.commit.stageFilesHint")}),e[9]=j,e[10]=o,e[11]=z):z=e[11];let T;e[12]!==A||e[13]!==z?(T=s.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[A,z]}),e[12]=A,e[13]=z,e[14]=T):T=e[14];let M;e[15]!==x||e[16]!==g?(M=s.jsx(Be,{highlights:x,onInsert:g}),e[15]=x,e[16]=g,e[17]=M):M=e[17];let y;e[18]!==u||e[19]!==a||e[20]!==h?(y=()=>{u&&!a&&h()},e[18]=u,e[19]=a,e[20]=h,e[21]=y):y=e[21];let $;e[22]!==o?($=o("gitView.commit.messagePlaceholder"),e[22]=o,e[23]=$):$=e[23];const W=f!==null;let L;e[24]!==r||e[25]!==H||e[26]!==I||e[27]!==w||e[28]!==W||e[29]!==y||e[30]!==$?(L=s.jsx(Ke,{value:r,onChange:w,onSubmit:y,placeholder:$,disabled:W,hasTouchInput:H,isMobile:I}),e[24]=r,e[25]=H,e[26]=I,e[27]=w,e[28]=W,e[29]=y,e[30]=$,e[31]=L):L=e[31];let F;e[32]!==V||e[33]!==k||e[34]!==o?(F=V&&s.jsxs(Y,{variant:"outline",size:"sm",onClick:k,className:"w-fit",type:"button",children:[s.jsx(E,{name:"emotion-happy",className:"size-4"}),o("gitView.commit.addGitmoji")]}),e[32]=V,e[33]=k,e[34]=o,e[35]=F):F=e[35];const X=a||f!==null||v||t===0;let R;e[36]!==o?(R=o("gitView.commit.generateAria"),e[36]=o,e[37]=R):R=e[37];let q;e[38]!==a?(q=a?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4 text-primary"}),e[38]=a,e[39]=q):q=e[39];let K;e[40]!==o?(K=o("gitView.commit.generate"),e[40]=o,e[41]=K):K=e[41];let O;e[42]!==K?(O=s.jsx("span",{className:"commit-actions__label",children:K}),e[42]=K,e[43]=O):O=e[43];let G;e[44]!==d||e[45]!==X||e[46]!==R||e[47]!==q||e[48]!==O?(G=s.jsxs(Y,{variant:"outline",size:"sm",onClick:d,disabled:X,type:"button","aria-label":R,className:"commit-actions__btn",children:[q,O]}),e[44]=d,e[45]=X,e[46]=R,e[47]=q,e[48]=O,e[49]=G):G=e[49];let _;e[50]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx("div",{className:"flex-1"}),e[50]=_):_=e[50];const Q=!u||a;let i;e[51]!==o?(i=o("gitView.commit.commitAria"),e[51]=o,e[52]=i):i=e[52];let n;e[53]!==f||e[54]!==o?(n=f==="commit"?s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.committing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"git-commit",className:"size-4"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.commit")})]}),e[53]=f,e[54]=o,e[55]=n):n=e[55];let l;e[56]!==h||e[57]!==Q||e[58]!==i||e[59]!==n?(l=s.jsx(Y,{size:"sm",variant:"outline",onClick:h,disabled:Q,className:"commit-actions__btn whitespace-nowrap","aria-label":i,children:n}),e[56]=h,e[57]=Q,e[58]=i,e[59]=n,e[60]=l):l=e[60];let m;e[61]!==u||e[62]!==f||e[63]!==a||e[64]!==I||e[65]!==S||e[66]!==o?(m=I?s.jsxs(be,{children:[s.jsx(ye,{asChild:!0,children:s.jsx(Y,{variant:"default",size:"sm",onClick:()=>S(),disabled:!u||a,className:"h-7 w-7 p-0","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"arrow-up",className:"size-3.5"})})}),s.jsx(we,{side:"top",children:s.jsx("p",{children:o("gitView.commit.push")})})]}):s.jsx(Y,{size:"sm",variant:"default",onClick:()=>S(),disabled:!u||a,className:"commit-actions__btn","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.pushing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"arrow-up",className:"size-3.5"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.push")})]})}),e[61]=u,e[62]=f,e[63]=a,e[64]=I,e[65]=S,e[66]=o,e[67]=m):m=e[67];let D;e[68]!==G||e[69]!==l||e[70]!==m?(D=s.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[G,_,l,m]}),e[68]=G,e[69]=l,e[70]=m,e[71]=D):D=e[71];let C;e[72]!==L||e[73]!==F||e[74]!==D||e[75]!==M?(C=s.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[M,L,F,D]}),e[72]=L,e[73]=F,e[74]=D,e[75]=M,e[76]=C):C=e[76];let B;return e[77]!==C||e[78]!==T?(B=s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[T,C]}),e[77]=C,e[78]=T,e[79]=B):B=e[79],B},Je=({open:p,onOpenChange:e,targetBranch:t,changedFileCount:r,onCommitAndSwitch:w,onGenerateMessage:x,onRevertAndSwitch:g})=>{const{t:d}=J(),[a,h]=N.useState(""),[S,f]=N.useState(null),[b,V]=N.useState(!1),k=S!==null;N.useEffect(()=>{p||(h(""),V(!1))},[p]);const v=async()=>{f("generate");try{const c=await x();c&&h(c)}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}},o=async()=>{f("commit");try{let c=a.trim();if(!c){if(c=(await x()).trim(),!c){ae.error(d("gitView.toast.enterCommitMessage"));return}h(c)}await w(c,b)}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}},j=async()=>{f("revert");try{await g()}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}};return s.jsx(fe,{open:p,onOpenChange:c=>{k||e(c)},children:s.jsx(ue,{className:"max-w-md w-[calc(100vw-2rem)]",children:s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsxs(pe,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(E,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),s.jsx(ge,{children:d("gitView.dirtySwitch.title")})]}),s.jsx(xe,{children:r===1?d("gitView.dirtySwitch.descriptionSingle",{branch:t}):d("gitView.dirtySwitch.descriptionPlural",{branch:t,count:r})})]}),s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border/60 px-3 py-2 focus-within:border-border",children:[s.jsx("input",{value:a,onChange:c=>h(c.target.value),placeholder:d("gitView.commit.messagePlaceholder"),disabled:k,onKeyDown:c=>{c.key==="Enter"&&!k&&(c.preventDefault(),o())},className:"min-w-0 flex-1 bg-transparent typography-meta text-foreground outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"button",onClick:()=>{v()},disabled:k,"aria-label":d("gitView.commit.generate"),title:d("gitView.commit.generate"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:S==="generate"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4 text-primary"})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Re,{checked:b,onChange:V,disabled:k,ariaLabel:d("gitView.dirtySwitch.pushAfterCommit")}),s.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!k&&V(!b),children:d("gitView.dirtySwitch.pushAfterCommit")})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[s.jsxs(Y,{variant:"destructive",size:"sm",onClick:()=>{j()},disabled:k,className:"gap-2",children:[S==="revert"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):null,d("gitView.dirtySwitch.revertAndSwitch")]}),s.jsxs(Y,{variant:"default",size:"sm",onClick:()=>{o()},disabled:k,className:"gap-2",children:[S==="commit"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):null,d("gitView.dirtySwitch.commitAndSwitch")]})]})]})})})};export{Qe as C,Je as D,Ze as a};