@openchamber/web 1.19.0 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{CodeMirrorCommentWidgets-DAvopJvy.js → CodeMirrorCommentWidgets-C36E738Y.js} +1 -1
- package/dist/assets/{CommitSection-D9cV-qR9.js → CommitSection-C-F3AX6D.js} +1 -1
- package/dist/assets/{DiagramEditor-B9NCadU7.js → DiagramEditor-BPECg1jS.js} +1 -1
- package/dist/assets/DiagramView-D0YNMix8.js +1 -0
- package/dist/assets/DiffView-BHWaMYCC.js +4 -0
- package/dist/assets/FilesView-NMBCW2Tm.js +14 -0
- package/dist/assets/{GitView-DsWXqWx3.js → GitView-Rp8P1KEI.js} +4 -4
- package/dist/assets/{JsonTreeView-h4dHASlq.js → JsonTreeView-KnXFN2A-.js} +1 -1
- package/dist/assets/{MarkdownImageGallery-n0ikH-xm.js → MarkdownImageGallery-BMn3mtor.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-kD6N03pH.js +12 -0
- package/dist/assets/{OnboardingScreen-CDjgzxEe.js → OnboardingScreen-CenIeD4v.js} +1 -1
- package/dist/assets/{PatchDiff-jPKTJje5.js → PatchDiff-BzVOVog8.js} +1 -1
- package/dist/assets/{PierreDiffViewer-D_Gt4A_6.js → PierreDiffViewer-Dlby4XqT.js} +2 -2
- package/dist/assets/PlanView-Czu1KMJa.js +4 -0
- package/dist/assets/SessionSwitcherDropdown-IETz58DB.js +1 -0
- package/dist/assets/SettingsView-B6vmuf-c.js +28 -0
- package/dist/assets/SettingsWindow-CauZpdD3.js +1 -0
- package/dist/assets/ToolOutputDialog-BB1c--Zr.js +15 -0
- package/dist/assets/ToolPartDiffPreview-DaOIDISD.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-B37yB9jZ.js → VirtualizedFileDiff-lESMT-2b.js} +4 -4
- package/dist/assets/{WalkthroughView-Bxun3k66.js → WalkthroughView-CaSYE0lw.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-DYFv_yZS.js → computeVirtualFileMetrics-DkRR5b75.js} +2 -2
- package/dist/assets/{contextPanelEmbeddedChat-BO1wRpaN.js → contextPanelEmbeddedChat-BEARQjgn.js} +1 -1
- package/dist/assets/de-DFdX3ABv.js +9 -0
- package/dist/assets/es-iC-FKvV9.js +15 -0
- package/dist/assets/fr-BBbi_1AL.js +13 -0
- package/dist/assets/{index-BSvmTvZl.js → index-BiEgzzkg.js} +1 -1
- package/dist/assets/index-Cwmuwk3V.js +7 -0
- package/dist/assets/index-GNm1wgUH.css +1 -0
- package/dist/assets/{isDiffPlainText-DwHKxDYc.js → isDiffPlainText-BG53Ixxy.js} +1 -1
- package/dist/assets/{isFilePlainText-Dwq6ILxo.js → isFilePlainText-BbV-39jl.js} +1 -1
- package/dist/assets/ja-DQLQJL2J.js +15 -0
- package/dist/assets/ko-BeElEB4Y.js +15 -0
- package/dist/assets/main-Dpzo18z7.js +2 -0
- package/dist/assets/main-WMjtYzJs.js +921 -0
- package/dist/assets/markdownCore--tDmyI_v.js +2 -0
- package/dist/assets/miniChat-ldEghBLB.js +2 -0
- package/dist/assets/mobile-Dk-VGreF.js +2 -0
- package/dist/assets/{patchFileDiff-BEDPDypx.js → patchFileDiff-BcFaMtMu.js} +2 -2
- package/dist/assets/pl-CLHt2_vV.js +15 -0
- package/dist/assets/pt-BR-C_MPUq7e.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-DIgCOmXY.js +2 -0
- package/dist/assets/{renderMobileApp-BiMbzPq9.js → renderMobileApp-CDfHS5rr.js} +7 -7
- package/dist/assets/runtimeEndpointReset-ovNbaZ-x.js +15 -0
- package/dist/assets/{scheduledTasksApi-01zzfzqH.js → scheduledTasksApi-BFSlqgnG.js} +1 -1
- package/dist/assets/{shikiHighlight-DXYW46vW.js → shikiHighlight-DCT2Sq_z.js} +1 -1
- package/dist/assets/uk-PhsC-c4-.js +15 -0
- package/dist/assets/{useAppFontEffects-CbzHzFop.js → useAppFontEffects-B53Rb6m7.js} +166 -159
- package/dist/assets/useInlineCommentController-DSfrIBKT.js +2 -0
- package/dist/assets/{vendor-base-ui-BYlZTzrw.js → vendor-base-ui-DsHmyMwp.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-CiAYDJXN.js → vendor-codemirror-language-data-vch3tJ4c.js} +2 -2
- package/dist/assets/vendor-zod-C9ioTTSo.js +39 -0
- package/dist/assets/{web-components-DCLjCO9n.js → web-components-pcwCTWjC.js} +4 -4
- package/dist/assets/zh-CN-wF-NOFHM.js +15 -0
- package/dist/assets/zh-TW-4m4-A7rT.js +15 -0
- package/dist/index.html +5 -4
- package/dist/mini-chat.html +4 -3
- package/dist/mobile.html +4 -3
- package/package.json +3 -5
- package/server/index.js +36 -0
- package/server/lib/agent-memory/project-resolution.js +10 -1
- package/server/lib/agent-memory/project-resolution.test.js +9 -0
- package/server/lib/agent-memory/runtime.js +7 -2
- package/server/lib/dictation/DOCUMENTATION.md +32 -8
- package/server/lib/dictation/local/sherpa-recognizer.js +35 -78
- package/server/lib/dictation/local/worker-process.js +2 -2
- package/server/lib/dictation/openai-compatible-session.js +3 -2
- package/server/lib/dictation/stream-manager.js +77 -34
- package/server/lib/dictation/stream-manager.test.js +60 -2
- package/server/lib/fs/routes.test.js +76 -0
- package/server/lib/git/routes.js +43 -0
- package/server/lib/git/service.js +85 -5
- package/server/lib/git/service.test.js +93 -0
- package/server/lib/opencode/DOCUMENTATION.md +6 -2
- package/server/lib/opencode/feature-routes-runtime.js +5 -9
- package/server/lib/opencode/lifecycle.js +202 -26
- package/server/lib/opencode/lifecycle.test.js +179 -1
- package/server/lib/opencode/providers.js +9 -4
- package/server/lib/opencode/providers.test.js +27 -0
- package/server/lib/opencode/restart-session-recovery.test.js +59 -0
- package/server/lib/opencode/session-runtime.js +39 -2
- package/server/lib/opencode/session-runtime.test.js +74 -0
- package/server/lib/opencode/settings-helpers.js +15 -0
- package/server/lib/opencode/settings-helpers.test.js +22 -0
- package/server/lib/opencode/settings-normalization-runtime.js +3 -0
- package/server/lib/opencode/settings-normalization-runtime.test.js +16 -0
- package/server/lib/opencode/settings-runtime.js +32 -10
- package/server/lib/opencode/settings-runtime.test.js +85 -0
- package/server/lib/opencode/skill-routes.js +29 -73
- package/server/lib/opencode/skill-routes.test.js +2 -5
- package/server/lib/project-context/DOCUMENTATION.md +2 -0
- package/server/lib/project-context/runtime.js +7 -2
- package/server/lib/projects/project-config.js +7 -2
- package/server/lib/quota/DOCUMENTATION.md +1 -1
- package/server/lib/quota/providers/claude/index.js +2 -2
- package/server/lib/quota/providers/command-code.js +1 -1
- package/server/lib/quota/providers/command-code.test.js +13 -0
- package/server/lib/quota/providers/index.js +12 -4
- package/server/lib/quota/providers/zai.js +26 -6
- package/server/lib/quota/providers/zai.test.js +33 -0
- package/server/lib/session-knowledge/DOCUMENTATION.md +2 -0
- package/server/lib/skills-catalog/DOCUMENTATION.md +18 -45
- package/server/lib/skills-catalog/cache.js +120 -1
- package/server/lib/skills-catalog/cache.test.js +77 -0
- package/server/lib/skills-catalog/curated-sources.js +21 -5
- package/server/lib/skills-catalog/curated-sources.test.js +4 -4
- package/server/lib/skills-catalog/disk-cache.js +52 -0
- package/server/lib/skills-catalog/github-meta.js +139 -0
- package/server/lib/skills-catalog/github-meta.test.js +71 -0
- package/server/lib/skills-catalog/source.js +0 -5
- package/server/lib/small-model/DOCUMENTATION.md +74 -6
- package/server/lib/small-model/call.js +46 -12
- package/server/lib/small-model/call.test.js +79 -0
- package/server/lib/small-model/index.js +51 -8
- package/server/lib/small-model/index.test.js +73 -3
- package/server/lib/small-model/routes.js +1 -1
- package/server/lib/small-model/runtime-providers.js +156 -0
- package/server/lib/small-model/runtime-providers.test.js +112 -0
- package/dist/assets/DiagramView-LKGBwf4G.js +0 -1
- package/dist/assets/DiffView-BWNq-0ov.js +0 -4
- package/dist/assets/FilesView-DB-Q0Gkz.js +0 -14
- package/dist/assets/MarkdownRendererImpl-CT2mjx-s.js +0 -12
- package/dist/assets/PlanView-UvuxIl9-.js +0 -4
- package/dist/assets/SessionSwitcherDropdown-xKU4LRuQ.js +0 -1
- package/dist/assets/SettingsView-3B9VN6Ys.js +0 -28
- package/dist/assets/SettingsWindow-CqQNDKNd.js +0 -1
- package/dist/assets/ToolOutputDialog-PmjlAxVE.js +0 -15
- package/dist/assets/ToolPartDiffPreview-B34Xw9wq.js +0 -8
- package/dist/assets/de-DbV6CLxv.js +0 -9
- package/dist/assets/es-CVDlyzZ4.js +0 -15
- package/dist/assets/fr-Czc-p0g-.js +0 -13
- package/dist/assets/index-1OhiMDBz.css +0 -1
- package/dist/assets/index-DzriVon2.js +0 -7
- package/dist/assets/ja-dwc9NM_S.js +0 -15
- package/dist/assets/ko-Ds1DZ8FX.js +0 -15
- package/dist/assets/main-BF51IOVF.js +0 -921
- package/dist/assets/main-D7UPARut.js +0 -2
- package/dist/assets/markdownCore-BgeBDwD3.js +0 -2
- package/dist/assets/miniChat-BISXSGOo.js +0 -2
- package/dist/assets/mobile-BnYxVuvw.js +0 -2
- package/dist/assets/pl-CLiTO7i-.js +0 -15
- package/dist/assets/pt-BR-GIimJgpK.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-BaOy72Gi.js +0 -2
- package/dist/assets/runtimeEndpointReset-BMBRhIbf.js +0 -15
- package/dist/assets/uk-DLfgD1ki.js +0 -15
- package/dist/assets/useInlineCommentController-CegKdDXi.js +0 -2
- package/dist/assets/vendor-zod-adaMkgkm.js +0 -39
- package/dist/assets/zh-CN-DkeP5awK.js +0 -15
- package/dist/assets/zh-TW-BocaFm3d.js +0 -15
- package/server/lib/skills-catalog/clawdhub/api.js +0 -126
- package/server/lib/skills-catalog/clawdhub/install.js +0 -238
- package/server/lib/skills-catalog/clawdhub/install.test.js +0 -100
- package/server/lib/skills-catalog/clawdhub/scan.js +0 -61
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{b as Te,c as
|
|
1
|
+
import{b as Te,c as Je,g as et,s as tt,d as Xe,e as Fe,f as it,h as nt,i as Ye,j as Ne,k as he,l as st,R as rt,I as ot,p as Pe,m as at,n as lt,o as ht,q as Ue,S as dt,r as ut,w as ft,t as Oe,u as ct,v as pt,x as Ae,y as gt,z as mt,A as Ct,B as St,C as vt,a as yt,F as Ht}from"./web-components-pcwCTWjC.js";import{j as w,m as Se,k as Lt,n as Tt,d as At,i as ke,o as P,q as ce,s as kt,b as Rt,f as Be,t as Y,u as Ze,w as Re}from"./computeVirtualFileMetrics-DkRR5b75.js";import{h as xt,a as se,i as be,b as re,r as Dt,g as Et,c as ve,d as we,e as oe,f as Me,j as ae}from"./isDiffPlainText-BG53Ixxy.js";import{gX as bt,gY as wt,gZ as Ie,fb as _,g_ as Mt,g$ as It,h0 as Ve,h1 as zt,gN as Ft,gO as Nt,gP as Pt,gQ as Ut}from"./useAppFontEffects-B53Rb6m7.js";import{c as Ot}from"./vendor-diff-C3JhlQdm.js";import{t as le}from"./vendor-hast-util-to-html-BKBhbTDb.js";function Z(e,t,i,n=!1){const s=bt(Ot(e.name,t.name,e.contents,t.contents,e.header,t.header,i),{cacheKey:(()=>{if(e.cacheKey!=null&&t.cacheKey!=null)return`${e.cacheKey}:${t.cacheKey}`})(),oldFile:e,newFile:t,throwOnError:n});if(s==null)throw new Error("parseDiffFrom: FileInvalid diff -- probably need to fix something -- if the files are the same maybe?");return t.lang!=null&&(s.lang=t.lang),s}var Bt=class{isDeletionsScrolling=!1;isAdditionsScrolling=!1;timeoutId=-1;codeDeletions;codeAdditions;enabled=!1;cleanUp(){this.enabled&&(this.codeDeletions?.removeEventListener("scroll",this.handleDeletionsScroll),this.codeAdditions?.removeEventListener("scroll",this.handleAdditionsScroll),clearTimeout(this.timeoutId),this.codeDeletions=void 0,this.codeAdditions=void 0,this.enabled=!1)}setup(e,t,i){if(t==null||i==null)for(const n of e.children??[])n instanceof HTMLElement&&("deletions"in n.dataset?t=n:"additions"in n.dataset&&(i=n));if(i==null||t==null){this.cleanUp();return}this.codeDeletions!==t&&(this.codeDeletions?.removeEventListener("scroll",this.handleDeletionsScroll),this.codeDeletions=t,t.addEventListener("scroll",this.handleDeletionsScroll,{passive:!0})),this.codeAdditions!==i&&(this.codeAdditions?.removeEventListener("scroll",this.handleAdditionsScroll),this.codeAdditions=i,i.addEventListener("scroll",this.handleAdditionsScroll,{passive:!0})),this.enabled=!0}handleDeletionsScroll=()=>{this.isAdditionsScrolling||(this.isDeletionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isDeletionsScrolling=!1},300),this.codeAdditions?.scrollTo({left:this.codeDeletions?.scrollLeft}))};handleAdditionsScroll=()=>{this.isDeletionsScrolling||(this.isAdditionsScrolling=!0,clearTimeout(this.timeoutId),this.timeoutId=setTimeout(()=>{this.isAdditionsScrolling=!1},300),this.codeDeletions?.scrollTo({left:this.codeAdditions?.scrollLeft}))}};function pe(e){return w({tagName:"div",properties:{"data-content-buffer":"","data-buffer-size":e,style:`grid-row: span ${e};min-height:calc(${e} * 1lh)`}})}function ge(e){return w({tagName:"div",children:[w({tagName:"span",children:[Se("No newline at end of file")]})],properties:{"data-no-newline":"","data-line-type":e,"data-column-content":""}})}function xe(e){return w({tagName:"div",children:[Lt({name:e==="both"?"diffs-icon-expand-all":"diffs-icon-expand",properties:{"data-icon":""}})],properties:{role:"button","data-expand-button":"","data-expand-both":e==="both"?"":void 0,"data-expand-up":e==="up"?"":void 0,"data-expand-down":e==="down"?"":void 0}})}function K({type:e,content:t,expandIndex:i,chunked:n=!1,slotName:s,isFirstHunk:r,isLastHunk:o}){let a=0;const l=[];if(e==="metadata"&&t!=null&&l.push(w({tagName:"div",children:[Se(t)],properties:{"data-separator-wrapper":""}})),(e==="line-info"||e==="line-info-basic")&&t!=null){const u=[];i!=null&&(n?(r||(u.push(xe("up")),a++),o||(u.push(xe("down")),a++)):(u.push(xe(!r&&!o?"both":r?"down":"up")),a++)),u.push(w({tagName:"div",children:[w({tagName:"span",children:[Se(t)],properties:{"data-unmodified-lines":""}})],properties:{"data-separator-content":""}})),n&&i!=null&&u.push(w({tagName:"div",children:[Se("Expand all")],properties:{role:"button","data-expand-button":"","data-expand-all-button":""}})),l.push(w({tagName:"div",children:u,properties:{"data-separator-wrapper":"","data-separator-multi-button":a>1?"":void 0}}))}return e==="custom"&&s!=null&&l.push(w({tagName:"slot",properties:{name:s}})),w({tagName:"div",children:l,properties:{"data-separator":l.length===0?"simple":e,"data-expand-index":i,"data-separator-first":r?"":void 0,"data-separator-last":o?"":void 0}})}function Vt(e,t){return`hunk-separator-${e}-${t}`}function Gt(e){const t=e.at(-1);return t==null?0:Math.max(t.additionStart+t.additionCount,t.deletionStart+t.deletionCount)}function Wt(e){return e.startingLine===0&&e.totalLines===1/0&&e.bufferBefore===0&&e.bufferAfter===0}function $t(e){return e!==""?e.split(wt):[]}function G(e,t){const i=Z({name:e.prevName??e.name,contents:e.deletionLines.join("")},{name:e.name,contents:e.additionLines.join(""),lang:e.lang},t);return{hunks:i.hunks,splitLineCount:i.splitLineCount,unifiedLineCount:i.unifiedLineCount,additionLines:i.additionLines,deletionLines:i.deletionLines,type:i.type}}function _t(e,t){const i=e.deletionLines.join(""),n=i===`
|
|
2
2
|
`?`
|
|
3
3
|
`:`
|
|
4
|
-
`,s=
|
|
4
|
+
`,s=Z({name:e.prevName??e.name,contents:i},{name:e.name,contents:n,lang:e.lang},t);return{hunks:s.hunks,splitLineCount:s.splitLineCount,unifiedLineCount:s.unifiedLineCount,additionLines:[""],deletionLines:s.deletionLines,type:s.type}}function jt(e,t,i){if(e.isPartial||e.deletionLines.length!==e.additionLines.length)return B(e,G(e,i));const n=Array.from(t);if(n.length===0)return B(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type});for(const r of n){const o=e.additionLines[r],a=e.deletionLines[r];if(o==null||a==null||Ie(o)===Ie(a))return B(e,G(e,i))}const s=qt(e,n);if(s.size===0)return B(e,G(e,i));for(const r of s)if(!Xt(e,r,i))return B(e,G(e,i));return Jt(e),xt(e)?B(e,G(e,i)):B(e,{hunks:e.hunks,splitLineCount:e.splitLineCount,unifiedLineCount:e.unifiedLineCount,type:e.type})}function B(e,t){return Object.assign(e,t),t}function qt(e,t){const i=new Set;for(const n of t){const s=Kt(e,n);if(s==null)return new Set;i.add(s)}return i}function Kt(e,t){for(const[i,n]of e.hunks.entries()){const s=n.additionLineIndex+n.additionCount;if(t>=n.additionLineIndex&&t<s)return i}}function Xt(e,t,i){const n=e.hunks[t];if(n==null)return!1;const s=e.deletionLines.slice(n.deletionLineIndex,n.deletionLineIndex+n.deletionCount),r=e.additionLines.slice(n.additionLineIndex,n.additionLineIndex+n.additionCount),o=Z({name:e.prevName??e.name,contents:s.join("")},{name:e.name,contents:r.join(""),lang:e.lang},{...i,context:0}),a=o.hunks[0];return a==null||o.hunks.length!==1?!1:(Zt(n,a),Yt(e,t),!0)}function Yt(e,t){const i=e.hunks[t];if(i==null)return;if(t!==e.hunks.length-1){i.noEOFCRAdditions=!1,i.noEOFCRDeletions=!1;return}const n=e.additionLines.at(-1),s=e.deletionLines.at(-1);i.noEOFCRAdditions=n!=null&&n!==""&&!n.endsWith(`
|
|
5
5
|
`),i.noEOFCRDeletions=s!=null&&s!==""&&!s.endsWith(`
|
|
6
|
-
`)}function Jt(e,t){const i=e.additionLineIndex,n=e.deletionLineIndex;e.hunkContent=t.hunkContent.map(s=>Zt(s,i,n)),e.additionLineIndex=i+t.additionLineIndex,e.additionStart=e.additionStart+t.additionLineIndex,e.additionCount=t.additionCount,e.additionLines=t.additionLines,t.deletionLineIndex>=0&&(e.deletionLineIndex=n+t.deletionLineIndex,e.deletionStart=e.deletionStart+t.deletionLineIndex),e.deletionCount=t.deletionCount,e.deletionLines=t.deletionLines,e.noEOFCRAdditions=t.noEOFCRAdditions,e.noEOFCRDeletions=t.noEOFCRDeletions,Ze(e)}function Zt(e,t,i){return{...e,additionLineIndex:e.additionLineIndex+t,deletionLineIndex:e.deletionLineIndex+i}}function Ze(e){let t=0,i=0;for(const n of e.hunkContent)n.type==="context"?(t+=n.lines,i+=n.lines):(t+=Math.max(n.additions,n.deletions),i+=n.additions+n.deletions);e.splitLineCount=t,e.unifiedLineCount=i}function Qt(e){let t=0,i=0,n=0;for(const s of e.hunks)s.collapsedBefore=Math.max(s.additionStart-1-n,0),s.splitLineStart=t+s.collapsedBefore,s.unifiedLineStart=i+s.collapsedBefore,Ze(s),t+=s.collapsedBefore+s.splitLineCount,i+=s.collapsedBefore+s.unifiedLineCount,n=s.additionStart+s.additionCount-1;if(e.hunks.length>0){const s=e.hunks[e.hunks.length-1],r=Math.max(e.additionLines.length-(s.additionLineIndex+s.additionCount),0);t+=r,i+=r}e.splitLineCount=t,e.unifiedLineCount=i}let ei=-1;var ti=class{options;onRenderUpdate;workerManager;__id=`diff-hunks-renderer:${++ei}`;highlighter;diff;expandedHunks=new Map;deletionAnnotations={};additionAnnotations={};computedLang="text";renderCache;constructor(e={theme:_},t,i){this.options=e,this.onRenderUpdate=t,this.workerManager=i,i?.isWorkingPool()!==!0&&(this.highlighter=Te(e.theme??_)?Tt():void 0)}cleanUp(){this.recycle(),this.expandedHunks.clear(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.highlighter=void 0,this.diff=void 0,this.clearRenderCache(),this.additionAnnotations={},this.deletionAnnotations={},this.workerManager?.cleanUpTasks(this)}getRenderDiff(){return this.renderCache?.diff??this.diff}clearRenderCache(){const e=this.renderCache;this.renderCache=void 0,e!=null&&e.isDirty===!0&&e.diff.cacheKey!=null&&this.workerManager?.evictDiffFromCache(e.diff.cacheKey)}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}expandHunk(e,t,i=this.getOptionsWithDefaults().expansionLineCount){const n={...this.expandedHunks.get(e)??{fromStart:0,fromEnd:0}};(t==="up"||t==="both")&&(n.fromStart+=i),(t==="down"||t==="both")&&(n.fromEnd+=i),this.renderCache?.highlighted!==!0&&this.clearRenderCache(),this.expandedHunks.set(e,n)}getExpandedHunk(e){return this.expandedHunks.get(e)??Mt}getExpandedHunksMap(){return this.expandedHunks}setLineAnnotations(e){this.additionAnnotations={},this.deletionAnnotations={};for(const t of e){const i=(()=>{switch(t.side){case"deletions":return this.deletionAnnotations;case"additions":return this.additionAnnotations}})(),n=i[t.lineNumber]??[];i[t.lineNumber]=n,n.push(t)}}updateRenderCache(e,t,i=!1){if(this.renderCache==null)return;const{result:n,diff:s}=this.renderCache;if(n==null)return;if(s.isPartial)throw new Error("Could not update render cache for partial diff");const r=n.code.additionLines,o=[];for(const[a,l]of e){const u=r[a]?.properties??{},f=l.map(g=>g[2]).join(""),h=a<s.additionLines.length,d=h?s.additionLines[a]??"":"",c=Ie(d);h&&(s.additionLines[a]=ni(d,f),c!==f&&o.push(a)),r[a]={type:"element",tagName:"div",properties:{"data-line":u["data-line"]??a+1,"data-line-index":u["data-line-index"]??a,"data-line-type":u["data-line-type"]??"context"},children:l.map(([g,m,C])=>g===0&&m===""?C===""?{type:"element",tagName:"br",properties:{},children:[]}:{type:"text",value:C}:{type:"element",tagName:"span",properties:{"data-char":g,style:`--diffs-token-${t}:${m};`},children:[{type:"text",value:C}]})}}!i&&o.length>0&&Object.assign(s,jt(s,o,this.options.parseDiffOptions)),n.baseThemeType=t,this.renderCache.isDirty=!0}applyDocumentChange(e){if(this.renderCache==null)return;const{diff:t,result:i}=this.renderCache;if(i==null)return;t.additionLines=$t(e.getText());const n=t.additionLines.length,s=i.code.additionLines,r=s.length;n<r&&(s.length=n);for(let o=r;o<n;o++)s[o]??=je(o,e);t.isPartial||(n===0?(Object.assign(t,_t(t,this.options.parseDiffOptions)),s[0]=je(0,e)):Object.assign(t,G(t,this.options.parseDiffOptions))),this.renderCache.isDirty=!0}getUnifiedLineDecoration({lineType:e}){return{gutterLineType:e,contentProperties:{"data-line-type":e}}}getSplitLineDecoration({side:e,type:t}){const i=t==="change"?e==="deletions"?"change-deletion":"change-addition":t;return{gutterLineType:i,contentProperties:{"data-line-type":i}}}createAnnotationElement=e=>Qe(e);getOptionsWithDefaults(){const{diffIndicators:e="bars",diffStyle:t="split",disableBackground:i=!1,disableFileHeader:n=!1,disableLineNumbers:s=!1,disableVirtualizationBuffers:r=!1,collapsed:o=!1,expandUnchanged:a=!1,collapsedContextThreshold:l=1,expansionLineCount:u=100,hunkSeparators:f="line-info",lineDiffType:h="word-alt",maxLineDiffLength:d=1e3,overflow:c="scroll",stickyHeader:g=!1,theme:m=_,headerRenderMode:C="default",tokenizeMaxLineLength:y=1e3,tokenizeMaxLength:v=It,useTokenTransformer:p=!1,useCSSClasses:S=!1}=this.options;return{diffIndicators:e,diffStyle:t,disableBackground:i,disableFileHeader:n,disableLineNumbers:s,disableVirtualizationBuffers:r,collapsed:o,expandUnchanged:a,collapsedContextThreshold:l,expansionLineCount:u,hunkSeparators:f,lineDiffType:h,maxLineDiffLength:d,overflow:c,stickyHeader:g,theme:this.workerManager?.getDiffRenderOptions().theme??m,headerRenderMode:C,tokenizeMaxLineLength:y,tokenizeMaxLength:v,useTokenTransformer:p,useCSSClasses:S}}async initializeHighlighter(){return this.highlighter=await At(et(this.computedLang,this.options)),this.highlighter}hydrate(e){if(e==null)return;this.diff=e;const{options:t}=this.getRenderOptions(e),i=Ee(e,this.getTokenizeMaxLength());let n=this.workerManager?.getDiffResultCache(e);n!=null&&!se(t,n.options)&&(n=void 0),this.renderCache??={diff:e,highlighted:!i&&!be(e),options:t,result:i?void 0:n?.result,renderRange:void 0},this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!i&&this.workerManager.highlightDiffAST(this,this.diff):this.highlighter==null&&(this.computedLang=e.lang??ke(e.name),this.initializeHighlighter())}getRenderOptions(e){const t=(()=>{if(this.workerManager?.isWorkingPool()===!0)return this.workerManager.getDiffRenderOptions();const{theme:n,tokenizeMaxLineLength:s,lineDiffType:r,maxLineDiffLength:o}=this.getOptionsWithDefaults();return{theme:n,useTokenTransformer:tt(this.options),tokenizeMaxLineLength:s,lineDiffType:r,maxLineDiffLength:o}})();this.getOptionsWithDefaults();const{renderCache:i}=this;return i?.result==null?{options:t,forceHighlight:!0}:!re(e,i.diff)||!se(t,i.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}renderDiff(e=this.renderCache?.diff,t=Ve){if(e==null)return;const{expandUnchanged:i=!1,collapsedContextThreshold:n}=this.getOptionsWithDefaults();let{options:s,forceHighlight:r}=this.getRenderOptions(e);const o=this.getMatchingWorkerResultCache(e,s);o!=null&&!this.hasHighlightedRenderCache(e,s)&&(this.renderCache={diff:e,highlighted:!0,renderRange:void 0,...o},r=!1),this.renderCache??={diff:e,highlighted:!1,options:s,result:void 0,renderRange:void 0};const a=e.additionLines.length>0||e.deletionLines.length>0,l=!a||be(e)||Ee(e,this.getTokenizeMaxLength()),u=!re(e,this.renderCache.diff),f=!Xe(this.renderCache.renderRange,t);if(this.workerManager?.isWorkingPool()===!0)(l||this.renderCache.result==null||!this.renderCache.highlighted&&(u||f))&&(this.renderCache.diff=e,this.renderCache.options=s,this.renderCache.highlighted=!1,(this.renderCache.result==null||u||f||r)&&(this.renderCache.result=this.workerManager.getPlainDiffAST(e,t.startingLine,t.totalLines,Wt(t)||i?!0:this.expandedHunks,n)),this.renderCache.renderRange=t),!l&&a&&(!this.renderCache.highlighted||r)&&this.workerManager.highlightDiffAST(this,e);else{this.computedLang=e.lang??ke(e.name);const h=this.highlighter!=null&&Te(s.theme),d=this.highlighter!=null&&Fe(this.computedLang),c=!l&&d;if(this.highlighter!=null&&h&&(r||l||!this.renderCache.highlighted&&c||this.renderCache.result==null)){const{result:g,options:m}=this.renderDiffWithHighlighter(e,this.highlighter,l||!d);this.renderCache={diff:e,options:m,highlighted:c,result:g,renderRange:void 0}}(!h||!l&&!d)&&this.asyncHighlight(e).then(({result:g,options:m})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.onHighlightSuccess(e,g,m,!l)})}return this.renderCache.result!=null?this.processDiffResult(this.renderCache.diff,t,this.renderCache.result):void 0}async asyncRender(e,t=Ve){const{result:i}=await this.asyncHighlight(e);return this.processDiffResult(e,t,i)}createPreElement(e,t,i){const{diffIndicators:n,disableBackground:s,disableLineNumbers:r,overflow:o}=this.getOptionsWithDefaults();return it({type:"diff",diffIndicators:n,disableBackground:s,disableLineNumbers:r,overflow:o,split:e,totalLines:t,customProperties:i})}async asyncHighlight(e){const t=Ee(e,this.getTokenizeMaxLength());this.computedLang=t?"text":e.lang??ke(e.name);const i=this.highlighter!=null&&Te(this.options.theme??_),n=t||this.highlighter!=null&&Fe(this.computedLang);return(this.highlighter==null||!i||!n)&&(this.highlighter=await this.initializeHighlighter()),this.renderDiffWithHighlighter(e,this.highlighter,t)}renderDiffWithHighlighter(e,t,i=!1){const{options:n}=this.getRenderOptions(e),{collapsedContextThreshold:s}=this.getOptionsWithDefaults();return{result:Dt(e,t,n,{forcePlainText:i,expandedHunks:i?!0:void 0,collapsedContextThreshold:s}),options:n}}onHighlightSuccess(e,t,i,n=!0){if(this.renderCache==null)return;const s=!this.renderCache.highlighted||!se(this.renderCache.options,i)||!re(this.renderCache.diff,e);this.renderCache={diff:e,options:i,highlighted:n,result:t,renderRange:void 0},s&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(e,t){const i=this.workerManager?.getDiffResultCache(e);if(!(i==null||!se(t,i.options)))return i}hasHighlightedRenderCache(e,t){const{renderCache:i}=this;return i?.result!=null&&i.highlighted&&re(e,i.diff)&&se(t,i.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}processDiffResult(e,t,{code:i,themeStyles:n,baseThemeType:s}){const{diffStyle:r,disableFileHeader:o,expandUnchanged:a,expansionLineCount:l,collapsedContextThreshold:u,hunkSeparators:f}=this.getOptionsWithDefaults(),h=this.renderCache?.isDirty??!1;this.diff=e;const d=r==="unified";let c=[],g=[],m=[];const C=[],{additionLines:y,deletionLines:v}=i,p={rowCount:0,hunkSeparators:f,additionsContentAST:c,deletionsContentAST:g,unifiedContentAST:m,unifiedGutterAST:ce(),deletionsGutterAST:ce(),additionsGutterAST:ce(),expansionLineCount:l,hunkData:C,incrementRowCount(R=1){p.rowCount+=R},pushToGutter(R,D){switch(R){case"unified":p.unifiedGutterAST.children.push(D);break;case"deletions":p.deletionsGutterAST.children.push(D);break;case"additions":p.additionsGutterAST.children.push(D);break}}},S=Et({fileDiff:e,errorPrefix:"DiffHunksRenderer.processDiffResult"}),L={size:0,side:void 0,increment(){this.size+=1},flush(){if(r!=="unified"){if(this.size<=0||this.side==null){this.side=void 0,this.size=0;return}this.side==="additions"?(p.pushToGutter("additions",P(void 0,"buffer",this.size)),c?.push(pe(this.size))):(p.pushToGutter("deletions",P(void 0,"buffer",this.size)),g?.push(pe(this.size))),this.size=0,this.side=void 0}}},T=(R,D,U,V,H)=>{p.pushToGutter(R,kt(D,U,V,H))};function F(R){L.flush(),r==="unified"?De("unified",R,p):(De("deletions",R,p),De("additions",R,p))}this.pushFileLevelAnnotations(e,r,t,p),ve({diff:e,diffStyle:r,startingLine:t.startingLine,totalLines:t.totalLines,expandedHunks:a?!0:this.expandedHunks,collapsedContextThreshold:u,callback:({hunkIndex:R,hunk:D,collapsedBefore:U,collapsedAfter:V,additionLine:H,deletionLine:A,type:x})=>{const I=A!=null?A.splitLineIndex:H.splitLineIndex,W=H!=null?H.unifiedLineIndex:A.unifiedLineIndex;r==="split"&&x!=="change"&&L.flush(),U>0&&F({hunkIndex:R,collapsedLines:U,rangeSize:Math.max(D?.collapsedBefore??0,0),hunkSpecs:D?.hunkSpecs,isFirstHunk:R===0,isLastHunk:!1,isExpandable:!e.isPartial});const Q=r==="unified"?W:I,ee={type:x,hunkIndex:R,lineIndex:Q,unifiedLineIndex:W,splitLineIndex:I,deletionLine:A,additionLine:H};if(r==="unified"){const k=this.getUnifiedInjectedRowsForLine?.(ee);k?.before!=null&&$e(k.before,p);let E=A!=null?v[A.lineIndex]:void 0,z=H!=null?y[H.lineIndex]:void 0;if(E==null&&z==null){const N="DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";throw console.error(N,{file:e.name}),new Error(N)}const $=x==="change"?H!=null?"change-addition":"change-deletion":x,O=this.getUnifiedLineDecoration({type:x,lineType:$,additionLineIndex:H?.lineIndex,deletionLineIndex:A?.lineIndex});T("unified",O.gutterLineType,H!=null?H.lineNumber:A.lineNumber,`${W},${I}`,O.gutterProperties),z!=null?z=Ce(z,O.contentProperties,h&&H!=null?{"data-line":H.lineNumber,"data-line-index":`${W},${I}`}:void 0):E!=null&&(E=Ce(E,O.contentProperties,h&&A!=null?{"data-line":A.lineNumber,"data-line-index":`${W},${I}`}:void 0)),me({diffStyle:"unified",type:x,deletionLine:E,additionLine:z,unifiedSpan:this.getAnnotations("unified",A?.lineNumber,H?.lineNumber,R,Q),createAnnotationElement:N=>this.createAnnotationElement(N),context:p}),k?.after!=null&&$e(k.after,p)}else{const k=this.getSplitInjectedRowsForLine?.(ee);k?.before!=null&&_e(k.before,p,L);let E=A!=null?v[A.lineIndex]:void 0,z=H!=null?y[H.lineIndex]:void 0;const $=this.getSplitLineDecoration({side:"deletions",type:x,lineIndex:A?.lineIndex}),O=this.getSplitLineDecoration({side:"additions",type:x,lineIndex:H?.lineIndex});if(E==null&&z==null){const M="DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";throw console.error(M,{file:e.name}),new Error(M)}const N=(()=>{if(x==="change"){if(z==null)return"additions";if(E==null)return"deletions"}})();if(N!=null){if(L.side!=null&&L.side!==N)throw new Error("DiffHunksRenderer.processDiffResult: iterateOverDiff, invalid pending splits");L.side=N,L.increment()}const ne=this.getAnnotations("split",A?.lineNumber,H?.lineNumber,R,Q);if(ne!=null&&L.size>0&&L.flush(),A!=null){const M=Ce(E,$.contentProperties,h?{"data-line":A.lineNumber,"data-line-index":`${A.unifiedLineIndex},${I}`}:void 0);T("deletions",$.gutterLineType,A.lineNumber,`${A.unifiedLineIndex},${I}`,$.gutterProperties),M!=null&&(E=M)}if(H!=null){const M=Ce(z,O.contentProperties,h?{"data-line":H.lineNumber,"data-line-index":`${H.unifiedLineIndex},${I}`}:void 0);T("additions",O.gutterLineType,H.lineNumber,`${H.unifiedLineIndex},${I}`,O.gutterProperties),M!=null&&(z=M)}me({diffStyle:"split",type:x,additionLine:z,deletionLine:E,...ne,createAnnotationElement:M=>this.createAnnotationElement(M),context:p}),k?.after!=null&&_e(k.after,p,L)}const fe=r==="split"&&D!=null&&I===D.splitLineStart+D.splitLineCount-1,ye=fe?D.noEOFCRDeletions:!1,Le=fe?D.noEOFCRAdditions:!1,te=(A?.noEOFCR??!1)||ye,ie=(H?.noEOFCR??!1)||Le;if(ie||te){if(r==="split"&&L.flush(),te){const k=x==="context"||x==="context-expanded"?x:"change-deletion";r==="unified"?(p.unifiedContentAST.push(ge(k)),p.pushToGutter("unified",P(k,"metadata",1))):(p.deletionsContentAST.push(ge(k)),p.pushToGutter("deletions",P(k,"metadata",1)),ie||(p.pushToGutter("additions",P(void 0,"buffer",1)),p.additionsContentAST.push(pe(1))))}if(ie){const k=x==="context"||x==="context-expanded"?x:"change-addition";r==="unified"?(p.unifiedContentAST.push(ge(k)),p.pushToGutter("unified",P(k,"metadata",1))):(p.additionsContentAST.push(ge(k)),p.pushToGutter("additions",P(k,"metadata",1)),te||(p.pushToGutter("deletions",P(void 0,"buffer",1)),p.deletionsContentAST.push(pe(1))))}p.incrementRowCount(1)}V>0&&f!=="simple"&&F({hunkIndex:x==="context-expanded"?R:R+1,collapsedLines:V,rangeSize:S,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:!e.isPartial}),p.incrementRowCount(1)}}),r==="split"&&L.flush();const de=Math.max(Gt(e.hunks),e.additionLines.length??0,e.deletionLines.length??0),j=t.bufferBefore>0||t.bufferAfter>0,ue=!d&&e.type!=="deleted",q=!d&&e.type!=="new",b=p.rowCount>0||j;c=ue&&b?c:void 0,g=q&&b?g:void 0,m=d&&b?m:void 0;const Z=this.createPreElement(g!=null&&c!=null,de);return{unifiedGutterAST:d&&b?p.unifiedGutterAST.children:void 0,unifiedContentAST:m,deletionsGutterAST:q&&b?p.deletionsGutterAST.children:void 0,deletionsContentAST:g,additionsGutterAST:ue&&b?p.additionsGutterAST.children:void 0,additionsContentAST:c,hunkData:C,preNode:Z,themeStyles:n,baseThemeType:s,headerElement:o?void 0:this.renderHeader(this.diff),totalLines:de,rowCount:p.rowCount,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:""}}renderCodeAST(e,t){const i=e==="unified"?t.unifiedGutterAST:e==="deletions"?t.deletionsGutterAST:t.additionsGutterAST,n=e==="unified"?t.unifiedContentAST:e==="deletions"?t.deletionsContentAST:t.additionsContentAST;if(i==null||n==null)return;const s=ce(i);return s.properties.style=`grid-row: span ${t.rowCount}`,[s,nt(n,t.rowCount)]}renderFullAST(e,t=[]){const i=this.getOptionsWithDefaults().hunkSeparators==="line-info",n=this.renderCodeAST("unified",e);if(n!=null)return t.push(w({tagName:"code",children:n,properties:{"data-code":"","data-container-size":i?"":void 0,"data-unified":""}})),{...e.preNode,children:t};const s=this.renderCodeAST("deletions",e);s!=null&&t.push(w({tagName:"code",children:s,properties:{"data-code":"","data-container-size":i?"":void 0,"data-deletions":""}}));const r=this.renderCodeAST("additions",e);return r!=null&&t.push(w({tagName:"code",children:r,properties:{"data-code":"","data-container-size":i?"":void 0,"data-additions":""}})),{...e.preNode,children:t}}renderFullHTML(e,t=[]){return le(this.renderFullAST(e,t))}renderPartialHTML(e,t){return t==null?le(e):le(w({tagName:"code",children:e,properties:{"data-code":"","data-container-size":this.getOptionsWithDefaults().hunkSeparators==="line-info"?"":void 0,[`data-${t}`]:""}}))}pushFileLevelAnnotations(e,t,i,n){if(!Ye(i))return;const s=e.type!=="new"?Ge(Ne(this.deletionAnnotations)):[],r=e.type!=="deleted"?Ge(Ne(this.additionAnnotations)):[];if(s.length===0&&r.length===0)return;const o=-1,a=-1,{createAnnotationElement:l}=this;if(t==="unified"){me({diffStyle:t,type:"context",unifiedSpan:{type:"annotation",hunkIndex:o,lineIndex:a,annotations:s.concat(r)},createAnnotationElement:l,context:n});return}me({diffStyle:t,type:"context",deletionSpan:{type:"annotation",hunkIndex:o,lineIndex:a,annotations:s},additionSpan:{type:"annotation",hunkIndex:o,lineIndex:a,annotations:r},createAnnotationElement:l,context:n})}getAnnotations(e,t,i,n,s){const r={type:"annotation",hunkIndex:n,lineIndex:s,annotations:[]};if(t!=null)for(const a of this.deletionAnnotations[t]??[])r.annotations.push(he(a));const o={type:"annotation",hunkIndex:n,lineIndex:s,annotations:[]};if(i!=null)for(const a of this.additionAnnotations[i]??[])(e==="unified"?r:o).annotations.push(he(a));if(e==="unified")return r.annotations.length>0?r:void 0;if(!(o.annotations.length===0&&r.annotations.length===0))return{deletionSpan:r,additionSpan:o}}renderHeader(e){const{headerRenderMode:t,stickyHeader:i}=this.getOptionsWithDefaults();return st({fileOrDiff:e,mode:t,stickyHeader:i})}};function Ge(e){return e?.map(t=>he(t))??[]}const ii=new Intl.PluralRules("en-US");function We(e){return`${e} unmodified line${ii.select(e)==="one"?"":"s"}`}function $e(e,t){for(const i of e)t.unifiedContentAST.push(i.content),t.pushToGutter("unified",i.gutter),t.incrementRowCount(1)}function _e(e,t,i){for(const{deletion:n,addition:s}of e){if(n==null&&s==null)continue;const r=n!=null&&s!=null?void 0:n==null?"deletions":"additions";(r==null||i.side!==r)&&i.flush(),n!=null&&(t.deletionsContentAST.push(n.content),t.pushToGutter("deletions",n.gutter)),s!=null&&(t.additionsContentAST.push(s.content),t.pushToGutter("additions",s.gutter)),r!=null&&(i.side=r,i.increment()),t.incrementRowCount(1)}}function me({diffStyle:e,type:t,deletionLine:i,additionLine:n,unifiedSpan:s,deletionSpan:r,additionSpan:o,createAnnotationElement:a,context:l}){let u=!1;if(e==="unified"){if(n!=null?l.unifiedContentAST.push(n):i!=null&&l.unifiedContentAST.push(i),s!=null){const f=t==="change"?i!=null?"change-deletion":"change-addition":t;l.unifiedContentAST.push(a(s)),l.pushToGutter("unified",P(f,"annotation",1)),u=!0}}else if(e==="split"){if(i!=null&&l.deletionsContentAST.push(i),n!=null&&l.additionsContentAST.push(n),r!=null){const f=t==="change"?i!=null?"change-deletion":"context":t;l.deletionsContentAST.push(a(r)),l.pushToGutter("deletions",P(f,"annotation",1)),u=!0}if(o!=null){const f=t==="change"?n!=null?"change-addition":"context":t;l.additionsContentAST.push(a(o)),l.pushToGutter("additions",P(f,"annotation",1)),u=!0}}u&&l.incrementRowCount(1)}function De(e,{hunkIndex:t,collapsedLines:i,rangeSize:n,hunkSpecs:s,isFirstHunk:r,isLastHunk:o,isExpandable:a},l){if(i<=0)return;const u=e==="unified"?l.unifiedContentAST:e==="deletions"?l.deletionsContentAST:l.additionsContentAST;if(l.hunkSeparators==="metadata"){s!=null&&(l.pushToGutter(e,K({type:"metadata",content:s,isFirstHunk:r,isLastHunk:o})),u.push(K({type:"metadata",content:s,isFirstHunk:r,isLastHunk:o})),e!=="additions"&&l.incrementRowCount(1));return}if(l.hunkSeparators==="simple"){t>0&&(l.pushToGutter(e,K({type:"simple",isFirstHunk:r,isLastHunk:!1})),u.push(K({type:"simple",isFirstHunk:r,isLastHunk:!1})),e!=="additions"&&l.incrementRowCount(1));return}const f=Vt(e,t),h=n>l.expansionLineCount,d=a?t:void 0;l.pushToGutter(e,K({type:l.hunkSeparators,content:We(i),expandIndex:d,chunked:h,slotName:f,isFirstHunk:r,isLastHunk:o})),u.push(K({type:l.hunkSeparators,content:We(i),expandIndex:d,chunked:h,slotName:f,isFirstHunk:r,isLastHunk:o})),e!=="additions"&&l.incrementRowCount(1),l.hunkData.push({slotName:f,hunkIndex:t,lines:i,type:e,expandable:a?{up:!r,down:!o,chunked:h}:void 0})}function Ce(e,t,i){return e==null||e.type!=="element"||t==null&&i==null?e:{...e,properties:{...e.properties,...t,...i}}}function je(e,t){return{type:"element",tagName:"div",properties:{"data-line":e+1,"data-line-index":`${e},${e}`,"data-line-type":"context"},children:[{type:"element",tagName:"span",properties:{"data-char":0},children:[{type:"text",value:t.getLineText(e)}]}]}}function ni(e,t){return e.endsWith(`\r
|
|
6
|
+
`)}function Zt(e,t){const i=e.additionLineIndex,n=e.deletionLineIndex;e.hunkContent=t.hunkContent.map(s=>Qt(s,i,n)),e.additionLineIndex=i+t.additionLineIndex,e.additionStart=e.additionStart+t.additionLineIndex,e.additionCount=t.additionCount,e.additionLines=t.additionLines,t.deletionLineIndex>=0&&(e.deletionLineIndex=n+t.deletionLineIndex,e.deletionStart=e.deletionStart+t.deletionLineIndex),e.deletionCount=t.deletionCount,e.deletionLines=t.deletionLines,e.noEOFCRAdditions=t.noEOFCRAdditions,e.noEOFCRDeletions=t.noEOFCRDeletions,Qe(e)}function Qt(e,t,i){return{...e,additionLineIndex:e.additionLineIndex+t,deletionLineIndex:e.deletionLineIndex+i}}function Qe(e){let t=0,i=0;for(const n of e.hunkContent)n.type==="context"?(t+=n.lines,i+=n.lines):(t+=Math.max(n.additions,n.deletions),i+=n.additions+n.deletions);e.splitLineCount=t,e.unifiedLineCount=i}function Jt(e){let t=0,i=0,n=0;for(const s of e.hunks)s.collapsedBefore=Math.max(s.additionStart-1-n,0),s.splitLineStart=t+s.collapsedBefore,s.unifiedLineStart=i+s.collapsedBefore,Qe(s),t+=s.collapsedBefore+s.splitLineCount,i+=s.collapsedBefore+s.unifiedLineCount,n=s.additionStart+s.additionCount-1;if(e.hunks.length>0){const s=e.hunks[e.hunks.length-1],r=Math.max(e.additionLines.length-(s.additionLineIndex+s.additionCount),0);t+=r,i+=r}e.splitLineCount=t,e.unifiedLineCount=i}let ei=-1;var ti=class{options;onRenderUpdate;workerManager;__id=`diff-hunks-renderer:${++ei}`;highlighter;diff;expandedHunks=new Map;deletionAnnotations={};additionAnnotations={};computedLang="text";renderCache;constructor(e={theme:_},t,i){this.options=e,this.onRenderUpdate=t,this.workerManager=i,i?.isWorkingPool()!==!0&&(this.highlighter=Te(e.theme??_)?Tt():void 0)}cleanUp(){this.recycle(),this.expandedHunks.clear(),this.workerManager=void 0,this.onRenderUpdate=void 0}recycle(){this.highlighter=void 0,this.diff=void 0,this.clearRenderCache(),this.additionAnnotations={},this.deletionAnnotations={},this.workerManager?.cleanUpTasks(this)}getRenderDiff(){return this.renderCache?.diff??this.diff}clearRenderCache(){const e=this.renderCache;this.renderCache=void 0,e!=null&&e.isDirty===!0&&e.diff.cacheKey!=null&&this.workerManager?.evictDiffFromCache(e.diff.cacheKey)}setOptions(e){this.options=e}mergeOptions(e){this.options={...this.options,...e}}expandHunk(e,t,i=this.getOptionsWithDefaults().expansionLineCount){const n={...this.expandedHunks.get(e)??{fromStart:0,fromEnd:0}};(t==="up"||t==="both")&&(n.fromStart+=i),(t==="down"||t==="both")&&(n.fromEnd+=i),this.renderCache?.highlighted!==!0&&this.clearRenderCache(),this.expandedHunks.set(e,n)}getExpandedHunk(e){return this.expandedHunks.get(e)??Mt}getExpandedHunksMap(){return this.expandedHunks}setLineAnnotations(e){this.additionAnnotations={},this.deletionAnnotations={};for(const t of e){const i=(()=>{switch(t.side){case"deletions":return this.deletionAnnotations;case"additions":return this.additionAnnotations}})(),n=i[t.lineNumber]??[];i[t.lineNumber]=n,n.push(t)}}updateRenderCache(e,t,i=!1){if(this.renderCache==null)return;const{result:n,diff:s}=this.renderCache;if(n==null)return;if(s.isPartial)throw new Error("Could not update render cache for partial diff");const r=n.code.additionLines,o=[];for(const[a,l]of e){const u=r[a]?.properties??{},f=l.map(g=>g[2]).join(""),h=a<s.additionLines.length,d=h?s.additionLines[a]??"":"",c=Ie(d);h&&(s.additionLines[a]=ni(d,f),c!==f&&o.push(a)),r[a]={type:"element",tagName:"div",properties:{"data-line":u["data-line"]??a+1,"data-line-index":u["data-line-index"]??a,"data-line-type":u["data-line-type"]??"context"},children:l.map(([g,m,C])=>g===0&&m===""?C===""?{type:"element",tagName:"br",properties:{},children:[]}:{type:"text",value:C}:{type:"element",tagName:"span",properties:{"data-char":g,style:`--diffs-token-${t}:${m};`},children:[{type:"text",value:C}]})}}!i&&o.length>0&&Object.assign(s,jt(s,o,this.options.parseDiffOptions)),n.baseThemeType=t,this.renderCache.isDirty=!0}applyDocumentChange(e){if(this.renderCache==null)return;const{diff:t,result:i}=this.renderCache;if(i==null)return;t.additionLines=$t(e.getText());const n=t.additionLines.length,s=i.code.additionLines,r=s.length;n<r&&(s.length=n);for(let o=r;o<n;o++)s[o]??=je(o,e);t.isPartial||(n===0?(Object.assign(t,_t(t,this.options.parseDiffOptions)),s[0]=je(0,e)):Object.assign(t,G(t,this.options.parseDiffOptions))),this.renderCache.isDirty=!0}getUnifiedLineDecoration({lineType:e}){return{gutterLineType:e,contentProperties:{"data-line-type":e}}}getSplitLineDecoration({side:e,type:t}){const i=t==="change"?e==="deletions"?"change-deletion":"change-addition":t;return{gutterLineType:i,contentProperties:{"data-line-type":i}}}createAnnotationElement=e=>Je(e);getOptionsWithDefaults(){const{diffIndicators:e="bars",diffStyle:t="split",disableBackground:i=!1,disableFileHeader:n=!1,disableLineNumbers:s=!1,disableVirtualizationBuffers:r=!1,collapsed:o=!1,expandUnchanged:a=!1,collapsedContextThreshold:l=1,expansionLineCount:u=100,hunkSeparators:f="line-info",lineDiffType:h="word-alt",maxLineDiffLength:d=1e3,overflow:c="scroll",stickyHeader:g=!1,theme:m=_,headerRenderMode:C="default",tokenizeMaxLineLength:y=1e3,tokenizeMaxLength:v=It,useTokenTransformer:p=!1,useCSSClasses:S=!1}=this.options;return{diffIndicators:e,diffStyle:t,disableBackground:i,disableFileHeader:n,disableLineNumbers:s,disableVirtualizationBuffers:r,collapsed:o,expandUnchanged:a,collapsedContextThreshold:l,expansionLineCount:u,hunkSeparators:f,lineDiffType:h,maxLineDiffLength:d,overflow:c,stickyHeader:g,theme:this.workerManager?.getDiffRenderOptions().theme??m,headerRenderMode:C,tokenizeMaxLineLength:y,tokenizeMaxLength:v,useTokenTransformer:p,useCSSClasses:S}}async initializeHighlighter(){return this.highlighter=await At(et(this.computedLang,this.options)),this.highlighter}hydrate(e){if(e==null)return;this.diff=e;const{options:t}=this.getRenderOptions(e),i=Ee(e,this.getTokenizeMaxLength());let n=this.workerManager?.getDiffResultCache(e);n!=null&&!se(t,n.options)&&(n=void 0),this.renderCache??={diff:e,highlighted:!i&&!be(e),options:t,result:i?void 0:n?.result,renderRange:void 0},this.workerManager?.isWorkingPool()===!0?this.renderCache.result==null&&!i&&this.workerManager.highlightDiffAST(this,this.diff):this.highlighter==null&&(this.computedLang=e.lang??ke(e.name),this.initializeHighlighter())}getRenderOptions(e){const t=(()=>{if(this.workerManager?.isWorkingPool()===!0)return this.workerManager.getDiffRenderOptions();const{theme:n,tokenizeMaxLineLength:s,lineDiffType:r,maxLineDiffLength:o}=this.getOptionsWithDefaults();return{theme:n,useTokenTransformer:tt(this.options),tokenizeMaxLineLength:s,lineDiffType:r,maxLineDiffLength:o}})();this.getOptionsWithDefaults();const{renderCache:i}=this;return i?.result==null?{options:t,forceHighlight:!0}:!re(e,i.diff)||!se(t,i.options)?{options:t,forceHighlight:!0}:{options:t,forceHighlight:!1}}renderDiff(e=this.renderCache?.diff,t=Ve){if(e==null)return;const{expandUnchanged:i=!1,collapsedContextThreshold:n}=this.getOptionsWithDefaults();let{options:s,forceHighlight:r}=this.getRenderOptions(e);const o=this.getMatchingWorkerResultCache(e,s);o!=null&&!this.hasHighlightedRenderCache(e,s)&&(this.renderCache={diff:e,highlighted:!0,renderRange:void 0,...o},r=!1),this.renderCache??={diff:e,highlighted:!1,options:s,result:void 0,renderRange:void 0};const a=e.additionLines.length>0||e.deletionLines.length>0,l=!a||be(e)||Ee(e,this.getTokenizeMaxLength()),u=!re(e,this.renderCache.diff),f=!Xe(this.renderCache.renderRange,t);if(this.workerManager?.isWorkingPool()===!0)(l||this.renderCache.result==null||!this.renderCache.highlighted&&(u||f))&&(this.renderCache.diff=e,this.renderCache.options=s,this.renderCache.highlighted=!1,(this.renderCache.result==null||u||f||r)&&(this.renderCache.result=this.workerManager.getPlainDiffAST(e,t.startingLine,t.totalLines,Wt(t)||i?!0:this.expandedHunks,n)),this.renderCache.renderRange=t),!l&&a&&(!this.renderCache.highlighted||r)&&this.workerManager.highlightDiffAST(this,e);else{this.computedLang=e.lang??ke(e.name);const h=this.highlighter!=null&&Te(s.theme),d=this.highlighter!=null&&Fe(this.computedLang),c=!l&&d;if(this.highlighter!=null&&h&&(r||l||!this.renderCache.highlighted&&c||this.renderCache.result==null)){const{result:g,options:m}=this.renderDiffWithHighlighter(e,this.highlighter,l||!d);this.renderCache={diff:e,options:m,highlighted:c,result:g,renderRange:void 0}}(!h||!l&&!d)&&this.asyncHighlight(e).then(({result:g,options:m})=>{this.renderCache!=null&&(this.renderCache.highlighted=!1),this.onHighlightSuccess(e,g,m,!l)})}return this.renderCache.result!=null?this.processDiffResult(this.renderCache.diff,t,this.renderCache.result):void 0}async asyncRender(e,t=Ve){const{result:i}=await this.asyncHighlight(e);return this.processDiffResult(e,t,i)}createPreElement(e,t,i){const{diffIndicators:n,disableBackground:s,disableLineNumbers:r,overflow:o}=this.getOptionsWithDefaults();return it({type:"diff",diffIndicators:n,disableBackground:s,disableLineNumbers:r,overflow:o,split:e,totalLines:t,customProperties:i})}async asyncHighlight(e){const t=Ee(e,this.getTokenizeMaxLength());this.computedLang=t?"text":e.lang??ke(e.name);const i=this.highlighter!=null&&Te(this.options.theme??_),n=t||this.highlighter!=null&&Fe(this.computedLang);return(this.highlighter==null||!i||!n)&&(this.highlighter=await this.initializeHighlighter()),this.renderDiffWithHighlighter(e,this.highlighter,t)}renderDiffWithHighlighter(e,t,i=!1){const{options:n}=this.getRenderOptions(e),{collapsedContextThreshold:s}=this.getOptionsWithDefaults();return{result:Dt(e,t,n,{forcePlainText:i,expandedHunks:i?!0:void 0,collapsedContextThreshold:s}),options:n}}onHighlightSuccess(e,t,i,n=!0){if(this.renderCache==null)return;const s=!this.renderCache.highlighted||!se(this.renderCache.options,i)||!re(this.renderCache.diff,e);this.renderCache={diff:e,options:i,highlighted:n,result:t,renderRange:void 0},s&&this.onRenderUpdate?.()}getMatchingWorkerResultCache(e,t){const i=this.workerManager?.getDiffResultCache(e);if(!(i==null||!se(t,i.options)))return i}hasHighlightedRenderCache(e,t){const{renderCache:i}=this;return i?.result!=null&&i.highlighted&&re(e,i.diff)&&se(t,i.options)}onHighlightError(e){console.error(e)}getTokenizeMaxLength(){return this.options.tokenizeMaxLength??1e5}processDiffResult(e,t,{code:i,themeStyles:n,baseThemeType:s}){const{diffStyle:r,disableFileHeader:o,expandUnchanged:a,expansionLineCount:l,collapsedContextThreshold:u,hunkSeparators:f}=this.getOptionsWithDefaults(),h=this.renderCache?.isDirty??!1;this.diff=e;const d=r==="unified";let c=[],g=[],m=[];const C=[],{additionLines:y,deletionLines:v}=i,p={rowCount:0,hunkSeparators:f,additionsContentAST:c,deletionsContentAST:g,unifiedContentAST:m,unifiedGutterAST:ce(),deletionsGutterAST:ce(),additionsGutterAST:ce(),expansionLineCount:l,hunkData:C,incrementRowCount(R=1){p.rowCount+=R},pushToGutter(R,D){switch(R){case"unified":p.unifiedGutterAST.children.push(D);break;case"deletions":p.deletionsGutterAST.children.push(D);break;case"additions":p.additionsGutterAST.children.push(D);break}}},S=Et({fileDiff:e,errorPrefix:"DiffHunksRenderer.processDiffResult"}),H={size:0,side:void 0,increment(){this.size+=1},flush(){if(r!=="unified"){if(this.size<=0||this.side==null){this.side=void 0,this.size=0;return}this.side==="additions"?(p.pushToGutter("additions",P(void 0,"buffer",this.size)),c?.push(pe(this.size))):(p.pushToGutter("deletions",P(void 0,"buffer",this.size)),g?.push(pe(this.size))),this.size=0,this.side=void 0}}},T=(R,D,U,V,L)=>{p.pushToGutter(R,kt(D,U,V,L))};function F(R){H.flush(),r==="unified"?De("unified",R,p):(De("deletions",R,p),De("additions",R,p))}this.pushFileLevelAnnotations(e,r,t,p),ve({diff:e,diffStyle:r,startingLine:t.startingLine,totalLines:t.totalLines,expandedHunks:a?!0:this.expandedHunks,collapsedContextThreshold:u,callback:({hunkIndex:R,hunk:D,collapsedBefore:U,collapsedAfter:V,additionLine:L,deletionLine:A,type:x})=>{const I=A!=null?A.splitLineIndex:L.splitLineIndex,W=L!=null?L.unifiedLineIndex:A.unifiedLineIndex;r==="split"&&x!=="change"&&H.flush(),U>0&&F({hunkIndex:R,collapsedLines:U,rangeSize:Math.max(D?.collapsedBefore??0,0),hunkSpecs:D?.hunkSpecs,isFirstHunk:R===0,isLastHunk:!1,isExpandable:!e.isPartial});const J=r==="unified"?W:I,ee={type:x,hunkIndex:R,lineIndex:J,unifiedLineIndex:W,splitLineIndex:I,deletionLine:A,additionLine:L};if(r==="unified"){const k=this.getUnifiedInjectedRowsForLine?.(ee);k?.before!=null&&$e(k.before,p);let E=A!=null?v[A.lineIndex]:void 0,z=L!=null?y[L.lineIndex]:void 0;if(E==null&&z==null){const N="DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";throw console.error(N,{file:e.name}),new Error(N)}const $=x==="change"?L!=null?"change-addition":"change-deletion":x,O=this.getUnifiedLineDecoration({type:x,lineType:$,additionLineIndex:L?.lineIndex,deletionLineIndex:A?.lineIndex});T("unified",O.gutterLineType,L!=null?L.lineNumber:A.lineNumber,`${W},${I}`,O.gutterProperties),z!=null?z=Ce(z,O.contentProperties,h&&L!=null?{"data-line":L.lineNumber,"data-line-index":`${W},${I}`}:void 0):E!=null&&(E=Ce(E,O.contentProperties,h&&A!=null?{"data-line":A.lineNumber,"data-line-index":`${W},${I}`}:void 0)),me({diffStyle:"unified",type:x,deletionLine:E,additionLine:z,unifiedSpan:this.getAnnotations("unified",A?.lineNumber,L?.lineNumber,R,J),createAnnotationElement:N=>this.createAnnotationElement(N),context:p}),k?.after!=null&&$e(k.after,p)}else{const k=this.getSplitInjectedRowsForLine?.(ee);k?.before!=null&&_e(k.before,p,H);let E=A!=null?v[A.lineIndex]:void 0,z=L!=null?y[L.lineIndex]:void 0;const $=this.getSplitLineDecoration({side:"deletions",type:x,lineIndex:A?.lineIndex}),O=this.getSplitLineDecoration({side:"additions",type:x,lineIndex:L?.lineIndex});if(E==null&&z==null){const M="DiffHunksRenderer.processDiffResult: deletionLine and additionLine are null, something is wrong";throw console.error(M,{file:e.name}),new Error(M)}const N=(()=>{if(x==="change"){if(z==null)return"additions";if(E==null)return"deletions"}})();if(N!=null){if(H.side!=null&&H.side!==N)throw new Error("DiffHunksRenderer.processDiffResult: iterateOverDiff, invalid pending splits");H.side=N,H.increment()}const ne=this.getAnnotations("split",A?.lineNumber,L?.lineNumber,R,J);if(ne!=null&&H.size>0&&H.flush(),A!=null){const M=Ce(E,$.contentProperties,h?{"data-line":A.lineNumber,"data-line-index":`${A.unifiedLineIndex},${I}`}:void 0);T("deletions",$.gutterLineType,A.lineNumber,`${A.unifiedLineIndex},${I}`,$.gutterProperties),M!=null&&(E=M)}if(L!=null){const M=Ce(z,O.contentProperties,h?{"data-line":L.lineNumber,"data-line-index":`${L.unifiedLineIndex},${I}`}:void 0);T("additions",O.gutterLineType,L.lineNumber,`${L.unifiedLineIndex},${I}`,O.gutterProperties),M!=null&&(z=M)}me({diffStyle:"split",type:x,additionLine:z,deletionLine:E,...ne,createAnnotationElement:M=>this.createAnnotationElement(M),context:p}),k?.after!=null&&_e(k.after,p,H)}const fe=r==="split"&&D!=null&&I===D.splitLineStart+D.splitLineCount-1,ye=fe?D.noEOFCRDeletions:!1,He=fe?D.noEOFCRAdditions:!1,te=(A?.noEOFCR??!1)||ye,ie=(L?.noEOFCR??!1)||He;if(ie||te){if(r==="split"&&H.flush(),te){const k=x==="context"||x==="context-expanded"?x:"change-deletion";r==="unified"?(p.unifiedContentAST.push(ge(k)),p.pushToGutter("unified",P(k,"metadata",1))):(p.deletionsContentAST.push(ge(k)),p.pushToGutter("deletions",P(k,"metadata",1)),ie||(p.pushToGutter("additions",P(void 0,"buffer",1)),p.additionsContentAST.push(pe(1))))}if(ie){const k=x==="context"||x==="context-expanded"?x:"change-addition";r==="unified"?(p.unifiedContentAST.push(ge(k)),p.pushToGutter("unified",P(k,"metadata",1))):(p.additionsContentAST.push(ge(k)),p.pushToGutter("additions",P(k,"metadata",1)),te||(p.pushToGutter("deletions",P(void 0,"buffer",1)),p.deletionsContentAST.push(pe(1))))}p.incrementRowCount(1)}V>0&&f!=="simple"&&F({hunkIndex:x==="context-expanded"?R:R+1,collapsedLines:V,rangeSize:S,hunkSpecs:void 0,isFirstHunk:!1,isLastHunk:!0,isExpandable:!e.isPartial}),p.incrementRowCount(1)}}),r==="split"&&H.flush();const de=Math.max(Gt(e.hunks),e.additionLines.length??0,e.deletionLines.length??0),j=t.bufferBefore>0||t.bufferAfter>0,ue=!d&&e.type!=="deleted",q=!d&&e.type!=="new",b=p.rowCount>0||j;c=ue&&b?c:void 0,g=q&&b?g:void 0,m=d&&b?m:void 0;const Q=this.createPreElement(g!=null&&c!=null,de);return{unifiedGutterAST:d&&b?p.unifiedGutterAST.children:void 0,unifiedContentAST:m,deletionsGutterAST:q&&b?p.deletionsGutterAST.children:void 0,deletionsContentAST:g,additionsGutterAST:ue&&b?p.additionsGutterAST.children:void 0,additionsContentAST:c,hunkData:C,preNode:Q,themeStyles:n,baseThemeType:s,headerElement:o?void 0:this.renderHeader(this.diff),totalLines:de,rowCount:p.rowCount,bufferBefore:t.bufferBefore,bufferAfter:t.bufferAfter,css:""}}renderCodeAST(e,t){const i=e==="unified"?t.unifiedGutterAST:e==="deletions"?t.deletionsGutterAST:t.additionsGutterAST,n=e==="unified"?t.unifiedContentAST:e==="deletions"?t.deletionsContentAST:t.additionsContentAST;if(i==null||n==null)return;const s=ce(i);return s.properties.style=`grid-row: span ${t.rowCount}`,[s,nt(n,t.rowCount)]}renderFullAST(e,t=[]){const i=this.getOptionsWithDefaults().hunkSeparators==="line-info",n=this.renderCodeAST("unified",e);if(n!=null)return t.push(w({tagName:"code",children:n,properties:{"data-code":"","data-container-size":i?"":void 0,"data-unified":""}})),{...e.preNode,children:t};const s=this.renderCodeAST("deletions",e);s!=null&&t.push(w({tagName:"code",children:s,properties:{"data-code":"","data-container-size":i?"":void 0,"data-deletions":""}}));const r=this.renderCodeAST("additions",e);return r!=null&&t.push(w({tagName:"code",children:r,properties:{"data-code":"","data-container-size":i?"":void 0,"data-additions":""}})),{...e.preNode,children:t}}renderFullHTML(e,t=[]){return le(this.renderFullAST(e,t))}renderPartialHTML(e,t){return t==null?le(e):le(w({tagName:"code",children:e,properties:{"data-code":"","data-container-size":this.getOptionsWithDefaults().hunkSeparators==="line-info"?"":void 0,[`data-${t}`]:""}}))}pushFileLevelAnnotations(e,t,i,n){if(!Ye(i))return;const s=e.type!=="new"?Ge(Ne(this.deletionAnnotations)):[],r=e.type!=="deleted"?Ge(Ne(this.additionAnnotations)):[];if(s.length===0&&r.length===0)return;const o=-1,a=-1,{createAnnotationElement:l}=this;if(t==="unified"){me({diffStyle:t,type:"context",unifiedSpan:{type:"annotation",hunkIndex:o,lineIndex:a,annotations:s.concat(r)},createAnnotationElement:l,context:n});return}me({diffStyle:t,type:"context",deletionSpan:{type:"annotation",hunkIndex:o,lineIndex:a,annotations:s},additionSpan:{type:"annotation",hunkIndex:o,lineIndex:a,annotations:r},createAnnotationElement:l,context:n})}getAnnotations(e,t,i,n,s){const r={type:"annotation",hunkIndex:n,lineIndex:s,annotations:[]};if(t!=null)for(const a of this.deletionAnnotations[t]??[])r.annotations.push(he(a));const o={type:"annotation",hunkIndex:n,lineIndex:s,annotations:[]};if(i!=null)for(const a of this.additionAnnotations[i]??[])(e==="unified"?r:o).annotations.push(he(a));if(e==="unified")return r.annotations.length>0?r:void 0;if(!(o.annotations.length===0&&r.annotations.length===0))return{deletionSpan:r,additionSpan:o}}renderHeader(e){const{headerRenderMode:t,stickyHeader:i}=this.getOptionsWithDefaults();return st({fileOrDiff:e,mode:t,stickyHeader:i})}};function Ge(e){return e?.map(t=>he(t))??[]}const ii=new Intl.PluralRules("en-US");function We(e){return`${e} unmodified line${ii.select(e)==="one"?"":"s"}`}function $e(e,t){for(const i of e)t.unifiedContentAST.push(i.content),t.pushToGutter("unified",i.gutter),t.incrementRowCount(1)}function _e(e,t,i){for(const{deletion:n,addition:s}of e){if(n==null&&s==null)continue;const r=n!=null&&s!=null?void 0:n==null?"deletions":"additions";(r==null||i.side!==r)&&i.flush(),n!=null&&(t.deletionsContentAST.push(n.content),t.pushToGutter("deletions",n.gutter)),s!=null&&(t.additionsContentAST.push(s.content),t.pushToGutter("additions",s.gutter)),r!=null&&(i.side=r,i.increment()),t.incrementRowCount(1)}}function me({diffStyle:e,type:t,deletionLine:i,additionLine:n,unifiedSpan:s,deletionSpan:r,additionSpan:o,createAnnotationElement:a,context:l}){let u=!1;if(e==="unified"){if(n!=null?l.unifiedContentAST.push(n):i!=null&&l.unifiedContentAST.push(i),s!=null){const f=t==="change"?i!=null?"change-deletion":"change-addition":t;l.unifiedContentAST.push(a(s)),l.pushToGutter("unified",P(f,"annotation",1)),u=!0}}else if(e==="split"){if(i!=null&&l.deletionsContentAST.push(i),n!=null&&l.additionsContentAST.push(n),r!=null){const f=t==="change"?i!=null?"change-deletion":"context":t;l.deletionsContentAST.push(a(r)),l.pushToGutter("deletions",P(f,"annotation",1)),u=!0}if(o!=null){const f=t==="change"?n!=null?"change-addition":"context":t;l.additionsContentAST.push(a(o)),l.pushToGutter("additions",P(f,"annotation",1)),u=!0}}u&&l.incrementRowCount(1)}function De(e,{hunkIndex:t,collapsedLines:i,rangeSize:n,hunkSpecs:s,isFirstHunk:r,isLastHunk:o,isExpandable:a},l){if(i<=0)return;const u=e==="unified"?l.unifiedContentAST:e==="deletions"?l.deletionsContentAST:l.additionsContentAST;if(l.hunkSeparators==="metadata"){s!=null&&(l.pushToGutter(e,K({type:"metadata",content:s,isFirstHunk:r,isLastHunk:o})),u.push(K({type:"metadata",content:s,isFirstHunk:r,isLastHunk:o})),e!=="additions"&&l.incrementRowCount(1));return}if(l.hunkSeparators==="simple"){t>0&&(l.pushToGutter(e,K({type:"simple",isFirstHunk:r,isLastHunk:!1})),u.push(K({type:"simple",isFirstHunk:r,isLastHunk:!1})),e!=="additions"&&l.incrementRowCount(1));return}const f=Vt(e,t),h=n>l.expansionLineCount,d=a?t:void 0;l.pushToGutter(e,K({type:l.hunkSeparators,content:We(i),expandIndex:d,chunked:h,slotName:f,isFirstHunk:r,isLastHunk:o})),u.push(K({type:l.hunkSeparators,content:We(i),expandIndex:d,chunked:h,slotName:f,isFirstHunk:r,isLastHunk:o})),e!=="additions"&&l.incrementRowCount(1),l.hunkData.push({slotName:f,hunkIndex:t,lines:i,type:e,expandable:a?{up:!r,down:!o,chunked:h}:void 0})}function Ce(e,t,i){return e==null||e.type!=="element"||t==null&&i==null?e:{...e,properties:{...e.properties,...t,...i}}}function je(e,t){return{type:"element",tagName:"div",properties:{"data-line":e+1,"data-line-index":`${e},${e}`,"data-line-type":"context"},children:[{type:"element",tagName:"span",properties:{"data-char":0},children:[{type:"text",value:t.getLineText(e)}]}]}}function ni(e,t){return e.endsWith(`\r
|
|
7
7
|
`)?t+`\r
|
|
8
8
|
`:e.endsWith("\r")?t+"\r":e.endsWith(`
|
|
9
9
|
`)?t+`
|
|
10
|
-
`:t}function Ee(e,t){return Math.max(e.additionLines.length,e.deletionLines.length)>t}function si(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function ri(e,t){return e.slotName===t.slotName&&e.hunkIndex===t.hunkIndex&&e.lines===t.lines&&e.type===t.type&&e.expandable?.chunked===t.expandable?.chunked&&e.expandable?.up===t.expandable?.up&&e.expandable?.down===t.expandable?.down}function oi(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:e?.useTokenTransformer,tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,diffStyle:e?.diffStyle,diffIndicators:e?.diffIndicators,disableBackground:e?.disableBackground,hunkSeparators:typeof e?.hunkSeparators=="function"?"custom":e?.hunkSeparators,expandUnchanged:e?.expandUnchanged,collapsedContextThreshold:e?.collapsedContextThreshold,lineDiffType:e?.lineDiffType,maxLineDiffLength:e?.maxLineDiffLength,expansionLineCount:e?.expansionLineCount,headerRenderMode:e?.renderCustomHeader!=null?"custom":"default"}}let ai=-1;var li=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file-diff:${++ai}`;type="file-diff";fileContainer;spriteSVG;pre;codeUnified;codeDeletions;codeAdditions;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;headerElement;headerPrefix;headerFilenameSuffix;headerMetadata;headerCustom;separatorCache=new Map;errorWrapper;placeHolder;hunksRenderer;resizeManager;scrollSyncManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;deletionFile;additionFile;fileDiff;renderRange;appliedPreAttributes;lastRenderedHeaderHTML;cachedHeaderHTML;lastRowCount;mounted=!1;enabled=!0;editor;fastRefreshTimeout;constructor(e={theme:_},t,i=!1){this.options=e,this.workerManager=t,this.isContainerManaged=i,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new rt,this.scrollSyncManager=new Bt,this.interactionManager=new ot("diff",Pe(e,typeof e.hunkSeparators=="function"||(e.hunkSeparators??"line-info")==="line-info"||e.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex)),this.workerManager?.subscribeToThemeChanges(this),this.enabled=!0}handleHighlightRender=()=>{this.rerender()};getHunksRendererOptions(e){return oi(e)}createHunksRenderer(e){return new ti(this.getHunksRendererOptions(e),this.handleHighlightRender,this.workerManager)}getLineIndex=(e,t="additions")=>{const i=this.hunksRenderer.getRenderDiff()??this.fileDiff;if(i==null)return;const n=i.hunks.at(-1);let s,r;e:for(const o of i.hunks){let a=t==="deletions"?o.deletionStart:o.additionStart;const l=t==="deletions"?o.deletionCount:o.additionCount;let u=o.splitLineStart,f=o.unifiedLineStart;if(e<a){const h=a-e;s=Math.max(f-h,0),r=Math.max(u-h,0);break e}if(e>=a+l){if(o===n){const h=e-(a+l);s=f+o.unifiedLineCount+h,r=u+o.splitLineCount+h;break e}continue}for(const h of o.hunkContent)if(h.type==="context")if(e<a+h.lines){const d=e-a;r=u+d,s=f+d;break e}else a+=h.lines,u+=h.lines,f+=h.lines;else{const d=t==="deletions"?h.deletions:h.additions;if(e<a+d){const c=e-a;s=f+(t==="additions"?h.deletions:0)+c,r=u+c;break e}else a+=d,u+=Math.max(h.deletions,h.additions),f+=h.deletions+h.additions}break e}if(!(s==null||r==null))return[s,r]};setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(Pe(this.options,typeof this.options.hunkSeparators=="function"||(this.options.hunkSeparators??"line-info")==="line-info"||this.options.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??"system")!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme=="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;const t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType===t?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!Rt(this.appliedThemeCSS.theme,this.options.theme??_)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}canPartiallyRender(e,t,i){return!(e||t||i||typeof this.options.hunkSeparators=="function")}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}const{diffStyle:e="split",overflow:t="scroll"}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,t==="wrap"),t==="scroll"&&e==="split"?this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp(),this.managersDirty=!1}cleanUp(e=!1){this.emitPostRender(!0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.placeHolder=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,e?this.hunksRenderer.recycle():(this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.deletionFile=void 0,this.additionFile=void 0),this.enabled=!1,this.editor?.cleanUp(),this.editor=void 0,this.fastRefreshTimeout!=null&&(clearTimeout(this.fastRefreshTimeout),this.fastRefreshTimeout=void 0)}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){const{fileContainer:t,prerenderedHTML:i,preventEmit:n=!1,lineAnnotations:s,oldFile:r,newFile:o,fileDiff:a}=e;this.hydrateElements(t,i),ui(this.pre,hi({fileDiff:a,oldFile:r,newFile:o}),this.options.collapsed)||fi(this.headerElement,di({fileDiff:a,oldFile:r,newFile:o}),this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({fileDiff:a,oldFile:r,newFile:o,lineAnnotations:s}),n||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),at(e,t);for(const i of e.shadowRoot?.children??[]){if(i instanceof SVGElement){this.spriteSVG=i;continue}if(i instanceof HTMLElement){if(i instanceof HTMLPreElement){this.pre=i;for(const n of i.children)!(n instanceof HTMLElement)||n.tagName.toLowerCase()!=="code"||("deletions"in n.dataset&&(this.codeDeletions=n),"additions"in n.dataset&&(this.codeAdditions=n),"unified"in n.dataset&&(this.codeUnified=n));continue}if("diffsHeader"in i.dataset){this.headerElement=i;continue}if(i instanceof HTMLStyleElement&&i.hasAttribute("data-theme-css")){this.themeCSSStyle=i;continue}if(i instanceof HTMLStyleElement&&i.hasAttribute("data-unsafe-css")){this.unsafeCSSStyle=i,this.appliedUnsafeCSS=i.textContent;continue}}}this.pre!=null&&(this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute("data-dehydrated")),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({fileDiff:e,oldFile:t,newFile:i,lineAnnotations:n}){this.lineAnnotations=n??this.lineAnnotations,this.additionFile=i,this.deletionFile=t,this.fileDiff=e??(t!=null&&i!=null?J(t,i,this.options.parseDiffOptions):void 0),this.pre!=null&&(this.syncInteractionOptions(),this.hunksRenderer.hydrate(this.fileDiff),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||this.render({forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.hunksRenderer.clearRenderCache(),this.rerender()}handleExpandHunk=(e,t,i)=>{this.expandHunk(e,t,i)};expandHunk=(e,t,i)=>{this.hunksRenderer.expandHunk(e,t,i),this.rerender()};render({oldFile:e,newFile:t,fileDiff:i,deferManagers:n=!1,forceRender:s=!1,preventEmit:r=!1,lineAnnotations:o,fileContainer:a,containerWrapper:l,renderRange:u}){if(!this.enabled)throw new Error("FileDiff.render: attempting to call render after cleaned up");this.editor?.__postponeBackgroundTokenizeToNextFrame();const{collapsed:f=!1,themeType:h="system"}=this.options,d=f?void 0:u,c=this.hasThemeChanged(),g=e!=null&&t!=null&&(!Be(e,this.deletionFile)||!Be(t,this.additionFile));let m=i!=null&&i!==this.fileDiff;const C=o!=null&&(o.length>0||this.lineAnnotations.length>0)?o!==this.lineAnnotations:!1;if(!f&&Xe(d,this.renderRange)&&!s&&!C&&!c&&(i!=null&&i===this.fileDiff||i==null&&!g))return this.applyCachedThemeState(h);const{renderRange:y}=this;if(this.renderRange=d,this.deletionFile=e,this.additionFile=t,i!=null?this.fileDiff=i:e!=null&&t!=null&&g&&(m=!0,this.fileDiff=J(e,t,this.options.parseDiffOptions)),m&&(this.cachedHeaderHTML=void 0),o!=null&&this.setLineAnnotations(o),this.fileDiff==null)return!1;this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.hunksRenderer.setLineAnnotations(this.lineAnnotations);const{disableErrorHandling:v=!1,disableFileHeader:p=!1}=this.options;if(p&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),a=this.getOrCreateFileContainer(a,l),this.applyCachedThemeState(h),f){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{const S=this.hunksRenderer.renderDiff(this.fileDiff,zt);S!=null&&this.applyThemeState(a,S.themeStyles,h,S.baseThemeType),S?.headerElement!=null&&this.applyHeaderToDOM(S.headerElement,a),this.renderSeparators([]),this.injectUnsafeCSS()}catch(S){if(v)throw S;console.error(S),S instanceof Error&&this.applyErrorToDOM(S,a)}return r||this.emitPostRender(),!0}try{const S=this.getOrCreatePreNode(a);if(!(this.canPartiallyRender(s,C,g||m||c)&&this.applyPartialRender({previousRenderRange:y,renderRange:d}))){const L=this.hunksRenderer.renderDiff(this.fileDiff,d);if(L==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(a,L.themeStyles,h,L.baseThemeType),L.headerElement!=null&&this.applyHeaderToDOM(L.headerElement,a),L.additionsContentAST!=null||L.deletionsContentAST!=null||L.unifiedContentAST!=null?this.applyHunksToDOM(S,L):this.pre!=null&&(this.pre.remove(),this.pre=void 0),this.renderSeparators(L.hunkData)}this.applyBuffers(S,d),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,n||this.flushManagers(),this.editor!=null&&this.syncRenderViewToEditor()}catch(S){if(v)throw S;console.error(S),S instanceof Error&&this.applyErrorToDOM(S,a)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){const{fileContainer:t,options:{onPostRender:i}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;this.options.onPostRender?.(t,this,"unmount");return}if(t==null)return;const n=this.mounted?"update":"mount";this.mounted=!0,i?.(t,this,n)}syncRenderViewToEditor(){const e=this.editor,t=this.fileContainer,i=this.fileDiff;e!=null&&t!=null&&i!=null&&!i.isPartial&&this.hunksRenderer.initializeHighlighter().then(n=>{e.__syncRenderView(n,t,i,this.lineAnnotations,this.renderRange)})}attachEditor(e){return this.editor?.cleanUp(),this.editor=e,this.interactionManager.setEditorAttached(!0),this.syncRenderViewToEditor(),()=>{this.editor=void 0,this.interactionManager.setEditorAttached(!1)}}applyDocumentChange(e,t){this.hunksRenderer.applyDocumentChange(e);const i=this.hunksRenderer.getRenderDiff();i!=null&&(this.fileDiff=i),this.rerender(),this.interactionManager.setSelectionDirty(),t!==void 0&&t!==this.lineAnnotations&&(this.setLineAnnotations(t),this.hunksRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations())}rerenderFromDocument(e){this.hunksRenderer.applyDocumentChange(e);const t=this.hunksRenderer.getRenderDiff();t!=null&&(this.fileDiff=t),this.hunksRenderer.clearRenderCache(),this.rerender()}updateRenderCache(e,t,i,n){this.hunksRenderer.updateRenderCache(e,t,n),i===!0&&(this.options.diffStyle==="split"?(this.fastRefreshTimeout!=null&&clearTimeout(this.fastRefreshTimeout),this.fastRefreshTimeout=setTimeout(()=>{this.fastRefreshTimeout=void 0,this.fastRefreshDiffView()},100)):this.refreshDiffView())}removeRenderedCode(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(const{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();for(const{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){const t=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",t.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${e}px`),!0}primeHighlightCache(){const{fileDiff:e,workerManager:t}=this;if(e==null||t==null||be(e))return;const i=this.options.tokenizeMaxLength??1e5;Math.max(e.additionLines.length,e.deletionLines.length)>i||t.primeDiffHighlightCache(e)}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderSeparators(e){const{hunkSeparators:t}=this.options;if(this.isContainerManaged||this.fileContainer==null||typeof t!="function"){for(const{element:n}of this.separatorCache.values())n.remove();this.separatorCache.clear();return}const i=new Map(this.separatorCache);for(const n of e){const s=n.slotName;let r=this.separatorCache.get(s);if(r==null||!ri(n,r.hunkData)){r?.element.remove();const o=document.createElement("div");o.style.display="contents",o.slot=n.slotName;const a=t(n,this);a!=null&&o.appendChild(a),this.fileContainer.appendChild(o),r={element:o,hunkData:n},this.separatorCache.set(s,r)}i.delete(s)}for(const[n,{element:s}]of i.entries())this.separatorCache.delete(n),s.remove()}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(const{element:i}of this.annotationCache.values())i.remove();this.annotationCache.clear();return}const e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(const[i,n]of this.lineAnnotations.entries()){const s=`${i}-${he(n)}`;let r=this.annotationCache.get(s);if(r==null||!si(n,r.annotation)){r?.element.remove();const o=t(n);if(o==null)continue;r={element:lt(he(n)),annotation:n},r.element.appendChild(o),this.fileContainer.appendChild(r.element),this.annotationCache.set(s,r)}e.delete(s)}for(const[i,{element:n}]of e.entries())this.annotationCache.delete(i),n.remove()}renderGutterUtility(){const{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const i=ht();i.appendChild(t),this.fileContainer.appendChild(i),this.gutterUtilityContent=i}getOrCreateFileContainer(e,t){const{fileContainer:i}=this,n=e??i??document.createElement("diffs-container"),s=i!==n;return s&&this.emitPostRender(!0),this.fileContainer=n,i!=null&&s&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),s&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){const{shadowRoot:t}=e;if(t!=null)for(const i of t.children)i instanceof SVGElement?this.spriteSVG??=i:Ue(i)&&i.hasAttribute("data-theme-css")?(this.themeCSSStyle??=i,this.hasAdoptedThemeCSS=!0):Ue(i)&&i.hasAttribute("data-unsafe-css")&&(this.unsafeCSSStyle??=i,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.spriteSVG==null){const i=document.createElement("div");i.innerHTML=dt;const n=i.firstChild;n instanceof SVGElement&&(this.spriteSVG=n)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});return this.pre==null?(this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(t.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(e){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(const t of Array.from(e.children))t instanceof HTMLElement&&(t.hasAttribute("data-unified")?this.codeUnified=t:t.hasAttribute("data-deletions")?this.codeDeletions=t:t.hasAttribute("data-additions")&&(this.codeAdditions=t))}applyHeaderToDOM(e,t){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;const{fileDiff:i}=this,n=this.cachedHeaderHTML??le(e);if(this.cachedHeaderHTML=n,n!==this.lastRenderedHeaderHTML){const h=document.createElement("div");h.innerHTML=n;const d=h.firstElementChild;if(!(d instanceof HTMLElement))return;this.headerElement!=null?t.shadowRoot?.replaceChild(d,this.headerElement):t.shadowRoot?.prepend(d),this.headerElement=d,this.lastRenderedHeaderHTML=n}if(this.isContainerManaged||i==null)return;const{renderCustomHeader:s,renderHeaderPrefix:r,renderHeaderFilenameSuffix:o,renderHeaderMetadata:a}=this.options;if(s!=null){const h=s(i)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,Ft,h),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0;return}const l=r?.(i)??void 0,u=o?.(i)??void 0,f=a?.(i)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,Nt,l),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,Pt,u),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,Ut,f),this.headerCustom?.remove(),this.headerCustom=void 0}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,i,n){if(n==null){t?.remove();return}const s=t??this.createHeaderSlotElement(i);return t==null&&e.appendChild(s),this.replaceHeaderSlotContent(s,n),s}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){const t=document.createElement("div");return t.slot=e,t}injectUnsafeCSS(){const{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===""){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??=ut(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=ft(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,i,n){const s=e.shadowRoot??e.attachShadow({mode:"open"}),r=n??i,o=this.options.theme??_,a=typeof o=="string"?o:{...o},l=Oe(s);if(this.themeCSSStyle?.parentNode===s&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===r&&this.appliedThemeCSS.scrollbarGutter===l){this.appliedThemeCSS.theme=a;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===s){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:a,themeStyles:t,themeType:r,baseThemeType:n,scrollbarGutter:l};return}this.themeCSSStyle=ct({shadowRoot:s,currentNode:this.themeCSSStyle,themeCSS:Ct(t,r,l)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:a,themeStyles:t,themeType:r,baseThemeType:n,scrollbarGutter:l}:void 0}hydrateMeasuredScrollbar(){const e=this.fileContainer?.shadowRoot;e==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=pt(this.themeCSSStyle.textContent??"",Oe(e)))}applyHunksToDOM(e,t){const{overflow:i="scroll"}=this.options,n=(this.options.hunkSeparators??"line-info")==="line-info",s=i==="wrap"?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let r=!1;const o=[],a=this.hunksRenderer.renderCodeAST("unified",t),l=this.hunksRenderer.renderCodeAST("deletions",t),u=this.hunksRenderer.renderCodeAST("additions",t);a!=null?(r=this.codeUnified==null||this.codeAdditions!=null||this.codeDeletions!=null,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.codeUnified=Ae({code:this.codeUnified,columnType:"unified",rowSpan:s,containerSize:n}),this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(a),o.push(this.codeUnified)):l!=null||u!=null?(l!=null?(r=this.codeDeletions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=Ae({code:this.codeDeletions,columnType:"deletions",rowSpan:s,containerSize:n}),this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(l),o.push(this.codeDeletions)):(this.codeDeletions?.remove(),this.codeDeletions=void 0),u!=null?(r=r||this.codeAdditions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=Ae({code:this.codeAdditions,columnType:"additions",rowSpan:s,containerSize:n}),this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(u),o.push(this.codeAdditions)):(this.codeAdditions?.remove(),this.codeAdditions=void 0)):(this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0),o.length===0?e.textContent="":r&&e.replaceChildren(...o),this.lastRowCount=t.rowCount}applyPartialRender({previousRenderRange:e,renderRange:t}){const{pre:i,codeUnified:n,codeAdditions:s,codeDeletions:r,options:{diffStyle:o="split"}}=this;if(i==null||e==null||t==null||!Number.isFinite(e.totalLines)||!Number.isFinite(t.totalLines)||this.lastRowCount==null)return!1;const a=this.getCodeColumns(o,n,r,s);if(a==null)return!1;const l=e.startingLine,u=t.startingLine,f=l+e.totalLines,h=u+t.totalLines,d=Math.max(l,u),c=Math.min(f,h);if(c<=d)return!1;const g=Math.max(0,d-l),m=Math.max(0,f-c),C=this.trimColumns({columns:a,trimStart:g,trimEnd:m,previousStart:l,overlapStart:d,overlapEnd:c,diffStyle:o});if(C<0)throw new Error("applyPartialRender: failed to trim to overlap");if(this.lastRowCount<C)throw new Error("applyPartialRender: trimmed beyond DOM row count");let y=this.lastRowCount-C;const v=(T,F)=>{if(!(F<=0||this.fileDiff==null))return this.hunksRenderer.renderDiff(this.fileDiff,{startingLine:T,totalLines:F,bufferBefore:0,bufferAfter:0})},p=v(u,Math.max(d-u,0));if(p==null&&u<d)return!1;const S=v(c,Math.max(h-c,0));if(S==null&&h>c)return!1;const L=(T,F)=>{if(T!=null){if(o==="unified"&&!Array.isArray(a))this.insertPartialHTML(o,a,T,F);else if(o==="split"&&Array.isArray(a))this.insertPartialHTML(o,a,T,F);else throw new Error("FileDiff.applyPartialRender.applyChunk: invalid chunk application");y+=T.rowCount}};return this.cleanupErrorWrapper(),L(p,"afterbegin"),L(S,"beforeend"),this.lastRowCount!==y&&(this.applyRowSpan(o,a,y),this.lastRowCount=y),!0}insertPartialHTML(e,t,i,n){if(e==="unified"&&!Array.isArray(t)){const s=this.hunksRenderer.renderCodeAST("unified",i);this.renderPartialColumn(t,s,n)}else if(e==="split"&&Array.isArray(t)){const s=this.hunksRenderer.renderCodeAST("deletions",i),r=this.hunksRenderer.renderCodeAST("additions",i);this.renderPartialColumn(t[0],s,n),this.renderPartialColumn(t[1],r,n)}else throw new Error("FileDiff.insertPartialHTML: Invalid argument composition")}fastRefreshDiffView(){if(this.options.diffStyle!=="split")return;const e=this.hunksRenderer.renderDiff(this.fileDiff,this.renderRange);if(e==null)return;const t=this.getCodeColumns("split",this.codeUnified,this.codeDeletions,this.codeAdditions);if(!Array.isArray(t))return;const i=(n,s)=>{if(s==null)return;const r=this.hunksRenderer.renderCodeAST(n,e),o=X(r?.[0]),a=X(r?.[1]);for(const[l,u]of[[s.gutter,o],[s.content,a]])if(u!=null&&l.childElementCount===u.length)for(let f=0;f<u.length;f++){const h=l.children[f],d=u[f].properties["data-line-type"];d!=null&&h.dataset.lineType!==d&&(h.dataset.lineType=d)}};i("deletions",t[0]),i("additions",t[1])}refreshDiffView(){const e=this.hunksRenderer.renderDiff(this.fileDiff,this.renderRange);if(e==null)return;const t=this.getCodeColumns(this.options.diffStyle??"split",this.codeUnified,this.codeDeletions,this.codeAdditions);if(t==null)return;const i=(n,s)=>{if(s==null)return;const r=this.hunksRenderer.renderCodeAST(n,e),o=X(r?.[0]),a=X(r?.[1]);for(const[l,u]of[[s.gutter,o],[s.content,a]])u!=null&&(l.innerHTML=le(u))};Array.isArray(t)?(i("deletions",t[0]),i("additions",t[1])):i("unified",t),this.syncRenderViewToEditor()}renderPartialColumn(e,t,i){if(e==null||t==null)return;const n=X(t[0]),s=X(t[1]);if(n==null||s==null)throw new Error("FileDiff.insertPartialHTML: Unexpected AST structure");const r=s.at(0);i==="beforeend"&&r?.type==="element"&&typeof r.properties["data-buffer-size"]=="number"&&this.mergeBuffersIfNecessary(r.properties["data-buffer-size"],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],n,s,!0);const o=s.at(-1);i==="afterbegin"&&o?.type==="element"&&typeof o.properties["data-buffer-size"]=="number"&&this.mergeBuffersIfNecessary(o.properties["data-buffer-size"],e.content.children[0],e.gutter.children[0],n,s,!1),e.gutter.insertAdjacentHTML(i,this.hunksRenderer.renderPartialHTML(n)),e.content.insertAdjacentHTML(i,this.hunksRenderer.renderPartialHTML(s))}mergeBuffersIfNecessary(e,t,i,n,s,r){if(!(t instanceof HTMLElement)||!(i instanceof HTMLElement))return;const o=this.getBufferSize(t.dataset);o!=null&&(r?(n.shift(),s.shift()):(n.pop(),s.pop()),this.updateBufferSize(t,o+e),this.updateBufferSize(i,o+e))}applyRowSpan(e,t,i){const n=s=>{s!=null&&(s.gutter.style.setProperty("grid-row",`span ${i}`),s.content.style.setProperty("grid-row",`span ${i}`))};if(e==="unified"&&!Array.isArray(t))n(t);else if(e==="split"&&Array.isArray(t))n(t[0]),n(t[1]);else throw new Error("dun fuuuuked up")}trimColumnRows(e,t,i){let n=0,s=0,r=0,o=!1;const a=i>=0;if(e==null)return 0;const l=Array.from(e.content.children),u=Array.from(e.gutter.children);if(l.length!==u.length)throw new Error("FileDiff.trimColumnRows: columns do not match");for(;r<l.length&&!(t<=0&&!a&&!o);){const f=u[r],h=l[r];if(r++,!(f instanceof HTMLElement)||!(h instanceof HTMLElement))throw console.error({gutterElement:f,contentElement:h}),new Error("FileDiff.trimColumnRows: invalid row elements");if(o&&(o=!1,f.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in h.dataset||f.dataset.gutterBuffer==="metadata"&&"noNewline"in h.dataset)){f.remove(),h.remove(),s++;continue}if("lineIndex"in f.dataset&&"lineIndex"in h.dataset){(t>0||a&&n>=i)&&(f.remove(),h.remove(),t>0&&(t--,t===0&&(o=!0)),s++),n++;continue}if("separator"in f.dataset&&"separator"in h.dataset){(t>0||a&&n>=i)&&(f.remove(),h.remove(),s++);continue}if(f.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in h.dataset){(t>0||a&&n>=i)&&(f.remove(),h.remove(),s++);continue}if(f.dataset.gutterBuffer==="metadata"&&"noNewline"in h.dataset){(t>0||a&&n>=i)&&(f.remove(),h.remove(),s++);continue}if(f.dataset.gutterBuffer==="buffer"&&"contentBuffer"in h.dataset){const d=this.getBufferSize(h.dataset);if(d==null)throw new Error("FileDiff.trimColumnRows: invalid element");if(t>0){const c=Math.min(t,d),g=d-c;g>0?(this.updateBufferSize(f,g),this.updateBufferSize(h,g),s+=c):(f.remove(),h.remove(),s+=d),t-=c,t===0&&g===0&&(o=!0)}else if(a){const c=n,g=n+d-1;if(i<=c)f.remove(),h.remove(),s+=d;else if(i<=g){const m=g-i+1,C=d-m;this.updateBufferSize(f,C),this.updateBufferSize(h,C),s+=m}}n+=d;continue}throw console.error({gutterElement:f,contentElement:h}),new Error("FileDiff.trimColumnRows: unknown row elements")}return s}trimColumns({columns:e,diffStyle:t,overlapEnd:i,overlapStart:n,previousStart:s,trimEnd:r,trimStart:o}){const a=Math.max(0,n-s),l=i-s;if(l<0)throw new Error("FileDiff.trimColumns: overlap ends before previous");const u=o>0,f=r>0;if(!u&&!f)return 0;const h=u?a:0,d=f?l:-1;if(t==="unified"&&!Array.isArray(e))return this.trimColumnRows(e,h,d);if(t==="split"&&Array.isArray(e)){const c=this.trimColumnRows(e[0],h,d),g=this.trimColumnRows(e[1],h,d);if(e[0]!=null&&e[1]!=null&&c!==g)throw new Error("FileDiff.trimColumns: split columns out of sync");return e[0]!=null?c:g}else throw console.error({diffStyle:t,columns:e}),new Error("FileDiff.trimColumns: Invalid columns for diffType")}getBufferSize(e){const t=Number.parseInt(e?.bufferSize??"",10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty("grid-row",`span ${t}`),e.style.setProperty("min-height",`calc(${t} * 1lh)`)}getCodeColumns(e,t,i,n){function s(r){if(r==null)return;const o=r.children[0],a=r.children[1];if(!(!(o instanceof HTMLElement)||!(a instanceof HTMLElement)||o.dataset.gutter==null||a.dataset.content==null))return{gutter:o,content:a}}if(e==="unified")return s(t);{const r=s(i),o=s(n);return r!=null||o!=null?[r,o]:void 0}}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore==null&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter==null&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyPreNodeAttributes(e,{additionsContentAST:t,deletionsContentAST:i,totalLines:n},s){const{diffIndicators:r="bars",disableBackground:o=!1,disableLineNumbers:a=!1,overflow:l="scroll",diffStyle:u="split"}=this.options,f={type:"diff",diffIndicators:r,disableBackground:o,disableLineNumbers:a,overflow:l,split:u==="unified"?!1:t!=null&&i!=null,totalLines:n,customProperties:s};gt(f,this.appliedPreAttributes)||(mt(e,f),this.appliedPreAttributes=f)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;const i=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??=document.createElement("div"),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.textContent="",i.appendChild(this.errorWrapper);const n=document.createElement("div");n.dataset.errorMessage="",n.innerText=e.message,this.errorWrapper.appendChild(n);const s=document.createElement("pre");s.dataset.errorStack="",s.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(s)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function hi({fileDiff:e,oldFile:t,newFile:i}){return e!=null&&e.hunks.length>0||t!=null||i!=null}function di({fileDiff:e,oldFile:t,newFile:i}){return e!=null||t!=null||i!=null}function ui(e,t,i=!1){return!i&&e==null&&t}function fi(e,t,i=!1){return e==null&&t&&!i}function X(e){if(!(e==null||e.type!=="element"))return e.children??[]}function ci({fileDiff:e,metrics:t,disableFileHeader:i,hunkSeparators:n,expandUnchanged:s,expandedHunks:r,collapsedContextThreshold:o}){let a=Y(t,i),l=a;const u=s?!0:r,f=e.hunks.length-1;for(let h=0;h<e.hunks.length;h++){const d=e.hunks[h];if(d==null)throw new Error("computeEstimatedDiffHeights: invalid hunk index");const c=we({isPartial:e.isPartial,rangeSize:d.collapsedBefore,expandedHunks:u,hunkIndex:h,collapsedContextThreshold:o}),g=(c.fromStart+c.fromEnd)*t.lineHeight;if(a+=g,l+=g,c.collapsedLines>0){const y=oe({type:n,metrics:t,hunkIndex:h,hunkSpecs:d.hunkSpecs})?.totalHeight??0;a+=y,l+=y}a+=d.splitLineCount*t.lineHeight,l+=d.unifiedLineCount*t.lineHeight;const m=pi(d);a+=m.split*t.lineHeight,l+=m.unified*t.lineHeight;const C=h===f?Me({fileDiff:e,hunkIndex:h,expandedHunks:u,collapsedContextThreshold:o,errorPrefix:"computeEstimatedDiffHeights"}):void 0;if(C!=null){const y=(C.fromStart+C.fromEnd)*t.lineHeight;if(a+=y,l+=y,C.collapsedLines>0){const v=ae({type:n,metrics:t})?.totalHeight??0;a+=v,l+=v}}}if(e.hunks.length>0){const h=Je(t);a+=h,l+=h}return{splitHeight:a,unifiedHeight:l}}function pi(e){if(!e.noEOFCRAdditions&&!e.noEOFCRDeletions)return{split:0,unified:0};const t=e.hunkContent.at(-1);if(t==null)return{split:0,unified:0};if(t.type==="context"){const i=t.lines>0?1:0;return{split:i,unified:i}}return gi(e,t)}function gi(e,t){const i=(t.deletions>0&&e.noEOFCRDeletions?1:0)+(t.additions>0&&e.noEOFCRAdditions?1:0),n=t.deletions>0&&e.noEOFCRDeletions,s=t.additions>0&&e.noEOFCRAdditions;return{split:n||s?1:0,unified:i}}const ze=5e3;let mi=-1;var Mi=class extends li{__id=`little-virtualized-file-diff:${++mi}`;top;height=0;metrics;cache={heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0,fileAnnotationHeight:0};isVisible=!1;isSetup=!1;virtualizer;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(e,t,i,n,s=!1){super(e,n,s),this.virtualizer=t,this.metrics=Re(i)}setMetrics(e,t=!1){const i=Re(e);!t&&St(this.metrics,i)||(this.metrics=i,this.resetLayoutCache({includeEstimatedHeights:!0}))}setLineAnnotations(e){this.syncLineAnnotations(e)&&this.resetLayoutCache({includeEstimatedHeights:!1})}syncLineAnnotations(e){return e==null||e===this.lineAnnotations||e.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(e),!0)}setFileAnnotationHeight(e){const t=this.cache.fileAnnotationHeight;return e===t?!1:(this.cache.fileAnnotationHeight=e,this.cache.measuredHeightDeltaTotal+=e-t,!0)}hasFileAnnotations(e=this.fileDiff){return e==null||!vt(this.lineAnnotations)?!1:this.lineAnnotations.some(t=>t.lineNumber!==0?!1:e.type==="new"?t.side==="additions":e.type==="deleted"?t.side==="deletions":!0)}getLineHeight(e,t=!1){return this.getEstimatedLineHeight(t)+(this.cache.heightDeltas.get(e)??0)}getEstimatedLineHeight(e=!1){const t=e?2:1;return this.metrics.lineHeight*t}setOptions(e){if(this.isAdvancedMode())throw new Error("VirtualizedFileDiff.setOptions cannot be used inside CodeView. Update CodeView options instead.");if(e==null)return;const{options:t}=this,i=!yt(t,e),n=i&&Hi(t,e);super.setOptions(e),n&&this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:Ti(t,e)}),i&&(this.forceRenderOverride=!0),i&&this.isSimpleMode()&&this.virtualizer.instanceChanged(this,n)}setThemeType(e){if(this.isAdvancedMode())throw new Error("VirtualizedFileDiff.setThemeType cannot be used inside CodeView. Update CodeView options instead.");super.setThemeType(e)}resetLayoutCache({forceSimpleRecompute:e=!1,includeEstimatedHeights:t=!1}={}){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heightDeltas.size>0&&this.cache.heightDeltas.clear(),this.cache.measuredHeightDeltaTotal!==0&&(this.cache.measuredHeightDeltaTotal=0),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.cache.totalLines!==0&&(this.cache.totalLines=0),t&&(this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0),this.renderRange!=null&&(this.renderRange=void 0),e&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let e=!1;const{overflow:t="scroll"}=this.options;if(this.fileContainer==null||this.fileDiff==null)return this.height!==0&&(e=!0),this.height=0,e;if(this.top=this.getVirtualizedTop(),t==="scroll"&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled())return e;const i=this.getDiffStyle(),n=i==="split"?[this.codeDeletions,this.codeAdditions]:[this.codeUnified],s=this.hasFileAnnotations(this.fileDiff);if(this.renderRange!=null&&s&&Ye(this.renderRange)){const r=Ci(n)??0;this.setFileAnnotationHeight(r)&&(e=!0)}else!s&&this.setFileAnnotationHeight(0)&&(e=!0);for(const r of n){if(r==null)continue;const o=r.children[1];if(o instanceof HTMLElement)for(const a of o.children){if(!(a instanceof HTMLElement))continue;const l=a.dataset.lineIndex;if(l==null)continue;const u=ki(l,i);let f=a.getBoundingClientRect().height,h=!1;a.nextElementSibling instanceof HTMLElement&&("lineAnnotation"in a.nextElementSibling.dataset||"noNewline"in a.nextElementSibling.dataset)&&("noNewline"in a.nextElementSibling.dataset&&(h=!0),f+=a.nextElementSibling.getBoundingClientRect().height);const d=this.getEstimatedLineHeight(h),c=this.cache.heightDeltas.get(u)??0,g=f-d;g!==c&&(e=!0,this.cache.measuredHeightDeltaTotal+=g-c,g===0?this.cache.heightDeltas.delete(u):this.cache.heightDeltas.set(u,g))}}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer==null?!1:(e&&(this.top=this.getVirtualizedTop()),this.render());prepareCodeViewItem(e,t,i,n){const s=!re(this.fileDiff,e),r=this.syncLineAnnotations(n);let o=i?.resetDiffLayoutCache===!0||s||r,a=s||i?.resetDiffLayoutCache===!0&&i.includeEstimatedDiffHeights;i?.metrics!=null&&(this.metrics=Re(i.metrics),o=!0,a=!0);const{collapsed:l=!1}=this.options;return this.currentCollapsed!==l&&(this.currentCollapsed=l,o=!0),o&&this.resetLayoutCache({includeEstimatedHeights:a}),this.fileDiff=e,this.top=t,this.computeApproximateSize(),this.height}getLinePosition(e,t="additions"){if(this.fileDiff==null||e<1)return;const i=this.getLineIndex(e,t);if(i==null)return;const{disableFileHeader:n=!1,expandUnchanged:s=!1,collapsed:r=!1,collapsedContextThreshold:o=1}=this.options,a=this.getDiffStyle(),l=this.getHunkSeparatorType(),u=a==="split"?i[1]:i[0];this.approximateLayoutCheckpoints();const f=Y(this.metrics,n),h=this.getLayoutCheckpointBeforeLineIndex(u);let d=h?.top??f+this.cache.fileAnnotationHeight;if(r)return{top:f,height:0};let c;return ve({diff:this.fileDiff,diffStyle:a,startingLine:h?.renderedLineIndex??0,expandedHunks:s?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:g,hunk:m,collapsedBefore:C,collapsedAfter:y,deletionLine:v,additionLine:p})=>{const S=a==="split"?p?.splitLineIndex??v?.splitLineIndex:p?.unifiedLineIndex??v?.unifiedLineIndex;if(S==null)throw new Error("VirtualizedFileDiff.getLinePosition: missing line index data");if(C>0){const T=oe({type:l,metrics:this.metrics,hunkIndex:g,hunkSpecs:m?.hunkSpecs});if(T!=null){if(d+=T.gapBefore,u>=S-C&&u<S)return c={top:d,height:T.height},!0;d+=T.height+T.gapAfter}}const L=this.getLineHeight(S,(p?.noEOFCR??!1)||(v?.noEOFCR??!1));if(S===u)return c={top:d,height:L},!0;if(d+=L,y>0){const T=ae({type:l,metrics:this.metrics});if(T!=null){if(u>S&&u<=S+y)return c={top:d+T.gapBefore,height:T.height},!0;d+=T.totalHeight}}return!1}}),c}getNumericScrollAnchor(e){if(this.fileDiff==null)return;const{disableFileHeader:t=!1,expandUnchanged:i=!1,collapsed:n=!1,collapsedContextThreshold:s=1}=this.options;if(n)return;const r=this.getDiffStyle(),o=this.getHunkSeparatorType();this.approximateLayoutCheckpoints();const a=this.getLayoutCheckpointBeforeTop(e);let l=a?.top??Y(this.metrics,t)+this.cache.fileAnnotationHeight,u;return ve({diff:this.fileDiff,diffStyle:r,startingLine:a?.renderedLineIndex??0,expandedHunks:i?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:s,callback:({hunkIndex:f,hunk:h,collapsedBefore:d,collapsedAfter:c,deletionLine:g,additionLine:m})=>{const C=r==="split"?m?.splitLineIndex??g?.splitLineIndex:m?.unifiedLineIndex??g?.unifiedLineIndex;if(C==null)throw new Error("VirtualizedFileDiff.getNumericScrollAnchor: missing line index data");if(d>0){const v=oe({type:o,metrics:this.metrics,hunkIndex:f,hunkSpecs:h?.hunkSpecs});v!=null&&(l+=v.totalHeight)}if(l>=e&&(g!=null?u={lineNumber:g.lineNumber,side:"deletions",top:l}:m!=null&&(u={lineNumber:m.lineNumber,side:"additions",top:l}),u!=null))return!0;const y=this.getLineHeight(C,(m?.noEOFCR??!1)||(g?.noEOFCR??!1));if(l+=y,c>0){const v=ae({type:o,metrics:this.metrics});v!=null&&(l+=v.totalHeight)}return!1}}),u}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){if(this.top==null||this.fileDiff==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};const t=e!=null?this.computeRenderRangeFromWindow(this.fileDiff,this.top,e):this.renderRange;if(t==null)return;const{bufferBefore:i,bufferAfter:n,totalLines:s}=t;let r=0;if(s===0){const o=e??this.virtualizer.getWindowSpecs();this.top<o.top&&(r=n)}return{topOffset:this.top+i+r,height:this.height-(i+n)}}cleanUp(e=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||this.resetLayoutCache({includeEstimatedHeights:!0}),this.isSetup=!1,super.cleanUp(e)}expandHunk=(e,t,i)=>{this.hunksRenderer.expandHunk(e,t,i),this.forceRenderOverride=!0,this.resetLayoutCache({includeEstimatedHeights:!0}),this.isSimpleMode()&&this.computeApproximateSize(),this.virtualizer.instanceChanged(this,!0)};setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(e,t,i=!1){const n=this.renderRange;if(super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0}),i&&n!==void 0&&this.fileDiff!==void 0){const s=this.virtualizer.getWindowSpecs(),r=this.computeRenderRangeFromWindow(this.fileDiff,this.top??0,s);r.bufferAfter!==n.bufferAfter&&this.updateBuffers(r)}}computeApproximateSize(e=!1){const t=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!t)return;const i=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.cache.totalLines=0,this.fileDiff==null){this.layoutDirty=!1;return}const{disableFileHeader:n=!1,collapsed:s=!1}=this.options,r=Y(this.metrics,n);if(this.height+=r,s){this.layoutDirty=!1;return}this.height=this.getActiveEstimatedHeight()+this.cache.measuredHeightDeltaTotal,t&&!i&&this.validateComputedHeight(),this.layoutDirty=!1}getActiveEstimatedHeight(){this.ensureEstimatedDiffHeights();const e=this.getDiffStyle()==="split"?this.cache.estimatedSplitHeight:this.cache.estimatedUnifiedHeight;if(e==null)throw new Error("VirtualizedFileDiff.getActiveEstimatedHeight: missing estimated height");return e}ensureEstimatedDiffHeights(){if(this.fileDiff==null){this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0;return}if(this.cache.estimatedSplitHeight!=null&&this.cache.estimatedUnifiedHeight!=null)return;const{disableFileHeader:e=!1,expandUnchanged:t=!1,collapsedContextThreshold:i=1}=this.options,{splitHeight:n,unifiedHeight:s}=ci({fileDiff:this.fileDiff,metrics:this.metrics,disableFileHeader:e,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:t,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i});this.cache.estimatedSplitHeight=n,this.cache.estimatedUnifiedHeight=s}validateComputedHeight(){if(this.fileContainer==null||this.fileDiff==null)return;const e=this.fileContainer.getBoundingClientRect();e.height!==this.height?console.log("VirtualizedFileDiff.computeApproximateSize: computed height doesnt match",{name:this.fileDiff.name,elementHeight:e.height,computedHeight:this.height}):console.log("VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT")}render({fileContainer:e,oldFile:t,newFile:i,fileDiff:n,forceRender:s=!1,lineAnnotations:r,...o}={}){const{forceRenderOverride:a,isSetup:l}=this;this.forceRenderOverride=void 0;const u=this.syncLineAnnotations(r);if(u&&this.resetLayoutCache({includeEstimatedHeights:!1}),this.fileDiff??=n??(t!=null&&i!=null?J(t,i,this.options.parseDiffOptions):void 0),e=this.getOrCreateFileContainer(e),this.fileDiff==null)return console.error("VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data"),!1;if(l)this.top??=this.getVirtualizedTop();else{this.computeApproximateSize();const c=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(c==null)throw new Error("VirtualizedFileDiff.render: simple virtualizer is not available");c.connect(e,this),this.isVisible=c.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode())return this.renderPlaceholder(this.height);const f=this.virtualizer.getWindowSpecs(),h=this.top??0,d=this.computeRenderRangeFromWindow(this.fileDiff,h,f);return super.render({fileDiff:this.fileDiff,fileContainer:e,renderRange:d,oldFile:t,newFile:i,lineAnnotations:r,forceRender:(a??s)||u,...o})}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}isSimpleMode(){return this.virtualizer.type==="simple"}isAdvancedMode(){return this.virtualizer.type==="advanced"}getVirtualizedTop(){return this.virtualizer.type==="advanced"?this.virtualizer.getLocalTopForInstance(this):this.fileContainer!=null?this.virtualizer.getOffsetInScrollContainer(this.fileContainer):0}getSimpleVirtualizer(){return this.virtualizer.type==="simple"?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}getDiffStyle(){return this.options.diffStyle??"split"}getHunkSeparatorType(){return Ai(this.options.hunkSeparators)}approximateLayoutCheckpoints(){if(this.cache.checkpoints.length>0||this.fileDiff==null||this.fileDiff.hunks.length===0||this.options.collapsed===!0)return;const{disableFileHeader:e=!1,expandUnchanged:t=!1,collapsedContextThreshold:i=1}=this.options,n=this.fileDiff.hunks.length-1,s=this.getDiffStyle(),r=this.getHunkSeparatorType(),o=t?!0:this.hunksRenderer.getExpandedHunksMap(),a=Si(this.cache.heightDeltas);let l=Y(this.metrics,e)+this.cache.fileAnnotationHeight,u=0;const f=({rowCount:h,startLineIndex:d,preSeparatorHeight:c=0,postSeparatorHeight:g=0,metadataOffsets:m=[]})=>{if(h<=0)return;const C=u,y=u+h;let v=vi(C);for(;v<y;){const p=v-C,S=l+(p>0?c:0)+p*this.metrics.lineHeight+yi(m,p)*this.metrics.lineHeight+qe(a,d,d+p);this.cache.checkpoints.push({renderedLineIndex:v,lineIndex:d+p,top:S}),v+=ze}l+=c+h*this.metrics.lineHeight+m.length*this.metrics.lineHeight+qe(a,d,d+h)+g,u=y};for(let h=0;h<this.fileDiff.hunks.length;h++){const d=this.fileDiff.hunks[h];if(d==null)throw new Error("VirtualizedFileDiff.approximateLayoutCheckpoints: invalid hunk index");const c=we({isPartial:this.fileDiff.isPartial,rangeSize:d.collapsedBefore,expandedHunks:o,hunkIndex:h,collapsedContextThreshold:i}),g=c.collapsedLines>0?oe({type:r,metrics:this.metrics,hunkIndex:h,hunkSpecs:d.hunkSpecs})?.totalHeight??0:0;f({rowCount:c.fromStart,startLineIndex:(s==="split"?d.splitLineStart:d.unifiedLineStart)-c.rangeSize});let m=g;f({rowCount:c.fromEnd,startLineIndex:(s==="split"?d.splitLineStart:d.unifiedLineStart)-c.fromEnd,preSeparatorHeight:m}),c.fromEnd>0&&(m=0);const C=h===n?Me({fileDiff:this.fileDiff,hunkIndex:h,expandedHunks:o,collapsedContextThreshold:i,errorPrefix:"VirtualizedFileDiff"}):void 0,y=C!=null&&C.collapsedLines>0?ae({type:r,metrics:this.metrics})?.totalHeight??0:0,v=C!=null?C.fromStart+C.fromEnd:0,p=s==="split"?d.splitLineCount:d.unifiedLineCount,S=s==="split"?d.splitLineStart:d.unifiedLineStart;f({rowCount:p,startLineIndex:S,preSeparatorHeight:m,postSeparatorHeight:v===0?y:0,metadataOffsets:Li({diffStyle:s,hunk:d,rowCount:p})}),C!=null&&v>0&&f({rowCount:v,startLineIndex:S+p,postSeparatorHeight:y})}this.cache.totalLines=u}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,i=this.cache.checkpoints.length-1,n;for(;t<=i;){const s=t+i>>1,r=this.cache.checkpoints[s];if(r==null)throw new Error("VirtualizedFileDiff: invalid checkpoint index");r.lineIndex<=e?(n=r,t=s+1):i=s-1}return n}getLayoutCheckpointBeforeTop(e,t){let i=0,n=this.cache.checkpoints.length-1,s=-1;for(;i<=n;){const r=i+n>>1,o=this.cache.checkpoints[r];if(o==null)throw new Error("VirtualizedFileDiff: invalid checkpoint index");o.top<=e?(s=r,i=r+1):n=r-1}if(t==null)return s>=0?this.cache.checkpoints[s]:void 0;for(let r=s;r>=0;r--){const o=this.cache.checkpoints[r];if(o==null)throw new Error("VirtualizedFileDiff: invalid checkpoint index");if(o.renderedLineIndex%t===0)return o}}getExpandedLineCount(e,t){let i=0;if(e.isPartial){for(const a of e.hunks)i+=t==="split"?a.splitLineCount:a.unifiedLineCount;return i}const{expandUnchanged:n=!1,collapsedContextThreshold:s=1}=this.options,r=n?!0:this.hunksRenderer.getExpandedHunksMap();for(const[a,l]of e.hunks.entries()){const u=t==="split"?l.splitLineCount:l.unifiedLineCount;i+=u;const f=Math.max(l.collapsedBefore,0),{fromStart:h,fromEnd:d,renderAll:c}=we({isPartial:e.isPartial,rangeSize:f,expandedHunks:r,hunkIndex:a,collapsedContextThreshold:s});f>0&&(i+=c?f:h+d)}const o=Me({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:r,collapsedContextThreshold:s,errorPrefix:"VirtualizedFileDiff"});return o!=null&&(i+=o.fromStart+o.fromEnd),i}computeRenderRangeFromWindow(e,t,{top:i,bottom:n}){const{disableFileHeader:s=!1,expandUnchanged:r=!1,collapsedContextThreshold:o=1}=this.options,{hunkLineCount:a,lineHeight:l}=this.metrics,u=this.getDiffStyle(),f=this.getHunkSeparatorType(),h=this.height;let d=this.cache.totalLines>0?this.cache.totalLines:this.getExpandedLineCount(e,u);const c=Y(this.metrics,s),g=e.hunks.length>0?Je(this.metrics):0,{fileAnnotationHeight:m}=this.cache,C=c+m,y=Math.max(0,h-c-m-g),v=this.hasFileAnnotations(e),p=t+c,S=m>0&&v&&p<n&&p+m>i;if(t<i-h||t>n)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:h-c-g};if(d<=a||e.hunks.length===0)return{startingLine:0,totalLines:a,bufferBefore:0,bufferAfter:0};this.approximateLayoutCheckpoints(),d=this.cache.totalLines>0?this.cache.totalLines:d;const L=Math.ceil(Math.max(n-i,0)/l),T=Math.ceil(L/a)*a+a,F=T/a,de=F,j=[],ue=(i+n)/2,q=this.getLayoutCheckpointBeforeTop(Math.max(0,i-t-T*l*2),a);let b=t+(q?.top??C),Z=q?.renderedLineIndex??0,R,D,U;if(ve({diff:e,diffStyle:u,startingLine:q?.renderedLineIndex??0,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:ye,hunk:Le,collapsedBefore:te,collapsedAfter:ie,deletionLine:k,additionLine:E})=>{const z=E!=null?E.splitLineIndex:k.splitLineIndex,$=E!=null?E.unifiedLineIndex:k.unifiedLineIndex,O=(E?.noEOFCR??!1)||(k?.noEOFCR??!1),N=(te>0?oe({type:f,metrics:this.metrics,hunkIndex:ye,hunkSpecs:Le?.hunkSpecs}):void 0)?.totalHeight??0;b+=N;const ne=Z%a===0,M=Math.floor(Z/a);if(ne&&(j[M]=b-(t+C+N),U!=null)){if(U<=0)return!0;U--}const He=this.getLineHeight(u==="split"?z:$,O);return b>i-He&&b<n&&(R??=M),D==null&&b+He>ue&&(D=M),U==null&&b>=n&&ne&&(U=de),Z++,b+=He,ie>0&&(b+=ae({type:f,metrics:this.metrics})?.totalHeight??0),!1}}),R==null)if(S)R=0,D=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:h-c-g};D??=R;const V=Math.round(D-F/2),H=Math.max(0,Math.ceil(d/a)-F),A=Math.max(0,Math.min(V,H)),x=A*a,I=V<0?T+V*a:T,W=j[A]??0,Q=x===0?0:m+W,ee=A+I/a,fe=ee<j.length?y-j[ee]:y-(b-t-C);return{startingLine:x,totalLines:I,bufferBefore:Q,bufferAfter:Math.max(0,fe)}}};function Ci(e){let t;for(const i of e){if(i==null)continue;const n=i.children[1];if(n instanceof HTMLElement)for(const s of n.children)s instanceof HTMLElement&&s.dataset.lineAnnotation===Lt&&(t=Math.max(t??0,s.getBoundingClientRect().height))}return t}function Si(e){const t=Array.from(e).sort((r,o)=>r[0]-o[0]),i=[],n=[0];let s=0;for(const[r,o]of t)i.push(r),s+=o,n.push(s);return{lineIndexes:i,prefixTotals:n}}function qe({lineIndexes:e,prefixTotals:t},i,n){if(i>=n||e.length===0)return 0;const s=Ke(e,i);return(t[Ke(e,n)]??0)-(t[s]??0)}function Ke(e,t){let i=0,n=e.length;for(;i<n;){const s=i+n>>1,r=e[s];if(r==null)throw new Error("VirtualizedFileDiff: invalid prefix index");r<t?i=s+1:n=s}return i}function vi(e){return Math.ceil(e/ze)*ze}function yi(e,t){let i=0;for(const n of e)n<t&&i++;return i}function Li({diffStyle:e,hunk:t,rowCount:i}){if(i<=0||!t.noEOFCRAdditions&&!t.noEOFCRDeletions)return[];const n=t.hunkContent.at(-1);if(n==null)return[];if(n.type==="context")return[i-1];const s=Math.max(n.deletions,n.additions),r=n.deletions+n.additions;if(e==="split")return s>0&&(t.noEOFCRAdditions||t.noEOFCRDeletions)?[i-1]:[];const o=[],a=i-r;return n.deletions>0&&t.noEOFCRDeletions&&o.push(a+n.deletions-1),n.additions>0&&t.noEOFCRAdditions&&o.push(i-1),o}function Hi(e,t){return(e.diffStyle??"split")!==(t.diffStyle??"split")||(e.overflow??"scroll")!==(t.overflow??"scroll")||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.diffIndicators??"bars")!==(t.diffIndicators??"bars")||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)||e.unsafeCSS!==t.unsafeCSS}function Ti(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function Ai(e){return typeof e=="function"?"custom":e??"line-info"}function ki(e,t){const[i,n]=e.split(",").map(Number);return t==="split"?n:i}export{li as F,Mi as V,J as p};
|
|
10
|
+
`:t}function Ee(e,t){return Math.max(e.additionLines.length,e.deletionLines.length)>t}function si(e,t){return e.lineNumber===t.lineNumber&&e.side===t.side&&e.metadata===t.metadata}function ri(e,t){return e.slotName===t.slotName&&e.hunkIndex===t.hunkIndex&&e.lines===t.lines&&e.type===t.type&&e.expandable?.chunked===t.expandable?.chunked&&e.expandable?.up===t.expandable?.up&&e.expandable?.down===t.expandable?.down}function oi(e){return{theme:e?.theme,disableLineNumbers:e?.disableLineNumbers,overflow:e?.overflow,collapsed:e?.collapsed,disableFileHeader:e?.disableFileHeader,disableVirtualizationBuffers:e?.disableVirtualizationBuffers,stickyHeader:e?.stickyHeader,preferredHighlighter:e?.preferredHighlighter,useCSSClasses:e?.useCSSClasses,useTokenTransformer:e?.useTokenTransformer,tokenizeMaxLineLength:e?.tokenizeMaxLineLength,tokenizeMaxLength:e?.tokenizeMaxLength,diffStyle:e?.diffStyle,diffIndicators:e?.diffIndicators,disableBackground:e?.disableBackground,hunkSeparators:typeof e?.hunkSeparators=="function"?"custom":e?.hunkSeparators,expandUnchanged:e?.expandUnchanged,collapsedContextThreshold:e?.collapsedContextThreshold,lineDiffType:e?.lineDiffType,maxLineDiffLength:e?.maxLineDiffLength,expansionLineCount:e?.expansionLineCount,headerRenderMode:e?.renderCustomHeader!=null?"custom":"default"}}let ai=-1;var li=class{options;workerManager;isContainerManaged;static LoadedCustomComponent=!0;__id=`file-diff:${++ai}`;type="file-diff";fileContainer;spriteSVG;pre;codeUnified;codeDeletions;codeAdditions;bufferBefore;bufferAfter;themeCSSStyle;appliedThemeCSS;hasAdoptedThemeCSS=!1;unsafeCSSStyle;appliedUnsafeCSS;gutterUtilityContent;headerElement;headerPrefix;headerFilenameSuffix;headerMetadata;headerCustom;separatorCache=new Map;errorWrapper;placeHolder;hunksRenderer;resizeManager;scrollSyncManager;interactionManager;annotationCache=new Map;lineAnnotations=[];managersDirty=!1;deletionFile;additionFile;fileDiff;renderRange;appliedPreAttributes;lastRenderedHeaderHTML;cachedHeaderHTML;lastRowCount;mounted=!1;enabled=!0;editor;fastRefreshTimeout;constructor(e={theme:_},t,i=!1){this.options=e,this.workerManager=t,this.isContainerManaged=i,this.hunksRenderer=this.createHunksRenderer(e),this.resizeManager=new rt,this.scrollSyncManager=new Bt,this.interactionManager=new ot("diff",Pe(e,typeof e.hunkSeparators=="function"||(e.hunkSeparators??"line-info")==="line-info"||e.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex)),this.workerManager?.subscribeToThemeChanges(this),this.enabled=!0}handleHighlightRender=()=>{this.rerender()};getHunksRendererOptions(e){return oi(e)}createHunksRenderer(e){return new ti(this.getHunksRendererOptions(e),this.handleHighlightRender,this.workerManager)}getLineIndex=(e,t="additions")=>{const i=this.hunksRenderer.getRenderDiff()??this.fileDiff;if(i==null)return;const n=i.hunks.at(-1);let s,r;e:for(const o of i.hunks){let a=t==="deletions"?o.deletionStart:o.additionStart;const l=t==="deletions"?o.deletionCount:o.additionCount;let u=o.splitLineStart,f=o.unifiedLineStart;if(e<a){const h=a-e;s=Math.max(f-h,0),r=Math.max(u-h,0);break e}if(e>=a+l){if(o===n){const h=e-(a+l);s=f+o.unifiedLineCount+h,r=u+o.splitLineCount+h;break e}continue}for(const h of o.hunkContent)if(h.type==="context")if(e<a+h.lines){const d=e-a;r=u+d,s=f+d;break e}else a+=h.lines,u+=h.lines,f+=h.lines;else{const d=t==="deletions"?h.deletions:h.additions;if(e<a+d){const c=e-a;s=f+(t==="additions"?h.deletions:0)+c,r=u+c;break e}else a+=d,u+=Math.max(h.deletions,h.additions),f+=h.deletions+h.additions}break e}if(!(s==null||r==null))return[s,r]};setOptions(e){e!=null&&(this.options=e,this.cachedHeaderHTML=void 0,this.hunksRenderer.setOptions(this.getHunksRendererOptions(e)),this.syncInteractionOptions())}syncInteractionOptions(){this.interactionManager.setOptions(Pe(this.options,typeof this.options.hunkSeparators=="function"||(this.options.hunkSeparators??"line-info")==="line-info"||this.options.hunkSeparators==="line-info-basic"?this.handleExpandHunk:void 0,this.getLineIndex))}mergeOptions(e){this.options={...this.options,...e}}setThemeType(e){(this.options.themeType??"system")!==e&&(this.mergeOptions({themeType:e}),this.applyCachedThemeState(e))}applyCachedThemeState(e){if(typeof this.options.theme=="string"||this.fileContainer==null||this.appliedThemeCSS==null)return!1;const t=this.appliedThemeCSS.baseThemeType??e;return this.appliedThemeCSS.themeType===t?!1:(this.applyThemeState(this.fileContainer,this.appliedThemeCSS.themeStyles,e,this.appliedThemeCSS.baseThemeType),!0)}hasThemeChanged(){return this.appliedThemeCSS!=null&&!Rt(this.appliedThemeCSS.theme,this.options.theme??_)}getHoveredLine=()=>this.interactionManager.getHoveredLine();setLineAnnotations(e){this.lineAnnotations=e}canPartiallyRender(e,t,i){return!(e||t||i||typeof this.options.hunkSeparators=="function")}setSelectedLines(e,t){this.interactionManager.setSelection(e,t)}flushManagers(){if(!this.managersDirty||this.pre==null){this.managersDirty=!1;return}const{diffStyle:e="split",overflow:t="scroll"}=this.options;this.interactionManager.setup(this.pre),this.resizeManager.setup(this.pre,t==="wrap"),t==="scroll"&&e==="split"?this.scrollSyncManager.setup(this.pre,this.codeDeletions,this.codeAdditions):this.scrollSyncManager.cleanUp(),this.managersDirty=!1}cleanUp(e=!1){this.emitPostRender(!0),this.resizeManager.cleanUp(),this.interactionManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.managersDirty=!1,this.workerManager?.unsubscribeToThemeChanges(this),this.renderRange=void 0,this.isContainerManaged||this.fileContainer?.remove(),this.fileContainer=void 0,this.mounted=!1,e||(this.lineAnnotations=[]),this.clearAuxiliaryNodes(),this.annotationCache.clear(),this.pre=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.appliedPreAttributes=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.placeHolder=void 0,this.lastRenderedHeaderHTML=void 0,e||(this.cachedHeaderHTML=void 0),this.errorWrapper=void 0,this.spriteSVG=void 0,this.lastRowCount=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,e?this.hunksRenderer.recycle():(this.hunksRenderer.cleanUp(),this.workerManager=void 0,this.fileDiff=void 0,this.deletionFile=void 0,this.additionFile=void 0),this.enabled=!1,this.editor?.cleanUp(),this.editor=void 0,this.fastRefreshTimeout!=null&&(clearTimeout(this.fastRefreshTimeout),this.fastRefreshTimeout=void 0)}virtualizedSetup(){this.enabled=!0,this.workerManager?.subscribeToThemeChanges(this)}hydrate(e){const{fileContainer:t,prerenderedHTML:i,preventEmit:n=!1,lineAnnotations:s,oldFile:r,newFile:o,fileDiff:a}=e;this.hydrateElements(t,i),ui(this.pre,hi({fileDiff:a,oldFile:r,newFile:o}),this.options.collapsed)||fi(this.headerElement,di({fileDiff:a,oldFile:r,newFile:o}),this.options.disableFileHeader)?this.render({...e,preventEmit:!0}):this.hydrationSetup({fileDiff:a,oldFile:r,newFile:o,lineAnnotations:s}),n||this.emitPostRender()}hydrateElements(e,t){this.fileContainer!==e&&this.emitPostRender(!0),at(e,t);for(const i of e.shadowRoot?.children??[]){if(i instanceof SVGElement){this.spriteSVG=i;continue}if(i instanceof HTMLElement){if(i instanceof HTMLPreElement){this.pre=i;for(const n of i.children)!(n instanceof HTMLElement)||n.tagName.toLowerCase()!=="code"||("deletions"in n.dataset&&(this.codeDeletions=n),"additions"in n.dataset&&(this.codeAdditions=n),"unified"in n.dataset&&(this.codeUnified=n));continue}if("diffsHeader"in i.dataset){this.headerElement=i;continue}if(i instanceof HTMLStyleElement&&i.hasAttribute("data-theme-css")){this.themeCSSStyle=i;continue}if(i instanceof HTMLStyleElement&&i.hasAttribute("data-unsafe-css")){this.unsafeCSSStyle=i,this.appliedUnsafeCSS=i.textContent;continue}}}this.pre!=null&&(this.syncCodeNodesFromPre(this.pre),this.pre.removeAttribute("data-dehydrated")),this.fileContainer=e,this.hydrateMeasuredScrollbar()}hydrationSetup({fileDiff:e,oldFile:t,newFile:i,lineAnnotations:n}){this.lineAnnotations=n??this.lineAnnotations,this.additionFile=i,this.deletionFile=t,this.fileDiff=e??(t!=null&&i!=null?Z(t,i,this.options.parseDiffOptions):void 0),this.pre!=null&&(this.syncInteractionOptions(),this.hunksRenderer.hydrate(this.fileDiff),this.renderAnnotations(),this.renderGutterUtility(),this.injectUnsafeCSS(),this.managersDirty=!0,this.flushManagers())}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||this.render({forceRender:!0,renderRange:this.renderRange})}onThemeChange(){this.hunksRenderer.clearRenderCache(),this.rerender()}handleExpandHunk=(e,t,i)=>{this.expandHunk(e,t,i)};expandHunk=(e,t,i)=>{this.hunksRenderer.expandHunk(e,t,i),this.rerender()};render({oldFile:e,newFile:t,fileDiff:i,deferManagers:n=!1,forceRender:s=!1,preventEmit:r=!1,lineAnnotations:o,fileContainer:a,containerWrapper:l,renderRange:u}){if(!this.enabled)throw new Error("FileDiff.render: attempting to call render after cleaned up");this.editor?.__postponeBackgroundTokenizeToNextFrame();const{collapsed:f=!1,themeType:h="system"}=this.options,d=f?void 0:u,c=this.hasThemeChanged(),g=e!=null&&t!=null&&(!Be(e,this.deletionFile)||!Be(t,this.additionFile));let m=i!=null&&i!==this.fileDiff;const C=o!=null&&(o.length>0||this.lineAnnotations.length>0)?o!==this.lineAnnotations:!1;if(!f&&Xe(d,this.renderRange)&&!s&&!C&&!c&&(i!=null&&i===this.fileDiff||i==null&&!g))return this.applyCachedThemeState(h);const{renderRange:y}=this;if(this.renderRange=d,this.deletionFile=e,this.additionFile=t,i!=null?this.fileDiff=i:e!=null&&t!=null&&g&&(m=!0,this.fileDiff=Z(e,t,this.options.parseDiffOptions)),m&&(this.cachedHeaderHTML=void 0),o!=null&&this.setLineAnnotations(o),this.fileDiff==null)return!1;this.hunksRenderer.setOptions(this.getHunksRendererOptions(this.options)),this.syncInteractionOptions(),this.hunksRenderer.setLineAnnotations(this.lineAnnotations);const{disableErrorHandling:v=!1,disableFileHeader:p=!1}=this.options;if(p&&(this.headerElement!=null&&(this.headerElement.remove(),this.headerElement=void 0,this.lastRenderedHeaderHTML=void 0),this.clearHeaderSlots()),a=this.getOrCreateFileContainer(a,l),this.applyCachedThemeState(h),f){this.removeRenderedCode(),this.clearAuxiliaryNodes();try{const S=this.hunksRenderer.renderDiff(this.fileDiff,zt);S!=null&&this.applyThemeState(a,S.themeStyles,h,S.baseThemeType),S?.headerElement!=null&&this.applyHeaderToDOM(S.headerElement,a),this.renderSeparators([]),this.injectUnsafeCSS()}catch(S){if(v)throw S;console.error(S),S instanceof Error&&this.applyErrorToDOM(S,a)}return r||this.emitPostRender(),!0}try{const S=this.getOrCreatePreNode(a);if(!(this.canPartiallyRender(s,C,g||m||c)&&this.applyPartialRender({previousRenderRange:y,renderRange:d}))){const H=this.hunksRenderer.renderDiff(this.fileDiff,d);if(H==null)return this.workerManager?.isInitialized()===!1&&this.workerManager.initialize().then(()=>this.rerender()),!1;this.applyThemeState(a,H.themeStyles,h,H.baseThemeType),H.headerElement!=null&&this.applyHeaderToDOM(H.headerElement,a),H.additionsContentAST!=null||H.deletionsContentAST!=null||H.unifiedContentAST!=null?this.applyHunksToDOM(S,H):this.pre!=null&&(this.pre.remove(),this.pre=void 0),this.renderSeparators(H.hunkData)}this.applyBuffers(S,d),this.injectUnsafeCSS(),this.renderAnnotations(),this.renderGutterUtility(),this.managersDirty=!0,n||this.flushManagers(),this.editor!=null&&this.syncRenderViewToEditor()}catch(S){if(v)throw S;console.error(S),S instanceof Error&&this.applyErrorToDOM(S,a)}return r||this.emitPostRender(),!0}emitPostRender(e=!1){const{fileContainer:t,options:{onPostRender:i}}=this;if(e){if(!this.mounted||(this.mounted=!1,t==null))return;this.options.onPostRender?.(t,this,"unmount");return}if(t==null)return;const n=this.mounted?"update":"mount";this.mounted=!0,i?.(t,this,n)}syncRenderViewToEditor(){const e=this.editor,t=this.fileContainer,i=this.fileDiff;e!=null&&t!=null&&i!=null&&!i.isPartial&&this.hunksRenderer.initializeHighlighter().then(n=>{e.__syncRenderView(n,t,i,this.lineAnnotations,this.renderRange)})}attachEditor(e){return this.editor?.cleanUp(),this.editor=e,this.interactionManager.setEditorAttached(!0),this.syncRenderViewToEditor(),()=>{this.editor=void 0,this.interactionManager.setEditorAttached(!1)}}applyDocumentChange(e,t){this.hunksRenderer.applyDocumentChange(e);const i=this.hunksRenderer.getRenderDiff();i!=null&&(this.fileDiff=i),this.rerender(),this.interactionManager.setSelectionDirty(),t!==void 0&&t!==this.lineAnnotations&&(this.setLineAnnotations(t),this.hunksRenderer.setLineAnnotations(this.lineAnnotations),this.renderAnnotations())}rerenderFromDocument(e){this.hunksRenderer.applyDocumentChange(e);const t=this.hunksRenderer.getRenderDiff();t!=null&&(this.fileDiff=t),this.hunksRenderer.clearRenderCache(),this.rerender()}updateRenderCache(e,t,i,n){this.hunksRenderer.updateRenderCache(e,t,n),i===!0&&(this.options.diffStyle==="split"?(this.fastRefreshTimeout!=null&&clearTimeout(this.fastRefreshTimeout),this.fastRefreshTimeout=setTimeout(()=>{this.fastRefreshTimeout=void 0,this.fastRefreshDiffView()},100)):this.refreshDiffView())}removeRenderedCode(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.bufferBefore?.remove(),this.bufferBefore=void 0,this.bufferAfter?.remove(),this.bufferAfter=void 0,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0,this.lastRowCount=void 0}clearAuxiliaryNodes(){for(const{element:e}of this.separatorCache.values())e.remove();this.separatorCache.clear();for(const{element:e}of this.annotationCache.values())e.remove();this.annotationCache.clear(),this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0}renderPlaceholder(e){if(this.fileContainer==null)return!1;if(this.emitPostRender(!0),this.cleanChildNodes(),this.placeHolder==null){const t=this.fileContainer.shadowRoot??this.fileContainer.attachShadow({mode:"open"});this.placeHolder=document.createElement("div"),this.placeHolder.dataset.placeholder="",t.appendChild(this.placeHolder)}return this.placeHolder.style.setProperty("height",`${e}px`),!0}primeHighlightCache(){const{fileDiff:e,workerManager:t}=this;if(e==null||t==null||be(e))return;const i=this.options.tokenizeMaxLength??1e5;Math.max(e.additionLines.length,e.deletionLines.length)>i||t.primeDiffHighlightCache(e)}cleanChildNodes(){this.resizeManager.cleanUp(),this.scrollSyncManager.cleanUp(),this.interactionManager.cleanUp(),this.clearAuxiliaryNodes(),this.bufferAfter?.remove(),this.bufferBefore?.remove(),this.codeAdditions?.remove(),this.codeDeletions?.remove(),this.codeUnified?.remove(),this.errorWrapper?.remove(),this.headerElement?.remove(),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.pre?.remove(),this.spriteSVG?.remove(),this.themeCSSStyle?.remove(),this.unsafeCSSStyle?.remove(),this.bufferAfter=void 0,this.bufferBefore=void 0,this.codeAdditions=void 0,this.codeDeletions=void 0,this.codeUnified=void 0,this.errorWrapper=void 0,this.headerElement=void 0,this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0,this.pre=void 0,this.spriteSVG=void 0,this.themeCSSStyle=void 0,this.appliedThemeCSS=void 0,this.hasAdoptedThemeCSS=!1,this.unsafeCSSStyle=void 0,this.appliedUnsafeCSS=void 0,this.lastRenderedHeaderHTML=void 0,this.lastRowCount=void 0,this.mounted=!1}renderSeparators(e){const{hunkSeparators:t}=this.options;if(this.isContainerManaged||this.fileContainer==null||typeof t!="function"){for(const{element:n}of this.separatorCache.values())n.remove();this.separatorCache.clear();return}const i=new Map(this.separatorCache);for(const n of e){const s=n.slotName;let r=this.separatorCache.get(s);if(r==null||!ri(n,r.hunkData)){r?.element.remove();const o=document.createElement("div");o.style.display="contents",o.slot=n.slotName;const a=t(n,this);a!=null&&o.appendChild(a),this.fileContainer.appendChild(o),r={element:o,hunkData:n},this.separatorCache.set(s,r)}i.delete(s)}for(const[n,{element:s}]of i.entries())this.separatorCache.delete(n),s.remove()}renderAnnotations(){if(this.isContainerManaged||this.fileContainer==null){for(const{element:i}of this.annotationCache.values())i.remove();this.annotationCache.clear();return}const e=new Map(this.annotationCache),{renderAnnotation:t}=this.options;if(t!=null&&this.lineAnnotations.length>0)for(const[i,n]of this.lineAnnotations.entries()){const s=`${i}-${he(n)}`;let r=this.annotationCache.get(s);if(r==null||!si(n,r.annotation)){r?.element.remove();const o=t(n);if(o==null)continue;r={element:lt(he(n)),annotation:n},r.element.appendChild(o),this.fileContainer.appendChild(r.element),this.annotationCache.set(s,r)}e.delete(s)}for(const[i,{element:n}]of e.entries())this.annotationCache.delete(i),n.remove()}renderGutterUtility(){const{renderGutterUtility:e}=this.options;if(this.fileContainer==null||e==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const t=e(this.interactionManager.getHoveredLine);if(t!=null&&this.gutterUtilityContent!=null)return;if(t==null){this.gutterUtilityContent?.remove(),this.gutterUtilityContent=void 0;return}const i=ht();i.appendChild(t),this.fileContainer.appendChild(i),this.gutterUtilityContent=i}getOrCreateFileContainer(e,t){const{fileContainer:i}=this,n=e??i??document.createElement("diffs-container"),s=i!==n;return s&&this.emitPostRender(!0),this.fileContainer=n,i!=null&&s&&(this.lastRenderedHeaderHTML=void 0,this.headerElement=void 0),t!=null&&this.fileContainer.parentNode!==t&&t.appendChild(this.fileContainer),s&&this.adoptReusableShellElements(this.fileContainer),this.ensureSpriteSVG(this.fileContainer),this.fileContainer}adoptReusableShellElements(e){const{shadowRoot:t}=e;if(t!=null)for(const i of t.children)i instanceof SVGElement?this.spriteSVG??=i:Ue(i)&&i.hasAttribute("data-theme-css")?(this.themeCSSStyle??=i,this.hasAdoptedThemeCSS=!0):Ue(i)&&i.hasAttribute("data-unsafe-css")&&(this.unsafeCSSStyle??=i,this.appliedUnsafeCSS??=this.options.unsafeCSS??void 0)}ensureSpriteSVG(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});if(this.spriteSVG==null){const i=document.createElement("div");i.innerHTML=dt;const n=i.firstChild;n instanceof SVGElement&&(this.spriteSVG=n)}this.spriteSVG!=null&&this.spriteSVG.parentNode!==t&&t.appendChild(this.spriteSVG)}getOrCreatePreNode(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});return this.pre==null?(this.pre=document.createElement("pre"),this.appliedPreAttributes=void 0,this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0,t.appendChild(this.pre)):this.pre.parentNode!==t&&(t.appendChild(this.pre),this.appliedPreAttributes=void 0),this.placeHolder?.remove(),this.placeHolder=void 0,this.pre}syncCodeNodesFromPre(e){this.codeUnified=void 0,this.codeDeletions=void 0,this.codeAdditions=void 0;for(const t of Array.from(e.children))t instanceof HTMLElement&&(t.hasAttribute("data-unified")?this.codeUnified=t:t.hasAttribute("data-deletions")?this.codeDeletions=t:t.hasAttribute("data-additions")&&(this.codeAdditions=t))}applyHeaderToDOM(e,t){this.cleanupErrorWrapper(),this.placeHolder?.remove(),this.placeHolder=void 0;const{fileDiff:i}=this,n=this.cachedHeaderHTML??le(e);if(this.cachedHeaderHTML=n,n!==this.lastRenderedHeaderHTML){const h=document.createElement("div");h.innerHTML=n;const d=h.firstElementChild;if(!(d instanceof HTMLElement))return;this.headerElement!=null?t.shadowRoot?.replaceChild(d,this.headerElement):t.shadowRoot?.prepend(d),this.headerElement=d,this.lastRenderedHeaderHTML=n}if(this.isContainerManaged||i==null)return;const{renderCustomHeader:s,renderHeaderPrefix:r,renderHeaderFilenameSuffix:o,renderHeaderMetadata:a}=this.options;if(s!=null){const h=s(i)??void 0;this.headerCustom=this.upsertHeaderSlotElement(t,this.headerCustom,Ft,h),this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0;return}const l=r?.(i)??void 0,u=o?.(i)??void 0,f=a?.(i)??void 0;this.headerPrefix=this.upsertHeaderSlotElement(t,this.headerPrefix,Nt,l),this.headerFilenameSuffix=this.upsertHeaderSlotElement(t,this.headerFilenameSuffix,Pt,u),this.headerMetadata=this.upsertHeaderSlotElement(t,this.headerMetadata,Ut,f),this.headerCustom?.remove(),this.headerCustom=void 0}clearHeaderSlots(){this.headerPrefix?.remove(),this.headerFilenameSuffix?.remove(),this.headerMetadata?.remove(),this.headerCustom?.remove(),this.headerPrefix=void 0,this.headerFilenameSuffix=void 0,this.headerMetadata=void 0,this.headerCustom=void 0}upsertHeaderSlotElement(e,t,i,n){if(n==null){t?.remove();return}const s=t??this.createHeaderSlotElement(i);return t==null&&e.appendChild(s),this.replaceHeaderSlotContent(s,n),s}replaceHeaderSlotContent(e,t){e.replaceChildren(),t instanceof Element?e.appendChild(t):e.innerText=`${t}`}createHeaderSlotElement(e){const t=document.createElement("div");return t.slot=e,t}injectUnsafeCSS(){const{unsafeCSS:e}=this.options,t=this.fileContainer?.shadowRoot;if(t!=null){if(e==null||e===""){this.unsafeCSSStyle!=null&&(this.unsafeCSSStyle.remove(),this.unsafeCSSStyle=void 0),this.appliedUnsafeCSS=void 0;return}this.unsafeCSSStyle?.parentNode===t&&this.appliedUnsafeCSS===e||(this.unsafeCSSStyle??=ut(),this.unsafeCSSStyle.parentNode!==t&&t.appendChild(this.unsafeCSSStyle),this.unsafeCSSStyle.textContent=ft(e),this.appliedUnsafeCSS=e)}}applyThemeState(e,t,i,n){const s=e.shadowRoot??e.attachShadow({mode:"open"}),r=n??i,o=this.options.theme??_,a=typeof o=="string"?o:{...o},l=Oe(s);if(this.themeCSSStyle?.parentNode===s&&this.appliedThemeCSS?.themeStyles===t&&this.appliedThemeCSS.themeType===r&&this.appliedThemeCSS.scrollbarGutter===l){this.appliedThemeCSS.theme=a;return}if(this.hasAdoptedThemeCSS&&this.themeCSSStyle?.parentNode===s){this.hasAdoptedThemeCSS=!1,this.appliedThemeCSS={theme:a,themeStyles:t,themeType:r,baseThemeType:n,scrollbarGutter:l};return}this.themeCSSStyle=ct({shadowRoot:s,currentNode:this.themeCSSStyle,themeCSS:Ct(t,r,l)}),this.appliedThemeCSS=this.themeCSSStyle!=null?{theme:a,themeStyles:t,themeType:r,baseThemeType:n,scrollbarGutter:l}:void 0}hydrateMeasuredScrollbar(){const e=this.fileContainer?.shadowRoot;e==null||this.themeCSSStyle==null||(this.themeCSSStyle.textContent=pt(this.themeCSSStyle.textContent??"",Oe(e)))}applyHunksToDOM(e,t){const{overflow:i="scroll"}=this.options,n=(this.options.hunkSeparators??"line-info")==="line-info",s=i==="wrap"?t.rowCount:void 0;this.cleanupErrorWrapper(),this.applyPreNodeAttributes(e,t);let r=!1;const o=[],a=this.hunksRenderer.renderCodeAST("unified",t),l=this.hunksRenderer.renderCodeAST("deletions",t),u=this.hunksRenderer.renderCodeAST("additions",t);a!=null?(r=this.codeUnified==null||this.codeAdditions!=null||this.codeDeletions!=null,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0,this.codeUnified=Ae({code:this.codeUnified,columnType:"unified",rowSpan:s,containerSize:n}),this.codeUnified.innerHTML=this.hunksRenderer.renderPartialHTML(a),o.push(this.codeUnified)):l!=null||u!=null?(l!=null?(r=this.codeDeletions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions=Ae({code:this.codeDeletions,columnType:"deletions",rowSpan:s,containerSize:n}),this.codeDeletions.innerHTML=this.hunksRenderer.renderPartialHTML(l),o.push(this.codeDeletions)):(this.codeDeletions?.remove(),this.codeDeletions=void 0),u!=null?(r=r||this.codeAdditions==null||this.codeUnified!=null,this.codeUnified?.remove(),this.codeUnified=void 0,this.codeAdditions=Ae({code:this.codeAdditions,columnType:"additions",rowSpan:s,containerSize:n}),this.codeAdditions.innerHTML=this.hunksRenderer.renderPartialHTML(u),o.push(this.codeAdditions)):(this.codeAdditions?.remove(),this.codeAdditions=void 0)):(this.codeUnified?.remove(),this.codeUnified=void 0,this.codeDeletions?.remove(),this.codeDeletions=void 0,this.codeAdditions?.remove(),this.codeAdditions=void 0),o.length===0?e.textContent="":r&&e.replaceChildren(...o),this.lastRowCount=t.rowCount}applyPartialRender({previousRenderRange:e,renderRange:t}){const{pre:i,codeUnified:n,codeAdditions:s,codeDeletions:r,options:{diffStyle:o="split"}}=this;if(i==null||e==null||t==null||!Number.isFinite(e.totalLines)||!Number.isFinite(t.totalLines)||this.lastRowCount==null)return!1;const a=this.getCodeColumns(o,n,r,s);if(a==null)return!1;const l=e.startingLine,u=t.startingLine,f=l+e.totalLines,h=u+t.totalLines,d=Math.max(l,u),c=Math.min(f,h);if(c<=d)return!1;const g=Math.max(0,d-l),m=Math.max(0,f-c),C=this.trimColumns({columns:a,trimStart:g,trimEnd:m,previousStart:l,overlapStart:d,overlapEnd:c,diffStyle:o});if(C<0)throw new Error("applyPartialRender: failed to trim to overlap");if(this.lastRowCount<C)throw new Error("applyPartialRender: trimmed beyond DOM row count");let y=this.lastRowCount-C;const v=(T,F)=>{if(!(F<=0||this.fileDiff==null))return this.hunksRenderer.renderDiff(this.fileDiff,{startingLine:T,totalLines:F,bufferBefore:0,bufferAfter:0})},p=v(u,Math.max(d-u,0));if(p==null&&u<d)return!1;const S=v(c,Math.max(h-c,0));if(S==null&&h>c)return!1;const H=(T,F)=>{if(T!=null){if(o==="unified"&&!Array.isArray(a))this.insertPartialHTML(o,a,T,F);else if(o==="split"&&Array.isArray(a))this.insertPartialHTML(o,a,T,F);else throw new Error("FileDiff.applyPartialRender.applyChunk: invalid chunk application");y+=T.rowCount}};return this.cleanupErrorWrapper(),H(p,"afterbegin"),H(S,"beforeend"),this.lastRowCount!==y&&(this.applyRowSpan(o,a,y),this.lastRowCount=y),!0}insertPartialHTML(e,t,i,n){if(e==="unified"&&!Array.isArray(t)){const s=this.hunksRenderer.renderCodeAST("unified",i);this.renderPartialColumn(t,s,n)}else if(e==="split"&&Array.isArray(t)){const s=this.hunksRenderer.renderCodeAST("deletions",i),r=this.hunksRenderer.renderCodeAST("additions",i);this.renderPartialColumn(t[0],s,n),this.renderPartialColumn(t[1],r,n)}else throw new Error("FileDiff.insertPartialHTML: Invalid argument composition")}fastRefreshDiffView(){if(this.options.diffStyle!=="split")return;const e=this.hunksRenderer.renderDiff(this.fileDiff,this.renderRange);if(e==null)return;const t=this.getCodeColumns("split",this.codeUnified,this.codeDeletions,this.codeAdditions);if(!Array.isArray(t))return;const i=(n,s)=>{if(s==null)return;const r=this.hunksRenderer.renderCodeAST(n,e),o=X(r?.[0]),a=X(r?.[1]);for(const[l,u]of[[s.gutter,o],[s.content,a]])if(u!=null&&l.childElementCount===u.length)for(let f=0;f<u.length;f++){const h=l.children[f],d=u[f].properties["data-line-type"];d!=null&&h.dataset.lineType!==d&&(h.dataset.lineType=d)}};i("deletions",t[0]),i("additions",t[1])}refreshDiffView(){const e=this.hunksRenderer.renderDiff(this.fileDiff,this.renderRange);if(e==null)return;const t=this.getCodeColumns(this.options.diffStyle??"split",this.codeUnified,this.codeDeletions,this.codeAdditions);if(t==null)return;const i=(n,s)=>{if(s==null)return;const r=this.hunksRenderer.renderCodeAST(n,e),o=X(r?.[0]),a=X(r?.[1]);for(const[l,u]of[[s.gutter,o],[s.content,a]])u!=null&&(l.innerHTML=le(u))};Array.isArray(t)?(i("deletions",t[0]),i("additions",t[1])):i("unified",t),this.syncRenderViewToEditor()}renderPartialColumn(e,t,i){if(e==null||t==null)return;const n=X(t[0]),s=X(t[1]);if(n==null||s==null)throw new Error("FileDiff.insertPartialHTML: Unexpected AST structure");const r=s.at(0);i==="beforeend"&&r?.type==="element"&&typeof r.properties["data-buffer-size"]=="number"&&this.mergeBuffersIfNecessary(r.properties["data-buffer-size"],e.content.children[e.content.children.length-1],e.gutter.children[e.gutter.children.length-1],n,s,!0);const o=s.at(-1);i==="afterbegin"&&o?.type==="element"&&typeof o.properties["data-buffer-size"]=="number"&&this.mergeBuffersIfNecessary(o.properties["data-buffer-size"],e.content.children[0],e.gutter.children[0],n,s,!1),e.gutter.insertAdjacentHTML(i,this.hunksRenderer.renderPartialHTML(n)),e.content.insertAdjacentHTML(i,this.hunksRenderer.renderPartialHTML(s))}mergeBuffersIfNecessary(e,t,i,n,s,r){if(!(t instanceof HTMLElement)||!(i instanceof HTMLElement))return;const o=this.getBufferSize(t.dataset);o!=null&&(r?(n.shift(),s.shift()):(n.pop(),s.pop()),this.updateBufferSize(t,o+e),this.updateBufferSize(i,o+e))}applyRowSpan(e,t,i){const n=s=>{s!=null&&(s.gutter.style.setProperty("grid-row",`span ${i}`),s.content.style.setProperty("grid-row",`span ${i}`))};if(e==="unified"&&!Array.isArray(t))n(t);else if(e==="split"&&Array.isArray(t))n(t[0]),n(t[1]);else throw new Error("dun fuuuuked up")}trimColumnRows(e,t,i){let n=0,s=0,r=0,o=!1;const a=i>=0;if(e==null)return 0;const l=Array.from(e.content.children),u=Array.from(e.gutter.children);if(l.length!==u.length)throw new Error("FileDiff.trimColumnRows: columns do not match");for(;r<l.length&&!(t<=0&&!a&&!o);){const f=u[r],h=l[r];if(r++,!(f instanceof HTMLElement)||!(h instanceof HTMLElement))throw console.error({gutterElement:f,contentElement:h}),new Error("FileDiff.trimColumnRows: invalid row elements");if(o&&(o=!1,f.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in h.dataset||f.dataset.gutterBuffer==="metadata"&&"noNewline"in h.dataset)){f.remove(),h.remove(),s++;continue}if("lineIndex"in f.dataset&&"lineIndex"in h.dataset){(t>0||a&&n>=i)&&(f.remove(),h.remove(),t>0&&(t--,t===0&&(o=!0)),s++),n++;continue}if("separator"in f.dataset&&"separator"in h.dataset){(t>0||a&&n>=i)&&(f.remove(),h.remove(),s++);continue}if(f.dataset.gutterBuffer==="annotation"&&"lineAnnotation"in h.dataset){(t>0||a&&n>=i)&&(f.remove(),h.remove(),s++);continue}if(f.dataset.gutterBuffer==="metadata"&&"noNewline"in h.dataset){(t>0||a&&n>=i)&&(f.remove(),h.remove(),s++);continue}if(f.dataset.gutterBuffer==="buffer"&&"contentBuffer"in h.dataset){const d=this.getBufferSize(h.dataset);if(d==null)throw new Error("FileDiff.trimColumnRows: invalid element");if(t>0){const c=Math.min(t,d),g=d-c;g>0?(this.updateBufferSize(f,g),this.updateBufferSize(h,g),s+=c):(f.remove(),h.remove(),s+=d),t-=c,t===0&&g===0&&(o=!0)}else if(a){const c=n,g=n+d-1;if(i<=c)f.remove(),h.remove(),s+=d;else if(i<=g){const m=g-i+1,C=d-m;this.updateBufferSize(f,C),this.updateBufferSize(h,C),s+=m}}n+=d;continue}throw console.error({gutterElement:f,contentElement:h}),new Error("FileDiff.trimColumnRows: unknown row elements")}return s}trimColumns({columns:e,diffStyle:t,overlapEnd:i,overlapStart:n,previousStart:s,trimEnd:r,trimStart:o}){const a=Math.max(0,n-s),l=i-s;if(l<0)throw new Error("FileDiff.trimColumns: overlap ends before previous");const u=o>0,f=r>0;if(!u&&!f)return 0;const h=u?a:0,d=f?l:-1;if(t==="unified"&&!Array.isArray(e))return this.trimColumnRows(e,h,d);if(t==="split"&&Array.isArray(e)){const c=this.trimColumnRows(e[0],h,d),g=this.trimColumnRows(e[1],h,d);if(e[0]!=null&&e[1]!=null&&c!==g)throw new Error("FileDiff.trimColumns: split columns out of sync");return e[0]!=null?c:g}else throw console.error({diffStyle:t,columns:e}),new Error("FileDiff.trimColumns: Invalid columns for diffType")}getBufferSize(e){const t=Number.parseInt(e?.bufferSize??"",10);return Number.isNaN(t)?void 0:t}updateBufferSize(e,t){e.dataset.bufferSize=`${t}`,e.style.setProperty("grid-row",`span ${t}`),e.style.setProperty("min-height",`calc(${t} * 1lh)`)}getCodeColumns(e,t,i,n){function s(r){if(r==null)return;const o=r.children[0],a=r.children[1];if(!(!(o instanceof HTMLElement)||!(a instanceof HTMLElement)||o.dataset.gutter==null||a.dataset.content==null))return{gutter:o,content:a}}if(e==="unified")return s(t);{const r=s(i),o=s(n);return r!=null||o!=null?[r,o]:void 0}}updateBuffers(e){this.pre!=null&&this.applyBuffers(this.pre,e)}applyBuffers(e,t){if(t==null||this.shouldDisableVirtualizationBuffers()){this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0);return}t.bufferBefore>0?(this.bufferBefore==null&&(this.bufferBefore=document.createElement("div"),this.bufferBefore.dataset.virtualizerBuffer="before",e.before(this.bufferBefore)),this.bufferBefore.style.setProperty("height",`${t.bufferBefore}px`),this.bufferBefore.style.setProperty("contain","strict")):this.bufferBefore!=null&&(this.bufferBefore.remove(),this.bufferBefore=void 0),t.bufferAfter>0?(this.bufferAfter==null&&(this.bufferAfter=document.createElement("div"),this.bufferAfter.dataset.virtualizerBuffer="after",e.after(this.bufferAfter)),this.bufferAfter.style.setProperty("height",`${t.bufferAfter}px`),this.bufferAfter.style.setProperty("contain","strict")):this.bufferAfter!=null&&(this.bufferAfter.remove(),this.bufferAfter=void 0)}shouldDisableVirtualizationBuffers(){return this.options.disableVirtualizationBuffers??!1}applyPreNodeAttributes(e,{additionsContentAST:t,deletionsContentAST:i,totalLines:n},s){const{diffIndicators:r="bars",disableBackground:o=!1,disableLineNumbers:a=!1,overflow:l="scroll",diffStyle:u="split"}=this.options,f={type:"diff",diffIndicators:r,disableBackground:o,disableLineNumbers:a,overflow:l,split:u==="unified"?!1:t!=null&&i!=null,totalLines:n,customProperties:s};gt(f,this.appliedPreAttributes)||(mt(e,f),this.appliedPreAttributes=f)}applyErrorToDOM(e,t){this.cleanupErrorWrapper(),this.pre?.remove(),this.pre=void 0,this.appliedPreAttributes=void 0;const i=t.shadowRoot??t.attachShadow({mode:"open"});this.errorWrapper??=document.createElement("div"),this.errorWrapper.dataset.errorWrapper="",this.errorWrapper.textContent="",i.appendChild(this.errorWrapper);const n=document.createElement("div");n.dataset.errorMessage="",n.innerText=e.message,this.errorWrapper.appendChild(n);const s=document.createElement("pre");s.dataset.errorStack="",s.innerText=e.stack??"No Error Stack",this.errorWrapper.appendChild(s)}cleanupErrorWrapper(){this.errorWrapper?.remove(),this.errorWrapper=void 0}};function hi({fileDiff:e,oldFile:t,newFile:i}){return e!=null&&e.hunks.length>0||t!=null||i!=null}function di({fileDiff:e,oldFile:t,newFile:i}){return e!=null||t!=null||i!=null}function ui(e,t,i=!1){return!i&&e==null&&t}function fi(e,t,i=!1){return e==null&&t&&!i}function X(e){if(!(e==null||e.type!=="element"))return e.children??[]}function ci({fileDiff:e,metrics:t,disableFileHeader:i,hunkSeparators:n,expandUnchanged:s,expandedHunks:r,collapsedContextThreshold:o}){let a=Y(t,i),l=a;const u=s?!0:r,f=e.hunks.length-1;for(let h=0;h<e.hunks.length;h++){const d=e.hunks[h];if(d==null)throw new Error("computeEstimatedDiffHeights: invalid hunk index");const c=we({isPartial:e.isPartial,rangeSize:d.collapsedBefore,expandedHunks:u,hunkIndex:h,collapsedContextThreshold:o}),g=(c.fromStart+c.fromEnd)*t.lineHeight;if(a+=g,l+=g,c.collapsedLines>0){const y=oe({type:n,metrics:t,hunkIndex:h,hunkSpecs:d.hunkSpecs})?.totalHeight??0;a+=y,l+=y}a+=d.splitLineCount*t.lineHeight,l+=d.unifiedLineCount*t.lineHeight;const m=pi(d);a+=m.split*t.lineHeight,l+=m.unified*t.lineHeight;const C=h===f?Me({fileDiff:e,hunkIndex:h,expandedHunks:u,collapsedContextThreshold:o,errorPrefix:"computeEstimatedDiffHeights"}):void 0;if(C!=null){const y=(C.fromStart+C.fromEnd)*t.lineHeight;if(a+=y,l+=y,C.collapsedLines>0){const v=ae({type:n,metrics:t})?.totalHeight??0;a+=v,l+=v}}}if(e.hunks.length>0){const h=Ze(t);a+=h,l+=h}return{splitHeight:a,unifiedHeight:l}}function pi(e){if(!e.noEOFCRAdditions&&!e.noEOFCRDeletions)return{split:0,unified:0};const t=e.hunkContent.at(-1);if(t==null)return{split:0,unified:0};if(t.type==="context"){const i=t.lines>0?1:0;return{split:i,unified:i}}return gi(e,t)}function gi(e,t){const i=(t.deletions>0&&e.noEOFCRDeletions?1:0)+(t.additions>0&&e.noEOFCRAdditions?1:0),n=t.deletions>0&&e.noEOFCRDeletions,s=t.additions>0&&e.noEOFCRAdditions;return{split:n||s?1:0,unified:i}}const ze=5e3;let mi=-1;var Mi=class extends li{__id=`little-virtualized-file-diff:${++mi}`;top;height=0;metrics;cache={heightDeltas:new Map,measuredHeightDeltaTotal:0,estimatedSplitHeight:void 0,estimatedUnifiedHeight:void 0,checkpoints:[],totalLines:0,fileAnnotationHeight:0};isVisible=!1;isSetup=!1;virtualizer;layoutDirty=!0;forceRenderOverride;currentCollapsed;constructor(e,t,i,n,s=!1){super(e,n,s),this.virtualizer=t,this.metrics=Re(i)}setMetrics(e,t=!1){const i=Re(e);!t&&St(this.metrics,i)||(this.metrics=i,this.resetLayoutCache({includeEstimatedHeights:!0}))}setLineAnnotations(e){this.syncLineAnnotations(e)&&this.resetLayoutCache({includeEstimatedHeights:!1})}syncLineAnnotations(e){return e==null||e===this.lineAnnotations||e.length===0&&this.lineAnnotations.length===0?!1:(super.setLineAnnotations(e),!0)}setFileAnnotationHeight(e){const t=this.cache.fileAnnotationHeight;return e===t?!1:(this.cache.fileAnnotationHeight=e,this.cache.measuredHeightDeltaTotal+=e-t,!0)}hasFileAnnotations(e=this.fileDiff){return e==null||!vt(this.lineAnnotations)?!1:this.lineAnnotations.some(t=>t.lineNumber!==0?!1:e.type==="new"?t.side==="additions":e.type==="deleted"?t.side==="deletions":!0)}getLineHeight(e,t=!1){return this.getEstimatedLineHeight(t)+(this.cache.heightDeltas.get(e)??0)}getEstimatedLineHeight(e=!1){const t=e?2:1;return this.metrics.lineHeight*t}setOptions(e){if(this.isAdvancedMode())throw new Error("VirtualizedFileDiff.setOptions cannot be used inside CodeView. Update CodeView options instead.");if(e==null)return;const{options:t}=this,i=!yt(t,e),n=i&&Li(t,e);super.setOptions(e),n&&this.resetLayoutCache({forceSimpleRecompute:!0,includeEstimatedHeights:Ti(t,e)}),i&&(this.forceRenderOverride=!0),i&&this.isSimpleMode()&&this.virtualizer.instanceChanged(this,n)}setThemeType(e){if(this.isAdvancedMode())throw new Error("VirtualizedFileDiff.setThemeType cannot be used inside CodeView. Update CodeView options instead.");super.setThemeType(e)}resetLayoutCache({forceSimpleRecompute:e=!1,includeEstimatedHeights:t=!1}={}){this.layoutDirty=!0,this.cache.fileAnnotationHeight=0,this.cache.heightDeltas.size>0&&this.cache.heightDeltas.clear(),this.cache.measuredHeightDeltaTotal!==0&&(this.cache.measuredHeightDeltaTotal=0),this.cache.checkpoints.length>0&&(this.cache.checkpoints.length=0),this.cache.totalLines!==0&&(this.cache.totalLines=0),t&&(this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0),this.renderRange!=null&&(this.renderRange=void 0),e&&this.isSimpleMode()&&this.computeApproximateSize()}reconcileHeights(){let e=!1;const{overflow:t="scroll"}=this.options;if(this.fileContainer==null||this.fileDiff==null)return this.height!==0&&(e=!0),this.height=0,e;if(this.top=this.getVirtualizedTop(),t==="scroll"&&this.lineAnnotations.length===0&&!this.isResizeDebuggingEnabled())return e;const i=this.getDiffStyle(),n=i==="split"?[this.codeDeletions,this.codeAdditions]:[this.codeUnified],s=this.hasFileAnnotations(this.fileDiff);if(this.renderRange!=null&&s&&Ye(this.renderRange)){const r=Ci(n)??0;this.setFileAnnotationHeight(r)&&(e=!0)}else!s&&this.setFileAnnotationHeight(0)&&(e=!0);for(const r of n){if(r==null)continue;const o=r.children[1];if(o instanceof HTMLElement)for(const a of o.children){if(!(a instanceof HTMLElement))continue;const l=a.dataset.lineIndex;if(l==null)continue;const u=ki(l,i);let f=a.getBoundingClientRect().height,h=!1;a.nextElementSibling instanceof HTMLElement&&("lineAnnotation"in a.nextElementSibling.dataset||"noNewline"in a.nextElementSibling.dataset)&&("noNewline"in a.nextElementSibling.dataset&&(h=!0),f+=a.nextElementSibling.getBoundingClientRect().height);const d=this.getEstimatedLineHeight(h),c=this.cache.heightDeltas.get(u)??0,g=f-d;g!==c&&(e=!0,this.cache.measuredHeightDeltaTotal+=g-c,g===0?this.cache.heightDeltas.delete(u):this.cache.heightDeltas.set(u,g))}}return(e||this.isResizeDebuggingEnabled())&&this.computeApproximateSize(!0),e}onRender=e=>this.fileContainer==null?!1:(e&&(this.top=this.getVirtualizedTop()),this.render());prepareCodeViewItem(e,t,i,n){const s=!re(this.fileDiff,e),r=this.syncLineAnnotations(n);let o=i?.resetDiffLayoutCache===!0||s||r,a=s||i?.resetDiffLayoutCache===!0&&i.includeEstimatedDiffHeights;i?.metrics!=null&&(this.metrics=Re(i.metrics),o=!0,a=!0);const{collapsed:l=!1}=this.options;return this.currentCollapsed!==l&&(this.currentCollapsed=l,o=!0),o&&this.resetLayoutCache({includeEstimatedHeights:a}),this.fileDiff=e,this.top=t,this.computeApproximateSize(),this.height}getLinePosition(e,t="additions"){if(this.fileDiff==null||e<1)return;const i=this.getLineIndex(e,t);if(i==null)return;const{disableFileHeader:n=!1,expandUnchanged:s=!1,collapsed:r=!1,collapsedContextThreshold:o=1}=this.options,a=this.getDiffStyle(),l=this.getHunkSeparatorType(),u=a==="split"?i[1]:i[0];this.approximateLayoutCheckpoints();const f=Y(this.metrics,n),h=this.getLayoutCheckpointBeforeLineIndex(u);let d=h?.top??f+this.cache.fileAnnotationHeight;if(r)return{top:f,height:0};let c;return ve({diff:this.fileDiff,diffStyle:a,startingLine:h?.renderedLineIndex??0,expandedHunks:s?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:g,hunk:m,collapsedBefore:C,collapsedAfter:y,deletionLine:v,additionLine:p})=>{const S=a==="split"?p?.splitLineIndex??v?.splitLineIndex:p?.unifiedLineIndex??v?.unifiedLineIndex;if(S==null)throw new Error("VirtualizedFileDiff.getLinePosition: missing line index data");if(C>0){const T=oe({type:l,metrics:this.metrics,hunkIndex:g,hunkSpecs:m?.hunkSpecs});if(T!=null){if(d+=T.gapBefore,u>=S-C&&u<S)return c={top:d,height:T.height},!0;d+=T.height+T.gapAfter}}const H=this.getLineHeight(S,(p?.noEOFCR??!1)||(v?.noEOFCR??!1));if(S===u)return c={top:d,height:H},!0;if(d+=H,y>0){const T=ae({type:l,metrics:this.metrics});if(T!=null){if(u>S&&u<=S+y)return c={top:d+T.gapBefore,height:T.height},!0;d+=T.totalHeight}}return!1}}),c}getNumericScrollAnchor(e){if(this.fileDiff==null)return;const{disableFileHeader:t=!1,expandUnchanged:i=!1,collapsed:n=!1,collapsedContextThreshold:s=1}=this.options;if(n)return;const r=this.getDiffStyle(),o=this.getHunkSeparatorType();this.approximateLayoutCheckpoints();const a=this.getLayoutCheckpointBeforeTop(e);let l=a?.top??Y(this.metrics,t)+this.cache.fileAnnotationHeight,u;return ve({diff:this.fileDiff,diffStyle:r,startingLine:a?.renderedLineIndex??0,expandedHunks:i?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:s,callback:({hunkIndex:f,hunk:h,collapsedBefore:d,collapsedAfter:c,deletionLine:g,additionLine:m})=>{const C=r==="split"?m?.splitLineIndex??g?.splitLineIndex:m?.unifiedLineIndex??g?.unifiedLineIndex;if(C==null)throw new Error("VirtualizedFileDiff.getNumericScrollAnchor: missing line index data");if(d>0){const v=oe({type:o,metrics:this.metrics,hunkIndex:f,hunkSpecs:h?.hunkSpecs});v!=null&&(l+=v.totalHeight)}if(l>=e&&(g!=null?u={lineNumber:g.lineNumber,side:"deletions",top:l}:m!=null&&(u={lineNumber:m.lineNumber,side:"additions",top:l}),u!=null))return!0;const y=this.getLineHeight(C,(m?.noEOFCR??!1)||(g?.noEOFCR??!1));if(l+=y,c>0){const v=ae({type:o,metrics:this.metrics});v!=null&&(l+=v.totalHeight)}return!1}}),u}getVirtualizedHeight(){return this.height}getAdvancedStickySpecs(e){if(this.top==null||this.fileDiff==null)return;if(this.options.collapsed===!0)return{topOffset:this.top,height:this.height};const t=e!=null?this.computeRenderRangeFromWindow(this.fileDiff,this.top,e):this.renderRange;if(t==null)return;const{bufferBefore:i,bufferAfter:n,totalLines:s}=t;let r=0;if(s===0){const o=e??this.virtualizer.getWindowSpecs();this.top<o.top&&(r=n)}return{topOffset:this.top+i+r,height:this.height-(i+n)}}cleanUp(e=!1){this.fileContainer!=null&&this.isSimpleMode()&&this.getSimpleVirtualizer()?.disconnect(this.fileContainer),e||this.resetLayoutCache({includeEstimatedHeights:!0}),this.isSetup=!1,super.cleanUp(e)}expandHunk=(e,t,i)=>{this.hunksRenderer.expandHunk(e,t,i),this.forceRenderOverride=!0,this.resetLayoutCache({includeEstimatedHeights:!0}),this.isSimpleMode()&&this.computeApproximateSize(),this.virtualizer.instanceChanged(this,!0)};setVisibility(e){this.isAdvancedMode()||this.fileContainer==null||(this.renderRange=void 0,e&&!this.isVisible?(this.top=this.getVirtualizedTop(),this.isVisible=!0):!e&&this.isVisible&&(this.isVisible=!1,this.rerender()))}rerender(){!this.enabled||this.fileDiff==null&&this.additionFile==null&&this.deletionFile==null||(this.forceRenderOverride=!0,this.virtualizer.instanceChanged(this,!1))}applyDocumentChange(e,t,i=!1){const n=this.renderRange;if(super.applyDocumentChange(e,t),this.getSimpleVirtualizer()?.markDOMDirty(),this.resetLayoutCache({forceSimpleRecompute:this.isSimpleMode(),includeEstimatedHeights:!0}),i&&n!==void 0&&this.fileDiff!==void 0){const s=this.virtualizer.getWindowSpecs(),r=this.computeRenderRangeFromWindow(this.fileDiff,this.top??0,s);r.bufferAfter!==n.bufferAfter&&this.updateBuffers(r)}}computeApproximateSize(e=!1){const t=this.isResizeDebuggingEnabled();if(!e&&!this.layoutDirty&&!t)return;const i=this.height===0;if(this.height=0,this.cache.checkpoints=[],this.cache.totalLines=0,this.fileDiff==null){this.layoutDirty=!1;return}const{disableFileHeader:n=!1,collapsed:s=!1}=this.options,r=Y(this.metrics,n);if(this.height+=r,s){this.layoutDirty=!1;return}this.height=this.getActiveEstimatedHeight()+this.cache.measuredHeightDeltaTotal,t&&!i&&this.validateComputedHeight(),this.layoutDirty=!1}getActiveEstimatedHeight(){this.ensureEstimatedDiffHeights();const e=this.getDiffStyle()==="split"?this.cache.estimatedSplitHeight:this.cache.estimatedUnifiedHeight;if(e==null)throw new Error("VirtualizedFileDiff.getActiveEstimatedHeight: missing estimated height");return e}ensureEstimatedDiffHeights(){if(this.fileDiff==null){this.cache.estimatedSplitHeight=void 0,this.cache.estimatedUnifiedHeight=void 0;return}if(this.cache.estimatedSplitHeight!=null&&this.cache.estimatedUnifiedHeight!=null)return;const{disableFileHeader:e=!1,expandUnchanged:t=!1,collapsedContextThreshold:i=1}=this.options,{splitHeight:n,unifiedHeight:s}=ci({fileDiff:this.fileDiff,metrics:this.metrics,disableFileHeader:e,hunkSeparators:this.getHunkSeparatorType(),expandUnchanged:t,expandedHunks:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:i});this.cache.estimatedSplitHeight=n,this.cache.estimatedUnifiedHeight=s}validateComputedHeight(){if(this.fileContainer==null||this.fileDiff==null)return;const e=this.fileContainer.getBoundingClientRect();e.height!==this.height?console.log("VirtualizedFileDiff.computeApproximateSize: computed height doesnt match",{name:this.fileDiff.name,elementHeight:e.height,computedHeight:this.height}):console.log("VirtualizedFileDiff.computeApproximateSize: computed height IS CORRECT")}render({fileContainer:e,oldFile:t,newFile:i,fileDiff:n,forceRender:s=!1,lineAnnotations:r,...o}={}){const{forceRenderOverride:a,isSetup:l}=this;this.forceRenderOverride=void 0;const u=this.syncLineAnnotations(r);if(u&&this.resetLayoutCache({includeEstimatedHeights:!1}),this.fileDiff??=n??(t!=null&&i!=null?Z(t,i,this.options.parseDiffOptions):void 0),e=this.getOrCreateFileContainer(e),this.fileDiff==null)return console.error("VirtualizedFileDiff.render: attempting to virtually render when we dont have the correct data"),!1;if(l)this.top??=this.getVirtualizedTop();else{this.computeApproximateSize();const c=this.getSimpleVirtualizer();if(this.top??=this.getVirtualizedTop(),this.isAdvancedMode())this.isVisible=!0;else{if(c==null)throw new Error("VirtualizedFileDiff.render: simple virtualizer is not available");c.connect(e,this),this.isVisible=c.isInstanceVisible(this.top??0,this.height)}this.isSetup=!0}if(!this.isVisible&&this.isSimpleMode())return this.renderPlaceholder(this.height);const f=this.virtualizer.getWindowSpecs(),h=this.top??0,d=this.computeRenderRangeFromWindow(this.fileDiff,h,f);return super.render({fileDiff:this.fileDiff,fileContainer:e,renderRange:d,oldFile:t,newFile:i,lineAnnotations:r,forceRender:(a??s)||u,...o})}syncVirtualizedTop(){this.top=this.getVirtualizedTop()}shouldDisableVirtualizationBuffers(){return this.isAdvancedMode()||super.shouldDisableVirtualizationBuffers()}isSimpleMode(){return this.virtualizer.type==="simple"}isAdvancedMode(){return this.virtualizer.type==="advanced"}getVirtualizedTop(){return this.virtualizer.type==="advanced"?this.virtualizer.getLocalTopForInstance(this):this.fileContainer!=null?this.virtualizer.getOffsetInScrollContainer(this.fileContainer):0}getSimpleVirtualizer(){return this.virtualizer.type==="simple"?this.virtualizer:void 0}isResizeDebuggingEnabled(){return this.getSimpleVirtualizer()?.config.resizeDebugging??!1}getDiffStyle(){return this.options.diffStyle??"split"}getHunkSeparatorType(){return Ai(this.options.hunkSeparators)}approximateLayoutCheckpoints(){if(this.cache.checkpoints.length>0||this.fileDiff==null||this.fileDiff.hunks.length===0||this.options.collapsed===!0)return;const{disableFileHeader:e=!1,expandUnchanged:t=!1,collapsedContextThreshold:i=1}=this.options,n=this.fileDiff.hunks.length-1,s=this.getDiffStyle(),r=this.getHunkSeparatorType(),o=t?!0:this.hunksRenderer.getExpandedHunksMap(),a=Si(this.cache.heightDeltas);let l=Y(this.metrics,e)+this.cache.fileAnnotationHeight,u=0;const f=({rowCount:h,startLineIndex:d,preSeparatorHeight:c=0,postSeparatorHeight:g=0,metadataOffsets:m=[]})=>{if(h<=0)return;const C=u,y=u+h;let v=vi(C);for(;v<y;){const p=v-C,S=l+(p>0?c:0)+p*this.metrics.lineHeight+yi(m,p)*this.metrics.lineHeight+qe(a,d,d+p);this.cache.checkpoints.push({renderedLineIndex:v,lineIndex:d+p,top:S}),v+=ze}l+=c+h*this.metrics.lineHeight+m.length*this.metrics.lineHeight+qe(a,d,d+h)+g,u=y};for(let h=0;h<this.fileDiff.hunks.length;h++){const d=this.fileDiff.hunks[h];if(d==null)throw new Error("VirtualizedFileDiff.approximateLayoutCheckpoints: invalid hunk index");const c=we({isPartial:this.fileDiff.isPartial,rangeSize:d.collapsedBefore,expandedHunks:o,hunkIndex:h,collapsedContextThreshold:i}),g=c.collapsedLines>0?oe({type:r,metrics:this.metrics,hunkIndex:h,hunkSpecs:d.hunkSpecs})?.totalHeight??0:0;f({rowCount:c.fromStart,startLineIndex:(s==="split"?d.splitLineStart:d.unifiedLineStart)-c.rangeSize});let m=g;f({rowCount:c.fromEnd,startLineIndex:(s==="split"?d.splitLineStart:d.unifiedLineStart)-c.fromEnd,preSeparatorHeight:m}),c.fromEnd>0&&(m=0);const C=h===n?Me({fileDiff:this.fileDiff,hunkIndex:h,expandedHunks:o,collapsedContextThreshold:i,errorPrefix:"VirtualizedFileDiff"}):void 0,y=C!=null&&C.collapsedLines>0?ae({type:r,metrics:this.metrics})?.totalHeight??0:0,v=C!=null?C.fromStart+C.fromEnd:0,p=s==="split"?d.splitLineCount:d.unifiedLineCount,S=s==="split"?d.splitLineStart:d.unifiedLineStart;f({rowCount:p,startLineIndex:S,preSeparatorHeight:m,postSeparatorHeight:v===0?y:0,metadataOffsets:Hi({diffStyle:s,hunk:d,rowCount:p})}),C!=null&&v>0&&f({rowCount:v,startLineIndex:S+p,postSeparatorHeight:y})}this.cache.totalLines=u}getLayoutCheckpointBeforeLineIndex(e){if(e<=0||this.cache.checkpoints.length===0)return;let t=0,i=this.cache.checkpoints.length-1,n;for(;t<=i;){const s=t+i>>1,r=this.cache.checkpoints[s];if(r==null)throw new Error("VirtualizedFileDiff: invalid checkpoint index");r.lineIndex<=e?(n=r,t=s+1):i=s-1}return n}getLayoutCheckpointBeforeTop(e,t){let i=0,n=this.cache.checkpoints.length-1,s=-1;for(;i<=n;){const r=i+n>>1,o=this.cache.checkpoints[r];if(o==null)throw new Error("VirtualizedFileDiff: invalid checkpoint index");o.top<=e?(s=r,i=r+1):n=r-1}if(t==null)return s>=0?this.cache.checkpoints[s]:void 0;for(let r=s;r>=0;r--){const o=this.cache.checkpoints[r];if(o==null)throw new Error("VirtualizedFileDiff: invalid checkpoint index");if(o.renderedLineIndex%t===0)return o}}getExpandedLineCount(e,t){let i=0;if(e.isPartial){for(const a of e.hunks)i+=t==="split"?a.splitLineCount:a.unifiedLineCount;return i}const{expandUnchanged:n=!1,collapsedContextThreshold:s=1}=this.options,r=n?!0:this.hunksRenderer.getExpandedHunksMap();for(const[a,l]of e.hunks.entries()){const u=t==="split"?l.splitLineCount:l.unifiedLineCount;i+=u;const f=Math.max(l.collapsedBefore,0),{fromStart:h,fromEnd:d,renderAll:c}=we({isPartial:e.isPartial,rangeSize:f,expandedHunks:r,hunkIndex:a,collapsedContextThreshold:s});f>0&&(i+=c?f:h+d)}const o=Me({fileDiff:e,hunkIndex:e.hunks.length-1,expandedHunks:r,collapsedContextThreshold:s,errorPrefix:"VirtualizedFileDiff"});return o!=null&&(i+=o.fromStart+o.fromEnd),i}computeRenderRangeFromWindow(e,t,{top:i,bottom:n}){const{disableFileHeader:s=!1,expandUnchanged:r=!1,collapsedContextThreshold:o=1}=this.options,{hunkLineCount:a,lineHeight:l}=this.metrics,u=this.getDiffStyle(),f=this.getHunkSeparatorType(),h=this.height;let d=this.cache.totalLines>0?this.cache.totalLines:this.getExpandedLineCount(e,u);const c=Y(this.metrics,s),g=e.hunks.length>0?Ze(this.metrics):0,{fileAnnotationHeight:m}=this.cache,C=c+m,y=Math.max(0,h-c-m-g),v=this.hasFileAnnotations(e),p=t+c,S=m>0&&v&&p<n&&p+m>i;if(t<i-h||t>n)return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:h-c-g};if(d<=a||e.hunks.length===0)return{startingLine:0,totalLines:a,bufferBefore:0,bufferAfter:0};this.approximateLayoutCheckpoints(),d=this.cache.totalLines>0?this.cache.totalLines:d;const H=Math.ceil(Math.max(n-i,0)/l),T=Math.ceil(H/a)*a+a,F=T/a,de=F,j=[],ue=(i+n)/2,q=this.getLayoutCheckpointBeforeTop(Math.max(0,i-t-T*l*2),a);let b=t+(q?.top??C),Q=q?.renderedLineIndex??0,R,D,U;if(ve({diff:e,diffStyle:u,startingLine:q?.renderedLineIndex??0,expandedHunks:r?!0:this.hunksRenderer.getExpandedHunksMap(),collapsedContextThreshold:o,callback:({hunkIndex:ye,hunk:He,collapsedBefore:te,collapsedAfter:ie,deletionLine:k,additionLine:E})=>{const z=E!=null?E.splitLineIndex:k.splitLineIndex,$=E!=null?E.unifiedLineIndex:k.unifiedLineIndex,O=(E?.noEOFCR??!1)||(k?.noEOFCR??!1),N=(te>0?oe({type:f,metrics:this.metrics,hunkIndex:ye,hunkSpecs:He?.hunkSpecs}):void 0)?.totalHeight??0;b+=N;const ne=Q%a===0,M=Math.floor(Q/a);if(ne&&(j[M]=b-(t+C+N),U!=null)){if(U<=0)return!0;U--}const Le=this.getLineHeight(u==="split"?z:$,O);return b>i-Le&&b<n&&(R??=M),D==null&&b+Le>ue&&(D=M),U==null&&b>=n&&ne&&(U=de),Q++,b+=Le,ie>0&&(b+=ae({type:f,metrics:this.metrics})?.totalHeight??0),!1}}),R==null)if(S)R=0,D=0;else return{startingLine:0,totalLines:0,bufferBefore:0,bufferAfter:h-c-g};D??=R;const V=Math.round(D-F/2),L=Math.max(0,Math.ceil(d/a)-F),A=Math.max(0,Math.min(V,L)),x=A*a,I=V<0?T+V*a:T,W=j[A]??0,J=x===0?0:m+W,ee=A+I/a,fe=ee<j.length?y-j[ee]:y-(b-t-C);return{startingLine:x,totalLines:I,bufferBefore:J,bufferAfter:Math.max(0,fe)}}};function Ci(e){let t;for(const i of e){if(i==null)continue;const n=i.children[1];if(n instanceof HTMLElement)for(const s of n.children)s instanceof HTMLElement&&s.dataset.lineAnnotation===Ht&&(t=Math.max(t??0,s.getBoundingClientRect().height))}return t}function Si(e){const t=Array.from(e).sort((r,o)=>r[0]-o[0]),i=[],n=[0];let s=0;for(const[r,o]of t)i.push(r),s+=o,n.push(s);return{lineIndexes:i,prefixTotals:n}}function qe({lineIndexes:e,prefixTotals:t},i,n){if(i>=n||e.length===0)return 0;const s=Ke(e,i);return(t[Ke(e,n)]??0)-(t[s]??0)}function Ke(e,t){let i=0,n=e.length;for(;i<n;){const s=i+n>>1,r=e[s];if(r==null)throw new Error("VirtualizedFileDiff: invalid prefix index");r<t?i=s+1:n=s}return i}function vi(e){return Math.ceil(e/ze)*ze}function yi(e,t){let i=0;for(const n of e)n<t&&i++;return i}function Hi({diffStyle:e,hunk:t,rowCount:i}){if(i<=0||!t.noEOFCRAdditions&&!t.noEOFCRDeletions)return[];const n=t.hunkContent.at(-1);if(n==null)return[];if(n.type==="context")return[i-1];const s=Math.max(n.deletions,n.additions),r=n.deletions+n.additions;if(e==="split")return s>0&&(t.noEOFCRAdditions||t.noEOFCRDeletions)?[i-1]:[];const o=[],a=i-r;return n.deletions>0&&t.noEOFCRDeletions&&o.push(a+n.deletions-1),n.additions>0&&t.noEOFCRAdditions&&o.push(i-1),o}function Li(e,t){return(e.diffStyle??"split")!==(t.diffStyle??"split")||(e.overflow??"scroll")!==(t.overflow??"scroll")||(e.collapsed??!1)!==(t.collapsed??!1)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.diffIndicators??"bars")!==(t.diffIndicators??"bars")||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)||e.unsafeCSS!==t.unsafeCSS}function Ti(e,t){return(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||(e.hunkSeparators??"line-info")!==(t.hunkSeparators??"line-info")||(e.expandUnchanged??!1)!==(t.expandUnchanged??!1)||(e.collapsedContextThreshold??1)!==(t.collapsedContextThreshold??1)}function Ai(e){return typeof e=="function"?"custom":e??"line-info"}function ki(e,t){const[i,n]=e.split(",").map(Number);return t==="split"?n:i}export{li as F,Mi as V,Z as p};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as p,j as s,f as O}from"./vendor-react-BUCujlKS.js";import{f as V,l as ot,I as N,
|
|
1
|
+
import{r as p,j as s,f as O}from"./vendor-react-BUCujlKS.js";import{f as V,l as ot,I as N,dq as nt,B as L,h as F,aa as Et,aY as at,aZ as lt,a_ as it,ad as At,a1 as Pt,bU as zt,a4 as Dt,V as Ht,aj as Je,bH as ie,bI as Lt,hM as Ot,aV as Qe,aS as et,aU as tt,ft as st,ba as Ce,fs as ce,aT as Wt,o as Bt}from"./useAppFontEffects-B53Rb6m7.js";import{b as A,d as $t,h as Ft,W as Gt}from"./main-WMjtYzJs.js";import{r as ct,L as Ut,u as ue}from"./index-Cwmuwk3V.js";import{P as _t}from"./PierreDiffViewer-Dlby4XqT.js";import{f as qt}from"./patchFileDiff-BcFaMtMu.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-base-ui-DsHmyMwp.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-BEARQjgn.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-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.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-vch3tJ4c.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-zod-C9ioTTSo.js";import"./runtimeEndpointReset-ovNbaZ-x.js";import"./SessionSwitcherDropdown-IETz58DB.js";import"./scheduledTasksApi-BFSlqgnG.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./web-components-pcwCTWjC.js";import"./computeVirtualFileMetrics-DkRR5b75.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"./VirtualizedFileDiff-lESMT-2b.js";import"./isDiffPlainText-BG53Ixxy.js";import"./vendor-diff-C3JhlQdm.js";import"./useInlineCommentController-DSfrIBKT.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";const Kt=o=>{if(!o?.walkthrough)return null;const t=new Map(o.hunks.map(a=>[a.id,a])),e=new Set,r=[],l=[];for(const[a,u]of o.walkthrough.chapters.entries()){const i=[];for(const m of u.stops){const d=[],h=[];for(const w of m.hunkIds){const x=t.get(w);x?(d.push(x),e.add(w)):h.push(w)}const g={stop:m,chapter:u,chapterIndex:a,position:r.length+1,hunks:d,missingHunkIds:h,isStale:h.length>0};r.push(g),i.push(g)}l.push({chapter:u,stops:i})}return{walkthrough:o.walkthrough,stops:r,chapters:l,uncoveredHunks:o.hunks.filter(a=>!e.has(a.id)),staleStopCount:r.filter(a=>a.isStale).length,isStale:r.some(a=>a.isStale)}},Vt=o=>{const t=new Map;for(const e of o){const r=t.get(e.path);if(r){r.added+=e.added,r.deleted+=e.deleted;continue}t.set(e.path,{path:e.path,added:e.added,deleted:e.deleted})}return[...t.values()]},ut=o=>{const t=[];for(const e of o){const r=t.at(-1);if(r&&r.path===e.path){r.hunks.push(e);continue}t.push({path:e.path,hunks:[e]})}return t},Xt=o=>{if(o.length===0)return"";if(o.length===1)return o[0].patch;const t=o[0].patch,e=t.indexOf(`
|
|
2
2
|
@@`);if(e===-1)return t;const r=t.slice(0,e),l=o.map(a=>{const u=a.patch.indexOf(`
|
|
3
3
|
@@`);return u===-1?"":a.patch.slice(u+1)});return`${r}
|
|
4
4
|
${l.join("")}`},Yt=o=>o?`${o.providerID}/${o.modelID}`:"",Zt=({reason:o,model:t,requiredChars:e,availableChars:r,onRetry:l})=>{const{t:a}=V(),u=ot(f=>f.modelsMetadata),[i,m]=p.useState(void 0),[d,h]=p.useState(!1),g=o==="context-too-small"||o==="structured-output-unsupported"||o==="output-exhausted";p.useEffect(()=>{if(!g||i!==void 0)return;let f=!1;return(async()=>{try{const b=await ct("/api/small-model",{method:"GET",headers:{Accept:"application/json"}});if(!b.ok)return;const T=await b.json().catch(()=>null);!f&&Array.isArray(T?.authenticatedProviders)&&m(T.authenticatedProviders.filter(I=>typeof I=="string"))}catch{}})(),()=>{f=!0}},[g,i]);const w=p.useCallback(async(f,b)=>{if(!f||!b||d)return;const T=`${f}/${b}`;h(!0);try{await Ut({walkthroughModelOverride:T}),l()}catch(I){console.warn("Failed to save small model override:",I)}finally{h(!1)}},[l,d]),x=p.useCallback((f,b)=>u.get(`${f}/${b}`)?.structured_output!==!1,[u]),k=Yt(t),v=()=>{if(o==="no-model")return a("walkthrough.blocked.noModel.description");if(o==="empty-diff")return a("walkthrough.blocked.emptyDiff.description");if(o==="only-generated")return a("walkthrough.blocked.onlyGenerated.description");if(o==="server-unsupported")return a("walkthrough.blocked.serverUnsupported.description");if(o==="output-exhausted")return k?a("walkthrough.blocked.outputExhausted.description",{model:k}):a("walkthrough.blocked.outputExhausted.descriptionUnknownModel");if(o==="structured-output-unsupported")return k?a("walkthrough.blocked.structuredOutput.description",{model:k}):a("walkthrough.blocked.structuredOutput.descriptionUnknownModel");const f=Math.ceil((e??0)/1e3),b=Math.ceil((r??0)/1e3);return k?a("walkthrough.blocked.contextTooSmall.description",{model:k,required:f,available:b}):a("walkthrough.blocked.contextTooSmall.descriptionUnknownModel",{required:f,available:b})},j=()=>a(o==="no-model"?"walkthrough.blocked.noModel.title":o==="empty-diff"?"walkthrough.blocked.emptyDiff.title":o==="only-generated"?"walkthrough.blocked.onlyGenerated.title":o==="server-unsupported"?"walkthrough.blocked.serverUnsupported.title":o==="output-exhausted"?"walkthrough.blocked.outputExhausted.title":o==="structured-output-unsupported"?"walkthrough.blocked.structuredOutput.title":"walkthrough.blocked.contextTooSmall.title");return s.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center",children:[s.jsx(N,{name:o==="empty-diff"||o==="only-generated"?"information":"error-warning",className:"size-6 text-muted-foreground"}),s.jsx("h3",{className:"typography-ui-label font-semibold text-foreground",children:j()}),s.jsx("p",{className:"typography-meta max-w-md text-muted-foreground",children:v()}),g&&s.jsxs("div",{className:"flex flex-col items-center gap-2 pt-2",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:a("walkthrough.blocked.chooseModel")}),s.jsx(nt,{providerId:t?.providerID??"",modelId:t?.modelID??"",onChange:(f,b)=>{w(f,b)},allowedProviderIds:i??[],isModelAllowed:x})]}),(o==="empty-diff"||o==="only-generated"||o==="server-unsupported")&&s.jsx(L,{type:"button",variant:"outline",size:"sm",onClick:l,children:a("walkthrough.action.refresh")})]})},Jt=[{labelKey:"walkthrough.stage.collecting"},{labelKey:"walkthrough.stage.asking"},{labelKey:"walkthrough.stage.assembling"}],Qt=o=>{const t=O.c(6),{progress:e}=o,{t:r}=V(),{completedCount:l,activeIndex:a}=e;let u;t[0]!==a||t[1]!==l||t[2]!==r?(u=Jt.map((m,d)=>{const h=d<l,g=a===d;return s.jsxs("li",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:h?s.jsx(N,{name:"check",className:"size-3.5 text-status-success"}):g?s.jsx(N,{name:"loader-4",className:"size-3.5 animate-spin text-[var(--status-info)]"}):s.jsx("span",{className:"size-1.5 rounded-full bg-surface-muted"})}),s.jsx("span",{className:F("typography-meta",g?"text-foreground":h?"text-muted-foreground":"text-muted-foreground/60"),children:r(m.labelKey)})]},m.labelKey)}),t[0]=a,t[1]=l,t[2]=r,t[3]=u):u=t[3];let i;return t[4]!==u?(i=s.jsx("ul",{className:"flex flex-col gap-2 text-left",children:u}),t[4]=u,t[5]=i):i=t[5],i},Q=["collecting","asking","assembling"],Ie=450,es=o=>o==="retrying"?Q.indexOf("asking"):o?Q.indexOf(o):-1,ts=(o,t)=>Math.min(o+1,t),ss=(o,t)=>{const e=O.c(17),[r,l]=p.useState(-1),a=p.useRef(0);let u;e[0]!==t||e[1]!==r||e[2]!==o?(u=t?Math.max(es(o),0):r<0?-1:Q.length,e[0]=t,e[1]=r,e[2]=o,e[3]=u):u=e[3];const i=u;let m,d;e[4]!==t||e[5]!==r||e[6]!==i?(m=()=>{if(i<=r){i<r&&t&&(l(i),a.current=Date.now());return}const f=Date.now()-a.current,b=()=>{a.current=Date.now(),l(I=>ts(I,i))};if(r<0||f>=Ie){b();return}const T=setTimeout(b,Ie-f);return()=>clearTimeout(T)},d=[t,r,i],e[4]=t,e[5]=r,e[6]=i,e[7]=m,e[8]=d):(m=e[7],d=e[8]),p.useEffect(m,d);let h,g;e[9]!==t||e[10]!==r?(h=()=>{if(t||r<Q.length)return;const f=setTimeout(()=>l(-1),Ie);return()=>clearTimeout(f)},g=[t,r],e[9]=t,e[10]=r,e[11]=h,e[12]=g):(h=e[11],g=e[12]),p.useEffect(h,g);const w=r>=Q.length,x=Math.max(0,Math.min(r,Q.length)),k=w||r<0?null:r,v=!t&&r>=0;let j;return e[13]!==x||e[14]!==k||e[15]!==v?(j={completedCount:x,activeIndex:k,holding:v},e[13]=x,e[14]=k,e[15]=v,e[16]=j):j=e[16],j},dt=p.memo(function(t){const e=O.c(11),{path:r,hunks:l,renderSideBySide:a,wrapLines:u}=t;let i;if(e[0]!==l||e[1]!==r){const g=Xt(l);i=g?qt(r,g):void 0,e[0]=l,e[1]=r,e[2]=i}else i=e[2];const m=i;if(!m)return null;let d;e[3]!==r?(d=Et(r)||"",e[3]=r,e[4]=d):d=e[4];let h;return e[5]!==m||e[6]!==r||e[7]!==a||e[8]!==d||e[9]!==u?(h=s.jsx(_t,{original:"",modified:"",fileDiff:m,language:d,fileName:r,renderSideBySide:a,wrapLines:u,layout:"inline"}),e[5]=m,e[6]=r,e[7]=a,e[8]=d,e[9]=u,e[10]=h):h=e[10],h}),Re=o=>`walkthrough-stop-${o}`,rs={critical:"border border-[var(--interactive-border)] font-medium text-foreground",normal:"bg-surface-muted text-muted-foreground",context:"bg-surface-muted text-muted-foreground"},os=o=>{const t=O.c(22),{stopView:e}=o,{t:r}=V(),{stop:l}=e;let a;t[0]!==e.position?(a=s.jsx("span",{className:"typography-micro flex h-5 min-w-5 shrink-0 items-center justify-center rounded-full bg-surface-muted px-1.5 tabular-nums text-muted-foreground",children:e.position}),t[0]=e.position,t[1]=a):a=t[1];let u;t[2]!==l.title?(u=s.jsx("h3",{className:"typography-ui-label font-semibold text-foreground",children:l.title}),t[2]=l.title,t[3]=u):u=t[3];let i;t[4]!==l.importance||t[5]!==r?(i=l.importance!=="normal"&&s.jsxs(at,{children:[s.jsx(lt,{className:F("typography-micro flex h-5 items-center rounded px-1.5 leading-none",rs[l.importance]),children:l.importance==="critical"?r("walkthrough.importance.critical"):r("walkthrough.importance.context")}),s.jsx(it,{className:"max-w-64",children:s.jsx("p",{className:"typography-micro leading-tight",children:l.importance==="critical"?r("walkthrough.importance.criticalHint"):r("walkthrough.importance.contextHint")})})]}),t[4]=l.importance,t[5]=r,t[6]=i):i=t[6];let m;t[7]!==a||t[8]!==u||t[9]!==i?(m=s.jsxs("div",{className:"flex items-center gap-2",children:[a,u,i]}),t[7]=a,t[8]=u,t[9]=i,t[10]=m):m=t[10];let d;t[11]!==l.prose?(d=s.jsx("p",{className:"typography-body text-muted-foreground",children:l.prose}),t[11]=l.prose,t[12]=d):d=t[12];let h;t[13]!==e.hunks||t[14]!==e.isStale||t[15]!==e.missingHunkIds||t[16]!==r?(h=e.isStale&&s.jsxs("p",{className:"typography-meta flex items-center gap-1.5 text-status-warning",children:[s.jsx(N,{name:"error-warning",className:"size-3.5 shrink-0"}),e.hunks.length===0?r("walkthrough.stop.staleAll"):r("walkthrough.stop.stalePartial",{count:e.missingHunkIds.length})]}),t[13]=e.hunks,t[14]=e.isStale,t[15]=e.missingHunkIds,t[16]=r,t[17]=h):h=t[17];let g;return t[18]!==m||t[19]!==d||t[20]!==h?(g=s.jsxs("header",{className:"flex flex-col gap-2 px-4 pt-5 pb-3",children:[m,d,h]}),t[18]=m,t[19]=d,t[20]=h,t[21]=g):g=t[21],g},pt=o=>{const t=O.c(2),{path:e}=o;let r;return t[0]!==e?(r=s.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-1.5 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 px-4 py-1.5 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80",children:[s.jsx(At,{filePath:e,className:"size-3.5 shrink-0"}),s.jsx("span",{className:"typography-meta truncate font-mono text-foreground",children:e})]}),t[0]=e,t[1]=r):r=t[1],r},ns=o=>{const t=O.c(11),{hunks:e,renderSideBySide:r,wrapLines:l}=o;let a;t[0]!==e?(a=ut(e),t[0]=e,t[1]=a):a=t[1];const u=a;let i;if(t[2]!==r||t[3]!==u||t[4]!==l){let d;t[6]!==r||t[7]!==l?(d=(h,g)=>s.jsxs("div",{children:[s.jsx(pt,{path:h.path}),s.jsx(dt,{path:h.path,hunks:h.hunks,renderSideBySide:r,wrapLines:l})]},`${h.path}-${g}`),t[6]=r,t[7]=l,t[8]=d):d=t[8],i=u.map(d),t[2]=r,t[3]=u,t[4]=l,t[5]=i}else i=t[5];let m;return t[9]!==i?(m=s.jsx(s.Fragment,{children:i}),t[9]=i,t[10]=m):m=t[10],m},as=p.memo(function(t){const e=O.c(35),{view:r,activeStopId:l,scrollToStopId:a,onActiveStopChange:u,onScrollHandled:i,renderSideBySide:m,wrapLines:d}=t,{t:h}=V(),g=p.useRef(null),[w,x]=p.useState(!1),k=p.useRef(null),v=p.useRef(null);let j,f;e[0]===Symbol.for("react.memo_cache_sentinel")?(j=()=>()=>{v.current!==null&&window.clearTimeout(v.current)},f=[],e[0]=j,e[1]=f):(j=e[0],f=e[1]),p.useEffect(j,f);let b,T;e[2]!==i||e[3]!==a?(b=()=>{if(!a)return;const M=document.getElementById(Re(a));M&&(k.current=a,M.scrollIntoView({behavior:"auto",block:"start"}),v.current!==null&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>{k.current=null,v.current=null},250)),i()},T=[a,i],e[2]=i,e[3]=a,e[4]=b,e[5]=T):(b=e[4],T=e[5]),p.useEffect(b,T);let I;e[6]!==u?(I=M=>{const R=M.filter(ls).sort(is)[0];if(!R)return;const P=R.target.getAttribute("data-stop-id");if(!P)return;const $=k.current;if($){P===$&&(k.current=null);return}u(P)},e[6]=u,e[7]=I):I=e[7];const X=I;let G,Y;e[8]!==X||e[9]!==r.stops?(G=()=>{const M=g.current;if(!M)return;const R=new IntersectionObserver(X,{root:M,rootMargin:"0px 0px -70% 0px",threshold:0});for(const P of r.stops){const $=document.getElementById(Re(P.stop.id));$&&R.observe($)}return()=>R.disconnect()},Y=[X,r.stops],e[8]=X,e[9]=r.stops,e[10]=G,e[11]=Y):(G=e[10],Y=e[11]),p.useEffect(G,Y);let U;e[12]!==r.uncoveredHunks?(U=ut(r.uncoveredHunks),e[12]=r.uncoveredHunks,e[13]=U):U=e[13];const ee=U;let W;if(e[14]!==l||e[15]!==m||e[16]!==h||e[17]!==r.stops||e[18]!==d){let M;e[20]!==l||e[21]!==m||e[22]!==h||e[23]!==d?(M=R=>s.jsxs("section",{id:Re(R.stop.id),"data-stop-id":R.stop.id,className:F("border-b border-border/60",l===R.stop.id&&"bg-interactive-selection/5"),children:[s.jsx(os,{stopView:R}),R.hunks.length>0?s.jsx(ns,{hunks:R.hunks,renderSideBySide:m,wrapLines:d}):s.jsx("p",{className:"typography-meta px-4 pb-4 text-muted-foreground",children:h("walkthrough.stop.noCode")})]},R.stop.id),e[20]=l,e[21]=m,e[22]=h,e[23]=d,e[24]=M):M=e[24],W=r.stops.map(M),e[14]=l,e[15]=m,e[16]=h,e[17]=r.stops,e[18]=d,e[19]=W}else W=e[19];let B;e[25]!==m||e[26]!==h||e[27]!==w||e[28]!==ee||e[29]!==r.uncoveredHunks.length||e[30]!==d?(B=r.uncoveredHunks.length>0&&s.jsxs("section",{className:"border-b border-border/60",children:[s.jsxs(L,{type:"button",variant:"ghost",className:"h-auto w-full justify-start gap-2 px-4 py-3",onClick:()=>x(cs),"aria-expanded":w,children:[s.jsx(N,{name:w?"arrow-down-s":"arrow-right-s",className:"size-4 shrink-0"}),s.jsx("span",{className:"typography-ui-label text-muted-foreground",children:h("walkthrough.uncovered.title",{count:r.uncoveredHunks.length})})]}),!w&&s.jsx("p",{className:"typography-meta px-4 pb-3 pl-10 text-muted-foreground",children:h("walkthrough.uncovered.description")}),w&&ee.map((M,R)=>s.jsxs("div",{children:[s.jsx(pt,{path:M.path}),s.jsx(dt,{path:M.path,hunks:M.hunks,renderSideBySide:m,wrapLines:d})]},`${M.path}-${R}`))]}),e[25]=m,e[26]=h,e[27]=w,e[28]=ee,e[29]=r.uncoveredHunks.length,e[30]=d,e[31]=B):B=e[31];let _;return e[32]!==B||e[33]!==W?(_=s.jsxs("div",{ref:g,className:"min-h-0 flex-1 overflow-y-auto","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:[W,B]}),e[32]=B,e[33]=W,e[34]=_):_=e[34],_});function ls(o){return o.isIntersecting}function is(o,t){return o.boundingClientRect.top-t.boundingClientRect.top}function cs(o){return!o}const us={bug:"bug",wrench:"tools",path:"compass-3",flask:"flask",doc:"file-text",gear:"settings-3"},ds=o=>{const t=O.c(30),{stopView:e,isActive:r,isVisited:l,onSelect:a,activeRef:u}=o,{t:i}=V();let m;if(t[0]!==u||t[1]!==r||t[2]!==l||t[3]!==a||t[4]!==e.hunks||t[5]!==e.isStale||t[6]!==e.position||t[7]!==e.stop.title||t[8]!==i){const d=Vt(e.hunks),h=r&&"bg-interactive-selection text-interactive-selection-foreground";let g;t[10]!==h?(g=F("flex w-full flex-col gap-1 rounded px-2 py-1.5 text-left transition-colors","hover:bg-interactive-hover",h),t[10]=h,t[11]=g):g=t[11];const w=r?"bg-interactive-selection-foreground/20":l?"bg-status-success/15 text-status-success":"bg-surface-muted text-muted-foreground";let x;t[12]!==w?(x=F("typography-micro flex h-4 min-w-4 shrink-0 items-center justify-center rounded-full px-1 tabular-nums",w),t[12]=w,t[13]=x):x=t[13];let k;t[14]!==r||t[15]!==l||t[16]!==e.position?(k=l&&!r?s.jsx(N,{name:"check",className:"size-2.5"}):e.position,t[14]=r,t[15]=l,t[16]=e.position,t[17]=k):k=t[17];let v;t[18]!==x||t[19]!==k?(v=s.jsx("span",{className:x,children:k}),t[18]=x,t[19]=k,t[20]=v):v=t[20];let j;t[21]!==e.stop.title?(j=s.jsx("span",{className:"typography-meta truncate font-medium",children:e.stop.title}),t[21]=e.stop.title,t[22]=j):j=t[22];let f;t[23]!==e.isStale||t[24]!==i?(f=e.isStale&&s.jsx(N,{name:"error-warning",className:"size-3 shrink-0 text-status-warning","aria-label":i("walkthrough.stop.staleShort")}),t[23]=e.isStale,t[24]=i,t[25]=f):f=t[25];let b;t[26]!==v||t[27]!==j||t[28]!==f?(b=s.jsxs("span",{className:"flex items-center gap-2",children:[v,j,f]}),t[26]=v,t[27]=j,t[28]=f,t[29]=b):b=t[29],m=s.jsx("li",{children:s.jsxs("button",{ref:r?u:void 0,type:"button",onClick:a,"aria-current":r?"step":void 0,className:g,children:[b,d.length>0&&s.jsxs("span",{className:"typography-micro flex flex-col gap-0.5 pl-6 text-muted-foreground",children:[d.slice(0,3).map(hs),d.length>3&&s.jsx("span",{children:i("walkthrough.toc.moreFiles",{count:d.length-3})})]})]})}),t[0]=u,t[1]=r,t[2]=l,t[3]=a,t[4]=e.hunks,t[5]=e.isStale,t[6]=e.position,t[7]=e.stop.title,t[8]=i,t[9]=m}else m=t[9];return m},ps=p.memo(function(t){const e=O.c(20),{view:r,activeStopId:l,visitedStopIds:a,onSelectStop:u,width:i}=t,{t:m}=V(),d=p.useRef(null);let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{d.current?.scrollIntoView({block:"nearest"})},e[0]=h):h=e[0];let g;e[1]!==l?(g=[l],e[1]=l,e[2]=g):g=e[2],p.useEffect(h,g);let w;e[3]!==i?(w={width:i},e[3]=i,e[4]=w):w=e[4];let x;e[5]!==r.walkthrough.focus?(x=r.walkthrough.focus&&s.jsx("p",{className:"typography-meta px-2 pb-3 pt-1 text-muted-foreground",children:r.walkthrough.focus}),e[5]=r.walkthrough.focus,e[6]=x):x=e[6];let k;e[7]!==l||e[8]!==u||e[9]!==r.chapters||e[10]!==a?(k=r.chapters.map(f=>{const{chapter:b,stops:T}=f;return s.jsxs("section",{className:"pb-3",children:[s.jsxs("h4",{className:"typography-micro flex items-center gap-1.5 px-2 py-1 font-semibold uppercase tracking-wide text-muted-foreground",children:[s.jsx(N,{name:us[b.icon]??"file-text",className:"size-3 shrink-0"}),s.jsx("span",{className:"truncate",children:b.title})]}),s.jsx("ul",{className:"flex flex-col gap-0.5",children:T.map(I=>s.jsx(ds,{stopView:I,isActive:l===I.stop.id,isVisited:a.has(I.stop.id),onSelect:()=>u(I.stop.id),activeRef:d},I.stop.id))})]},b.id)}),e[7]=l,e[8]=u,e[9]=r.chapters,e[10]=a,e[11]=k):k=e[11];let v;e[12]!==m||e[13]!==r.uncoveredHunks.length?(v=r.uncoveredHunks.length>0&&s.jsx("p",{className:"typography-micro mt-auto px-2 pt-3 text-muted-foreground",children:m("walkthrough.toc.uncovered",{count:r.uncoveredHunks.length})}),e[12]=m,e[13]=r.uncoveredHunks.length,e[14]=v):v=e[14];let j;return e[15]!==w||e[16]!==x||e[17]!==k||e[18]!==v?(j=s.jsxs("nav",{className:"flex shrink-0 flex-col overflow-y-auto border-r border-border/60 p-2",style:w,children:[x,k,v]}),e[15]=w,e[16]=x,e[17]=k,e[18]=v,e[19]=j):j=e[19],j});function hs(o){return s.jsx("span",{className:"truncate font-mono",children:o.path},o.path)}const ms=["all","staged","working"],gs="https://docs.openchamber.dev/walkthrough/",Te="typography-meta font-normal text-muted-foreground",rt=720,J=180,Ee=.5,fs=680,Ao=({directory:o})=>{const{t,locale:e,locales:r,label:l}=V(),a=p.useRef(null),[u,i]=p.useState(0);p.useEffect(()=>{const n=a.current;if(!n||typeof ResizeObserver>"u")return;const y=new ResizeObserver(E=>{i(E[0]?.contentRect.width??0)});return y.observe(n),()=>y.disconnect()},[]);const m=ue(n=>n.walkthroughTocWidth),d=ue(n=>n.setWalkthroughTocWidth),[h,g]=p.useState(!1),w=u===0||u>=rt,x=u>0&&u<fs,k=Math.min(Math.max(m,J),Math.max(J,(u||rt)*Ee)),v=p.useCallback(n=>{n.preventDefault();const y=n.clientX,E=k,z=Math.max(J,(a.current?.clientWidth??0)*Ee);g(!0);const le=Me=>{const Z=Math.min(z,Math.max(J,E+Me.clientX-y));d(Z)},q=()=>{g(!1),window.removeEventListener("pointermove",le),window.removeEventListener("pointerup",q),window.removeEventListener("pointercancel",q)};window.addEventListener("pointermove",le),window.addEventListener("pointerup",q),window.addEventListener("pointercancel",q)},[d,k]),j=p.useCallback(n=>{const y=n.shiftKey?40:10,E=n.key==="ArrowLeft"?-y:n.key==="ArrowRight"?y:0;if(E===0)return;n.preventDefault();const z=Math.max(J,(a.current?.clientWidth??0)*Ee);d(Math.min(z,Math.max(J,k+E)))},[d,k]),[f,b]=p.useState("all"),[T,I]=p.useState(null),[X,G]=p.useState(null),[Y,U]=p.useState(()=>new Set),ee=ue(n=>n.diffLayoutPreference),W=ue(n=>n.diffWrapLines),B=ee==="side-by-side",_=A(n=>n.requestedSource[o]),M=A(n=>n.clearRequestedSource),R=Pt(o||null),P=zt(o||null),$=Dt(n=>n.ensureAll),{github:Ae,git:Pe}=Ht();p.useEffect(()=>{o&&$(o,Pe)},[o,$,Pe]);const D=R?.current??null,oe=p.useMemo(()=>{const n=D;if(!n)return null;const y=P?.all??[],E=y.filter(K=>!K.startsWith("remotes/")),z=y.filter(K=>K.startsWith("remotes/")).map(K=>K.slice(8)),le=new Set(z.map(K=>K.split("/")[0]).filter(Boolean)),q=R?.tracking?.split("/")[0],Me=(q&&P?.defaultBranches?.[q])??P?.defaultBranches?.origin,Z=$t({remoteNames:le,localBranches:E,defaultBranch:Me,headBranch:n});return!Z||Z===n||!Ft({baseBranch:Z,localBranches:E,remoteBranches:z})?null:{kind:"branch",baseRef:Z,headRef:n}},[P,D,R?.tracking]),de=Je(n=>n.status?.connected??!1),pe=Je(n=>n.hasChecked),ze=ie(n=>n.ensureEntry),De=ie(n=>n.setParams),He=ie(n=>n.refreshTargets);p.useEffect(()=>{if(!o||!D||!pe||!de)return;const n=Lt(o,D);ze(n),De(n,{directory:o,branch:D,remoteName:null,canShow:!0,github:Ae,githubAuthChecked:pe,githubConnected:de}),He([{directory:o,branch:D,remoteName:null}])},[D,o,ze,Ae,pe,de,He,De]);const he=ie(n=>o&&D?Ot(n.entries,o,D)?.pr?.number??null:null),C=p.useMemo(()=>_??{kind:"working-tree",scope:f},[_,f]),te=p.useMemo(()=>C.kind==="pr"?C:he?{kind:"pr",number:he}:null,[he,C]),ht=p.useCallback(n=>{M(o),b(n)},[M,o]),c=A(n=>n.getEntry(o,C)),me=A(n=>n.load),Le=A(n=>n.generate),mt=A(n=>n.cancel),Oe=A(n=>n.requestSource),gt=A(n=>n.selectModel),ne=A(n=>n.getSelectedModel(o,C)),ft=A(n=>n.selectLanguage),ge=A(n=>n.getSelectedLanguage(o,C)),fe=c.result?.language,H=ge&&r.includes(ge)?ge:fe&&r.includes(fe)?fe:e;p.useEffect(()=>{me(o,C,{language:H})},[H,o,me,C,ne]);const S=p.useMemo(()=>Kt(c.result),[c.result]),xe=c.result?.generatedAt,We=p.useRef(void 0);p.useEffect(()=>{We.current!==xe&&(We.current=xe,U(new Set),I(S?.stops[0]?.stop.id??null))},[xe,S]);const ke=p.useCallback(n=>{I(n),U(y=>{if(y.has(n))return y;const E=new Set(y);return E.add(n),E})},[]),be=p.useCallback(n=>{ke(n),G(n)},[ke]),Be=p.useCallback(n=>{if(!S||S.stops.length===0)return;const y=S.stops.findIndex(z=>z.stop.id===T),E=Math.min(S.stops.length-1,Math.max(0,(y<0?0:y)+n));be(S.stops[E].stop.id)},[T,be,S]),[xt,$e]=p.useState(!1),[kt,Fe]=p.useState(!1),bt=C.kind==="working-tree"?C.scope:C.kind,wt=C.kind==="branch"?t("walkthrough.scope.branch"):C.kind==="pr"?t("walkthrough.scope.pullRequest",{number:C.number}):t(f==="all"?"walkthrough.scope.all":f==="staged"?"walkthrough.scope.staged":"walkthrough.scope.working"),Ge=ot(n=>n.modelsMetadata),[se,vt]=p.useState(void 0),we=n=>!n||se===void 0?!1:se.includes(n),jt=c.readiness?.model&&c.readiness.model.hasLogin!==!1&&we(c.readiness.model.providerID)?`${c.readiness.model.providerID}/${c.readiness.model.modelID}`:void 0,yt=c.result?.model&&we(c.result.model.providerID)?`${c.result.model.providerID}/${c.result.model.modelID}`:void 0,ae=(ne&&we(ne.split("/")[0])?ne:void 0)??yt??jt,[St,...Nt]=(ae??"").split("/"),Ue=Nt.join("/");p.useEffect(()=>{if(se!==void 0)return;let n=!1;return(async()=>{try{const y=await ct("/api/small-model",{method:"GET",headers:{Accept:"application/json"}});if(!y.ok)return;const E=await y.json().catch(()=>null);!n&&Array.isArray(E?.authenticatedProviders)&&vt(E.authenticatedProviders.filter(z=>typeof z=="string"))}catch{}})(),()=>{n=!0}},[se]);const Mt=p.useCallback((n,y)=>Ge.get(`${n}/${y}`)?.structured_output!==!1,[Ge]),_e=c.status==="generating",qe=c.result?.model?`${c.result.model.providerID}/${c.result.model.modelID}`:void 0,ve=c.result?.language,je=ve&&r.includes(ve)?ve:void 0,Ke=c.status==="ready"&&!!S,ye=Ke&&!!je&&je!==H,Ve=Ke&&!!qe&&!!ae&&qe!==ae,Xe=ss(c.stage,c.status==="generating"),Ye=p.useRef(!1),Ze=p.useRef(c.status);p.useEffect(()=>{Ze.current!=="generating"&&c.status==="generating"&&(Ye.current=!S),Ze.current=c.status},[c.status,S]);const Ct=Ye.current&&(c.status==="generating"||Xe.holding),Se=c.error?.code==="context-too-small"||c.error?.code==="structured-output-unsupported"||c.error?.code==="no-model"||c.error?.code==="empty-diff"||c.error?.code==="only-generated"||c.error?.code==="output-exhausted"||c.error?.code==="server-unsupported"?c.error.code:c.readiness&&!c.readiness.ready&&!S&&c.readiness.reason!=="no-provider-login"?c.readiness.reason:void 0,It=c.error?.model??c.readiness?.model,Rt=c.error?.requiredChars??c.readiness?.requiredChars,Tt=c.error?.availableChars??c.readiness?.availableChars,re=!ae||!!(c.readiness&&!c.readiness.ready),Ne=p.useCallback(n=>{re||Le(o,C,{force:n,language:H})},[H,o,Le,re,C]);return s.jsxs("div",{ref:a,className:"flex h-full min-h-0 flex-col",children:[s.jsxs("header",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b border-border/60 px-3 py-2",children:[s.jsxs(Qe,{open:xt,onOpenChange:$e,children:[s.jsx(et,{asChild:!0,children:s.jsxs("button",{type:"button",className:"flex h-8 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":t("walkthrough.scope.selectorAria"),children:[s.jsx("span",{className:"whitespace-nowrap",children:wt}),s.jsx(N,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"})]})}),s.jsx(tt,{align:"start",className:"w-48",children:s.jsxs(st,{value:bt,onValueChange:n=>{if($e(!1),n==="branch"){oe&&Oe(o,oe);return}if(n==="pr"){te&&Oe(o,te);return}ht(n)},children:[s.jsx(Ce,{className:Te,children:t("walkthrough.scope.group.workingTree")}),ms.map(n=>s.jsx(ce,{value:n,children:t(n==="all"?"walkthrough.scope.all":n==="staged"?"walkthrough.scope.staged":"walkthrough.scope.working")},n)),(oe||te)&&s.jsxs(s.Fragment,{children:[s.jsx(Wt,{}),s.jsx(Ce,{className:Te,children:t("walkthrough.scope.group.committed")})]}),oe&&s.jsx(ce,{value:"branch",children:t("walkthrough.scope.branch")}),te&&s.jsx(ce,{value:"pr",children:t("walkthrough.scope.pullRequest",{number:te.number})})]})})]}),s.jsxs("div",{className:"ml-auto flex min-w-0 items-center gap-1",children:[s.jsxs(at,{children:[s.jsx(lt,{asChild:!0,children:s.jsx(L,{type:"button",variant:"ghost",size:"sm","aria-label":t("walkthrough.help.guide"),onClick:()=>{Bt(gs)},children:s.jsx(N,{name:"question",className:"size-4"})})}),s.jsx(it,{children:s.jsx("p",{className:"typography-micro leading-tight",children:t("walkthrough.help.guide")})})]}),s.jsxs(Qe,{open:kt,onOpenChange:Fe,children:[s.jsx(et,{asChild:!0,children:s.jsxs("button",{type:"button",className:"flex h-8 min-w-0 flex-shrink items-center gap-1.5 rounded-md px-2 typography-ui-label text-muted-foreground outline-none hover:bg-interactive-hover hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring","aria-label":t("walkthrough.language.selectorAria"),title:x?l(H):void 0,children:[s.jsx(N,{name:"global",className:"size-4 flex-shrink-0 opacity-70"}),!x&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"truncate",children:l(H)}),s.jsx(N,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"})]})]})}),s.jsxs(tt,{align:"end",className:"w-48",children:[s.jsx(Ce,{className:Te,children:t("walkthrough.language.menuLabel")}),s.jsx(st,{value:H,onValueChange:n=>{Fe(!1),ft(o,C,n)},children:r.map(n=>s.jsx(ce,{value:n,children:l(n)},n))})]})]}),s.jsx(nt,{providerId:St??"",modelId:Ue,onChange:(n,y)=>{gt(o,C,n&&y?`${n}/${y}`:null)},allowedProviderIds:se??[],isModelAllowed:Mt,tooltipsEnabled:!1,dropdownPortalToBody:!0,compact:x,className:F("h-8 min-w-0",!x&&"max-w-48")}),S&&s.jsxs(s.Fragment,{children:[s.jsx(L,{type:"button",variant:"ghost",size:"sm","aria-label":t("walkthrough.action.previous"),onClick:()=>Be(-1),children:s.jsx(N,{name:"arrow-right-s",className:"size-4 rotate-180"})}),s.jsx(L,{type:"button",variant:"ghost",size:"sm","aria-label":t("walkthrough.action.next"),onClick:()=>Be(1),children:s.jsx(N,{name:"arrow-right-s",className:"size-4"})})]}),_e?s.jsx(L,{type:"button",variant:"outline",size:"sm","aria-label":x?t("walkthrough.action.cancel"):void 0,title:x?t("walkthrough.action.cancel"):void 0,onClick:()=>mt(o,C),children:x?s.jsx(N,{name:"stop",className:"size-3.5"}):t("walkthrough.action.cancel")}):s.jsxs(L,{type:"button",variant:"outline",size:"sm",className:re?"border-border text-muted-foreground":Gt,disabled:re,"aria-label":x?t(S?"walkthrough.action.regenerate":"walkthrough.action.generate"):void 0,title:x?t(S?"walkthrough.action.regenerate":"walkthrough.action.generate"):void 0,onClick:()=>Ne(!!S),children:[s.jsx(N,{name:S?"refresh":"route",className:"size-3.5"}),!x&&t(S?"walkthrough.action.regenerate":"walkthrough.action.generate")]})]})]}),c.status==="generating"&&S&&s.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border/60 bg-[var(--status-info-background)] px-3 py-2",children:[s.jsx(N,{name:"loader-4",className:"size-4 shrink-0 animate-spin text-[var(--status-info)]"}),s.jsx("span",{className:"typography-meta text-foreground",children:c.stage==="collecting"?t("walkthrough.stage.collecting"):c.stage==="assembling"?t("walkthrough.stage.assembling"):t("walkthrough.stage.asking")})]}),(ye||Ve)&&s.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border/60 bg-[var(--status-info-background)] px-3 py-2",children:[s.jsx(N,{name:"information",className:"size-4 shrink-0 text-[var(--status-info)]"}),s.jsx("span",{className:"typography-meta text-foreground",children:ye&&Ve?t("walkthrough.missing.languageAndModel"):ye?t("walkthrough.missing.language",{requested:l(H),shown:l(je)}):t("walkthrough.missing.model",{model:Ue})}),s.jsx(L,{type:"button",variant:"ghost",size:"xs",className:"ml-auto",disabled:re,onClick:()=>Ne(!1),children:t("walkthrough.action.generate")})]}),S?.isStale&&c.status!=="generating"&&s.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border/60 bg-status-warning/10 px-3 py-2",children:[s.jsx(N,{name:"error-warning",className:"size-4 shrink-0 text-status-warning"}),s.jsx("span",{className:"typography-meta text-foreground",children:t("walkthrough.stale.banner",{count:S.staleStopCount})}),s.jsx(L,{type:"button",variant:"ghost",size:"xs",className:"ml-auto",disabled:_e,onClick:()=>Ne(!0),children:t("walkthrough.action.regenerate")})]}),c.error&&!Se&&c.error.code!=="no-provider-login"&&s.jsxs("div",{className:"flex shrink-0 items-start gap-2 border-b border-border/60 bg-status-error/10 px-3 py-2",children:[s.jsx(N,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-status-error"}),s.jsx("span",{className:"typography-meta line-clamp-2 text-foreground",title:c.error.message,children:c.error.message})]}),s.jsx("div",{className:F("flex min-h-0 flex-1",w?"flex-row":"flex-col"),children:Se?s.jsx(Zt,{reason:Se,model:It,requiredChars:Rt,availableChars:Tt,onRetry:()=>{me(o,C)}}):Ct?s.jsx("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-8",children:s.jsx(Qt,{progress:Xe})}):S?s.jsxs(s.Fragment,{children:[w&&s.jsxs(s.Fragment,{children:[s.jsx(ps,{view:S,activeStopId:T,visitedStopIds:Y,onSelectStop:be,width:k}),s.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":t("walkthrough.toc.resize"),tabIndex:0,onPointerDown:v,onKeyDown:j,className:F("group relative w-1 shrink-0 cursor-col-resize","before:absolute before:inset-y-0 before:-left-1 before:-right-1 before:content-['']","hover:bg-interactive-selection focus-visible:bg-interactive-selection focus-visible:outline-none",h&&"bg-interactive-selection")})]}),s.jsx(as,{view:S,activeStopId:T,scrollToStopId:X,onActiveStopChange:ke,onScrollHandled:()=>G(null),renderSideBySide:B,wrapLines:W})]}):s.jsx("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center",children:c.status==="loading"?s.jsx(N,{name:"loader-4",className:"size-6 animate-spin text-muted-foreground"}):s.jsxs(s.Fragment,{children:[s.jsx(N,{name:"route",className:"size-6 text-muted-foreground"}),s.jsx("h3",{className:"typography-ui-label font-semibold text-foreground",children:t("walkthrough.empty.title")}),s.jsx("p",{className:"typography-meta max-w-md text-muted-foreground",children:t("walkthrough.empty.description")})]})})})]})};export{Ao as WalkthroughView};
|