@cmmd-center/forge 0.9.16 → 0.9.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`forge-web@0.9.10`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`24a85626-b86e-448f-8991-714315ce653a`,e._sentryDebugIdIdentifier=`sentry-dbid-24a85626-b86e-448f-8991-714315ce653a`)}catch{}})();import{r as e}from"./rolldown-runtime-BaTzPAyU.js";import{Ba as t,Va as n,za as r}from"./Stream-D8tJNlvy.js";import{Ht as i,Ut as a}from"./useTriggerFocusGuards-DfUh9uvu.js";import{E as o,Mr as s,Or as c,P as l,Tr as u,_r as d,b as f,c as p,f as m,hr as h,l as g,n as _,p as v,pr as y,s as b,t as x,tr as S,u as C,v as w}from"./DiffWorkerPoolProvider-tFSGuVfC.js";import{$t as T,As as E,Bs as D,Jt as O,Qt as k,Xt as A,Yt as j,Zt as M,_ as N,d as P,dn as F,en as I,es as L,hn as R,i as ee,m as z,mn as B,n as V,nn as H,on as U,rn as W,sn as G,u as te,un as K,ys as ne,z as re}from"./DiffPanelShell-tIdXu7mn.js";import{Mn as ie}from"./CompositeItem-Cn5DdObI.js";import{f as ae,h as oe,l as se,m as q,n as ce,o as J,p as le,t as ue,u as de}from"./DiffPanel.logic-BIPcNz_o.js";function fe(e,t){return E(e,s,t)}function pe(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function me(e,t){return e==null||t==null?e===t:e.header!==t.header||e.footer!==t.footer?!1:he(e.items,t.items)}function he(e,t){if(e==null||t==null)return e===t;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r==null||i==null||r.id!==i.id||r.type!==i.type||r.element!==i.element||r.instance!==i.instance||r.version!==i.version)return!1}return!0}function ge(e,t,n){let r=document.createElement(`div`);return r.style.display=`flow-root`,e===`header`?(r.setAttribute(W,``),t.before(r)):(r.setAttribute(H,``),t.after(r)),n?.observe(r),r}function Y(e){let t=window.devicePixelRatio??1;return Math.round(e*t)/t}var _e=`theme.disableLineNumbers.overflow.themeType.disableFileHeader.disableVirtualizationBuffers.preferredHighlighter.useCSSClasses.useTokenTransformer.tokenizeMaxLineLength.tokenizeMaxLength.unsafeCSS.diffStyle.diffIndicators.disableBackground.expandUnchanged.loadDiffFiles.collapsedContextThreshold.lineDiffType.maxLineDiffLength.expansionLineCount.lineHoverHighlight.enableTokenInteractionsOnWhitespace.enableGutterUtility.__debugPointerEvents.enableLineSelection.controlledSelection.disableErrorHandling`.split(`.`),ve=[`theme`,`disableLineNumbers`,`overflow`,`themeType`,`disableFileHeader`,`disableVirtualizationBuffers`,`preferredHighlighter`,`useCSSClasses`,`useTokenTransformer`,`tokenizeMaxLineLength`,`tokenizeMaxLength`,`unsafeCSS`,`lineHoverHighlight`,`enableTokenInteractionsOnWhitespace`,`enableGutterUtility`,`__debugPointerEvents`,`enableLineSelection`,`controlledSelection`,`disableErrorHandling`],ye=[`renderCustomHeader`,`renderHeaderPrefix`,`renderHeaderFilenameSuffix`,`renderHeaderMetadata`,`renderAnnotation`,`renderGutterUtility`,`onPostRender`,`onGutterUtilityClick`,`onLineClick`,`onLineNumberClick`,`onLineEnter`,`onLineLeave`,`onTokenClick`,`onTokenEnter`,`onTokenLeave`],be=[`onLineSelected`,`onLineSelectionStart`,`onLineSelectionChange`,`onLineSelectionEnd`],xe=Symbol(`CodeView.itemOptionsState`);function Se(e,t){Object.defineProperty(e,xe,{configurable:!1,enumerable:!1,value:t})}function Ce(e){return e[xe]}function X(e,t,n){Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get(){return n(this)}})}var we=120,Te=1,Ee=`--diffs-overflow-override`,De=12e6,Oe=1e6,ke=2e6,Ae=1e7,je=11e6;function Me(e){if(e==null)throw Error(`CodeView: createEditor is required for items with edit: true`)}var Ne=(()=>{let{navigator:e}=globalThis,t=e.userAgent,n=/iP(?:hone|ad|od)/.test(t),r=e.platform===`MacIntel`&&e.maxTouchPoints>1;return(n||r)&&/AppleWebKit/.test(t)&&/Safari/.test(t)&&!/(CriOS|FxiOS|EdgiOS|OPiOS)/.test(t)})(),Pe=class e{static __STOP=!1;static __lastScrollPosition=0;type=`advanced`;config={overscrollSize:200,intersectionObserverMargin:0,resizeDebugging:!1};items=[];idToItem=new Map;selectedLines=null;itemEditors=new Map;attachedEditors=new Set;instanceToItem=new Map;layoutDirtyIndex;pendingLayoutReset;renderOptionsRevision=0;slotCoordinator;slotSnapshot;scrollListeners=new Set;scrollHeight=0;containerHeight=-1;scrollTop=0;scrollPageOffset=0;scrollDirty=!0;scrollInteractionFixTimer;pointerEventsDisabled=!1;codeOverflowFix=!1;height=0;heightDirty=!0;windowSpecs={top:0,bottom:0};renderState={scrollTop:-1,firstIndex:-1,lastIndex:-1,stickyHeight:0,stickyTop:-1,stickyBottom:-1};itemMetricsCache=U;fileOptionsPrototype;diffOptionsPrototype;pendingScrollTarget;pendingLayoutAnchor;shouldFixContainerFocus=!1;scrollAnimation;root;resizeObserver;container=document.createElement(`div`);stickyContainer=document.createElement(`div`);stickyOffset=document.createElement(`div`);header={element:void 0,render:void 0,height:0};footer={element:void 0,render:void 0,height:0};elementPool=[];elementPoolVersion=0;elementPoolTracker=new WeakMap;pendingElementPool=[];options;workerManager;isReadySubscription;isContainerManaged;constructor(e={theme:F},t,n=!1){this.options=e,this.computeMetricsCache(e.itemMetrics),this.fileOptionsPrototype=this.createFileOptionsPrototype(),this.diffOptionsPrototype=this.createDiffOptionsPrototype(),this.workerManager=t,this.isContainerManaged=n,this.stickyOffset.style.contain=`layout size`,this.stickyContainer.style.position=`sticky`,this.stickyContainer.style.width=`100%`,this.stickyContainer.style.contain=`layout style inline-size`,this.stickyContainer.style.isolation=`isolate`,this.stickyContainer.style.display=`flex`,this.stickyContainer.style.flexDirection=`column`}getLayout(){return this.options.layout??G}getItemTopOffset(){return this.getLayout().paddingTop+this.header.height}computeMetricsCache(e){return this.itemMetricsCache={hunkLineCount:e?.hunkLineCount??U.hunkLineCount,lineHeight:e?.lineHeight??U.lineHeight,diffHeaderHeight:e?.diffHeaderHeight??U.diffHeaderHeight,hunkSeparatorHeight:e?.hunkSeparatorHeight,spacing:e?.spacing??U.spacing,paddingTop:e?.paddingTop,paddingBottom:e?.paddingBottom},this.itemMetricsCache}getSmoothScrollSettings(){return this.options.smoothScrollSettings??K}shouldDisablePointerEvents(){return this.options.pointerEventsOnScroll!==!0}shouldValidateItemHeights(){return B&&this.options.__devOnlyValidateItemHeights===!0}validateRenderedItemHeight(e){if(!this.shouldValidateItemHeights()||e.element==null)return;let t=e.instance.getAdvancedStickySpecs();if(t==null)return;let n=t.height,r=e.element.getBoundingClientRect().height;n!==r&&console.error(`CodeView: reconciled item height does not match DOM height`,{id:e.item.id,type:e.type,index:e.index,version:e.version,expectedHeight:n,actualHeight:r,delta:r-n,stickyTopOffset:t.topOffset,virtualizedHeight:e.instance.getVirtualizedHeight(),top:e.top,scrollTop:this.getScrollTop(),windowSpecs:{...this.windowSpecs},element:e.element,instance:e.instance})}validateStickyContainerHeight(){if(!this.shouldValidateItemHeights())return;let{firstIndex:e,lastIndex:t,stickyHeight:n,stickyTop:r,stickyBottom:i}=this.renderState;if(e===-1||t===-1)return;let a=this.stickyContainer.getBoundingClientRect().height;Math.abs(a-n)<Te||console.error(`CodeView: sticky container height does not match computed layout`,{computedStickyHeight:n,actualStickyHeight:a,delta:a-n,stickyTop:r,stickyBottom:i,firstIndex:e,lastIndex:t,firstStickySpecs:this.items[e]?.instance.getAdvancedStickySpecs(),lastStickySpecs:this.items[t]?.instance.getAdvancedStickySpecs(),scrollTop:this.getScrollTop(),scrollPageOffset:this.scrollPageOffset,windowSpecs:{...this.windowSpecs},stickyContainer:this.stickyContainer})}clearScrollInteractionTimer(){this.scrollInteractionFixTimer!=null&&(clearTimeout(this.scrollInteractionFixTimer),this.scrollInteractionFixTimer=void 0)}suspendScrollInteractions(){this.clearScrollInteractionTimer(),this.shouldDisablePointerEvents()&&!this.pointerEventsDisabled&&(this.stickyContainer.style.pointerEvents=`none`,this.pointerEventsDisabled=!0),Ne&&!this.codeOverflowFix&&(this.stickyContainer.style.setProperty(Ee,`hidden`),this.codeOverflowFix=!0),this.scrollInteractionFixTimer=setTimeout(this.restoreScrollInteractions,we)}restoreScrollInteractions=()=>{this.clearScrollInteractionTimer(),this.pointerEventsDisabled&&=(this.stickyContainer.style.removeProperty(`pointer-events`),!1),this.codeOverflowFix&&=(this.stickyContainer.style.setProperty(Ee,`auto`),!1)};syncLayout(){let{gap:e,paddingBottom:t,paddingTop:n}=this.getLayout();this.stickyContainer.style.gap=`${e}px`,this.container?.style.setProperty(`margin-top`,`${n}px`),this.container?.style.setProperty(`margin-bottom`,`${t}px`)}reconcileHeaderFooterHosts(){let e=this.reconcileHost(`header`),t=this.reconcileHost(`footer`);return e||t}reconcileHost(e){let{root:t,container:n}=this;if(t==null||n==null)return!1;let r=e===`header`?this.header:this.footer,i=e===`header`?this.options.renderCodeViewHeader:this.options.renderCodeViewFooter;if(i==null)return r.element!=null&&(this.resizeObserver?.unobserve(r.element),r.element.remove(),r.element=void 0,r.render=void 0,this.setHostHeight(r,0),!1);if(r.element!=null&&i===r.render)return!1;let a=r.element??ge(e,n,this.resizeObserver);r.element=a;let o=i();return o==null?!this.isContainerManaged&&a.children.length>0&&(a.textContent=``):a.replaceChildren(o),r.render=i,!0}setHostHeight(e,t){e.height!==t&&(e.height=t,this.scrollDirty=!0)}measureMountedHosts(){this.header.element!=null&&this.setHostHeight(this.header,this.header.element.getBoundingClientRect().height),this.footer.element!=null&&this.setHostHeight(this.footer,this.footer.element.getBoundingClientRect().height)}setup(t){if(this.root!=null)throw Error(`CodeView.setup: already setup`);this.workerManager?.subscribeToThemeChanges(this),this.root=t,this.root.style.overflowAnchor=`none`,this.root.hasAttribute(`tabindex`)||(this.root.tabIndex=-1),this.container??=document.createElement(`div`),this.container.style.contain=`layout style`,this.syncLayout(),this.container.appendChild(this.stickyOffset),this.container.appendChild(this.stickyContainer),this.root.appendChild(this.container),this.scrollDirty=!0,this.heightDirty=!0,this.resizeObserver=new ResizeObserver(this.handleResize),this.resizeObserver.observe(this.stickyContainer),this.root.addEventListener(`scroll`,this.handleScroll,{passive:!0}),this.root.addEventListener(`wheel`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`touchstart`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`pointerdown`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`keydown`,this.clearPendingScroll,{passive:!0}),this.resizeObserver.observe(this.root),this.render(!0),window.__INSTANCE=this,window.__TOGGLE=()=>{e.__STOP?(e.__STOP=!1,this.scrollTo({type:`position`,position:e.__lastScrollPosition,behavior:`instant`})):(e.__lastScrollPosition=this.getScrollTop(),e.__STOP=!0)}}reset(){T(this.computeRenderRangeAndEmit),this.clearReadySubscription(),this.restoreScrollInteractions(),this.cleanAllRenderedItems();for(let e of this.itemEditors.values())e.editor.cleanUp();this.itemEditors.clear(),this.attachedEditors.clear(),this.selectedLines=null,this.items.length=0,this.idToItem.clear(),this.instanceToItem.clear(),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,this.stickyContainer.textContent=``,this.stickyOffset.style.height=``,this.container?.style.removeProperty(`height`),this.containerHeight=-1,this.windowSpecs={top:0,bottom:0},this.pendingLayoutAnchor=void 0,this.shouldFixContainerFocus=!1,this.height=0,this.scrollTop=0,this.scrollPageOffset=0,this.scrollHeight=0,this.scrollDirty=!0,this.heightDirty=!0,this.resetRenderState(),this.isContainerManaged||this.flushSlotCoordinator()}cleanUp(){this.reset(),this.clearElementPool(),this.restoreScrollInteractions(),this.workerManager?.unsubscribeToThemeChanges(this),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.root?.removeEventListener(`scroll`,this.handleScroll),this.root?.removeEventListener(`wheel`,this.clearPendingScroll),this.root?.removeEventListener(`touchstart`,this.clearPendingScroll),this.root?.removeEventListener(`pointerdown`,this.clearPendingScroll),this.root?.removeEventListener(`keydown`,this.clearPendingScroll),this.root?.style.removeProperty(`overflow-anchor`),this.container?.remove(),this.stickyOffset.remove(),this.stickyContainer.remove(),this.stickyContainer.textContent=``,this.header.element?.remove(),this.header.element=void 0,this.header.render=void 0,this.header.height=0,this.footer.element?.remove(),this.footer.element=void 0,this.footer.render=void 0,this.footer.height=0,this.root=void 0,this.container=void 0}cleanAllRenderedItems(){if(this.renderState.firstIndex!==-1)for(let e=this.renderState.firstIndex;e<=this.renderState.lastIndex;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.cleanAllRenderedItems: Item does not exist at index: ${e}`);this.releaseRenderedItem(t)}}primeScrollTarget(e){e.type!==`position`&&this.idToItem.get(e.id)?.instance.primeHighlightCache()}getElementPoolLimit(){let e=this.getHeight()+this.config.overscrollSize*2,{diffHeaderHeight:t}=this.itemMetricsCache;return Math.max(8,Math.ceil(e/Math.max(t,10))+1)*(this.isContainerManaged?2:1)}acquireElement(){this.promotePendingPooledElements();let e=this.elementPool.pop();for(;e!=null&&!this.isElementPoolGenerationCurrent(e);)e=this.elementPool.pop();return e??=document.createElement(R),this.markElementPoolGenerationCurrent(e),e}releaseRenderedItem(e){let{element:t}=e;t!=null&&this.renderedItemOwnsFocus(t)&&(this.shouldFixContainerFocus=!0),e.instance.cleanUp(!0),this.attachedEditors.delete(e.item.id),e.element=void 0,t!=null&&(t.remove(),this.cleanElement(t),this.queueElementForPool(t))}renderedItemOwnsFocus(e){let{activeElement:t}=document;return t===e||e.contains(t)||e.shadowRoot?.activeElement!=null}fixContainerFocus(){this.shouldFixContainerFocus&&(this.shouldFixContainerFocus=!1,this.root?.focus({preventScroll:!0}))}cleanElement(e){let{shadowRoot:t}=e;if(t!=null)for(let e of Array.from(t.children))ze(e)||e.remove();this.isContainerManaged||e.replaceChildren()}queueElementForPool(e){let t=this.getElementPoolLimit();!this.isElementPoolGenerationCurrent(e)||this.getElementPoolSize()>=t||(this.isElementClean(e)?this.elementPool.push(e):this.pendingElementPool.push(e))}promotePendingPooledElements(){if(this.pendingElementPool.length===0)return;let{pendingElementPool:e}=this;this.pendingElementPool=[];let t=this.getElementPoolLimit();for(let n of e)this.isElementPoolGenerationCurrent(n)&&this.isElementClean(n)&&this.elementPool.length<t?this.elementPool.push(n):this.isElementPoolGenerationCurrent(n)&&this.getElementPoolSize()<t&&this.pendingElementPool.push(n)}isElementClean(e){return e.childNodes.length===0}getElementPoolSize(){return this.elementPool.length+this.pendingElementPool.length}clearElementPool(){this.elementPool.length=0,this.pendingElementPool.length=0}invalidateElementPool(){this.elementPoolVersion++,this.clearElementPool()}markElementPoolGenerationCurrent(e){this.elementPoolTracker.set(e,this.elementPoolVersion)}isElementPoolGenerationCurrent(e){return this.elementPoolTracker.get(e)===this.elementPoolVersion}resolveEffectiveScrollBehavior(e,t){return pe()?`instant`:e.behavior===`smooth-auto`?Math.abs(t-this.getScrollTop())<=this.getHeight()*10?`smooth`:`instant`:e.behavior??`instant`}scrollTo(e){if(this.root==null)return;let t=this.normalizeScrollTarget(e);if(t==null)return;let n=this.resolveScrollTargetTop(t);n!=null&&(this.primeScrollTarget(t),this.resolveEffectiveScrollBehavior(t,n)===`smooth`?this.scrollAnimation??={position:this.getScrollTop(),velocity:0,lastTimestamp:performance.now()}:this.scrollAnimation=void 0,this.suspendScrollInteractions(),this.pendingLayoutAnchor=void 0,this.pendingScrollTarget=t,this.render())}setSelectedLines(e,t){this.applySelectedLines(e,t)}getSelectedLines(){return this.selectedLines}clearSelectedLines(e){this.applySelectedLines(null,e)}getItem(e){return this.idToItem.get(e)?.item}getEditor(e){return this.itemEditors.get(e)?.editor}updateItem(e){let t=this.idToItem.get(e.id);return t==null?(console.error(`CodeView.updateItem: unknown item id "${e.id}"`),!1):this.syncItemRecord(t,e)?(this.markItemLayoutDirty(t),this.scrollDirty=!0,this.render(),this.syncItemEditors(),this.syncSelection(),!0):!1}updateItemId(e,t){if(e===t)return!0;let n=this.idToItem.get(e);if(n==null)return console.error(`CodeView.updateItemId: unknown item id "${e}"`),!1;if(this.idToItem.has(t))return console.error(`CodeView.updateItemId: duplicate item id "${t}"`),!1;this.idToItem.delete(e),n.item.id=t,this.idToItem.set(t,n),this.updateItemOptionsId(n.instance.options,t),this.selectedLines?.id===e&&(this.selectedLines={...this.selectedLines,id:t},this.options.onSelectedLinesChange?.(this.selectedLines));let r=this.itemEditors.get(e);return r!=null&&(r.state.id=t,this.itemEditors.delete(e),this.itemEditors.set(t,r),this.attachedEditors.delete(e)&&this.attachedEditors.add(t)),this.renamePendingScrollTarget(e,t),this.renamePendingLayoutAnchor(e,t),this.render(),!0}addItem(e){this.addItems([e])}addItems(e){this.appendItemsInternal(e),this.syncItemEditors(),this.syncSelection()}removeItem(e){let t=this.idToItem.get(e);if(t==null)return console.error(`CodeView.removeItem: unknown item id "${e}"`),!1;let n=[];for(let e of this.items)e!==t&&n.push(e.item);return this.setItems(n),!0}setItems(e){let t;this.items.length===0?this.appendItemsInternal(e):this.tryAppendItems(e)||(t=this.reconcileItems(e)),this.syncItemEditors(t),this.syncSelection()}appendItemsInternal(e,t=!0){if(e.length===0)return;let n=this.getLayout(),r=this.items.length===0?0:this.scrollHeight+n.gap,i=r;for(let t=0;t<e.length;t++){let i=e[t];if(i==null)throw Error(`CodeView.appendItemsInternal: missing input item`);if(this.idToItem.has(i.id))throw Error(`CodeView.addItem: duplicate id "${i.id}"`);let a=this.createItem(i,this.items.length,r);this.items.push(a),this.idToItem.set(a.item.id,a),this.instanceToItem.set(a.instance,a),a.height=Fe(a),r+=a.height+n.gap}this.scrollHeight=r-n.gap,this.scrollDirty=!0,t&&(this.canSkipRenderForAppend(i)?this.syncContainerHeight():this.render())}canSkipRenderForAppend(e){return this.container!=null&&this.renderState.firstIndex!==-1&&this.pendingScrollTarget==null&&this.scrollAnimation==null&&this.layoutDirtyIndex==null&&e>this.windowSpecs.bottom}onThemeChange(){this.invalidateElementPool()}setOptions(e){if(e==null)return;this.capturePendingLayoutAnchor();let{options:t}=this,n=this.getLayout(),{itemMetricsCache:r}=this;Ie(t,e)&&this.invalidateElementPool(),this.options=e;let i=this.computeMetricsCache(e.itemMetrics),a=!k(r,i),o=!k(n,this.getLayout());o&&this.syncLayout();let s=a||Le(t,e);if(s){let n=this.pendingLayoutReset;this.pendingLayoutReset={metrics:a?i:n?.metrics,resetFileLayoutCache:!0,resetDiffLayoutCache:!0,includeEstimatedDiffHeights:n?.includeEstimatedDiffHeights===!0||a||Re(t,e)}}(o||s)&&(this.markLayoutDirtyFromIndex(0),this.scrollDirty=!0),A(t,e)||this.renderOptionsRevision++,this.syncItemEditors();let c=t.renderCodeViewHeader!==e.renderCodeViewHeader||t.renderCodeViewFooter!==e.renderCodeViewFooter;!this.isContainerManaged&&(this.items.length>0||c)&&this.render()}capturePendingLayoutAnchor(e=this.idToItem){this.root!=null&&this.items.length!==0&&this.pendingScrollTarget==null&&(this.pendingLayoutAnchor=this.getScrollAnchor(this.getScrollTop(),e))}render(t=!1){e.__STOP||(t?(T(this.computeRenderRangeAndEmit),this.computeRenderRangeAndEmit()):I(this.computeRenderRangeAndEmit))}isReady(){let{workerManager:e}=this;return e==null||e.isInitialized()||e.getStats().workersFailed?(this.clearReadySubscription(),!0):(this.isReadySubscription??=e.subscribeToStatChanges(e=>{e.managerState!==`initialized`&&!e.workersFailed||(this.clearReadySubscription(),this.render(!0))}),e.getStats().managerState===`waiting`&&e.initialize().catch(()=>{}),!1)}clearReadySubscription(){this.isReadySubscription!=null&&(this.isReadySubscription(),this.isReadySubscription=void 0)}instanceChanged(e,t){let n=this.instanceToItem.get(e);if(n==null)throw Error(`CodeView.instanceChanged: An instance has changed that is not registered`);t&&this.markItemLayoutDirty(n),this.render()}getWindowSpecs(){return this.windowSpecs}getContainerElement(){return this.root}getHeaderElement(){return this.header.element}getFooterElement(){return this.footer.element}getRenderedItems(){let{firstIndex:e,lastIndex:t}=this.renderState;if(e===-1||t===-1||t<e)return[];let n=[];for(let r=e;r<=t;r++){let e=this.items[r];e?.element!=null&&(e.type===`diff`?n.push({id:e.item.id,type:`diff`,item:e.item,version:e.version,element:e.element,instance:e.instance}):n.push({id:e.item.id,type:`file`,item:e.item,version:e.version,element:e.element,instance:e.instance}))}return n}setSlotCoordinator(e){return e!==this.slotCoordinator&&(this.slotCoordinator=e,this.slotSnapshot=void 0,!0)}getSlotSnapshot(e){return this.buildSlotSnapshot(e)}buildSlotSnapshot(e){let t=Ge(this.getRenderedItems(),e),{element:n}=this.header,{element:r}=this.footer;if(t!=null||n!=null||r!=null)return{items:t,header:n,footer:r}}subscribeToScroll(e){return this.scrollListeners.add(e),()=>{this.scrollListeners.delete(e)}}getLocalTopForInstance(e){let t=this.instanceToItem.get(e);if(t==null)throw Error(`CodeView.getLocalTopForInstance: unknown virtualized instance`);return t.top}getTopForItem(e){let t=this.idToItem.get(e);if(t!=null)return t.top+this.getItemTopOffset()}createItem(e,t,n){let{itemMetricsCache:r}=this;if(e.type===`diff`){let i=new de(this.createDiffOptions(e.id),this,r,this.workerManager,this.isContainerManaged);return{type:`diff`,item:e,version:e.version,index:t,top:n,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:i}}let i=new l(this.createFileOptions(e.id),this,r,this.workerManager,this.isContainerManaged);return{type:`file`,item:e,version:e.version,index:t,top:n,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:i}}applySelectedLines(e,t){let{selectedLines:n}=this;e==null&&n==null||e!=null&&n?.id===e.id&&j(n.range,e.range)||(n!=null&&n.id!==e?.id&&this.idToItem.get(n.id)?.instance.setSelectedLines(null,{notify:!1}),this.selectedLines=e,this.idToItem.get(e?.id??``)?.instance.setSelectedLines(e?.range??null,t))}syncSelection(){if(this.selectedLines==null)return;let e=this.idToItem.get(this.selectedLines.id);if(e==null){this.selectedLines=null,this.options.onSelectedLinesChange?.(null);return}e.instance.setSelectedLines(this.selectedLines.range,{notify:!1})}isItemInEditMode(e){return e.item.edit===!0&&e.item.collapsed!==!0}attachItemEditor(e){let{id:t}=e.item,{createEditor:n}=this.options;if(e.element==null||this.attachedEditors.has(t)||!this.isItemInEditMode(e))return;let r=this.itemEditors.get(t),i=!1;try{if(r==null){Me(n);let e={id:t},a=n({onChange:(t,n)=>{let r=this.idToItem.get(e.id);r!=null&&(e.lastChange={item:r.item,file:t,lineAnnotations:n},this.options.onItemEditChange?.(r.item,t,n))}});if(a==null)return;r={editor:a,state:e},this.itemEditors.set(t,r),i=!0}r.editor.edit(e.instance),this.attachedEditors.add(t)}catch(n){throw i&&r!=null&&(this.itemEditors.delete(t),r.editor.cleanUp()),this.releaseRenderedItem(e),n}}syncItemEditors(e){if(this.itemEditors.size===0)return;let t=[];for(let[n,r]of this.itemEditors){let i=this.idToItem.get(n),a=e?.get(n);if(a==null&&i!=null&&this.isItemInEditMode(i))continue;r.editor.cleanUp(),this.itemEditors.delete(n),this.attachedEditors.delete(n);let{lastChange:o}=r.state,s=a==null?i?.item??o?.item:o?.item??a.item;s?.type===`diff`&&(a==null&&i!=null&&i.type===`diff`&&i.instance.completeEditSession()&&(this.markItemLayoutDirty(i),this.render()),ae(s.fileDiff)),o!=null&&t.push(a!=null||i==null?o:{...o,item:i.item})}for(let{item:e,file:n,lineAnnotations:r}of t)this.options.onItemEditComplete?.(e,n,r)}renamePendingScrollTarget(e,t){let{pendingScrollTarget:n}=this;n!=null&&n.type!==`position`&&n.id===e&&(this.pendingScrollTarget={...n,id:t})}renamePendingLayoutAnchor(e,t){this.pendingLayoutAnchor?.id===e&&(this.pendingLayoutAnchor.id=t)}createFileOptionsPrototype(){let e={};for(let t of ve)X(e,t,()=>this.options[t]);X(e,`stickyHeader`,()=>this.options.stickyHeaders),X(e,`collapsed`,e=>{let t=Ce(e);if(t!=null)return this.getItemOptions(t,`file`)?.item.collapsed});for(let t of ye)this.defineItemSharedCallback(e,`file`,t);for(let t of be)this.defineItemSelectionCallback(e,`file`,t);return e}createDiffOptionsPrototype(){let e={};for(let t of _e)X(e,t,()=>this.options[t]);X(e,`stickyHeader`,()=>this.options.stickyHeaders),X(e,`hunkSeparators`,()=>this.options.hunkSeparators),X(e,`collapsed`,e=>{let t=Ce(e);if(t!=null)return this.getItemOptions(t,`diff`)?.item.collapsed});for(let t of ye)this.defineItemSharedCallback(e,`diff`,t);for(let t of be)this.defineItemSelectionCallback(e,`diff`,t);return e}createFileOptions(e){let t=Object.create(this.fileOptionsPrototype);return Se(t,{id:e}),t}createDiffOptions(e){let t=Object.create(this.diffOptionsPrototype);return Se(t,{id:e}),t}updateItemOptionsId(e,t){let n=Ce(e);if(n==null)throw Error(`CodeView.updateItemOptionsId: No valid state`);n.id=t}getItemOptions(e,t){let n=this.idToItem.get(e.id);if(n!=null&&n.type===t)return n}defineItemSharedCallback(e,t,n){X(e,n,e=>{if(this.options[n]==null)return;let r=Ce(e);if(r==null)return;let i=r.callbackCache??={},a=i[n];return a??(a=((...e)=>{let i=this.getItemOptions(r,t);if(i==null)return;let a=this.options[n];return a?.(...e,i)}),i[n]=a),a})}defineItemSelectionCallback(e,t,n){X(e,n,e=>{let r=Ce(e);if(r==null)return;let i=r.callbackCache??={},a=i[n];return a??(a=(e=>{let i=this.getItemOptions(r,t);if(i==null)return;let a=e==null?null:{id:i.item.id,range:e};this.options.controlledSelection!==!0&&(e!=null||this.selectedLines?.id===i.item.id)&&this.applySelectedLines(a,{notify:!1}),this.options.onSelectedLinesChange?.(a);let o=this.options[n];return o?.(e,i)}),i[n]=a),a})}markLayoutDirtyFromIndex(e){this.layoutDirtyIndex=Math.min(this.layoutDirtyIndex??e,e)}markItemLayoutDirty(e){if(this.items[e.index]!==e)throw Error(`CodeView.markItemLayoutDirty: unknown item id "${e.item.id}"`);this.markLayoutDirtyFromIndex(e.index)}tryAppendItems(e){if(e.length<=this.items.length)return!1;for(let t=0;t<this.items.length;t++){let n=this.items[t];if(n==null)throw Error(`CodeView.tryAppendItems: missing existing item`);let r=e[t];if(r==null||n.item.id!==r.id||n.type!==r.type)return!1}for(let t=0;t<this.items.length;t++){let n=this.items[t];if(n==null)throw Error(`CodeView.tryAppendItems: missing existing item`);let r=e[t];if(r==null)throw Error(`CodeView.tryAppendItems: append candidate missing prefix item`);this.syncItemRecord(n,r)&&this.markLayoutDirtyFromIndex(t)}return this.appendItemsInternal(e.slice(this.items.length),!1),this.scrollDirty=!0,this.render(),!0}reconcileItems(e){let{items:t,idToItem:n}=this,r=new Set(t),i=[],a=new Map,o=new Map,s=new Map,c;for(let s=0;s<e.length;s++){let l=e[s];if(l==null)throw Error(`CodeView.reconcileItems: missing input item`);if(a.has(l.id))throw Error(`CodeView.setItems: duplicate id "${l.id}"`);let u=n.get(l.id),d=u!=null&&u.type===l.type?u:this.createItem(l,s,0);d.index=s,u!=null&&u.type===l.type?(r.delete(u),this.syncItemRecord(d,l)&&(c=Math.min(c??s,s))):c=Math.min(c??s,s),t[s]!==d&&(c=Math.min(c??s,s)),i.push(d),a.set(l.id,d),o.set(d.instance,d)}if(c==null){if(r.size===0)return;c=Math.max(i.length-1,0)}this.capturePendingLayoutAnchor(a);for(let e=0;e<t.length;e++){let n=t[e];if(n==null||!r.has(n))continue;s.set(n.item.id,n),this.releaseRenderedItem(n);let a=Math.max(i.length-1,0);c=Math.min(c??a,a)}return this.items=i,this.idToItem=a,this.instanceToItem=o,this.renderState.firstIndex>=i.length?this.resetRenderState():this.renderState.lastIndex>=i.length&&(this.renderState.lastIndex=i.length-1),this.markLayoutDirtyFromIndex(c),this.scrollDirty=!0,this.render(),s.size>0?s:void 0}syncItemRecord(e,t){if(e.type!==t.type)throw Error(`CodeView.syncItemRecord: type mismatch for id "${t.id}"`);return e.version!==t.version&&(e.item=t,e.version=t.version,e.renderedOptionsRevision=-1,!0)}getMaxScrollTopForHeight(e){let{paddingBottom:t,paddingTop:n}=this.getLayout();return Math.max(n+this.header.height+e+this.footer.height+t-this.getHeight(),0)}getMaxScrollTop(){return this.getMaxScrollTopForHeight(this.getScrollHeight())}shouldRebaseScroll(){return this.getMaxScrollTop()>je}getPagedScrollHeight(){return this.shouldRebaseScroll()?Math.min(this.getScrollHeight(),De):this.getScrollHeight()}getMaxPagedScrollTop(){return this.getMaxScrollTopForHeight(this.getPagedScrollHeight())}clampPagedScrollTop(e){let t=this.getMaxPagedScrollTop();return Math.max(0,Math.min(e,t))}clampScrollTop(e){let t=this.getMaxScrollTop();return Math.max(0,Math.min(e,t))}getMaxScrollPageOffset(){return Math.max(this.getMaxScrollTop()-this.getMaxPagedScrollTop(),0)}clampScrollPageOffset(e){let t=this.getMaxScrollPageOffset();return Math.max(0,Math.min(e,t))}resolveScrollPageWindow(e,t){let n=Y(this.clampPagedScrollTop(t)),r=this.clampScrollPageOffset(e-n);return n=Y(this.clampPagedScrollTop(e-r)),r=this.clampScrollPageOffset(e-n),{pagedScrollTop:n,scrollPageOffset:r}}resolvePagedScrollPosition(e){if(!this.shouldRebaseScroll())return{pagedScrollTop:this.clampPagedScrollTop(e),scrollPageOffset:0};let t=this.clampScrollPageOffset(this.scrollPageOffset),n=e-t,r=this.getMaxPagedScrollTop(),i=this.getMaxScrollPageOffset(),a=n>je&&t<i,o=n<Oe&&t>0;return n<0||n>r||a||o?this.resolveScrollPageWindow(e,o?Math.min(Ae,r):ke):{pagedScrollTop:Y(this.clampPagedScrollTop(n)),scrollPageOffset:t}}needsScrollPageUpdate(e){let t=Y(this.clampScrollTop(e)),{scrollPageOffset:n}=this.resolvePagedScrollPosition(t);return n!==this.scrollPageOffset}getPagedLayoutTop(e){return this.shouldRebaseScroll()?Math.max(e-this.scrollPageOffset,0):e}getStickyHeaderOffset(){return this.options.stickyHeaders===!0&&this.options.disableFileHeader!==!0?this.itemMetricsCache.diffHeaderHeight:0}getScrollTargetRect(e){let t=this.idToItem.get(e.id);if(t==null){console.warn(`CodeView.scrollTo: unknown item id "${e.id}"`);return}if(e.type===`item`)return{top:t.top,height:t.height};if(e.type===`range`){let n=this.getRangeScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve range ${Be(e.range)} for item "${e.id}"`);return}return{top:t.top+n.top,height:n.height}}let n=this.getLineScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve line ${e.lineNumber} for item "${e.id}"`);return}return{top:t.top+n.top,height:n.height}}normalizeScrollTarget(e){if(e.type===`position`||e.align!==`nearest`)return e;let t=this.getScrollTargetRect(e);if(t==null)return;let n=e.offset??0,r=this.getItemTopOffset()+t.top,i=r+t.height,a=this.getScrollTop(),o=a+(e.type===`line`||e.type===`range`?this.getStickyHeaderOffset():0),s=a+this.getHeight();if(!(r-n<=o&&i+n>=s)){if(r-n<o)return{...e,align:`start`};if(i+n>s)return{...e,align:`end`}}}resolveScrollTargetTop(e){if(e.type===`position`){let t=this.clampScrollTop(e.position);return t===e.position?this.clampScrollTop(e.position-this.getStickyHeaderOffset()):t}let t=this.idToItem.get(e.id);if(t==null){console.warn(`CodeView.scrollTo: unknown item id "${e.id}"`);return}if(e.type===`item`)return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top,t.height,e.align,e.offset));if(e.type===`range`){let n=this.getRangeScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve range ${Be(e.range)} for item "${e.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top+n.top,n.height,e.align,e.offset,this.getStickyHeaderOffset()))}let n=this.getLineScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve line ${e.lineNumber} for item "${e.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top+n.top,n.height,e.align,e.offset,this.getStickyHeaderOffset()))}resolveAlignedScrollPosition(e,t,n,r=0,i=0){e+=this.getItemTopOffset();let a=this.getHeight();return n===`center`&&t+r<a?e-(a-t)/2+r:n===`end`?e-(a-t)+r:e-i-r}getLineScrollPosition(e,t){return e.type===`diff`?e.instance.getLinePosition(t.lineNumber,t.side):e.instance.getLinePosition(t.lineNumber)}getRangeScrollPosition(e,t){let{range:n}=t,r=this.getLineScrollPosition(e,{type:`line`,id:t.id,lineNumber:n.start,side:n.side}),i=this.getLineScrollPosition(e,{type:`line`,id:t.id,lineNumber:n.end,side:n.endSide??n.side});if(r==null||i==null)return;let a=r.top,o=a+r.height,s=i.top,c=s+i.height,l=Math.min(a,s);return{top:l,height:Math.max(o,c)-l}}computeTargetScrollTopForFrame(e,t){if(this.pendingScrollTarget==null)return e;let n=this.resolveScrollTargetTop(this.pendingScrollTarget);if(n==null)return e;let{scrollAnimation:r}=this;return r==null?n:this.computeSpringStep(r,n,t).position}computeSpringStep(e,t,n){let r=Math.max(0,n-e.lastTimestamp),{omega:i}=this.getSmoothScrollSettings(),a=Math.exp(-i*r),o=e.position-t,s=e.velocity+i*o;return{position:t+(o+s*r)*a,velocity:(s*(1-i*r)-i*o)*a}}advanceScrollAnimation(e,t){if(this.pendingScrollTarget==null)return;let n=this.resolveScrollTargetTop(this.pendingScrollTarget);if(n==null){this.pendingScrollTarget=void 0,this.scrollAnimation=void 0;return}let r=this.scrollAnimation;if(r==null)return n;r.position+=t;let{position:i,velocity:a}=this.computeSpringStep(r,n,e);r.lastTimestamp=e,r.position=i,r.velocity=a;let{positionEpsilon:o,velocityEpsilon:s}=this.getSmoothScrollSettings();return Math.abs(n-i)<=o&&Math.abs(a)<=s?(r.position=n,r.velocity=0,this.scrollAnimation=void 0,n):r.position}computeRenderRangeAndEmit=(t=performance.now())=>{if(e.__STOP||this.container==null||!this.isReady())return;let n=this.getHeight(),r=this.getScrollTop(),i=r,a=this.pendingLayoutAnchor!=null,o=this.getScrollAnchor(i);if(this.layoutDirtyIndex!=null&&(this.recomputeLayout(this.layoutDirtyIndex,this.pendingLayoutReset),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,a=!0),a&&o!=null){let e=this.resolveAnchoredScrollTop(o);if(e!=null){let t=e-i;i=e,this.scrollAnimation!=null&&(this.scrollAnimation.position+=t)}}a&&(i=this.clampScrollTop(i),this.syncContainerHeight());let s=this.computeTargetScrollTopForFrame(i,t),c=!a&&(this.renderState.scrollTop===-1||Math.abs(s-this.renderState.scrollTop)>n+this.config.overscrollSize*2);c&&(o=void 0),this.windowSpecs=O({scrollTop:s-this.header.height,height:n,scrollHeight:this.getScrollHeight(),fitPerfectly:c,fitPerfectlyOverscroll:this.getFitPerfectlyOverscroll(),overscrollSize:this.config.overscrollSize});let l=r;(this.pendingScrollTarget!=null&&s!==l||this.needsScrollPageUpdate(s))&&(this.applyScrollFix(s,l,this.windowSpecs),l=s);let{top:u,bottom:d}=this.windowSpecs,{firstIndex:f,lastIndex:p}=this.renderState;if(f>=0)for(let e=f;e<=p;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.computeRenderRangeAndEmit: No item at index: ${e}`);t.top>u-t.height&&t.top<=d||this.releaseRenderedItem(t)}let m=this.reconcileHeaderFooterHosts(),h,g=new Set,_=this.findFirstVisibleIndex(u),v=this.findLastVisibleIndex(d);for(let e=_;e<=v;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.computeRenderRangeAndEmit: missing item`);let{instance:n}=t;t.element==null?(t.element=this.acquireElement(),Ue(this.stickyContainer,t.element,h),n.virtualizedSetup(),He(t,t.element)&&(t.renderedOptionsRevision=this.renderOptionsRevision,g.add(t)),h=t.element):(Ue(this.stickyContainer,t.element,h),He(t,void 0,t.renderedOptionsRevision!==this.renderOptionsRevision)&&(t.renderedOptionsRevision=this.renderOptionsRevision,g.add(t)),h=t.element),t.item.edit===!0&&this.attachItemEditor(t)}this.renderState.firstIndex=_<=v?_:-1,this.renderState.lastIndex=v,this.flushSlotCoordinator(),this.flushManagers(g),m&&this.measureMountedHosts(),this.reconcileRenderedItems(g),this.syncContainerHeight(),this.updateStickyPositioning();let y=o==null?void 0:this.resolveAnchoredScrollTop(o);o===this.pendingLayoutAnchor&&(this.pendingLayoutAnchor=void 0);let b=y==null?0:y-i,x=s,S=!1;if(this.pendingScrollTarget!=null){let e=this.advanceScrollAnimation(t,b);e==null?x=i:(x=e,S=!0)}else x=y??s;x!==l&&(this.applyScrollFix(x,l,this.windowSpecs),l=x),S&&this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),this.renderState.scrollTop=Y(l),this.updateStickyPositioning(),this.validateStickyContainerHeight(),this.fixContainerFocus(),(c||this.scrollAnimation!=null)&&this.render()};flushManagers(e){for(let t of e)t.instance.flushManagers()}syncContainerHeight(){let e=this.getPagedScrollHeight();this.container!=null&&this.containerHeight!==e&&(this.container.style.height=`${e}px`,this.containerHeight=e)}getStickyBounds(e){let{firstIndex:t,lastIndex:n}=e==null?this.renderState:{firstIndex:this.findFirstVisibleIndex(e.top),lastIndex:this.findLastVisibleIndex(e.bottom)};if(t===-1||n===-1||t>n)return;let r=this.items[t]?.instance.getAdvancedStickySpecs(e),i=this.items[n]?.instance.getAdvancedStickySpecs(e);if(r!=null&&i!=null)return{stickyTop:this.getPagedLayoutTop(Math.max(r.topOffset,0)),stickyBottom:this.getPagedLayoutTop(i.topOffset+i.height)}}applyStickyPositioning({stickyTop:e,stickyBottom:t}){let n=this.getHeight(),{itemMetricsCache:r}=this,i=t-e;this.renderState.stickyHeight=i,this.renderState.stickyTop=e,this.renderState.stickyBottom=t,this.stickyOffset.style.height=`${e}px`;let a=(Math.random()*r.lineHeight>>0)*-1,o=-Math.max(i+a,0)+n;this.stickyContainer.style.top=`${o}px`,this.stickyContainer.style.bottom=`${o+r.diffHeaderHeight}px`}syncPagedScrollScaffolding(e){this.syncContainerHeight();let t=this.getStickyBounds(e);t!=null&&this.applyStickyPositioning(t)}reconcileRenderedItems(e){let{firstIndex:t,lastIndex:n}=this.renderState;if(t===-1)return;let r=-1,i=!1;for(let a=t;a<this.items.length&&!(!i&&a>n);a++){let t=this.items[a];if(t==null)throw Error(`CodeView.reconcileRenderedItems: Invalid item`);r===-1?r=t.top:t.top!==r&&(t.top=r,t.instance.syncVirtualizedTop(),i=!0),(e==null?a<=n:e.has(t))&&(t.instance.reconcileHeights()&&(i=!0,t.height=t.instance.getVirtualizedHeight()),this.validateRenderedItemHeight(t)),r+=t.instance.getVirtualizedHeight(),a<this.items.length-1&&(r+=this.getLayout().gap)}i&&r!=null&&(this.scrollDirty=!0,this.scrollHeight=r)}updateStickyPositioning(){let e=this.getStickyBounds();if(e==null){this.renderState.firstIndex===-1&&(this.stickyOffset.style.height=``);return}let{stickyTop:t,stickyBottom:n}=e;(n-t!==this.renderState.stickyHeight||t!==this.renderState.stickyTop||n!==this.renderState.stickyBottom)&&this.applyStickyPositioning(e)}handleScroll=()=>{e.__STOP||(this.suspendScrollInteractions(),this.scrollDirty=!0,this.notifyScroll(),this.render())};clearPendingScroll=()=>{this.pendingScrollTarget=void 0,this.pendingLayoutAnchor=void 0,this.scrollAnimation=void 0};handleResize=e=>{let t=!1;for(let n of e)if(n.target===this.stickyContainer){let e=n.borderBoxSize[0].blockSize;if(Math.abs(e-this.renderState.stickyHeight)>=Te){let e=this.getScrollTop(),n=this.getScrollAnchor(e);this.reconcileRenderedItems(),this.updateStickyPositioning();let r=n==null?void 0:this.resolveAnchoredScrollTop(n);if(r!=null){let t=r-e;this.applyScrollFix(r,e,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=t)}this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),t=!0}}else if(n.target===this.header.element||n.target===this.footer.element){let e=n.target===this.header.element?this.header:this.footer,r=n.borderBoxSize[0].blockSize;if(r!==e.height){let n=this.getScrollTop(),i=this.getScrollAnchor(n);this.setHostHeight(e,r);let a=i==null?void 0:this.resolveAnchoredScrollTop(i);if(a!=null){let e=a-n;this.applyScrollFix(a,n,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=e)}this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),t=!0}}else this.scrollDirty=!0,this.heightDirty=!0,t=!0;t&&this.render(!0)};getScrollAnchorViewportTop(e,t){return e<t?t+this.getStickyHeaderOffset():t}getScrollAnchor(e,t=this.idToItem){let n,{pendingLayoutAnchor:r}=this;if(r!=null){let e=this.idToItem.get(r.id);if(e!=null&&t.get(r.id)===e)return r;e!=null&&(n=e)}if(e<=0)return;let{firstIndex:i,lastIndex:a,stickyTop:o,stickyBottom:s}=this.renderState;if(i===-1||a===-1)return;let c=this.getHeight();if(o!==-1&&s!==-1){for(let r=i;r<=a;r++){let i=this.items[r];if(i==null)continue;let a=this.getItemTopOffset()+i.top;if(a+i.height<=e)continue;if(a>=e+c)break;if(t.get(i.item.id)!==i){n??=i;continue}if(a>=e)return{type:`item`,id:i.item.id,viewportOffset:a-e};let o=this.getScrollAnchorViewportTop(a,e)-a,s=i.instance.getNumericScrollAnchor(o);if(s!=null){let t=a+s.top;return{type:`line`,id:i.item.id,lineNumber:s.lineNumber,side:s.side,viewportOffset:t-e}}}if(n!=null)for(let e=n.index+1;e<this.items.length;e++){let n=this.items[e];if(n!=null&&t.get(n.item.id)===n)return{type:`item`,id:n.item.id,viewportOffset:0}}}}resolveAnchoredScrollTop(e){let t=this.idToItem.get(e.id);if(t==null)return;let n=this.getItemTopOffset();if(e.type===`item`){let r=n+t.top;return this.clampScrollTop(r-e.viewportOffset)}let r=t.type===`diff`?t.instance.getLinePosition(e.lineNumber,e.side):t.instance.getLinePosition(e.lineNumber);if(r==null)return;let i=n+t.top+r.top;return this.clampScrollTop(i-e.viewportOffset)}applyScrollFix(e,t,n){if(this.root==null)return;let r=Y(this.clampScrollTop(e)),i=Y(t),{scrollPageOffset:a}=this,o=Y(this.clampPagedScrollTop(i-a)),{pagedScrollTop:s,scrollPageOffset:c}=this.resolvePagedScrollPosition(r),l=s,u=a!==c;r===this.renderState.scrollTop&&r===i&&l===o&&!u||(this.suspendScrollInteractions(),(l!==o||u)&&(this.scrollPageOffset=c,this.syncPagedScrollScaffolding(n)),l!==o&&this.root.scrollTo({top:l,behavior:`instant`}),this.renderState.scrollTop=r,this.scrollTop=r,this.scrollDirty=!1)}isPendingTargetSettled(e){let t=this.resolveScrollTargetTop(e);return t==null||Y(this.getScrollTop())===Y(t)}getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root?.scrollTop??0;return this.scrollTop=this.clampScrollTop(e+this.scrollPageOffset),this.scrollTop}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root?.getBoundingClientRect().height??0,this.height):this.height}getScrollHeight(){return this.scrollHeight}flushSlotCoordinator(){if(this.slotCoordinator==null)return;let e=this.buildSlotSnapshot(this.slotCoordinator);me(this.slotSnapshot,e)||(this.slotSnapshot=e,this.slotCoordinator.onSnapshotChange(e))}notifyScroll(){if(this.scrollListeners.size===0)return;let e=this.getScrollTop();for(let t of this.scrollListeners)t(e,this)}findFirstVisibleIndex(e){let t=0,n=this.items.length-1,r=this.items.length;for(;t<=n;){let i=t+n>>1,a=this.items[i];if(a==null)throw Error(`CodeView.findFirstVisibleIndex: invalid item index`);a.top+a.height>e?(r=i,n=i-1):t=i+1}return r}findLastVisibleIndex(e){let t=0,n=this.items.length-1,r=-1;for(;t<=n;){let i=t+n>>1,a=this.items[i];if(a==null)throw Error(`CodeView.findLastVisibleIndex: invalid item index`);a.top<=e?(r=i,t=i+1):n=i-1}return r}recomputeLayout(e=0,t){if(this.items.length===0){this.scrollHeight=0;return}let n=this.getLayout(),r=0;if(e>0){let t=this.items[e-1];if(t==null)throw Error(`CodeView.recomputeLayout: invalid dirty index`);r=t.top+t.height+n.gap}for(let i=e;i<this.items.length;i++){let e=this.items[i];if(e==null)throw Error(`CodeView.recomputeLayout: invalid item index`);if(e.top=r,e.type===`diff`){let n=e.instance.consumeCodeViewLayoutChanges(e.item.fileDiff);n!=null&&Object.assign(e.item.fileDiff,n),e.height=e.instance.prepareCodeViewItem(e.item.fileDiff,r,t,e.item.annotations??[])}else e.height=e.instance.prepareCodeViewItem(e.item.file,r,t,e.item.annotations??[]);r+=e.height,i<this.items.length-1&&(r+=n.gap)}r!==this.scrollHeight&&(this.scrollDirty=!0),this.scrollHeight=r}resetRenderState(){this.renderState.scrollTop=-1,this.renderState.firstIndex=-1,this.renderState.lastIndex=-1,this.renderState.stickyHeight=0,this.renderState.stickyTop=-1,this.renderState.stickyBottom=-1}getFitPerfectlyOverscroll(){return this.getLayout().gap+this.itemMetricsCache.diffHeaderHeight}};function Fe(e){return e.instance.cleanUp(!0),e.type===`diff`?e.instance.prepareCodeViewItem(e.item.fileDiff,e.top,void 0,e.item.annotations??[]):e.instance.prepareCodeViewItem(e.item.file,e.top,void 0,e.item.annotations??[])}function Ie(e,t){return!M(e.theme??F,t.theme??F)||(e.themeType??`system`)!==(t.themeType??`system`)||e.unsafeCSS!==t.unsafeCSS}function Le(e,t){return(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS||(e.diffStyle??`split`)!==(t.diffStyle??`split`)||(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)}function Re(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 ze(e){return e instanceof SVGElement||re(e)&&(e.hasAttribute(`data-core-css`)||e.hasAttribute(`data-theme-css`)||e.hasAttribute(`data-unsafe-css`))}function Be(e){let t=Ve(e.start,e.side),n=Ve(e.end,e.endSide??e.side);return t===n?t:`${t}-${n}`}function Ve(e,t){return t==null?`${e}`:`${t===`deletions`?`D`:`A`}${e}`}function He(e,t,n=!1){return e.type===`diff`?e.instance.render({deferManagers:!0,fileContainer:t,fileDiff:e.item.fileDiff,forceRender:n,lineAnnotations:e.item.annotations??[]}):e.instance.render({deferManagers:!0,fileContainer:t,file:e.item.file,forceRender:n,lineAnnotations:e.item.annotations??[]})}function Ue(e,t,n){if(n==null){e.firstChild!==t&&e.prepend(t);return}n.nextSibling!==t&&n.after(t)}function We(e){return(e.annotations?.length??0)>0}function Ge(e,{hasHeaderRenderers:t,hasAnnotationRenderer:n,hasGutterRenderer:r}){if(e.length===0)return;if(t||r)return e;if(!n)return;let i=[];for(let t of e)We(t.item)&&i.push(t);return i.length>0?i:void 0}var Z=e(n(),1),Ke=e(a(),1),Q=t(),qe=typeof window>`u`?Z.useEffect:Z.useLayoutEffect;function Je(e){return{instance:void 0,items:void 0,controlled:e,managedOptions:void 0,disableFlushSync:!1,slotCoordinator:void 0}}function Ye(e,t){let{className:n,containerRef:r,disableWorkerPool:i=!1,editorOptions:a,initialItems:o,items:s,onItemEditChange:c,onItemEditComplete:l,onScroll:u,onSelectedLinesChange:d,options:f,renderAnnotation:p,renderCodeViewFooter:m,renderCodeViewHeader:h,renderCustomHeader:g,renderGutterUtility:_,renderHeaderFilenameSuffix:v,renderHeaderMetadata:y,renderHeaderPrefix:b,selectedLines:x,style:S}=e,C=s!==void 0,w=te(),T=(0,Z.useContext)(ee),E=(0,Z.useRef)(Je(C)),D=g!=null,O=p!=null,k=_!=null,j=D||b!=null||v!=null||y!=null,M=j||O||k,N=h!=null,F=m!=null,I=P(e=>{d?.(e)}),L=x!==void 0,R=P(e=>{if(w==null)throw Error(`CodeView: EditContext is not attached`);let t=w({...a,...e});if(t==null)throw Error(`CodeView: EditProvider.createEditor must return an editor instance`);return t}),z=P((e,t,n)=>{c?.(e,t,n)}),B=P((e,t,n)=>{l?.(e,t,n)}),V=(0,Z.useMemo)(()=>tt({options:f,hasCustomHeader:D,hasGutterRenderer:k,hasCodeViewHeader:N,hasCodeViewFooter:F,onSelectedLinesChange:d==null?void 0:I,controlledSelection:L,createEditor:w==null?void 0:R,onItemEditChange:c==null?void 0:z,onItemEditComplete:l==null?void 0:B}),[w,L,R,z,B,I,F,N,D,k,c,l,d,f]),[H]=(0,Z.useState)(()=>et()),[,U]=(0,Z.useState)({}),W=P(e=>{E.current.instance!=null&&(e==null||e!==E.current.instance.getContainerElement())&&(E.current.instance.cleanUp(),H.publish(void 0),E.current=Je(C)),e!=null&&e!==E.current.instance?.getContainerElement()&&(E.current.instance=new Pe(V,i?void 0:T,!0),E.current.instance.setup(e)),typeof r==`function`?r(e):r!=null&&(r.current=e)}),G=P(e=>{E.current.disableFlushSync?H.publish(e):(0,Ke.flushSync)(()=>{H.publish(e)})}),K=(0,Z.useMemo)(()=>{if(!(!j&&!O&&!k&&!N&&!F))return{hasHeaderRenderers:j,hasAnnotationRenderer:O,hasGutterRenderer:k,onSnapshotChange:G}},[G,O,k,j,N,F]);return qe(()=>u==null?void 0:E.current.instance?.subscribeToScroll(u)),qe(()=>{let{instance:e,controlled:t,items:n,managedOptions:r,slotCoordinator:i}=E.current;if(e!=null)try{E.current.disableFlushSync=!0;let a=!1;if(A(V,r)||(E.current.managedOptions=V,e.setOptions(V),a=!0),t!==C){console.error(`CodeView: cannot switch between controlled and uncontrolled modes. Remount with a new key instead.`);return}if(C)s!==n&&(Qe(n,s)?E.current.items=s:Ze(n,s)?(E.current.items=s,e.addItems(s.slice(n.length))):(E.current.items=s,e.setItems(s),a=!0));else if(n==null){let t=o??[];E.current.items=t,t.length>0&&(e.setItems(t),a=!0)}x!==void 0&&e.setSelectedLines(x,{notify:!1});let c=e.setSlotCoordinator(K),l=!1;K!==i&&((K==null||i==null)&&(l=!0),E.current.slotCoordinator=K),(a||c)&&e.render(!0),c&&K==null&&H.publish(void 0),l&&U({})}finally{E.current.disableFlushSync=!1}}),(0,Z.useImperativeHandle)(t,()=>({addItems(e){let{controlled:t,instance:n}=E.current;$e(t,`addItems`),n==null?console.error(`CodeView.addItems: no valid instance to append items with`,e):n.addItems(e)},getItem(e){let{instance:t}=E.current;if(t==null){console.error(`CodeView.getItem: no valid instance exists`,e);return}return t.getItem(e)},removeItem(e){let{controlled:t,instance:n}=E.current;return $e(t,`removeItem`),n==null?(console.error(`CodeView.removeItem: no valid instance to remove item from`,e),!1):n.removeItem(e)},updateItem(e){let{controlled:t,instance:n}=E.current;return $e(t,`updateItem`),n==null?(console.error(`CodeView.updateItem: no valid instance to update item with`,e),!1):n.updateItem(e)},updateItemId(e,t){let{controlled:n,instance:r}=E.current;return $e(n,`updateItemId`),r==null?(console.error(`CodeView.updateItemId: no valid instance to update item id with`,e,t),!1):r.updateItemId(e,t)},scrollTo(e){let{instance:t}=E.current;t==null?console.error(`CodeView.scrollTo: no valid instance to scroll with`,e):t.scrollTo(e)},setSelectedLines(e){let{instance:t}=E.current;t==null?console.error(`CodeView.setSelectedLines: no valid instance to update selection with`,e):(t.setSelectedLines(e,{notify:!1}),I(e))},getSelectedLines(){let{instance:e}=E.current;return e==null?(console.error(`CodeView.getSelectedLines: no valid instance exists`),null):e.getSelectedLines()},clearSelectedLines(){let{instance:e}=E.current;e==null?console.error(`CodeView.clearSelectedLines: no valid instance to update selection with`):(e.clearSelectedLines({notify:!1}),I(null))},getEditor(e){let{instance:t}=E.current;if(t==null){console.error(`CodeView.getEditor: no valid instance exists`,e);return}return t.getEditor(e)},getInstance(){return E.current.instance}}),[I]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{ref:W,className:n,style:S}),(M||N||F)&&(0,Q.jsx)(nt,{managedContentStore:H,renderCustomHeader:g,renderHeaderPrefix:b,renderHeaderFilenameSuffix:v,renderHeaderMetadata:y,renderAnnotation:p,renderGutterUtility:_,renderCodeViewHeader:h,renderCodeViewFooter:m})]})}var Xe=(0,Z.forwardRef)(Ye);function Ze(e,t){if(e==null||t.length<=e.length)return!1;if(e.length===0)return!0;for(let n=0;n<e.length;n++)if(t[n]!==e[n])return!1;return!0}function Qe(e,t){if(e==null||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function $e(e,t){if(e)throw Error(`CodeView.${t} cannot be used when CodeView is controlled. Use initialItems for imperative item updates.`)}function et(){let e,t=new Set;return{getSnapshot(){return e},publish(n){if(!me(e,n)){e=n;for(let e of t)e()}},subscribe(e){return t.add(e),()=>{t.delete(e)}}}}function tt({options:e,hasCustomHeader:t,hasGutterRenderer:n,hasCodeViewHeader:r,hasCodeViewFooter:i,onSelectedLinesChange:a,controlledSelection:o,createEditor:s,onItemEditChange:c,onItemEditComplete:l}){let u={...e,controlledSelection:o,onSelectedLinesChange:a,createEditor:s};return c!=null&&(u.onItemEditChange=c),l!=null&&(u.onItemEditComplete=l),t&&(u.renderCustomHeader=it),n&&(u.renderGutterUtility=it),r&&(u.renderCodeViewHeader=it),i&&(u.renderCodeViewFooter=it),u}var nt=(0,Z.memo)(function({managedContentStore:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,renderGutterUtility:o,renderCodeViewHeader:s,renderCodeViewFooter:c}){"use no memo";let l=P(t=>e.subscribe(t)),u=P(()=>e.getSnapshot()),d=(0,Z.useSyncExternalStore)(l,u,u),f=``;for(let e of d?.items??[])f+=`${e.id}:${e.version}:${e.type}`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Z.useMemo)(()=>d?.items?.map(e=>(0,Ke.createPortal)(rt({renderedItem:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,renderGutterUtility:o}),e.element,e.id)),[t,n,r,i,a,o,f]),(0,Z.useMemo)(()=>s!=null&&d?.header!=null?(0,Ke.createPortal)(s(),d.header):null,[s,d?.header]),(0,Z.useMemo)(()=>c!=null&&d?.footer!=null?(0,Ke.createPortal)(c(),d.footer):null,[c,d?.footer])]})});function rt({renderedItem:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,renderGutterUtility:o}){if(e.type===`diff`){let{item:s,instance:c}=e;return se({fileDiff:s.fileDiff,renderCustomHeader:t==null?void 0:()=>t(s),renderHeaderPrefix:n==null?void 0:()=>n(s),renderHeaderFilenameSuffix:r==null?void 0:()=>r(s),renderHeaderMetadata:i==null?void 0:()=>i(s),renderAnnotation:a==null?void 0:e=>a(e,s),lineAnnotations:s.annotations,renderGutterUtility:o==null?void 0:e=>o(e,s),getHoveredLine:c.getHoveredLine})}{let{item:s,instance:c}=e;return _({file:s.file,renderCustomHeader:t==null?void 0:()=>t(s),renderHeaderPrefix:n==null?void 0:()=>n(s),renderHeaderFilenameSuffix:r==null?void 0:()=>r(s),renderHeaderMetadata:i==null?void 0:()=>i(s),renderAnnotation:a==null?void 0:e=>a(e,s),lineAnnotations:s.annotations,renderGutterUtility:o==null?void 0:e=>o(e,s),getHoveredLine:c.getHoveredLine})}}function it(){}var $=r(),at=0;function ot(){return at+=1,`pending-review-comment-${at}`}function st(e,t){return`${e}/${t.projectId}/${t.repository}#${t.number}`}var ct=[],lt=ie()(e=>({drafts:{},summaries:{},addComment:(t,n)=>e(e=>({drafts:{...e.drafts,[t]:[...e.drafts[t]??ct,n]}})),removeComment:(t,n)=>e(e=>{let r=(e.drafts[t]??ct).filter(e=>e.id!==n);if(r.length>0)return{drafts:{...e.drafts,[t]:r}};let{[t]:i,...a}=e.drafts;return{drafts:a}}),removeComments:(t,n)=>e(e=>{let r=new Set(n),i=(e.drafts[t]??ct).filter(e=>!r.has(e.id));if(i.length>0)return{drafts:{...e.drafts,[t]:i}};let{[t]:a,...o}=e.drafts;return{drafts:o}}),clear:t=>e(e=>{let{[t]:n,...r}=e.drafts;return{drafts:r}}),setSummary:(t,n)=>e(e=>({summaries:{...e.summaries,[t]:n}})),clearSummary:(t,n)=>e(e=>{if(e.summaries[t]!==n)return e;let{[t]:r,...i}=e.summaries;return{summaries:i}})}));function ut(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=t=>t.drafts[st(e.environmentId,e)]??ct,t[0]=e,t[1]=n),lt(n)}function dt(e){return[...e].toSorted((e,t)=>t.committedDate.localeCompare(e.committedDate))}function ft(e,t,n){let r=e.slice(0,n),i=e.find(e=>e.oid===t);return i!==void 0&&!r.includes(i)?[...r,i]:r}function pt(e){let t=(0,$.c)(60),[n,r]=(0,Z.useState)(10),i,a,o,s,c,l,u,d,f;if(t[0]!==e||t[1]!==n){i=dt(e.commits);let r=ft(i,e.selectedCommitOid,n);f=`flex shrink-0 items-center gap-2 overflow-x-auto border-b border-border/60 px-3 py-2`,u=`min-w-40 flex-1`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(`span`,{className:`sr-only`,children:`Diff scope`}),t[11]=d):d=t[11],a=`max-w-full rounded-md border border-border bg-background px-2 py-1 text-xs`,o=e.selectedCommitOid??``,t[12]===e?s=t[13]:(s=t=>e.onSelectedCommitChange(t.target.value||null),t[12]=e,t[13]=s),t[14]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(`option`,{value:``,children:`All commits`}),t[14]=c):c=t[14],l=r.map(ht),t[0]=e,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];let p;t[15]!==a||t[16]!==o||t[17]!==s||t[18]!==c||t[19]!==l?(p=(0,Q.jsxs)(`select`,{className:a,value:o,onChange:s,children:[c,l]}),t[15]=a,t[16]=o,t[17]=s,t[18]=c,t[19]=l,t[20]=p):p=t[20];let m;t[21]!==u||t[22]!==d||t[23]!==p?(m=(0,Q.jsxs)(`label`,{className:u,children:[d,p]}),t[21]=u,t[22]=d,t[23]=p,t[24]=m):m=t[24];let g;t[25]!==i.length||t[26]!==n?(g=n<i.length?(0,Q.jsx)(S,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>r(mt),children:`More commits`}):null,t[25]=i.length,t[26]=n,t[27]=g):g=t[27];let _;t[28]===e.onToggleAll?_=t[29]:(_=(0,Q.jsx)(S,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Toggle all files`,onClick:e.onToggleAll,children:`⌄`}),t[28]=e.onToggleAll,t[29]=_);let v=e.diffStyle===`unified`,y;t[30]===e?y=t[31]:(y=()=>e.onDiffStyleChange(`unified`),t[30]=e,t[31]=y);let b;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(q,{className:`size-3.5`}),t[32]=b):b=t[32];let x;t[33]!==v||t[34]!==y?(x=(0,Q.jsx)(S,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Unified diff view`,"aria-pressed":v,onClick:y,children:b}),t[33]=v,t[34]=y,t[35]=x):x=t[35];let C=e.diffStyle===`split`,w;t[36]===e?w=t[37]:(w=()=>e.onDiffStyleChange(`split`),t[36]=e,t[37]=w);let T;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Q.jsx)(oe,{className:`size-3.5`}),t[38]=T):T=t[38];let E;t[39]!==C||t[40]!==w?(E=(0,Q.jsx)(S,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Split diff view`,"aria-pressed":C,onClick:w,children:T}),t[39]=C,t[40]=w,t[41]=E):E=t[41];let D;t[42]===e?D=t[43]:(D=()=>e.onWordWrapChange(!e.wordWrap),t[42]=e,t[43]=D);let O;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Q.jsx)(le,{className:`size-3.5`}),t[44]=O):O=t[44];let k;t[45]!==e.wordWrap||t[46]!==D?(k=(0,Q.jsx)(S,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Toggle line wrapping`,"aria-pressed":e.wordWrap,onClick:D,children:O}),t[45]=e.wordWrap,t[46]=D,t[47]=k):k=t[47];let A;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Q.jsx)(h,{className:`size-3.5`}),t[48]=A):A=t[48];let j;t[49]===e.onRefresh?j=t[50]:(j=(0,Q.jsx)(S,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Refresh pull request diff`,onClick:e.onRefresh,children:A}),t[49]=e.onRefresh,t[50]=j);let M;return t[51]!==g||t[52]!==_||t[53]!==x||t[54]!==E||t[55]!==k||t[56]!==j||t[57]!==f||t[58]!==m?(M=(0,Q.jsxs)(`header`,{className:f,children:[m,g,_,x,E,k,j]}),t[51]=g,t[52]=_,t[53]=x,t[54]=E,t[55]=k,t[56]=j,t[57]=f,t[58]=m,t[59]=M):M=t[59],M}function mt(e){return e+10}function ht(e){return(0,Q.jsx)(`option`,{value:e.oid,children:`${e.messageHeadline} (${e.oid.slice(0,7)})`},e.oid)}var gt=new Set([`pnpm-lock.yaml`,`yarn.lock`,`package-lock.json`,`bun.lockb`,`Cargo.lock`,`go.sum`,`composer.lock`,`Gemfile.lock`]),_t=new Set([`__snapshots__`,`__generated__`,`dist`,`build`,`vendor`]),vt=new Set([`__tests__`,`tests`,`test`]),yt=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`];function bt(e){let t=e.split(`/`),n=t.at(-1)??``;return gt.has(n)||n.endsWith(`.snap`)||n.endsWith(`.min.js`)||n.endsWith(`.min.css`)||/\.generated\./.test(n)||t.slice(0,-1).some(e=>_t.has(e))?`generated`:/\.(?:test|spec)\./.test(n)||t.slice(0,-1).some(e=>vt.has(e))?`test`:`source`}function xt(e){let t=e.lastIndexOf(`.`);return t>e.lastIndexOf(`/`)?e.slice(0,t):e}function St(e){return xt(e.split(`/`).at(-1)??``)}function Ct(e,t){let n=e.split(`/`).slice(0,-1);for(let e of t.split(`/`))e!==`.`&&e!==``&&(e===`..`?n.pop():n.push(e));return n.join(`/`)}var wt=/(?:\bfrom|\bimport|\brequire\s*\()\s*\(?\s*["']([^"']+)["']/g;function Tt(e,t,n,r){let i=t.startsWith(`.`)?Ct(e,t):t,a=yt.find(e=>i.endsWith(e)),o=a===void 0?i:i.slice(0,-a.length),s=n.get(o)??n.get(`${o}/index`)??r.get(St(o));return s===e?void 0:s}function Et(e){return wt.lastIndex=0,Array.from(e.matchAll(wt),e=>e[1]??``)}function Dt(e,t,n,r){let i=new Set;for(let a of t.flatMap(Et)){let t=Tt(e,a,n,r);t!==void 0&&i.add(t)}return i}function Ot(e,t){let n=new Set(e),r=[],i=e.toSorted((e,t)=>e.localeCompare(t));for(;n.size>0;){let e=i.filter(e=>n.has(e)),a=e.find(e=>[...t.get(e)??[]].every(e=>!n.has(e)))??e[0];n.delete(a),r.push(a)}return r}function kt(e){return(e.split(`/`).at(-1)??``).replace(/\.(?:test|spec)\..*$/,``).replace(/\.[^.]+$/,``)}function At(e){let t=new Map;for(let n of e)t.set(J(n),n);let n=new Map;for(let e of t.keys())n.set(e,bt(e));let r=[...t.keys()].filter(e=>n.get(e)===`source`),i=new Map,a=new Set,o=new Map;for(let e of r){i.set(xt(e),e);let t=St(e);o.has(t)&&a.add(t),o.set(t,e)}for(let e of a)o.delete(e);let s=new Map;for(let e of r){let n=t.get(e);s.set(e,Dt(e,[...n.additionLines,...n.deletionLines],i,o))}let c=Ot(r,s),l=new Map;c.forEach((e,t)=>{let n=St(e);l.has(n)||l.set(n,t)});let u=[...t.keys()].filter(e=>n.get(e)===`test`).toSorted((e,t)=>(l.get(kt(e))??2**53-1)-(l.get(kt(t))??2**53-1)||e.localeCompare(t)),d=[...t.keys()].filter(e=>n.get(e)===`generated`).toSorted((e,t)=>e.localeCompare(t));return[...c,...u,...d].map(e=>t.get(e))}function jt(e,t,n){return e.hunks.some(e=>t===`left`?n>=e.deletionStart&&n<e.deletionStart+e.deletionCount:n>=e.additionStart&&n<e.additionStart+e.additionCount)}function Mt(e,t,n){let r=t!==`expanded`;return n.has(e)?!r:r}function Nt(e,t,n,r){let i=t-(n===`left`?r.oldLine:r.newLine);return i>=0&&i<e.lines?{kind:`context`,oldLine:r.oldLine+i,newLine:r.newLine+i,side:n}:null}function Pt(e,t,n,r){let i=n===`left`?r.oldLine:r.newLine,a=n===`left`?e.deletions:e.additions;return t>=i&&t<i+a?n===`left`?{kind:`deleted`,oldLine:t}:{kind:`added`,newLine:t}:null}function Ft(e,t){return e.type===`context`?{oldLine:t.oldLine+e.lines,newLine:t.newLine+e.lines}:{oldLine:t.oldLine+e.deletions,newLine:t.newLine+e.additions}}function It(e,t,n){let r={oldLine:e.deletionStart,newLine:e.additionStart};for(let i of e.hunkContent){let e=i.type===`context`?Nt(i,t,n,r):Pt(i,t,n,r);if(e!==null)return e;r=Ft(i,r)}return null}function Lt(e,t,n){let r=n===`deletions`?`left`:`right`;for(let n of e.hunks){let e=It(n,t,r);if(e!==null)return e}return null}function Rt(e){let t=(0,$.c)(7),n;return t[0]!==e.annotation.comment||t[1]!==e.annotation.kind||t[2]!==e.annotation.thread||t[3]!==e.environmentId||t[4]!==e.permissions||t[5]!==e.reference?(n=e.annotation.kind===`thread`?(0,Q.jsx)(C,{environmentId:e.environmentId,reference:e.reference,thread:e.annotation.thread,canReply:e.permissions.canReply,canResolve:e.permissions.canResolve,reactionsEnabled:e.permissions.reactionsEnabled}):(0,Q.jsx)(zt,{body:e.annotation.comment.body}),t[0]=e.annotation.comment,t[1]=e.annotation.kind,t[2]=e.annotation.thread,t[3]=e.environmentId,t[4]=e.permissions,t[5]=e.reference,t[6]=n):n=t[6],n}function zt(e){let t=(0,$.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(`p`,{className:`text-xs font-medium text-info-foreground`,children:`Pending review comment`}),t[0]=n):n=t[0];let r;return t[1]===e.body?r=t[2]:(r=(0,Q.jsxs)(`article`,{className:`rounded-md border border-info-border bg-info-surface p-3`,children:[n,(0,Q.jsx)(v,{text:e.body,className:`mt-1`})]}),t[1]=e.body,t[2]=r),r}function Bt(e){let t=(0,$.c)(10),n;t[0]!==e.file||t[1]!==e.omittedStats?(n=Vt(e.file,e.omittedStats),t[0]=e.file,t[1]=e.omittedStats,t[2]=n):n=t[2];let{additions:r,deletions:i}=n,a;t[3]===r?a=t[4]:(a=(0,Q.jsxs)(`span`,{className:`text-success-foreground`,children:[`+`,r]}),t[3]=r,t[4]=a);let o;t[5]===i?o=t[6]:(o=(0,Q.jsxs)(`span`,{className:`text-destructive-foreground`,children:[`−`,i]}),t[5]=i,t[6]=o);let s;return t[7]!==a||t[8]!==o?(s=(0,Q.jsxs)(`span`,{className:`flex gap-1 font-mono text-[11px] tabular-nums`,children:[a,o]}),t[7]=a,t[8]=o,t[9]=s):s=t[9],s}function Vt(e,t){let n=e.hunks.reduce((e,t)=>({additions:e.additions+t.additionLines,deletions:e.deletions+t.deletionLines}),{additions:0,deletions:0});return n.additions===0&&n.deletions===0?t.get(J(e))??n:n}function Ht(e){let t=(0,$.c)(9),n=e.item.collapsed===!0,r=n?`Expand file`:`Collapse file`,a=!n,o;t[0]===e?o=t[1]:(o=()=>e.onToggleFile(e.item.id),t[0]=e,t[1]=o);let s;t[2]===n?s=t[3]:(s=n?(0,Q.jsx)(ne,{className:`size-3.5`}):(0,Q.jsx)(i,{className:`size-3.5`}),t[2]=n,t[3]=s);let c;return t[4]!==r||t[5]!==a||t[6]!==o||t[7]!==s?(c=(0,Q.jsx)(S,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":r,"aria-expanded":a,onClick:o,children:s}),t[4]=r,t[5]=a,t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function Ut(e){let t=(0,$.c)(2),n;return t[0]===e.threads?n=t[1]:(n=e.threads.length>0?(0,Q.jsxs)(`section`,{className:`border-b border-warning-border bg-warning-surface px-3 py-2 text-xs text-warning-foreground`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,Q.jsx)(y,{className:`size-3.5`}),`Conversations not on the diff loaded so far`]}),e.threads.map(Wt)]}):null,t[0]=e.threads,t[1]=n),n}function Wt(e){return(0,Q.jsxs)(`p`,{className:`mt-1 truncate`,children:[e.path,e.line===null?``:`:${e.line}`,e.isOutdated?` · outdated`:``]},e.id)}function Gt(e){let t=(0,$.c)(2),n;return t[0]===e.children?n=t[1]:(n=(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-center text-sm text-muted-foreground`,children:e.children}),t[0]=e.children,t[1]=n),n}function Kt(e){let t=(0,$.c)(7),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={diffHeaderHeight:32,hunkSeparatorHeight:24,spacing:0,paddingTop:0,paddingBottom:8},r={paddingTop:0,paddingBottom:0,gap:0},t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;t[2]===e.options?i=t[3]:(i={...e.options,unsafeCSS:`[data-diffs-header]{position:sticky!important;top:0;z-index:4;background:var(--background)!important;border-bottom:1px solid var(--border)!important}`,itemMetrics:n,layout:r},t[2]=e.options,t[3]=i);let a;return t[4]!==e||t[5]!==i?(a=(0,Q.jsx)(Xe,{...e,options:i}),t[4]=e,t[5]=i,t[6]=a):a=t[6],a}function qt(e){return[...e.threads.flatMap(t=>Yt(e.file,t)),...e.pendingComments.flatMap(t=>Zt(e.file,t))]}function Jt(e,t){return e.some(e=>Xt(e,t))}function Yt(e,t){return Xt(e,t)?[{side:$t(t.side),lineNumber:t.line,metadata:{kind:`thread`,thread:t}}]:[]}function Xt(e,t){return[!t.isOutdated,t.line!==null,J(e)===t.path,t.line!==null&&jt(e,t.side,t.line)].every(Boolean)}function Zt(e,t){if(J(e)!==t.path)return[];let n=Qt(t);return n===null||!jt(e,n.side,n.line)?[]:[{side:$t(n.side),lineNumber:n.line,metadata:{kind:`pending`,comment:t}}]}function Qt(e){switch(e.position.kind){case`added`:return{side:`right`,line:e.position.newLine};case`deleted`:return{side:`left`,line:e.position.oldLine};case`context`:return e.position.side===`left`?{side:`left`,line:e.position.oldLine}:{side:`right`,line:e.position.newLine}}}function $t(e){return e===`left`?`deletions`:`additions`}function en(e){return tn[nn(e)](e)}var tn={loading:()=>(0,Q.jsx)(V,{label:`Loading pull request diff…`}),error:e=>(0,Q.jsx)(Gt,{children:e.error?.message??`Pull request diff could not be loaded.`}),empty:()=>(0,Q.jsx)(Gt,{children:`This pull request has no file changes.`}),loaded:e=>(0,Q.jsx)(cn,{...e})};function nn(e){return rn(e)?`loading`:an(e)?`error`:on(e)?`empty`:`loaded`}function rn(e){return e.loading&&e.slices.length===0}function an(e){return e.error!==null&&e.slices.length===0}function on(e){return!sn({itemCount:e.items.length,rawCount:e.raw.length,withheld:e.withheld})}function sn(e){return e.itemCount>0||e.rawCount>0||e.withheld}function cn(e){let t=(0,$.c)(12),n,r;t[0]===e?(n=t[1],r=t[2]):(n=(0,Q.jsx)(ln,{...e}),r=e.items.length>0?(0,Q.jsx)(fn,{...e}):null,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===e.raw?i=t[4]:(i=(0,Q.jsx)(hn,{raw:e.raw}),t[3]=e.raw,t[4]=i);let a;t[5]===e?a=t[6]:(a=(0,Q.jsx)(gn,{...e}),t[5]=e,t[6]=a);let o;return t[7]!==n||t[8]!==r||t[9]!==i||t[10]!==a?(o=(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[n,r,i,a]}),t[7]=n,t[8]=r,t[9]=i,t[10]=a,t[11]=o):o=t[11],o}function ln(e){let t=(0,$.c)(14),n;t[0]!==e.activity?.reviewThreads||t[1]!==e.files?(n=e.activity?.reviewThreads.filter(t=>!Jt(e.files,t)),t[0]=e.activity?.reviewThreads,t[1]=e.files,t[2]=n):n=t[2];let r=n,i;t[3]===e?i=t[4]:(i=e.error===null?null:(0,Q.jsx)(un,{...e,error:e.error}),t[3]=e,t[4]=i);let a;t[5]!==e.omittedFileCount||t[6]!==e.withheld?(a=e.withheld?(0,Q.jsx)(dn,{omittedFileCount:e.omittedFileCount}):null,t[5]=e.omittedFileCount,t[6]=e.withheld,t[7]=a):a=t[7];let o;t[8]===r?o=t[9]:(o=r===void 0?null:(0,Q.jsx)(Ut,{threads:r}),t[8]=r,t[9]=o);let s;return t[10]!==i||t[11]!==a||t[12]!==o?(s=(0,Q.jsxs)(Q.Fragment,{children:[i,a,o]}),t[10]=i,t[11]=a,t[12]=o,t[13]=s):s=t[13],s}function un(e){let t=(0,$.c)(8),n;t[0]===e.error.message?n=t[1]:(n=(0,Q.jsxs)(`span`,{children:[`More diff content could not be loaded: `,e.error.message]}),t[0]=e.error.message,t[1]=n);let r;t[2]!==e.hasNextPage||t[3]!==e.onLoadNextPage?(r=e.hasNextPage?(0,Q.jsx)(S,{type:`button`,size:`xs`,variant:`outline`,onClick:e.onLoadNextPage,children:`Retry`}):null,t[2]=e.hasNextPage,t[3]=e.onLoadNextPage,t[4]=r):r=t[4];let i;return t[5]!==n||t[6]!==r?(i=(0,Q.jsxs)(`section`,{className:`flex items-center justify-between gap-2 border-b border-destructive-border bg-destructive-surface px-3 py-2 text-xs text-destructive-foreground`,children:[n,r]}),t[5]=n,t[6]=r,t[7]=i):i=t[7],i}function dn(e){let t=(0,$.c)(2),n=e.omittedFileCount>0?` ${e.omittedFileCount} file statistics remain available.`:``,r;return t[0]===n?r=t[1]:(r=(0,Q.jsxs)(`section`,{className:`border-b border-warning-border bg-warning-surface px-3 py-2 text-xs text-warning-foreground`,children:[`Binary or oversized content was withheld by the provider.`,n]}),t[0]=n,t[1]=r),r}function fn(e){let t=(0,$.c)(14),n;t[0]===e.onToggleFile?n=t[1]:(n=t=>pn(t,e.onToggleFile),t[0]=e.onToggleFile,t[1]=n);let r;t[2]===e.omittedStats?r=t[3]:(r=t=>mn(t,e.omittedStats),t[2]=e.omittedStats,t[3]=r);let i;t[4]!==e.annotationPermissions||t[5]!==e.environmentId||t[6]!==e.reference?(i=t=>(0,Q.jsx)(Rt,{annotation:t.metadata,environmentId:e.environmentId,reference:e.reference,permissions:e.annotationPermissions}),t[4]=e.annotationPermissions,t[5]=e.environmentId,t[6]=e.reference,t[7]=i):i=t[7];let a;return t[8]!==e.items||t[9]!==e.viewOptions||t[10]!==n||t[11]!==r||t[12]!==i?(a=(0,Q.jsx)(Kt,{className:`h-full min-h-0 [scrollbar-gutter:stable]`,items:e.items,options:e.viewOptions,renderHeaderPrefix:n,renderHeaderMetadata:r,renderAnnotation:i}),t[8]=e.items,t[9]=e.viewOptions,t[10]=n,t[11]=r,t[12]=i,t[13]=a):a=t[13],a}function pn(e,t){return(0,Q.jsx)(Ht,{item:e,onToggleFile:t})}function mn(e,t){return e.type===`diff`?(0,Q.jsx)(Bt,{file:e.fileDiff,omittedStats:t}):null}function hn(e){return e.raw.map(e=>(0,Q.jsxs)(`pre`,{className:`m-3 whitespace-pre-wrap break-words rounded-md border border-warning-border bg-warning-surface p-3 font-mono text-xs text-warning-foreground`,children:[e.reason,`
1
+ (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`forge-web@0.9.10`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`24a85626-b86e-448f-8991-714315ce653a`,e._sentryDebugIdIdentifier=`sentry-dbid-24a85626-b86e-448f-8991-714315ce653a`)}catch{}})();import{r as e}from"./rolldown-runtime-BaTzPAyU.js";import{Ba as t,Va as n,za as r}from"./Stream-D8tJNlvy.js";import{Ht as i,Ut as a}from"./useTriggerFocusGuards-mvO6ygs-.js";import{E as o,Mr as s,Or as c,P as l,Tr as u,_r as d,b as f,c as p,f as m,hr as h,l as g,n as _,p as v,pr as y,s as b,t as x,tr as S,u as C,v as w}from"./DiffWorkerPoolProvider-lEFZi8QR.js";import{$t as T,As as E,Bs as D,Jt as O,Qt as k,Xt as A,Yt as j,Zt as M,_ as N,d as P,dn as F,en as I,es as L,hn as R,i as ee,m as z,mn as B,n as V,nn as H,on as U,rn as W,sn as G,u as te,un as K,ys as ne,z as re}from"./DiffPanelShell-R1Q66jTc.js";import{Mn as ie}from"./CompositeItem-Bsi2e5qV.js";import{f as ae,h as oe,l as se,m as q,n as ce,o as J,p as le,t as ue,u as de}from"./DiffPanel.logic-o7tDdTzf.js";function fe(e,t){return E(e,s,t)}function pe(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function me(e,t){return e==null||t==null?e===t:e.header!==t.header||e.footer!==t.footer?!1:he(e.items,t.items)}function he(e,t){if(e==null||t==null)return e===t;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r==null||i==null||r.id!==i.id||r.type!==i.type||r.element!==i.element||r.instance!==i.instance||r.version!==i.version)return!1}return!0}function ge(e,t,n){let r=document.createElement(`div`);return r.style.display=`flow-root`,e===`header`?(r.setAttribute(W,``),t.before(r)):(r.setAttribute(H,``),t.after(r)),n?.observe(r),r}function Y(e){let t=window.devicePixelRatio??1;return Math.round(e*t)/t}var _e=`theme.disableLineNumbers.overflow.themeType.disableFileHeader.disableVirtualizationBuffers.preferredHighlighter.useCSSClasses.useTokenTransformer.tokenizeMaxLineLength.tokenizeMaxLength.unsafeCSS.diffStyle.diffIndicators.disableBackground.expandUnchanged.loadDiffFiles.collapsedContextThreshold.lineDiffType.maxLineDiffLength.expansionLineCount.lineHoverHighlight.enableTokenInteractionsOnWhitespace.enableGutterUtility.__debugPointerEvents.enableLineSelection.controlledSelection.disableErrorHandling`.split(`.`),ve=[`theme`,`disableLineNumbers`,`overflow`,`themeType`,`disableFileHeader`,`disableVirtualizationBuffers`,`preferredHighlighter`,`useCSSClasses`,`useTokenTransformer`,`tokenizeMaxLineLength`,`tokenizeMaxLength`,`unsafeCSS`,`lineHoverHighlight`,`enableTokenInteractionsOnWhitespace`,`enableGutterUtility`,`__debugPointerEvents`,`enableLineSelection`,`controlledSelection`,`disableErrorHandling`],ye=[`renderCustomHeader`,`renderHeaderPrefix`,`renderHeaderFilenameSuffix`,`renderHeaderMetadata`,`renderAnnotation`,`renderGutterUtility`,`onPostRender`,`onGutterUtilityClick`,`onLineClick`,`onLineNumberClick`,`onLineEnter`,`onLineLeave`,`onTokenClick`,`onTokenEnter`,`onTokenLeave`],be=[`onLineSelected`,`onLineSelectionStart`,`onLineSelectionChange`,`onLineSelectionEnd`],xe=Symbol(`CodeView.itemOptionsState`);function Se(e,t){Object.defineProperty(e,xe,{configurable:!1,enumerable:!1,value:t})}function Ce(e){return e[xe]}function X(e,t,n){Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get(){return n(this)}})}var we=120,Te=1,Ee=`--diffs-overflow-override`,De=12e6,Oe=1e6,ke=2e6,Ae=1e7,je=11e6;function Me(e){if(e==null)throw Error(`CodeView: createEditor is required for items with edit: true`)}var Ne=(()=>{let{navigator:e}=globalThis,t=e.userAgent,n=/iP(?:hone|ad|od)/.test(t),r=e.platform===`MacIntel`&&e.maxTouchPoints>1;return(n||r)&&/AppleWebKit/.test(t)&&/Safari/.test(t)&&!/(CriOS|FxiOS|EdgiOS|OPiOS)/.test(t)})(),Pe=class e{static __STOP=!1;static __lastScrollPosition=0;type=`advanced`;config={overscrollSize:200,intersectionObserverMargin:0,resizeDebugging:!1};items=[];idToItem=new Map;selectedLines=null;itemEditors=new Map;attachedEditors=new Set;instanceToItem=new Map;layoutDirtyIndex;pendingLayoutReset;renderOptionsRevision=0;slotCoordinator;slotSnapshot;scrollListeners=new Set;scrollHeight=0;containerHeight=-1;scrollTop=0;scrollPageOffset=0;scrollDirty=!0;scrollInteractionFixTimer;pointerEventsDisabled=!1;codeOverflowFix=!1;height=0;heightDirty=!0;windowSpecs={top:0,bottom:0};renderState={scrollTop:-1,firstIndex:-1,lastIndex:-1,stickyHeight:0,stickyTop:-1,stickyBottom:-1};itemMetricsCache=U;fileOptionsPrototype;diffOptionsPrototype;pendingScrollTarget;pendingLayoutAnchor;shouldFixContainerFocus=!1;scrollAnimation;root;resizeObserver;container=document.createElement(`div`);stickyContainer=document.createElement(`div`);stickyOffset=document.createElement(`div`);header={element:void 0,render:void 0,height:0};footer={element:void 0,render:void 0,height:0};elementPool=[];elementPoolVersion=0;elementPoolTracker=new WeakMap;pendingElementPool=[];options;workerManager;isReadySubscription;isContainerManaged;constructor(e={theme:F},t,n=!1){this.options=e,this.computeMetricsCache(e.itemMetrics),this.fileOptionsPrototype=this.createFileOptionsPrototype(),this.diffOptionsPrototype=this.createDiffOptionsPrototype(),this.workerManager=t,this.isContainerManaged=n,this.stickyOffset.style.contain=`layout size`,this.stickyContainer.style.position=`sticky`,this.stickyContainer.style.width=`100%`,this.stickyContainer.style.contain=`layout style inline-size`,this.stickyContainer.style.isolation=`isolate`,this.stickyContainer.style.display=`flex`,this.stickyContainer.style.flexDirection=`column`}getLayout(){return this.options.layout??G}getItemTopOffset(){return this.getLayout().paddingTop+this.header.height}computeMetricsCache(e){return this.itemMetricsCache={hunkLineCount:e?.hunkLineCount??U.hunkLineCount,lineHeight:e?.lineHeight??U.lineHeight,diffHeaderHeight:e?.diffHeaderHeight??U.diffHeaderHeight,hunkSeparatorHeight:e?.hunkSeparatorHeight,spacing:e?.spacing??U.spacing,paddingTop:e?.paddingTop,paddingBottom:e?.paddingBottom},this.itemMetricsCache}getSmoothScrollSettings(){return this.options.smoothScrollSettings??K}shouldDisablePointerEvents(){return this.options.pointerEventsOnScroll!==!0}shouldValidateItemHeights(){return B&&this.options.__devOnlyValidateItemHeights===!0}validateRenderedItemHeight(e){if(!this.shouldValidateItemHeights()||e.element==null)return;let t=e.instance.getAdvancedStickySpecs();if(t==null)return;let n=t.height,r=e.element.getBoundingClientRect().height;n!==r&&console.error(`CodeView: reconciled item height does not match DOM height`,{id:e.item.id,type:e.type,index:e.index,version:e.version,expectedHeight:n,actualHeight:r,delta:r-n,stickyTopOffset:t.topOffset,virtualizedHeight:e.instance.getVirtualizedHeight(),top:e.top,scrollTop:this.getScrollTop(),windowSpecs:{...this.windowSpecs},element:e.element,instance:e.instance})}validateStickyContainerHeight(){if(!this.shouldValidateItemHeights())return;let{firstIndex:e,lastIndex:t,stickyHeight:n,stickyTop:r,stickyBottom:i}=this.renderState;if(e===-1||t===-1)return;let a=this.stickyContainer.getBoundingClientRect().height;Math.abs(a-n)<Te||console.error(`CodeView: sticky container height does not match computed layout`,{computedStickyHeight:n,actualStickyHeight:a,delta:a-n,stickyTop:r,stickyBottom:i,firstIndex:e,lastIndex:t,firstStickySpecs:this.items[e]?.instance.getAdvancedStickySpecs(),lastStickySpecs:this.items[t]?.instance.getAdvancedStickySpecs(),scrollTop:this.getScrollTop(),scrollPageOffset:this.scrollPageOffset,windowSpecs:{...this.windowSpecs},stickyContainer:this.stickyContainer})}clearScrollInteractionTimer(){this.scrollInteractionFixTimer!=null&&(clearTimeout(this.scrollInteractionFixTimer),this.scrollInteractionFixTimer=void 0)}suspendScrollInteractions(){this.clearScrollInteractionTimer(),this.shouldDisablePointerEvents()&&!this.pointerEventsDisabled&&(this.stickyContainer.style.pointerEvents=`none`,this.pointerEventsDisabled=!0),Ne&&!this.codeOverflowFix&&(this.stickyContainer.style.setProperty(Ee,`hidden`),this.codeOverflowFix=!0),this.scrollInteractionFixTimer=setTimeout(this.restoreScrollInteractions,we)}restoreScrollInteractions=()=>{this.clearScrollInteractionTimer(),this.pointerEventsDisabled&&=(this.stickyContainer.style.removeProperty(`pointer-events`),!1),this.codeOverflowFix&&=(this.stickyContainer.style.setProperty(Ee,`auto`),!1)};syncLayout(){let{gap:e,paddingBottom:t,paddingTop:n}=this.getLayout();this.stickyContainer.style.gap=`${e}px`,this.container?.style.setProperty(`margin-top`,`${n}px`),this.container?.style.setProperty(`margin-bottom`,`${t}px`)}reconcileHeaderFooterHosts(){let e=this.reconcileHost(`header`),t=this.reconcileHost(`footer`);return e||t}reconcileHost(e){let{root:t,container:n}=this;if(t==null||n==null)return!1;let r=e===`header`?this.header:this.footer,i=e===`header`?this.options.renderCodeViewHeader:this.options.renderCodeViewFooter;if(i==null)return r.element!=null&&(this.resizeObserver?.unobserve(r.element),r.element.remove(),r.element=void 0,r.render=void 0,this.setHostHeight(r,0),!1);if(r.element!=null&&i===r.render)return!1;let a=r.element??ge(e,n,this.resizeObserver);r.element=a;let o=i();return o==null?!this.isContainerManaged&&a.children.length>0&&(a.textContent=``):a.replaceChildren(o),r.render=i,!0}setHostHeight(e,t){e.height!==t&&(e.height=t,this.scrollDirty=!0)}measureMountedHosts(){this.header.element!=null&&this.setHostHeight(this.header,this.header.element.getBoundingClientRect().height),this.footer.element!=null&&this.setHostHeight(this.footer,this.footer.element.getBoundingClientRect().height)}setup(t){if(this.root!=null)throw Error(`CodeView.setup: already setup`);this.workerManager?.subscribeToThemeChanges(this),this.root=t,this.root.style.overflowAnchor=`none`,this.root.hasAttribute(`tabindex`)||(this.root.tabIndex=-1),this.container??=document.createElement(`div`),this.container.style.contain=`layout style`,this.syncLayout(),this.container.appendChild(this.stickyOffset),this.container.appendChild(this.stickyContainer),this.root.appendChild(this.container),this.scrollDirty=!0,this.heightDirty=!0,this.resizeObserver=new ResizeObserver(this.handleResize),this.resizeObserver.observe(this.stickyContainer),this.root.addEventListener(`scroll`,this.handleScroll,{passive:!0}),this.root.addEventListener(`wheel`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`touchstart`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`pointerdown`,this.clearPendingScroll,{passive:!0}),this.root.addEventListener(`keydown`,this.clearPendingScroll,{passive:!0}),this.resizeObserver.observe(this.root),this.render(!0),window.__INSTANCE=this,window.__TOGGLE=()=>{e.__STOP?(e.__STOP=!1,this.scrollTo({type:`position`,position:e.__lastScrollPosition,behavior:`instant`})):(e.__lastScrollPosition=this.getScrollTop(),e.__STOP=!0)}}reset(){T(this.computeRenderRangeAndEmit),this.clearReadySubscription(),this.restoreScrollInteractions(),this.cleanAllRenderedItems();for(let e of this.itemEditors.values())e.editor.cleanUp();this.itemEditors.clear(),this.attachedEditors.clear(),this.selectedLines=null,this.items.length=0,this.idToItem.clear(),this.instanceToItem.clear(),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,this.stickyContainer.textContent=``,this.stickyOffset.style.height=``,this.container?.style.removeProperty(`height`),this.containerHeight=-1,this.windowSpecs={top:0,bottom:0},this.pendingLayoutAnchor=void 0,this.shouldFixContainerFocus=!1,this.height=0,this.scrollTop=0,this.scrollPageOffset=0,this.scrollHeight=0,this.scrollDirty=!0,this.heightDirty=!0,this.resetRenderState(),this.isContainerManaged||this.flushSlotCoordinator()}cleanUp(){this.reset(),this.clearElementPool(),this.restoreScrollInteractions(),this.workerManager?.unsubscribeToThemeChanges(this),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.root?.removeEventListener(`scroll`,this.handleScroll),this.root?.removeEventListener(`wheel`,this.clearPendingScroll),this.root?.removeEventListener(`touchstart`,this.clearPendingScroll),this.root?.removeEventListener(`pointerdown`,this.clearPendingScroll),this.root?.removeEventListener(`keydown`,this.clearPendingScroll),this.root?.style.removeProperty(`overflow-anchor`),this.container?.remove(),this.stickyOffset.remove(),this.stickyContainer.remove(),this.stickyContainer.textContent=``,this.header.element?.remove(),this.header.element=void 0,this.header.render=void 0,this.header.height=0,this.footer.element?.remove(),this.footer.element=void 0,this.footer.render=void 0,this.footer.height=0,this.root=void 0,this.container=void 0}cleanAllRenderedItems(){if(this.renderState.firstIndex!==-1)for(let e=this.renderState.firstIndex;e<=this.renderState.lastIndex;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.cleanAllRenderedItems: Item does not exist at index: ${e}`);this.releaseRenderedItem(t)}}primeScrollTarget(e){e.type!==`position`&&this.idToItem.get(e.id)?.instance.primeHighlightCache()}getElementPoolLimit(){let e=this.getHeight()+this.config.overscrollSize*2,{diffHeaderHeight:t}=this.itemMetricsCache;return Math.max(8,Math.ceil(e/Math.max(t,10))+1)*(this.isContainerManaged?2:1)}acquireElement(){this.promotePendingPooledElements();let e=this.elementPool.pop();for(;e!=null&&!this.isElementPoolGenerationCurrent(e);)e=this.elementPool.pop();return e??=document.createElement(R),this.markElementPoolGenerationCurrent(e),e}releaseRenderedItem(e){let{element:t}=e;t!=null&&this.renderedItemOwnsFocus(t)&&(this.shouldFixContainerFocus=!0),e.instance.cleanUp(!0),this.attachedEditors.delete(e.item.id),e.element=void 0,t!=null&&(t.remove(),this.cleanElement(t),this.queueElementForPool(t))}renderedItemOwnsFocus(e){let{activeElement:t}=document;return t===e||e.contains(t)||e.shadowRoot?.activeElement!=null}fixContainerFocus(){this.shouldFixContainerFocus&&(this.shouldFixContainerFocus=!1,this.root?.focus({preventScroll:!0}))}cleanElement(e){let{shadowRoot:t}=e;if(t!=null)for(let e of Array.from(t.children))ze(e)||e.remove();this.isContainerManaged||e.replaceChildren()}queueElementForPool(e){let t=this.getElementPoolLimit();!this.isElementPoolGenerationCurrent(e)||this.getElementPoolSize()>=t||(this.isElementClean(e)?this.elementPool.push(e):this.pendingElementPool.push(e))}promotePendingPooledElements(){if(this.pendingElementPool.length===0)return;let{pendingElementPool:e}=this;this.pendingElementPool=[];let t=this.getElementPoolLimit();for(let n of e)this.isElementPoolGenerationCurrent(n)&&this.isElementClean(n)&&this.elementPool.length<t?this.elementPool.push(n):this.isElementPoolGenerationCurrent(n)&&this.getElementPoolSize()<t&&this.pendingElementPool.push(n)}isElementClean(e){return e.childNodes.length===0}getElementPoolSize(){return this.elementPool.length+this.pendingElementPool.length}clearElementPool(){this.elementPool.length=0,this.pendingElementPool.length=0}invalidateElementPool(){this.elementPoolVersion++,this.clearElementPool()}markElementPoolGenerationCurrent(e){this.elementPoolTracker.set(e,this.elementPoolVersion)}isElementPoolGenerationCurrent(e){return this.elementPoolTracker.get(e)===this.elementPoolVersion}resolveEffectiveScrollBehavior(e,t){return pe()?`instant`:e.behavior===`smooth-auto`?Math.abs(t-this.getScrollTop())<=this.getHeight()*10?`smooth`:`instant`:e.behavior??`instant`}scrollTo(e){if(this.root==null)return;let t=this.normalizeScrollTarget(e);if(t==null)return;let n=this.resolveScrollTargetTop(t);n!=null&&(this.primeScrollTarget(t),this.resolveEffectiveScrollBehavior(t,n)===`smooth`?this.scrollAnimation??={position:this.getScrollTop(),velocity:0,lastTimestamp:performance.now()}:this.scrollAnimation=void 0,this.suspendScrollInteractions(),this.pendingLayoutAnchor=void 0,this.pendingScrollTarget=t,this.render())}setSelectedLines(e,t){this.applySelectedLines(e,t)}getSelectedLines(){return this.selectedLines}clearSelectedLines(e){this.applySelectedLines(null,e)}getItem(e){return this.idToItem.get(e)?.item}getEditor(e){return this.itemEditors.get(e)?.editor}updateItem(e){let t=this.idToItem.get(e.id);return t==null?(console.error(`CodeView.updateItem: unknown item id "${e.id}"`),!1):this.syncItemRecord(t,e)?(this.markItemLayoutDirty(t),this.scrollDirty=!0,this.render(),this.syncItemEditors(),this.syncSelection(),!0):!1}updateItemId(e,t){if(e===t)return!0;let n=this.idToItem.get(e);if(n==null)return console.error(`CodeView.updateItemId: unknown item id "${e}"`),!1;if(this.idToItem.has(t))return console.error(`CodeView.updateItemId: duplicate item id "${t}"`),!1;this.idToItem.delete(e),n.item.id=t,this.idToItem.set(t,n),this.updateItemOptionsId(n.instance.options,t),this.selectedLines?.id===e&&(this.selectedLines={...this.selectedLines,id:t},this.options.onSelectedLinesChange?.(this.selectedLines));let r=this.itemEditors.get(e);return r!=null&&(r.state.id=t,this.itemEditors.delete(e),this.itemEditors.set(t,r),this.attachedEditors.delete(e)&&this.attachedEditors.add(t)),this.renamePendingScrollTarget(e,t),this.renamePendingLayoutAnchor(e,t),this.render(),!0}addItem(e){this.addItems([e])}addItems(e){this.appendItemsInternal(e),this.syncItemEditors(),this.syncSelection()}removeItem(e){let t=this.idToItem.get(e);if(t==null)return console.error(`CodeView.removeItem: unknown item id "${e}"`),!1;let n=[];for(let e of this.items)e!==t&&n.push(e.item);return this.setItems(n),!0}setItems(e){let t;this.items.length===0?this.appendItemsInternal(e):this.tryAppendItems(e)||(t=this.reconcileItems(e)),this.syncItemEditors(t),this.syncSelection()}appendItemsInternal(e,t=!0){if(e.length===0)return;let n=this.getLayout(),r=this.items.length===0?0:this.scrollHeight+n.gap,i=r;for(let t=0;t<e.length;t++){let i=e[t];if(i==null)throw Error(`CodeView.appendItemsInternal: missing input item`);if(this.idToItem.has(i.id))throw Error(`CodeView.addItem: duplicate id "${i.id}"`);let a=this.createItem(i,this.items.length,r);this.items.push(a),this.idToItem.set(a.item.id,a),this.instanceToItem.set(a.instance,a),a.height=Fe(a),r+=a.height+n.gap}this.scrollHeight=r-n.gap,this.scrollDirty=!0,t&&(this.canSkipRenderForAppend(i)?this.syncContainerHeight():this.render())}canSkipRenderForAppend(e){return this.container!=null&&this.renderState.firstIndex!==-1&&this.pendingScrollTarget==null&&this.scrollAnimation==null&&this.layoutDirtyIndex==null&&e>this.windowSpecs.bottom}onThemeChange(){this.invalidateElementPool()}setOptions(e){if(e==null)return;this.capturePendingLayoutAnchor();let{options:t}=this,n=this.getLayout(),{itemMetricsCache:r}=this;Ie(t,e)&&this.invalidateElementPool(),this.options=e;let i=this.computeMetricsCache(e.itemMetrics),a=!k(r,i),o=!k(n,this.getLayout());o&&this.syncLayout();let s=a||Le(t,e);if(s){let n=this.pendingLayoutReset;this.pendingLayoutReset={metrics:a?i:n?.metrics,resetFileLayoutCache:!0,resetDiffLayoutCache:!0,includeEstimatedDiffHeights:n?.includeEstimatedDiffHeights===!0||a||Re(t,e)}}(o||s)&&(this.markLayoutDirtyFromIndex(0),this.scrollDirty=!0),A(t,e)||this.renderOptionsRevision++,this.syncItemEditors();let c=t.renderCodeViewHeader!==e.renderCodeViewHeader||t.renderCodeViewFooter!==e.renderCodeViewFooter;!this.isContainerManaged&&(this.items.length>0||c)&&this.render()}capturePendingLayoutAnchor(e=this.idToItem){this.root!=null&&this.items.length!==0&&this.pendingScrollTarget==null&&(this.pendingLayoutAnchor=this.getScrollAnchor(this.getScrollTop(),e))}render(t=!1){e.__STOP||(t?(T(this.computeRenderRangeAndEmit),this.computeRenderRangeAndEmit()):I(this.computeRenderRangeAndEmit))}isReady(){let{workerManager:e}=this;return e==null||e.isInitialized()||e.getStats().workersFailed?(this.clearReadySubscription(),!0):(this.isReadySubscription??=e.subscribeToStatChanges(e=>{e.managerState!==`initialized`&&!e.workersFailed||(this.clearReadySubscription(),this.render(!0))}),e.getStats().managerState===`waiting`&&e.initialize().catch(()=>{}),!1)}clearReadySubscription(){this.isReadySubscription!=null&&(this.isReadySubscription(),this.isReadySubscription=void 0)}instanceChanged(e,t){let n=this.instanceToItem.get(e);if(n==null)throw Error(`CodeView.instanceChanged: An instance has changed that is not registered`);t&&this.markItemLayoutDirty(n),this.render()}getWindowSpecs(){return this.windowSpecs}getContainerElement(){return this.root}getHeaderElement(){return this.header.element}getFooterElement(){return this.footer.element}getRenderedItems(){let{firstIndex:e,lastIndex:t}=this.renderState;if(e===-1||t===-1||t<e)return[];let n=[];for(let r=e;r<=t;r++){let e=this.items[r];e?.element!=null&&(e.type===`diff`?n.push({id:e.item.id,type:`diff`,item:e.item,version:e.version,element:e.element,instance:e.instance}):n.push({id:e.item.id,type:`file`,item:e.item,version:e.version,element:e.element,instance:e.instance}))}return n}setSlotCoordinator(e){return e!==this.slotCoordinator&&(this.slotCoordinator=e,this.slotSnapshot=void 0,!0)}getSlotSnapshot(e){return this.buildSlotSnapshot(e)}buildSlotSnapshot(e){let t=Ge(this.getRenderedItems(),e),{element:n}=this.header,{element:r}=this.footer;if(t!=null||n!=null||r!=null)return{items:t,header:n,footer:r}}subscribeToScroll(e){return this.scrollListeners.add(e),()=>{this.scrollListeners.delete(e)}}getLocalTopForInstance(e){let t=this.instanceToItem.get(e);if(t==null)throw Error(`CodeView.getLocalTopForInstance: unknown virtualized instance`);return t.top}getTopForItem(e){let t=this.idToItem.get(e);if(t!=null)return t.top+this.getItemTopOffset()}createItem(e,t,n){let{itemMetricsCache:r}=this;if(e.type===`diff`){let i=new de(this.createDiffOptions(e.id),this,r,this.workerManager,this.isContainerManaged);return{type:`diff`,item:e,version:e.version,index:t,top:n,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:i}}let i=new l(this.createFileOptions(e.id),this,r,this.workerManager,this.isContainerManaged);return{type:`file`,item:e,version:e.version,index:t,top:n,height:0,element:void 0,renderedOptionsRevision:this.renderOptionsRevision,instance:i}}applySelectedLines(e,t){let{selectedLines:n}=this;e==null&&n==null||e!=null&&n?.id===e.id&&j(n.range,e.range)||(n!=null&&n.id!==e?.id&&this.idToItem.get(n.id)?.instance.setSelectedLines(null,{notify:!1}),this.selectedLines=e,this.idToItem.get(e?.id??``)?.instance.setSelectedLines(e?.range??null,t))}syncSelection(){if(this.selectedLines==null)return;let e=this.idToItem.get(this.selectedLines.id);if(e==null){this.selectedLines=null,this.options.onSelectedLinesChange?.(null);return}e.instance.setSelectedLines(this.selectedLines.range,{notify:!1})}isItemInEditMode(e){return e.item.edit===!0&&e.item.collapsed!==!0}attachItemEditor(e){let{id:t}=e.item,{createEditor:n}=this.options;if(e.element==null||this.attachedEditors.has(t)||!this.isItemInEditMode(e))return;let r=this.itemEditors.get(t),i=!1;try{if(r==null){Me(n);let e={id:t},a=n({onChange:(t,n)=>{let r=this.idToItem.get(e.id);r!=null&&(e.lastChange={item:r.item,file:t,lineAnnotations:n},this.options.onItemEditChange?.(r.item,t,n))}});if(a==null)return;r={editor:a,state:e},this.itemEditors.set(t,r),i=!0}r.editor.edit(e.instance),this.attachedEditors.add(t)}catch(n){throw i&&r!=null&&(this.itemEditors.delete(t),r.editor.cleanUp()),this.releaseRenderedItem(e),n}}syncItemEditors(e){if(this.itemEditors.size===0)return;let t=[];for(let[n,r]of this.itemEditors){let i=this.idToItem.get(n),a=e?.get(n);if(a==null&&i!=null&&this.isItemInEditMode(i))continue;r.editor.cleanUp(),this.itemEditors.delete(n),this.attachedEditors.delete(n);let{lastChange:o}=r.state,s=a==null?i?.item??o?.item:o?.item??a.item;s?.type===`diff`&&(a==null&&i!=null&&i.type===`diff`&&i.instance.completeEditSession()&&(this.markItemLayoutDirty(i),this.render()),ae(s.fileDiff)),o!=null&&t.push(a!=null||i==null?o:{...o,item:i.item})}for(let{item:e,file:n,lineAnnotations:r}of t)this.options.onItemEditComplete?.(e,n,r)}renamePendingScrollTarget(e,t){let{pendingScrollTarget:n}=this;n!=null&&n.type!==`position`&&n.id===e&&(this.pendingScrollTarget={...n,id:t})}renamePendingLayoutAnchor(e,t){this.pendingLayoutAnchor?.id===e&&(this.pendingLayoutAnchor.id=t)}createFileOptionsPrototype(){let e={};for(let t of ve)X(e,t,()=>this.options[t]);X(e,`stickyHeader`,()=>this.options.stickyHeaders),X(e,`collapsed`,e=>{let t=Ce(e);if(t!=null)return this.getItemOptions(t,`file`)?.item.collapsed});for(let t of ye)this.defineItemSharedCallback(e,`file`,t);for(let t of be)this.defineItemSelectionCallback(e,`file`,t);return e}createDiffOptionsPrototype(){let e={};for(let t of _e)X(e,t,()=>this.options[t]);X(e,`stickyHeader`,()=>this.options.stickyHeaders),X(e,`hunkSeparators`,()=>this.options.hunkSeparators),X(e,`collapsed`,e=>{let t=Ce(e);if(t!=null)return this.getItemOptions(t,`diff`)?.item.collapsed});for(let t of ye)this.defineItemSharedCallback(e,`diff`,t);for(let t of be)this.defineItemSelectionCallback(e,`diff`,t);return e}createFileOptions(e){let t=Object.create(this.fileOptionsPrototype);return Se(t,{id:e}),t}createDiffOptions(e){let t=Object.create(this.diffOptionsPrototype);return Se(t,{id:e}),t}updateItemOptionsId(e,t){let n=Ce(e);if(n==null)throw Error(`CodeView.updateItemOptionsId: No valid state`);n.id=t}getItemOptions(e,t){let n=this.idToItem.get(e.id);if(n!=null&&n.type===t)return n}defineItemSharedCallback(e,t,n){X(e,n,e=>{if(this.options[n]==null)return;let r=Ce(e);if(r==null)return;let i=r.callbackCache??={},a=i[n];return a??(a=((...e)=>{let i=this.getItemOptions(r,t);if(i==null)return;let a=this.options[n];return a?.(...e,i)}),i[n]=a),a})}defineItemSelectionCallback(e,t,n){X(e,n,e=>{let r=Ce(e);if(r==null)return;let i=r.callbackCache??={},a=i[n];return a??(a=(e=>{let i=this.getItemOptions(r,t);if(i==null)return;let a=e==null?null:{id:i.item.id,range:e};this.options.controlledSelection!==!0&&(e!=null||this.selectedLines?.id===i.item.id)&&this.applySelectedLines(a,{notify:!1}),this.options.onSelectedLinesChange?.(a);let o=this.options[n];return o?.(e,i)}),i[n]=a),a})}markLayoutDirtyFromIndex(e){this.layoutDirtyIndex=Math.min(this.layoutDirtyIndex??e,e)}markItemLayoutDirty(e){if(this.items[e.index]!==e)throw Error(`CodeView.markItemLayoutDirty: unknown item id "${e.item.id}"`);this.markLayoutDirtyFromIndex(e.index)}tryAppendItems(e){if(e.length<=this.items.length)return!1;for(let t=0;t<this.items.length;t++){let n=this.items[t];if(n==null)throw Error(`CodeView.tryAppendItems: missing existing item`);let r=e[t];if(r==null||n.item.id!==r.id||n.type!==r.type)return!1}for(let t=0;t<this.items.length;t++){let n=this.items[t];if(n==null)throw Error(`CodeView.tryAppendItems: missing existing item`);let r=e[t];if(r==null)throw Error(`CodeView.tryAppendItems: append candidate missing prefix item`);this.syncItemRecord(n,r)&&this.markLayoutDirtyFromIndex(t)}return this.appendItemsInternal(e.slice(this.items.length),!1),this.scrollDirty=!0,this.render(),!0}reconcileItems(e){let{items:t,idToItem:n}=this,r=new Set(t),i=[],a=new Map,o=new Map,s=new Map,c;for(let s=0;s<e.length;s++){let l=e[s];if(l==null)throw Error(`CodeView.reconcileItems: missing input item`);if(a.has(l.id))throw Error(`CodeView.setItems: duplicate id "${l.id}"`);let u=n.get(l.id),d=u!=null&&u.type===l.type?u:this.createItem(l,s,0);d.index=s,u!=null&&u.type===l.type?(r.delete(u),this.syncItemRecord(d,l)&&(c=Math.min(c??s,s))):c=Math.min(c??s,s),t[s]!==d&&(c=Math.min(c??s,s)),i.push(d),a.set(l.id,d),o.set(d.instance,d)}if(c==null){if(r.size===0)return;c=Math.max(i.length-1,0)}this.capturePendingLayoutAnchor(a);for(let e=0;e<t.length;e++){let n=t[e];if(n==null||!r.has(n))continue;s.set(n.item.id,n),this.releaseRenderedItem(n);let a=Math.max(i.length-1,0);c=Math.min(c??a,a)}return this.items=i,this.idToItem=a,this.instanceToItem=o,this.renderState.firstIndex>=i.length?this.resetRenderState():this.renderState.lastIndex>=i.length&&(this.renderState.lastIndex=i.length-1),this.markLayoutDirtyFromIndex(c),this.scrollDirty=!0,this.render(),s.size>0?s:void 0}syncItemRecord(e,t){if(e.type!==t.type)throw Error(`CodeView.syncItemRecord: type mismatch for id "${t.id}"`);return e.version!==t.version&&(e.item=t,e.version=t.version,e.renderedOptionsRevision=-1,!0)}getMaxScrollTopForHeight(e){let{paddingBottom:t,paddingTop:n}=this.getLayout();return Math.max(n+this.header.height+e+this.footer.height+t-this.getHeight(),0)}getMaxScrollTop(){return this.getMaxScrollTopForHeight(this.getScrollHeight())}shouldRebaseScroll(){return this.getMaxScrollTop()>je}getPagedScrollHeight(){return this.shouldRebaseScroll()?Math.min(this.getScrollHeight(),De):this.getScrollHeight()}getMaxPagedScrollTop(){return this.getMaxScrollTopForHeight(this.getPagedScrollHeight())}clampPagedScrollTop(e){let t=this.getMaxPagedScrollTop();return Math.max(0,Math.min(e,t))}clampScrollTop(e){let t=this.getMaxScrollTop();return Math.max(0,Math.min(e,t))}getMaxScrollPageOffset(){return Math.max(this.getMaxScrollTop()-this.getMaxPagedScrollTop(),0)}clampScrollPageOffset(e){let t=this.getMaxScrollPageOffset();return Math.max(0,Math.min(e,t))}resolveScrollPageWindow(e,t){let n=Y(this.clampPagedScrollTop(t)),r=this.clampScrollPageOffset(e-n);return n=Y(this.clampPagedScrollTop(e-r)),r=this.clampScrollPageOffset(e-n),{pagedScrollTop:n,scrollPageOffset:r}}resolvePagedScrollPosition(e){if(!this.shouldRebaseScroll())return{pagedScrollTop:this.clampPagedScrollTop(e),scrollPageOffset:0};let t=this.clampScrollPageOffset(this.scrollPageOffset),n=e-t,r=this.getMaxPagedScrollTop(),i=this.getMaxScrollPageOffset(),a=n>je&&t<i,o=n<Oe&&t>0;return n<0||n>r||a||o?this.resolveScrollPageWindow(e,o?Math.min(Ae,r):ke):{pagedScrollTop:Y(this.clampPagedScrollTop(n)),scrollPageOffset:t}}needsScrollPageUpdate(e){let t=Y(this.clampScrollTop(e)),{scrollPageOffset:n}=this.resolvePagedScrollPosition(t);return n!==this.scrollPageOffset}getPagedLayoutTop(e){return this.shouldRebaseScroll()?Math.max(e-this.scrollPageOffset,0):e}getStickyHeaderOffset(){return this.options.stickyHeaders===!0&&this.options.disableFileHeader!==!0?this.itemMetricsCache.diffHeaderHeight:0}getScrollTargetRect(e){let t=this.idToItem.get(e.id);if(t==null){console.warn(`CodeView.scrollTo: unknown item id "${e.id}"`);return}if(e.type===`item`)return{top:t.top,height:t.height};if(e.type===`range`){let n=this.getRangeScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve range ${Be(e.range)} for item "${e.id}"`);return}return{top:t.top+n.top,height:n.height}}let n=this.getLineScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve line ${e.lineNumber} for item "${e.id}"`);return}return{top:t.top+n.top,height:n.height}}normalizeScrollTarget(e){if(e.type===`position`||e.align!==`nearest`)return e;let t=this.getScrollTargetRect(e);if(t==null)return;let n=e.offset??0,r=this.getItemTopOffset()+t.top,i=r+t.height,a=this.getScrollTop(),o=a+(e.type===`line`||e.type===`range`?this.getStickyHeaderOffset():0),s=a+this.getHeight();if(!(r-n<=o&&i+n>=s)){if(r-n<o)return{...e,align:`start`};if(i+n>s)return{...e,align:`end`}}}resolveScrollTargetTop(e){if(e.type===`position`){let t=this.clampScrollTop(e.position);return t===e.position?this.clampScrollTop(e.position-this.getStickyHeaderOffset()):t}let t=this.idToItem.get(e.id);if(t==null){console.warn(`CodeView.scrollTo: unknown item id "${e.id}"`);return}if(e.type===`item`)return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top,t.height,e.align,e.offset));if(e.type===`range`){let n=this.getRangeScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve range ${Be(e.range)} for item "${e.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top+n.top,n.height,e.align,e.offset,this.getStickyHeaderOffset()))}let n=this.getLineScrollPosition(t,e);if(n==null){console.warn(`CodeView.scrollTo: unable to resolve line ${e.lineNumber} for item "${e.id}"`);return}return this.clampScrollTop(this.resolveAlignedScrollPosition(t.top+n.top,n.height,e.align,e.offset,this.getStickyHeaderOffset()))}resolveAlignedScrollPosition(e,t,n,r=0,i=0){e+=this.getItemTopOffset();let a=this.getHeight();return n===`center`&&t+r<a?e-(a-t)/2+r:n===`end`?e-(a-t)+r:e-i-r}getLineScrollPosition(e,t){return e.type===`diff`?e.instance.getLinePosition(t.lineNumber,t.side):e.instance.getLinePosition(t.lineNumber)}getRangeScrollPosition(e,t){let{range:n}=t,r=this.getLineScrollPosition(e,{type:`line`,id:t.id,lineNumber:n.start,side:n.side}),i=this.getLineScrollPosition(e,{type:`line`,id:t.id,lineNumber:n.end,side:n.endSide??n.side});if(r==null||i==null)return;let a=r.top,o=a+r.height,s=i.top,c=s+i.height,l=Math.min(a,s);return{top:l,height:Math.max(o,c)-l}}computeTargetScrollTopForFrame(e,t){if(this.pendingScrollTarget==null)return e;let n=this.resolveScrollTargetTop(this.pendingScrollTarget);if(n==null)return e;let{scrollAnimation:r}=this;return r==null?n:this.computeSpringStep(r,n,t).position}computeSpringStep(e,t,n){let r=Math.max(0,n-e.lastTimestamp),{omega:i}=this.getSmoothScrollSettings(),a=Math.exp(-i*r),o=e.position-t,s=e.velocity+i*o;return{position:t+(o+s*r)*a,velocity:(s*(1-i*r)-i*o)*a}}advanceScrollAnimation(e,t){if(this.pendingScrollTarget==null)return;let n=this.resolveScrollTargetTop(this.pendingScrollTarget);if(n==null){this.pendingScrollTarget=void 0,this.scrollAnimation=void 0;return}let r=this.scrollAnimation;if(r==null)return n;r.position+=t;let{position:i,velocity:a}=this.computeSpringStep(r,n,e);r.lastTimestamp=e,r.position=i,r.velocity=a;let{positionEpsilon:o,velocityEpsilon:s}=this.getSmoothScrollSettings();return Math.abs(n-i)<=o&&Math.abs(a)<=s?(r.position=n,r.velocity=0,this.scrollAnimation=void 0,n):r.position}computeRenderRangeAndEmit=(t=performance.now())=>{if(e.__STOP||this.container==null||!this.isReady())return;let n=this.getHeight(),r=this.getScrollTop(),i=r,a=this.pendingLayoutAnchor!=null,o=this.getScrollAnchor(i);if(this.layoutDirtyIndex!=null&&(this.recomputeLayout(this.layoutDirtyIndex,this.pendingLayoutReset),this.layoutDirtyIndex=void 0,this.pendingLayoutReset=void 0,a=!0),a&&o!=null){let e=this.resolveAnchoredScrollTop(o);if(e!=null){let t=e-i;i=e,this.scrollAnimation!=null&&(this.scrollAnimation.position+=t)}}a&&(i=this.clampScrollTop(i),this.syncContainerHeight());let s=this.computeTargetScrollTopForFrame(i,t),c=!a&&(this.renderState.scrollTop===-1||Math.abs(s-this.renderState.scrollTop)>n+this.config.overscrollSize*2);c&&(o=void 0),this.windowSpecs=O({scrollTop:s-this.header.height,height:n,scrollHeight:this.getScrollHeight(),fitPerfectly:c,fitPerfectlyOverscroll:this.getFitPerfectlyOverscroll(),overscrollSize:this.config.overscrollSize});let l=r;(this.pendingScrollTarget!=null&&s!==l||this.needsScrollPageUpdate(s))&&(this.applyScrollFix(s,l,this.windowSpecs),l=s);let{top:u,bottom:d}=this.windowSpecs,{firstIndex:f,lastIndex:p}=this.renderState;if(f>=0)for(let e=f;e<=p;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.computeRenderRangeAndEmit: No item at index: ${e}`);t.top>u-t.height&&t.top<=d||this.releaseRenderedItem(t)}let m=this.reconcileHeaderFooterHosts(),h,g=new Set,_=this.findFirstVisibleIndex(u),v=this.findLastVisibleIndex(d);for(let e=_;e<=v;e++){let t=this.items[e];if(t==null)throw Error(`CodeView.computeRenderRangeAndEmit: missing item`);let{instance:n}=t;t.element==null?(t.element=this.acquireElement(),Ue(this.stickyContainer,t.element,h),n.virtualizedSetup(),He(t,t.element)&&(t.renderedOptionsRevision=this.renderOptionsRevision,g.add(t)),h=t.element):(Ue(this.stickyContainer,t.element,h),He(t,void 0,t.renderedOptionsRevision!==this.renderOptionsRevision)&&(t.renderedOptionsRevision=this.renderOptionsRevision,g.add(t)),h=t.element),t.item.edit===!0&&this.attachItemEditor(t)}this.renderState.firstIndex=_<=v?_:-1,this.renderState.lastIndex=v,this.flushSlotCoordinator(),this.flushManagers(g),m&&this.measureMountedHosts(),this.reconcileRenderedItems(g),this.syncContainerHeight(),this.updateStickyPositioning();let y=o==null?void 0:this.resolveAnchoredScrollTop(o);o===this.pendingLayoutAnchor&&(this.pendingLayoutAnchor=void 0);let b=y==null?0:y-i,x=s,S=!1;if(this.pendingScrollTarget!=null){let e=this.advanceScrollAnimation(t,b);e==null?x=i:(x=e,S=!0)}else x=y??s;x!==l&&(this.applyScrollFix(x,l,this.windowSpecs),l=x),S&&this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),this.renderState.scrollTop=Y(l),this.updateStickyPositioning(),this.validateStickyContainerHeight(),this.fixContainerFocus(),(c||this.scrollAnimation!=null)&&this.render()};flushManagers(e){for(let t of e)t.instance.flushManagers()}syncContainerHeight(){let e=this.getPagedScrollHeight();this.container!=null&&this.containerHeight!==e&&(this.container.style.height=`${e}px`,this.containerHeight=e)}getStickyBounds(e){let{firstIndex:t,lastIndex:n}=e==null?this.renderState:{firstIndex:this.findFirstVisibleIndex(e.top),lastIndex:this.findLastVisibleIndex(e.bottom)};if(t===-1||n===-1||t>n)return;let r=this.items[t]?.instance.getAdvancedStickySpecs(e),i=this.items[n]?.instance.getAdvancedStickySpecs(e);if(r!=null&&i!=null)return{stickyTop:this.getPagedLayoutTop(Math.max(r.topOffset,0)),stickyBottom:this.getPagedLayoutTop(i.topOffset+i.height)}}applyStickyPositioning({stickyTop:e,stickyBottom:t}){let n=this.getHeight(),{itemMetricsCache:r}=this,i=t-e;this.renderState.stickyHeight=i,this.renderState.stickyTop=e,this.renderState.stickyBottom=t,this.stickyOffset.style.height=`${e}px`;let a=(Math.random()*r.lineHeight>>0)*-1,o=-Math.max(i+a,0)+n;this.stickyContainer.style.top=`${o}px`,this.stickyContainer.style.bottom=`${o+r.diffHeaderHeight}px`}syncPagedScrollScaffolding(e){this.syncContainerHeight();let t=this.getStickyBounds(e);t!=null&&this.applyStickyPositioning(t)}reconcileRenderedItems(e){let{firstIndex:t,lastIndex:n}=this.renderState;if(t===-1)return;let r=-1,i=!1;for(let a=t;a<this.items.length&&!(!i&&a>n);a++){let t=this.items[a];if(t==null)throw Error(`CodeView.reconcileRenderedItems: Invalid item`);r===-1?r=t.top:t.top!==r&&(t.top=r,t.instance.syncVirtualizedTop(),i=!0),(e==null?a<=n:e.has(t))&&(t.instance.reconcileHeights()&&(i=!0,t.height=t.instance.getVirtualizedHeight()),this.validateRenderedItemHeight(t)),r+=t.instance.getVirtualizedHeight(),a<this.items.length-1&&(r+=this.getLayout().gap)}i&&r!=null&&(this.scrollDirty=!0,this.scrollHeight=r)}updateStickyPositioning(){let e=this.getStickyBounds();if(e==null){this.renderState.firstIndex===-1&&(this.stickyOffset.style.height=``);return}let{stickyTop:t,stickyBottom:n}=e;(n-t!==this.renderState.stickyHeight||t!==this.renderState.stickyTop||n!==this.renderState.stickyBottom)&&this.applyStickyPositioning(e)}handleScroll=()=>{e.__STOP||(this.suspendScrollInteractions(),this.scrollDirty=!0,this.notifyScroll(),this.render())};clearPendingScroll=()=>{this.pendingScrollTarget=void 0,this.pendingLayoutAnchor=void 0,this.scrollAnimation=void 0};handleResize=e=>{let t=!1;for(let n of e)if(n.target===this.stickyContainer){let e=n.borderBoxSize[0].blockSize;if(Math.abs(e-this.renderState.stickyHeight)>=Te){let e=this.getScrollTop(),n=this.getScrollAnchor(e);this.reconcileRenderedItems(),this.updateStickyPositioning();let r=n==null?void 0:this.resolveAnchoredScrollTop(n);if(r!=null){let t=r-e;this.applyScrollFix(r,e,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=t)}this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),t=!0}}else if(n.target===this.header.element||n.target===this.footer.element){let e=n.target===this.header.element?this.header:this.footer,r=n.borderBoxSize[0].blockSize;if(r!==e.height){let n=this.getScrollTop(),i=this.getScrollAnchor(n);this.setHostHeight(e,r);let a=i==null?void 0:this.resolveAnchoredScrollTop(i);if(a!=null){let e=a-n;this.applyScrollFix(a,n,this.windowSpecs),this.scrollAnimation!=null&&(this.scrollAnimation.position+=e)}this.pendingScrollTarget!=null&&this.isPendingTargetSettled(this.pendingScrollTarget)&&(this.pendingScrollTarget=void 0,this.scrollAnimation=void 0),t=!0}}else this.scrollDirty=!0,this.heightDirty=!0,t=!0;t&&this.render(!0)};getScrollAnchorViewportTop(e,t){return e<t?t+this.getStickyHeaderOffset():t}getScrollAnchor(e,t=this.idToItem){let n,{pendingLayoutAnchor:r}=this;if(r!=null){let e=this.idToItem.get(r.id);if(e!=null&&t.get(r.id)===e)return r;e!=null&&(n=e)}if(e<=0)return;let{firstIndex:i,lastIndex:a,stickyTop:o,stickyBottom:s}=this.renderState;if(i===-1||a===-1)return;let c=this.getHeight();if(o!==-1&&s!==-1){for(let r=i;r<=a;r++){let i=this.items[r];if(i==null)continue;let a=this.getItemTopOffset()+i.top;if(a+i.height<=e)continue;if(a>=e+c)break;if(t.get(i.item.id)!==i){n??=i;continue}if(a>=e)return{type:`item`,id:i.item.id,viewportOffset:a-e};let o=this.getScrollAnchorViewportTop(a,e)-a,s=i.instance.getNumericScrollAnchor(o);if(s!=null){let t=a+s.top;return{type:`line`,id:i.item.id,lineNumber:s.lineNumber,side:s.side,viewportOffset:t-e}}}if(n!=null)for(let e=n.index+1;e<this.items.length;e++){let n=this.items[e];if(n!=null&&t.get(n.item.id)===n)return{type:`item`,id:n.item.id,viewportOffset:0}}}}resolveAnchoredScrollTop(e){let t=this.idToItem.get(e.id);if(t==null)return;let n=this.getItemTopOffset();if(e.type===`item`){let r=n+t.top;return this.clampScrollTop(r-e.viewportOffset)}let r=t.type===`diff`?t.instance.getLinePosition(e.lineNumber,e.side):t.instance.getLinePosition(e.lineNumber);if(r==null)return;let i=n+t.top+r.top;return this.clampScrollTop(i-e.viewportOffset)}applyScrollFix(e,t,n){if(this.root==null)return;let r=Y(this.clampScrollTop(e)),i=Y(t),{scrollPageOffset:a}=this,o=Y(this.clampPagedScrollTop(i-a)),{pagedScrollTop:s,scrollPageOffset:c}=this.resolvePagedScrollPosition(r),l=s,u=a!==c;r===this.renderState.scrollTop&&r===i&&l===o&&!u||(this.suspendScrollInteractions(),(l!==o||u)&&(this.scrollPageOffset=c,this.syncPagedScrollScaffolding(n)),l!==o&&this.root.scrollTo({top:l,behavior:`instant`}),this.renderState.scrollTop=r,this.scrollTop=r,this.scrollDirty=!1)}isPendingTargetSettled(e){let t=this.resolveScrollTargetTop(e);return t==null||Y(this.getScrollTop())===Y(t)}getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root?.scrollTop??0;return this.scrollTop=this.clampScrollTop(e+this.scrollPageOffset),this.scrollTop}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root?.getBoundingClientRect().height??0,this.height):this.height}getScrollHeight(){return this.scrollHeight}flushSlotCoordinator(){if(this.slotCoordinator==null)return;let e=this.buildSlotSnapshot(this.slotCoordinator);me(this.slotSnapshot,e)||(this.slotSnapshot=e,this.slotCoordinator.onSnapshotChange(e))}notifyScroll(){if(this.scrollListeners.size===0)return;let e=this.getScrollTop();for(let t of this.scrollListeners)t(e,this)}findFirstVisibleIndex(e){let t=0,n=this.items.length-1,r=this.items.length;for(;t<=n;){let i=t+n>>1,a=this.items[i];if(a==null)throw Error(`CodeView.findFirstVisibleIndex: invalid item index`);a.top+a.height>e?(r=i,n=i-1):t=i+1}return r}findLastVisibleIndex(e){let t=0,n=this.items.length-1,r=-1;for(;t<=n;){let i=t+n>>1,a=this.items[i];if(a==null)throw Error(`CodeView.findLastVisibleIndex: invalid item index`);a.top<=e?(r=i,t=i+1):n=i-1}return r}recomputeLayout(e=0,t){if(this.items.length===0){this.scrollHeight=0;return}let n=this.getLayout(),r=0;if(e>0){let t=this.items[e-1];if(t==null)throw Error(`CodeView.recomputeLayout: invalid dirty index`);r=t.top+t.height+n.gap}for(let i=e;i<this.items.length;i++){let e=this.items[i];if(e==null)throw Error(`CodeView.recomputeLayout: invalid item index`);if(e.top=r,e.type===`diff`){let n=e.instance.consumeCodeViewLayoutChanges(e.item.fileDiff);n!=null&&Object.assign(e.item.fileDiff,n),e.height=e.instance.prepareCodeViewItem(e.item.fileDiff,r,t,e.item.annotations??[])}else e.height=e.instance.prepareCodeViewItem(e.item.file,r,t,e.item.annotations??[]);r+=e.height,i<this.items.length-1&&(r+=n.gap)}r!==this.scrollHeight&&(this.scrollDirty=!0),this.scrollHeight=r}resetRenderState(){this.renderState.scrollTop=-1,this.renderState.firstIndex=-1,this.renderState.lastIndex=-1,this.renderState.stickyHeight=0,this.renderState.stickyTop=-1,this.renderState.stickyBottom=-1}getFitPerfectlyOverscroll(){return this.getLayout().gap+this.itemMetricsCache.diffHeaderHeight}};function Fe(e){return e.instance.cleanUp(!0),e.type===`diff`?e.instance.prepareCodeViewItem(e.item.fileDiff,e.top,void 0,e.item.annotations??[]):e.instance.prepareCodeViewItem(e.item.file,e.top,void 0,e.item.annotations??[])}function Ie(e,t){return!M(e.theme??F,t.theme??F)||(e.themeType??`system`)!==(t.themeType??`system`)||e.unsafeCSS!==t.unsafeCSS}function Le(e,t){return(e.overflow??`scroll`)!==(t.overflow??`scroll`)||(e.disableLineNumbers??!1)!==(t.disableLineNumbers??!1)||(e.disableFileHeader??!1)!==(t.disableFileHeader??!1)||e.unsafeCSS!==t.unsafeCSS||(e.diffStyle??`split`)!==(t.diffStyle??`split`)||(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)}function Re(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 ze(e){return e instanceof SVGElement||re(e)&&(e.hasAttribute(`data-core-css`)||e.hasAttribute(`data-theme-css`)||e.hasAttribute(`data-unsafe-css`))}function Be(e){let t=Ve(e.start,e.side),n=Ve(e.end,e.endSide??e.side);return t===n?t:`${t}-${n}`}function Ve(e,t){return t==null?`${e}`:`${t===`deletions`?`D`:`A`}${e}`}function He(e,t,n=!1){return e.type===`diff`?e.instance.render({deferManagers:!0,fileContainer:t,fileDiff:e.item.fileDiff,forceRender:n,lineAnnotations:e.item.annotations??[]}):e.instance.render({deferManagers:!0,fileContainer:t,file:e.item.file,forceRender:n,lineAnnotations:e.item.annotations??[]})}function Ue(e,t,n){if(n==null){e.firstChild!==t&&e.prepend(t);return}n.nextSibling!==t&&n.after(t)}function We(e){return(e.annotations?.length??0)>0}function Ge(e,{hasHeaderRenderers:t,hasAnnotationRenderer:n,hasGutterRenderer:r}){if(e.length===0)return;if(t||r)return e;if(!n)return;let i=[];for(let t of e)We(t.item)&&i.push(t);return i.length>0?i:void 0}var Z=e(n(),1),Ke=e(a(),1),Q=t(),qe=typeof window>`u`?Z.useEffect:Z.useLayoutEffect;function Je(e){return{instance:void 0,items:void 0,controlled:e,managedOptions:void 0,disableFlushSync:!1,slotCoordinator:void 0}}function Ye(e,t){let{className:n,containerRef:r,disableWorkerPool:i=!1,editorOptions:a,initialItems:o,items:s,onItemEditChange:c,onItemEditComplete:l,onScroll:u,onSelectedLinesChange:d,options:f,renderAnnotation:p,renderCodeViewFooter:m,renderCodeViewHeader:h,renderCustomHeader:g,renderGutterUtility:_,renderHeaderFilenameSuffix:v,renderHeaderMetadata:y,renderHeaderPrefix:b,selectedLines:x,style:S}=e,C=s!==void 0,w=te(),T=(0,Z.useContext)(ee),E=(0,Z.useRef)(Je(C)),D=g!=null,O=p!=null,k=_!=null,j=D||b!=null||v!=null||y!=null,M=j||O||k,N=h!=null,F=m!=null,I=P(e=>{d?.(e)}),L=x!==void 0,R=P(e=>{if(w==null)throw Error(`CodeView: EditContext is not attached`);let t=w({...a,...e});if(t==null)throw Error(`CodeView: EditProvider.createEditor must return an editor instance`);return t}),z=P((e,t,n)=>{c?.(e,t,n)}),B=P((e,t,n)=>{l?.(e,t,n)}),V=(0,Z.useMemo)(()=>tt({options:f,hasCustomHeader:D,hasGutterRenderer:k,hasCodeViewHeader:N,hasCodeViewFooter:F,onSelectedLinesChange:d==null?void 0:I,controlledSelection:L,createEditor:w==null?void 0:R,onItemEditChange:c==null?void 0:z,onItemEditComplete:l==null?void 0:B}),[w,L,R,z,B,I,F,N,D,k,c,l,d,f]),[H]=(0,Z.useState)(()=>et()),[,U]=(0,Z.useState)({}),W=P(e=>{E.current.instance!=null&&(e==null||e!==E.current.instance.getContainerElement())&&(E.current.instance.cleanUp(),H.publish(void 0),E.current=Je(C)),e!=null&&e!==E.current.instance?.getContainerElement()&&(E.current.instance=new Pe(V,i?void 0:T,!0),E.current.instance.setup(e)),typeof r==`function`?r(e):r!=null&&(r.current=e)}),G=P(e=>{E.current.disableFlushSync?H.publish(e):(0,Ke.flushSync)(()=>{H.publish(e)})}),K=(0,Z.useMemo)(()=>{if(!(!j&&!O&&!k&&!N&&!F))return{hasHeaderRenderers:j,hasAnnotationRenderer:O,hasGutterRenderer:k,onSnapshotChange:G}},[G,O,k,j,N,F]);return qe(()=>u==null?void 0:E.current.instance?.subscribeToScroll(u)),qe(()=>{let{instance:e,controlled:t,items:n,managedOptions:r,slotCoordinator:i}=E.current;if(e!=null)try{E.current.disableFlushSync=!0;let a=!1;if(A(V,r)||(E.current.managedOptions=V,e.setOptions(V),a=!0),t!==C){console.error(`CodeView: cannot switch between controlled and uncontrolled modes. Remount with a new key instead.`);return}if(C)s!==n&&(Qe(n,s)?E.current.items=s:Ze(n,s)?(E.current.items=s,e.addItems(s.slice(n.length))):(E.current.items=s,e.setItems(s),a=!0));else if(n==null){let t=o??[];E.current.items=t,t.length>0&&(e.setItems(t),a=!0)}x!==void 0&&e.setSelectedLines(x,{notify:!1});let c=e.setSlotCoordinator(K),l=!1;K!==i&&((K==null||i==null)&&(l=!0),E.current.slotCoordinator=K),(a||c)&&e.render(!0),c&&K==null&&H.publish(void 0),l&&U({})}finally{E.current.disableFlushSync=!1}}),(0,Z.useImperativeHandle)(t,()=>({addItems(e){let{controlled:t,instance:n}=E.current;$e(t,`addItems`),n==null?console.error(`CodeView.addItems: no valid instance to append items with`,e):n.addItems(e)},getItem(e){let{instance:t}=E.current;if(t==null){console.error(`CodeView.getItem: no valid instance exists`,e);return}return t.getItem(e)},removeItem(e){let{controlled:t,instance:n}=E.current;return $e(t,`removeItem`),n==null?(console.error(`CodeView.removeItem: no valid instance to remove item from`,e),!1):n.removeItem(e)},updateItem(e){let{controlled:t,instance:n}=E.current;return $e(t,`updateItem`),n==null?(console.error(`CodeView.updateItem: no valid instance to update item with`,e),!1):n.updateItem(e)},updateItemId(e,t){let{controlled:n,instance:r}=E.current;return $e(n,`updateItemId`),r==null?(console.error(`CodeView.updateItemId: no valid instance to update item id with`,e,t),!1):r.updateItemId(e,t)},scrollTo(e){let{instance:t}=E.current;t==null?console.error(`CodeView.scrollTo: no valid instance to scroll with`,e):t.scrollTo(e)},setSelectedLines(e){let{instance:t}=E.current;t==null?console.error(`CodeView.setSelectedLines: no valid instance to update selection with`,e):(t.setSelectedLines(e,{notify:!1}),I(e))},getSelectedLines(){let{instance:e}=E.current;return e==null?(console.error(`CodeView.getSelectedLines: no valid instance exists`),null):e.getSelectedLines()},clearSelectedLines(){let{instance:e}=E.current;e==null?console.error(`CodeView.clearSelectedLines: no valid instance to update selection with`):(e.clearSelectedLines({notify:!1}),I(null))},getEditor(e){let{instance:t}=E.current;if(t==null){console.error(`CodeView.getEditor: no valid instance exists`,e);return}return t.getEditor(e)},getInstance(){return E.current.instance}}),[I]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{ref:W,className:n,style:S}),(M||N||F)&&(0,Q.jsx)(nt,{managedContentStore:H,renderCustomHeader:g,renderHeaderPrefix:b,renderHeaderFilenameSuffix:v,renderHeaderMetadata:y,renderAnnotation:p,renderGutterUtility:_,renderCodeViewHeader:h,renderCodeViewFooter:m})]})}var Xe=(0,Z.forwardRef)(Ye);function Ze(e,t){if(e==null||t.length<=e.length)return!1;if(e.length===0)return!0;for(let n=0;n<e.length;n++)if(t[n]!==e[n])return!1;return!0}function Qe(e,t){if(e==null||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function $e(e,t){if(e)throw Error(`CodeView.${t} cannot be used when CodeView is controlled. Use initialItems for imperative item updates.`)}function et(){let e,t=new Set;return{getSnapshot(){return e},publish(n){if(!me(e,n)){e=n;for(let e of t)e()}},subscribe(e){return t.add(e),()=>{t.delete(e)}}}}function tt({options:e,hasCustomHeader:t,hasGutterRenderer:n,hasCodeViewHeader:r,hasCodeViewFooter:i,onSelectedLinesChange:a,controlledSelection:o,createEditor:s,onItemEditChange:c,onItemEditComplete:l}){let u={...e,controlledSelection:o,onSelectedLinesChange:a,createEditor:s};return c!=null&&(u.onItemEditChange=c),l!=null&&(u.onItemEditComplete=l),t&&(u.renderCustomHeader=it),n&&(u.renderGutterUtility=it),r&&(u.renderCodeViewHeader=it),i&&(u.renderCodeViewFooter=it),u}var nt=(0,Z.memo)(function({managedContentStore:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,renderGutterUtility:o,renderCodeViewHeader:s,renderCodeViewFooter:c}){"use no memo";let l=P(t=>e.subscribe(t)),u=P(()=>e.getSnapshot()),d=(0,Z.useSyncExternalStore)(l,u,u),f=``;for(let e of d?.items??[])f+=`${e.id}:${e.version}:${e.type}`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Z.useMemo)(()=>d?.items?.map(e=>(0,Ke.createPortal)(rt({renderedItem:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,renderGutterUtility:o}),e.element,e.id)),[t,n,r,i,a,o,f]),(0,Z.useMemo)(()=>s!=null&&d?.header!=null?(0,Ke.createPortal)(s(),d.header):null,[s,d?.header]),(0,Z.useMemo)(()=>c!=null&&d?.footer!=null?(0,Ke.createPortal)(c(),d.footer):null,[c,d?.footer])]})});function rt({renderedItem:e,renderCustomHeader:t,renderHeaderPrefix:n,renderHeaderFilenameSuffix:r,renderHeaderMetadata:i,renderAnnotation:a,renderGutterUtility:o}){if(e.type===`diff`){let{item:s,instance:c}=e;return se({fileDiff:s.fileDiff,renderCustomHeader:t==null?void 0:()=>t(s),renderHeaderPrefix:n==null?void 0:()=>n(s),renderHeaderFilenameSuffix:r==null?void 0:()=>r(s),renderHeaderMetadata:i==null?void 0:()=>i(s),renderAnnotation:a==null?void 0:e=>a(e,s),lineAnnotations:s.annotations,renderGutterUtility:o==null?void 0:e=>o(e,s),getHoveredLine:c.getHoveredLine})}{let{item:s,instance:c}=e;return _({file:s.file,renderCustomHeader:t==null?void 0:()=>t(s),renderHeaderPrefix:n==null?void 0:()=>n(s),renderHeaderFilenameSuffix:r==null?void 0:()=>r(s),renderHeaderMetadata:i==null?void 0:()=>i(s),renderAnnotation:a==null?void 0:e=>a(e,s),lineAnnotations:s.annotations,renderGutterUtility:o==null?void 0:e=>o(e,s),getHoveredLine:c.getHoveredLine})}}function it(){}var $=r(),at=0;function ot(){return at+=1,`pending-review-comment-${at}`}function st(e,t){return`${e}/${t.projectId}/${t.repository}#${t.number}`}var ct=[],lt=ie()(e=>({drafts:{},summaries:{},addComment:(t,n)=>e(e=>({drafts:{...e.drafts,[t]:[...e.drafts[t]??ct,n]}})),removeComment:(t,n)=>e(e=>{let r=(e.drafts[t]??ct).filter(e=>e.id!==n);if(r.length>0)return{drafts:{...e.drafts,[t]:r}};let{[t]:i,...a}=e.drafts;return{drafts:a}}),removeComments:(t,n)=>e(e=>{let r=new Set(n),i=(e.drafts[t]??ct).filter(e=>!r.has(e.id));if(i.length>0)return{drafts:{...e.drafts,[t]:i}};let{[t]:a,...o}=e.drafts;return{drafts:o}}),clear:t=>e(e=>{let{[t]:n,...r}=e.drafts;return{drafts:r}}),setSummary:(t,n)=>e(e=>({summaries:{...e.summaries,[t]:n}})),clearSummary:(t,n)=>e(e=>{if(e.summaries[t]!==n)return e;let{[t]:r,...i}=e.summaries;return{summaries:i}})}));function ut(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=t=>t.drafts[st(e.environmentId,e)]??ct,t[0]=e,t[1]=n),lt(n)}function dt(e){return[...e].toSorted((e,t)=>t.committedDate.localeCompare(e.committedDate))}function ft(e,t,n){let r=e.slice(0,n),i=e.find(e=>e.oid===t);return i!==void 0&&!r.includes(i)?[...r,i]:r}function pt(e){let t=(0,$.c)(60),[n,r]=(0,Z.useState)(10),i,a,o,s,c,l,u,d,f;if(t[0]!==e||t[1]!==n){i=dt(e.commits);let r=ft(i,e.selectedCommitOid,n);f=`flex shrink-0 items-center gap-2 overflow-x-auto border-b border-border/60 px-3 py-2`,u=`min-w-40 flex-1`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,Q.jsx)(`span`,{className:`sr-only`,children:`Diff scope`}),t[11]=d):d=t[11],a=`max-w-full rounded-md border border-border bg-background px-2 py-1 text-xs`,o=e.selectedCommitOid??``,t[12]===e?s=t[13]:(s=t=>e.onSelectedCommitChange(t.target.value||null),t[12]=e,t[13]=s),t[14]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(`option`,{value:``,children:`All commits`}),t[14]=c):c=t[14],l=r.map(ht),t[0]=e,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];let p;t[15]!==a||t[16]!==o||t[17]!==s||t[18]!==c||t[19]!==l?(p=(0,Q.jsxs)(`select`,{className:a,value:o,onChange:s,children:[c,l]}),t[15]=a,t[16]=o,t[17]=s,t[18]=c,t[19]=l,t[20]=p):p=t[20];let m;t[21]!==u||t[22]!==d||t[23]!==p?(m=(0,Q.jsxs)(`label`,{className:u,children:[d,p]}),t[21]=u,t[22]=d,t[23]=p,t[24]=m):m=t[24];let g;t[25]!==i.length||t[26]!==n?(g=n<i.length?(0,Q.jsx)(S,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>r(mt),children:`More commits`}):null,t[25]=i.length,t[26]=n,t[27]=g):g=t[27];let _;t[28]===e.onToggleAll?_=t[29]:(_=(0,Q.jsx)(S,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Toggle all files`,onClick:e.onToggleAll,children:`⌄`}),t[28]=e.onToggleAll,t[29]=_);let v=e.diffStyle===`unified`,y;t[30]===e?y=t[31]:(y=()=>e.onDiffStyleChange(`unified`),t[30]=e,t[31]=y);let b;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(q,{className:`size-3.5`}),t[32]=b):b=t[32];let x;t[33]!==v||t[34]!==y?(x=(0,Q.jsx)(S,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Unified diff view`,"aria-pressed":v,onClick:y,children:b}),t[33]=v,t[34]=y,t[35]=x):x=t[35];let C=e.diffStyle===`split`,w;t[36]===e?w=t[37]:(w=()=>e.onDiffStyleChange(`split`),t[36]=e,t[37]=w);let T;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Q.jsx)(oe,{className:`size-3.5`}),t[38]=T):T=t[38];let E;t[39]!==C||t[40]!==w?(E=(0,Q.jsx)(S,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Split diff view`,"aria-pressed":C,onClick:w,children:T}),t[39]=C,t[40]=w,t[41]=E):E=t[41];let D;t[42]===e?D=t[43]:(D=()=>e.onWordWrapChange(!e.wordWrap),t[42]=e,t[43]=D);let O;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Q.jsx)(le,{className:`size-3.5`}),t[44]=O):O=t[44];let k;t[45]!==e.wordWrap||t[46]!==D?(k=(0,Q.jsx)(S,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Toggle line wrapping`,"aria-pressed":e.wordWrap,onClick:D,children:O}),t[45]=e.wordWrap,t[46]=D,t[47]=k):k=t[47];let A;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Q.jsx)(h,{className:`size-3.5`}),t[48]=A):A=t[48];let j;t[49]===e.onRefresh?j=t[50]:(j=(0,Q.jsx)(S,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":`Refresh pull request diff`,onClick:e.onRefresh,children:A}),t[49]=e.onRefresh,t[50]=j);let M;return t[51]!==g||t[52]!==_||t[53]!==x||t[54]!==E||t[55]!==k||t[56]!==j||t[57]!==f||t[58]!==m?(M=(0,Q.jsxs)(`header`,{className:f,children:[m,g,_,x,E,k,j]}),t[51]=g,t[52]=_,t[53]=x,t[54]=E,t[55]=k,t[56]=j,t[57]=f,t[58]=m,t[59]=M):M=t[59],M}function mt(e){return e+10}function ht(e){return(0,Q.jsx)(`option`,{value:e.oid,children:`${e.messageHeadline} (${e.oid.slice(0,7)})`},e.oid)}var gt=new Set([`pnpm-lock.yaml`,`yarn.lock`,`package-lock.json`,`bun.lockb`,`Cargo.lock`,`go.sum`,`composer.lock`,`Gemfile.lock`]),_t=new Set([`__snapshots__`,`__generated__`,`dist`,`build`,`vendor`]),vt=new Set([`__tests__`,`tests`,`test`]),yt=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`];function bt(e){let t=e.split(`/`),n=t.at(-1)??``;return gt.has(n)||n.endsWith(`.snap`)||n.endsWith(`.min.js`)||n.endsWith(`.min.css`)||/\.generated\./.test(n)||t.slice(0,-1).some(e=>_t.has(e))?`generated`:/\.(?:test|spec)\./.test(n)||t.slice(0,-1).some(e=>vt.has(e))?`test`:`source`}function xt(e){let t=e.lastIndexOf(`.`);return t>e.lastIndexOf(`/`)?e.slice(0,t):e}function St(e){return xt(e.split(`/`).at(-1)??``)}function Ct(e,t){let n=e.split(`/`).slice(0,-1);for(let e of t.split(`/`))e!==`.`&&e!==``&&(e===`..`?n.pop():n.push(e));return n.join(`/`)}var wt=/(?:\bfrom|\bimport|\brequire\s*\()\s*\(?\s*["']([^"']+)["']/g;function Tt(e,t,n,r){let i=t.startsWith(`.`)?Ct(e,t):t,a=yt.find(e=>i.endsWith(e)),o=a===void 0?i:i.slice(0,-a.length),s=n.get(o)??n.get(`${o}/index`)??r.get(St(o));return s===e?void 0:s}function Et(e){return wt.lastIndex=0,Array.from(e.matchAll(wt),e=>e[1]??``)}function Dt(e,t,n,r){let i=new Set;for(let a of t.flatMap(Et)){let t=Tt(e,a,n,r);t!==void 0&&i.add(t)}return i}function Ot(e,t){let n=new Set(e),r=[],i=e.toSorted((e,t)=>e.localeCompare(t));for(;n.size>0;){let e=i.filter(e=>n.has(e)),a=e.find(e=>[...t.get(e)??[]].every(e=>!n.has(e)))??e[0];n.delete(a),r.push(a)}return r}function kt(e){return(e.split(`/`).at(-1)??``).replace(/\.(?:test|spec)\..*$/,``).replace(/\.[^.]+$/,``)}function At(e){let t=new Map;for(let n of e)t.set(J(n),n);let n=new Map;for(let e of t.keys())n.set(e,bt(e));let r=[...t.keys()].filter(e=>n.get(e)===`source`),i=new Map,a=new Set,o=new Map;for(let e of r){i.set(xt(e),e);let t=St(e);o.has(t)&&a.add(t),o.set(t,e)}for(let e of a)o.delete(e);let s=new Map;for(let e of r){let n=t.get(e);s.set(e,Dt(e,[...n.additionLines,...n.deletionLines],i,o))}let c=Ot(r,s),l=new Map;c.forEach((e,t)=>{let n=St(e);l.has(n)||l.set(n,t)});let u=[...t.keys()].filter(e=>n.get(e)===`test`).toSorted((e,t)=>(l.get(kt(e))??2**53-1)-(l.get(kt(t))??2**53-1)||e.localeCompare(t)),d=[...t.keys()].filter(e=>n.get(e)===`generated`).toSorted((e,t)=>e.localeCompare(t));return[...c,...u,...d].map(e=>t.get(e))}function jt(e,t,n){return e.hunks.some(e=>t===`left`?n>=e.deletionStart&&n<e.deletionStart+e.deletionCount:n>=e.additionStart&&n<e.additionStart+e.additionCount)}function Mt(e,t,n){let r=t!==`expanded`;return n.has(e)?!r:r}function Nt(e,t,n,r){let i=t-(n===`left`?r.oldLine:r.newLine);return i>=0&&i<e.lines?{kind:`context`,oldLine:r.oldLine+i,newLine:r.newLine+i,side:n}:null}function Pt(e,t,n,r){let i=n===`left`?r.oldLine:r.newLine,a=n===`left`?e.deletions:e.additions;return t>=i&&t<i+a?n===`left`?{kind:`deleted`,oldLine:t}:{kind:`added`,newLine:t}:null}function Ft(e,t){return e.type===`context`?{oldLine:t.oldLine+e.lines,newLine:t.newLine+e.lines}:{oldLine:t.oldLine+e.deletions,newLine:t.newLine+e.additions}}function It(e,t,n){let r={oldLine:e.deletionStart,newLine:e.additionStart};for(let i of e.hunkContent){let e=i.type===`context`?Nt(i,t,n,r):Pt(i,t,n,r);if(e!==null)return e;r=Ft(i,r)}return null}function Lt(e,t,n){let r=n===`deletions`?`left`:`right`;for(let n of e.hunks){let e=It(n,t,r);if(e!==null)return e}return null}function Rt(e){let t=(0,$.c)(7),n;return t[0]!==e.annotation.comment||t[1]!==e.annotation.kind||t[2]!==e.annotation.thread||t[3]!==e.environmentId||t[4]!==e.permissions||t[5]!==e.reference?(n=e.annotation.kind===`thread`?(0,Q.jsx)(C,{environmentId:e.environmentId,reference:e.reference,thread:e.annotation.thread,canReply:e.permissions.canReply,canResolve:e.permissions.canResolve,reactionsEnabled:e.permissions.reactionsEnabled}):(0,Q.jsx)(zt,{body:e.annotation.comment.body}),t[0]=e.annotation.comment,t[1]=e.annotation.kind,t[2]=e.annotation.thread,t[3]=e.environmentId,t[4]=e.permissions,t[5]=e.reference,t[6]=n):n=t[6],n}function zt(e){let t=(0,$.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(`p`,{className:`text-xs font-medium text-info-foreground`,children:`Pending review comment`}),t[0]=n):n=t[0];let r;return t[1]===e.body?r=t[2]:(r=(0,Q.jsxs)(`article`,{className:`rounded-md border border-info-border bg-info-surface p-3`,children:[n,(0,Q.jsx)(v,{text:e.body,className:`mt-1`})]}),t[1]=e.body,t[2]=r),r}function Bt(e){let t=(0,$.c)(10),n;t[0]!==e.file||t[1]!==e.omittedStats?(n=Vt(e.file,e.omittedStats),t[0]=e.file,t[1]=e.omittedStats,t[2]=n):n=t[2];let{additions:r,deletions:i}=n,a;t[3]===r?a=t[4]:(a=(0,Q.jsxs)(`span`,{className:`text-success-foreground`,children:[`+`,r]}),t[3]=r,t[4]=a);let o;t[5]===i?o=t[6]:(o=(0,Q.jsxs)(`span`,{className:`text-destructive-foreground`,children:[`−`,i]}),t[5]=i,t[6]=o);let s;return t[7]!==a||t[8]!==o?(s=(0,Q.jsxs)(`span`,{className:`flex gap-1 font-mono text-[11px] tabular-nums`,children:[a,o]}),t[7]=a,t[8]=o,t[9]=s):s=t[9],s}function Vt(e,t){let n=e.hunks.reduce((e,t)=>({additions:e.additions+t.additionLines,deletions:e.deletions+t.deletionLines}),{additions:0,deletions:0});return n.additions===0&&n.deletions===0?t.get(J(e))??n:n}function Ht(e){let t=(0,$.c)(9),n=e.item.collapsed===!0,r=n?`Expand file`:`Collapse file`,a=!n,o;t[0]===e?o=t[1]:(o=()=>e.onToggleFile(e.item.id),t[0]=e,t[1]=o);let s;t[2]===n?s=t[3]:(s=n?(0,Q.jsx)(ne,{className:`size-3.5`}):(0,Q.jsx)(i,{className:`size-3.5`}),t[2]=n,t[3]=s);let c;return t[4]!==r||t[5]!==a||t[6]!==o||t[7]!==s?(c=(0,Q.jsx)(S,{type:`button`,size:`icon-sm`,variant:`ghost`,"aria-label":r,"aria-expanded":a,onClick:o,children:s}),t[4]=r,t[5]=a,t[6]=o,t[7]=s,t[8]=c):c=t[8],c}function Ut(e){let t=(0,$.c)(2),n;return t[0]===e.threads?n=t[1]:(n=e.threads.length>0?(0,Q.jsxs)(`section`,{className:`border-b border-warning-border bg-warning-surface px-3 py-2 text-xs text-warning-foreground`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,Q.jsx)(y,{className:`size-3.5`}),`Conversations not on the diff loaded so far`]}),e.threads.map(Wt)]}):null,t[0]=e.threads,t[1]=n),n}function Wt(e){return(0,Q.jsxs)(`p`,{className:`mt-1 truncate`,children:[e.path,e.line===null?``:`:${e.line}`,e.isOutdated?` · outdated`:``]},e.id)}function Gt(e){let t=(0,$.c)(2),n;return t[0]===e.children?n=t[1]:(n=(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-center text-sm text-muted-foreground`,children:e.children}),t[0]=e.children,t[1]=n),n}function Kt(e){let t=(0,$.c)(7),n,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={diffHeaderHeight:32,hunkSeparatorHeight:24,spacing:0,paddingTop:0,paddingBottom:8},r={paddingTop:0,paddingBottom:0,gap:0},t[0]=n,t[1]=r):(n=t[0],r=t[1]);let i;t[2]===e.options?i=t[3]:(i={...e.options,unsafeCSS:`[data-diffs-header]{position:sticky!important;top:0;z-index:4;background:var(--background)!important;border-bottom:1px solid var(--border)!important}`,itemMetrics:n,layout:r},t[2]=e.options,t[3]=i);let a;return t[4]!==e||t[5]!==i?(a=(0,Q.jsx)(Xe,{...e,options:i}),t[4]=e,t[5]=i,t[6]=a):a=t[6],a}function qt(e){return[...e.threads.flatMap(t=>Yt(e.file,t)),...e.pendingComments.flatMap(t=>Zt(e.file,t))]}function Jt(e,t){return e.some(e=>Xt(e,t))}function Yt(e,t){return Xt(e,t)?[{side:$t(t.side),lineNumber:t.line,metadata:{kind:`thread`,thread:t}}]:[]}function Xt(e,t){return[!t.isOutdated,t.line!==null,J(e)===t.path,t.line!==null&&jt(e,t.side,t.line)].every(Boolean)}function Zt(e,t){if(J(e)!==t.path)return[];let n=Qt(t);return n===null||!jt(e,n.side,n.line)?[]:[{side:$t(n.side),lineNumber:n.line,metadata:{kind:`pending`,comment:t}}]}function Qt(e){switch(e.position.kind){case`added`:return{side:`right`,line:e.position.newLine};case`deleted`:return{side:`left`,line:e.position.oldLine};case`context`:return e.position.side===`left`?{side:`left`,line:e.position.oldLine}:{side:`right`,line:e.position.newLine}}}function $t(e){return e===`left`?`deletions`:`additions`}function en(e){return tn[nn(e)](e)}var tn={loading:()=>(0,Q.jsx)(V,{label:`Loading pull request diff…`}),error:e=>(0,Q.jsx)(Gt,{children:e.error?.message??`Pull request diff could not be loaded.`}),empty:()=>(0,Q.jsx)(Gt,{children:`This pull request has no file changes.`}),loaded:e=>(0,Q.jsx)(cn,{...e})};function nn(e){return rn(e)?`loading`:an(e)?`error`:on(e)?`empty`:`loaded`}function rn(e){return e.loading&&e.slices.length===0}function an(e){return e.error!==null&&e.slices.length===0}function on(e){return!sn({itemCount:e.items.length,rawCount:e.raw.length,withheld:e.withheld})}function sn(e){return e.itemCount>0||e.rawCount>0||e.withheld}function cn(e){let t=(0,$.c)(12),n,r;t[0]===e?(n=t[1],r=t[2]):(n=(0,Q.jsx)(ln,{...e}),r=e.items.length>0?(0,Q.jsx)(fn,{...e}):null,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===e.raw?i=t[4]:(i=(0,Q.jsx)(hn,{raw:e.raw}),t[3]=e.raw,t[4]=i);let a;t[5]===e?a=t[6]:(a=(0,Q.jsx)(gn,{...e}),t[5]=e,t[6]=a);let o;return t[7]!==n||t[8]!==r||t[9]!==i||t[10]!==a?(o=(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[n,r,i,a]}),t[7]=n,t[8]=r,t[9]=i,t[10]=a,t[11]=o):o=t[11],o}function ln(e){let t=(0,$.c)(14),n;t[0]!==e.activity?.reviewThreads||t[1]!==e.files?(n=e.activity?.reviewThreads.filter(t=>!Jt(e.files,t)),t[0]=e.activity?.reviewThreads,t[1]=e.files,t[2]=n):n=t[2];let r=n,i;t[3]===e?i=t[4]:(i=e.error===null?null:(0,Q.jsx)(un,{...e,error:e.error}),t[3]=e,t[4]=i);let a;t[5]!==e.omittedFileCount||t[6]!==e.withheld?(a=e.withheld?(0,Q.jsx)(dn,{omittedFileCount:e.omittedFileCount}):null,t[5]=e.omittedFileCount,t[6]=e.withheld,t[7]=a):a=t[7];let o;t[8]===r?o=t[9]:(o=r===void 0?null:(0,Q.jsx)(Ut,{threads:r}),t[8]=r,t[9]=o);let s;return t[10]!==i||t[11]!==a||t[12]!==o?(s=(0,Q.jsxs)(Q.Fragment,{children:[i,a,o]}),t[10]=i,t[11]=a,t[12]=o,t[13]=s):s=t[13],s}function un(e){let t=(0,$.c)(8),n;t[0]===e.error.message?n=t[1]:(n=(0,Q.jsxs)(`span`,{children:[`More diff content could not be loaded: `,e.error.message]}),t[0]=e.error.message,t[1]=n);let r;t[2]!==e.hasNextPage||t[3]!==e.onLoadNextPage?(r=e.hasNextPage?(0,Q.jsx)(S,{type:`button`,size:`xs`,variant:`outline`,onClick:e.onLoadNextPage,children:`Retry`}):null,t[2]=e.hasNextPage,t[3]=e.onLoadNextPage,t[4]=r):r=t[4];let i;return t[5]!==n||t[6]!==r?(i=(0,Q.jsxs)(`section`,{className:`flex items-center justify-between gap-2 border-b border-destructive-border bg-destructive-surface px-3 py-2 text-xs text-destructive-foreground`,children:[n,r]}),t[5]=n,t[6]=r,t[7]=i):i=t[7],i}function dn(e){let t=(0,$.c)(2),n=e.omittedFileCount>0?` ${e.omittedFileCount} file statistics remain available.`:``,r;return t[0]===n?r=t[1]:(r=(0,Q.jsxs)(`section`,{className:`border-b border-warning-border bg-warning-surface px-3 py-2 text-xs text-warning-foreground`,children:[`Binary or oversized content was withheld by the provider.`,n]}),t[0]=n,t[1]=r),r}function fn(e){let t=(0,$.c)(14),n;t[0]===e.onToggleFile?n=t[1]:(n=t=>pn(t,e.onToggleFile),t[0]=e.onToggleFile,t[1]=n);let r;t[2]===e.omittedStats?r=t[3]:(r=t=>mn(t,e.omittedStats),t[2]=e.omittedStats,t[3]=r);let i;t[4]!==e.annotationPermissions||t[5]!==e.environmentId||t[6]!==e.reference?(i=t=>(0,Q.jsx)(Rt,{annotation:t.metadata,environmentId:e.environmentId,reference:e.reference,permissions:e.annotationPermissions}),t[4]=e.annotationPermissions,t[5]=e.environmentId,t[6]=e.reference,t[7]=i):i=t[7];let a;return t[8]!==e.items||t[9]!==e.viewOptions||t[10]!==n||t[11]!==r||t[12]!==i?(a=(0,Q.jsx)(Kt,{className:`h-full min-h-0 [scrollbar-gutter:stable]`,items:e.items,options:e.viewOptions,renderHeaderPrefix:n,renderHeaderMetadata:r,renderAnnotation:i}),t[8]=e.items,t[9]=e.viewOptions,t[10]=n,t[11]=r,t[12]=i,t[13]=a):a=t[13],a}function pn(e,t){return(0,Q.jsx)(Ht,{item:e,onToggleFile:t})}function mn(e,t){return e.type===`diff`?(0,Q.jsx)(Bt,{file:e.fileDiff,omittedStats:t}):null}function hn(e){return e.raw.map(e=>(0,Q.jsxs)(`pre`,{className:`m-3 whitespace-pre-wrap break-words rounded-md border border-warning-border bg-warning-surface p-3 font-mono text-xs text-warning-foreground`,children:[e.reason,`
2
2
 
3
3
  `,e.text]},`${e.reason}:${e.text.slice(0,32)}`))}function gn(e){let t=(0,$.c)(5),n;return t[0]!==e.continuationRef||t[1]!==e.hasNextPage||t[2]!==e.loadingNextPage||t[3]!==e.onLoadNextPage?(n=e.hasNextPage?(0,Q.jsx)(`div`,{ref:e.continuationRef,className:`flex justify-center p-3`,children:(0,Q.jsx)(S,{type:`button`,size:`sm`,variant:`outline`,disabled:e.loadingNextPage,onClick:e.onLoadNextPage,children:e.loadingNextPage?`Loading more files…`:`Load more files`})}):null,t[0]=e.continuationRef,t[1]=e.hasNextPage,t[2]=e.loadingNextPage,t[3]=e.onLoadNextPage,t[4]=n):n=t[4],n}function _n(e){let t=(0,Z.useRef)(null),{resolvedTheme:n}=z(),r=(0,Z.useMemo)(()=>yn(e.slices),[e.slices]),i=(0,Z.useMemo)(()=>bn(r),[r]),a=vn(i,e),o=(0,Z.useMemo)(()=>Tn(e.onLoadFileContents,e.revisionKey),[e.onLoadFileContents,e.revisionKey]);return kn({target:t,hasNextPage:e.hasNextPage,loadingNextPage:e.loadingNextPage,error:e.error,onLoadNextPage:e.onLoadNextPage}),(0,Q.jsx)(en,{...e,continuationRef:t,files:i,raw:xn(r),withheld:e.slices.some(e=>e.truncated),omittedFileCount:Sn(e.slices),omittedStats:Cn(e.slices),items:a,viewOptions:wn(e,o,n)})}function vn(e,t){return e.map((e,n)=>{let r=ue(e);return{id:r,type:`diff`,fileDiff:e,collapsed:Mt(r,t.collapsedOverride,t.toggledFiles),annotations:qt({file:e,threads:t.activity?.reviewThreads??[],pendingComments:t.pendingComments}),version:n}})}function yn(e){return e.map(e=>ce(e.patch))}function bn(e){return At(e.flatMap(e=>e?.kind===`files`?e.files:[]))}function xn(e){return e.flatMap(e=>e?.kind===`raw`?[e]:[])}function Sn(e){return e.reduce((e,t)=>e+(t.omittedFileStats?.length??0),0)}function Cn(e){return new Map(e.flatMap(e=>e.omittedFileStats??[]).map(e=>[e.path,e]))}function wn(e,t,n){return{diffStyle:e.diffStyle,overflow:e.wordWrap?`wrap`:`scroll`,theme:N(n),themeType:n,stickyHeaders:!0,loadDiffFiles:t,enableLineSelection:e.onSelectLines!==void 0,...e.onSelectLines===void 0?{}:{onLineSelectionEnd:En(e.onSelectLines)}}}function Tn(e,t){return async n=>{let r=J(n),i=n.prevName?J({name:n.prevName}):r,a=await e({changeType:n.type,oldPath:i,newPath:r});return{oldFile:n.type===`rename-pure`?null:{name:i,contents:a.oldContents,cacheKey:`${t}:old:${i}`},newFile:{name:r,contents:a.newContents,cacheKey:`${t}:new:${r}`}}}}function En(e){return(t,n)=>{let r=Dn(t,n.item);r!==null&&e(r)}}function Dn(e,t){return e===null||t.type!==`diff`?null:On(e,t.fileDiff)}function On(e,t){let n=Lt(t,e.end,e.endSide??e.side);return n===null?null:{path:J(t),oldPath:t.prevName?J({name:t.prevName}):null,start:e.start,end:e.end,position:n}}function kn(e){let t=(0,$.c)(12),{target:n,hasNextPage:r,loadingNextPage:i,error:a,onLoadNextPage:o}=e,s;t[0]!==a||t[1]!==r||t[2]!==i||t[3]!==o||t[4]!==n.current?(s=()=>{let e=n.current;if(!jn(e,{hasNextPage:r,loadingNextPage:i,error:a,onLoadNextPage:o}))return;let t=new IntersectionObserver(e=>{e.some(An)&&o()},{rootMargin:`240px`});return t.observe(e),()=>t.disconnect()},t[0]=a,t[1]=r,t[2]=i,t[3]=o,t[4]=n.current,t[5]=s):s=t[5];let c;t[6]!==a||t[7]!==r||t[8]!==i||t[9]!==o||t[10]!==n?(c=[a,r,i,o,n],t[6]=a,t[7]=r,t[8]=i,t[9]=o,t[10]=n,t[11]=c):c=t[11],(0,Z.useEffect)(s,c)}function An(e){return e.isIntersecting}function jn(e,t){return[e!==null,t.hasNextPage,!t.loadingNextPage,t.error===null].every(Boolean)}function Mn(e){return[e.isDetailFresh,e.selectedCommitOid===null,e.detail.capabilities.review.inlineComment,e.detail.viewerPermissions.comment].every(Boolean)}function Nn(e){return e.isDetailFresh?e.detail.capabilities.review.verdicts.filter(t=>e.detail.viewerPermissions.verdicts.includes(t)):[]}function Pn(e){let t=e.selectedCommitOid??`head`;return`${e.reference.projectId}:${e.reference.repository}#${e.reference.number}:${e.detail.updatedAt}:${t}`}function Fn(e){let t=(0,$.c)(22),n;t[0]===e?n=t[1]:(n=t=>Ln(t,e),t[0]=e,t[1]=n);let r=e.anchor.end===e.anchor.start?``:`–${e.anchor.end}`,i;t[2]!==e.anchor.path||t[3]!==e.anchor.start||t[4]!==r?(i=(0,Q.jsxs)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:[`Comment on `,e.anchor.path,`:`,e.anchor.start,r]}),t[2]=e.anchor.path,t[3]=e.anchor.start,t[4]=r,t[5]=i):i=t[5];let a;t[6]!==e.body||t[7]!==e.onBodyChange?(a=(0,Q.jsx)(f,{value:e.body,ariaLabel:`Inline review comment`,placeholder:`Add a line comment…`,density:`compact`,onChange:e.onBodyChange}),t[6]=e.body,t[7]=e.onBodyChange,t[8]=a):a=t[8];let o;t[9]===e.onCancel?o=t[10]:(o=(0,Q.jsx)(S,{type:`button`,size:`sm`,variant:`ghost`,onClick:e.onCancel,children:`Cancel`}),t[9]=e.onCancel,t[10]=o);let s=e.body.trim().length===0,c;t[11]!==e.onAdd||t[12]!==s?(c=(0,Q.jsx)(S,{type:`button`,size:`sm`,disabled:s,onClick:e.onAdd,children:`Add to review`}),t[11]=e.onAdd,t[12]=s,t[13]=c):c=t[13];let l;t[14]!==o||t[15]!==c?(l=(0,Q.jsxs)(`div`,{className:`mt-2 flex justify-end gap-2`,children:[o,c]}),t[14]=o,t[15]=c,t[16]=l):l=t[16];let u;return t[17]!==n||t[18]!==i||t[19]!==a||t[20]!==l?(u=(0,Q.jsxs)(`aside`,{className:`absolute inset-x-3 bottom-3 z-20 rounded-lg border border-border bg-card p-3 shadow-lg`,onPointerDown:In,onKeyDown:n,children:[i,a,l]}),t[17]=n,t[18]=i,t[19]=a,t[20]=l,t[21]=u):u=t[21],u}function In(e){return e.stopPropagation()}function Ln(e,t){if(e.key===`Escape`){e.preventDefault(),t.onCancel();return}Rn(e)&&t.body.trim().length>0&&(e.preventDefault(),t.onAdd())}function Rn(e){return e.key===`Enter`&&[e.metaKey,e.ctrlKey].some(Boolean)}var zn=[{value:`comment`,label:`Comment`},{value:`approve`,label:`Approve`},{value:`request-changes`,label:`Request changes`}];function Bn(e,t,n,r){return!r&&(e===`approve`||t.trim().length>0||n.length>0)}function Vn(e){let[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(null),a=async r=>{if(Bn(r,e.body,e.pendingComments,t)){n(!0),i(null);try{await e.onSubmit({verdict:r,body:e.body,comments:e.pendingComments})}catch(e){i(e instanceof Error?e.message:`Review could not be submitted.`)}finally{n(!1)}}};return(0,Q.jsxs)(`aside`,{className:`absolute inset-x-3 bottom-3 z-10 rounded-lg border border-border bg-card shadow-lg`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/60 px-3 py-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:e.pendingComments.length===0?`Review`:`${e.pendingComments.length} line comments pending`}),(0,Q.jsx)(S,{type:`button`,size:`xs`,variant:`ghost`,onClick:e.onClose,children:`Close`})]}),(0,Q.jsxs)(`div`,{className:`p-3`,children:[(0,Q.jsx)(f,{value:e.body,ariaLabel:`Review summary`,placeholder:`Summarize your review (optional)`,density:`compact`,disabled:t,onChange:e.onBodyChange}),r===null?null:(0,Q.jsxs)(`p`,{role:`alert`,className:`mt-2 text-xs text-destructive-foreground`,children:[`Review could not be submitted: `,r]}),(0,Q.jsx)(`div`,{className:`mt-2 flex flex-wrap justify-end gap-2`,children:zn.filter(t=>e.verdicts.includes(t.value)).map(e=>(0,Q.jsxs)(S,{type:`button`,size:`sm`,variant:e.value===`comment`?`outline`:`default`,disabled:t,onClick:()=>void a(e.value),children:[e.value===`approve`?(0,Q.jsx)(c,{className:`size-3.5`}):e.value===`comment`?(0,Q.jsx)(d,{className:`size-3.5`}):(0,Q.jsx)(u,{className:`size-3.5`}),e.label]},e.value))})]})]})}function Hn(e){let t=(0,$.c)(3),n=Kn(e),r;return t[0]!==n||t[1]!==e?(r=(0,Q.jsx)(Un,{props:e,model:n}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r}function Un(e){let t=(0,$.c)(2),n;return t[0]===e?n=t[1]:(n=(0,Q.jsx)(x,{children:(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,Q.jsx)(Wn,{...e}),(0,Q.jsx)(Gn,{...e}),(0,Q.jsx)(rr,{...e})]})}),t[0]=e,t[1]=n),n}function Wn(e){let t=(0,$.c)(12),{props:n,model:r}=e,i;t[0]===n.activity?.commits?i=t[1]:(i=n.activity?.commits??[],t[0]=n.activity?.commits,t[1]=i);let a;return t[2]!==r.diffStyle||t[3]!==r.setDiffStyle||t[4]!==r.setWordWrap||t[5]!==r.toggleAll||t[6]!==r.wordWrap||t[7]!==n.onRefresh||t[8]!==n.onSelectedCommitChange||t[9]!==n.selectedCommitOid||t[10]!==i?(a=(0,Q.jsx)(pt,{commits:i,selectedCommitOid:n.selectedCommitOid,diffStyle:r.diffStyle,wordWrap:r.wordWrap,onSelectedCommitChange:n.onSelectedCommitChange,onDiffStyleChange:r.setDiffStyle,onWordWrapChange:r.setWordWrap,onToggleAll:r.toggleAll,onRefresh:n.onRefresh}),t[2]=r.diffStyle,t[3]=r.setDiffStyle,t[4]=r.setWordWrap,t[5]=r.toggleAll,t[6]=r.wordWrap,t[7]=n.onRefresh,t[8]=n.onSelectedCommitChange,t[9]=n.selectedCommitOid,t[10]=i,t[11]=a):a=t[11],a}function Gn(e){let t=(0,$.c)(27),{props:n,model:r}=e,i;t[0]===r.onSelectLines?i=t[1]:(i=r.onSelectLines===void 0?{}:{onSelectLines:r.onSelectLines},t[0]=r.onSelectLines,t[1]=i);let a=i,o=n.environmentId,s=n.reference,c=n.selectedCommitOid===null?n.activity:void 0,l;t[2]!==r.pendingComments||t[3]!==n.selectedCommitOid?(l=n.selectedCommitOid===null?r.pendingComments:[],t[2]=r.pendingComments,t[3]=n.selectedCommitOid,t[4]=l):l=t[4];let u=r.annotationPermissions,d=n.slices,f=n.loading,p=n.error,m=n.hasNextPage,h=n.loadingNextPage,g=r.collapsedOverride,_=r.toggledFiles,v=r.diffStyle,y=r.wordWrap,b;t[5]===n?b=t[6]:(b=Pn(n),t[5]=n,t[6]=b);let x;return t[7]!==r.annotationPermissions||t[8]!==r.collapsedOverride||t[9]!==r.diffStyle||t[10]!==r.toggleFile||t[11]!==r.toggledFiles||t[12]!==r.wordWrap||t[13]!==n.environmentId||t[14]!==n.error||t[15]!==n.hasNextPage||t[16]!==n.loading||t[17]!==n.loadingNextPage||t[18]!==n.onLoadFileContents||t[19]!==n.onLoadNextPage||t[20]!==n.reference||t[21]!==n.slices||t[22]!==a||t[23]!==b||t[24]!==c||t[25]!==l?(x=(0,Q.jsx)(_n,{environmentId:o,reference:s,activity:c,pendingComments:l,annotationPermissions:u,slices:d,loading:f,error:p,hasNextPage:m,loadingNextPage:h,collapsedOverride:g,toggledFiles:_,diffStyle:v,wordWrap:y,revisionKey:b,onToggleFile:r.toggleFile,onLoadNextPage:n.onLoadNextPage,onLoadFileContents:n.onLoadFileContents,...a}),t[7]=r.annotationPermissions,t[8]=r.collapsedOverride,t[9]=r.diffStyle,t[10]=r.toggleFile,t[11]=r.toggledFiles,t[12]=r.wordWrap,t[13]=n.environmentId,t[14]=n.error,t[15]=n.hasNextPage,t[16]=n.loading,t[17]=n.loadingNextPage,t[18]=n.onLoadFileContents,t[19]=n.onLoadNextPage,t[20]=n.reference,t[21]=n.slices,t[22]=a,t[23]=b,t[24]=c,t[25]=l,t[26]=x):x=t[26],x}function Kn(e){let t=(0,$.c)(98),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(Qn),[o,s]=(0,Z.useState)(`unified`),[c,l]=(0,Z.useState)(!0),[u,d]=(0,Z.useState)(!1),[f,m]=(0,Z.useState)(null),[h,_]=(0,Z.useState)(``),v;t[0]!==e.environmentId||t[1]!==e.reference?(v=st(e.environmentId,e.reference),t[0]=e.environmentId,t[1]=e.reference,t[2]=v):v=t[2];let y=v,x;t[3]!==e.environmentId||t[4]!==e.reference?(x={environmentId:e.environmentId,...e.reference},t[3]=e.environmentId,t[4]=e.reference,t[5]=x):x=t[5];let S=ut(x),C=lt(Zn),w=lt(Xn),T=lt(Yn),E;t[6]===y?E=t[7]:(E=e=>e.summaries[y]??``,t[6]=y,t[7]=E);let D=lt(E),O=lt(Jn),k=lt(qn),A,j,M,N,P,F,I,L,R,ee,z,B,V,H,U,W,G,te,K,ne,re,ie,ae,oe,se;if(t[8]!==w||t[9]!==k||t[10]!==n||t[11]!==o||t[12]!==f||t[13]!==h||t[14]!==S||t[15]!==e||t[16]!==T||t[17]!==D||t[18]!==y||t[19]!==u||t[20]!==O||t[21]!==i||t[22]!==c){let v=Mn(e),x;t[48]!==e.detail||t[49]!==e.isDetailFresh?(x=p(e.detail,e.isDetailFresh),t[48]=e.detail,t[49]=e.isDetailFresh,t[50]=x):x=t[50];let C;t[51]!==e.detail||t[52]!==e.isDetailFresh?(C=g(e.detail,e.isDetailFresh),t[51]=e.detail,t[52]=e.isDetailFresh,t[53]=C):C=t[53];let E;t[54]!==e.detail||t[55]!==e.isDetailFresh?(E=b(e.detail,e.isDetailFresh),t[54]=e.detail,t[55]=e.isDetailFresh,t[56]=E):E=t[56];let q;t[57]!==x||t[58]!==C||t[59]!==E?(q={canReply:x,canResolve:C,reactionsEnabled:E},t[57]=x,t[58]=C,t[59]=E,t[60]=q):q=t[60];let ce=q,J;t[61]===e?J=t[62]:(J=Nn(e),t[61]=e,t[62]=J);let le=J,ue;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(ue=()=>{m(null),_(``)},t[63]=ue):ue=t[63],A=ue,K=n,ne=i,re=o,ie=c,ae=u,oe=f,se=h,j=y,M=S,N=ce,P=D,F=le,I=s,L=l,R=d,ee=_,z=O,B=w,V=T,H=k,U=A,t[64]===Symbol.for(`react.memo_cache_sentinel`)?(W=()=>{r($n),a(new Set)},G=e=>a(t=>tr(t,e)),t[64]=W,t[65]=G):(W=t[64],G=t[65]),te=er(v,m,e.onSelectLines),t[8]=w,t[9]=k,t[10]=n,t[11]=o,t[12]=f,t[13]=h,t[14]=S,t[15]=e,t[16]=T,t[17]=D,t[18]=y,t[19]=u,t[20]=O,t[21]=i,t[22]=c,t[23]=A,t[24]=j,t[25]=M,t[26]=N,t[27]=P,t[28]=F,t[29]=I,t[30]=L,t[31]=R,t[32]=ee,t[33]=z,t[34]=B,t[35]=V,t[36]=H,t[37]=U,t[38]=W,t[39]=G,t[40]=te,t[41]=K,t[42]=ne,t[43]=re,t[44]=ie,t[45]=ae,t[46]=oe,t[47]=se}else A=t[23],j=t[24],M=t[25],N=t[26],P=t[27],F=t[28],I=t[29],L=t[30],R=t[31],ee=t[32],z=t[33],B=t[34],V=t[35],H=t[36],U=t[37],W=t[38],G=t[39],te=t[40],K=t[41],ne=t[42],re=t[43],ie=t[44],ae=t[45],oe=t[46],se=t[47];let q;t[66]!==C||t[67]!==f||t[68]!==h||t[69]!==A||t[70]!==y?(q=()=>nr({draftAnchor:f,draftBody:h,reviewKey:y,addComment:C,resetDraft:A}),t[66]=C,t[67]=f,t[68]=h,t[69]=A,t[70]=y,t[71]=q):q=t[71];let ce;return t[72]!==j||t[73]!==M||t[74]!==N||t[75]!==P||t[76]!==F||t[77]!==I||t[78]!==L||t[79]!==R||t[80]!==ee||t[81]!==z||t[82]!==B||t[83]!==V||t[84]!==H||t[85]!==U||t[86]!==W||t[87]!==G||t[88]!==te||t[89]!==q||t[90]!==K||t[91]!==ne||t[92]!==re||t[93]!==ie||t[94]!==ae||t[95]!==oe||t[96]!==se?(ce={collapsedOverride:K,toggledFiles:ne,diffStyle:re,wordWrap:ie,reviewOpen:ae,draftAnchor:oe,draftBody:se,reviewKey:j,pendingComments:M,annotationPermissions:N,reviewBody:P,verdicts:F,setDiffStyle:I,setWordWrap:L,setReviewOpen:R,setDraftBody:ee,setReviewBody:z,clearComments:B,removeComments:V,clearReviewBody:H,resetDraft:U,toggleAll:W,toggleFile:G,onSelectLines:te,addDraft:q},t[72]=j,t[73]=M,t[74]=N,t[75]=P,t[76]=F,t[77]=I,t[78]=L,t[79]=R,t[80]=ee,t[81]=z,t[82]=B,t[83]=V,t[84]=H,t[85]=U,t[86]=W,t[87]=G,t[88]=te,t[89]=q,t[90]=K,t[91]=ne,t[92]=re,t[93]=ie,t[94]=ae,t[95]=oe,t[96]=se,t[97]=ce):ce=t[97],ce}function qn(e){return e.clearSummary}function Jn(e){return e.setSummary}function Yn(e){return e.removeComments}function Xn(e){return e.clear}function Zn(e){return e.addComment}function Qn(){return new Set}function $n(e){return e===`expanded`?`folded`:`expanded`}function er(e,t,n){if(e)return e=>{t(e),n!==void 0&&n(e)}}function tr(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function nr(e){let t=e.draftBody.trim();t.length!==0&&e.draftAnchor!==null&&(e.addComment(e.reviewKey,{id:ot(),path:e.draftAnchor.path,...e.draftAnchor.oldPath===null?{}:{oldPath:e.draftAnchor.oldPath},position:e.draftAnchor.position,body:t}),e.resetDraft())}function rr(e){let t=(0,$.c)(11),n;t[0]!==e.model.addDraft||t[1]!==e.model.draftAnchor||t[2]!==e.model.draftBody||t[3]!==e.model.resetDraft||t[4]!==e.model.setDraftBody?(n=e.model.draftAnchor===null?null:(0,Q.jsx)(Fn,{anchor:e.model.draftAnchor,body:e.model.draftBody,onBodyChange:e.model.setDraftBody,onCancel:e.model.resetDraft,onAdd:e.model.addDraft}),t[0]=e.model.addDraft,t[1]=e.model.draftAnchor,t[2]=e.model.draftBody,t[3]=e.model.resetDraft,t[4]=e.model.setDraftBody,t[5]=n):n=t[5];let r;t[6]===e?r=t[7]:(r=(0,Q.jsx)(ir,{...e}),t[6]=e,t[7]=r);let i;return t[8]!==n||t[9]!==r?(i=(0,Q.jsxs)(Q.Fragment,{children:[n,r]}),t[8]=n,t[9]=r,t[10]=i):i=t[10],i}function ir(e){let t=(0,$.c)(21);if(e.model.verdicts.length===0)return null;if(!e.model.reviewOpen){let n;t[0]===e.model?n=t[1]:(n=()=>e.model.setReviewOpen(!0),t[0]=e.model,t[1]=n);let r=e.model.pendingComments.length>0?` (${e.model.pendingComments.length})`:``,i;return t[2]!==n||t[3]!==r?(i=(0,Q.jsxs)(`button`,{type:`button`,className:`absolute bottom-3 right-4 rounded-md bg-foreground px-3 py-1.5 text-xs font-medium text-background shadow-sm hover:opacity-90`,onClick:n,children:[`Review`,r]}),t[2]=n,t[3]=r,t[4]=i):i=t[4],i}let n,r;t[5]===e.model?(n=t[6],r=t[7]):(n=t=>e.model.setReviewBody(e.model.reviewKey,t),r=t=>{t.length===0&&e.model.clearComments(e.model.reviewKey)},t[5]=e.model,t[6]=n,t[7]=r);let i;t[8]!==e.model||t[9]!==e.props?(i=async t=>{await e.props.onSubmitReview(t),e.model.removeComments(e.model.reviewKey,e.model.pendingComments.map(ar)),e.model.clearReviewBody(e.model.reviewKey,t.body),e.model.setReviewOpen(!1)},t[8]=e.model,t[9]=e.props,t[10]=i):i=t[10];let a;t[11]===e.model?a=t[12]:(a=()=>e.model.setReviewOpen(!1),t[11]=e.model,t[12]=a);let o;return t[13]!==e.model.pendingComments||t[14]!==e.model.reviewBody||t[15]!==e.model.verdicts||t[16]!==n||t[17]!==r||t[18]!==i||t[19]!==a?(o=(0,Q.jsx)(Vn,{verdicts:e.model.verdicts,pendingComments:e.model.pendingComments,body:e.model.reviewBody,onBodyChange:n,onPendingCommentsChange:r,onSubmit:i,onClose:a}),t[13]=e.model.pendingComments,t[14]=e.model.reviewBody,t[15]=e.model.verdicts,t[16]=n,t[17]=r,t[18]=i,t[19]=a,t[20]=o):o=t[20],o}function ar(e){return e.id}function or(e){let t=(0,$.c)(27),n=D(),r;t[0]!==e.environmentId||t[1]!==e.reference||t[2]!==e.selectedCommitOid?(r=o({environmentId:e.environmentId,input:{...e.reference,...e.selectedCommitOid===null?{}:{commit:e.selectedCommitOid}}}),t[0]=e.environmentId,t[1]=e.reference,t[2]=e.selectedCommitOid,t[3]=r):r=t[3];let i=r,a=fe(i),s=m(e.environmentId,e.reference),c;t[4]===a.data?.pages?c=t[5]:(c=a.data?.pages??[],t[4]=a.data?.pages,t[5]=c);let l;t[6]===a?l=t[7]:(l=()=>void a.fetchNextPage(),t[6]=a,t[7]=l);let u;t[8]!==i||t[9]!==n?(u=()=>void n.resetQueries({queryKey:i.queryKey,exact:!0}),t[8]=i,t[9]=n,t[10]=u):u=t[10];let d;t[11]!==e.reference||t[12]!==e.selectedCommitOid?(d=async t=>{if(e.reference.projectRepositoryId===void 0)throw Error(`This pull request has no canonical Command repository identity.`);return L.getPullRequestDiffFileContents({projectId:Number(e.reference.projectId),projectRepositoryId:e.reference.projectRepositoryId,number:e.reference.number,...t,...e.selectedCommitOid===null?{}:{commit:e.selectedCommitOid}})},t[11]=e.reference,t[12]=e.selectedCommitOid,t[13]=d):d=t[13];let f;t[14]!==s||t[15]!==e.reference?(f=t=>s.execute(async()=>{if(e.reference.projectRepositoryId===void 0)throw Error(`This pull request has no canonical Command repository identity.`);await L.submitPullRequestReview({projectId:Number(e.reference.projectId),projectRepositoryId:e.reference.projectRepositoryId,number:e.reference.number,idempotencyKey:crypto.randomUUID(),verdict:t.verdict,body:t.body,comments:t.comments.map(sr)})}),t[14]=s,t[15]=e.reference,t[16]=f):f=t[16];let p;return t[17]!==a.error||t[18]!==a.hasNextPage||t[19]!==a.isFetchingNextPage||t[20]!==a.isPending||t[21]!==c||t[22]!==l||t[23]!==u||t[24]!==d||t[25]!==f?(p={slices:c,loading:a.isPending,error:a.error,hasNextPage:a.hasNextPage,loadingNextPage:a.isFetchingNextPage,loadNextPage:l,refresh:u,loadFileContents:d,submitReview:f},t[17]=a.error,t[18]=a.hasNextPage,t[19]=a.isFetchingNextPage,t[20]=a.isPending,t[21]=c,t[22]=l,t[23]=u,t[24]=d,t[25]=f,t[26]=p):p=t[26],p}function sr(e){return{path:e.path,...e.oldPath===void 0?{}:{oldPath:e.oldPath},position:{...e.position},body:e.body}}function cr(e){let t=(0,$.c)(23),[n,r]=(0,Z.useState)(null),i;t[0]!==e.activity?.commits||t[1]!==n?(i=e.activity?.commits.some(e=>e.oid===n)?n:null,t[0]=e.activity?.commits,t[1]=n,t[2]=i):i=t[2];let a=i,o;t[3]!==e.environmentId||t[4]!==e.reference||t[5]!==a?(o={environmentId:e.environmentId,reference:e.reference,selectedCommitOid:a},t[3]=e.environmentId,t[4]=e.reference,t[5]=a,t[6]=o):o=t[6];let s=or(o),c;t[7]!==s.slices||t[8]!==e?(c=t=>e.onSelectLines({...t,patch:w(s.slices.map(lr).join(`
4
4
  `),t.path)}),t[7]=s.slices,t[8]=e,t[9]=c):c=t[9];let l;return t[10]!==s.error||t[11]!==s.hasNextPage||t[12]!==s.loadFileContents||t[13]!==s.loadNextPage||t[14]!==s.loading||t[15]!==s.loadingNextPage||t[16]!==s.refresh||t[17]!==s.slices||t[18]!==s.submitReview||t[19]!==e||t[20]!==a||t[21]!==c?(l=(0,Q.jsx)(Hn,{...e,selectedCommitOid:a,slices:s.slices,loading:s.loading,error:s.error,hasNextPage:s.hasNextPage,loadingNextPage:s.loadingNextPage,onSelectedCommitChange:r,onLoadNextPage:s.loadNextPage,onRefresh:s.refresh,onLoadFileContents:s.loadFileContents,onSubmitReview:s.submitReview,onSelectLines:c}),t[10]=s.error,t[11]=s.hasNextPage,t[12]=s.loadFileContents,t[13]=s.loadNextPage,t[14]=s.loading,t[15]=s.loadingNextPage,t[16]=s.refresh,t[17]=s.slices,t[18]=s.submitReview,t[19]=e,t[20]=a,t[21]=c,t[22]=l):l=t[22],l}function lr(e){return e.patch}export{cr as default};
5
- //# sourceMappingURL=PullRequestCodePanel-inwJYfZC.js.map
5
+ //# sourceMappingURL=PullRequestCodePanel-BpbniIb5.js.map
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`forge-web@0.9.10`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`69e15ad8-581f-4bb2-8143-40eaaebdd7ca`,e._sentryDebugIdIdentifier=`sentry-dbid-69e15ad8-581f-4bb2-8143-40eaaebdd7ca`)}catch{}})();import{r as e}from"./rolldown-runtime-BaTzPAyU.js";import{Ba as t,Va as n,za as r}from"./Stream-D8tJNlvy.js";import{$t as i,Gn as a,Hn as o,Jt as s,en as c,fc as l,ga as u,mr as d}from"./DiffPanelShell-tIdXu7mn.js";import{Ft as f,J as p,Nn as m,Z as h,a as g,c as _,d as v,et as y,f as b,gn as x,it as S,l as C,m as w,n as T,o as E,ot as D,p as O,pn as k,rt as A,s as j,st as M,tt as N,vn as P,x as F,xn as I,yn as L}from"./CompositeItem-Cn5DdObI.js";import{Ot as R}from"./src-DljvAdHI.js";import{n as z,t as B}from"./toggle-It2CvaLA.js";function ee(e){return l({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}var te=m(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),ne=m(`file-diff`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]),V=e(n(),1),H=r(),U=t();function re(e){let t=(0,H.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,orientation:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`horizontal`:i,o;t[4]===n?o=t[5]:(o=I(`shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:not-[[class^='h-']]:not-[[class*='_h-']]:self-stretch`,n),t[4]=n,t[5]=o);let s;return t[6]!==a||t[7]!==r||t[8]!==o?(s=(0,U.jsx)(u,{className:o,"data-slot":`separator`,orientation:a,...r}),t[6]=a,t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function W(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}function ie(e,t){return e==null||t==null?e===t:e.top===t.top&&e.bottom===t.bottom}var G=1e3,ae=G*4,oe=[0,1e-6,.99999,1],se={overscrollSize:G,intersectionObserverMargin:ae,resizeDebugging:!1},K=0,ce=-1,le=class e{static __STOP=!1;static __lastScrollPosition=0;__id=`virtualizer-${++ce}`;config;type=`simple`;intersectionObserver;scrollTop=0;height=0;scrollHeight=0;windowSpecs={top:0,bottom:0};root;contentContainer;resizeObserver;observers=new Map;visibleInstances=new Map;visibleInstancesDirty=!1;instancesChanged=new Set;reconcileQueue=new Set;scrollDirty=!0;heightDirty=!0;scrollHeightDirty=!0;renderedObservers=0;connectQueue=new Map;constructor(e){this.config={...se,...e}}setup(t,n){if(this.root==null){this.root=t,this.resizeObserver=new ResizeObserver(this.handleContainerResize),this.intersectionObserver=new IntersectionObserver(this.handleIntersectionChange,{root:this.root,threshold:oe,rootMargin:`${this.config.intersectionObserverMargin}px 0px ${this.config.intersectionObserverMargin}px 0px`}),t instanceof Document?this.setupWindow():this.setupElement(n),window.__INSTANCE=this,window.__TOGGLE=()=>{e.__STOP?(e.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:e.__lastScrollPosition}),c(this.computeRenderRangeAndEmit)):(e.__lastScrollPosition=this.getScrollTop(),e.__STOP=!0)};for(let[e,t]of this.connectQueue.entries())this.connect(e,t);this.connectQueue.clear(),this.markDOMDirty(),c(this.computeRenderRangeAndEmit)}}instanceChanged(e,t){this.instancesChanged.add(e),t&&this.markDOMDirty(),c(this.computeRenderRangeAndEmit)}requestHeightReconcile(e){this.reconcileQueue.add(e),c(this.computeRenderRangeAndEmit)}getWindowSpecs(){return this.windowSpecs.top===0&&this.windowSpecs.bottom===0&&(this.windowSpecs=s({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize})),this.windowSpecs}getRoot(){return this.root}isInstanceVisible(e,t){let n=this.getScrollTop(),r=this.getHeight(),i=this.config.intersectionObserverMargin,a=n-i,o=n+r+i;return!(e<a-t||e>o)}handleContainerResize=e=>{if(this.root==null)return;let t=!1;for(let n of e){let e=n.borderBoxSize[0].blockSize;this.root instanceof Document?e!==this.scrollHeight&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log(`Virtualizer: content size change`,this.__id,{sizeChange:e-K,newSize:e}),K=e)):n.target===this.root?e!==this.height&&(this.heightDirty=!0,t=!0):n.target===this.contentContainer&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log(`Virtualizer: scroller size change`,this.__id,{sizeChange:e-K,newSize:e}),K=e))}t&&c(this.computeRenderRangeAndEmit)};setupWindow(){if(this.root==null||!(this.root instanceof Document))throw Error(`Virtualizer.setupWindow: Invalid setup method`);window.addEventListener(`scroll`,this.handleWindowScroll,{passive:!0}),window.addEventListener(`resize`,this.handleWindowResize,{passive:!0}),this.resizeObserver?.observe(this.root.documentElement)}setupElement(e){if(this.root==null||this.root instanceof Document)throw Error(`Virtualizer.setupElement: Invalid setup method`);this.root.addEventListener(`scroll`,this.handleElementScroll,{passive:!0}),this.resizeObserver?.observe(this.root),e??=this.root.firstElementChild??void 0,e instanceof HTMLElement&&(this.contentContainer=e,this.resizeObserver?.observe(e))}cleanUp(){i(this.computeRenderRangeAndEmit),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.root?.removeEventListener(`scroll`,this.handleElementScroll),window.removeEventListener(`scroll`,this.handleWindowScroll),window.removeEventListener(`resize`,this.handleWindowResize),this.root=void 0,this.contentContainer=void 0,this.observers.clear(),this.visibleInstances.clear(),this.instancesChanged.clear(),this.reconcileQueue.clear(),this.connectQueue.clear(),this.visibleInstancesDirty=!1,this.windowSpecs={top:0,bottom:0},this.scrollTop=0,this.height=0,this.scrollHeight=0,this.scrollDirty=!0,this.heightDirty=!0,this.scrollHeightDirty=!0}getOffsetInScrollContainer(e){return this.getScrollTop()+q(e,this.getScrollContainerElement())}connect(e,t){if(this.observers.has(e))throw Error(`Virtualizer.connect: instance is already connected...`);return this.intersectionObserver==null?this.connectQueue.set(e,t):(this.intersectionObserver.observe(e),this.observers.set(e,t),this.instancesChanged.add(t),this.markDOMDirty(),c(this.computeRenderRangeAndEmit)),()=>this.disconnect(e)}disconnect(e){let t=this.observers.get(e);this.connectQueue.delete(e),t!=null&&(this.intersectionObserver?.unobserve(e),this.observers.delete(e),this.instancesChanged.delete(t),this.reconcileQueue.delete(t),this.visibleInstances.delete(e)&&(this.visibleInstancesDirty=!0),this.markDOMDirty(),c(this.computeRenderRangeAndEmit))}handleWindowResize=()=>{e.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,c(this.computeRenderRangeAndEmit))};handleWindowScroll=()=>{e.__STOP||this.root==null||!(this.root instanceof Document)||(this.scrollDirty=!0,c(this.computeRenderRangeAndEmit))};handleElementScroll=()=>{e.__STOP||this.root==null||this.root instanceof Document||(this.scrollDirty=!0,c(this.computeRenderRangeAndEmit))};computeRenderRangeAndEmit=()=>{if(e.__STOP)return;let t=this.heightDirty||this.scrollHeightDirty,n=this.instancesChanged.size>0;if(this.instancesChanged.size===0){let e=s({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize});if(!t&&ie(this.windowSpecs,e)&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&this.reconcileQueue.size===0)return;this.windowSpecs=e}this.visibleInstancesDirty=!1,this.renderedObservers=this.observers.size;let r=this.getScrollAnchor(this.height),i=new Set;for(let e of t?this.observers.values():this.visibleInstances.values())e.onRender(t)&&i.add(e);for(let e of this.instancesChanged)i.has(e)||e.onRender(t)&&i.add(e);this.scrollFix(r);for(let e of i)this.reconcileQueue.delete(e),e.reconcileHeights();for(let e of this.reconcileQueue)e.reconcileHeights()&&(n=!0);this.reconcileQueue.clear(),n||=this.instancesChanged.size>0,n&&this.markDOMDirty(),(n||t)&&c(this.computeRenderRangeAndEmit),i.clear(),this.instancesChanged.clear()};scrollFix(e){if(e==null)return;let t=this.getScrollContainerElement(),{lineIndex:n,lineOffset:r,fileElement:i,fileOffset:a,fileTypeOffset:o}=e;if(n!=null&&r!=null){let e=i.shadowRoot?.querySelector(`[data-line][data-line-index="${n}"]`);if(e instanceof HTMLElement){let n=q(e,t);if(n!==r){let e=n-r;this.applyScrollFix(e)}return}}let s=q(i,t);if(o===`top`)s!==a&&this.applyScrollFix(s-a);else{let e=s+i.getBoundingClientRect().height;e!==a&&this.applyScrollFix(e-a)}}applyScrollFix(e){this.root==null||this.root instanceof Document?window.scrollTo({top:window.scrollY+e,behavior:`instant`}):this.root.scrollTo({top:this.root.scrollTop+e,behavior:`instant`}),this.markDOMDirty()}getScrollAnchor(e){let t=this.getScrollContainerElement(),n;for(let[r]of this.visibleInstances.entries()){let i=q(r,t),a=i+r.offsetHeight,o,s;a<=0?(o=a,s=`bottom`):(o=i,s=`top`);let c,l;if(a>0&&i<e)for(let e of r.shadowRoot?.querySelectorAll(`[data-line][data-line-index]`)??[]){if(!(e instanceof HTMLElement))continue;let n=e.dataset.lineIndex;if(n==null)continue;let r=q(e,t);if(!(r<0)){c=n,l=r;break}}if(n?.lineOffset!=null&&l==null)continue;let u=!1;(n==null||l!=null&&(n.lineOffset==null||l<n.lineOffset)||l==null&&n.lineOffset==null&&(o>=0&&(n.fileOffset<0||o<n.fileOffset)||o<0&&n.fileOffset<0&&o>n.fileOffset))&&(u=!0),u&&(n={fileElement:r,fileTypeOffset:s,fileOffset:o,lineIndex:c,lineOffset:l})}return n}handleIntersectionChange=e=>{this.scrollDirty=!0;for(let{target:t,isIntersecting:n}of e){if(!(t instanceof HTMLElement))throw Error(`Virtualizer.handleIntersectionChange: target not an HTMLElement`);let e=this.observers.get(t);e!=null&&(n&&!this.visibleInstances.has(t)?(e.setVisibility(!0),this.visibleInstances.set(t,e),this.visibleInstancesDirty=!0):!n&&this.visibleInstances.has(t)&&(e.setVisibility(!1),this.visibleInstances.delete(t),this.visibleInstancesDirty=!0))}this.visibleInstancesDirty&&c(this.computeRenderRangeAndEmit)};getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root==null?0:this.root instanceof Document?window.scrollY:this.root.scrollTop;return e=this.clampScrollTop(e),this.scrollTop=e,e}scrollTo({top:e,behavior:t=`auto`}){let{root:n}=this;if(n==null)return;let r=this.clampScrollTop(e);n instanceof Document?window.scrollTo({top:r,behavior:t}):n.scrollTo({top:r,behavior:t}),this.scrollDirty=!0,c(this.computeRenderRangeAndEmit)}clampScrollTop(e){return Math.max(0,Math.min(e,this.getScrollHeight()-this.getHeight()))}getScrollHeight(){return this.scrollHeightDirty?(this.scrollHeightDirty=!1,this.scrollHeight=this.root==null?0:this.root instanceof Document?this.root.documentElement.scrollHeight:this.root.scrollHeight,this.scrollHeight):this.scrollHeight}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root==null?0:this.root instanceof Document?globalThis.innerHeight:this.root.getBoundingClientRect().height,this.height):this.height}markDOMDirty(){this.scrollDirty=!0,this.scrollHeightDirty=!0,this.heightDirty=!0}getScrollContainerElement(){return this.root==null||this.root instanceof Document?void 0:this.root}};function q(e,t){let n=e.getBoundingClientRect(),r=t?.getBoundingClientRect().top??0;return n.top-r}var ue=o.filter(e=>e!==`file`&&e!==`pull-request`);function J(e){return e===`1`||e===1||e===!0}function de(e){return e===`0`||e===0||e===!1}function Y(e){if(typeof e!=`string`)return;let t=e.trim();return t.length>0?t:void 0}function X(e){return typeof e==`string`&&ue.includes(e)}function Z(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}function fe(e){if(Array.isArray(e))return Z(e.filter(X));if(typeof e!=`string`)return[];let t=e.trim();if(t.startsWith(`[`)&&t.endsWith(`]`))try{let e=JSON.parse(t);return Array.isArray(e)?Z(e.filter(X)):[]}catch{return[]}return Z(t.split(`,`).map(e=>e.trim()).filter(X))}function pe(e){if(J(e.canvas))return`canvas`;if(J(e.preview))return`preview`;if(J(e.diff))return`diff`}function me(e,t){let n=fe(e.rightPanelTabs),r=Z(t&&!n.includes(t)?[...n,t]:n),i=Y(e.rightPanelTabs)!==void 0,a=J(e.rightPanelOpen),o=de(e.rightPanelOpen);return{rightPanelOpen:a?!0:!o&&i,rightPanelTabs:r,stated:a||o||i,hasExplicitTabs:i}}function he(e,t){if(t===`preview`){let t=Y(e.previewTabId);return t?{previewTabId:t}:{}}if(t!==`diff`)return{};let n=Y(e.diffTurnId);if(!n)return{};let r=R.make(n),i=Y(e.diffFilePath);return i?{diffTurnId:r,diffFilePath:i}:{diffTurnId:r}}function ge(e){let t=(X(e.rightPanel)?e.rightPanel:void 0)??pe(e),n=me(e,t);return{...n.stated?{rightPanelOpen:n.rightPanelOpen}:{},...t?{rightPanel:t}:{},...n.hasExplicitTabs&&n.rightPanelTabs.length>0?{rightPanelTabs:n.rightPanelTabs}:{},...he(e,t)}}function _e(e){let t=(0,H.c)(6),n;bb0:{if(!e){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],n=e;break bb0}n=e.turnDiffSummaries}let r=n,i,a;t[1]===r?a=t[2]:(a=d(r),t[1]=r,t[2]=a),i=a;let o=i,s;return t[3]!==o||t[4]!==r?(s={turnDiffSummaries:r,inferredCheckpointTurnCountByTurnId:o},t[3]=o,t[4]=r,t[5]=s):s=t[5],s}var ve=[];function ye(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:u,disabledIndices:d,modifierKeys:p=ve}=e,[m,h]=V.useState(0),v=r!=null,w=V.useRef(null),T=y(w,c),P=V.useRef([]),F=V.useRef(!1),I=o??m,L=k((e,t=!1)=>{if((s??h)(e),t){let t=P.current[e];O(w.current,t,a,n)}}),R=k(e=>{if(e.size===0||F.current)return;F.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)L(i);else if(M(t,I,d)){let e=N(t,{disabledIndices:d});D(t,e)||L(e)}O(w.current,r,a,n)});x(()=>{if(d==null||o!=null||!F.current)return;let e=P.current;if(M(e,I,d)){let t=N(e,{disabledIndices:d});D(e,t)||L(t)}},[d,o,I,P,L]);let z=k((e,t,n)=>i?i(e,t,n,P):n),B=k(e=>{let o=e.key===`Home`||e.key===`End`;if(!C.has(e.key)||!l&&o||be(e,p)||!w.current)return;let s=a===`rtl`,c=s?E:j,m=s?j:E,h=n===`vertical`?g:c,y=n===`vertical`?_:m,x=f(e.nativeEvent);if(x!=null&&b(x)&&!W(x)){let t=x.selectionStart,n=x.selectionEnd,r=x.value;if(t==null||e.shiftKey||t!==n||e.key!==y&&t<r.length||e.key!==h&&t>0)return}let T=I,O=S(P,d),k=A(P,d);r!=null&&(T=r({disabledIndices:d,elementsRef:P,event:e,highlightedIndex:I,loopFocus:t,maxIndex:k,minIndex:O,onLoop:z,orientation:n,rtl:s}));let M=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,F=n!==`vertical`&&e.key===m||n!==`horizontal`&&e.key===`ArrowUp`;l&&(e.key===`Home`?T=O:e.key===`End`&&(T=k)),T===I&&(M||F)&&(t&&T===k&&M?(T=O,i&&(T=i(e,I,T,P))):t&&T===O&&F?(T=k,i&&(T=i(e,I,T,P))):T=N(P.current,{startingIndex:T,decrement:F,disabledIndices:d})),T!==I&&!D(P.current,T)&&(u&&e.stopPropagation(),(v||o||M||F)&&e.preventDefault(),L(T,!0),queueMicrotask(()=>{P.current[T]?.focus()}))});return{props:{ref:T,onFocus(e){let t=w.current,n=f(e.nativeEvent);!t||n==null||!b(n)||n.setSelectionRange(0,n.value.length)},onKeyDown:B},highlightedIndex:I,onHighlightedIndexChange:L,elementsRef:P,onMapChange:R,relayKeyboardEvent:B}}function be(e,t){for(let n of v)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function xe(e){let{render:t,className:n,style:r,refs:i=P,props:o=P,state:s=L,stateAttributesMapping:c,highlightedIndex:l,onHighlightedIndexChange:u,orientation:d,grid:f,loopFocus:m,onLoop:g,enableHomeAndEndKeys:_,onMapChange:v,stopEventPropagation:y=!0,rootRef:b,disabledIndices:x,modifierKeys:S,highlightItemOnHover:C=!1,tag:w=`div`,...T}=e,{props:E,highlightedIndex:D,onHighlightedIndexChange:O,elementsRef:k,onMapChange:A,relayKeyboardEvent:j}=ye({grid:f,loopFocus:m,onLoop:g,orientation:d,highlightedIndex:l,onHighlightedIndexChange:u,rootRef:b,stopEventPropagation:y,enableHomeAndEndKeys:_,direction:F(),disabledIndices:x,modifierKeys:S}),M=h(w,e,{state:s,ref:i,props:[E,...o,T],stateAttributesMapping:c}),N=V.useMemo(()=>({highlightedIndex:D,onHighlightedIndexChange:O,highlightItemOnHover:C,relayKeyboardEvent:j}),[D,O,C,j]);return(0,U.jsx)(p.Provider,{value:N,children:(0,U.jsx)(a,{elementsRef:k,onMapChange:e=>{v?.(e),A(e)},children:M})})}var Se=V.createContext(void 0);function Ce(){return V.useContext(Se)}var we=V.forwardRef(function(e,t){let{defaultValue:n,disabled:r=!1,loopFocus:i=!0,onValueChange:a,orientation:o=`horizontal`,multiple:s=!1,value:c,className:l,render:u,style:d,...f}=e,p=T(!0),m=Ce(),g=c!==void 0||n!==void 0,_=(p?.disabled??!1)||(m?.disabled??!1)||r,[v,y]=w({controlled:c,default:c===void 0?n??P:void 0,name:`ToggleGroup`,state:`value`}),b=k((e,t,n)=>{let r;s?(r=v.slice(),t?r.push(e):r.splice(v.indexOf(e),1)):r=t?[e]:[],a?.(r,n),!n.isCanceled&&y(r)}),x={disabled:_,multiple:s,orientation:o},S=V.useMemo(()=>({disabled:_,setGroupValue:b,value:v,isValueInitialized:g}),[_,b,v,g]),C={role:`group`},E=h(`div`,e,{enabled:!!p,state:x,ref:t,props:[C,f]});return(0,U.jsx)(z.Provider,{value:S,children:p?E:(0,U.jsx)(xe,{render:u,className:l,style:d,state:x,refs:[t],props:[C,f],loopFocus:i,enableHomeAndEndKeys:!0,orientation:o})})}),Q=V.createContext({size:`default`,variant:`default`});function Te({className:e,variant:t=`default`,size:n=t===`segmented`?`segmented`:`default`,orientation:r=`horizontal`,children:i,...a}){let o=V.useMemo(()=>({size:n,variant:t}),[n,t]);return(0,U.jsx)(we,{className:I(`flex w-fit *:focus-visible:z-10 dark:*:[[data-slot=separator]:has(+[data-slot=toggle]:hover)]:before:bg-input/64 dark:*:[[data-slot=separator]:has(+[data-slot=toggle][data-pressed])]:before:bg-input dark:*:[[data-slot=toggle]:hover+[data-slot=separator]]:before:bg-input/64 dark:*:[[data-slot=toggle][data-pressed]+[data-slot=separator]]:before:bg-input`,r===`horizontal`?`*:pointer-coarse:after:min-w-auto`:`*:pointer-coarse:after:min-h-auto`,t===`segmented`?`gap-0.5 rounded-lg bg-input/40 p-0.5`:t==="default"?`gap-0.5`:r===`horizontal`?`*:not-first:not-data-[slot=separator]:before:-start-[0.5px] *:not-last:not-data-[slot=separator]:before:-end-[0.5px] *:not-first:rounded-s-none *:not-last:rounded-e-none *:not-first:border-s-0 *:not-last:border-e-0 *:not-first:before:rounded-s-none *:not-last:before:rounded-e-none`:`*:not-first:not-data-[slot=separator]:before:-top-[0.5px] *:not-last:not-data-[slot=separator]:before:-bottom-[0.5px] flex-col *:not-first:rounded-t-none *:not-last:rounded-b-none *:not-first:border-t-0 *:not-last:border-b-0 *:not-first:before:rounded-t-none *:not-last:before:rounded-b-none *:data-[slot=toggle]:not-last:before:hidden dark:*:last:before:hidden dark:*:first:before:block`,e),"data-size":n,"data-slot":`toggle-group`,"data-variant":t,orientation:r,...a,children:(0,U.jsx)(Q.Provider,{value:o,children:i})})}function Ee(e){let t=(0,H.c)(12),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,variant:o,size:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=V.useContext(Q),c=o??s.variant,l=a??s.size,u;return t[6]!==n||t[7]!==r||t[8]!==i||t[9]!==l||t[10]!==c?(u=(0,U.jsx)(B,{className:r,"data-size":l,"data-variant":c,size:l,variant:c,...i,children:n}),t[6]=n,t[7]=r,t[8]=i,t[9]=l,t[10]=c,t[11]=u):u=t[11],u}function De(e){return e.threadWorktreePath??e.projectCwd??void 0}function Oe(e){return e?.isRepo??!0}function ke(e,t){return typeof window>`u`&&t!=null?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`template`,{shadowrootmode:`open`,dangerouslySetInnerHTML:{__html:t}}),e]}):(0,U.jsx)(U.Fragment,{children:e})}var $=(0,V.createContext)(void 0);function Ae({children:e,config:t,className:n,style:r,contentClassName:i,contentStyle:a}){let[o]=(0,V.useState)(()=>typeof window<`u`?new le(t):void 0),s=(0,V.useCallback)(e=>{e==null?o?.cleanUp():o?.setup(e)},[o]);return(0,U.jsx)($.Provider,{value:o,children:(0,U.jsx)(`div`,{className:n,style:r,ref:s,children:(0,U.jsx)(`div`,{className:i,style:a,children:e})})})}function je(){return(0,V.useContext)($)}export{Oe as a,_e as c,re as d,ne as f,De as i,ge as l,ee as m,je as n,Ee as o,te as p,ke as r,Te as s,Ae as t,W as u};
2
- //# sourceMappingURL=Virtualizer-DeKxnAeU.js.map
1
+ (function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`forge-web@0.9.10`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`69e15ad8-581f-4bb2-8143-40eaaebdd7ca`,e._sentryDebugIdIdentifier=`sentry-dbid-69e15ad8-581f-4bb2-8143-40eaaebdd7ca`)}catch{}})();import{r as e}from"./rolldown-runtime-BaTzPAyU.js";import{Ba as t,Va as n,za as r}from"./Stream-D8tJNlvy.js";import{$t as i,Gn as a,Hn as o,Jt as s,en as c,fc as l,ga as u,mr as d}from"./DiffPanelShell-R1Q66jTc.js";import{Ft as f,J as p,Nn as m,Z as h,a as g,c as _,d as v,et as y,f as b,gn as x,it as S,l as C,m as w,n as T,o as E,ot as D,p as O,pn as k,rt as A,s as j,st as M,tt as N,vn as P,x as F,xn as I,yn as L}from"./CompositeItem-Bsi2e5qV.js";import{Ot as R}from"./src-BL6J64vk.js";import{n as z,t as B}from"./toggle-CW3yNjj1.js";function ee(e){return l({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}var te=m(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),ne=m(`file-diff`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]),V=e(n(),1),H=r(),U=t();function re(e){let t=(0,H.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,orientation:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`horizontal`:i,o;t[4]===n?o=t[5]:(o=I(`shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:not-[[class^='h-']]:not-[[class*='_h-']]:self-stretch`,n),t[4]=n,t[5]=o);let s;return t[6]!==a||t[7]!==r||t[8]!==o?(s=(0,U.jsx)(u,{className:o,"data-slot":`separator`,orientation:a,...r}),t[6]=a,t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function W(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}function ie(e,t){return e==null||t==null?e===t:e.top===t.top&&e.bottom===t.bottom}var G=1e3,ae=G*4,oe=[0,1e-6,.99999,1],se={overscrollSize:G,intersectionObserverMargin:ae,resizeDebugging:!1},K=0,ce=-1,le=class e{static __STOP=!1;static __lastScrollPosition=0;__id=`virtualizer-${++ce}`;config;type=`simple`;intersectionObserver;scrollTop=0;height=0;scrollHeight=0;windowSpecs={top:0,bottom:0};root;contentContainer;resizeObserver;observers=new Map;visibleInstances=new Map;visibleInstancesDirty=!1;instancesChanged=new Set;reconcileQueue=new Set;scrollDirty=!0;heightDirty=!0;scrollHeightDirty=!0;renderedObservers=0;connectQueue=new Map;constructor(e){this.config={...se,...e}}setup(t,n){if(this.root==null){this.root=t,this.resizeObserver=new ResizeObserver(this.handleContainerResize),this.intersectionObserver=new IntersectionObserver(this.handleIntersectionChange,{root:this.root,threshold:oe,rootMargin:`${this.config.intersectionObserverMargin}px 0px ${this.config.intersectionObserverMargin}px 0px`}),t instanceof Document?this.setupWindow():this.setupElement(n),window.__INSTANCE=this,window.__TOGGLE=()=>{e.__STOP?(e.__STOP=!1,(this.getScrollContainerElement()??window).scrollTo({top:e.__lastScrollPosition}),c(this.computeRenderRangeAndEmit)):(e.__lastScrollPosition=this.getScrollTop(),e.__STOP=!0)};for(let[e,t]of this.connectQueue.entries())this.connect(e,t);this.connectQueue.clear(),this.markDOMDirty(),c(this.computeRenderRangeAndEmit)}}instanceChanged(e,t){this.instancesChanged.add(e),t&&this.markDOMDirty(),c(this.computeRenderRangeAndEmit)}requestHeightReconcile(e){this.reconcileQueue.add(e),c(this.computeRenderRangeAndEmit)}getWindowSpecs(){return this.windowSpecs.top===0&&this.windowSpecs.bottom===0&&(this.windowSpecs=s({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize})),this.windowSpecs}getRoot(){return this.root}isInstanceVisible(e,t){let n=this.getScrollTop(),r=this.getHeight(),i=this.config.intersectionObserverMargin,a=n-i,o=n+r+i;return!(e<a-t||e>o)}handleContainerResize=e=>{if(this.root==null)return;let t=!1;for(let n of e){let e=n.borderBoxSize[0].blockSize;this.root instanceof Document?e!==this.scrollHeight&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log(`Virtualizer: content size change`,this.__id,{sizeChange:e-K,newSize:e}),K=e)):n.target===this.root?e!==this.height&&(this.heightDirty=!0,t=!0):n.target===this.contentContainer&&(this.scrollHeightDirty=!0,t=!0,this.config.resizeDebugging&&(console.log(`Virtualizer: scroller size change`,this.__id,{sizeChange:e-K,newSize:e}),K=e))}t&&c(this.computeRenderRangeAndEmit)};setupWindow(){if(this.root==null||!(this.root instanceof Document))throw Error(`Virtualizer.setupWindow: Invalid setup method`);window.addEventListener(`scroll`,this.handleWindowScroll,{passive:!0}),window.addEventListener(`resize`,this.handleWindowResize,{passive:!0}),this.resizeObserver?.observe(this.root.documentElement)}setupElement(e){if(this.root==null||this.root instanceof Document)throw Error(`Virtualizer.setupElement: Invalid setup method`);this.root.addEventListener(`scroll`,this.handleElementScroll,{passive:!0}),this.resizeObserver?.observe(this.root),e??=this.root.firstElementChild??void 0,e instanceof HTMLElement&&(this.contentContainer=e,this.resizeObserver?.observe(e))}cleanUp(){i(this.computeRenderRangeAndEmit),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.intersectionObserver?.disconnect(),this.intersectionObserver=void 0,this.root?.removeEventListener(`scroll`,this.handleElementScroll),window.removeEventListener(`scroll`,this.handleWindowScroll),window.removeEventListener(`resize`,this.handleWindowResize),this.root=void 0,this.contentContainer=void 0,this.observers.clear(),this.visibleInstances.clear(),this.instancesChanged.clear(),this.reconcileQueue.clear(),this.connectQueue.clear(),this.visibleInstancesDirty=!1,this.windowSpecs={top:0,bottom:0},this.scrollTop=0,this.height=0,this.scrollHeight=0,this.scrollDirty=!0,this.heightDirty=!0,this.scrollHeightDirty=!0}getOffsetInScrollContainer(e){return this.getScrollTop()+q(e,this.getScrollContainerElement())}connect(e,t){if(this.observers.has(e))throw Error(`Virtualizer.connect: instance is already connected...`);return this.intersectionObserver==null?this.connectQueue.set(e,t):(this.intersectionObserver.observe(e),this.observers.set(e,t),this.instancesChanged.add(t),this.markDOMDirty(),c(this.computeRenderRangeAndEmit)),()=>this.disconnect(e)}disconnect(e){let t=this.observers.get(e);this.connectQueue.delete(e),t!=null&&(this.intersectionObserver?.unobserve(e),this.observers.delete(e),this.instancesChanged.delete(t),this.reconcileQueue.delete(t),this.visibleInstances.delete(e)&&(this.visibleInstancesDirty=!0),this.markDOMDirty(),c(this.computeRenderRangeAndEmit))}handleWindowResize=()=>{e.__STOP||window.innerHeight===this.height||(this.heightDirty=!0,c(this.computeRenderRangeAndEmit))};handleWindowScroll=()=>{e.__STOP||this.root==null||!(this.root instanceof Document)||(this.scrollDirty=!0,c(this.computeRenderRangeAndEmit))};handleElementScroll=()=>{e.__STOP||this.root==null||this.root instanceof Document||(this.scrollDirty=!0,c(this.computeRenderRangeAndEmit))};computeRenderRangeAndEmit=()=>{if(e.__STOP)return;let t=this.heightDirty||this.scrollHeightDirty,n=this.instancesChanged.size>0;if(this.instancesChanged.size===0){let e=s({scrollTop:this.getScrollTop(),height:this.getHeight(),scrollHeight:this.getScrollHeight(),overscrollSize:this.config.overscrollSize});if(!t&&ie(this.windowSpecs,e)&&this.renderedObservers===this.observers.size&&!this.visibleInstancesDirty&&this.reconcileQueue.size===0)return;this.windowSpecs=e}this.visibleInstancesDirty=!1,this.renderedObservers=this.observers.size;let r=this.getScrollAnchor(this.height),i=new Set;for(let e of t?this.observers.values():this.visibleInstances.values())e.onRender(t)&&i.add(e);for(let e of this.instancesChanged)i.has(e)||e.onRender(t)&&i.add(e);this.scrollFix(r);for(let e of i)this.reconcileQueue.delete(e),e.reconcileHeights();for(let e of this.reconcileQueue)e.reconcileHeights()&&(n=!0);this.reconcileQueue.clear(),n||=this.instancesChanged.size>0,n&&this.markDOMDirty(),(n||t)&&c(this.computeRenderRangeAndEmit),i.clear(),this.instancesChanged.clear()};scrollFix(e){if(e==null)return;let t=this.getScrollContainerElement(),{lineIndex:n,lineOffset:r,fileElement:i,fileOffset:a,fileTypeOffset:o}=e;if(n!=null&&r!=null){let e=i.shadowRoot?.querySelector(`[data-line][data-line-index="${n}"]`);if(e instanceof HTMLElement){let n=q(e,t);if(n!==r){let e=n-r;this.applyScrollFix(e)}return}}let s=q(i,t);if(o===`top`)s!==a&&this.applyScrollFix(s-a);else{let e=s+i.getBoundingClientRect().height;e!==a&&this.applyScrollFix(e-a)}}applyScrollFix(e){this.root==null||this.root instanceof Document?window.scrollTo({top:window.scrollY+e,behavior:`instant`}):this.root.scrollTo({top:this.root.scrollTop+e,behavior:`instant`}),this.markDOMDirty()}getScrollAnchor(e){let t=this.getScrollContainerElement(),n;for(let[r]of this.visibleInstances.entries()){let i=q(r,t),a=i+r.offsetHeight,o,s;a<=0?(o=a,s=`bottom`):(o=i,s=`top`);let c,l;if(a>0&&i<e)for(let e of r.shadowRoot?.querySelectorAll(`[data-line][data-line-index]`)??[]){if(!(e instanceof HTMLElement))continue;let n=e.dataset.lineIndex;if(n==null)continue;let r=q(e,t);if(!(r<0)){c=n,l=r;break}}if(n?.lineOffset!=null&&l==null)continue;let u=!1;(n==null||l!=null&&(n.lineOffset==null||l<n.lineOffset)||l==null&&n.lineOffset==null&&(o>=0&&(n.fileOffset<0||o<n.fileOffset)||o<0&&n.fileOffset<0&&o>n.fileOffset))&&(u=!0),u&&(n={fileElement:r,fileTypeOffset:s,fileOffset:o,lineIndex:c,lineOffset:l})}return n}handleIntersectionChange=e=>{this.scrollDirty=!0;for(let{target:t,isIntersecting:n}of e){if(!(t instanceof HTMLElement))throw Error(`Virtualizer.handleIntersectionChange: target not an HTMLElement`);let e=this.observers.get(t);e!=null&&(n&&!this.visibleInstances.has(t)?(e.setVisibility(!0),this.visibleInstances.set(t,e),this.visibleInstancesDirty=!0):!n&&this.visibleInstances.has(t)&&(e.setVisibility(!1),this.visibleInstances.delete(t),this.visibleInstancesDirty=!0))}this.visibleInstancesDirty&&c(this.computeRenderRangeAndEmit)};getScrollTop(){if(!this.scrollDirty)return this.scrollTop;this.scrollDirty=!1;let e=this.root==null?0:this.root instanceof Document?window.scrollY:this.root.scrollTop;return e=this.clampScrollTop(e),this.scrollTop=e,e}scrollTo({top:e,behavior:t=`auto`}){let{root:n}=this;if(n==null)return;let r=this.clampScrollTop(e);n instanceof Document?window.scrollTo({top:r,behavior:t}):n.scrollTo({top:r,behavior:t}),this.scrollDirty=!0,c(this.computeRenderRangeAndEmit)}clampScrollTop(e){return Math.max(0,Math.min(e,this.getScrollHeight()-this.getHeight()))}getScrollHeight(){return this.scrollHeightDirty?(this.scrollHeightDirty=!1,this.scrollHeight=this.root==null?0:this.root instanceof Document?this.root.documentElement.scrollHeight:this.root.scrollHeight,this.scrollHeight):this.scrollHeight}getHeight(){return this.heightDirty?(this.heightDirty=!1,this.height=this.root==null?0:this.root instanceof Document?globalThis.innerHeight:this.root.getBoundingClientRect().height,this.height):this.height}markDOMDirty(){this.scrollDirty=!0,this.scrollHeightDirty=!0,this.heightDirty=!0}getScrollContainerElement(){return this.root==null||this.root instanceof Document?void 0:this.root}};function q(e,t){let n=e.getBoundingClientRect(),r=t?.getBoundingClientRect().top??0;return n.top-r}var ue=o.filter(e=>e!==`file`&&e!==`pull-request`);function J(e){return e===`1`||e===1||e===!0}function de(e){return e===`0`||e===0||e===!1}function Y(e){if(typeof e!=`string`)return;let t=e.trim();return t.length>0?t:void 0}function X(e){return typeof e==`string`&&ue.includes(e)}function Z(e){let t=new Set,n=[];for(let r of e)t.has(r)||(t.add(r),n.push(r));return n}function fe(e){if(Array.isArray(e))return Z(e.filter(X));if(typeof e!=`string`)return[];let t=e.trim();if(t.startsWith(`[`)&&t.endsWith(`]`))try{let e=JSON.parse(t);return Array.isArray(e)?Z(e.filter(X)):[]}catch{return[]}return Z(t.split(`,`).map(e=>e.trim()).filter(X))}function pe(e){if(J(e.canvas))return`canvas`;if(J(e.preview))return`preview`;if(J(e.diff))return`diff`}function me(e,t){let n=fe(e.rightPanelTabs),r=Z(t&&!n.includes(t)?[...n,t]:n),i=Y(e.rightPanelTabs)!==void 0,a=J(e.rightPanelOpen),o=de(e.rightPanelOpen);return{rightPanelOpen:a?!0:!o&&i,rightPanelTabs:r,stated:a||o||i,hasExplicitTabs:i}}function he(e,t){if(t===`preview`){let t=Y(e.previewTabId);return t?{previewTabId:t}:{}}if(t!==`diff`)return{};let n=Y(e.diffTurnId);if(!n)return{};let r=R.make(n),i=Y(e.diffFilePath);return i?{diffTurnId:r,diffFilePath:i}:{diffTurnId:r}}function ge(e){let t=(X(e.rightPanel)?e.rightPanel:void 0)??pe(e),n=me(e,t);return{...n.stated?{rightPanelOpen:n.rightPanelOpen}:{},...t?{rightPanel:t}:{},...n.hasExplicitTabs&&n.rightPanelTabs.length>0?{rightPanelTabs:n.rightPanelTabs}:{},...he(e,t)}}function _e(e){let t=(0,H.c)(6),n;bb0:{if(!e){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],n=e;break bb0}n=e.turnDiffSummaries}let r=n,i,a;t[1]===r?a=t[2]:(a=d(r),t[1]=r,t[2]=a),i=a;let o=i,s;return t[3]!==o||t[4]!==r?(s={turnDiffSummaries:r,inferredCheckpointTurnCountByTurnId:o},t[3]=o,t[4]=r,t[5]=s):s=t[5],s}var ve=[];function ye(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:u,disabledIndices:d,modifierKeys:p=ve}=e,[m,h]=V.useState(0),v=r!=null,w=V.useRef(null),T=y(w,c),P=V.useRef([]),F=V.useRef(!1),I=o??m,L=k((e,t=!1)=>{if((s??h)(e),t){let t=P.current[e];O(w.current,t,a,n)}}),R=k(e=>{if(e.size===0||F.current)return;F.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)L(i);else if(M(t,I,d)){let e=N(t,{disabledIndices:d});D(t,e)||L(e)}O(w.current,r,a,n)});x(()=>{if(d==null||o!=null||!F.current)return;let e=P.current;if(M(e,I,d)){let t=N(e,{disabledIndices:d});D(e,t)||L(t)}},[d,o,I,P,L]);let z=k((e,t,n)=>i?i(e,t,n,P):n),B=k(e=>{let o=e.key===`Home`||e.key===`End`;if(!C.has(e.key)||!l&&o||be(e,p)||!w.current)return;let s=a===`rtl`,c=s?E:j,m=s?j:E,h=n===`vertical`?g:c,y=n===`vertical`?_:m,x=f(e.nativeEvent);if(x!=null&&b(x)&&!W(x)){let t=x.selectionStart,n=x.selectionEnd,r=x.value;if(t==null||e.shiftKey||t!==n||e.key!==y&&t<r.length||e.key!==h&&t>0)return}let T=I,O=S(P,d),k=A(P,d);r!=null&&(T=r({disabledIndices:d,elementsRef:P,event:e,highlightedIndex:I,loopFocus:t,maxIndex:k,minIndex:O,onLoop:z,orientation:n,rtl:s}));let M=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,F=n!==`vertical`&&e.key===m||n!==`horizontal`&&e.key===`ArrowUp`;l&&(e.key===`Home`?T=O:e.key===`End`&&(T=k)),T===I&&(M||F)&&(t&&T===k&&M?(T=O,i&&(T=i(e,I,T,P))):t&&T===O&&F?(T=k,i&&(T=i(e,I,T,P))):T=N(P.current,{startingIndex:T,decrement:F,disabledIndices:d})),T!==I&&!D(P.current,T)&&(u&&e.stopPropagation(),(v||o||M||F)&&e.preventDefault(),L(T,!0),queueMicrotask(()=>{P.current[T]?.focus()}))});return{props:{ref:T,onFocus(e){let t=w.current,n=f(e.nativeEvent);!t||n==null||!b(n)||n.setSelectionRange(0,n.value.length)},onKeyDown:B},highlightedIndex:I,onHighlightedIndexChange:L,elementsRef:P,onMapChange:R,relayKeyboardEvent:B}}function be(e,t){for(let n of v)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function xe(e){let{render:t,className:n,style:r,refs:i=P,props:o=P,state:s=L,stateAttributesMapping:c,highlightedIndex:l,onHighlightedIndexChange:u,orientation:d,grid:f,loopFocus:m,onLoop:g,enableHomeAndEndKeys:_,onMapChange:v,stopEventPropagation:y=!0,rootRef:b,disabledIndices:x,modifierKeys:S,highlightItemOnHover:C=!1,tag:w=`div`,...T}=e,{props:E,highlightedIndex:D,onHighlightedIndexChange:O,elementsRef:k,onMapChange:A,relayKeyboardEvent:j}=ye({grid:f,loopFocus:m,onLoop:g,orientation:d,highlightedIndex:l,onHighlightedIndexChange:u,rootRef:b,stopEventPropagation:y,enableHomeAndEndKeys:_,direction:F(),disabledIndices:x,modifierKeys:S}),M=h(w,e,{state:s,ref:i,props:[E,...o,T],stateAttributesMapping:c}),N=V.useMemo(()=>({highlightedIndex:D,onHighlightedIndexChange:O,highlightItemOnHover:C,relayKeyboardEvent:j}),[D,O,C,j]);return(0,U.jsx)(p.Provider,{value:N,children:(0,U.jsx)(a,{elementsRef:k,onMapChange:e=>{v?.(e),A(e)},children:M})})}var Se=V.createContext(void 0);function Ce(){return V.useContext(Se)}var we=V.forwardRef(function(e,t){let{defaultValue:n,disabled:r=!1,loopFocus:i=!0,onValueChange:a,orientation:o=`horizontal`,multiple:s=!1,value:c,className:l,render:u,style:d,...f}=e,p=T(!0),m=Ce(),g=c!==void 0||n!==void 0,_=(p?.disabled??!1)||(m?.disabled??!1)||r,[v,y]=w({controlled:c,default:c===void 0?n??P:void 0,name:`ToggleGroup`,state:`value`}),b=k((e,t,n)=>{let r;s?(r=v.slice(),t?r.push(e):r.splice(v.indexOf(e),1)):r=t?[e]:[],a?.(r,n),!n.isCanceled&&y(r)}),x={disabled:_,multiple:s,orientation:o},S=V.useMemo(()=>({disabled:_,setGroupValue:b,value:v,isValueInitialized:g}),[_,b,v,g]),C={role:`group`},E=h(`div`,e,{enabled:!!p,state:x,ref:t,props:[C,f]});return(0,U.jsx)(z.Provider,{value:S,children:p?E:(0,U.jsx)(xe,{render:u,className:l,style:d,state:x,refs:[t],props:[C,f],loopFocus:i,enableHomeAndEndKeys:!0,orientation:o})})}),Q=V.createContext({size:`default`,variant:`default`});function Te({className:e,variant:t=`default`,size:n=t===`segmented`?`segmented`:`default`,orientation:r=`horizontal`,children:i,...a}){let o=V.useMemo(()=>({size:n,variant:t}),[n,t]);return(0,U.jsx)(we,{className:I(`flex w-fit *:focus-visible:z-10 dark:*:[[data-slot=separator]:has(+[data-slot=toggle]:hover)]:before:bg-input/64 dark:*:[[data-slot=separator]:has(+[data-slot=toggle][data-pressed])]:before:bg-input dark:*:[[data-slot=toggle]:hover+[data-slot=separator]]:before:bg-input/64 dark:*:[[data-slot=toggle][data-pressed]+[data-slot=separator]]:before:bg-input`,r===`horizontal`?`*:pointer-coarse:after:min-w-auto`:`*:pointer-coarse:after:min-h-auto`,t===`segmented`?`gap-0.5 rounded-lg bg-input/40 p-0.5`:t==="default"?`gap-0.5`:r===`horizontal`?`*:not-first:not-data-[slot=separator]:before:-start-[0.5px] *:not-last:not-data-[slot=separator]:before:-end-[0.5px] *:not-first:rounded-s-none *:not-last:rounded-e-none *:not-first:border-s-0 *:not-last:border-e-0 *:not-first:before:rounded-s-none *:not-last:before:rounded-e-none`:`*:not-first:not-data-[slot=separator]:before:-top-[0.5px] *:not-last:not-data-[slot=separator]:before:-bottom-[0.5px] flex-col *:not-first:rounded-t-none *:not-last:rounded-b-none *:not-first:border-t-0 *:not-last:border-b-0 *:not-first:before:rounded-t-none *:not-last:before:rounded-b-none *:data-[slot=toggle]:not-last:before:hidden dark:*:last:before:hidden dark:*:first:before:block`,e),"data-size":n,"data-slot":`toggle-group`,"data-variant":t,orientation:r,...a,children:(0,U.jsx)(Q.Provider,{value:o,children:i})})}function Ee(e){let t=(0,H.c)(12),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,variant:o,size:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=V.useContext(Q),c=o??s.variant,l=a??s.size,u;return t[6]!==n||t[7]!==r||t[8]!==i||t[9]!==l||t[10]!==c?(u=(0,U.jsx)(B,{className:r,"data-size":l,"data-variant":c,size:l,variant:c,...i,children:n}),t[6]=n,t[7]=r,t[8]=i,t[9]=l,t[10]=c,t[11]=u):u=t[11],u}function De(e){return e.threadWorktreePath??e.projectCwd??void 0}function Oe(e){return e?.isRepo??!0}function ke(e,t){return typeof window>`u`&&t!=null?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`template`,{shadowrootmode:`open`,dangerouslySetInnerHTML:{__html:t}}),e]}):(0,U.jsx)(U.Fragment,{children:e})}var $=(0,V.createContext)(void 0);function Ae({children:e,config:t,className:n,style:r,contentClassName:i,contentStyle:a}){let[o]=(0,V.useState)(()=>typeof window<`u`?new le(t):void 0),s=(0,V.useCallback)(e=>{e==null?o?.cleanUp():o?.setup(e)},[o]);return(0,U.jsx)($.Provider,{value:o,children:(0,U.jsx)(`div`,{className:n,style:r,ref:s,children:(0,U.jsx)(`div`,{className:i,style:a,children:e})})})}function je(){return(0,V.useContext)($)}export{Oe as a,_e as c,re as d,ne as f,De as i,ge as l,ee as m,je as n,Ee as o,te as p,ke as r,Te as s,Ae as t,W as u};
2
+ //# sourceMappingURL=Virtualizer-B5NXbN5f.js.map