farming-code 2.2.29 → 2.2.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -66
- package/README.zh_cn.md +15 -66
- package/backend/acp-runtime.js +1 -15
- package/backend/acp-session-state.js +78 -88
- package/backend/agent-session-history.js +45 -12
- package/backend/codex-session-history.js +1 -1
- package/backend/codex-transcript.js +0 -202
- package/backend/config-manager.js +3 -19
- package/backend/farming-app-cli.js +1 -1
- package/backend/farming-cli.js +3 -57
- package/backend/index-html.js +21 -3
- package/backend/main-agent-skills.js +1 -18
- package/backend/server.js +6 -48
- package/backend/storage-layout.js +15 -0
- package/backend/update-service.js +55 -935
- package/config/farming.deploy.env.example +1 -1
- package/config/farming.install.env.example +1 -1
- package/dist/acp/codex-acp-1.1.4.mjs +387 -7
- package/dist/assets/App-Z1N7T0eM.js +695 -0
- package/dist/assets/{ProjectFilesSection-Cf2BEcAN.js → ProjectFilesSection-K3GHuQ4U.js} +2 -2
- package/dist/assets/code-dark-kLsQLvpf.css +1 -0
- package/dist/assets/{index-CQNaZc3l.js → index-D-zetSol.js} +2 -2
- package/dist/assets/main-DUTz-Rd2.css +1 -0
- package/dist/index.html +2 -1
- package/extensions/browser/backend/browser-resource-manager.js +27 -5
- package/extensions/browser/backend/browser-router.js +8 -0
- package/extensions/browser/backend/executable-discovery.js +26 -12
- package/extensions/browser/backend/managed-chromium-installer.js +593 -0
- package/extensions/browser/frontend/types.ts +8 -1
- package/extensions/browser/frontend/useBrowserResources.ts +8 -0
- package/index.html +1 -0
- package/package.json +1 -1
- package/backend/agent-memory-report.js +0 -583
- package/backend/bundle-update-helper.js +0 -113
- package/backend/codex-rollout-follower.js +0 -326
- package/dist/assets/App-Ex2oVVXO.js +0 -693
- package/dist/assets/code-dark-BEZTQwYZ.css +0 -1
- package/dist/assets/main-DK9Sy7-c.css +0 -1
|
@@ -8,5 +8,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
8
8
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ds(e,t){if(e){if(typeof e==`string`)return fs(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return fs(e,t)}}function fs(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ps(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function ms(e){if(Array.isArray(e))return e}function hs(e,t,n){var r=yo(),i=cs(e,t),a=ns(e);uo(function(){var e=ls(co(a,i,r),2),o=e[0],s=e[1];return t.receiveHandlerId(o),n.receiveHandlerId(o),s},[r,t,i,n,a.map(function(e){return e.toString()}).join(`|`)])}function gs(){var e=yo();return(0,B.useMemo)(function(){return new Ga(e)},[e])}function _s(e){var t=yo(),n=(0,B.useMemo)(function(){return new so(t.getBackend())},[t]);return uo(function(){return n.dropTargetOptions=e||null,n.reconnect(),function(){return n.disconnectDropTarget()}},[e]),n}function vs(e){return(0,B.useMemo)(function(){return e.hooks.dropTarget()},[e])}function ys(e,t){var n=Po(e,t),r=gs(),i=_s(n.options);return hs(n,r,i),[Qo(n.collect,r,i),vs(i)]}function bs(e,t){return Ts(e)||ws(e,t)||Ss(e,t)||xs()}function xs(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
9
9
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ss(e,t){if(e){if(typeof e==`string`)return Cs(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Cs(e,t)}}function Cs(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ws(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function Ts(e){if(Array.isArray(e))return e}function Es(e){var t=yo().getMonitor(),n=bs(Wo(t,e),2),r=n[0],i=n[1];return(0,B.useEffect)(function(){return t.subscribeToOffsetChange(i)}),(0,B.useEffect)(function(){return t.subscribeToStateChange(i)}),r}function Ds(e){var t=null;return function(){return t??=e(),t}}function Os(e,t){return e.filter(function(e){return e!==t})}function ks(e,t){var n=new Set,r=function(e){return n.add(e)};e.forEach(r),t.forEach(r);var i=[];return n.forEach(function(e){return i.push(e)}),i}function As(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function js(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Ms(e,t,n){return t&&js(e.prototype,t),n&&js(e,n),e}function Ns(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ps=function(){function e(t){As(this,e),Ns(this,`entered`,[]),Ns(this,`isNodeInDocument`,void 0),this.isNodeInDocument=t}return Ms(e,[{key:`enter`,value:function(e){var t=this,n=this.entered.length;return this.entered=ks(this.entered.filter(function(n){return t.isNodeInDocument(n)&&(!n.contains||n.contains(e))}),[e]),n===0&&this.entered.length>0}},{key:`leave`,value:function(e){var t=this.entered.length;return this.entered=Os(this.entered.filter(this.isNodeInDocument),e),t>0&&this.entered.length===0}},{key:`reset`,value:function(){this.entered=[]}}]),e}(),Fs=Ds(function(){return/firefox/i.test(navigator.userAgent)}),Is=Ds(function(){return!!window.safari});function Ls(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function Rs(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function zs(e,t,n){return t&&Rs(e.prototype,t),n&&Rs(e,n),e}function Bs(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Vs=function(){function e(t,n){Ls(this,e),Bs(this,`xs`,void 0),Bs(this,`ys`,void 0),Bs(this,`c1s`,void 0),Bs(this,`c2s`,void 0),Bs(this,`c3s`,void 0);for(var r=t.length,i=[],a=0;a<r;a++)i.push(a);i.sort(function(e,n){return t[e]<t[n]?-1:1});for(var o=[],s=[],c=[],l,u,d=0;d<r-1;d++)l=t[d+1]-t[d],u=n[d+1]-n[d],s.push(l),o.push(u),c.push(u/l);for(var f=[c[0]],p=0;p<s.length-1;p++){var m=c[p],h=c[p+1];if(m*h<=0)f.push(0);else{l=s[p];var g=s[p+1],_=l+g;f.push(3*_/((_+g)/m+(_+l)/h))}}f.push(c[c.length-1]);for(var v=[],y=[],b,x=0;x<f.length-1;x++){b=c[x];var S=f[x],C=1/s[x],w=S+f[x+1]-b-b;v.push((b-S-w)*C),y.push(w*C*C)}this.xs=t,this.ys=n,this.c1s=f,this.c2s=v,this.c3s=y}return zs(e,[{key:`interpolate`,value:function(e){var t=this.xs,n=this.ys,r=this.c1s,i=this.c2s,a=this.c3s,o=t.length-1;if(e===t[o])return n[o];for(var s=0,c=a.length-1,l;s<=c;){l=Math.floor(.5*(s+c));var u=t[l];if(u<e)s=l+1;else if(u>e)c=l-1;else return n[l]}o=Math.max(0,c);var d=e-t[o],f=d*d;return n[o]+r[o]*d+i[o]*f+a[o]*d*f}}]),e}(),Hs=1;function Us(e){var t=e.nodeType===Hs?e:e.parentElement;if(!t)return null;var n=t.getBoundingClientRect(),r=n.top;return{x:n.left,y:r}}function Ws(e){return{x:e.clientX,y:e.clientY}}function Gs(e){var t;return e.nodeName===`IMG`&&(Fs()||!((t=document.documentElement)!=null&&t.contains(e)))}function Ks(e,t,n,r){var i=e?t.width:n,a=e?t.height:r;return Is()&&e&&(a/=window.devicePixelRatio,i/=window.devicePixelRatio),{dragPreviewWidth:i,dragPreviewHeight:a}}function qs(e,t,n,r,i){var a=Gs(t),o=Us(a?e:t),s={x:n.x-o.x,y:n.y-o.y},c=e.offsetWidth,l=e.offsetHeight,u=r.anchorX,d=r.anchorY,f=Ks(a,t,c,l),p=f.dragPreviewWidth,m=f.dragPreviewHeight,h=function(){var e=new Vs([0,.5,1],[s.y,s.y/l*m,s.y+m-l]).interpolate(d);return Is()&&a&&(e+=(window.devicePixelRatio-1)*m),e},g=function(){return new Vs([0,.5,1],[s.x,s.x/c*p,s.x+p-c]).interpolate(u)},_=i.offsetX,v=i.offsetY,y=_===0||_,b=v===0||v;return{x:y?_:g(),y:b?v:h()}}var Js=e({FILE:()=>Ys,HTML:()=>Qs,TEXT:()=>Zs,URL:()=>Xs}),Ys=`__NATIVE_FILE__`,Xs=`__NATIVE_URL__`,Zs=`__NATIVE_TEXT__`,Qs=`__NATIVE_HTML__`;function $s(e,t,n){return t.reduce(function(t,n){return t||e.getData(n)},``)??n}var ec;function tc(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var nc=(ec={},tc(ec,Ys,{exposeProperties:{files:function(e){return Array.prototype.slice.call(e.files)},items:function(e){return e.items},dataTransfer:function(e){return e}},matchesTypes:[`Files`]}),tc(ec,Qs,{exposeProperties:{html:function(e,t){return $s(e,t,``)},dataTransfer:function(e){return e}},matchesTypes:[`Html`,`text/html`]}),tc(ec,Xs,{exposeProperties:{urls:function(e,t){return $s(e,t,``).split(`
|
|
10
10
|
`)},dataTransfer:function(e){return e}},matchesTypes:[`Url`,`text/uri-list`]}),tc(ec,Zs,{exposeProperties:{text:function(e,t){return $s(e,t,``)},dataTransfer:function(e){return e}},matchesTypes:[`Text`,`text/plain`]}),ec);function rc(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ic(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ac(e,t,n){return t&&ic(e.prototype,t),n&&ic(e,n),e}function oc(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var sc=function(){function e(t){rc(this,e),oc(this,`item`,void 0),oc(this,`config`,void 0),this.config=t,this.item={},this.initializeExposedProperties()}return ac(e,[{key:`initializeExposedProperties`,value:function(){var e=this;Object.keys(this.config.exposeProperties).forEach(function(t){Object.defineProperty(e.item,t,{configurable:!0,enumerable:!0,get:function(){return console.warn(`Browser doesn't allow reading "${t}" until the drop event.`),null}})})}},{key:`loadDataTransfer`,value:function(e){var t=this;if(e){var n={};Object.keys(this.config.exposeProperties).forEach(function(r){n[r]={value:t.config.exposeProperties[r](e,t.config.matchesTypes),configurable:!0,enumerable:!0}}),Object.defineProperties(this.item,n)}}},{key:`canDrag`,value:function(){return!0}},{key:`beginDrag`,value:function(){return this.item}},{key:`isDragging`,value:function(e,t){return t===e.getSourceId()}},{key:`endDrag`,value:function(){}}]),e}();function cc(e,t){var n=new sc(nc[e]);return n.loadDataTransfer(t),n}function lc(e){if(!e)return null;var t=Array.prototype.slice.call(e.types||[]);return Object.keys(nc).filter(function(e){return nc[e].matchesTypes.some(function(e){return t.indexOf(e)>-1})})[0]||null}function uc(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function dc(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function fc(e,t,n){return t&&dc(e.prototype,t),n&&dc(e,n),e}function pc(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var mc=function(){function e(t,n){uc(this,e),pc(this,`ownerDocument`,null),pc(this,`globalContext`,void 0),pc(this,`optionsArgs`,void 0),this.globalContext=t,this.optionsArgs=n}return fc(e,[{key:`window`,get:function(){if(this.globalContext)return this.globalContext;if(typeof window<`u`)return window}},{key:`document`,get:function(){var e;if((e=this.globalContext)!=null&&e.document)return this.globalContext.document;if(this.window)return this.window.document}},{key:`rootElement`,get:function(){return this.optionsArgs?.rootElement||this.window}}]),e}();function hc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function gc(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?hc(Object(n),!0).forEach(function(t){Z(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hc(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function _c(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function vc(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function yc(e,t,n){return t&&vc(e.prototype,t),n&&vc(e,n),e}function Z(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var bc=function(){function e(t,n,r){var i=this;_c(this,e),Z(this,`options`,void 0),Z(this,`actions`,void 0),Z(this,`monitor`,void 0),Z(this,`registry`,void 0),Z(this,`enterLeaveCounter`,void 0),Z(this,`sourcePreviewNodes`,new Map),Z(this,`sourcePreviewNodeOptions`,new Map),Z(this,`sourceNodes`,new Map),Z(this,`sourceNodeOptions`,new Map),Z(this,`dragStartSourceIds`,null),Z(this,`dropTargetIds`,[]),Z(this,`dragEnterTargetIds`,[]),Z(this,`currentNativeSource`,null),Z(this,`currentNativeHandle`,null),Z(this,`currentDragSourceNode`,null),Z(this,`altKeyPressed`,!1),Z(this,`mouseMoveTimeoutTimer`,null),Z(this,`asyncEndDragFrameId`,null),Z(this,`dragOverTargetIds`,null),Z(this,`lastClientOffset`,null),Z(this,`hoverRafId`,null),Z(this,`getSourceClientOffset`,function(e){var t=i.sourceNodes.get(e);return t&&Us(t)||null}),Z(this,`endDragNativeItem`,function(){i.isDraggingNativeItem()&&(i.actions.endDrag(),i.currentNativeHandle&&i.registry.removeSource(i.currentNativeHandle),i.currentNativeHandle=null,i.currentNativeSource=null)}),Z(this,`isNodeInDocument`,function(e){return!!(e&&i.document&&i.document.body&&i.document.body.contains(e))}),Z(this,`endDragIfSourceWasRemovedFromDOM`,function(){var e=i.currentDragSourceNode;e==null||i.isNodeInDocument(e)||i.clearCurrentDragSourceNode()&&i.monitor.isDragging()&&i.actions.endDrag()}),Z(this,`handleTopDragStartCapture`,function(){i.clearCurrentDragSourceNode(),i.dragStartSourceIds=[]}),Z(this,`handleTopDragStart`,function(e){if(!e.defaultPrevented){var t=i.dragStartSourceIds;i.dragStartSourceIds=null;var n=Ws(e);i.monitor.isDragging()&&i.actions.endDrag(),i.actions.beginDrag(t||[],{publishSource:!1,getSourceClientOffset:i.getSourceClientOffset,clientOffset:n});var r=e.dataTransfer,a=lc(r);if(i.monitor.isDragging()){if(r&&typeof r.setDragImage==`function`){var o=i.monitor.getSourceId(),s=i.sourceNodes.get(o),c=i.sourcePreviewNodes.get(o)||s;if(c){var l=i.getCurrentSourcePreviewNodeOptions(),u=l.anchorX,d=l.anchorY,f=l.offsetX,p=l.offsetY,m=qs(s,c,n,{anchorX:u,anchorY:d},{offsetX:f,offsetY:p});r.setDragImage(c,m.x,m.y)}}try{r?.setData(`application/json`,{})}catch{}i.setCurrentDragSourceNode(e.target),i.getCurrentSourcePreviewNodeOptions().captureDraggingState?i.actions.publishDragSource():setTimeout(function(){return i.actions.publishDragSource()},0)}else if(a)i.beginDragNativeItem(a);else if(r&&!r.types&&(e.target&&!e.target.hasAttribute||!e.target.hasAttribute(`draggable`)))return;else e.preventDefault()}}),Z(this,`handleTopDragEndCapture`,function(){i.clearCurrentDragSourceNode()&&i.monitor.isDragging()&&i.actions.endDrag()}),Z(this,`handleTopDragEnterCapture`,function(e){if(i.dragEnterTargetIds=[],!(!i.enterLeaveCounter.enter(e.target)||i.monitor.isDragging())){var t=e.dataTransfer,n=lc(t);n&&i.beginDragNativeItem(n,t)}}),Z(this,`handleTopDragEnter`,function(e){var t=i.dragEnterTargetIds;i.dragEnterTargetIds=[],i.monitor.isDragging()&&(i.altKeyPressed=e.altKey,t.length>0&&i.actions.hover(t,{clientOffset:Ws(e)}),t.some(function(e){return i.monitor.canDropOnTarget(e)})&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=i.getCurrentDropEffect())))}),Z(this,`handleTopDragOverCapture`,function(){i.dragOverTargetIds=[]}),Z(this,`handleTopDragOver`,function(e){var t=i.dragOverTargetIds;if(i.dragOverTargetIds=[],!i.monitor.isDragging()){e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`none`);return}i.altKeyPressed=e.altKey,i.lastClientOffset=Ws(e),i.hoverRafId===null&&typeof requestAnimationFrame<`u`&&(i.hoverRafId=requestAnimationFrame(function(){i.monitor.isDragging()&&i.actions.hover(t||[],{clientOffset:i.lastClientOffset}),i.hoverRafId=null})),(t||[]).some(function(e){return i.monitor.canDropOnTarget(e)})?(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=i.getCurrentDropEffect())):i.isDraggingNativeItem()?e.preventDefault():(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`none`))}),Z(this,`handleTopDragLeaveCapture`,function(e){i.isDraggingNativeItem()&&e.preventDefault(),i.enterLeaveCounter.leave(e.target)&&i.isDraggingNativeItem()&&setTimeout(function(){return i.endDragNativeItem()},0)}),Z(this,`handleTopDropCapture`,function(e){if(i.dropTargetIds=[],i.isDraggingNativeItem()){var t;e.preventDefault(),(t=i.currentNativeSource)==null||t.loadDataTransfer(e.dataTransfer)}else lc(e.dataTransfer)&&e.preventDefault();i.enterLeaveCounter.reset()}),Z(this,`handleTopDrop`,function(e){var t=i.dropTargetIds;i.dropTargetIds=[],i.actions.hover(t,{clientOffset:Ws(e)}),i.actions.drop({dropEffect:i.getCurrentDropEffect()}),i.isDraggingNativeItem()?i.endDragNativeItem():i.monitor.isDragging()&&i.actions.endDrag()}),Z(this,`handleSelectStart`,function(e){var t=e.target;typeof t.dragDrop==`function`&&(t.tagName===`INPUT`||t.tagName===`SELECT`||t.tagName===`TEXTAREA`||t.isContentEditable||(e.preventDefault(),t.dragDrop()))}),this.options=new mc(n,r),this.actions=t.getActions(),this.monitor=t.getMonitor(),this.registry=t.getRegistry(),this.enterLeaveCounter=new Ps(this.isNodeInDocument)}return yc(e,[{key:`profile`,value:function(){return{sourcePreviewNodes:this.sourcePreviewNodes.size,sourcePreviewNodeOptions:this.sourcePreviewNodeOptions.size,sourceNodeOptions:this.sourceNodeOptions.size,sourceNodes:this.sourceNodes.size,dragStartSourceIds:this.dragStartSourceIds?.length||0,dropTargetIds:this.dropTargetIds.length,dragEnterTargetIds:this.dragEnterTargetIds.length,dragOverTargetIds:this.dragOverTargetIds?.length||0}}},{key:`window`,get:function(){return this.options.window}},{key:`document`,get:function(){return this.options.document}},{key:`rootElement`,get:function(){return this.options.rootElement}},{key:`setup`,value:function(){var e=this.rootElement;if(e!==void 0){if(e.__isReactDndBackendSetUp)throw Error(`Cannot have two HTML5 backends at the same time.`);e.__isReactDndBackendSetUp=!0,this.addEventListeners(e)}}},{key:`teardown`,value:function(){var e=this.rootElement;if(e!==void 0&&(e.__isReactDndBackendSetUp=!1,this.removeEventListeners(this.rootElement),this.clearCurrentDragSourceNode(),this.asyncEndDragFrameId)){var t;(t=this.window)==null||t.cancelAnimationFrame(this.asyncEndDragFrameId)}}},{key:`connectDragPreview`,value:function(e,t,n){var r=this;return this.sourcePreviewNodeOptions.set(e,n),this.sourcePreviewNodes.set(e,t),function(){r.sourcePreviewNodes.delete(e),r.sourcePreviewNodeOptions.delete(e)}}},{key:`connectDragSource`,value:function(e,t,n){var r=this;this.sourceNodes.set(e,t),this.sourceNodeOptions.set(e,n);var i=function(t){return r.handleDragStart(t,e)},a=function(e){return r.handleSelectStart(e)};return t.setAttribute(`draggable`,`true`),t.addEventListener(`dragstart`,i),t.addEventListener(`selectstart`,a),function(){r.sourceNodes.delete(e),r.sourceNodeOptions.delete(e),t.removeEventListener(`dragstart`,i),t.removeEventListener(`selectstart`,a),t.setAttribute(`draggable`,`false`)}}},{key:`connectDropTarget`,value:function(e,t){var n=this,r=function(t){return n.handleDragEnter(t,e)},i=function(t){return n.handleDragOver(t,e)},a=function(t){return n.handleDrop(t,e)};return t.addEventListener(`dragenter`,r),t.addEventListener(`dragover`,i),t.addEventListener(`drop`,a),function(){t.removeEventListener(`dragenter`,r),t.removeEventListener(`dragover`,i),t.removeEventListener(`drop`,a)}}},{key:`addEventListeners`,value:function(e){e.addEventListener&&(e.addEventListener(`dragstart`,this.handleTopDragStart),e.addEventListener(`dragstart`,this.handleTopDragStartCapture,!0),e.addEventListener(`dragend`,this.handleTopDragEndCapture,!0),e.addEventListener(`dragenter`,this.handleTopDragEnter),e.addEventListener(`dragenter`,this.handleTopDragEnterCapture,!0),e.addEventListener(`dragleave`,this.handleTopDragLeaveCapture,!0),e.addEventListener(`dragover`,this.handleTopDragOver),e.addEventListener(`dragover`,this.handleTopDragOverCapture,!0),e.addEventListener(`drop`,this.handleTopDrop),e.addEventListener(`drop`,this.handleTopDropCapture,!0))}},{key:`removeEventListeners`,value:function(e){e.removeEventListener&&(e.removeEventListener(`dragstart`,this.handleTopDragStart),e.removeEventListener(`dragstart`,this.handleTopDragStartCapture,!0),e.removeEventListener(`dragend`,this.handleTopDragEndCapture,!0),e.removeEventListener(`dragenter`,this.handleTopDragEnter),e.removeEventListener(`dragenter`,this.handleTopDragEnterCapture,!0),e.removeEventListener(`dragleave`,this.handleTopDragLeaveCapture,!0),e.removeEventListener(`dragover`,this.handleTopDragOver),e.removeEventListener(`dragover`,this.handleTopDragOverCapture,!0),e.removeEventListener(`drop`,this.handleTopDrop),e.removeEventListener(`drop`,this.handleTopDropCapture,!0))}},{key:`getCurrentSourceNodeOptions`,value:function(){var e=this.monitor.getSourceId(),t=this.sourceNodeOptions.get(e);return gc({dropEffect:this.altKeyPressed?`copy`:`move`},t||{})}},{key:`getCurrentDropEffect`,value:function(){return this.isDraggingNativeItem()?`copy`:this.getCurrentSourceNodeOptions().dropEffect}},{key:`getCurrentSourcePreviewNodeOptions`,value:function(){var e=this.monitor.getSourceId();return gc({anchorX:.5,anchorY:.5,captureDraggingState:!1},this.sourcePreviewNodeOptions.get(e)||{})}},{key:`isDraggingNativeItem`,value:function(){var e=this.monitor.getItemType();return Object.keys(Js).some(function(t){return Js[t]===e})}},{key:`beginDragNativeItem`,value:function(e,t){this.clearCurrentDragSourceNode(),this.currentNativeSource=cc(e,t),this.currentNativeHandle=this.registry.addSource(e,this.currentNativeSource),this.actions.beginDrag([this.currentNativeHandle])}},{key:`setCurrentDragSourceNode`,value:function(e){var t=this;this.clearCurrentDragSourceNode(),this.currentDragSourceNode=e,this.mouseMoveTimeoutTimer=setTimeout(function(){return t.rootElement?.addEventListener(`mousemove`,t.endDragIfSourceWasRemovedFromDOM,!0)},1e3)}},{key:`clearCurrentDragSourceNode`,value:function(){if(this.currentDragSourceNode){if(this.currentDragSourceNode=null,this.rootElement){var e;(e=this.window)==null||e.clearTimeout(this.mouseMoveTimeoutTimer||void 0),this.rootElement.removeEventListener(`mousemove`,this.endDragIfSourceWasRemovedFromDOM,!0)}return this.mouseMoveTimeoutTimer=null,!0}return!1}},{key:`handleDragStart`,value:function(e,t){e.defaultPrevented||(this.dragStartSourceIds||=[],this.dragStartSourceIds.unshift(t))}},{key:`handleDragEnter`,value:function(e,t){this.dragEnterTargetIds.unshift(t)}},{key:`handleDragOver`,value:function(e,t){this.dragOverTargetIds===null&&(this.dragOverTargetIds=[]),this.dragOverTargetIds.unshift(t)}},{key:`handleDrop`,value:function(e,t){this.dropTargetIds.unshift(t)}}]),e}(),xc;function Sc(){return xc||(xc=new Image,xc.src=`data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==`),xc}var Cc=function(e,t,n){return new bc(e,t,n)};function wc(e,t){return typeof e==`function`?e(t):e??`NODE`}function Tc(e){return e.isDraggable&&!e.isEditing}function Ec(e){let t=W(),n=t.selectedIds,[r,i,a]=ts(()=>({canDrag:()=>Tc(e),type:wc(t.props.dragType,e),item:()=>{let r=t.isSelected(e.id)?Array.from(n):[e.id];return t.dispatch(_n.dragStart(e.id,r)),{id:e.id,dragIds:r,data:e.data}},end:()=>{t.hideCursor(),t.redrawList(),t.dispatch(_n.dragEnd())}}),[n,e,t.props.dragType]);return(0,B.useEffect)(()=>{a(Sc())},[a]),i}function Dc(e,t){let n=e.getBoundingClientRect(),r=t.x-Math.round(n.x),i=t.y-Math.round(n.y),a=n.height,o=i<a/2,s=!o,c=a/4,l=i>c&&i<a-c;return{x:r,inTopHalf:o,inBottomHalf:s,inMiddle:l,atTop:!l&&o,atBottom:!l&&s}}function Oc(e,t,n,r){return e?e.isInternal?r.atTop?[t,e]:r.inMiddle?[e,e]:[e,n]:r.inTopHalf?[t,e]:[e,n]:[t,null]}function kc(e,t){return{parentId:e||null,index:t}}function Ac(e,t){return{type:`line`,index:e,level:t}}function jc(e){return{type:`highlight`,id:e}}function Mc(e,t){let n=e;for(;n.parent&&n.level>t;)n=n.parent;return{parentId:n.parent?.id||null,index:kt(n)+1}}function Nc(e){let t=Dc(e.element,e.offset),n=e.indent,r=Math.round(Math.max(0,t.x-n)/n),{node:i,nextNode:a,prevNode:o}=e,[s,c]=Oc(i,o,a,t);if(i&&i.isInternal&&t.inMiddle)return{drop:kc(i.id,null),cursor:jc(i.id)};if(!s)return{drop:kc(c?.parent?.id,0),cursor:Ac(0,0)};if(Tt(s)){let e=wt(r,c?.level||0,s.level);return{drop:Mc(s,e),cursor:Ac(s.rowIndex+1,e)}}if(Et(s)){let e=wt(r,c?.level||0,s.level);return{drop:Mc(s,e),cursor:Ac(s.rowIndex+1,e)}}if(Dt(s)){let e=wt(r,0,s.level+1);return e>s.level?{drop:kc(s.id,0),cursor:Ac(s.rowIndex+1,e)}:{drop:Mc(s,e),cursor:Ac(s.rowIndex+1,e)}}return{drop:kc(s?.id,0),cursor:Ac(s.rowIndex+1,s.level+1)}}function Pc(e,t){let n=W(),[r,i]=ys(()=>({accept:`NODE`,canDrop:()=>n.canDrop(),hover:(r,i)=>{let a=i.getClientOffset();if(!e.current||!a)return;let{cursor:o,drop:s}=Nc({element:e.current,offset:a,indent:n.indent,node:t,prevNode:t.prev,nextNode:t.next});s&&n.dispatch(_n.hovering(s.parentId,s.index)),i.canDrop()?o&&n.showCursor(o):n.hideCursor()},drop:(e,t)=>{if(!t.canDrop())return null;n.drop()}}),[t,e.current,n.props]);return i}function Fc(e){let t=W(),n=t.at(e);if(!n)throw Error(`Could not find node for index: ${e}`);return(0,B.useMemo)(()=>{let r=n.clone();return t.visibleNodes[e]=r,r},[...Object.values(n.state),n])}var Ic=B.memo(function({index:e,style:t}){St(),vt();let n=W(),r=Fc(e),i=(0,B.useRef)(null),a=Ec(r),o=Pc(i,r),s=(0,B.useCallback)(e=>{i.current=e,o(e)},[o]),c=n.indent*r.level,l=(0,B.useMemo)(()=>({paddingLeft:c}),[c]),u=(0,B.useMemo)(()=>Object.assign(Object.assign({},t),{top:parseFloat(t.top)+(n.props.padding??n.props.paddingTop??0),minWidth:`max-content`}),[t,n.props.padding,n.props.paddingTop]),d={role:`treeitem`,"aria-level":r.level+1,"aria-selected":r.isSelected,"aria-expanded":r.isOpen,style:u,tabIndex:-1,className:n.props.rowClassName};(0,B.useEffect)(()=>{var e;!r.isEditing&&r.isFocused&&((e=i.current)==null||e.focus({preventScroll:!0}))},[r.isEditing,r.isFocused,i.current]);let f=n.renderNode,p=n.renderRow;return(0,V.jsx)(p,{node:r,innerRef:s,attrs:d,children:(0,V.jsx)(f,{node:r,tree:n,style:l,dragHandle:a})})}),Lc=``,Rc=null;function zc(){St();let e=W();return(0,V.jsx)(`div`,{role:`tree`,"aria-label":e.props[`aria-label`],"aria-labelledby":e.props[`aria-labelledby`],"aria-multiselectable":!e.props.disableMultiSelection||void 0,style:{height:e.height,width:e.width,minHeight:0,minWidth:0},onContextMenu:e.props.onContextMenu,onClick:e.props.onClick,tabIndex:0,onFocus:t=>{t.currentTarget.contains(t.relatedTarget)||e.onFocus()},onBlur:t=>{t.currentTarget.contains(t.relatedTarget)||e.onBlur()},onKeyDown:t=>{if(e.isEditing)return;if(t.key===`Backspace`){if(!e.props.onDelete)return;let t=Array.from(e.selectedIds);if(t.length>1){let n=e.mostRecentNode;for(;n&&n.isSelected;)n=n.nextSibling;n||=e.lastNode,e.focus(n,{scroll:!1}),e.delete(Array.from(t))}else{let t=e.focusedNode;if(t){let n=t.nextSibling,r=t.parent;e.focus(n||r,{scroll:!1}),e.delete(t)}}return}if(t.key===`Tab`&&!t.shiftKey){t.preventDefault(),Nt(t.currentTarget);return}if(t.key===`Tab`&&t.shiftKey){t.preventDefault(),Pt(t.currentTarget);return}if(t.key===`ArrowDown`){t.preventDefault();let n=e.nextNode;if(t.metaKey){e.select(e.focusedNode),e.activate(e.focusedNode);return}else if(!t.shiftKey||e.props.disableMultiSelection){e.focus(n);return}else{if(!n)return;let t=e.focusedNode;t?t.isSelected?e.selectContiguous(n):e.selectMulti(n):e.focus(e.firstNode);return}}if(t.key===`ArrowUp`){t.preventDefault();let n=e.prevNode;if(!t.shiftKey||e.props.disableMultiSelection){e.focus(n);return}else{if(!n)return;let t=e.focusedNode;t?t.isSelected?e.selectContiguous(n):e.selectMulti(n):e.focus(e.lastNode);return}}if(t.key===`ArrowRight`){let t=e.focusedNode;if(!t)return;t.isInternal&&t.isOpen?e.focus(e.nextNode):t.isInternal&&e.open(t.id);return}if(t.key===`ArrowLeft`){let t=e.focusedNode;if(!t||t.isRoot)return;t.isInternal&&t.isOpen?e.close(t.id):t.parent?.isRoot||e.focus(t.parent);return}if(t.key===`a`&&(t.metaKey||t.ctrlKey)&&!e.props.disableMultiSelection){t.preventDefault(),e.selectAll();return}if(t.key===`a`&&!t.metaKey&&!t.ctrlKey&&e.props.onCreate){e.createLeaf();return}if(t.key===`A`&&!t.metaKey&&!t.ctrlKey){if(!e.props.onCreate)return;e.createInternal();return}if(t.key===`Home`){t.preventDefault(),e.focus(e.firstNode);return}if(t.key===`End`){t.preventDefault(),e.focus(e.lastNode);return}if(t.key===`Enter`){let t=e.focusedNode;if(!t||!t.isEditable||!e.props.onRename)return;setTimeout(()=>{t&&e.edit(t)});return}if(t.key===` `){t.preventDefault();let n=e.focusedNode;if(!n)return;n.isLeaf?(n.select(),n.activate()):n.toggle();return}if(t.key===`*`){let t=e.focusedNode;if(!t)return;e.openSiblings(t);return}if(t.key===`PageUp`){t.preventDefault(),e.pageUp();return}t.key===`PageDown`&&(t.preventDefault(),e.pageDown()),clearTimeout(Rc),Lc+=t.key,Rc=setTimeout(()=>{Lc=``},600);let n=e.visibleNodes.find(e=>{let t=e.data.name;return typeof t==`string`?t.toLowerCase().startsWith(Lc):!1});n&&e.focus(n.id)},children:(0,V.jsx)(Bc,{})})}function Bc(){let e=W(),t={className:e.props.className,outerRef:e.listEl,itemCount:e.visibleNodes.length,height:e.height,width:e.width,overscanCount:e.overscanCount,itemKey:t=>e.visibleNodes[t]?.id||t,outerElementType:e.props.outerElementType??nr,innerElementType:e.props.innerElementType??ar,onScroll:e.props.onScroll,onItemsRendered:e.onItemsRendered.bind(e)};return typeof e.props.rowHeight==`function`?(0,V.jsx)(Qn,Object.assign({},t,{itemSize:e.rowHeightAt,ref:e.list,children:Ic})):(0,V.jsx)($n,Object.assign({},t,{itemSize:e.rowHeight,ref:e.list,children:Ic}))}function Vc(e){return e.isFiltered?Uc(e.root,e.isMatch.bind(e)):Hc(e.root)}function Hc(e){let t=[];function n(e){var r;e.level>=0&&t.push(e),e.isOpen&&((r=e.children)==null||r.forEach(n))}return n(e),t.forEach(Wc),t}function Uc(e,t){let n={},r=[];function i(e){if(!e.isRoot&&t(e)){n[e.id]=!0;let t=e.parent;for(;t;)n[t.id]=!0,t=t.parent}if(e.children)for(let t of e.children)i(t)}function a(e){var t;e.level>=0&&n[e.id]&&r.push(e),e.isOpen&&((t=e.children)==null||t.forEach(a))}return i(e),a(e),r.forEach(Wc),r}function Wc(e,t){e.rowIndex=t}var Gc=e=>e.reduce((e,t,n)=>(e[t.id]=n,e),{}),Kc=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},{safeRun:Q}=Ct,qc=class e{constructor(e,t,n,r){this.store=e,this.props=t,this.list=n,this.listEl=r,this.visibleStartIndex=0,this.visibleStopIndex=0,this.rowOffsets=null,this.rowHeightAt=e=>{let t=this.props.rowHeight;if(typeof t==`function`){let n=this.at(e);return n?t(n):this.rowHeight}return t??24},this.rowTopPosition=e=>{if(typeof this.props.rowHeight!=`function`)return e*this.rowHeight;let t=this.getRowOffsets();return t[Math.max(0,Math.min(e,t.length-1))]},this.redrawList=(e=0)=>{this.rowOffsets=null;let t=this.list.current;t&&`resetAfterIndex`in t&&t.resetAfterIndex(Math.max(0,e))},this.root=rn(this),this.visibleNodes=Vc(this),this.idToIndex=Gc(this.visibleNodes)}update(e){this.props=e,this.root=rn(this),this.visibleNodes=Vc(this),this.idToIndex=Gc(this.visibleNodes),this.rowOffsets=null;let t=this.list.current;t&&`resetAfterIndex`in t&&t.resetAfterIndex(0,!1)}dispatch(e){return this.store.dispatch(e)}get state(){return this.store.getState()}get openState(){return this.state.nodes.open.unfiltered}get width(){return this.props.width??300}get height(){return this.props.height??500}get indent(){return this.props.indent??24}get rowHeight(){return typeof this.props.rowHeight==`number`?this.props.rowHeight:24}getRowOffsets(){if(this.rowOffsets)return this.rowOffsets;let e=[0];for(let t=0;t<this.visibleNodes.length;t++)e.push(e[t]+this.rowHeightAt(t));return this.rowOffsets=e,e}get overscanCount(){return this.props.overscanCount??1}get searchTerm(){return(this.props.searchTerm||``).trim()}get matchFn(){let e=this.props.searchMatch??((e,t)=>JSON.stringify(Object.values(e.data)).toLocaleLowerCase().includes(t.toLocaleLowerCase()));return t=>e(t,this.searchTerm)}accessChildren(e){return Rt(e,this.props.childrenAccessor||`children`)??null}accessId(e){let t=Rt(e,this.props.idAccessor||`id`);if(!t)throw Error(`Data must contain an 'id' property or props.idAccessor must return a string`);return t}identify(e){return typeof e==`string`?e:e instanceof an?e.id:Rt(e,this.props.idAccessor||`id`)}identifyNull(e){return e==null?null:this.identify(e)}get firstNode(){return this.visibleNodes[0]??null}get lastNode(){return this.visibleNodes[this.visibleNodes.length-1]??null}get focusedNode(){return this.get(this.state.nodes.focus.id)??null}get mostRecentNode(){return this.get(this.state.nodes.selection.mostRecent)??null}get nextNode(){let e=this.indexOf(this.focusedNode);return e===null?null:this.at(e+1)}get prevNode(){let e=this.indexOf(this.focusedNode);return e===null?null:this.at(e-1)}get(e){return e&&e in this.idToIndex&&this.visibleNodes[this.idToIndex[e]]||null}at(e){return this.visibleNodes[e]||null}nodesBetween(e,t){if(e===null||t===null)return[];let n=this.indexOf(e)??0,r=this.indexOf(t);if(r===null)return[];let i=Math.min(n,r),a=Math.max(n,r);return this.visibleNodes.slice(i,a+1)}indexOf(e){let t=this.identifyNull(e);return t?this.idToIndex[t]:null}get editingId(){return this.state.nodes.edit.id}createInternal(){return this.create({type:`internal`})}createLeaf(){return this.create({type:`leaf`})}create(){return Kc(this,arguments,void 0,function*(e={}){let t=e.parentId===void 0?qt(this):e.parentId,n=e.index??Wt(this),r=e.type??`leaf`,i=yield Q(this.props.onCreate,{type:r,parentId:t,index:n,parentNode:this.get(t)});i&&(this.focus(i),setTimeout(()=>{this.edit(i).then(()=>{this.select(i),this.activate(i)})}))})}delete(e){return Kc(this,void 0,void 0,function*(){if(!e)return;let t=(Array.isArray(e)?e:[e]).map(e=>this.identify(e)),n=t.map(e=>this.get(e)).filter(e=>!!e),r=n.length?Math.min(...n.map(e=>e.rowIndex??0)):0;yield Q(this.props.onDelete,{nodes:n,ids:t}),this.redrawList(r)})}edit(t){let n=this.identify(t);return this.resolveEdit({cancelled:!0}),this.scrollTo(n),this.dispatch(on(n)),this.redrawList(this.get(n)?.rowIndex??0),new Promise(t=>{e.editPromise=t})}submit(e,t){return Kc(this,void 0,void 0,function*(){if(!e)return;let n=this.identify(e);yield Q(this.props.onRename,{id:n,name:t,node:this.get(n)}),this.dispatch(on(null)),this.resolveEdit({cancelled:!1,value:t}),this.redrawList(this.get(n)?.rowIndex??0),setTimeout(()=>this.onFocus())})}reset(){this.dispatch(on(null)),this.resolveEdit({cancelled:!0}),this.redrawList(),setTimeout(()=>this.onFocus())}activate(e){let t=this.get(this.identifyNull(e));t&&Q(this.props.onActivate,t)}resolveEdit(t){let n=e.editPromise;n&&n(t),e.editPromise=null}get selectedIds(){return this.state.nodes.selection.ids}get selectedNodes(){let e=[];for(let t of Array.from(this.selectedIds)){let n=this.get(t);n&&e.push(n)}return e}focus(e,t={}){e&&(this.props.selectionFollowsFocus?this.select(e):(this.dispatch(cn(this.identify(e))),t.scroll!==!1&&this.scrollTo(e),this.focusedNode&&Q(this.props.onFocus,this.focusedNode)))}pageUp(){let e=this.visibleStartIndex,t=this.visibleStopIndex-e,n=this.focusedNode?.rowIndex??0;n=n>e?e:Math.max(e-t,0),this.focus(this.at(n))}pageDown(){let e=this.visibleStartIndex,t=this.visibleStopIndex,n=t-e,r=this.focusedNode?.rowIndex??0;r=r<t?t:Math.min(r+n,this.visibleNodes.length-1),this.focus(this.at(r))}select(e,t={}){if(!e)return;let n=t.focus!==!1,r=this.identify(e);n&&this.dispatch(cn(r)),this.get(r)?.isSelectable&&this.setSelection({ids:[r],anchor:r,mostRecent:r}),this.scrollTo(r,t.align),this.focusedNode&&n&&Q(this.props.onFocus,this.focusedNode)}deselect(e){if(!e)return;let t=this.identify(e);this.dispatch(hn.remove(t)),Q(this.props.onSelect,this.selectedNodes)}selectMulti(e,t={}){let n=this.get(this.identifyNull(e));if(!n)return;let r=t.focus!==!1;r&&this.dispatch(cn(n.id)),n.isSelectable&&(this.dispatch(hn.add(n.id)),this.dispatch(hn.anchor(n.id)),this.dispatch(hn.mostRecent(n.id))),this.scrollTo(n,t.align),this.focusedNode&&r&&Q(this.props.onFocus,this.focusedNode),Q(this.props.onSelect,this.selectedNodes)}selectContiguous(e){if(!e)return;let t=this.identify(e);if(this.dispatch(cn(t)),this.get(t)?.isSelectable){let{anchor:e,mostRecent:n}=this.state.nodes.selection,r=this.filterSelectableNodes(this.nodesBetween(e,this.identifyNull(t)));this.dispatch(hn.remove(this.nodesBetween(e,n))),this.dispatch(hn.add(r)),this.dispatch(hn.mostRecent(t))}this.scrollTo(t),this.focusedNode&&Q(this.props.onFocus,this.focusedNode),Q(this.props.onSelect,this.selectedNodes)}deselectAll(){this.setSelection({ids:[],anchor:null,mostRecent:null})}selectAll(){let e=this.filterSelectableNodes(Object.keys(this.idToIndex));this.setSelection({ids:e,anchor:e[0]??null,mostRecent:e[e.length-1]??null}),this.dispatch(cn(this.lastNode?.id)),this.focusedNode&&Q(this.props.onFocus,this.focusedNode)}filterSelectableNodes(e){return e.map(e=>this.get(this.identify(e))).filter(e=>!!e&&e.isSelectable)}setSelection(e){let t=new Set(e.ids?.map(e=>this.identify(e))),n=this.identifyNull(e.anchor),r=this.identifyNull(e.mostRecent);this.dispatch(hn.set({ids:t,anchor:n,mostRecent:r})),Q(this.props.onSelect,this.selectedNodes)}get cursorParentId(){let{cursor:e}=this.state.dnd;switch(e.type){case`highlight`:return e.id;default:return null}}get cursorOverFolder(){return this.state.dnd.cursor.type===`highlight`}get dragNodes(){return this.state.dnd.dragIds.map(e=>this.get(e)).filter(e=>!!e)}get dragNode(){return this.get(this.state.nodes.drag.id)}get dragDestinationParent(){return this.get(this.state.nodes.drag.destinationParentId)}get dragDestinationIndex(){return this.state.nodes.drag.destinationIndex}canDrop(){if(this.isFiltered)return!1;let e=this.get(this.state.dnd.parentId)??this.root,t=this.dragNodes,n=this.props.disableDrop;for(let n of t)if(!n||!e||n.isInternal&&Ot(e,n))return!1;return typeof n==`function`?!n({parentNode:e,dragNodes:this.dragNodes,index:this.state.dnd.index||0}):typeof n==`string`?!e.data[n]:typeof n==`boolean`?!n:!0}drop(){let{parentId:e,index:t,dragIds:n}=this.state.dnd;Q(this.props.onMove,{dragIds:n,parentId:e===`__REACT_ARBORIST_INTERNAL_ROOT__`?null:e,index:t===null?0:t,dragNodes:this.dragNodes,parentNode:this.get(e)}),this.open(e)}hideCursor(){this.dispatch(_n.cursor({type:`none`}))}showCursor(e){this.dispatch(_n.cursor(e))}open(e,t=!0){let n=this.identifyNull(e);n&&(this.isOpen(n)||(this.dispatch(dn.open(n,this.isFiltered)),t&&this.redrawList(this.get(n)?.rowIndex??0),Q(this.props.onToggle,n)))}close(e,t=!0){let n=this.identifyNull(e);n&&this.isOpen(n)&&(this.dispatch(dn.close(n,this.isFiltered)),t&&this.redrawList(this.get(n)?.rowIndex??0),Q(this.props.onToggle,n))}toggle(e){let t=this.identifyNull(e);if(t)return this.isOpen(t)?this.close(t):this.open(t)}openParents(e){let t=this.identifyNull(e);if(!t)return;let n=jt(this.root,t)?.parent;for(;n;)this.open(n.id,!1),n=n.parent;this.redrawList()}openSiblings(e){let t=e.parent;if(!t)this.toggle(e.id);else if(t.children){let n=e.isOpen;for(let e of t.children)e.isInternal&&(n?this.close(e.id,!1):this.open(e.id,!1));this.redrawList(),this.scrollTo(this.focusedNode)}}openAll(){Mt(this.root,e=>{e.isInternal&&this.open(e.id,!1)}),this.redrawList()}closeAll(){Mt(this.root,e=>{e.isInternal&&this.close(e.id,!1)}),this.redrawList()}scrollTo(e,t=`smart`){if(!e)return;let n=this.identify(e);return this.openParents(n),Ut(()=>n in this.idToIndex).then(()=>{var e;let r=this.idToIndex[n];r!==void 0&&((e=this.list.current)==null||e.scrollToItem(r,t))}).catch(()=>{})}get isEditing(){return this.state.nodes.edit.id!==null}get isFiltered(){return!!this.props.searchTerm?.trim()}get hasFocus(){return this.state.nodes.focus.treeFocused}get hasNoSelection(){return this.state.nodes.selection.ids.size===0}get hasOneSelection(){return this.state.nodes.selection.ids.size===1}get hasMultipleSelections(){return this.state.nodes.selection.ids.size>1}isSelected(e){return e?this.state.nodes.selection.ids.has(e):!1}isOpen(e){if(!e)return!1;if(e===`__REACT_ARBORIST_INTERNAL_ROOT__`)return!0;let t=this.props.openByDefault??!0;return this.isFiltered?this.state.nodes.open.filtered[e]??!0:this.state.nodes.open.unfiltered[e]??t}isEditable(e){return this.isActionPossible(e,this.props.disableEdit)}isDraggable(e){return this.isActionPossible(e,this.props.disableDrag)}isSelectable(e){return this.isActionPossible(e,this.props.disableSelect)}isActionPossible(e,t=()=>!1){return!Rt(e,t)}isDragging(e){let t=this.identifyNull(e);return t?this.state.nodes.drag.id===t:!1}isFocused(e){return this.hasFocus&&this.state.nodes.focus.id===e}isMatch(e){return this.matchFn(e)}willReceiveDrop(e){let t=this.identifyNull(e);if(!t)return!1;let{destinationParentId:n,destinationIndex:r}=this.state.nodes.drag;return t===n&&r===null}onFocus(){let e=this.focusedNode||this.firstNode;e&&this.dispatch(cn(e.id))}onBlur(){this.dispatch(ln())}onItemsRendered(e){this.visibleStartIndex=e.visibleStartIndex,this.visibleStopIndex=e.visibleStopIndex}get renderContainer(){return this.props.renderContainer||zc}get renderRow(){return this.props.renderRow||Qt}get renderNode(){return this.props.children||$t}get renderDragPreview(){return this.props.renderDragPreview||Sn}get renderCursor(){return this.props.renderCursor||Zt}};function $(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var Jc=typeof Symbol==`function`&&Symbol.observable||`@@observable`,Yc=()=>Math.random().toString(36).substring(7).split(``).join(`.`),Xc={INIT:`@@redux/INIT${Yc()}`,REPLACE:`@@redux/REPLACE${Yc()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Yc()}`};function Zc(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function Qc(e,t,n){if(typeof e!=`function`)throw Error($(2));if(typeof t==`function`&&typeof n==`function`||typeof n==`function`&&typeof arguments[3]==`function`)throw Error($(0));if(typeof t==`function`&&n===void 0&&(n=t,t=void 0),n!==void 0){if(typeof n!=`function`)throw Error($(1));return n(Qc)(e,t)}let r=e,i=t,a=new Map,o=a,s=0,c=!1;function l(){o===a&&(o=new Map,a.forEach((e,t)=>{o.set(t,e)}))}function u(){if(c)throw Error($(3));return i}function d(e){if(typeof e!=`function`)throw Error($(4));if(c)throw Error($(5));let t=!0;l();let n=s++;return o.set(n,e),function(){if(t){if(c)throw Error($(6));t=!1,l(),o.delete(n),a=null}}}function f(e){if(!Zc(e))throw Error($(7));if(e.type===void 0)throw Error($(8));if(typeof e.type!=`string`)throw Error($(17));if(c)throw Error($(9));try{c=!0,i=r(i,e)}finally{c=!1}return(a=o).forEach(e=>{e()}),e}function p(e){if(typeof e!=`function`)throw Error($(10));r=e,f({type:Xc.REPLACE})}function m(){let e=d;return{subscribe(t){if(typeof t!=`object`||!t)throw Error($(11));function n(){let e=t;e.next&&e.next(u())}return n(),{unsubscribe:e(n)}},[Jc](){return this}}}return f({type:Xc.INIT}),{dispatch:f,subscribe:d,getState:u,replaceReducer:p,[Jc]:m}}function $c(e){Object.keys(e).forEach(t=>{let n=e[t];if(n(void 0,{type:Xc.INIT})===void 0)throw Error($(12));if(n(void 0,{type:Xc.PROBE_UNKNOWN_ACTION()})===void 0)throw Error($(13))})}function el(e){let t=Object.keys(e),n={};for(let r=0;r<t.length;r++){let i=t[r];typeof e[i]==`function`&&(n[i]=e[i])}let r=Object.keys(n),i;try{$c(n)}catch(e){i=e}return function(e={},t){if(i)throw i;let a=!1,o={};for(let i=0;i<r.length;i++){let s=r[i],c=n[s],l=e[s],u=c(l,t);if(u===void 0)throw t&&t.type,Error($(14));o[s]=u,a||=u!==l}return a||=r.length!==Object.keys(e).length,a?o:e}}function tl(e=mn().nodes.drag,t){switch(t.type){case`DND_DRAG_START`:return Object.assign(Object.assign({},e),{id:t.id,selectedIds:t.dragIds});case`DND_DRAG_END`:return Object.assign(Object.assign({},e),{id:null,destinationParentId:null,destinationIndex:null,selectedIds:[]});case`DND_HOVERING`:return t.parentId!==e.destinationParentId||t.index!=e.destinationIndex?Object.assign(Object.assign({},e),{destinationParentId:t.parentId,destinationIndex:t.index}):e;default:return e}}var nl=el({nodes:el({focus:un,edit:sn,open:pn,selection:gn,drag:tl}),dnd:vn}),rl=ht(),il=mn();function al({treeProps:e,imperativeHandle:t,children:n}){let r=(0,B.useRef)(null),i=(0,B.useRef)(null),a=(0,B.useRef)(Qc(nl,mn(e))),o=(0,rl.useSyncExternalStore)(a.current.subscribe,a.current.getState,()=>il),s=(0,B.useMemo)(()=>new qc(a.current,e,r,i),[]),c=(0,B.useRef)(0);return(0,B.useMemo)(()=>{c.current+=1,s.update(e)},Object.values(e)),(0,B.useMemo)(()=>{c.current+=1,s.update(s.props)},[o.nodes.open]),(0,B.useImperativeHandle)(t,()=>s),(0,B.useEffect)(()=>{s.props.selection?s.select(s.props.selection,{focus:!1}):s.deselectAll()},[s.props.selection]),(0,B.useEffect)(()=>{s.props.searchTerm||a.current.dispatch(dn.clear(!0))},[s.props.searchTerm]),(0,V.jsx)(gt.Provider,{value:s,children:(0,V.jsx)(xt.Provider,{value:c.current,children:(0,V.jsx)(_t.Provider,{value:o.nodes,children:(0,V.jsx)(yt.Provider,{value:o.dnd,children:(0,V.jsx)(ka,Object.assign({},e.dndManager?{manager:e.dndManager}:{backend:e.dndBackend||Cc,options:{rootElement:s.props.dndRootElement||void 0}},{children:n}))})})})})}function ol(){let e=W(),[,t]=ys(()=>({accept:`NODE`,canDrop:(t,n)=>n.isOver({shallow:!0})?e.canDrop():!1,hover:(t,n)=>{if(!n.isOver({shallow:!0}))return;let r=n.getClientOffset();if(!e.listEl.current||!r)return;let{cursor:i,drop:a}=Nc({element:e.listEl.current,offset:r,indent:e.indent,node:null,prevNode:e.visibleNodes[e.visibleNodes.length-1],nextNode:null});a&&e.dispatch(_n.hovering(a.parentId,a.index)),n.canDrop()?i&&e.showCursor(i):e.hideCursor()},drop:(t,n)=>{if(!n.isOver({shallow:!0})||!n.canDrop())return null;e.drop()}}),[e]);t(e.listEl)}function sl(e){return ol(),e.children}function cl(){return(0,V.jsx)(V.Fragment,{children:(0,V.jsx)(W().props.renderContainer||zc,{})})}function ll(){let e=W(),{offset:t,mouse:n,item:r,isDragging:i}=Es(e=>({offset:e.getSourceClientOffset(),mouse:e.getClientOffset(),item:e.getItem(),isDragging:e.isDragging()}));return(0,V.jsx)(e.props.renderDragPreview||Sn,{offset:t,mouse:n,id:r?.id||null,dragIds:r?.dragIds||[],isDragging:i})}function ul(e={}){let t=e.idAccessor??`id`,n=e.childrenAccessor??`children`;return{getId:typeof t==`function`?t:e=>e[t],getChildren:typeof n==`function`?n:e=>e[n],childrenKey:typeof n==`string`?n:`children`}}var dl=class{constructor(e,t={}){this.accessors=ul(t),this.root=fl(e,this.accessors)}get data(){return this.root.children?.map(e=>e.data)??[]}create(e){let t=e.parentId?this.find(e.parentId):this.root;if(!t)return null;t.addChild(e.data,e.index)}move(e){let t=this.find(e.id),n=e.parentId?this.find(e.parentId):this.root;!t||!n||(n.addChild(t.data,e.index),t.drop())}update(e){let t=this.find(e.id);t&&t.update(e.changes)}drop(e){let t=this.find(e.id);t&&t.drop()}find(e,t=this.root){if(!t)return null;if(t.id===e)return t;if(t.children){for(let n of t.children){let t=this.find(e,n);if(t)return t}return null}return null}};function fl(e,t){let n=new ml({},null,t,`ROOT`);return n.children=e.map(e=>pl(e,n,t)),n}function pl(e,t,n){let r=new ml(e,t,n),i=n.getChildren(e);return i&&(r.children=i.map(e=>pl(e,r,n))),r}var ml=class{constructor(e,t,n,r){this.data=e,this.parent=t,this.accessors=n,this.id=r??n.getId(e)}hasParent(){return!!this.parent}get childIndex(){return this.hasParent()?this.parent.children.indexOf(this):-1}addChild(e,t){let n=pl(e,this,this.accessors);this.children=this.children??[],this.children.splice(t,0,n);let r=this.accessors.childrenKey,i=this.data;i[r]=i[r]??[],i[r].splice(t,0,e)}removeChild(e){var t,n;(t=this.children)==null||t.splice(e,1),(n=this.data[this.accessors.childrenKey])==null||n.splice(e,1)}update(e){if(this.hasParent()){let t=this.childIndex;this.parent.addChild(Object.assign(Object.assign({},this.data),e),t),this.drop()}}drop(){this.hasParent()&&this.parent.removeChild(this.childIndex)}},hl=0;function gl(e,t={}){let[n,r]=(0,B.useState)(e),i=t.idAccessor,a=t.childrenAccessor,o=(0,B.useMemo)(()=>new dl(n,{idAccessor:i,childrenAccessor:a}),[n,i,a]),s=e=>{for(let t of e.dragIds)o.move({id:t,parentId:e.parentId,index:e.index});r(o.data)},c=({name:e,id:t})=>{o.update({id:t,changes:{name:e}}),r(o.data)},l=typeof i==`string`?i:`id`,u=typeof a==`string`?a:`children`;return[n,{onMove:s,onRename:c,onCreate:({parentId:e,index:t,type:n})=>{if(typeof i==`function`)throw Error("React Arborist => initialData can't create nodes when idAccessor is a function: the generated id can't be written under a key the accessor reads. Use a string idAccessor, or the controlled `data` prop with your own onCreate.");if(n===`internal`&&typeof a==`function`)throw Error("React Arborist => initialData can't create folder nodes when childrenAccessor is a function: the new children array can't be written under a key the accessor reads. Use a string childrenAccessor, or the controlled `data` prop with your own onCreate.");let s={[l]:`simple-tree-id-${hl++}`,name:``};return n===`internal`&&(s[u]=[]),o.create({parentId:e,index:t,data:s}),r(o.data),s},onDelete:e=>{e.ids.forEach(e=>o.drop({id:e})),r(o.data)}}]}function _l(e){if(e.initialData&&e.data)throw Error(`React Arborist Tree => Provide either a data or initialData prop, but not both.`);if(e.initialData&&(e.onCreate||e.onDelete||e.onMove||e.onRename))throw Error(`React Arborist Tree => You passed the initialData prop along with a data handler.
|
|
11
|
-
Use the data prop if you want to provide your own handlers.`);if(e.initialData){let[t,n]=gl(e.initialData,{idAccessor:e.idAccessor,childrenAccessor:e.childrenAccessor});return Object.assign(Object.assign(Object.assign({},e),n),{data:t})}else return e}function vl(e,t){return(0,V.jsxs)(al,{treeProps:_l(e),imperativeHandle:t,children:[(0,V.jsx)(sl,{children:(0,V.jsx)(cl,{})}),(0,V.jsx)(ll,{})]})}var yl=(0,B.forwardRef)(vl),bl=[0,80,180,300,520,900,1200],xl=[80,180,360],Sl=new Set([`ArrowDown`,`ArrowUp`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`PageUp`,`PageDown`,`Enter`,` `,`F2`,`Delete`,`Backspace`,`ContextMenu`]);function Cl(e,t){return t.top<e.top?t.top-e.top:t.bottom>e.bottom?t.bottom-e.bottom:0}function wl(e){return e.focusRow&&!e.operationActive&&!e.activeElementIsSearchInput&&!e.searchInputValue}function Tl(e){return e.activeElementIsSearchInput&&!!e.searchInputValue}function El(e){return e.requestedSelect||!e.searchInputValue}function Dl(e){return Sl.has(e)}function Ol(e){return e.rows.find(t=>t.path===e.lastFocusedPath)?.path??e.rows.find(e=>e.selected)?.path??e.rows[0]?.path??null}function kl(e){return e.selectedPath??e.targetPath??e.focusedPath??e.lastFocusedPath??null}function Al(e,t){return Math.max(1,Math.floor(Math.max(0,e)/Math.max(1,t))-1)}function jl(e){if(e.rowCount<=0)return-1;let t=Math.max(0,Math.min(e.currentIndex,e.rowCount-1))+(e.key===`PageUp`?-1:1)*Math.max(1,e.pageSize);return Math.max(0,Math.min(t,e.rowCount-1))}function Ml(e){if(e.nodeType!==`directory`)return!1;let t=e.selectedRow.path===e.nodePath&&e.selectedRow.type===`directory`&&e.selectedRow.expanded===!0;return e.nodeOpen||t||e.openDirectoryPaths.has(e.nodePath)}function Nl(e){let t=!e.metaKey&&!e.ctrlKey&&!e.shiftKey;return e.nodeType===`directory`&&t?`toggle-directory`:e.nodeType===`file`&&t?`open-file`:`select`}function Pl(e){return e.nodeType===`directory`?e.nodeOpen?`close-directory`:`open-directory`:e.nodeType===`file`?`open-file`:`none`}function Fl(e,t=30,n=0,r=25){return e+t+n+r}function Il(e,t,n=1){return e<t+n}function Ll(e,t,n,r=1){return e.find(e=>e.bottom>t+r&&e.top<n)?.path??``}function Rl(e,t,n){if(!e)return[];let r=new Map(t.map(e=>[e.path,e.top]));return E(e).filter(e=>{let t=r.get(e);return typeof t==`number`&&t<n})}function zl(e){return!e.visible&&e.directoryNodes.length===0?[]:e.directoryNodes.map(e=>({kind:`directory`,key:e.path,node:e}))}function Bl(e){return e.map(e=>e.displayName??e.name).filter(Boolean).join(`/`)}function Vl(e){if(!e)return()=>{};let t=e.scrollTop,n=()=>{e.scrollTop=t};return n(),window.requestAnimationFrame(n),window.setTimeout(n,0),window.setTimeout(n,80),window.setTimeout(n,180),n}function Hl(e,t,n){let r=qe(e.node.descendantGitStatus);return(0,V.jsxs)(`button`,{type:`button`,className:`code-file-row directory code-file-sticky-row`,style:H(D(e.node.path)),title:e.node.path,onClick:t=>{t.preventDefault(),t.stopPropagation(),n(e.node)},children:[(0,V.jsx)(`span`,{className:`code-file-chevron expanded`,"aria-hidden":`true`,children:(0,V.jsx)(R,{})}),(0,V.jsx)(`span`,{className:`code-file-name`,children:e.node.displayName??e.node.name}),r&&(0,V.jsx)(`span`,{className:r,title:Ge(`git`,t)})]},e.key)}function Ul({copy:e,items:t,onFocusDirectory:n}){if(t.length===0)return null;let r=t.filter(e=>e.kind===`directory`),i=r[r.length-1];return(0,V.jsx)(`div`,{className:`code-file-sticky-shell`,children:(0,V.jsxs)(`div`,{className:`code-file-sticky-stack`,"data-testid":`code-file-sticky-stack`,"aria-label":e.stickyFolderPath,children:[(0,V.jsx)(`div`,{className:`code-file-sticky-expanded-rows`,children:r.map(t=>Hl(t,e,n))}),i&&(0,V.jsxs)(`button`,{type:`button`,className:`code-file-row directory code-file-sticky-row code-file-sticky-compact-row`,style:H(0),title:i.node.path,onClick:e=>{e.preventDefault(),e.stopPropagation(),n(i.node)},children:[(0,V.jsx)(`span`,{className:`code-file-chevron expanded`,"aria-hidden":`true`,children:(0,V.jsx)(R,{})}),(0,V.jsx)(`span`,{className:`code-file-name`,children:Bl(r.map(e=>e.node))})]})]})})}function Wl({agentId:e,copy:t,fileOperation:n,inputRef:r,item:i,onCancel:a,onInputName:o,onSubmit:s}){return(0,B.useLayoutEffect)(()=>{let e=r.current;e&&(e.focus({preventScroll:!0}),document.activeElement===e&&e.setSelectionRange(0,ot(n)))},[n.item?.path,r]),(0,V.jsx)(`form`,{className:`code-file-inline-operation`,"data-testid":`code-file-inline-operation`,"aria-busy":n.submitting,style:{gridColumn:`3 / -1`},autoComplete:`off`,onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),onSubmit:e=>{e.preventDefault(),e.stopPropagation(),s()},children:(0,V.jsx)(`input`,{id:`code-file-operation-input`,"data-testid":`code-file-operation-input`,name:`farming-file-${e}-rename`,type:`text`,inputMode:`text`,ref:r,defaultValue:n.name,disabled:n.submitting,"aria-label":t.renameEntry(i.name),autoComplete:`off`,"aria-autocomplete":`none`,autoCapitalize:`none`,autoCorrect:`off`,autoFocus:!0,spellCheck:!1,enterKeyHint:`done`,"data-lpignore":`true`,"data-1p-ignore":`true`,"data-bwignore":`true`,"data-form-type":`other`,onInput:e=>{o(e.currentTarget.value)},onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),a();return}e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),s())}})})}function Gl({copy:e,item:t,viewState:n}){let{directoryDotClassName:r,directoryDotTitleKind:i,fileChangedClassName:a,fileChangedTitleKind:o,fileOpening:s,isDirectory:c,showDirectoryDot:l,visibleGitStatus:u,visibleGitStatusClassName:d,visibleGitStatusLabel:f}=n;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`code-file-name`,children:t.displayName??t.name}),t.symbolicLink&&(0,V.jsx)(`span`,{className:`code-file-symbolic-link`,"aria-hidden":`true`,children:`↷`}),s&&(0,V.jsx)(`span`,{className:`code-file-open-spinner`,title:e.loading,"aria-hidden":`true`}),!s&&l&&(0,V.jsx)(`span`,{className:r,title:Ge(i,e)}),!s&&!c&&f&&(0,V.jsx)(`span`,{className:d,title:e.gitStatus(u||``),children:f}),!s&&!c&&!f&&a&&(0,V.jsx)(`span`,{className:a,title:Ge(o,e)})]})}function Kl(e){e?.focus({preventScroll:!0})}function ql({isDirectory:e,item:t,lastFocusedFilePathRef:n,node:r,treeViewportRef:i,onCancelPendingFileFocus:a,onFocusFileTreeTarget:o,onOpenFileContextMenu:s,onOpenFilePath:c,onToggleDirectory:l}){let u=(0,B.useCallback)(()=>{Kl(i.current?.querySelector(`[role="tree"]`))},[i]),d=(0,B.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),a(),n.current=t.path,r.select(),s(e.clientX,e.clientY,t)},[t,n,r,a,s]),f=(0,B.useCallback)(n=>{e||n.button!==0||n.metaKey||n.ctrlKey||n.shiftKey||c(t.path,{transient:!0})},[e,t.path,c]);return{handleRowClick:(0,B.useCallback)(s=>{a(),n.current=t.path;let d=Nl({nodeType:t.type,metaKey:s.metaKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey}),f=e?Vl(i.current?.closest(`.code-project-list`)):null;if(d===`toggle-directory`){s.preventDefault(),s.stopPropagation();let e=l(t.path);r.select(),r.focus(),u(),e?r.open():r.close(),o(t),f?.();return}if(d===`open-file`&&s.detail===0&&c(t.path,{transient:!0}),r.handleClick(s),r.focus(),u(),s.shiftKey){Kl(s.currentTarget),f?.();return}o(t),f?.()},[u,e,t,n,r,a,o,c,l,i]),handleRowContextMenu:d,handleRowMouseDown:f}}function Jl({activeFilePath:e,agentId:t,copy:n,editorDirtyFilePaths:r,editorExternalChangedFilePaths:i,fileOperation:a,fileOperationInputRef:o,lastFocusedFilePathRef:s,locatedFilePath:c,node:l,openFilePendingPath:u,treeViewportRef:d,onCancelPendingFileFocus:f,onCloseFileOperation:p,onFocusFileTreeTarget:m,onOpenFileContextMenu:h,onOpenFilePath:g,onRememberFileOperationName:_,onToggleDirectory:v,onSubmitFileOperation:y}){let b=l.data,x=Ye({activeFilePath:e,editorDirtyFilePaths:r,editorExternalChangedFilePaths:i,openFilePendingPath:u,item:b,isFocused:l.isFocused,isOpen:l.isOpen,isSelected:l.isSelected}),{chevronState:S,isDirectory:C}=x,w=`${x.rowClasses} ${c===b.path?`located`:``}`.trim(),T=C?``:F(b.path),E=a?.kind===`rename`&&a.item?.path===b.path?a:null,{handleRowClick:D,handleRowContextMenu:O,handleRowMouseDown:k}=ql({isDirectory:C,item:b,lastFocusedFilePathRef:s,node:l,treeViewportRef:d,onCancelPendingFileFocus:f,onFocusFileTreeTarget:m,onOpenFileContextMenu:h,onOpenFilePath:g,onToggleDirectory:v});return(0,V.jsxs)(`div`,{className:w,style:H(l.level),"data-testid":`code-file-row`,"data-file-path":b.path,"data-file-type":b.type,"data-tree-level":l.level,"aria-label":b.path,title:b.linkTarget?`${b.path} ↷ ${b.linkTarget}`:b.linkError?`${b.path} (${b.linkError})`:void 0,tabIndex:-1,"aria-expanded":C?l.isOpen:void 0,onContextMenu:O,onMouseDown:k,onClick:D,children:[(0,V.jsx)(`span`,{className:`code-file-chevron ${S}`,"aria-hidden":`true`,children:S===`expanded`?(0,V.jsx)(R,{}):S===`collapsed`?(0,V.jsx)(z,{}):null}),!C&&(0,V.jsx)(`img`,{className:`code-file-type-icon file`,src:T,alt:``,"aria-hidden":`true`}),E?(0,V.jsx)(Wl,{agentId:t,copy:n,fileOperation:E,inputRef:o,item:b,onCancel:p,onInputName:_,onSubmit:y}):(0,V.jsx)(Gl,{copy:n,item:b,viewState:x})]})}function Yl({activeFilePath:e,agentId:t,copy:n,editorDirtyFilePaths:r,editorExternalChangedFilePaths:i,fileOperation:a,fileOperationInputRef:o,handleTreeKeyDownCapture:s,lastFocusedFilePathRef:c,locatedFilePath:l,openFilePendingPath:u,renderFileTreeRow:d,rowHeight:f,stickyContextItems:p,treeData:m,treeHeight:h,treeRef:g,treeViewportRef:_,visibleTreeRowCount:v,onCancelPendingFileFocus:y,onCloseFileOperation:b,onFocusFileTreeTarget:x,onFocusStickyDirectory:S,onOpenFileContextMenu:C,onOpenFilePath:w,onRememberFileOperationName:T,onToggleDirectory:E,onSubmitFileOperation:D,onToggleTreeNode:O,onTreeFocus:k,onTreeSelect:A,onUpdateFileOperationName:j}){let M=(0,B.useCallback)(e=>{e.target?.closest(`[data-file-path]`)||(e.preventDefault(),y(),C(e.clientX,e.clientY,null))},[y,C]),N=(0,B.useCallback)(({node:s})=>(0,V.jsx)(Jl,{activeFilePath:e,agentId:t,copy:n,editorDirtyFilePaths:r,editorExternalChangedFilePaths:i,fileOperation:a,fileOperationInputRef:o,lastFocusedFilePathRef:c,locatedFilePath:l,node:s,openFilePendingPath:u,treeViewportRef:_,onCancelPendingFileFocus:y,onCloseFileOperation:b,onFocusFileTreeTarget:x,onOpenFileContextMenu:C,onOpenFilePath:w,onRememberFileOperationName:T,onToggleDirectory:E,onSubmitFileOperation:D,onUpdateFileOperationName:j}),[e,t,n,r,i,a,o,c,l,y,b,x,C,w,T,D,E,j,u,_]);return(0,V.jsxs)(`div`,{className:`code-file-tree-viewport`,ref:_,"data-visible-row-count":v,style:{height:h},onKeyDownCapture:s,onContextMenu:M,children:[(0,V.jsx)(Ul,{copy:n,items:p,onFocusDirectory:S}),(0,V.jsx)(yl,{ref:g,data:m,idAccessor:`id`,childrenAccessor:`children`,rowHeight:f,indent:0,height:h,width:`100%`,overscanCount:v,openByDefault:!1,selectionFollowsFocus:!0,className:`code-file-tree`,rowClassName:`code-file-tree-row`,renderRow:d,onToggle:O,onFocus:k,onSelect:A,disableDrag:!0,disableEdit:!0,disableDrop:!0,children:N})]})}function Xl({copy:e,agentLaunchOptions:t,fileMenu:n,fileMenuRef:r,openFileError:i,rootDirectoryError:a,rootDirectoryHasItems:o,rootDirectoryLoading:s,search:c,searchActions:l,tree:u,onCloseFileMenu:d,onCloseFileMenuWithFocusRestore:f,onCopyFileMenuPath:p,onCopyFileMenuShareUrl:m,onOpenNewAgentFromFileMenu:h,onRefreshFileMenuTarget:g,onStartAgentFromFileMenu:_,onStartFileMenuOperation:v,readOnly:y=!1}){return(0,V.jsxs)(V.Fragment,{children:[s&&!o&&(0,V.jsx)(`div`,{className:`code-file-status`,style:H(0),children:e.loading}),a&&(0,V.jsx)(`div`,{className:`code-file-status error`,style:H(0),children:a}),i&&!c.active&&(0,V.jsx)(`div`,{className:`code-file-status error`,"data-testid":`code-file-open-error`,style:H(0),children:i}),c.active&&(0,V.jsx)(Ue,{activeMatchIndex:c.activeMatchIndex,anchorRef:c.anchorRef,containerRef:c.resultsRef,copy:e,error:c.error,jumpTarget:c.jumpTarget,listboxId:c.listboxId,loading:c.loading,matches:c.matches,openFileError:i,query:c.query,showIgnoredSearch:!c.includeIgnored,timeoutMs:c.timeoutMs,truncated:c.truncated,onOpenJumpQuery:l.onOpenJumpQuery,onOpenMatch:l.onOpenMatch,onSearchIgnored:l.onSearchIgnored,onSelectMatchIndex:l.onSelectMatchIndex}),(0,V.jsx)(Yl,{...u,copy:e}),(0,V.jsx)(pt,{agentId:u.agentId,copy:e,agentLaunchOptions:t,fileMenu:n,fileOperation:u.fileOperation,fileMenuRef:r,fileOperationInputRef:u.fileOperationInputRef,onCloseFileMenu:d,onCloseFileMenuWithFocusRestore:f,onCloseFileOperation:u.onCloseFileOperation,onCopyFileMenuPath:p,onCopyFileMenuShareUrl:m,onOpenNewAgent:h,onRefreshFileMenuTarget:g,onRememberFileOperationName:u.onRememberFileOperationName,onStartAgent:_,onStartFileMenuOperation:v,onSubmitFileOperation:u.onSubmitFileOperation,onUpdateFileOperationName:u.onUpdateFileOperationName,readOnly:y})]})}function Zl({copy:e,filesCollapsed:t,refreshStatus:n,search:r,onCancelPendingFileFocus:i,onFileSearchKeyDown:a,onSearchQueryChange:o,onRefreshFiles:s,onToggleFilesCollapsed:c}){let l=n===`refreshing`?e.refreshingFiles:n===`success`?e.filesRefreshed:n===`error`?e.filesRefreshFailed:e.refreshFiles;return(0,V.jsxs)(`div`,{className:`code-files-header ${t?`collapsed`:``}`,children:[(0,V.jsxs)(`div`,{className:`code-files-heading`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`code-files-title`,"aria-expanded":!t,onClick:c,children:[(0,V.jsx)(`span`,{className:`code-file-section-chevron ${t?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:t?(0,V.jsx)(z,{}):(0,V.jsx)(R,{})}),(0,V.jsx)(`span`,{children:e.files})]}),(0,V.jsx)(`button`,{type:`button`,className:`code-files-refresh`,"data-testid":`code-files-refresh`,"data-refresh-status":n,title:l,"aria-label":l,"aria-busy":n===`refreshing`,disabled:n===`refreshing`,onClick:s,children:(0,V.jsx)(`span`,{className:`code-files-refresh-glyph`,"aria-hidden":`true`,children:n===`success`?(0,V.jsx)(ge,{}):n===`error`?(0,V.jsx)(he,{}):`↻`})}),(0,V.jsx)(`span`,{className:`code-visually-hidden`,role:`status`,"aria-live":`polite`,children:n===`idle`?``:l})]}),!t&&(0,V.jsxs)(`label`,{className:`code-file-search-box`,children:[(0,V.jsx)(`span`,{className:`code-file-search-icon`,"aria-hidden":`true`}),(0,V.jsx)(`input`,{ref:r.inputRef,type:`search`,name:`farming-file-search`,inputMode:`search`,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1,enterKeyHint:`search`,"data-lpignore":`true`,"data-1p-ignore":`true`,"data-bwignore":`true`,"data-form-type":`other`,value:r.query,onChange:e=>{i(),o(e.target.value)},onFocus:i,onPointerDown:e=>{i(),b()&&(e.preventDefault(),e.currentTarget.focus({preventScroll:!0}))},onMouseDown:i,onKeyDownCapture:a,placeholder:e.searchOrPathLine,"aria-label":e.searchFilesOrJump,"aria-autocomplete":`list`,"aria-controls":r.active?r.listboxId:void 0,"aria-expanded":r.active,"aria-activedescendant":r.activeOptionId,role:`combobox`})]})]})}var Ql=o(),$l=[`#ffb000`,`#dc267f`,`#994f00`,`#40b0a6`,`#b66dff`],eu=`#2188ff`;function tu(e){return{...e}}function nu(e,t){for(let n of e.references??[]){let e=t.get(n.id);if(e!==void 0)return e}}function ru(e,t,n=new Map){let r=-1,i=[];for(let a of e){let o=a.id===t?`HEAD`:`node`,s=(i[i.length-1]?.outputSwimlanes??[]).map(tu),c=[],l=!1;if(a.parentIds.length>0)for(let e of s){if(e.id===a.id){l||=(c.push({id:a.parentIds[0],color:nu(a,n)??e.color}),!0);continue}c.push(tu(e))}for(let t=+!!l;t<a.parentIds.length;t+=1){let i;if(t===0)i=nu(a,n);else{let r=e.find(e=>e.id===a.parentIds[t]);i=r?nu(r,n):void 0}i||=(r=(r+1)%$l.length,$l[r]),c.push({id:a.parentIds[t],color:i})}i.push({historyItem:a,kind:o,inputSwimlanes:s,outputSwimlanes:c})}return i}var iu=5,au=4,ou=2,su=`http://www.w3.org/2000/svg`;function cu(e,t=1){let n=document.createElementNS(su,`path`);return n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,e),n.setAttribute(`stroke-width`,String(t)),n.setAttribute(`stroke-linecap`,`round`),n}function lu(e,t,n,r,i=!1){let a=document.createElementNS(su,`circle`);return a.setAttribute(`cx`,String(11*(e+1))),a.setAttribute(`cy`,`11`),a.setAttribute(`r`,String(t)),a.setAttribute(`stroke`,r),a.setAttribute(`stroke-width`,String(n)),a.setAttribute(`fill`,i?r:`var(--code-git-history-node-bg, #f6f7f3)`),a}function uu(e,t,n,r,i=1){let a=cu(r,i);return a.setAttribute(`d`,`M ${e} ${t} V ${n}`),a}function du(e,t){for(let n=e.length-1;n>=0;--n)if(e[n].id===t)return n;return-1}function fu(e){let t=document.createElementNS(su,`svg`);t.classList.add(`code-git-history-graph-svg`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let{historyItem:n,inputSwimlanes:r,outputSwimlanes:i}=e,a=r.findIndex(e=>e.id===n.id),o=a===-1?r.length:a,s=o<i.length?i[o].color:o<r.length?r[o].color:eu,c=0;for(let e=0;e<r.length;e+=1){let a=r[e],s=a.color;if(a.id===n.id){if(e!==o){let n=cu(s);n.setAttribute(`d`,[`M ${11*(e+1)} 0`,`A 11 11 0 0 1 ${11*e} 11`,`H ${11*(o+1)}`].join(` `)),t.append(n)}else c+=1;continue}if(c<i.length&&a.id===i[c].id){if(e===c)t.append(uu(11*(e+1),0,22,s));else{let n=cu(s);n.setAttribute(`d`,[`M ${11*(e+1)} 0`,`V 6`,`A ${iu} ${iu} 0 0 1 ${11*(e+1)-iu} ${22/2}`,`H ${11*(c+1)+iu}`,`A ${iu} ${iu} 0 0 0 ${11*(c+1)} ${22/2+iu}`,`V 22`].join(` `)),t.append(n)}c+=1}}for(let e=1;e<n.parentIds.length;e+=1){let r=du(i,n.parentIds[e]);if(r===-1)continue;let a=cu(i[r].color);a.setAttribute(`d`,[`M ${11*r} ${22/2}`,`A 11 11 0 0 1 ${11*(r+1)} 22`,`M ${11*r} ${22/2}`,`H ${11*(o+1)}`].join(` `)),t.append(a)}a!==-1&&t.append(uu(11*(o+1),0,22/2,r[a].color)),n.parentIds.length>0&&t.append(uu(11*(o+1),22/2,22,s)),e.kind===`HEAD`?(t.append(lu(o,au+3,ou,s)),t.append(lu(o,ou,1,s,!0))):n.parentIds.length>1?(t.append(lu(o,au+2,ou,s)),t.append(lu(o,au-1,ou,s))):t.append(lu(o,au+1,ou,s));let l=11*(Math.max(r.length,i.length,1)+1);return t.setAttribute(`width`,String(l)),t.setAttribute(`height`,`22`),t.setAttribute(`viewBox`,`0 0 ${l} 22`),t}function pu(e,t=22){let n=document.createElementNS(su,`svg`);n.classList.add(`code-git-history-graph-placeholder-svg`),n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`focusable`,`false`);for(let r=0;r<e.length;r+=1)n.append(uu(11*(r+1),0,t,e[r].color));let r=11*(Math.max(e.length,1)+1);return n.setAttribute(`width`,String(r)),n.setAttribute(`height`,String(t)),n.setAttribute(`viewBox`,`0 0 ${r} ${t}`),n}var mu=(0,B.memo)(function({viewModel:e}){let t=(0,B.useRef)(null);return(0,B.useLayoutEffect)(()=>{let n=t.current;n&&n.replaceChildren(fu(e))},[e]),(0,V.jsx)(`span`,{ref:t,className:`code-git-history-graph`,"aria-hidden":`true`})}),hu=(0,B.memo)(function({columns:e}){let t=(0,B.useRef)(null);return(0,B.useLayoutEffect)(()=>{let n=t.current;if(!n)return;let r=()=>{let t=Math.max(22,Math.round(n.getBoundingClientRect().height));n.replaceChildren(pu(e,t))};if(r(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(r);return i.observe(n),()=>i.disconnect()},[e]),(0,V.jsx)(`span`,{ref:t,className:`code-git-history-graph-placeholder`,"aria-hidden":`true`})}),gu=50,_u=20;function vu(e){if(!e)return``;let t=new Date(e);if(!Number.isFinite(t.getTime()))return``;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function yu(e,t){let n=new Set(e.map(e=>e.id));return[...e,...t.filter(e=>!n.has(e.id))]}function bu(e){return e.previousPath?`${e.previousPath} → ${e.path}`:e.path}function xu(e){let t=e.message.trim();return!t||t===e.subject?``:t.startsWith(e.subject)?t.slice(e.subject.length).trim():t}function Su({agentId:e,copy:t,projectId:n,projectWorkspace:r}){let[a,o]=(0,B.useState)(!0),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(`current`),[f,p]=(0,B.useState)(!1),[m,h]=(0,B.useState)(``),[g,_]=(0,B.useState)(``),[v,y]=(0,B.useState)(``),[b,x]=(0,B.useState)(null),[S,C]=(0,B.useState)(!1),[w,T]=(0,B.useState)(``),[E,D]=(0,B.useState)(null),O=(0,B.useCallback)(()=>D(null),[]),k=(0,B.useRef)(null),A=(0,B.useRef)(null),j=(0,B.useRef)(new Map),M=(0,B.useRef)(null),N=(0,B.useRef)(null),P=(0,B.useCallback)(()=>{A.current?.abort(),A.current=null,_(``),y(``),x(null),C(!1),T(``),D(null)},[]);(0,B.useEffect)(()=>(k.current?.abort(),A.current?.abort(),k.current=null,A.current=null,j.current.clear(),o(!0),l(null),d(`current`),p(!1),h(``),_(``),y(``),x(null),C(!1),T(``),()=>{k.current?.abort(),A.current?.abort()}),[e,n]),s(E!==null,N,M,O);let ee=(0,B.useCallback)(async(t,n,r=u)=>{k.current?.abort();let i=new AbortController;k.current=i,p(!0),h(``);try{let a=await ae(e,{limit:gu,skip:t,scope:r,signal:i.signal});if(i.signal.aborted)return;l(e=>n||!e?a:{...a,items:yu(e.items,a.items)})}catch(e){if(i.signal.aborted)return;h(e instanceof Error?e.message:`Git history request failed`)}finally{k.current===i&&(k.current=null,p(!1))}},[e,u]),ne=(0,B.useCallback)(async(t,n)=>{let r=`${t.id}:${n||`root`}`,i=j.current.get(r);if(A.current?.abort(),i){x(i),C(!1),T(``);return}let a=new AbortController;A.current=a,x(null),C(!0),T(``);try{let i=await te(e,t.id,{parent:n||void 0,signal:a.signal});if(a.signal.aborted)return;if(j.current.set(r,i),j.current.size>_u){let e=j.current.keys().next().value;e&&j.current.delete(e)}x(i)}catch(e){if(a.signal.aborted)return;T(e instanceof Error?e.message:`Commit changes request failed`)}finally{A.current===a&&(A.current=null,C(!1))}},[e]),re=()=>{o(e=>(e&&!c&&!f&&ee(0,!0),!e))},ie=()=>{j.current.clear(),P(),ee(0,!0)},I=e=>{D(null),e!==u&&(d(e),l(null),j.current.clear(),P(),ee(0,!0,e))},oe=()=>{D(e=>{if(e)return null;let t=M.current?.getBoundingClientRect();return t?{x:Math.max(8,Math.min(window.innerWidth-132-8,t.right-132)),y:t.bottom+66+8<=window.innerHeight?t.bottom+3:Math.max(8,t.top-66-3)}:null})},se=e=>{if(g===e.id){P();return}let t=e.parentIds[0]||``;_(e.id),y(t),ne(e,t)},L=(e,t)=>{y(t),ne(e,t)},ce=(e,t,n)=>{if(!t)return;let a=new URLSearchParams({root:r,base:t,head:e.id});n&&a.append(`path`,n),window.open(i(`/review?${a.toString()}`),`_blank`,`noopener,noreferrer`)},le=(0,B.useMemo)(()=>ru(c?.items??[],c?.head),[c?.head,c?.items]);return(0,V.jsxs)(`section`,{className:`code-git-history-section ${a?`collapsed`:``}`,"data-testid":`code-git-history-section`,"data-project-id":n,"aria-label":t.gitHistory,children:[(0,V.jsxs)(`div`,{className:`code-git-history-header`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`code-git-history-title`,"aria-expanded":!a,onClick:re,children:[(0,V.jsx)(`span`,{className:`code-file-section-chevron ${a?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:a?(0,V.jsx)(z,{}):(0,V.jsx)(R,{})}),(0,V.jsx)(`span`,{children:t.gitHistory})]}),!a&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`button`,{ref:M,type:`button`,className:`code-git-history-scope`,"aria-label":t.gitHistoryView,title:t.gitHistoryView,"aria-haspopup":`menu`,"aria-expanded":E?!0:void 0,disabled:f,onClick:oe,children:[(0,V.jsx)(`span`,{children:u===`current`?t.gitHistoryCurrentScope:t.gitHistoryAllScope}),(0,V.jsx)(R,{"aria-hidden":`true`})]}),E&&typeof document<`u`&&(0,Ql.createPortal)((0,V.jsx)(`div`,{ref:N,className:`code-git-history-scope-menu`,"data-testid":`code-git-history-scope-menu`,role:`menu`,"aria-label":t.gitHistoryView,style:{left:E.x,top:E.y},children:[[`current`,t.gitHistoryCurrentBranch],[`all`,t.gitHistoryAllBranches]].map(([e,t])=>(0,V.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":u===e,onClick:()=>I(e),children:[(0,V.jsx)(`span`,{className:`code-git-history-scope-check`,"aria-hidden":`true`,children:u===e&&(0,V.jsx)(ge,{})}),(0,V.jsx)(`span`,{children:t})]},e))}),document.body),(0,V.jsx)(`button`,{type:`button`,className:`code-git-history-refresh ${f?`loading`:``}`,title:t.refresh,"aria-label":t.refresh,disabled:f,onClick:ie,children:`↻`})]})]}),!a&&(0,V.jsxs)(`div`,{className:`code-git-history-body`,children:[f&&!c&&(0,V.jsx)(`div`,{className:`code-git-history-status`,children:t.loading}),m&&(0,V.jsx)(`div`,{className:`code-git-history-status error`,children:m}),c&&!c.isGitRepo&&(0,V.jsx)(`div`,{className:`code-git-history-status`,children:t.gitHistoryNotRepository}),c?.isGitRepo&&c.items.length===0&&!f&&(0,V.jsx)(`div`,{className:`code-git-history-status`,children:t.gitHistoryEmpty}),le.map(e=>{let n=e.historyItem,r=g===n.id,i=vu(n.timestamp),a=xu(n),o=n.references.filter(e=>e.category!==`head`&&!(u===`current`&&c?.branch&&e.name===c.branch));return(0,V.jsxs)(`div`,{className:`code-git-history-entry ${r?`selected`:``}`,"data-testid":`code-git-history-entry`,"data-commit-id":n.id,children:[(0,V.jsxs)(`button`,{type:`button`,className:`code-git-history-commit`,"aria-expanded":r,title:`${n.message||n.subject}\n${n.id}\n${n.author}${i?` · ${i}`:``}`,onClick:()=>se(n),children:[(0,V.jsx)(mu,{viewModel:e}),(0,V.jsxs)(`span`,{className:`code-git-history-commit-content`,children:[(0,V.jsx)(`span`,{className:`code-git-history-subject`,children:n.subject||n.displayId}),(0,V.jsxs)(`span`,{className:`code-git-history-footer`,children:[(0,V.jsxs)(`span`,{className:`code-git-history-meta`,children:[(0,V.jsx)(`span`,{className:`code-git-history-hash`,children:n.displayId}),n.author&&(0,V.jsx)(`span`,{children:n.author}),i&&n.timestamp!==void 0&&(0,V.jsx)(`time`,{dateTime:new Date(n.timestamp).toISOString(),children:i})]}),o.length>0&&(0,V.jsxs)(`span`,{className:`code-git-history-references`,"aria-label":o.map(e=>e.name).join(`, `),children:[o.slice(0,1).map(e=>(0,V.jsx)(`span`,{className:`code-git-history-reference ${e.category}`,title:e.name,children:e.name},e.id)),o.length>1&&(0,V.jsxs)(`span`,{className:`code-git-history-reference-more`,children:[`+`,o.length-1]})]})]})]})]}),r&&(0,V.jsxs)(`div`,{className:`code-git-history-details`,"data-testid":`code-git-history-details`,children:[(0,V.jsx)(hu,{columns:e.outputSwimlanes}),(0,V.jsxs)(`div`,{className:`code-git-history-details-content`,children:[(n.parentIds.length>1||n.parentIds.length===0)&&(0,V.jsx)(`div`,{className:`code-git-history-details-header`,children:n.parentIds.length>1?(0,V.jsxs)(`label`,{className:`code-git-history-parent-select`,children:[(0,V.jsx)(`span`,{children:t.gitHistoryParent}),(0,V.jsx)(`select`,{value:v,onChange:e=>L(n,e.target.value),children:n.parentIds.map((e,t)=>(0,V.jsxs)(`option`,{value:e,children:[t+1,`: `,e.slice(0,8)]},e))})]}):(0,V.jsx)(`span`,{className:`code-git-history-root-label`,children:t.gitHistoryRootCommit})}),a&&(0,V.jsxs)(`div`,{className:`code-git-history-message`,children:[(0,V.jsx)(`span`,{className:`code-git-history-message-label`,children:t.gitHistoryCommitMessage}),(0,V.jsx)(`span`,{className:`code-git-history-message-body`,children:a})]}),S&&(0,V.jsx)(`div`,{className:`code-git-history-status compact`,children:t.loading}),w&&(0,V.jsx)(`div`,{className:`code-git-history-status compact error`,children:w}),b&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`code-git-history-change-summary-row`,children:[(0,V.jsx)(`span`,{className:`code-git-history-change-summary`,children:t.gitHistoryCommitChanges(b.items.length)}),b.comparisonBase&&(0,V.jsxs)(`button`,{type:`button`,className:`code-git-history-review`,"aria-label":t.gitHistoryReviewCommit,title:t.gitHistoryReviewCommit,onClick:()=>ce(n,b.comparisonBase),children:[(0,V.jsx)(`span`,{children:t.reviewChanges}),(0,V.jsx)(me,{})]})]}),b.items.length===0&&(0,V.jsx)(`div`,{className:`code-git-history-status compact`,children:t.gitHistoryNoChanges}),(0,V.jsx)(`div`,{className:`code-git-history-change-list`,children:b.items.map(e=>b.comparisonBase?(0,V.jsxs)(`button`,{type:`button`,className:`code-git-history-change`,title:bu(e),onClick:()=>ce(n,b.comparisonBase,e.path),children:[(0,V.jsx)(`img`,{src:F(e.path),alt:``,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`code-git-history-change-path`,children:e.path}),e.previousPath&&(0,V.jsxs)(`span`,{className:`code-git-history-change-previous`,children:[`← `,e.previousPath]}),(0,V.jsx)(`span`,{className:`code-git-history-change-status ${e.status}`,children:e.statusLabel})]},`${e.status}:${e.path}`):(0,V.jsxs)(`div`,{className:`code-git-history-change static`,title:bu(e),children:[(0,V.jsx)(`img`,{src:F(e.path),alt:``,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`code-git-history-change-path`,children:e.path}),(0,V.jsx)(`span`,{className:`code-git-history-change-status ${e.status}`,children:e.statusLabel})]},`${e.status}:${e.path}`))}),b.truncated&&(0,V.jsx)(`div`,{className:`code-git-history-status compact`,children:t.gitHistoryChangesTruncated})]})]})]})]},n.id)}),c?.hasMore&&(0,V.jsx)(`button`,{type:`button`,className:`code-git-history-load-more`,disabled:f||c.nextSkip===null,onClick:()=>{c.nextSkip!==null&&ee(c.nextSkip,!1)},children:f?t.loading:t.gitHistoryLoadMore})]})]})}function Cu(e){return e.split(`/`).filter(Boolean).pop()||e}function wu({activeFilePath:e,collapsed:t,copy:n,files:r,projectId:i,onCloseOpenFile:a,onOpenFileContextMenu:o,onSelectOpenFile:s,onToggleCollapsed:c}){let l=(0,B.useRef)(null),u=(0,B.useRef)(null),d=Math.min(r.length,7),f=(0,B.useMemo)(()=>({"--code-open-editors-visible-rows":d,"--code-open-editors-list-max-height":`${d*28}px`}),[d]);return(0,B.useEffect)(()=>{if(t)return;let e=l.current,n=u.current;if(!e||!n)return;let r=n.offsetTop,i=r+n.offsetHeight;r<e.scrollTop?e.scrollTop=r:i>e.scrollTop+e.clientHeight&&(e.scrollTop=i-e.clientHeight)},[e,t,r.length]),r.length===0?null:(0,V.jsxs)(`div`,{className:`code-open-editors ${t?`collapsed`:``}`,"data-testid":`code-open-editors`,"data-project-id":i,"data-open-editor-count":r.length,"data-visible-editor-count":d,style:f,children:[(0,V.jsx)(`div`,{className:`code-open-editors-header`,children:(0,V.jsxs)(`button`,{type:`button`,className:`code-open-editors-title`,"aria-expanded":!t,onClick:c,children:[(0,V.jsx)(`span`,{className:`code-file-section-chevron ${t?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:t?(0,V.jsx)(z,{}):(0,V.jsx)(R,{})}),(0,V.jsx)(`span`,{children:n.openEditors})]})}),!t&&(0,V.jsx)(`div`,{ref:l,className:`code-open-editors-list`,children:r.map(t=>{let r=e===t.path,i=_e(t);return(0,V.jsxs)(`div`,{ref:r?u:void 0,className:`code-open-editor-row ${r?`active`:``}`,"data-testid":`code-open-editor-row`,"data-file-path":t.path,title:t.path,onContextMenu:e=>{o&&(e.preventDefault(),o(e.clientX,e.clientY,t))},children:[(0,V.jsxs)(`button`,{type:`button`,className:`code-open-editor-main`,onClick:()=>s?.(t.agentId,t.path),children:[(0,V.jsx)(`img`,{className:`code-file-type-icon file`,src:F(t.path),alt:``,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`code-open-editor-name`,children:Cu(t.path)}),(0,V.jsx)(`span`,{className:`code-open-editor-path`,children:M(t.path)}),i&&(0,V.jsx)(`span`,{className:`code-open-editor-state ${i}`,title:i===`external`?n.changedOnDisk:n.unsavedChanges})]}),a&&(0,V.jsx)(`button`,{type:`button`,className:`code-open-editor-close`,"aria-label":n.closeFile(t.path),title:n.closeFile(t.path),onClick:()=>a(t.agentId,t.path,t.workspaceRoot)})]},t.key)})})]})}function Tu({activeFilePath:e,activeSearchOptionId:t,agentId:n,agentLaunchOptions:r,copy:i,editorDirtyFilePaths:a,editorExternalChangedFilePaths:o,fileMenu:s,fileMenuRef:c,fileOperation:l,fileOperationInputRef:u,fileSearch:d,fileSearchInputRef:f,fileSearchListboxId:p,fileSearchResultsRef:m,filesCollapsed:h,handleFileSearchKeyDown:g,handleTreeKeyDownCapture:_,lastFocusedFilePathRef:v,locatedFilePath:y,openEditorsCollapsed:b,openFileError:x,openFilePendingPath:S,projectId:C,renderFileTreeRow:w,rootDirectoryError:T,rootDirectoryHasItems:E,rootDirectoryLoading:D,rowHeight:O,readOnly:k=!1,stickyContextItems:A,treeData:j,treeHeight:M,treeRef:N,treeViewportRef:P,visibleTreeRowCount:ee,onCancelPendingFileFocus:te,onCloseFileMenuWithFocusRestore:ne,onCloseFileMenuWithoutFocus:F,onCloseFileOperation:re,onCloseOpenFile:ie,onCopyFileMenuPath:ae,onCopyFileMenuShareUrl:I,onFocusFileTreeTarget:oe,onFocusStickyDirectory:se,onOpenFileContextMenu:L,onOpenFileJumpQuery:ce,onOpenFilePath:le,onOpenFileSearchMatch:ue,onOpenNewAgentFromFileMenu:de,onRefreshFileMenuTarget:fe,onRememberFileOperationName:pe,onSearchQueryChange:me,onSelectOpenFile:he,onSelectSearchMatchIndex:R,onToggleDirectory:ge,onStartAgentFromFileMenu:z,onStartFileMenuOperation:_e,onSubmitFileOperation:ve,onToggleFilesCollapsed:V,onToggleOpenEditorsCollapsed:ye,onToggleTreeNode:be,onTreeFocus:xe,onTreeSelect:Se,onUpdateFileOperationName:Ce}){let we=(0,B.useMemo)(()=>({active:d.active,activeOptionId:t,inputRef:f,listboxId:p,query:d.query}),[t,d.active,d.query,f,p]),Te=(0,B.useMemo)(()=>({active:d.active,activeMatchIndex:d.activeMatchIndex,anchorRef:f,error:d.error,includeIgnored:d.includeIgnored,jumpTarget:d.jumpTarget,listboxId:p,loading:d.loading,matches:d.matches,query:d.query,resultsRef:m,timeoutMs:d.timeoutMs,truncated:d.truncated}),[d.active,d.activeMatchIndex,d.error,d.includeIgnored,f,d.jumpTarget,d.loading,d.matches,d.query,d.timeoutMs,d.truncated,p,m]),Ee=(0,B.useMemo)(()=>({onOpenJumpQuery:ce,onOpenMatch:ue,onSearchIgnored:d.searchIgnored,onSelectMatchIndex:R}),[ce,ue,d.searchIgnored,R]),De=(0,B.useMemo)(()=>({activeFilePath:e,agentId:n,editorDirtyFilePaths:a,editorExternalChangedFilePaths:o,fileOperation:l,fileOperationInputRef:u,handleTreeKeyDownCapture:_,lastFocusedFilePathRef:v,locatedFilePath:y,openFilePendingPath:S,renderFileTreeRow:w,rowHeight:O,stickyContextItems:A,treeData:j,treeHeight:M,treeRef:N,treeViewportRef:P,visibleTreeRowCount:ee,onCancelPendingFileFocus:te,onCloseFileOperation:re,onFocusFileTreeTarget:oe,onFocusStickyDirectory:se,onOpenFileContextMenu:L,onOpenFilePath:le,onRememberFileOperationName:pe,onToggleDirectory:ge,onSubmitFileOperation:ve,onToggleTreeNode:be,onTreeFocus:xe,onTreeSelect:Se,onUpdateFileOperationName:Ce}),[e,n,a,o,l,u,_,v,y,S,w,O,A,j,M,N,P,ee,te,re,oe,se,L,le,pe,ge,ve,be,xe,Se,Ce]);return{bodySearch:Te,bodySearchActions:Ee,bodyTree:De,fileMenu:s,fileMenuRef:c,filesCollapsed:h,headerSearch:we,openEditors:{activeFilePath:e,collapsed:b,copy:i,projectId:C,onCloseOpenFile:ie,onSelectOpenFile:he,onToggleCollapsed:ye},sectionBody:{copy:i,agentLaunchOptions:r,fileMenu:s,fileMenuRef:c,openFileError:x,rootDirectoryError:T,rootDirectoryHasItems:E,rootDirectoryLoading:D,search:Te,searchActions:Ee,tree:De,onCloseFileMenu:F,onCloseFileMenuWithFocusRestore:ne,onCopyFileMenuPath:ae,onCopyFileMenuShareUrl:I,onOpenNewAgentFromFileMenu:de,onRefreshFileMenuTarget:fe,onStartAgentFromFileMenu:z,onStartFileMenuOperation:_e,readOnly:k},sectionHeader:{copy:i,filesCollapsed:h,search:we,onCancelPendingFileFocus:te,onFileSearchKeyDown:g,onSearchQueryChange:me,onToggleFilesCollapsed:V}}}var Eu=200,Du=15e3,Ou={error:null,items:[],loaded:!1,loading:!1,truncated:!1};function ku(e,t){let[n,r]=(0,B.useState)(Ou),i=(0,B.useRef)(null),a=(0,B.useRef)(0),o=(0,B.useRef)(new Map),s=(0,B.useRef)(t),l=(0,B.useRef)(!1),u=(0,B.useCallback)(()=>{if(!e)return i.current?.abort(),a.current+=1,r(Ou),Promise.resolve(!0);i.current?.abort();let t=new AbortController,n=!1,o=window.setTimeout(()=>{n=!0,t.abort()},Du);i.current=t;let s=a.current+1;return a.current=s,r(e=>({...e,error:null,loading:!0})),le(e,{limit:Eu,signal:t.signal}).then(e=>a.current===s?(r({error:null,items:e.items,loaded:!0,loading:!1,truncated:e.truncated}),!0):!1).catch(e=>{if(!n&&t.signal.aborted||a.current!==s)return!1;let i=!c().connected;return i&&(l.current=!0),r(t=>({...t,error:i?null:n?`File refresh timed out`:e instanceof Error?e.message:`Failed to refresh changes`,loaded:!0,loading:i})),!1}).finally(()=>window.clearTimeout(o))},[e]);return(0,B.useEffect)(()=>{s.current=t},[t]),(0,B.useEffect)(()=>{l.current=!1,o.current=O(s.current),u()},[e,u]),(0,B.useEffect)(()=>{let e=o.current,n=O(t);o.current=n,v(e,n)&&u()},[e,t,u]),(0,B.useEffect)(()=>{let e=()=>{l.current&&(l.current=!1,u())};return window.addEventListener(`farming:backend-connected`,e),()=>window.removeEventListener(`farming:backend-connected`,e)},[u]),(0,B.useEffect)(()=>()=>{i.current?.abort(),l.current=!1},[]),{...n,refreshChanges:u}}var Au=50,ju=60,Mu=6e3,Nu=80,Pu=100,Fu=2;function Iu(e){e?.focus({preventScroll:!0})}function Lu(){let e=document.activeElement;return e instanceof Element&&!!e.closest(`.code-file-monaco, .monaco-editor`)}function Ru(e,t){let n=e.getBoundingClientRect(),r=t.closest(`.code-project-group`),i=t.closest(`.code-files-section`),a=[r?.querySelector(`.code-project-row`),r?.querySelector(`.code-agents-section`),r?.querySelector(`[data-testid="code-open-editors"]`),i?.querySelector(`.code-files-header`),i?.querySelector(`.code-file-sticky-stack`)].reduce((e,t)=>{if(!t)return e;let r=t.getBoundingClientRect();return r.height<=0||r.bottom<=n.top||r.top>=n.bottom?e:Math.max(e,r.bottom)},n.top);return{top:Math.min(a,n.bottom),bottom:n.bottom}}function zu(e,t=!1){let n=e.closest(`.code-project-list`);if(!n)return;let r=Ru(n,e),i=e.getBoundingClientRect();n.scrollTop+=t?i.top-r.top-6:Cl(r,i)}function Bu({treeRef:e,treeViewportRef:t,fileSearchInputRef:n,fileOperationActiveRef:r,lastFocusedFilePathRef:i,treeData:a,isDirectoryLoaded:o,loadMissingDirectories:s,openDirectoriesInLayout:c,refreshTreeLayout:l}){let u=(0,B.useRef)(null),d=(0,B.useRef)([]),f=(0,B.useRef)(null),p=(0,B.useRef)([]),m=(0,B.useRef)([]),h=(0,B.useRef)([]),g=(0,B.useRef)([]),_=(0,B.useRef)(0),[v,y]=(0,B.useState)(null),b=(0,B.useRef)(null),x=(0,B.useRef)(a),S=(0,B.useRef)(o);(0,B.useEffect)(()=>{x.current=a},[a]),(0,B.useEffect)(()=>{S.current=o},[o]);let C=(0,B.useCallback)(()=>{y(null),b.current!==null&&(window.clearTimeout(b.current),b.current=null)},[]),w=(0,B.useCallback)(e=>{document.body.classList.contains(`code-file-location-dismissed`)||(C(),y(e),b.current=window.setTimeout(C,Mu))},[C]),T=(0,B.useCallback)(()=>{u.current!==null&&(window.cancelAnimationFrame(u.current),u.current=null),d.current.forEach(e=>window.clearTimeout(e)),d.current=[]},[]),D=(0,B.useCallback)(()=>{f.current!==null&&(window.cancelAnimationFrame(f.current),f.current=null),p.current.forEach(e=>window.clearTimeout(e)),p.current=[]},[]),O=(0,B.useCallback)(()=>{m.current.forEach(e=>window.clearTimeout(e)),m.current=[]},[]),k=(0,B.useCallback)(()=>{_.current+=1,D(),O(),h.current.forEach(e=>window.cancelAnimationFrame(e)),h.current=[],g.current.forEach(e=>window.clearTimeout(e)),g.current=[]},[O,D]),M=(0,B.useCallback)(()=>{T(),k(),C()},[T,k,C]),N=(0,B.useCallback)((i,a=!1,o=!1)=>{D(),O();let s=!1,c=()=>{let e=0,n=0,r=()=>{n+=1;let a=Array.from(t.current?.querySelectorAll(`[data-file-path]`)??[]).find(e=>e.dataset.filePath===i)??null;if(e=a?.classList.contains(`selected`)===!0?e+1:0,a&&e>=Fu){m.current=[],w(i);return}n>=Pu||(m.current=[window.setTimeout(r,Nu)])};r()},l=()=>{let e=n.current,s=wl({focusRow:a,operationActive:r.current,activeElementIsSearchInput:document.activeElement===e,searchInputValue:e?.value}),c=Array.from(t.current?.querySelectorAll(`[data-file-path]`)??[]).find(e=>e.dataset.filePath===i);c&&(c.scrollIntoView({block:`nearest`}),zu(c,o),s&&Iu(c.closest(`[role="tree"]`)))},u=()=>{let t=e.current;if(a&&!s){s=!0,t?.get(i)?.select();let e=t?.scrollTo(i,o?`start`:`smart`);e&&e.then(()=>{window.requestAnimationFrame(l)})}l()};u(),f.current=window.requestAnimationFrame(()=>{u(),f.current=window.requestAnimationFrame(u)}),xl.forEach(e=>{let t=window.setTimeout(u,e);p.current.push(t)}),o&&c()},[O,D,r,n,w,e,t]),P=(0,B.useCallback)((t,n=0,r=!1,i)=>{let a=i??_.current+1;i===void 0&&(_.current=a);let o=()=>_.current===a,s=e.current,u=x.current,d=j(u,t,r),f=A(u,t)??t,p=I(u,f),m=!!s;if(c(d),r&&(p?.type!==`directory`||!S.current(t))&&(m=!1),s&&(d.forEach(e=>{s.get(e)?s.open(e):m=!1}),r&&s.get(f)&&s.open(f),s.get(f)||(m=!1)),!m&&n<ju){let e=window.setTimeout(()=>{g.current=g.current.filter(t=>t!==e),o()&&P(t,n+1,r,a)},Au);g.current.push(e);return}(e=>{let t=window.requestAnimationFrame(()=>{h.current=h.current.filter(e=>e!==t),o()&&e()});h.current.push(t)})(()=>{o()&&(d.forEach(t=>e.current?.open(t)),l(d),N(f,!0,r))})},[c,l,N,e]),ee=(0,B.useCallback)(async e=>{await s([``,...E(e)]),P(e)},[s,P]),te=(0,B.useCallback)(async(e,t)=>{t===`directory`&&(document.body.classList.remove(`code-file-location-dismissed`),C()),await s([``,...E(e),...t===`directory`&&e?[e]:[]]),P(e,0,t===`directory`)},[C,s,P]),ne=(0,B.useCallback)(()=>{M();let e=(e=!1)=>{let t=n.current;t&&(Tl({activeElementIsSearchInput:document.activeElement===t,searchInputValue:t.value})||(t.focus(),El({requestedSelect:e,searchInputValue:t.value})&&t.select()))};e(!0),u.current=window.requestAnimationFrame(()=>e(!1)),bl.forEach(t=>{let n=window.setTimeout(()=>e(!1),t);d.current.push(n)})},[M,n]),F=(0,B.useCallback)(()=>{M();let r=()=>{if(n.current?.value)return;n.current?.blur();let r=t.current?.querySelector(`[role="tree"]`),a=Array.from(t.current?.querySelectorAll(`[data-file-path]`)??[]),o=Ol({lastFocusedPath:i.current,rows:a.map(e=>({path:e.dataset.filePath??``,selected:e.classList.contains(`selected`)})).filter(e=>e.path)});if(o&&a.find(e=>e.dataset.filePath===o)&&o){i.current=o,e.current?.get(o)?.select(),Iu(r);return}Iu(r)};r(),f.current=window.requestAnimationFrame(r),xl.forEach(e=>{let t=window.setTimeout(r,e);p.current.push(t)})},[M,n,i,e,t]),re=(0,B.useCallback)(n=>{D();let r=()=>{let r=Lu();if(n){e.current?.get(n)?.select();let i=Array.from(t.current?.querySelectorAll(`[data-file-path]`)??[]).find(e=>e.dataset.filePath===n),a=i?.closest(`[role="tree"]`)??t.current?.querySelector(`[role="tree"]`);if(r||Iu(a),i){i.scrollIntoView({block:`nearest`}),zu(i);return}}r||Iu(t.current?.querySelector(`[role="tree"]`))};r(),f.current=window.requestAnimationFrame(()=>{f.current=null,r()}),[80,180,360].forEach(e=>{let t=window.setTimeout(r,e);p.current.push(t)})},[D,e,t]),ie=(0,B.useCallback)(e=>{re(e?.path??null)},[re]);return(0,B.useEffect)(()=>{if(!v)return;let e=e=>{let t=e.target;(t instanceof Element?t.closest(`[data-file-path]`):null)?.dataset.filePath!==v&&(document.body.classList.add(`code-file-location-dismissed`),C())};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`keydown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`keydown`,e,!0)}},[C,v]),(0,B.useEffect)(()=>()=>{M(),C()},[M,C]),{cancelPendingFileFocus:M,focusFileSearchInput:ne,focusFileTreeFromSearch:F,focusFileTreePath:re,focusFileTreeTarget:ie,locatedFilePath:v,revealExplorerPath:te,revealFilePath:ee}}var Vu=15e3;function Hu(e){return e.replace(/^\/+|\/+$/g,``)}function Uu(e,t=e){let[n,r]=(0,B.useState)({}),i=(0,B.useRef)({}),a=(0,B.useRef)(new Map),o=(0,B.useRef)(new Map),s=(0,B.useRef)(new Set),l=(0,B.useRef)(0),u=(0,B.useCallback)((t=``)=>{if(!e)return Promise.resolve(null);let n=Hu(t),i=a.current.get(n);if(i)return i;let d=l.current;r(e=>({...e,[n]:{items:e[n]?.items??[],loading:!0,error:null}}));let f=null;return f=(async()=>{let t=new AbortController,i=!1,p=window.setTimeout(()=>{i=!0,t.abort()},Vu);try{let i=await C(e,n,{signal:t.signal});if(l.current!==d)return null;if(r(e=>({...e,[n]:{items:i.items,loading:!1,error:null,gitStatusPending:i.gitStatusPending}})),i.gitStatusPending&&!o.current.has(n)){let e=window.setTimeout(()=>{o.current.delete(n),u(n)},2e3);o.current.set(n,e)}return i}catch(e){if(l.current!==d)return null;let t=!c().connected;return t&&s.current.add(n),r(r=>({...r,[n]:{items:r[n]?.items??[],loading:t,error:t?null:i?`File refresh timed out`:e instanceof Error?e.message:`Failed to load directory`}})),null}finally{window.clearTimeout(p),f&&a.current.get(n)===f&&a.current.delete(n)}})(),a.current.set(n,f),f},[e]),d=(0,B.useCallback)(e=>{let t=Hu(e),n=i.current[t];return!n||n.loading||n.error?u(t):Promise.resolve({path:t,items:n.items,gitStatusPending:n.gitStatusPending})},[u]);return(0,B.useEffect)(()=>{i.current=n},[n]),(0,B.useEffect)(()=>{l.current+=1,a.current.clear(),s.current.clear(),o.current.forEach(e=>window.clearTimeout(e)),o.current.clear()},[e,t]),(0,B.useEffect)(()=>{r({}),i.current={}},[e,t]),(0,B.useEffect)(()=>()=>{a.current.clear(),o.current.forEach(e=>window.clearTimeout(e)),o.current.clear()},[]),(0,B.useEffect)(()=>{let e=()=>{let e=Array.from(s.current);s.current.clear(),e.forEach(e=>{u(e)})};return window.addEventListener(`farming:backend-connected`,e),()=>window.removeEventListener(`farming:backend-connected`,e)},[u]),(0,B.useMemo)(()=>({directories:n,loadDirectory:u,ensureDirectoryLoaded:d}),[n,d,u])}var Wu=12,Gu=6;function Ku(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function qu(e){return e.split(`/`).filter(Boolean).length}function Ju(e,t=e){let n=t||``,{directories:r,loadDirectory:i,ensureDirectoryLoaded:a}=Uu(e,t),[o,s]=(0,B.useState)(()=>new Set(p(n).openDirectoryPaths??[])),c=(0,B.useRef)(o),l=(0,B.useRef)(n),u=(0,B.useRef)(new Map),d=(0,B.useRef)(``),m=(0,B.useMemo)(()=>ee(r[``]?.items??[],r),[r]),h=(0,B.useMemo)(()=>Math.max(1,ue(m,o)),[o,m]),g=(0,B.useCallback)((e,t)=>{let n=c.current;if(n.has(e)===t)return;let r=new Set(n);t?r.add(e):r.delete(e),c.current=r,s(r)},[]),_=(0,B.useCallback)(e=>c.current.has(e),[]),v=(0,B.useCallback)(e=>{if(e.length===0)return;let t=new Set(c.current),n=!1;e.forEach(e=>{!e||t.has(e)||(t.add(e),n=!0)}),n&&(c.current=t,s(t))},[]),y=(0,B.useCallback)(()=>i(``),[i]),b=(0,B.useCallback)(e=>{let t=e.filter(e=>!r[e]);return Promise.all(t.map(e=>i(e)))},[r,i]),x=(0,B.useCallback)(e=>{let t=r[e];return!!(t&&!t.loading&&!t.error)},[r]),S=(0,B.useCallback)(e=>{let t=new Set([``]);e.forEach(e=>{let n=String(e??``).replace(/^\/+|\/+$/g,``);for(t.add(n);n;)n=Ku(n),t.add(n)});let n=Array.from(t).sort((e,t)=>qu(e)-qu(t)||e.localeCompare(t));return(async()=>{let e=new Map,t=new Set,r=!0,a=0;for(;a<n.length;){let o=qu(n[a]),s=[];for(;a<n.length&&qu(n[a])===o;)s.push(n[a]),a+=1;let c=s.filter(n=>{if(!n)return!0;if(Array.from(t).some(e=>n===e||n.startsWith(`${e}/`)))return!1;let i=Ku(n),a=e.get(i);return a===null?(r=!1,!1):a&&!a.items.some(e=>e.type===`directory`&&e.path===n)?(t.add(n),!1):!0}),l=0,u=Array.from({length:Math.min(Gu,c.length)},async()=>{for(;l<c.length;){let t=c[l];l+=1;let n=await i(t);e.set(t,n),n||(r=!1)}});await Promise.all(u)}if(t.size>0){let e=Array.from(t),n=new Set(Array.from(c.current).filter(t=>!e.some(e=>t===e||t.startsWith(`${e}/`))));c.current=n,s(n)}return r})()},[i]),C=(0,B.useCallback)(e=>{let t=u.current.get(e);if(t)return t;let n;return n=(async()=>{let t=e;for(let e=0;e<Wu;e+=1){let e=await a(t),n=e?.items.length===1&&e.items[0]?.type===`directory`?e.items[0]:null;if(!n)return;t=n.path}})().finally(()=>{u.current.get(e)===n&&u.current.delete(e)}),u.current.set(e,n),n},[a]);return(0,B.useEffect)(()=>{u.current.clear()},[e]),(0,B.useEffect)(()=>{l.current===n&&f(n,{openDirectoryPaths:Array.from(o)})},[n,o]),(0,B.useEffect)(()=>{if(l.current===n)return;l.current=n,d.current=``;let e=p(n).openDirectoryPaths??[],t=new Set(e);c.current=t,s(t)},[n]),(0,B.useEffect)(()=>{if(o.size===0)return;let e=`${n}:${Array.from(o).join(`
|
|
12
|
-
`)}`;d.current!==e&&(d.current=e,y(),b(Array.from(o)))},[b,y,n,o]),(0,B.useMemo)(()=>({directories:r,treeData:m,openDirectoryPaths:o,visibleTreeRowCount:h,loadRootDirectory:y,ensureDirectoryLoaded:a,isDirectoryLoaded:x,loadMissingDirectories:b,refreshDirectories:S,hydrateCompactDirectoryChains:C,isDirectoryOpen:_,setDirectoryOpen:g,openDirectoriesInLayout:v}),[r,a,C,_,x,b,y,v,o,S,g,m,h])}function Yu({agentId:e,agentLaunchOptionCount:t=0,cancelPendingFileFocus:n,clearFileOperation:r,focusFileTreeTarget:a,refreshDirectories:o,projectWorkspace:s,shareLinkFailed:c,setOpenFileError:u,startFileOperation:d}){let f=(0,B.useRef)(null),[p,h]=(0,B.useState)(null),g=(0,B.useCallback)(()=>{h(null)},[]),_=(0,B.useCallback)((e,i,a)=>{n(),u(null),r(),h({...dt(e,i,a,window.innerWidth,window.innerHeight,t),item:a})},[t,n,r,u]),v=(0,B.useCallback)((e=!1)=>{let t=p?.item??null;h(null),e&&a(t)},[p?.item,a]),y=(0,B.useCallback)(()=>{v(!1)},[v]),b=(0,B.useCallback)(()=>{v(!0)},[v]),x=(0,B.useCallback)((e,t=p?.item??null)=>{n(),h(null),d(e,t)},[n,p?.item,d]),S=(0,B.useCallback)(()=>{e&&(o([rt(p?.item??null)]),h(null))},[e,p?.item,o]);return{fileMenu:p,fileMenuRef:f,clearFileMenu:g,closeFileMenuWithFocusRestore:b,closeFileMenuWithoutFocus:y,copyFileMenuPath:(0,B.useCallback)(async()=>{let e=p?.item;if(e){h(null),u(null);try{await navigator.clipboard?.writeText(e.path)}catch{u(`Copy failed`)}}},[p?.item,u]),copyFileMenuShareUrl:(0,B.useCallback)(async()=>{let t=p?.item;if(!(!e||!t||t.type!==`file`&&t.type!==`directory`)){h(null),u(null);try{let n=t.type===`directory`?{kind:`folder`,agentId:e,folderPath:t.path,absolutePath:m(s,t.path),projectLabel:l(s)}:{kind:`file`,agentId:e,filePath:t.path,absolutePath:m(s,t.path),projectLabel:l(s)},r=await fetch(i(`/api/share/qr-ticket`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target:n})}),a=await r.json();if(!r.ok||!a.longUrl||!await pe(a.longUrl))throw Error(a.error||c)}catch(e){u(e instanceof Error?e.message:c)}}},[e,p?.item,s,u,c]),fileMenuTargetDirectory:(0,B.useCallback)((e=p?.item??null)=>rt(e),[p?.item]),openFileContextMenu:_,refreshFileMenuTarget:S,startFileMenuOperation:x}}var Xu=220;function Zu({agentId:e,onClearSearch:t,onOpenFile:n,onRevealFilePath:r,onSelectOpenFile:i}){let a=(0,B.useRef)(0),o=(0,B.useRef)({agentId:e,mounted:!0}),s=(0,B.useRef)(null),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(null);o.current.agentId=e;let f=(0,B.useCallback)(()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null),d(null)},[]),p=(0,B.useCallback)((e,t,n)=>{f(),s.current=window.setTimeout(()=>{a.current===e&&o.current.agentId===t&&o.current.mounted&&d(n),s.current=null},Xu)},[f]);return(0,B.useEffect)(()=>(o.current.mounted=!0,()=>{o.current.mounted=!1,a.current+=1,s.current!==null&&(window.clearTimeout(s.current),s.current=null)}),[]),(0,B.useEffect)(()=>{a.current+=1,f(),l(null)},[e,f]),{openFileError:c,openFilePendingPath:u,openFilePath:(0,B.useCallback)(async(s,c)=>{if(!e)return;let u=e,d=a.current+1;if(a.current=d,l(null),i?.(e,s,c)){f(),t(),oe(c)&&r(s);return}p(d,u,s);try{let e=await k(u,s);if(a.current!==d||o.current.agentId!==u||!o.current.mounted)return;f(),n(u,e,c),t(),oe(c)&&r(s)}catch(e){if(a.current!==d||o.current.agentId!==u||!o.current.mounted)return;if(f(),c&&e instanceof se&&e.status===404&&_(c)){n(u,g(s,c),c),t();return}l(e instanceof Error?e.message:`Failed to open file`)}},[e,f,t,n,r,i,p]),setOpenFileError:l}}var Qu=15e3;async function $u(e){let t=new AbortController,n=!1,r=window.setTimeout(()=>{n=!0,t.abort()},Qu);try{return await e(t.signal)}catch(e){if(n){let e=Error(`File operation timed out`);throw e.name=`TimeoutError`,e}throw e}finally{window.clearTimeout(r)}}function ed({agentId:e,fileOperationActiveRef:t,ensureDirectoryLoaded:n,focusFileTreePath:r,onDeleteEntries:i,onMoveEntries:a,onOpenFile:o,onWorkspaceChange:s,refreshDirectories:c,setOpenFileError:l}){let u=(0,B.useRef)(null),d=(0,B.useRef)(``),f=(0,B.useRef)(0),p=(0,B.useRef)(null),[m,h]=(0,B.useState)(null),g=(0,B.useCallback)(()=>{p.current=null,t.current=!1,h(null)},[]),_=(0,B.useCallback)(e=>{let t=p.current;return t?.generation===e.generation&&t.rootId===e.rootId},[]),v=(0,B.useCallback)(e=>_(e)?(p.current=null,t.current=!1,h(e=>p.current===null?null:e),!0):!1,[_]),y=(0,B.useCallback)(e=>{if(!_(e))return!1;let t={...e,generation:f.current+1,operation:{...e.operation,submitting:!1},submitted:!1};return f.current=t.generation,p.current=t,h(e=>p.current===t?t.operation:e),!0},[_]),b=(0,B.useCallback)((n,r)=>{if(!e||r?.readOnly&&!(r.symbolicLink&&(n===`rename`||n===`delete`)))return;let i=at(n,r),a=f.current+1;f.current=a,p.current={generation:a,operation:i,rootId:e,submitted:!1},d.current=i.name,t.current=!0,l(null),h(i)},[e,l]),x=(0,B.useCallback)(()=>{let e=p.current;e&&v(e)&&r(e.operation.item?.path??null)},[v,r]),S=(0,B.useCallback)(e=>{d.current=e;let t=p.current;t&&!t.submitted&&(t.operation={...t.operation,name:e})},[]),T=(0,B.useCallback)(e=>{d.current=e;let t=p.current;t&&!t.submitted&&(t.operation={...t.operation,name:e}),h(t=>t&&{...t,name:e})},[]),E=(0,B.useCallback)(async()=>{let t=p.current;if(!e||!t||t.rootId!==e||t.submitted)return;let u=t.operation.kind===`delete`?t.operation:{...t.operation,name:d.current},f=U(u);if(!(u.kind!==`delete`&&!f)){t.operation={...u,submitting:!0},t.submitted=!0,h(e=>_(t)?t.operation:e),l(null);try{if(u.kind===`new-file`||u.kind===`new-folder`){let e=await $u(e=>N(t.rootId,u.parentPath,f,u.kind===`new-folder`?`directory`:`file`,{signal:e}));c([u.parentPath]),s?.(),_(t)&&(e.entry.type===`directory`&&(n(e.entry.path),r(e.entry.path)),e.file&&o(t.rootId,e.file),v(t));return}if(u.kind===`rename`&&u.item){let e=u.item,n=await $u(n=>fe(t.rootId,e.path,f,e.version,{signal:n}));c(L(n)),a(t.rootId,[n]),s?.(),v(t)&&r(ie(n));return}if(u.kind===`delete`&&u.item){let e=u.item,n=await $u(n=>re(t.rootId,e.path,e.version,{signal:n}));c(w(n)),i(t.rootId,[n]),s?.(),v(t)&&r(P(n))}}catch(e){let d=u.kind===`new-file`||u.kind===`new-folder`?[u.parentPath]:u.item?[u.item.path.includes(`/`)?u.item.path.slice(0,u.item.path.lastIndexOf(`/`)):``]:[],p=!(e instanceof se)||e.status>=500;if(p&&(u.kind===`new-file`||u.kind===`new-folder`))try{let e=ct(u,f,(await $u(e=>C(t.rootId,u.parentPath,{signal:e}))).items);if(e){if(c([u.parentPath]),s?.(),e.type===`directory`&&_(t))n(e.path),r(e.path),v(t);else if(e.type===`file`&&_(t)){r(e.path);try{let n=await $u(n=>k(t.rootId,e.path,{signal:n}));_(t)&&o(t.rootId,n)}catch{}v(t)}return}}catch{}if(p&&u.item&&(u.kind===`rename`||u.kind===`delete`))try{let e=d[0]??``,n=await $u(n=>C(t.rootId,e,{signal:n}));if(u.kind===`rename`){let e=lt(u,f,n.items);if(e){c(L(e)),a(t.rootId,[e]),s?.(),v(t)&&r(ie(e));return}}if(u.kind===`delete`){let e=st(u,n.items);if(e){c(w(e)),i(t.rootId,[e]),s?.(),v(t)&&r(P(e));return}}}catch{}d.length>0&&(c(d),s?.()),y(t)&&l(e instanceof Error?e.message:`File operation failed`)}}},[e,v,n,r,_,i,a,o,s,c,y,l]);return(0,B.useLayoutEffect)(()=>{let t=p.current;t&&t.rootId!==e&&g()},[e,g]),(0,B.useLayoutEffect)(()=>()=>{p.current=null,t.current=!1},[]),(0,B.useEffect)(()=>{if(!m)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),x())};return document.addEventListener(`keydown`,e,!0),()=>{document.removeEventListener(`keydown`,e,!0)}},[x,m]),{fileOperation:m,fileOperationActiveRef:t,fileOperationInputRef:u,clearFileOperation:g,closeFileOperation:x,rememberFileOperationName:S,startFileOperation:b,submitFileOperation:E,updateFileOperationName:T}}var td=3e3;function nd(e){let[t,n]=(0,B.useState)(``),[r,i]=(0,B.useState)([]),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(0),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(td),[h,g]=(0,B.useState)(!1),_=(0,B.useRef)(0),v=t.trim().length>0,y=(0,B.useMemo)(()=>v?De(t):null,[v,t]),b=r.length>0?Math.min(l,r.length-1):-1,x=b>=0?r[b]??null:null,S=(0,B.useCallback)(()=>{_.current+=1,n(``),i([]),c(null),u(0),f(!1),m(td),g(!1),o(!1)},[]),C=(0,B.useCallback)(e=>{g(!1),n(e)},[]),w=(0,B.useCallback)(()=>{g(!0)},[]),T=(0,B.useCallback)(()=>{r.length!==0&&u(e=>Math.min(e+1,r.length-1))},[r.length]),E=(0,B.useCallback)(()=>{r.length!==0&&u(e=>Math.max(e-1,0))},[r.length]),D=(0,B.useCallback)(e=>{u(Math.max(0,Math.min(e,Math.max(r.length-1,0))))},[r.length]);return(0,B.useEffect)(()=>{let n=t.trim(),r=_.current+1;if(_.current=r,u(0),!e||!n||De(n)){i([]),o(!1),c(null),f(!1);return}o(!0),c(null);let a=new AbortController,s=window.setTimeout(()=>{de(e,n,{includeIgnored:h,limit:60,signal:a.signal}).then(e=>{_.current===r&&(i(e.matches),f(e.truncated),m(e.timeoutMs??td),o(!1))}).catch(e=>{_.current===r&&(e instanceof DOMException&&e.name===`AbortError`||(i([]),f(!1),c(e instanceof Error?e.message:`Search failed`),o(!1)))})},180);return()=>{window.clearTimeout(s),a.abort()}},[e,h,t]),(0,B.useEffect)(()=>{u(e=>Math.min(e,Math.max(r.length-1,0)))},[r.length]),(0,B.useMemo)(()=>({query:t,setQuery:C,matches:r,loading:a,error:s,selectMatchIndex:D,truncated:d,timeoutMs:p,includeIgnored:h,active:v,jumpTarget:y,activeMatchIndex:b,selectedMatch:x,clear:S,searchIgnored:w,selectNext:T,selectPrevious:E}),[v,b,S,s,y,a,r,h,w,t,D,T,E,x,d,p])}function rd({fileMenuOpen:e,fileOperationActive:t,fileSearch:n,fileSearchResultsRef:r,filesCollapsed:i,focusFileTreeFromSearch:a,listboxId:o,onOpenFilePath:s,onRevealDirectoryPath:c}){let l=je({active:n.active,activeMatchIndex:n.activeMatchIndex,jumpTarget:n.jumpTarget,listboxId:o}),u=(0,B.useCallback)(e=>{if(e.kind===`path`&&e.entryType===`directory`){c(e.path),n.clear();return}let t=ke(e);s(t.path,t.target),n.clear()},[n,s,c]),d=(0,B.useCallback)(e=>{let t=Ae(e);return t?(s(t.path,t.target),n.clear(),!0):!1},[n,s]),f=(0,B.useCallback)(e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),n.clear(),a();return}if(e.key===`ArrowDown`){if(n.matches.length===0)return;e.preventDefault(),n.selectNext();return}if(e.key===`ArrowUp`){if(n.matches.length===0)return;e.preventDefault(),n.selectPrevious();return}if(e.key!==`Enter`||(e.preventDefault(),e.stopPropagation(),d(e.currentTarget.value)))return;let t=n.selectedMatch??n.matches[0];t&&u(t)},[n,a,d,u]);return(0,B.useEffect)(()=>{if(!n.active||n.matches.length===0)return;let e=r.current,t=e?.querySelector(`.code-file-search-result.active`);if(!e||!t)return;let i=t.offsetTop,a=i+t.offsetHeight;i<e.scrollTop?e.scrollTop=i:a>e.scrollTop+e.clientHeight&&(e.scrollTop=a-e.clientHeight)},[n.active,n.activeMatchIndex,n.matches.length,r]),(0,B.useEffect)(()=>{if(i||!n.active||e||t)return;let r=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n.clear(),a())};return document.addEventListener(`keydown`,r,!0),()=>{document.removeEventListener(`keydown`,r,!0)}},[e,t,n,i,a]),{activeOptionId:l,handleFileSearchKeyDown:f,openFileJumpQuery:d,openFileSearchMatch:u}}function id({agentId:e,workspaceKey:t,clearFileMenu:n,clearFileOperation:r,clearFileSearch:i,focusFileSearchInput:a,focusSearchRequest:o,loadRootDirectory:s,openFilesCount:c,refreshTreeLayout:l,revealExplorerPath:u,revealRequest:d,rootDirectoryLoaded:m,setFileSearchQuery:h,setOpenFileError:g,treeData:_}){let[v,y]=(0,B.useState)(()=>p(t).filesCollapsed??!0),[b,x]=(0,B.useState)(!0),S=(0,B.useRef)(null),C=(0,B.useRef)(t),w=(0,B.useCallback)(()=>{let e=!v;e?(n(),r(),i()):m||s(),y(e)},[n,r,i,v,s,m]),T=(0,B.useCallback)(()=>{x(e=>!e)},[]);return(0,B.useEffect)(()=>{g(null),n(),r(),i()},[e,n,r,i,g]),(0,B.useEffect)(()=>{if(d){if(y(!1),!m){s();return}S.current!==d.requestId&&(S.current=d.requestId,u(d.path,d.kind))}},[s,u,d,m]),(0,B.useEffect)(()=>{o&&(y(!1),m||s(),typeof o.query==`string`&&h(o.query),a())},[a,o,s,m,h]),(0,B.useEffect)(()=>{c===0&&x(!0)},[c]),(0,B.useEffect)(()=>{C.current===t&&f(t,{filesCollapsed:v})},[v,t]),(0,B.useEffect)(()=>{C.current!==t&&(C.current=t,y(p(t).filesCollapsed??!0))},[t]),(0,B.useEffect)(()=>{!v&&!m&&s()},[v,s,m]),(0,B.useEffect)(()=>{v||l()},[v,l,_]),{filesCollapsed:v,openEditorsCollapsed:b,toggleFilesCollapsed:w,toggleOpenEditorsCollapsed:T}}function ad(e,t){let n=t.closest(`.code-project-group`),r=n?.querySelector(`.code-project-row`),i=n?.querySelector(`.code-agents-section`),a=n?.querySelector(`[data-testid="code-open-editors"]`);return Fl(e.getBoundingClientRect().top,r?.getBoundingClientRect().height??30,(i?.getBoundingClientRect().height??0)+(a?.getBoundingClientRect().height??0),25)}function od({filesCollapsed:e,focusFileTreePath:t,lastFocusedFilePathRef:n,openDirectoryPaths:r,refreshTreeLayout:i,resetKey:a,treeData:o,treeViewportRef:s}){let[c,l]=(0,B.useState)([]),[u,d]=(0,B.useState)(!1),f=(0,B.useMemo)(()=>c.map(e=>I(o,e)).filter(e=>!!e),[c,o]),p=(0,B.useMemo)(()=>zl({visible:u,directoryNodes:f}),[u,f]),m=(0,B.useCallback)(()=>{l(e=>e.length===0?e:[]),d(!1)},[]),h=(0,B.useCallback)(()=>{let t=s.current,n=t?.closest(`.code-project-list`);if(!t||!n||e){m();return}let r=n.getBoundingClientRect(),i=ad(n,t),a=t.getBoundingClientRect(),o=Array.from(t.querySelectorAll(`[data-file-path]`)).flatMap(e=>{let t=e.dataset.filePath;if(!t)return[];let n=e.getBoundingClientRect();return[{path:t,top:n.top,bottom:n.bottom}]}),c=Ll(o,i,r.bottom);if(!c){m();return}d(Il(a.top,i));let u=Rl(c,o,i);l(e=>e.length===u.length&&e.every((e,t)=>e===u[t])?e:u)},[m,e,s]),g=(0,B.useCallback)(e=>{n.current=e.path,t(e.path)},[t,n]);return(0,B.useEffect)(()=>{m()},[m,a]),(0,B.useEffect)(()=>{if(e){m();return}i();let t=window.requestAnimationFrame(()=>i()),n=window.setTimeout(i,80),r=window.setTimeout(i,180);return()=>{window.cancelAnimationFrame(t),window.clearTimeout(n),window.clearTimeout(r)}},[m,e,r,i,o]),(0,B.useLayoutEffect)(()=>{if(e)return;let t=s.current?.closest(`.code-project-list`),n=0,r=()=>{n||=window.requestAnimationFrame(()=>{n=0,(0,Ql.flushSync)(h)})};return h(),window.setTimeout(h,80),t?.addEventListener(`scroll`,r,{passive:!0}),window.addEventListener(`resize`,r),()=>{n&&window.cancelAnimationFrame(n),t?.removeEventListener(`scroll`,r),window.removeEventListener(`resize`,r)}},[e,r,h,o,s]),{focusStickyDirectory:g,stickyContextItems:p}}function sd({rowHeight:e,visibleTreeRowCount:t,openDirectoryPaths:n,treeData:r,hydrateCompactDirectoryChains:i,isDirectoryOpen:a,setDirectoryOpen:o}){let s=(0,B.useRef)(void 0),c=(0,B.useRef)(null),l=(0,B.useRef)(null),u=(0,B.useRef)(new Set),d=(0,B.useRef)(new Set),f=Math.max(e,t*e),p=(0,B.useCallback)(e=>{if(e.length===0)return!1;let t=s.current;if(!t)return!1;let n=!1;return e.forEach(e=>{!e||!t.get(e)||u.current.has(e)||t.isOpen(e)||(t.open(e,!1),n=!0)}),n},[]),m=(0,B.useCallback)((e=[])=>{let t=()=>{p(e),s.current?.redrawList()};t(),window.requestAnimationFrame(t),window.setTimeout(t,80)},[p]),h=(0,B.useCallback)((e,t)=>{t?(u.current.delete(e),d.current.delete(e)):(u.current.add(e),d.current.delete(e)),o(e,t)},[o]),g=(0,B.useCallback)(e=>{let t=!a(e);return h(e,t),t},[a,h]);(0,B.useEffect)(()=>{u.current.forEach(e=>{if(!n.has(e)){d.current.add(e);return}d.current.has(e)&&(u.current.delete(e),d.current.delete(e))})},[n]),(0,B.useEffect)(()=>{let e=Array.from(n);if(e.length===0)return;let t=()=>{p(e)&&s.current?.redrawList()};t();let r=window.requestAnimationFrame(t),i=window.setTimeout(t,80),a=window.setTimeout(t,180);return()=>{window.cancelAnimationFrame(r),window.clearTimeout(i),window.clearTimeout(a)}},[n,p,r]);let _=(0,B.useCallback)(({attrs:e,innerRef:t,children:n})=>{let{style:r,className:i,...a}=e;return(0,B.createElement)(`div`,{...a,ref:t,style:{...r,minWidth:`100%`,width:`100%`},className:`code-file-tree-row-frame ${i??``}`.trim()},n)},[]);return{treeRef:s,treeViewportRef:c,lastFocusedFilePathRef:l,treeHeight:f,handleTreeToggle:(0,B.useCallback)(e=>{Vl(c.current?.closest(`.code-project-list`)),a(e)?i(e).finally(()=>m([e])):m()},[i,a,m]),refreshTreeLayout:m,rememberFocusedTreeNode:(0,B.useCallback)(e=>{e&&(l.current=e.data.path)},[]),rememberSelectedTreeNodes:(0,B.useCallback)(e=>{let t=e[e.length-1];t&&(l.current=t.data.path)},[]),renderFileTreeRow:_,setTreePathOpen:h,toggleTreePathOpen:g}}function cd({treeRef:e,treeViewportRef:t,lastFocusedFilePathRef:n,fileOperation:r,openDirectoryPaths:i,cancelPendingFileFocus:a,closeFileOperation:o,focusFileSearchInput:s,focusFileTreePath:c,focusFileTreeTarget:l,openFileContextMenu:u,openFilePath:d,setDirectoryOpen:f,startFileOperation:p,toggleDirectoryOpen:m}){let h=(0,B.useCallback)(()=>t.current?.closest(`.code-project-list`)??null,[t]),g=(0,B.useCallback)(()=>{let e=t.current,n=(e?.querySelector(`[data-file-path]`))?.getBoundingClientRect().height||24;return Al((h()??e)?.getBoundingClientRect().height??n,n)},[h,t]),_=(0,B.useCallback)((e,t=!0)=>{Vl(h()),t&&f(e.data.path,!0),e.open(),n.current=e.data.path,l(e.data)},[l,n,h,f]),v=(0,B.useCallback)((t,r,i=!0)=>{Vl(h()),i&&f(t,!1),r?r.close():e.current?.close(t),n.current=t,r?l(r.data):c(t)},[c,l,n,h,f,e]),y=(0,B.useCallback)(c=>{if(c.defaultPrevented||c.altKey)return;if((c.ctrlKey||c.metaKey)&&!c.shiftKey&&c.key.toLowerCase()===`p`){c.preventDefault(),c.stopPropagation(),s();return}if(c.ctrlKey||c.metaKey)return;let f=e.current,h=c.target;if(r&&c.key===`Escape`&&h?.closest(`.code-file-inline-operation`)){c.preventDefault(),c.stopPropagation(),o();return}if(h?.closest(`input, textarea, [contenteditable="true"], .code-file-inline-operation`))return;Dl(c.key)&&a();let y=h?.closest(`[data-file-path]`)?.dataset.filePath,b=y?void 0:t.current?.querySelector(`[data-file-path].selected`),x={path:b?.dataset.filePath,type:b?.dataset.fileType,expanded:b?.getAttribute(`aria-expanded`)===`true`},S=f?.focusedNode&&!f.focusedNode.isRoot?f.focusedNode:null,C=kl({targetPath:y,selectedPath:x.path,focusedPath:S?.data.path,lastFocusedPath:n.current}),w=C?f?.get(C):f?.focusedNode??f?.mostRecentNode;if(!w||w.isRoot)return;if(n.current=w.data.path,c.key===`ContextMenu`||c.shiftKey&&c.key===`F10`){c.preventDefault(),c.stopPropagation();let e=(c.target?.closest(`[data-file-path]`))?.getBoundingClientRect();u(e?e.left+24:24,e?e.top+e.height:24,w.data);return}if(c.shiftKey)return;if(c.key===`ArrowDown`||c.key===`ArrowUp`){c.preventDefault(),c.stopPropagation();let e=c.key===`ArrowDown`?w.next:w.prev;if(!e||e.isRoot)return;e.focus(),e.select(),n.current=e.data.path;return}if(c.key===`Home`||c.key===`End`){c.preventDefault(),c.stopPropagation();let e=f?.visibleNodes.filter(e=>!e.isRoot)??[],t=c.key===`Home`?e[0]:e[e.length-1];if(!t)return;t.focus(),t.select(),n.current=t.data.path,l(t.data);return}if(c.key===`PageUp`||c.key===`PageDown`){c.preventDefault(),c.stopPropagation();let e=f?.visibleNodes.filter(e=>!e.isRoot)??[],t=jl({currentIndex:e.findIndex(e=>e.id===w.id),key:c.key,pageSize:g(),rowCount:e.length}),r=t>=0?e[t]:null;if(!r)return;r.focus(),r.select(),n.current=r.data.path,l(r.data);return}if(c.key===`F2`){c.preventDefault(),c.stopPropagation(),p(`rename`,w.data);return}if(c.key===`Delete`||c.key===`Backspace`){c.preventDefault(),c.stopPropagation(),p(`delete`,w.data);return}if(c.key===`ArrowRight`){if(w.data.type!==`directory`)return;if(c.preventDefault(),c.stopPropagation(),!w.isOpen){_(w);return}let e=w.children?.[0]??null;e&&(e.select(),e.focus(),n.current=e.data.path,l(e.data));return}if(c.key===`ArrowLeft`){if(c.preventDefault(),c.stopPropagation(),Ml({nodePath:w.data.path,nodeType:w.data.type,nodeOpen:w.isOpen,selectedRow:x,openDirectoryPaths:i})){v(w.data.path,w);return}let e=w.parent;e&&!e.isRoot&&(e.select(),e.focus(),n.current=e.data.path,l(e.data));return}if(c.key!==`Enter`&&c.key!==` `)return;c.preventDefault(),c.stopPropagation();let T=w.data.type===`directory`?m(w.data.path)?`open-directory`:`close-directory`:Pl({nodeType:w.data.type,nodeOpen:w.isOpen});if(T===`close-directory`){v(w.data.path,w,!1);return}if(T===`open-directory`){_(w,!1);return}T===`open-file`&&(n.current=w.data.path,d(w.data.path))},[a,o,v,r,s,l,n,_,i,u,d,g,p,m,e,t]);return(0,B.useEffect)(()=>{let n=n=>{if(n.key!==`ArrowLeft`||n.altKey||n.ctrlKey||n.metaKey)return;let r=t.current,i=document.activeElement;if(!r||!(i instanceof Element)||!r.contains(i))return;let a=r.querySelector(`[data-file-path].selected`),o=a?.dataset.filePath;if(!o||a?.dataset.fileType!==`directory`||a.getAttribute(`aria-expanded`)!==`true`)return;n.preventDefault(),n.stopPropagation();let s=e.current?.get(o);v(o,s)};return window.addEventListener(`keydown`,n,!0),()=>{window.removeEventListener(`keydown`,n,!0)}},[v,e,t]),{handleTreeKeyDownCapture:y}}var ld=24,ud=350,dd=1400,fd=new Set;function pd(e){return e.replace(/[^a-zA-Z0-9_-]+/g,`-`)||`root`}function md(e,t){let n=e.replace(/\/+$/,``)||`/`,r=t.replace(/^\/+|\/+$/g,``);return r?n===`/`?`/${r}`:`${n}/${r}`:n}function hd(e){return e.split(`/`).filter(Boolean).pop()||e}function gd(e){return{id:e.path,name:hd(e.path),path:e.path,type:`file`,size:0,mtimeMs:0}}function _d({projectId:e,projectWorkspace:t,agentId:n,agentLaunchOptions:r,activeFilePath:i,revealRequest:a,focusSearchRequest:o,editorDirtyFilePaths:s=fd,editorExternalChangedFilePaths:l=fd,openFiles:u=[],onOpenFile:d,onSelectOpenFile:f,onCloseOpenFile:p,onNewAgent:m,onStartAgent:g,onMoveEntries:_,onDeleteEntries:v,onRefreshOpenFiles:y,onFilesCollapsedChange:b,readOnly:x=!1,copy:S}){let{directories:C,treeData:w,openDirectoryPaths:T,visibleTreeRowCount:E,loadRootDirectory:D,ensureDirectoryLoaded:O,isDirectoryLoaded:k,loadMissingDirectories:A,refreshDirectories:j,hydrateCompactDirectoryChains:M,isDirectoryOpen:N,setDirectoryOpen:P,openDirectoriesInLayout:ee}=Ju(n,e),te=(0,B.useRef)(!1),ne=(0,B.useRef)(null),F=(0,B.useRef)(null),re=(0,B.useRef)(null),ie=(0,B.useRef)(!1),ae=(0,B.useRef)(0),I=(0,B.useRef)(null),[oe,se]=(0,B.useState)(`idle`),L=nd(n),ce=`code-file-search-results-${pd(e)}`,{treeRef:le,treeViewportRef:ue,lastFocusedFilePathRef:de,treeHeight:fe,handleTreeToggle:pe,refreshTreeLayout:me,rememberFocusedTreeNode:he,rememberSelectedTreeNodes:R,renderFileTreeRow:ge,setTreePathOpen:z,toggleTreePathOpen:_e}=sd({rowHeight:ld,visibleTreeRowCount:E,openDirectoryPaths:T,treeData:w,hydrateCompactDirectoryChains:M,isDirectoryOpen:N,setDirectoryOpen:P}),{cancelPendingFileFocus:ve,focusFileSearchInput:ye,focusFileTreeFromSearch:be,focusFileTreePath:xe,focusFileTreeTarget:Se,locatedFilePath:Ce,revealExplorerPath:we,revealFilePath:Te}=Bu({treeRef:le,treeViewportRef:ue,fileSearchInputRef:ne,fileOperationActiveRef:te,lastFocusedFilePathRef:de,treeData:w,isDirectoryLoaded:k,loadMissingDirectories:A,openDirectoriesInLayout:ee,refreshTreeLayout:me}),De=L.clear,{openFileError:Oe,openFilePendingPath:ke,openFilePath:Ae,setOpenFileError:je}=Zu({agentId:n,onClearSearch:De,onOpenFile:d,onRevealFilePath:Te,onSelectOpenFile:f}),Me=ku(x?null:n,u),[Ne,Pe]=(0,B.useState)(!0),Fe=(0,B.useCallback)(()=>{if(ie.current)return;ie.current=!0;let e=ae.current+1;ae.current=e,I.current!==null&&(window.clearTimeout(I.current),I.current=null),se(`refreshing`),je(null);let r=[``,...T],i=new Promise(e=>{window.setTimeout(e,ud)});(async()=>{let a=!1;try{let e=await Me.refreshChanges(),[o,s]=await Promise.all([j(r),n&&y?y(n,t):Promise.resolve(!0)]);await i,a=e&&o&&s}catch{await i}ae.current===e&&(ie.current=!1,se(a?`success`:c().connected?`error`:`idle`),a&&(I.current=window.setTimeout(()=>{ae.current===e&&se(`idle`),I.current=null},dd)))})()},[n,Me.refreshChanges,y,T,t,j,je]);(0,B.useEffect)(()=>{ae.current+=1,ie.current=!1,I.current!==null&&(window.clearTimeout(I.current),I.current=null),se(`idle`)},[n,e]),(0,B.useEffect)(()=>()=>{ae.current+=1,I.current!==null&&window.clearTimeout(I.current)},[]),(0,B.useEffect)(()=>{Pe(!0)},[n]);let Ie=(0,B.useCallback)(()=>{Pe(e=>!e)},[]),Le=(0,B.useCallback)(e=>{Ae(e.path,{...h(e),transient:!0})},[Ae]),{fileOperation:Re,fileOperationInputRef:ze,clearFileOperation:Be,closeFileOperation:Ve,rememberFileOperationName:He,startFileOperation:Ue,submitFileOperation:We,updateFileOperationName:Ge}=ed({agentId:n,fileOperationActiveRef:te,ensureDirectoryLoaded:O,focusFileTreePath:xe,onDeleteEntries:v,onMoveEntries:_,onOpenFile:d,onWorkspaceChange:Me.refreshChanges,refreshDirectories:j,setOpenFileError:je}),{fileMenu:H,fileMenuRef:Ke,clearFileMenu:qe,closeFileMenuWithFocusRestore:Je,closeFileMenuWithoutFocus:Ye,copyFileMenuPath:Xe,copyFileMenuShareUrl:Ze,fileMenuTargetDirectory:Qe,openFileContextMenu:$e,refreshFileMenuTarget:et,startFileMenuOperation:tt}=Yu({agentId:n,agentLaunchOptionCount:r.length,cancelPendingFileFocus:ve,clearFileOperation:Be,focusFileTreeTarget:Se,projectWorkspace:t,refreshDirectories:j,shareLinkFailed:S.shareLinkFailed,setOpenFileError:je,startFileOperation:Ue}),nt=(0,B.useCallback)(e=>{je(null),L.setQuery(e)},[L.setQuery,je]),rt=(0,B.useCallback)(()=>md(t,Qe()),[Qe,t]),it=(0,B.useCallback)(()=>{m&&(Ye(),m(t))},[Ye,m,t]),at=(0,B.useCallback)(e=>{if(!g)return;let n=rt();Ye(),g(e,n,n===t?void 0:{projectWorkspace:t})},[Ye,rt,g,t]),ot=(0,B.useCallback)((e,t,n)=>{$e(e,t,gd(n))},[$e]),{filesCollapsed:U,openEditorsCollapsed:st,toggleFilesCollapsed:ct,toggleOpenEditorsCollapsed:lt}=id({agentId:n,workspaceKey:e,clearFileMenu:qe,clearFileOperation:Be,clearFileSearch:De,focusFileSearchInput:ye,focusSearchRequest:o,loadRootDirectory:D,openFilesCount:u.length,refreshTreeLayout:me,revealExplorerPath:we,revealRequest:a,rootDirectoryLoaded:!!(C[``]&&!C[``].loading),setFileSearchQuery:L.setQuery,setOpenFileError:je,treeData:w});(0,B.useEffect)(()=>{b?.(U)},[U,b]);let ut=(0,B.useMemo)(()=>u.length===0?{"--code-open-editors-sticky-height":`0px`}:st?{"--code-open-editors-sticky-height":`25px`}:{"--code-open-editors-sticky-height":`${25+Math.min(u.length,7)*28}px`},[st,u.length]);(0,B.useEffect)(()=>{!i||U||!C[``]||re.current!==i&&(re.current=i,Te(i))},[i,C,U,Te]);let{focusStickyDirectory:dt,stickyContextItems:ft}=od({filesCollapsed:U,focusFileTreePath:xe,lastFocusedFilePathRef:de,openDirectoryPaths:T,refreshTreeLayout:me,resetKey:n,treeData:w,treeViewportRef:ue}),{activeOptionId:mt,handleFileSearchKeyDown:ht,openFileJumpQuery:gt,openFileSearchMatch:W}=rd({fileMenuOpen:!!H,fileOperationActive:!!Re,fileSearch:L,fileSearchResultsRef:F,filesCollapsed:U,focusFileTreeFromSearch:be,listboxId:ce,onOpenFilePath:Ae,onRevealDirectoryPath:e=>we(e,`directory`)}),{handleTreeKeyDownCapture:_t}=cd({treeRef:le,treeViewportRef:ue,lastFocusedFilePathRef:de,fileOperation:Re,openDirectoryPaths:T,cancelPendingFileFocus:ve,closeFileOperation:Ve,focusFileSearchInput:ye,focusFileTreePath:xe,focusFileTreeTarget:Se,openFileContextMenu:$e,openFilePath:Ae,setDirectoryOpen:z,startFileOperation:tt,toggleDirectoryOpen:_e}),vt=Tu({activeFilePath:i,activeSearchOptionId:mt,agentId:n??``,agentLaunchOptions:r,copy:S,editorDirtyFilePaths:s,editorExternalChangedFilePaths:l,fileMenu:H,fileMenuRef:Ke,fileOperation:Re,fileOperationInputRef:ze,fileSearch:L,fileSearchInputRef:ne,fileSearchListboxId:ce,fileSearchResultsRef:F,filesCollapsed:U,handleFileSearchKeyDown:ht,handleTreeKeyDownCapture:_t,lastFocusedFilePathRef:de,locatedFilePath:Ce,openEditorsCollapsed:st,openFileError:Oe,openFilePendingPath:ke,projectId:e,renderFileTreeRow:ge,rootDirectoryError:C[``]?.error??null,rootDirectoryHasItems:!!C[``]?.items.length,rootDirectoryLoading:!!C[``]?.loading,rowHeight:ld,readOnly:x,stickyContextItems:ft,treeData:w,treeHeight:fe,treeRef:le,treeViewportRef:ue,visibleTreeRowCount:E,onCancelPendingFileFocus:ve,onCloseFileMenuWithFocusRestore:Je,onCloseFileMenuWithoutFocus:Ye,onCloseFileOperation:Ve,onCloseOpenFile:p,onCopyFileMenuPath:Xe,onCopyFileMenuShareUrl:Ze,onFocusFileTreeTarget:Se,onFocusStickyDirectory:dt,onOpenFileContextMenu:$e,onOpenFileJumpQuery:gt,onOpenFilePath:Ae,onOpenFileSearchMatch:W,onOpenNewAgentFromFileMenu:it,onRefreshFileMenuTarget:et,onRememberFileOperationName:He,onSearchQueryChange:nt,onSelectOpenFile:f,onSelectSearchMatchIndex:L.selectMatchIndex,onToggleDirectory:_e,onStartAgentFromFileMenu:at,onStartFileMenuOperation:tt,onSubmitFileOperation:We,onToggleFilesCollapsed:ct,onToggleOpenEditorsCollapsed:lt,onToggleTreeNode:pe,onTreeFocus:he,onTreeSelect:R,onUpdateFileOperationName:Ge});return n?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(wu,{...vt.openEditors,files:u,onOpenFileContextMenu:ot}),(0,V.jsxs)(`div`,{className:`code-files-section ${U?`collapsed`:``}`,"data-testid":`code-files-section`,"data-project-id":e,style:ut,children:[(0,V.jsx)(Zl,{...vt.sectionHeader,refreshStatus:oe,onRefreshFiles:Fe}),!U&&(0,V.jsxs)(V.Fragment,{children:[!x&&(0,V.jsx)(Ee,{activeFilePath:i,projectWorkspace:t,changes:Me,collapsed:Ne,copy:S,projectId:e,refreshing:oe===`refreshing`,onOpenChange:Le,onToggleCollapsed:Ie}),!x&&(0,V.jsx)(Su,{agentId:n,copy:S,projectId:e,projectWorkspace:t}),(0,V.jsx)(Xl,{...vt.sectionBody})]})]}),U&&(0,V.jsx)(pt,{agentId:n,copy:S,agentLaunchOptions:r,fileMenu:H,fileOperation:Re,fileMenuRef:Ke,fileOperationInputRef:ze,onCloseFileMenu:Ye,onCloseFileMenuWithFocusRestore:Je,onCloseFileOperation:Ve,onCopyFileMenuPath:Xe,onCopyFileMenuShareUrl:Ze,onOpenNewAgent:it,onRefreshFileMenuTarget:et,onRememberFileOperationName:He,onStartAgent:at,onStartFileMenuOperation:tt,onSubmitFileOperation:We,onUpdateFileOperationName:Ge,readOnly:x})]}):null}export{_d as ProjectFilesSection};
|
|
11
|
+
Use the data prop if you want to provide your own handlers.`);if(e.initialData){let[t,n]=gl(e.initialData,{idAccessor:e.idAccessor,childrenAccessor:e.childrenAccessor});return Object.assign(Object.assign(Object.assign({},e),n),{data:t})}else return e}function vl(e,t){return(0,V.jsxs)(al,{treeProps:_l(e),imperativeHandle:t,children:[(0,V.jsx)(sl,{children:(0,V.jsx)(cl,{})}),(0,V.jsx)(ll,{})]})}var yl=(0,B.forwardRef)(vl),bl=[0,80,180,300,520,900,1200],xl=[80,180,360],Sl=new Set([`ArrowDown`,`ArrowUp`,`ArrowLeft`,`ArrowRight`,`Home`,`End`,`PageUp`,`PageDown`,`Enter`,` `,`F2`,`Delete`,`Backspace`,`ContextMenu`]);function Cl(e,t){return t.top<e.top?t.top-e.top:t.bottom>e.bottom?t.bottom-e.bottom:0}function wl(e){return e.focusRow&&!e.operationActive&&!e.activeElementIsSearchInput&&!e.searchInputValue}function Tl(e){return e.activeElementIsSearchInput&&!!e.searchInputValue}function El(e){return e.requestedSelect||!e.searchInputValue}function Dl(e){return Sl.has(e)}function Ol(e){return e.rows.find(t=>t.path===e.lastFocusedPath)?.path??e.rows.find(e=>e.selected)?.path??e.rows[0]?.path??null}function kl(e){return e.selectedPath??e.targetPath??e.focusedPath??e.lastFocusedPath??null}function Al(e,t){return Math.max(1,Math.floor(Math.max(0,e)/Math.max(1,t))-1)}function jl(e){if(e.rowCount<=0)return-1;let t=Math.max(0,Math.min(e.currentIndex,e.rowCount-1))+(e.key===`PageUp`?-1:1)*Math.max(1,e.pageSize);return Math.max(0,Math.min(t,e.rowCount-1))}function Ml(e){if(e.nodeType!==`directory`)return!1;let t=e.selectedRow.path===e.nodePath&&e.selectedRow.type===`directory`&&e.selectedRow.expanded===!0;return e.nodeOpen||t||e.openDirectoryPaths.has(e.nodePath)}function Nl(e){let t=!e.metaKey&&!e.ctrlKey&&!e.shiftKey;return e.nodeType===`directory`&&t?`toggle-directory`:e.nodeType===`file`&&t?`open-file`:`select`}function Pl(e){return e.nodeType===`directory`?e.nodeOpen?`close-directory`:`open-directory`:e.nodeType===`file`?`open-file`:`none`}function Fl(e,t=30,n=0,r=25){return e+t+n+r}function Il(e,t,n=1){return e<t+n}function Ll(e,t,n,r=1){return e.find(e=>e.bottom>t+r&&e.top<n)?.path??``}function Rl(e,t,n){if(!e)return[];let r=new Map(t.map(e=>[e.path,e.top]));return E(e).filter(e=>{let t=r.get(e);return typeof t==`number`&&t<n})}function zl(e){let t=Math.max(1,e.rowHeight),n=Math.max(0,Math.floor(e.maxRows));if(n===0)return[];let r=e.stickyTop,i=[],a=Ll(e.rows,r,e.scrollerBottom);for(let o=0;o<e.rows.length+1;o+=1){let o=Rl(a,e.rows,r).slice(-n),s=e.stickyTop+o.length*t;if(s===r&&o.length===i.length&&o.every((e,t)=>e===i[t]))return o;i=o,r=s,a=e.rows.find(t=>t.top>=r-1&&t.top<e.scrollerBottom)?.path??``}return i}function Bl(e){return!e.visible&&e.directoryNodes.length===0?[]:e.directoryNodes.map(e=>({kind:`directory`,key:e.path,node:e}))}function Vl(e){return e.map(e=>e.displayName??e.name).filter(Boolean).join(`/`)}function Hl(e){if(!e)return()=>{};let t=e.scrollTop,n=()=>{e.scrollTop=t};return n(),window.requestAnimationFrame(n),window.setTimeout(n,0),window.setTimeout(n,80),window.setTimeout(n,180),n}function Ul(e,t,n){let r=qe(e.node.descendantGitStatus);return(0,V.jsxs)(`button`,{type:`button`,className:`code-file-row directory code-file-sticky-row`,style:H(D(e.node.path)),title:e.node.path,onClick:t=>{t.preventDefault(),t.stopPropagation(),n(e.node)},children:[(0,V.jsx)(`span`,{className:`code-file-chevron expanded`,"aria-hidden":`true`,children:(0,V.jsx)(R,{})}),(0,V.jsx)(`span`,{className:`code-file-name`,children:e.node.displayName??e.node.name}),r&&(0,V.jsx)(`span`,{className:r,title:Ge(`git`,t)})]},e.key)}function Wl({copy:e,items:t,onFocusDirectory:n}){if(t.length===0)return null;let r=t.filter(e=>e.kind===`directory`),i=r[r.length-1];return(0,V.jsx)(`div`,{className:`code-file-sticky-shell`,children:(0,V.jsxs)(`div`,{className:`code-file-sticky-stack`,"data-testid":`code-file-sticky-stack`,"aria-label":e.stickyFolderPath,children:[(0,V.jsx)(`div`,{className:`code-file-sticky-expanded-rows`,children:r.map(t=>Ul(t,e,n))}),i&&(0,V.jsxs)(`button`,{type:`button`,className:`code-file-row directory code-file-sticky-row code-file-sticky-compact-row`,style:H(0),title:i.node.path,onClick:e=>{e.preventDefault(),e.stopPropagation(),n(i.node)},children:[(0,V.jsx)(`span`,{className:`code-file-chevron expanded`,"aria-hidden":`true`,children:(0,V.jsx)(R,{})}),(0,V.jsx)(`span`,{className:`code-file-name`,children:Vl(r.map(e=>e.node))})]})]})})}function Gl({agentId:e,copy:t,fileOperation:n,inputRef:r,item:i,onCancel:a,onInputName:o,onSubmit:s}){return(0,B.useLayoutEffect)(()=>{let e=r.current;e&&(e.focus({preventScroll:!0}),document.activeElement===e&&e.setSelectionRange(0,ot(n)))},[n.item?.path,r]),(0,V.jsx)(`form`,{className:`code-file-inline-operation`,"data-testid":`code-file-inline-operation`,"aria-busy":n.submitting,style:{gridColumn:`3 / -1`},autoComplete:`off`,onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),onSubmit:e=>{e.preventDefault(),e.stopPropagation(),s()},children:(0,V.jsx)(`input`,{id:`code-file-operation-input`,"data-testid":`code-file-operation-input`,name:`farming-file-${e}-rename`,type:`text`,inputMode:`text`,ref:r,defaultValue:n.name,disabled:n.submitting,"aria-label":t.renameEntry(i.name),autoComplete:`off`,"aria-autocomplete":`none`,autoCapitalize:`none`,autoCorrect:`off`,autoFocus:!0,spellCheck:!1,enterKeyHint:`done`,"data-lpignore":`true`,"data-1p-ignore":`true`,"data-bwignore":`true`,"data-form-type":`other`,onInput:e=>{o(e.currentTarget.value)},onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),a();return}e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),s())}})})}function Kl({copy:e,item:t,viewState:n}){let{directoryDotClassName:r,directoryDotTitleKind:i,fileChangedClassName:a,fileChangedTitleKind:o,fileOpening:s,isDirectory:c,showDirectoryDot:l,visibleGitStatus:u,visibleGitStatusClassName:d,visibleGitStatusLabel:f}=n;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`code-file-name`,children:t.displayName??t.name}),t.symbolicLink&&(0,V.jsx)(`span`,{className:`code-file-symbolic-link`,"aria-hidden":`true`,children:`↷`}),s&&(0,V.jsx)(`span`,{className:`code-file-open-spinner`,title:e.loading,"aria-hidden":`true`}),!s&&l&&(0,V.jsx)(`span`,{className:r,title:Ge(i,e)}),!s&&!c&&f&&(0,V.jsx)(`span`,{className:d,title:e.gitStatus(u||``),children:f}),!s&&!c&&!f&&a&&(0,V.jsx)(`span`,{className:a,title:Ge(o,e)})]})}function ql(e){e?.focus({preventScroll:!0})}function Jl({isDirectory:e,item:t,lastFocusedFilePathRef:n,node:r,treeViewportRef:i,onCancelPendingFileFocus:a,onFocusFileTreeTarget:o,onOpenFileContextMenu:s,onOpenFilePath:c,onToggleDirectory:l}){let u=(0,B.useCallback)(()=>{ql(i.current?.querySelector(`[role="tree"]`))},[i]),d=(0,B.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),a(),n.current=t.path,r.select(),s(e.clientX,e.clientY,t)},[t,n,r,a,s]),f=(0,B.useCallback)(n=>{e||n.button!==0||n.metaKey||n.ctrlKey||n.shiftKey||c(t.path,{transient:!0})},[e,t.path,c]);return{handleRowClick:(0,B.useCallback)(s=>{a(),n.current=t.path;let d=Nl({nodeType:t.type,metaKey:s.metaKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey}),f=e?Hl(i.current?.closest(`.code-project-list`)):null;if(d===`toggle-directory`){s.preventDefault(),s.stopPropagation();let e=l(t.path);r.select(),r.focus(),u(),e?r.open():r.close(),o(t),f?.();return}if(d===`open-file`&&s.detail===0&&c(t.path,{transient:!0}),r.handleClick(s),r.focus(),u(),s.shiftKey){ql(s.currentTarget),f?.();return}o(t),f?.()},[u,e,t,n,r,a,o,c,l,i]),handleRowContextMenu:d,handleRowMouseDown:f}}function Yl({activeFilePath:e,agentId:t,copy:n,editorDirtyFilePaths:r,editorExternalChangedFilePaths:i,fileOperation:a,fileOperationInputRef:o,lastFocusedFilePathRef:s,locatedFilePath:c,node:l,openFilePendingPath:u,treeViewportRef:d,onCancelPendingFileFocus:f,onCloseFileOperation:p,onFocusFileTreeTarget:m,onOpenFileContextMenu:h,onOpenFilePath:g,onRememberFileOperationName:_,onToggleDirectory:v,onSubmitFileOperation:y}){let b=l.data,x=Ye({activeFilePath:e,editorDirtyFilePaths:r,editorExternalChangedFilePaths:i,openFilePendingPath:u,item:b,isFocused:l.isFocused,isOpen:l.isOpen,isSelected:l.isSelected}),{chevronState:S,isDirectory:C}=x,w=`${x.rowClasses} ${c===b.path?`located`:``}`.trim(),T=C?``:F(b.path),E=a?.kind===`rename`&&a.item?.path===b.path?a:null,{handleRowClick:D,handleRowContextMenu:O,handleRowMouseDown:k}=Jl({isDirectory:C,item:b,lastFocusedFilePathRef:s,node:l,treeViewportRef:d,onCancelPendingFileFocus:f,onFocusFileTreeTarget:m,onOpenFileContextMenu:h,onOpenFilePath:g,onToggleDirectory:v});return(0,V.jsxs)(`div`,{className:w,style:H(l.level),"data-testid":`code-file-row`,"data-file-path":b.path,"data-file-type":b.type,"data-tree-level":l.level,"aria-label":b.path,title:b.linkTarget?`${b.path} ↷ ${b.linkTarget}`:b.linkError?`${b.path} (${b.linkError})`:void 0,tabIndex:-1,"aria-expanded":C?l.isOpen:void 0,onContextMenu:O,onMouseDown:k,onClick:D,children:[(0,V.jsx)(`span`,{className:`code-file-chevron ${S}`,"aria-hidden":`true`,children:S===`expanded`?(0,V.jsx)(R,{}):S===`collapsed`?(0,V.jsx)(z,{}):null}),!C&&(0,V.jsx)(`img`,{className:`code-file-type-icon file`,src:T,alt:``,"aria-hidden":`true`}),E?(0,V.jsx)(Gl,{agentId:t,copy:n,fileOperation:E,inputRef:o,item:b,onCancel:p,onInputName:_,onSubmit:y}):(0,V.jsx)(Kl,{copy:n,item:b,viewState:x})]})}function Xl({activeFilePath:e,agentId:t,copy:n,editorDirtyFilePaths:r,editorExternalChangedFilePaths:i,fileOperation:a,fileOperationInputRef:o,handleTreeKeyDownCapture:s,lastFocusedFilePathRef:c,locatedFilePath:l,openFilePendingPath:u,renderFileTreeRow:d,rowHeight:f,stickyContextItems:p,treeData:m,treeHeight:h,treeRef:g,treeViewportRef:_,visibleTreeRowCount:v,onCancelPendingFileFocus:y,onCloseFileOperation:b,onFocusFileTreeTarget:x,onFocusStickyDirectory:S,onOpenFileContextMenu:C,onOpenFilePath:w,onRememberFileOperationName:T,onToggleDirectory:E,onSubmitFileOperation:D,onToggleTreeNode:O,onTreeFocus:k,onTreeSelect:A,onUpdateFileOperationName:j}){let M=(0,B.useCallback)(e=>{e.target?.closest(`[data-file-path]`)||(e.preventDefault(),y(),C(e.clientX,e.clientY,null))},[y,C]),N=(0,B.useCallback)(({node:s})=>(0,V.jsx)(Yl,{activeFilePath:e,agentId:t,copy:n,editorDirtyFilePaths:r,editorExternalChangedFilePaths:i,fileOperation:a,fileOperationInputRef:o,lastFocusedFilePathRef:c,locatedFilePath:l,node:s,openFilePendingPath:u,treeViewportRef:_,onCancelPendingFileFocus:y,onCloseFileOperation:b,onFocusFileTreeTarget:x,onOpenFileContextMenu:C,onOpenFilePath:w,onRememberFileOperationName:T,onToggleDirectory:E,onSubmitFileOperation:D,onUpdateFileOperationName:j}),[e,t,n,r,i,a,o,c,l,y,b,x,C,w,T,D,E,j,u,_]);return(0,V.jsxs)(`div`,{className:`code-file-tree-viewport`,ref:_,"data-visible-row-count":v,style:{height:h},onKeyDownCapture:s,onContextMenu:M,children:[(0,V.jsx)(Wl,{copy:n,items:p,onFocusDirectory:S}),(0,V.jsx)(yl,{ref:g,data:m,idAccessor:`id`,childrenAccessor:`children`,rowHeight:f,indent:0,height:h,width:`100%`,overscanCount:v,openByDefault:!1,selectionFollowsFocus:!0,className:`code-file-tree`,rowClassName:`code-file-tree-row`,renderRow:d,onToggle:O,onFocus:k,onSelect:A,disableDrag:!0,disableEdit:!0,disableDrop:!0,children:N})]})}function Zl({copy:e,agentLaunchOptions:t,fileMenu:n,fileMenuRef:r,openFileError:i,rootDirectoryError:a,rootDirectoryHasItems:o,rootDirectoryLoading:s,search:c,searchActions:l,tree:u,onCloseFileMenu:d,onCloseFileMenuWithFocusRestore:f,onCopyFileMenuPath:p,onCopyFileMenuShareUrl:m,onOpenNewAgentFromFileMenu:h,onRefreshFileMenuTarget:g,onStartAgentFromFileMenu:_,onStartFileMenuOperation:v,readOnly:y=!1}){return(0,V.jsxs)(V.Fragment,{children:[s&&!o&&(0,V.jsx)(`div`,{className:`code-file-status`,style:H(0),children:e.loading}),a&&(0,V.jsx)(`div`,{className:`code-file-status error`,style:H(0),children:a}),i&&!c.active&&(0,V.jsx)(`div`,{className:`code-file-status error`,"data-testid":`code-file-open-error`,style:H(0),children:i}),c.active&&(0,V.jsx)(Ue,{activeMatchIndex:c.activeMatchIndex,anchorRef:c.anchorRef,containerRef:c.resultsRef,copy:e,error:c.error,jumpTarget:c.jumpTarget,listboxId:c.listboxId,loading:c.loading,matches:c.matches,openFileError:i,query:c.query,showIgnoredSearch:!c.includeIgnored,timeoutMs:c.timeoutMs,truncated:c.truncated,onOpenJumpQuery:l.onOpenJumpQuery,onOpenMatch:l.onOpenMatch,onSearchIgnored:l.onSearchIgnored,onSelectMatchIndex:l.onSelectMatchIndex}),(0,V.jsx)(Xl,{...u,copy:e}),(0,V.jsx)(pt,{agentId:u.agentId,copy:e,agentLaunchOptions:t,fileMenu:n,fileOperation:u.fileOperation,fileMenuRef:r,fileOperationInputRef:u.fileOperationInputRef,onCloseFileMenu:d,onCloseFileMenuWithFocusRestore:f,onCloseFileOperation:u.onCloseFileOperation,onCopyFileMenuPath:p,onCopyFileMenuShareUrl:m,onOpenNewAgent:h,onRefreshFileMenuTarget:g,onRememberFileOperationName:u.onRememberFileOperationName,onStartAgent:_,onStartFileMenuOperation:v,onSubmitFileOperation:u.onSubmitFileOperation,onUpdateFileOperationName:u.onUpdateFileOperationName,readOnly:y})]})}function Ql({copy:e,filesCollapsed:t,refreshStatus:n,search:r,onCancelPendingFileFocus:i,onFileSearchKeyDown:a,onSearchQueryChange:o,onRefreshFiles:s,onToggleFilesCollapsed:c}){let l=n===`refreshing`?e.refreshingFiles:n===`success`?e.filesRefreshed:n===`error`?e.filesRefreshFailed:e.refreshFiles;return(0,V.jsxs)(`div`,{className:`code-files-header ${t?`collapsed`:``}`,children:[(0,V.jsxs)(`div`,{className:`code-files-heading`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`code-files-title`,"aria-expanded":!t,onClick:c,children:[(0,V.jsx)(`span`,{className:`code-file-section-chevron ${t?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:t?(0,V.jsx)(z,{}):(0,V.jsx)(R,{})}),(0,V.jsx)(`span`,{children:e.files})]}),(0,V.jsx)(`button`,{type:`button`,className:`code-files-refresh`,"data-testid":`code-files-refresh`,"data-refresh-status":n,title:l,"aria-label":l,"aria-busy":n===`refreshing`,disabled:n===`refreshing`,onClick:s,children:(0,V.jsx)(`span`,{className:`code-files-refresh-glyph`,"aria-hidden":`true`,children:n===`success`?(0,V.jsx)(ge,{}):n===`error`?(0,V.jsx)(he,{}):`↻`})}),(0,V.jsx)(`span`,{className:`code-visually-hidden`,role:`status`,"aria-live":`polite`,children:n===`idle`?``:l})]}),!t&&(0,V.jsxs)(`label`,{className:`code-file-search-box`,children:[(0,V.jsx)(`span`,{className:`code-file-search-icon`,"aria-hidden":`true`}),(0,V.jsx)(`input`,{ref:r.inputRef,type:`search`,name:`farming-file-search`,inputMode:`search`,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1,enterKeyHint:`search`,"data-lpignore":`true`,"data-1p-ignore":`true`,"data-bwignore":`true`,"data-form-type":`other`,value:r.query,onChange:e=>{i(),o(e.target.value)},onFocus:i,onPointerDown:e=>{i(),b()&&(e.preventDefault(),e.currentTarget.focus({preventScroll:!0}))},onMouseDown:i,onKeyDownCapture:a,placeholder:e.searchOrPathLine,"aria-label":e.searchFilesOrJump,"aria-autocomplete":`list`,"aria-controls":r.active?r.listboxId:void 0,"aria-expanded":r.active,"aria-activedescendant":r.activeOptionId,role:`combobox`})]})]})}var $l=o(),eu=[`#ffb000`,`#dc267f`,`#994f00`,`#40b0a6`,`#b66dff`],tu=`#2188ff`;function nu(e){return{...e}}function ru(e,t){for(let n of e.references??[]){let e=t.get(n.id);if(e!==void 0)return e}}function iu(e,t,n=new Map){let r=-1,i=[];for(let a of e){let o=a.id===t?`HEAD`:`node`,s=(i[i.length-1]?.outputSwimlanes??[]).map(nu),c=[],l=!1;if(a.parentIds.length>0)for(let e of s){if(e.id===a.id){l||=(c.push({id:a.parentIds[0],color:ru(a,n)??e.color}),!0);continue}c.push(nu(e))}for(let t=+!!l;t<a.parentIds.length;t+=1){let i;if(t===0)i=ru(a,n);else{let r=e.find(e=>e.id===a.parentIds[t]);i=r?ru(r,n):void 0}i||=(r=(r+1)%eu.length,eu[r]),c.push({id:a.parentIds[t],color:i})}i.push({historyItem:a,kind:o,inputSwimlanes:s,outputSwimlanes:c})}return i}var au=5,ou=4,su=2,cu=`http://www.w3.org/2000/svg`;function lu(e,t=1){let n=document.createElementNS(cu,`path`);return n.setAttribute(`fill`,`none`),n.setAttribute(`stroke`,e),n.setAttribute(`stroke-width`,String(t)),n.setAttribute(`stroke-linecap`,`round`),n}function uu(e,t,n,r,i=!1){let a=document.createElementNS(cu,`circle`);return a.setAttribute(`cx`,String(11*(e+1))),a.setAttribute(`cy`,`11`),a.setAttribute(`r`,String(t)),a.setAttribute(`stroke`,r),a.setAttribute(`stroke-width`,String(n)),a.setAttribute(`fill`,i?r:`var(--code-git-history-node-bg, #f6f7f3)`),a}function du(e,t,n,r,i=1){let a=lu(r,i);return a.setAttribute(`d`,`M ${e} ${t} V ${n}`),a}function fu(e,t){for(let n=e.length-1;n>=0;--n)if(e[n].id===t)return n;return-1}function pu(e){let t=document.createElementNS(cu,`svg`);t.classList.add(`code-git-history-graph-svg`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let{historyItem:n,inputSwimlanes:r,outputSwimlanes:i}=e,a=r.findIndex(e=>e.id===n.id),o=a===-1?r.length:a,s=o<i.length?i[o].color:o<r.length?r[o].color:tu,c=0;for(let e=0;e<r.length;e+=1){let a=r[e],s=a.color;if(a.id===n.id){if(e!==o){let n=lu(s);n.setAttribute(`d`,[`M ${11*(e+1)} 0`,`A 11 11 0 0 1 ${11*e} 11`,`H ${11*(o+1)}`].join(` `)),t.append(n)}else c+=1;continue}if(c<i.length&&a.id===i[c].id){if(e===c)t.append(du(11*(e+1),0,22,s));else{let n=lu(s);n.setAttribute(`d`,[`M ${11*(e+1)} 0`,`V 6`,`A ${au} ${au} 0 0 1 ${11*(e+1)-au} ${22/2}`,`H ${11*(c+1)+au}`,`A ${au} ${au} 0 0 0 ${11*(c+1)} ${22/2+au}`,`V 22`].join(` `)),t.append(n)}c+=1}}for(let e=1;e<n.parentIds.length;e+=1){let r=fu(i,n.parentIds[e]);if(r===-1)continue;let a=lu(i[r].color);a.setAttribute(`d`,[`M ${11*r} ${22/2}`,`A 11 11 0 0 1 ${11*(r+1)} 22`,`M ${11*r} ${22/2}`,`H ${11*(o+1)}`].join(` `)),t.append(a)}a!==-1&&t.append(du(11*(o+1),0,22/2,r[a].color)),n.parentIds.length>0&&t.append(du(11*(o+1),22/2,22,s)),e.kind===`HEAD`?(t.append(uu(o,ou+3,su,s)),t.append(uu(o,su,1,s,!0))):n.parentIds.length>1?(t.append(uu(o,ou+2,su,s)),t.append(uu(o,ou-1,su,s))):t.append(uu(o,ou+1,su,s));let l=11*(Math.max(r.length,i.length,1)+1);return t.setAttribute(`width`,String(l)),t.setAttribute(`height`,`22`),t.setAttribute(`viewBox`,`0 0 ${l} 22`),t}function mu(e,t=22){let n=document.createElementNS(cu,`svg`);n.classList.add(`code-git-history-graph-placeholder-svg`),n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`focusable`,`false`);for(let r=0;r<e.length;r+=1)n.append(du(11*(r+1),0,t,e[r].color));let r=11*(Math.max(e.length,1)+1);return n.setAttribute(`width`,String(r)),n.setAttribute(`height`,String(t)),n.setAttribute(`viewBox`,`0 0 ${r} ${t}`),n}var hu=(0,B.memo)(function({viewModel:e}){let t=(0,B.useRef)(null);return(0,B.useLayoutEffect)(()=>{let n=t.current;n&&n.replaceChildren(pu(e))},[e]),(0,V.jsx)(`span`,{ref:t,className:`code-git-history-graph`,"aria-hidden":`true`})}),gu=(0,B.memo)(function({columns:e}){let t=(0,B.useRef)(null);return(0,B.useLayoutEffect)(()=>{let n=t.current;if(!n)return;let r=()=>{let t=Math.max(22,Math.round(n.getBoundingClientRect().height));n.replaceChildren(mu(e,t))};if(r(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(r);return i.observe(n),()=>i.disconnect()},[e]),(0,V.jsx)(`span`,{ref:t,className:`code-git-history-graph-placeholder`,"aria-hidden":`true`})}),_u=50,vu=20;function yu(e){if(!e)return``;let t=new Date(e);if(!Number.isFinite(t.getTime()))return``;let n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function bu(e,t){let n=new Set(e.map(e=>e.id));return[...e,...t.filter(e=>!n.has(e.id))]}function xu(e){return e.previousPath?`${e.previousPath} → ${e.path}`:e.path}function Su(e){let t=e.message.trim();return!t||t===e.subject?``:t.startsWith(e.subject)?t.slice(e.subject.length).trim():t}function Cu({agentId:e,copy:t,projectId:n,projectWorkspace:r}){let[a,o]=(0,B.useState)(!0),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(`current`),[f,p]=(0,B.useState)(!1),[m,h]=(0,B.useState)(``),[g,_]=(0,B.useState)(``),[v,y]=(0,B.useState)(``),[b,x]=(0,B.useState)(null),[S,C]=(0,B.useState)(!1),[w,T]=(0,B.useState)(``),[E,D]=(0,B.useState)(null),O=(0,B.useCallback)(()=>D(null),[]),k=(0,B.useRef)(null),A=(0,B.useRef)(null),j=(0,B.useRef)(new Map),M=(0,B.useRef)(null),N=(0,B.useRef)(null),P=(0,B.useCallback)(()=>{A.current?.abort(),A.current=null,_(``),y(``),x(null),C(!1),T(``),D(null)},[]);(0,B.useEffect)(()=>(k.current?.abort(),A.current?.abort(),k.current=null,A.current=null,j.current.clear(),o(!0),l(null),d(`current`),p(!1),h(``),_(``),y(``),x(null),C(!1),T(``),()=>{k.current?.abort(),A.current?.abort()}),[e,n]),s(E!==null,N,M,O);let ee=(0,B.useCallback)(async(t,n,r=u)=>{k.current?.abort();let i=new AbortController;k.current=i,p(!0),h(``);try{let a=await ae(e,{limit:_u,skip:t,scope:r,signal:i.signal});if(i.signal.aborted)return;l(e=>n||!e?a:{...a,items:bu(e.items,a.items)})}catch(e){if(i.signal.aborted)return;h(e instanceof Error?e.message:`Git history request failed`)}finally{k.current===i&&(k.current=null,p(!1))}},[e,u]),ne=(0,B.useCallback)(async(t,n)=>{let r=`${t.id}:${n||`root`}`,i=j.current.get(r);if(A.current?.abort(),i){x(i),C(!1),T(``);return}let a=new AbortController;A.current=a,x(null),C(!0),T(``);try{let i=await te(e,t.id,{parent:n||void 0,signal:a.signal});if(a.signal.aborted)return;if(j.current.set(r,i),j.current.size>vu){let e=j.current.keys().next().value;e&&j.current.delete(e)}x(i)}catch(e){if(a.signal.aborted)return;T(e instanceof Error?e.message:`Commit changes request failed`)}finally{A.current===a&&(A.current=null,C(!1))}},[e]),re=()=>{o(e=>(e&&!c&&!f&&ee(0,!0),!e))},ie=()=>{j.current.clear(),P(),ee(0,!0)},I=e=>{D(null),e!==u&&(d(e),l(null),j.current.clear(),P(),ee(0,!0,e))},oe=()=>{D(e=>{if(e)return null;let t=M.current?.getBoundingClientRect();return t?{x:Math.max(8,Math.min(window.innerWidth-132-8,t.right-132)),y:t.bottom+66+8<=window.innerHeight?t.bottom+3:Math.max(8,t.top-66-3)}:null})},se=e=>{if(g===e.id){P();return}let t=e.parentIds[0]||``;_(e.id),y(t),ne(e,t)},L=(e,t)=>{y(t),ne(e,t)},ce=(e,t,n)=>{if(!t)return;let a=new URLSearchParams({root:r,base:t,head:e.id});n&&a.append(`path`,n),window.open(i(`/review?${a.toString()}`),`_blank`,`noopener,noreferrer`)},le=(0,B.useMemo)(()=>iu(c?.items??[],c?.head),[c?.head,c?.items]);return(0,V.jsxs)(`section`,{className:`code-git-history-section ${a?`collapsed`:``}`,"data-testid":`code-git-history-section`,"data-project-id":n,"aria-label":t.gitHistory,children:[(0,V.jsxs)(`div`,{className:`code-git-history-header`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`code-git-history-title`,"aria-expanded":!a,onClick:re,children:[(0,V.jsx)(`span`,{className:`code-file-section-chevron ${a?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:a?(0,V.jsx)(z,{}):(0,V.jsx)(R,{})}),(0,V.jsx)(`span`,{children:t.gitHistory})]}),!a&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`button`,{ref:M,type:`button`,className:`code-git-history-scope`,"aria-label":t.gitHistoryView,title:t.gitHistoryView,"aria-haspopup":`menu`,"aria-expanded":E?!0:void 0,disabled:f,onClick:oe,children:[(0,V.jsx)(`span`,{children:u===`current`?t.gitHistoryCurrentScope:t.gitHistoryAllScope}),(0,V.jsx)(R,{"aria-hidden":`true`})]}),E&&typeof document<`u`&&(0,$l.createPortal)((0,V.jsx)(`div`,{ref:N,className:`code-git-history-scope-menu`,"data-testid":`code-git-history-scope-menu`,role:`menu`,"aria-label":t.gitHistoryView,style:{left:E.x,top:E.y},children:[[`current`,t.gitHistoryCurrentBranch],[`all`,t.gitHistoryAllBranches]].map(([e,t])=>(0,V.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":u===e,onClick:()=>I(e),children:[(0,V.jsx)(`span`,{className:`code-git-history-scope-check`,"aria-hidden":`true`,children:u===e&&(0,V.jsx)(ge,{})}),(0,V.jsx)(`span`,{children:t})]},e))}),document.body),(0,V.jsx)(`button`,{type:`button`,className:`code-git-history-refresh ${f?`loading`:``}`,title:t.refresh,"aria-label":t.refresh,disabled:f,onClick:ie,children:`↻`})]})]}),!a&&(0,V.jsxs)(`div`,{className:`code-git-history-body`,children:[f&&!c&&(0,V.jsx)(`div`,{className:`code-git-history-status`,children:t.loading}),m&&(0,V.jsx)(`div`,{className:`code-git-history-status error`,children:m}),c&&!c.isGitRepo&&(0,V.jsx)(`div`,{className:`code-git-history-status`,children:t.gitHistoryNotRepository}),c?.isGitRepo&&c.items.length===0&&!f&&(0,V.jsx)(`div`,{className:`code-git-history-status`,children:t.gitHistoryEmpty}),le.map(e=>{let n=e.historyItem,r=g===n.id,i=yu(n.timestamp),a=Su(n),o=n.references.filter(e=>e.category!==`head`&&!(u===`current`&&c?.branch&&e.name===c.branch));return(0,V.jsxs)(`div`,{className:`code-git-history-entry ${r?`selected`:``}`,"data-testid":`code-git-history-entry`,"data-commit-id":n.id,children:[(0,V.jsxs)(`button`,{type:`button`,className:`code-git-history-commit`,"aria-expanded":r,title:`${n.message||n.subject}\n${n.id}\n${n.author}${i?` · ${i}`:``}`,onClick:()=>se(n),children:[(0,V.jsx)(hu,{viewModel:e}),(0,V.jsxs)(`span`,{className:`code-git-history-commit-content`,children:[(0,V.jsx)(`span`,{className:`code-git-history-subject`,children:n.subject||n.displayId}),(0,V.jsxs)(`span`,{className:`code-git-history-footer`,children:[(0,V.jsxs)(`span`,{className:`code-git-history-meta`,children:[(0,V.jsx)(`span`,{className:`code-git-history-hash`,children:n.displayId}),n.author&&(0,V.jsx)(`span`,{children:n.author}),i&&n.timestamp!==void 0&&(0,V.jsx)(`time`,{dateTime:new Date(n.timestamp).toISOString(),children:i})]}),o.length>0&&(0,V.jsxs)(`span`,{className:`code-git-history-references`,"aria-label":o.map(e=>e.name).join(`, `),children:[o.slice(0,1).map(e=>(0,V.jsx)(`span`,{className:`code-git-history-reference ${e.category}`,title:e.name,children:e.name},e.id)),o.length>1&&(0,V.jsxs)(`span`,{className:`code-git-history-reference-more`,children:[`+`,o.length-1]})]})]})]})]}),r&&(0,V.jsxs)(`div`,{className:`code-git-history-details`,"data-testid":`code-git-history-details`,children:[(0,V.jsx)(gu,{columns:e.outputSwimlanes}),(0,V.jsxs)(`div`,{className:`code-git-history-details-content`,children:[(n.parentIds.length>1||n.parentIds.length===0)&&(0,V.jsx)(`div`,{className:`code-git-history-details-header`,children:n.parentIds.length>1?(0,V.jsxs)(`label`,{className:`code-git-history-parent-select`,children:[(0,V.jsx)(`span`,{children:t.gitHistoryParent}),(0,V.jsx)(`select`,{value:v,onChange:e=>L(n,e.target.value),children:n.parentIds.map((e,t)=>(0,V.jsxs)(`option`,{value:e,children:[t+1,`: `,e.slice(0,8)]},e))})]}):(0,V.jsx)(`span`,{className:`code-git-history-root-label`,children:t.gitHistoryRootCommit})}),a&&(0,V.jsxs)(`div`,{className:`code-git-history-message`,children:[(0,V.jsx)(`span`,{className:`code-git-history-message-label`,children:t.gitHistoryCommitMessage}),(0,V.jsx)(`span`,{className:`code-git-history-message-body`,children:a})]}),S&&(0,V.jsx)(`div`,{className:`code-git-history-status compact`,children:t.loading}),w&&(0,V.jsx)(`div`,{className:`code-git-history-status compact error`,children:w}),b&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`code-git-history-change-summary-row`,children:[(0,V.jsx)(`span`,{className:`code-git-history-change-summary`,children:t.gitHistoryCommitChanges(b.items.length)}),b.comparisonBase&&(0,V.jsxs)(`button`,{type:`button`,className:`code-git-history-review`,"aria-label":t.gitHistoryReviewCommit,title:t.gitHistoryReviewCommit,onClick:()=>ce(n,b.comparisonBase),children:[(0,V.jsx)(`span`,{children:t.reviewChanges}),(0,V.jsx)(me,{})]})]}),b.items.length===0&&(0,V.jsx)(`div`,{className:`code-git-history-status compact`,children:t.gitHistoryNoChanges}),(0,V.jsx)(`div`,{className:`code-git-history-change-list`,children:b.items.map(e=>b.comparisonBase?(0,V.jsxs)(`button`,{type:`button`,className:`code-git-history-change`,title:xu(e),onClick:()=>ce(n,b.comparisonBase,e.path),children:[(0,V.jsx)(`img`,{src:F(e.path),alt:``,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`code-git-history-change-path`,children:e.path}),e.previousPath&&(0,V.jsxs)(`span`,{className:`code-git-history-change-previous`,children:[`← `,e.previousPath]}),(0,V.jsx)(`span`,{className:`code-git-history-change-status ${e.status}`,children:e.statusLabel})]},`${e.status}:${e.path}`):(0,V.jsxs)(`div`,{className:`code-git-history-change static`,title:xu(e),children:[(0,V.jsx)(`img`,{src:F(e.path),alt:``,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`code-git-history-change-path`,children:e.path}),(0,V.jsx)(`span`,{className:`code-git-history-change-status ${e.status}`,children:e.statusLabel})]},`${e.status}:${e.path}`))}),b.truncated&&(0,V.jsx)(`div`,{className:`code-git-history-status compact`,children:t.gitHistoryChangesTruncated})]})]})]})]},n.id)}),c?.hasMore&&(0,V.jsx)(`button`,{type:`button`,className:`code-git-history-load-more`,disabled:f||c.nextSkip===null,onClick:()=>{c.nextSkip!==null&&ee(c.nextSkip,!1)},children:f?t.loading:t.gitHistoryLoadMore})]})]})}function wu(e){return e.split(`/`).filter(Boolean).pop()||e}function Tu({activeFilePath:e,collapsed:t,copy:n,files:r,projectId:i,onCloseOpenFile:a,onOpenFileContextMenu:o,onSelectOpenFile:s,onToggleCollapsed:c}){let l=(0,B.useRef)(null),u=(0,B.useRef)(null),d=Math.min(r.length,7),f=(0,B.useMemo)(()=>({"--code-open-editors-visible-rows":d,"--code-open-editors-list-max-height":`${d*28}px`}),[d]);return(0,B.useEffect)(()=>{if(t)return;let e=l.current,n=u.current;if(!e||!n)return;let r=n.offsetTop,i=r+n.offsetHeight;r<e.scrollTop?e.scrollTop=r:i>e.scrollTop+e.clientHeight&&(e.scrollTop=i-e.clientHeight)},[e,t,r.length]),r.length===0?null:(0,V.jsxs)(`div`,{className:`code-open-editors ${t?`collapsed`:``}`,"data-testid":`code-open-editors`,"data-project-id":i,"data-open-editor-count":r.length,"data-visible-editor-count":d,style:f,children:[(0,V.jsx)(`div`,{className:`code-open-editors-header`,children:(0,V.jsxs)(`button`,{type:`button`,className:`code-open-editors-title`,"aria-expanded":!t,onClick:c,children:[(0,V.jsx)(`span`,{className:`code-file-section-chevron ${t?`collapsed`:`expanded`}`,"aria-hidden":`true`,children:t?(0,V.jsx)(z,{}):(0,V.jsx)(R,{})}),(0,V.jsx)(`span`,{children:n.openEditors})]})}),!t&&(0,V.jsx)(`div`,{ref:l,className:`code-open-editors-list`,children:r.map(t=>{let r=e===t.path,i=_e(t);return(0,V.jsxs)(`div`,{ref:r?u:void 0,className:`code-open-editor-row ${r?`active`:``}`,"data-testid":`code-open-editor-row`,"data-file-path":t.path,title:t.path,onContextMenu:e=>{o&&(e.preventDefault(),o(e.clientX,e.clientY,t))},children:[(0,V.jsxs)(`button`,{type:`button`,className:`code-open-editor-main`,onClick:()=>s?.(t.agentId,t.path),children:[(0,V.jsx)(`img`,{className:`code-file-type-icon file`,src:F(t.path),alt:``,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`code-open-editor-name`,children:wu(t.path)}),(0,V.jsx)(`span`,{className:`code-open-editor-path`,children:M(t.path)}),i&&(0,V.jsx)(`span`,{className:`code-open-editor-state ${i}`,title:i===`external`?n.changedOnDisk:n.unsavedChanges})]}),a&&(0,V.jsx)(`button`,{type:`button`,className:`code-open-editor-close`,"aria-label":n.closeFile(t.path),title:n.closeFile(t.path),onClick:()=>a(t.agentId,t.path,t.workspaceRoot)})]},t.key)})})]})}function Eu({activeFilePath:e,activeSearchOptionId:t,agentId:n,agentLaunchOptions:r,copy:i,editorDirtyFilePaths:a,editorExternalChangedFilePaths:o,fileMenu:s,fileMenuRef:c,fileOperation:l,fileOperationInputRef:u,fileSearch:d,fileSearchInputRef:f,fileSearchListboxId:p,fileSearchResultsRef:m,filesCollapsed:h,handleFileSearchKeyDown:g,handleTreeKeyDownCapture:_,lastFocusedFilePathRef:v,locatedFilePath:y,openEditorsCollapsed:b,openFileError:x,openFilePendingPath:S,projectId:C,renderFileTreeRow:w,rootDirectoryError:T,rootDirectoryHasItems:E,rootDirectoryLoading:D,rowHeight:O,readOnly:k=!1,stickyContextItems:A,treeData:j,treeHeight:M,treeRef:N,treeViewportRef:P,visibleTreeRowCount:ee,onCancelPendingFileFocus:te,onCloseFileMenuWithFocusRestore:ne,onCloseFileMenuWithoutFocus:F,onCloseFileOperation:re,onCloseOpenFile:ie,onCopyFileMenuPath:ae,onCopyFileMenuShareUrl:I,onFocusFileTreeTarget:oe,onFocusStickyDirectory:se,onOpenFileContextMenu:L,onOpenFileJumpQuery:ce,onOpenFilePath:le,onOpenFileSearchMatch:ue,onOpenNewAgentFromFileMenu:de,onRefreshFileMenuTarget:fe,onRememberFileOperationName:pe,onSearchQueryChange:me,onSelectOpenFile:he,onSelectSearchMatchIndex:R,onToggleDirectory:ge,onStartAgentFromFileMenu:z,onStartFileMenuOperation:_e,onSubmitFileOperation:ve,onToggleFilesCollapsed:V,onToggleOpenEditorsCollapsed:ye,onToggleTreeNode:be,onTreeFocus:xe,onTreeSelect:Se,onUpdateFileOperationName:Ce}){let we=(0,B.useMemo)(()=>({active:d.active,activeOptionId:t,inputRef:f,listboxId:p,query:d.query}),[t,d.active,d.query,f,p]),Te=(0,B.useMemo)(()=>({active:d.active,activeMatchIndex:d.activeMatchIndex,anchorRef:f,error:d.error,includeIgnored:d.includeIgnored,jumpTarget:d.jumpTarget,listboxId:p,loading:d.loading,matches:d.matches,query:d.query,resultsRef:m,timeoutMs:d.timeoutMs,truncated:d.truncated}),[d.active,d.activeMatchIndex,d.error,d.includeIgnored,f,d.jumpTarget,d.loading,d.matches,d.query,d.timeoutMs,d.truncated,p,m]),Ee=(0,B.useMemo)(()=>({onOpenJumpQuery:ce,onOpenMatch:ue,onSearchIgnored:d.searchIgnored,onSelectMatchIndex:R}),[ce,ue,d.searchIgnored,R]),De=(0,B.useMemo)(()=>({activeFilePath:e,agentId:n,editorDirtyFilePaths:a,editorExternalChangedFilePaths:o,fileOperation:l,fileOperationInputRef:u,handleTreeKeyDownCapture:_,lastFocusedFilePathRef:v,locatedFilePath:y,openFilePendingPath:S,renderFileTreeRow:w,rowHeight:O,stickyContextItems:A,treeData:j,treeHeight:M,treeRef:N,treeViewportRef:P,visibleTreeRowCount:ee,onCancelPendingFileFocus:te,onCloseFileOperation:re,onFocusFileTreeTarget:oe,onFocusStickyDirectory:se,onOpenFileContextMenu:L,onOpenFilePath:le,onRememberFileOperationName:pe,onToggleDirectory:ge,onSubmitFileOperation:ve,onToggleTreeNode:be,onTreeFocus:xe,onTreeSelect:Se,onUpdateFileOperationName:Ce}),[e,n,a,o,l,u,_,v,y,S,w,O,A,j,M,N,P,ee,te,re,oe,se,L,le,pe,ge,ve,be,xe,Se,Ce]);return{bodySearch:Te,bodySearchActions:Ee,bodyTree:De,fileMenu:s,fileMenuRef:c,filesCollapsed:h,headerSearch:we,openEditors:{activeFilePath:e,collapsed:b,copy:i,projectId:C,onCloseOpenFile:ie,onSelectOpenFile:he,onToggleCollapsed:ye},sectionBody:{copy:i,agentLaunchOptions:r,fileMenu:s,fileMenuRef:c,openFileError:x,rootDirectoryError:T,rootDirectoryHasItems:E,rootDirectoryLoading:D,search:Te,searchActions:Ee,tree:De,onCloseFileMenu:F,onCloseFileMenuWithFocusRestore:ne,onCopyFileMenuPath:ae,onCopyFileMenuShareUrl:I,onOpenNewAgentFromFileMenu:de,onRefreshFileMenuTarget:fe,onStartAgentFromFileMenu:z,onStartFileMenuOperation:_e,readOnly:k},sectionHeader:{copy:i,filesCollapsed:h,search:we,onCancelPendingFileFocus:te,onFileSearchKeyDown:g,onSearchQueryChange:me,onToggleFilesCollapsed:V}}}var Du=200,Ou=15e3,ku={error:null,items:[],loaded:!1,loading:!1,truncated:!1};function Au(e,t){let[n,r]=(0,B.useState)(ku),i=(0,B.useRef)(null),a=(0,B.useRef)(0),o=(0,B.useRef)(new Map),s=(0,B.useRef)(t),l=(0,B.useRef)(!1),u=(0,B.useCallback)(()=>{if(!e)return i.current?.abort(),a.current+=1,r(ku),Promise.resolve(!0);i.current?.abort();let t=new AbortController,n=!1,o=window.setTimeout(()=>{n=!0,t.abort()},Ou);i.current=t;let s=a.current+1;return a.current=s,r(e=>({...e,error:null,loading:!0})),le(e,{limit:Du,signal:t.signal}).then(e=>a.current===s?(r({error:null,items:e.items,loaded:!0,loading:!1,truncated:e.truncated}),!0):!1).catch(e=>{if(!n&&t.signal.aborted||a.current!==s)return!1;let i=!c().connected;return i&&(l.current=!0),r(t=>({...t,error:i?null:n?`File refresh timed out`:e instanceof Error?e.message:`Failed to refresh changes`,loaded:!0,loading:i})),!1}).finally(()=>window.clearTimeout(o))},[e]);return(0,B.useEffect)(()=>{s.current=t},[t]),(0,B.useEffect)(()=>{l.current=!1,o.current=O(s.current),u()},[e,u]),(0,B.useEffect)(()=>{let e=o.current,n=O(t);o.current=n,v(e,n)&&u()},[e,t,u]),(0,B.useEffect)(()=>{let e=()=>{l.current&&(l.current=!1,u())};return window.addEventListener(`farming:backend-connected`,e),()=>window.removeEventListener(`farming:backend-connected`,e)},[u]),(0,B.useEffect)(()=>()=>{i.current?.abort(),l.current=!1},[]),{...n,refreshChanges:u}}var ju=50,Mu=60,Nu=6e3,Pu=80,Fu=100,Iu=2;function Lu(e){e?.focus({preventScroll:!0})}function Ru(){let e=document.activeElement;return e instanceof Element&&!!e.closest(`.code-file-monaco, .monaco-editor`)}function zu(e,t){let n=e.getBoundingClientRect(),r=t.closest(`.code-project-group`),i=t.closest(`.code-files-section`),a=[r?.querySelector(`.code-project-row`),r?.querySelector(`.code-agents-section`),r?.querySelector(`[data-testid="code-open-editors"]`),i?.querySelector(`.code-files-header`),i?.querySelector(`.code-file-sticky-stack`)].reduce((e,t)=>{if(!t)return e;let r=t.getBoundingClientRect();return r.height<=0||r.bottom<=n.top||r.top>=n.bottom?e:Math.max(e,r.bottom)},n.top);return{top:Math.min(a,n.bottom),bottom:n.bottom}}function Bu(e,t=!1){let n=e.closest(`.code-project-list`);if(!n)return;let r=zu(n,e),i=e.getBoundingClientRect();n.scrollTop+=t?i.top-r.top-6:Cl(r,i)}function Vu({treeRef:e,treeViewportRef:t,fileSearchInputRef:n,fileOperationActiveRef:r,lastFocusedFilePathRef:i,treeData:a,isDirectoryLoaded:o,loadMissingDirectories:s,openDirectoriesInLayout:c,refreshTreeLayout:l}){let u=(0,B.useRef)(null),d=(0,B.useRef)([]),f=(0,B.useRef)(null),p=(0,B.useRef)([]),m=(0,B.useRef)([]),h=(0,B.useRef)([]),g=(0,B.useRef)([]),_=(0,B.useRef)(0),[v,y]=(0,B.useState)(null),b=(0,B.useRef)(null),x=(0,B.useRef)(a),S=(0,B.useRef)(o);(0,B.useEffect)(()=>{x.current=a},[a]),(0,B.useEffect)(()=>{S.current=o},[o]);let C=(0,B.useCallback)(()=>{y(null),b.current!==null&&(window.clearTimeout(b.current),b.current=null)},[]),w=(0,B.useCallback)(e=>{document.body.classList.contains(`code-file-location-dismissed`)||(C(),y(e),b.current=window.setTimeout(C,Nu))},[C]),T=(0,B.useCallback)(()=>{u.current!==null&&(window.cancelAnimationFrame(u.current),u.current=null),d.current.forEach(e=>window.clearTimeout(e)),d.current=[]},[]),D=(0,B.useCallback)(()=>{f.current!==null&&(window.cancelAnimationFrame(f.current),f.current=null),p.current.forEach(e=>window.clearTimeout(e)),p.current=[]},[]),O=(0,B.useCallback)(()=>{m.current.forEach(e=>window.clearTimeout(e)),m.current=[]},[]),k=(0,B.useCallback)(()=>{_.current+=1,D(),O(),h.current.forEach(e=>window.cancelAnimationFrame(e)),h.current=[],g.current.forEach(e=>window.clearTimeout(e)),g.current=[]},[O,D]),M=(0,B.useCallback)(()=>{T(),k(),C()},[T,k,C]),N=(0,B.useCallback)((i,a=!1,o=!1)=>{D(),O();let s=!1,c=()=>{let e=0,n=0,r=()=>{n+=1;let a=Array.from(t.current?.querySelectorAll(`[data-file-path]`)??[]).find(e=>e.dataset.filePath===i)??null;if(e=a?.classList.contains(`selected`)===!0?e+1:0,a&&e>=Iu){m.current=[],w(i);return}n>=Fu||(m.current=[window.setTimeout(r,Pu)])};r()},l=()=>{let e=n.current,s=wl({focusRow:a,operationActive:r.current,activeElementIsSearchInput:document.activeElement===e,searchInputValue:e?.value}),c=Array.from(t.current?.querySelectorAll(`[data-file-path]`)??[]).find(e=>e.dataset.filePath===i);c&&(c.scrollIntoView({block:`nearest`}),Bu(c,o),s&&Lu(c.closest(`[role="tree"]`)))},u=()=>{let t=e.current;if(a&&!s){s=!0,t?.get(i)?.select();let e=t?.scrollTo(i,o?`start`:`smart`);e&&e.then(()=>{window.requestAnimationFrame(l)})}l()};u(),f.current=window.requestAnimationFrame(()=>{u(),f.current=window.requestAnimationFrame(u)}),xl.forEach(e=>{let t=window.setTimeout(u,e);p.current.push(t)}),o&&c()},[O,D,r,n,w,e,t]),P=(0,B.useCallback)((t,n=0,r=!1,i)=>{let a=i??_.current+1;i===void 0&&(_.current=a);let o=()=>_.current===a,s=e.current,u=x.current,d=j(u,t,r),f=A(u,t)??t,p=I(u,f),m=!!s;if(c(d),r&&(p?.type!==`directory`||!S.current(t))&&(m=!1),s&&(d.forEach(e=>{s.get(e)?s.open(e):m=!1}),r&&s.get(f)&&s.open(f),s.get(f)||(m=!1)),!m&&n<Mu){let e=window.setTimeout(()=>{g.current=g.current.filter(t=>t!==e),o()&&P(t,n+1,r,a)},ju);g.current.push(e);return}(e=>{let t=window.requestAnimationFrame(()=>{h.current=h.current.filter(e=>e!==t),o()&&e()});h.current.push(t)})(()=>{o()&&(d.forEach(t=>e.current?.open(t)),l(d),N(f,!0,r))})},[c,l,N,e]),ee=(0,B.useCallback)(async e=>{await s([``,...E(e)]),P(e)},[s,P]),te=(0,B.useCallback)(async(e,t)=>{t===`directory`&&(document.body.classList.remove(`code-file-location-dismissed`),C()),await s([``,...E(e),...t===`directory`&&e?[e]:[]]),P(e,0,t===`directory`)},[C,s,P]),ne=(0,B.useCallback)(()=>{M();let e=(e=!1)=>{let t=n.current;t&&(Tl({activeElementIsSearchInput:document.activeElement===t,searchInputValue:t.value})||(t.focus(),El({requestedSelect:e,searchInputValue:t.value})&&t.select()))};e(!0),u.current=window.requestAnimationFrame(()=>e(!1)),bl.forEach(t=>{let n=window.setTimeout(()=>e(!1),t);d.current.push(n)})},[M,n]),F=(0,B.useCallback)(()=>{M();let r=()=>{if(n.current?.value)return;n.current?.blur();let r=t.current?.querySelector(`[role="tree"]`),a=Array.from(t.current?.querySelectorAll(`[data-file-path]`)??[]),o=Ol({lastFocusedPath:i.current,rows:a.map(e=>({path:e.dataset.filePath??``,selected:e.classList.contains(`selected`)})).filter(e=>e.path)});if(o&&a.find(e=>e.dataset.filePath===o)&&o){i.current=o,e.current?.get(o)?.select(),Lu(r);return}Lu(r)};r(),f.current=window.requestAnimationFrame(r),xl.forEach(e=>{let t=window.setTimeout(r,e);p.current.push(t)})},[M,n,i,e,t]),re=(0,B.useCallback)(n=>{D();let r=()=>{let r=Ru();if(n){e.current?.get(n)?.select();let i=Array.from(t.current?.querySelectorAll(`[data-file-path]`)??[]).find(e=>e.dataset.filePath===n),a=i?.closest(`[role="tree"]`)??t.current?.querySelector(`[role="tree"]`);if(r||Lu(a),i){i.scrollIntoView({block:`nearest`}),Bu(i);return}}r||Lu(t.current?.querySelector(`[role="tree"]`))};r(),f.current=window.requestAnimationFrame(()=>{f.current=null,r()}),[80,180,360].forEach(e=>{let t=window.setTimeout(r,e);p.current.push(t)})},[D,e,t]),ie=(0,B.useCallback)(e=>{re(e?.path??null)},[re]);return(0,B.useEffect)(()=>{if(!v)return;let e=e=>{let t=e.target;(t instanceof Element?t.closest(`[data-file-path]`):null)?.dataset.filePath!==v&&(document.body.classList.add(`code-file-location-dismissed`),C())};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`keydown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`keydown`,e,!0)}},[C,v]),(0,B.useEffect)(()=>()=>{M(),C()},[M,C]),{cancelPendingFileFocus:M,focusFileSearchInput:ne,focusFileTreeFromSearch:F,focusFileTreePath:re,focusFileTreeTarget:ie,locatedFilePath:v,revealExplorerPath:te,revealFilePath:ee}}var Hu=15e3;function Uu(e){return e.replace(/^\/+|\/+$/g,``)}function Wu(e,t=e){let[n,r]=(0,B.useState)({}),i=(0,B.useRef)({}),a=(0,B.useRef)(new Map),o=(0,B.useRef)(new Map),s=(0,B.useRef)(new Set),l=(0,B.useRef)(0),u=(0,B.useCallback)((t=``)=>{if(!e)return Promise.resolve(null);let n=Uu(t),i=a.current.get(n);if(i)return i;let d=l.current;r(e=>({...e,[n]:{items:e[n]?.items??[],loading:!0,error:null}}));let f=null;return f=(async()=>{let t=new AbortController,i=!1,p=window.setTimeout(()=>{i=!0,t.abort()},Hu);try{let i=await C(e,n,{signal:t.signal});if(l.current!==d)return null;if(r(e=>({...e,[n]:{items:i.items,loading:!1,error:null,gitStatusPending:i.gitStatusPending}})),i.gitStatusPending&&!o.current.has(n)){let e=window.setTimeout(()=>{o.current.delete(n),u(n)},2e3);o.current.set(n,e)}return i}catch(e){if(l.current!==d)return null;let t=!c().connected;return t&&s.current.add(n),r(r=>({...r,[n]:{items:r[n]?.items??[],loading:t,error:t?null:i?`File refresh timed out`:e instanceof Error?e.message:`Failed to load directory`}})),null}finally{window.clearTimeout(p),f&&a.current.get(n)===f&&a.current.delete(n)}})(),a.current.set(n,f),f},[e]),d=(0,B.useCallback)(e=>{let t=Uu(e),n=i.current[t];return!n||n.loading||n.error?u(t):Promise.resolve({path:t,items:n.items,gitStatusPending:n.gitStatusPending})},[u]);return(0,B.useEffect)(()=>{i.current=n},[n]),(0,B.useEffect)(()=>{l.current+=1,a.current.clear(),s.current.clear(),o.current.forEach(e=>window.clearTimeout(e)),o.current.clear()},[e,t]),(0,B.useEffect)(()=>{r({}),i.current={}},[e,t]),(0,B.useEffect)(()=>()=>{a.current.clear(),o.current.forEach(e=>window.clearTimeout(e)),o.current.clear()},[]),(0,B.useEffect)(()=>{let e=()=>{let e=Array.from(s.current);s.current.clear(),e.forEach(e=>{u(e)})};return window.addEventListener(`farming:backend-connected`,e),()=>window.removeEventListener(`farming:backend-connected`,e)},[u]),(0,B.useMemo)(()=>({directories:n,loadDirectory:u,ensureDirectoryLoaded:d}),[n,d,u])}var Gu=12,Ku=6;function qu(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function Ju(e){return e.split(`/`).filter(Boolean).length}function Yu(e,t=e){let n=t||``,{directories:r,loadDirectory:i,ensureDirectoryLoaded:a}=Wu(e,t),[o,s]=(0,B.useState)(()=>new Set(p(n).openDirectoryPaths??[])),c=(0,B.useRef)(o),l=(0,B.useRef)(n),u=(0,B.useRef)(new Map),d=(0,B.useRef)(``),m=(0,B.useMemo)(()=>ee(r[``]?.items??[],r),[r]),h=(0,B.useMemo)(()=>Math.max(1,ue(m,o)),[o,m]),g=(0,B.useCallback)((e,t)=>{let n=c.current;if(n.has(e)===t)return;let r=new Set(n);t?r.add(e):r.delete(e),c.current=r,s(r)},[]),_=(0,B.useCallback)(e=>c.current.has(e),[]),v=(0,B.useCallback)(e=>{if(e.length===0)return;let t=new Set(c.current),n=!1;e.forEach(e=>{!e||t.has(e)||(t.add(e),n=!0)}),n&&(c.current=t,s(t))},[]),y=(0,B.useCallback)(()=>i(``),[i]),b=(0,B.useCallback)(e=>{let t=e.filter(e=>!r[e]);return Promise.all(t.map(e=>i(e)))},[r,i]),x=(0,B.useCallback)(e=>{let t=r[e];return!!(t&&!t.loading&&!t.error)},[r]),S=(0,B.useCallback)(e=>{let t=new Set([``]);e.forEach(e=>{let n=String(e??``).replace(/^\/+|\/+$/g,``);for(t.add(n);n;)n=qu(n),t.add(n)});let n=Array.from(t).sort((e,t)=>Ju(e)-Ju(t)||e.localeCompare(t));return(async()=>{let e=new Map,t=new Set,r=!0,a=0;for(;a<n.length;){let o=Ju(n[a]),s=[];for(;a<n.length&&Ju(n[a])===o;)s.push(n[a]),a+=1;let c=s.filter(n=>{if(!n)return!0;if(Array.from(t).some(e=>n===e||n.startsWith(`${e}/`)))return!1;let i=qu(n),a=e.get(i);return a===null?(r=!1,!1):a&&!a.items.some(e=>e.type===`directory`&&e.path===n)?(t.add(n),!1):!0}),l=0,u=Array.from({length:Math.min(Ku,c.length)},async()=>{for(;l<c.length;){let t=c[l];l+=1;let n=await i(t);e.set(t,n),n||(r=!1)}});await Promise.all(u)}if(t.size>0){let e=Array.from(t),n=new Set(Array.from(c.current).filter(t=>!e.some(e=>t===e||t.startsWith(`${e}/`))));c.current=n,s(n)}return r})()},[i]),C=(0,B.useCallback)(e=>{let t=u.current.get(e);if(t)return t;let n;return n=(async()=>{let t=e;for(let e=0;e<Gu;e+=1){let e=await a(t),n=e?.items.length===1&&e.items[0]?.type===`directory`?e.items[0]:null;if(!n)return;t=n.path}})().finally(()=>{u.current.get(e)===n&&u.current.delete(e)}),u.current.set(e,n),n},[a]);return(0,B.useEffect)(()=>{u.current.clear()},[e]),(0,B.useEffect)(()=>{l.current===n&&f(n,{openDirectoryPaths:Array.from(o)})},[n,o]),(0,B.useEffect)(()=>{if(l.current===n)return;l.current=n,d.current=``;let e=p(n).openDirectoryPaths??[],t=new Set(e);c.current=t,s(t)},[n]),(0,B.useEffect)(()=>{if(o.size===0)return;let e=`${n}:${Array.from(o).join(`
|
|
12
|
+
`)}`;d.current!==e&&(d.current=e,y(),b(Array.from(o)))},[b,y,n,o]),(0,B.useMemo)(()=>({directories:r,treeData:m,openDirectoryPaths:o,visibleTreeRowCount:h,loadRootDirectory:y,ensureDirectoryLoaded:a,isDirectoryLoaded:x,loadMissingDirectories:b,refreshDirectories:S,hydrateCompactDirectoryChains:C,isDirectoryOpen:_,setDirectoryOpen:g,openDirectoriesInLayout:v}),[r,a,C,_,x,b,y,v,o,S,g,m,h])}function Xu({agentId:e,agentLaunchOptionCount:t=0,cancelPendingFileFocus:n,clearFileOperation:r,focusFileTreeTarget:a,refreshDirectories:o,projectWorkspace:s,shareLinkFailed:c,setOpenFileError:u,startFileOperation:d}){let f=(0,B.useRef)(null),[p,h]=(0,B.useState)(null),g=(0,B.useCallback)(()=>{h(null)},[]),_=(0,B.useCallback)((e,i,a)=>{n(),u(null),r(),h({...dt(e,i,a,window.innerWidth,window.innerHeight,t),item:a})},[t,n,r,u]),v=(0,B.useCallback)((e=!1)=>{let t=p?.item??null;h(null),e&&a(t)},[p?.item,a]),y=(0,B.useCallback)(()=>{v(!1)},[v]),b=(0,B.useCallback)(()=>{v(!0)},[v]),x=(0,B.useCallback)((e,t=p?.item??null)=>{n(),h(null),d(e,t)},[n,p?.item,d]),S=(0,B.useCallback)(()=>{e&&(o([rt(p?.item??null)]),h(null))},[e,p?.item,o]);return{fileMenu:p,fileMenuRef:f,clearFileMenu:g,closeFileMenuWithFocusRestore:b,closeFileMenuWithoutFocus:y,copyFileMenuPath:(0,B.useCallback)(async()=>{let e=p?.item;if(e){h(null),u(null);try{await navigator.clipboard?.writeText(e.path)}catch{u(`Copy failed`)}}},[p?.item,u]),copyFileMenuShareUrl:(0,B.useCallback)(async()=>{let t=p?.item;if(!(!e||!t||t.type!==`file`&&t.type!==`directory`)){h(null),u(null);try{let n=t.type===`directory`?{kind:`folder`,agentId:e,folderPath:t.path,absolutePath:m(s,t.path),projectLabel:l(s)}:{kind:`file`,agentId:e,filePath:t.path,absolutePath:m(s,t.path),projectLabel:l(s)},r=await fetch(i(`/api/share/qr-ticket`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target:n})}),a=await r.json();if(!r.ok||!a.longUrl||!await pe(a.longUrl))throw Error(a.error||c)}catch(e){u(e instanceof Error?e.message:c)}}},[e,p?.item,s,u,c]),fileMenuTargetDirectory:(0,B.useCallback)((e=p?.item??null)=>rt(e),[p?.item]),openFileContextMenu:_,refreshFileMenuTarget:S,startFileMenuOperation:x}}var Zu=220;function Qu({agentId:e,onClearSearch:t,onOpenFile:n,onRevealFilePath:r,onSelectOpenFile:i}){let a=(0,B.useRef)(0),o=(0,B.useRef)({agentId:e,mounted:!0}),s=(0,B.useRef)(null),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(null);o.current.agentId=e;let f=(0,B.useCallback)(()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null),d(null)},[]),p=(0,B.useCallback)((e,t,n)=>{f(),s.current=window.setTimeout(()=>{a.current===e&&o.current.agentId===t&&o.current.mounted&&d(n),s.current=null},Zu)},[f]);return(0,B.useEffect)(()=>(o.current.mounted=!0,()=>{o.current.mounted=!1,a.current+=1,s.current!==null&&(window.clearTimeout(s.current),s.current=null)}),[]),(0,B.useEffect)(()=>{a.current+=1,f(),l(null)},[e,f]),{openFileError:c,openFilePendingPath:u,openFilePath:(0,B.useCallback)(async(s,c)=>{if(!e)return;let u=e,d=a.current+1;if(a.current=d,l(null),i?.(e,s,c)){f(),t(),oe(c)&&r(s);return}p(d,u,s);try{let e=await k(u,s);if(a.current!==d||o.current.agentId!==u||!o.current.mounted)return;f(),n(u,e,c),t(),oe(c)&&r(s)}catch(e){if(a.current!==d||o.current.agentId!==u||!o.current.mounted)return;if(f(),c&&e instanceof se&&e.status===404&&_(c)){n(u,g(s,c),c),t();return}l(e instanceof Error?e.message:`Failed to open file`)}},[e,f,t,n,r,i,p]),setOpenFileError:l}}var $u=15e3;async function ed(e){let t=new AbortController,n=!1,r=window.setTimeout(()=>{n=!0,t.abort()},$u);try{return await e(t.signal)}catch(e){if(n){let e=Error(`File operation timed out`);throw e.name=`TimeoutError`,e}throw e}finally{window.clearTimeout(r)}}function td({agentId:e,fileOperationActiveRef:t,ensureDirectoryLoaded:n,focusFileTreePath:r,onDeleteEntries:i,onMoveEntries:a,onOpenFile:o,onWorkspaceChange:s,refreshDirectories:c,setOpenFileError:l}){let u=(0,B.useRef)(null),d=(0,B.useRef)(``),f=(0,B.useRef)(0),p=(0,B.useRef)(null),[m,h]=(0,B.useState)(null),g=(0,B.useCallback)(()=>{p.current=null,t.current=!1,h(null)},[]),_=(0,B.useCallback)(e=>{let t=p.current;return t?.generation===e.generation&&t.rootId===e.rootId},[]),v=(0,B.useCallback)(e=>_(e)?(p.current=null,t.current=!1,h(e=>p.current===null?null:e),!0):!1,[_]),y=(0,B.useCallback)(e=>{if(!_(e))return!1;let t={...e,generation:f.current+1,operation:{...e.operation,submitting:!1},submitted:!1};return f.current=t.generation,p.current=t,h(e=>p.current===t?t.operation:e),!0},[_]),b=(0,B.useCallback)((n,r)=>{if(!e||r?.readOnly&&!(r.symbolicLink&&(n===`rename`||n===`delete`)))return;let i=at(n,r),a=f.current+1;f.current=a,p.current={generation:a,operation:i,rootId:e,submitted:!1},d.current=i.name,t.current=!0,l(null),h(i)},[e,l]),x=(0,B.useCallback)(()=>{let e=p.current;e&&v(e)&&r(e.operation.item?.path??null)},[v,r]),S=(0,B.useCallback)(e=>{d.current=e;let t=p.current;t&&!t.submitted&&(t.operation={...t.operation,name:e})},[]),T=(0,B.useCallback)(e=>{d.current=e;let t=p.current;t&&!t.submitted&&(t.operation={...t.operation,name:e}),h(t=>t&&{...t,name:e})},[]),E=(0,B.useCallback)(async()=>{let t=p.current;if(!e||!t||t.rootId!==e||t.submitted)return;let u=t.operation.kind===`delete`?t.operation:{...t.operation,name:d.current},f=U(u);if(!(u.kind!==`delete`&&!f)){t.operation={...u,submitting:!0},t.submitted=!0,h(e=>_(t)?t.operation:e),l(null);try{if(u.kind===`new-file`||u.kind===`new-folder`){let e=await ed(e=>N(t.rootId,u.parentPath,f,u.kind===`new-folder`?`directory`:`file`,{signal:e}));c([u.parentPath]),s?.(),_(t)&&(e.entry.type===`directory`&&(n(e.entry.path),r(e.entry.path)),e.file&&o(t.rootId,e.file),v(t));return}if(u.kind===`rename`&&u.item){let e=u.item,n=await ed(n=>fe(t.rootId,e.path,f,e.version,{signal:n}));c(L(n)),a(t.rootId,[n]),s?.(),v(t)&&r(ie(n));return}if(u.kind===`delete`&&u.item){let e=u.item,n=await ed(n=>re(t.rootId,e.path,e.version,{signal:n}));c(w(n)),i(t.rootId,[n]),s?.(),v(t)&&r(P(n))}}catch(e){let d=u.kind===`new-file`||u.kind===`new-folder`?[u.parentPath]:u.item?[u.item.path.includes(`/`)?u.item.path.slice(0,u.item.path.lastIndexOf(`/`)):``]:[],p=!(e instanceof se)||e.status>=500;if(p&&(u.kind===`new-file`||u.kind===`new-folder`))try{let e=ct(u,f,(await ed(e=>C(t.rootId,u.parentPath,{signal:e}))).items);if(e){if(c([u.parentPath]),s?.(),e.type===`directory`&&_(t))n(e.path),r(e.path),v(t);else if(e.type===`file`&&_(t)){r(e.path);try{let n=await ed(n=>k(t.rootId,e.path,{signal:n}));_(t)&&o(t.rootId,n)}catch{}v(t)}return}}catch{}if(p&&u.item&&(u.kind===`rename`||u.kind===`delete`))try{let e=d[0]??``,n=await ed(n=>C(t.rootId,e,{signal:n}));if(u.kind===`rename`){let e=lt(u,f,n.items);if(e){c(L(e)),a(t.rootId,[e]),s?.(),v(t)&&r(ie(e));return}}if(u.kind===`delete`){let e=st(u,n.items);if(e){c(w(e)),i(t.rootId,[e]),s?.(),v(t)&&r(P(e));return}}}catch{}d.length>0&&(c(d),s?.()),y(t)&&l(e instanceof Error?e.message:`File operation failed`)}}},[e,v,n,r,_,i,a,o,s,c,y,l]);return(0,B.useLayoutEffect)(()=>{let t=p.current;t&&t.rootId!==e&&g()},[e,g]),(0,B.useLayoutEffect)(()=>()=>{p.current=null,t.current=!1},[]),(0,B.useEffect)(()=>{if(!m)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),x())};return document.addEventListener(`keydown`,e,!0),()=>{document.removeEventListener(`keydown`,e,!0)}},[x,m]),{fileOperation:m,fileOperationActiveRef:t,fileOperationInputRef:u,clearFileOperation:g,closeFileOperation:x,rememberFileOperationName:S,startFileOperation:b,submitFileOperation:E,updateFileOperationName:T}}var nd=3e3;function rd(e){let[t,n]=(0,B.useState)(``),[r,i]=(0,B.useState)([]),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(0),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(nd),[h,g]=(0,B.useState)(!1),_=(0,B.useRef)(0),v=t.trim().length>0,y=(0,B.useMemo)(()=>v?De(t):null,[v,t]),b=r.length>0?Math.min(l,r.length-1):-1,x=b>=0?r[b]??null:null,S=(0,B.useCallback)(()=>{_.current+=1,n(``),i([]),c(null),u(0),f(!1),m(nd),g(!1),o(!1)},[]),C=(0,B.useCallback)(e=>{g(!1),n(e)},[]),w=(0,B.useCallback)(()=>{g(!0)},[]),T=(0,B.useCallback)(()=>{r.length!==0&&u(e=>Math.min(e+1,r.length-1))},[r.length]),E=(0,B.useCallback)(()=>{r.length!==0&&u(e=>Math.max(e-1,0))},[r.length]),D=(0,B.useCallback)(e=>{u(Math.max(0,Math.min(e,Math.max(r.length-1,0))))},[r.length]);return(0,B.useEffect)(()=>{let n=t.trim(),r=_.current+1;if(_.current=r,u(0),!e||!n||De(n)){i([]),o(!1),c(null),f(!1);return}o(!0),c(null);let a=new AbortController,s=window.setTimeout(()=>{de(e,n,{includeIgnored:h,limit:60,signal:a.signal}).then(e=>{_.current===r&&(i(e.matches),f(e.truncated),m(e.timeoutMs??nd),o(!1))}).catch(e=>{_.current===r&&(e instanceof DOMException&&e.name===`AbortError`||(i([]),f(!1),c(e instanceof Error?e.message:`Search failed`),o(!1)))})},180);return()=>{window.clearTimeout(s),a.abort()}},[e,h,t]),(0,B.useEffect)(()=>{u(e=>Math.min(e,Math.max(r.length-1,0)))},[r.length]),(0,B.useMemo)(()=>({query:t,setQuery:C,matches:r,loading:a,error:s,selectMatchIndex:D,truncated:d,timeoutMs:p,includeIgnored:h,active:v,jumpTarget:y,activeMatchIndex:b,selectedMatch:x,clear:S,searchIgnored:w,selectNext:T,selectPrevious:E}),[v,b,S,s,y,a,r,h,w,t,D,T,E,x,d,p])}function id({fileMenuOpen:e,fileOperationActive:t,fileSearch:n,fileSearchResultsRef:r,filesCollapsed:i,focusFileTreeFromSearch:a,listboxId:o,onOpenFilePath:s,onRevealDirectoryPath:c}){let l=je({active:n.active,activeMatchIndex:n.activeMatchIndex,jumpTarget:n.jumpTarget,listboxId:o}),u=(0,B.useCallback)(e=>{if(e.kind===`path`&&e.entryType===`directory`){c(e.path),n.clear();return}let t=ke(e);s(t.path,t.target),n.clear()},[n,s,c]),d=(0,B.useCallback)(e=>{let t=Ae(e);return t?(s(t.path,t.target),n.clear(),!0):!1},[n,s]),f=(0,B.useCallback)(e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),n.clear(),a();return}if(e.key===`ArrowDown`){if(n.matches.length===0)return;e.preventDefault(),n.selectNext();return}if(e.key===`ArrowUp`){if(n.matches.length===0)return;e.preventDefault(),n.selectPrevious();return}if(e.key!==`Enter`||(e.preventDefault(),e.stopPropagation(),d(e.currentTarget.value)))return;let t=n.selectedMatch??n.matches[0];t&&u(t)},[n,a,d,u]);return(0,B.useEffect)(()=>{if(!n.active||n.matches.length===0)return;let e=r.current,t=e?.querySelector(`.code-file-search-result.active`);if(!e||!t)return;let i=t.offsetTop,a=i+t.offsetHeight;i<e.scrollTop?e.scrollTop=i:a>e.scrollTop+e.clientHeight&&(e.scrollTop=a-e.clientHeight)},[n.active,n.activeMatchIndex,n.matches.length,r]),(0,B.useEffect)(()=>{if(i||!n.active||e||t)return;let r=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n.clear(),a())};return document.addEventListener(`keydown`,r,!0),()=>{document.removeEventListener(`keydown`,r,!0)}},[e,t,n,i,a]),{activeOptionId:l,handleFileSearchKeyDown:f,openFileJumpQuery:d,openFileSearchMatch:u}}function ad({agentId:e,workspaceKey:t,clearFileMenu:n,clearFileOperation:r,clearFileSearch:i,focusFileSearchInput:a,focusSearchRequest:o,loadRootDirectory:s,openFilesCount:c,refreshTreeLayout:l,revealExplorerPath:u,revealRequest:d,rootDirectoryLoaded:m,setFileSearchQuery:h,setOpenFileError:g,treeData:_}){let[v,y]=(0,B.useState)(()=>p(t).filesCollapsed??!0),[b,x]=(0,B.useState)(!0),S=(0,B.useRef)(null),C=(0,B.useRef)(t),w=(0,B.useCallback)(()=>{let e=!v;e?(n(),r(),i()):m||s(),y(e)},[n,r,i,v,s,m]),T=(0,B.useCallback)(()=>{x(e=>!e)},[]);return(0,B.useEffect)(()=>{g(null),n(),r(),i()},[e,n,r,i,g]),(0,B.useEffect)(()=>{if(d){if(y(!1),!m){s();return}S.current!==d.requestId&&(S.current=d.requestId,u(d.path,d.kind))}},[s,u,d,m]),(0,B.useEffect)(()=>{o&&(y(!1),m||s(),typeof o.query==`string`&&h(o.query),a())},[a,o,s,m,h]),(0,B.useEffect)(()=>{c===0&&x(!0)},[c]),(0,B.useEffect)(()=>{C.current===t&&f(t,{filesCollapsed:v})},[v,t]),(0,B.useEffect)(()=>{C.current!==t&&(C.current=t,y(p(t).filesCollapsed??!0))},[t]),(0,B.useEffect)(()=>{!v&&!m&&s()},[v,s,m]),(0,B.useEffect)(()=>{v||l()},[v,l,_]),{filesCollapsed:v,openEditorsCollapsed:b,toggleFilesCollapsed:w,toggleOpenEditorsCollapsed:T}}var od=8,sd=4;function cd(e,t){let n=t.closest(`.code-project-group`),r=n?.querySelector(`.code-project-row`),i=n?.querySelector(`.code-agents-section`),a=n?.querySelector(`[data-testid="code-open-editors"]`);return Fl(e.getBoundingClientRect().top,r?.getBoundingClientRect().height??30,(i?.getBoundingClientRect().height??0)+(a?.getBoundingClientRect().height??0),25)}function ld({filesCollapsed:e,focusFileTreePath:t,lastFocusedFilePathRef:n,openDirectoryPaths:r,refreshTreeLayout:i,resetKey:a,treeData:o,treeViewportRef:s}){let[c,l]=(0,B.useState)([]),[u,d]=(0,B.useState)(!1),f=(0,B.useMemo)(()=>c.map(e=>I(o,e)).filter(e=>!!e),[c,o]),p=(0,B.useMemo)(()=>Bl({visible:u,directoryNodes:f}),[u,f]),m=(0,B.useCallback)(()=>{l(e=>e.length===0?e:[]),d(!1)},[]),h=(0,B.useCallback)(()=>{let t=s.current,n=t?.closest(`.code-project-list`);if(!t||!n||e){m();return}let r=n.getBoundingClientRect(),i=cd(n,t),a=t.getBoundingClientRect(),o=Array.from(t.querySelectorAll(`[data-file-path]`)),c=o.flatMap(e=>{let t=e.dataset.filePath;if(!t)return[];let n=e.getBoundingClientRect();return[{path:t,top:n.top,bottom:n.bottom}]});if(!Ll(c,i,r.bottom)){m();return}d(Il(a.top,i));let u=Math.max(1,o[0]?.getBoundingClientRect().height??24),f=Math.floor(Math.max(0,r.bottom-i)/u),p=Math.min(od,Math.max(1,f-sd)),h=zl({rows:c,stickyTop:i,scrollerBottom:r.bottom,rowHeight:u,maxRows:p});l(e=>e.length===h.length&&e.every((e,t)=>e===h[t])?e:h)},[m,e,s]),g=(0,B.useCallback)(e=>{n.current=e.path,t(e.path)},[t,n]);return(0,B.useEffect)(()=>{m()},[m,a]),(0,B.useEffect)(()=>{if(e){m();return}i();let t=window.requestAnimationFrame(()=>i()),n=window.setTimeout(i,80),r=window.setTimeout(i,180);return()=>{window.cancelAnimationFrame(t),window.clearTimeout(n),window.clearTimeout(r)}},[m,e,r,i,o]),(0,B.useLayoutEffect)(()=>{if(e)return;let t=s.current?.closest(`.code-project-list`),n=0,r=()=>{n||=window.requestAnimationFrame(()=>{n=0,(0,$l.flushSync)(h)})};return h(),window.setTimeout(h,80),t?.addEventListener(`scroll`,r,{passive:!0}),window.addEventListener(`resize`,r),()=>{n&&window.cancelAnimationFrame(n),t?.removeEventListener(`scroll`,r),window.removeEventListener(`resize`,r)}},[e,r,h,o,s]),{focusStickyDirectory:g,stickyContextItems:p}}function ud({rowHeight:e,visibleTreeRowCount:t,openDirectoryPaths:n,treeData:r,hydrateCompactDirectoryChains:i,isDirectoryOpen:a,setDirectoryOpen:o}){let s=(0,B.useRef)(void 0),c=(0,B.useRef)(null),l=(0,B.useRef)(null),u=(0,B.useRef)(new Set),d=(0,B.useRef)(new Set),f=Math.max(e,t*e),p=(0,B.useCallback)(e=>{if(e.length===0)return!1;let t=s.current;if(!t)return!1;let n=!1;return e.forEach(e=>{!e||!t.get(e)||u.current.has(e)||t.isOpen(e)||(t.open(e,!1),n=!0)}),n},[]),m=(0,B.useCallback)((e=[])=>{let t=()=>{p(e),s.current?.redrawList()};t(),window.requestAnimationFrame(t),window.setTimeout(t,80)},[p]),h=(0,B.useCallback)((e,t)=>{t?(u.current.delete(e),d.current.delete(e)):(u.current.add(e),d.current.delete(e)),o(e,t)},[o]),g=(0,B.useCallback)(e=>{let t=!a(e);return h(e,t),t},[a,h]);(0,B.useEffect)(()=>{u.current.forEach(e=>{if(!n.has(e)){d.current.add(e);return}d.current.has(e)&&(u.current.delete(e),d.current.delete(e))})},[n]),(0,B.useEffect)(()=>{let e=Array.from(n);if(e.length===0)return;let t=()=>{p(e)&&s.current?.redrawList()};t();let r=window.requestAnimationFrame(t),i=window.setTimeout(t,80),a=window.setTimeout(t,180);return()=>{window.cancelAnimationFrame(r),window.clearTimeout(i),window.clearTimeout(a)}},[n,p,r]);let _=(0,B.useCallback)(({attrs:e,innerRef:t,children:n})=>{let{style:r,className:i,...a}=e;return(0,B.createElement)(`div`,{...a,ref:t,style:{...r,minWidth:`100%`,width:`100%`},className:`code-file-tree-row-frame ${i??``}`.trim()},n)},[]);return{treeRef:s,treeViewportRef:c,lastFocusedFilePathRef:l,treeHeight:f,handleTreeToggle:(0,B.useCallback)(e=>{Hl(c.current?.closest(`.code-project-list`)),a(e)?i(e).finally(()=>m([e])):m()},[i,a,m]),refreshTreeLayout:m,rememberFocusedTreeNode:(0,B.useCallback)(e=>{e&&(l.current=e.data.path)},[]),rememberSelectedTreeNodes:(0,B.useCallback)(e=>{let t=e[e.length-1];t&&(l.current=t.data.path)},[]),renderFileTreeRow:_,setTreePathOpen:h,toggleTreePathOpen:g}}function dd({treeRef:e,treeViewportRef:t,lastFocusedFilePathRef:n,fileOperation:r,openDirectoryPaths:i,cancelPendingFileFocus:a,closeFileOperation:o,focusFileSearchInput:s,focusFileTreePath:c,focusFileTreeTarget:l,openFileContextMenu:u,openFilePath:d,setDirectoryOpen:f,startFileOperation:p,toggleDirectoryOpen:m}){let h=(0,B.useCallback)(()=>t.current?.closest(`.code-project-list`)??null,[t]),g=(0,B.useCallback)(()=>{let e=t.current,n=(e?.querySelector(`[data-file-path]`))?.getBoundingClientRect().height||24;return Al((h()??e)?.getBoundingClientRect().height??n,n)},[h,t]),_=(0,B.useCallback)((e,t=!0)=>{Hl(h()),t&&f(e.data.path,!0),e.open(),n.current=e.data.path,l(e.data)},[l,n,h,f]),v=(0,B.useCallback)((t,r,i=!0)=>{Hl(h()),i&&f(t,!1),r?r.close():e.current?.close(t),n.current=t,r?l(r.data):c(t)},[c,l,n,h,f,e]),y=(0,B.useCallback)(c=>{if(c.defaultPrevented||c.altKey)return;if((c.ctrlKey||c.metaKey)&&!c.shiftKey&&c.key.toLowerCase()===`p`){c.preventDefault(),c.stopPropagation(),s();return}if(c.ctrlKey||c.metaKey)return;let f=e.current,h=c.target;if(r&&c.key===`Escape`&&h?.closest(`.code-file-inline-operation`)){c.preventDefault(),c.stopPropagation(),o();return}if(h?.closest(`input, textarea, [contenteditable="true"], .code-file-inline-operation`))return;Dl(c.key)&&a();let y=h?.closest(`[data-file-path]`)?.dataset.filePath,b=y?void 0:t.current?.querySelector(`[data-file-path].selected`),x={path:b?.dataset.filePath,type:b?.dataset.fileType,expanded:b?.getAttribute(`aria-expanded`)===`true`},S=f?.focusedNode&&!f.focusedNode.isRoot?f.focusedNode:null,C=kl({targetPath:y,selectedPath:x.path,focusedPath:S?.data.path,lastFocusedPath:n.current}),w=C?f?.get(C):f?.focusedNode??f?.mostRecentNode;if(!w||w.isRoot)return;if(n.current=w.data.path,c.key===`ContextMenu`||c.shiftKey&&c.key===`F10`){c.preventDefault(),c.stopPropagation();let e=(c.target?.closest(`[data-file-path]`))?.getBoundingClientRect();u(e?e.left+24:24,e?e.top+e.height:24,w.data);return}if(c.shiftKey)return;if(c.key===`ArrowDown`||c.key===`ArrowUp`){c.preventDefault(),c.stopPropagation();let e=c.key===`ArrowDown`?w.next:w.prev;if(!e||e.isRoot)return;e.focus(),e.select(),n.current=e.data.path;return}if(c.key===`Home`||c.key===`End`){c.preventDefault(),c.stopPropagation();let e=f?.visibleNodes.filter(e=>!e.isRoot)??[],t=c.key===`Home`?e[0]:e[e.length-1];if(!t)return;t.focus(),t.select(),n.current=t.data.path,l(t.data);return}if(c.key===`PageUp`||c.key===`PageDown`){c.preventDefault(),c.stopPropagation();let e=f?.visibleNodes.filter(e=>!e.isRoot)??[],t=jl({currentIndex:e.findIndex(e=>e.id===w.id),key:c.key,pageSize:g(),rowCount:e.length}),r=t>=0?e[t]:null;if(!r)return;r.focus(),r.select(),n.current=r.data.path,l(r.data);return}if(c.key===`F2`){c.preventDefault(),c.stopPropagation(),p(`rename`,w.data);return}if(c.key===`Delete`||c.key===`Backspace`){c.preventDefault(),c.stopPropagation(),p(`delete`,w.data);return}if(c.key===`ArrowRight`){if(w.data.type!==`directory`)return;if(c.preventDefault(),c.stopPropagation(),!w.isOpen){_(w);return}let e=w.children?.[0]??null;e&&(e.select(),e.focus(),n.current=e.data.path,l(e.data));return}if(c.key===`ArrowLeft`){if(c.preventDefault(),c.stopPropagation(),Ml({nodePath:w.data.path,nodeType:w.data.type,nodeOpen:w.isOpen,selectedRow:x,openDirectoryPaths:i})){v(w.data.path,w);return}let e=w.parent;e&&!e.isRoot&&(e.select(),e.focus(),n.current=e.data.path,l(e.data));return}if(c.key!==`Enter`&&c.key!==` `)return;c.preventDefault(),c.stopPropagation();let T=w.data.type===`directory`?m(w.data.path)?`open-directory`:`close-directory`:Pl({nodeType:w.data.type,nodeOpen:w.isOpen});if(T===`close-directory`){v(w.data.path,w,!1);return}if(T===`open-directory`){_(w,!1);return}T===`open-file`&&(n.current=w.data.path,d(w.data.path))},[a,o,v,r,s,l,n,_,i,u,d,g,p,m,e,t]);return(0,B.useEffect)(()=>{let n=n=>{if(n.key!==`ArrowLeft`||n.altKey||n.ctrlKey||n.metaKey)return;let r=t.current,i=document.activeElement;if(!r||!(i instanceof Element)||!r.contains(i))return;let a=r.querySelector(`[data-file-path].selected`),o=a?.dataset.filePath;if(!o||a?.dataset.fileType!==`directory`||a.getAttribute(`aria-expanded`)!==`true`)return;n.preventDefault(),n.stopPropagation();let s=e.current?.get(o);v(o,s)};return window.addEventListener(`keydown`,n,!0),()=>{window.removeEventListener(`keydown`,n,!0)}},[v,e,t]),{handleTreeKeyDownCapture:y}}var fd=24,pd=350,md=1400,hd=new Set;function gd(e){return e.replace(/[^a-zA-Z0-9_-]+/g,`-`)||`root`}function _d(e,t){let n=e.replace(/\/+$/,``)||`/`,r=t.replace(/^\/+|\/+$/g,``);return r?n===`/`?`/${r}`:`${n}/${r}`:n}function vd(e){return e.split(`/`).filter(Boolean).pop()||e}function yd(e){return{id:e.path,name:vd(e.path),path:e.path,type:`file`,size:0,mtimeMs:0}}function bd({projectId:e,projectWorkspace:t,agentId:n,agentLaunchOptions:r,activeFilePath:i,revealRequest:a,focusSearchRequest:o,editorDirtyFilePaths:s=hd,editorExternalChangedFilePaths:l=hd,openFiles:u=[],onOpenFile:d,onSelectOpenFile:f,onCloseOpenFile:p,onNewAgent:m,onStartAgent:g,onMoveEntries:_,onDeleteEntries:v,onRefreshOpenFiles:y,onFilesCollapsedChange:b,readOnly:x=!1,copy:S}){let{directories:C,treeData:w,openDirectoryPaths:T,visibleTreeRowCount:E,loadRootDirectory:D,ensureDirectoryLoaded:O,isDirectoryLoaded:k,loadMissingDirectories:A,refreshDirectories:j,hydrateCompactDirectoryChains:M,isDirectoryOpen:N,setDirectoryOpen:P,openDirectoriesInLayout:ee}=Yu(n,e),te=(0,B.useRef)(!1),ne=(0,B.useRef)(null),F=(0,B.useRef)(null),re=(0,B.useRef)(null),ie=(0,B.useRef)(!1),ae=(0,B.useRef)(0),I=(0,B.useRef)(null),[oe,se]=(0,B.useState)(`idle`),L=rd(n),ce=`code-file-search-results-${gd(e)}`,{treeRef:le,treeViewportRef:ue,lastFocusedFilePathRef:de,treeHeight:fe,handleTreeToggle:pe,refreshTreeLayout:me,rememberFocusedTreeNode:he,rememberSelectedTreeNodes:R,renderFileTreeRow:ge,setTreePathOpen:z,toggleTreePathOpen:_e}=ud({rowHeight:fd,visibleTreeRowCount:E,openDirectoryPaths:T,treeData:w,hydrateCompactDirectoryChains:M,isDirectoryOpen:N,setDirectoryOpen:P}),{cancelPendingFileFocus:ve,focusFileSearchInput:ye,focusFileTreeFromSearch:be,focusFileTreePath:xe,focusFileTreeTarget:Se,locatedFilePath:Ce,revealExplorerPath:we,revealFilePath:Te}=Vu({treeRef:le,treeViewportRef:ue,fileSearchInputRef:ne,fileOperationActiveRef:te,lastFocusedFilePathRef:de,treeData:w,isDirectoryLoaded:k,loadMissingDirectories:A,openDirectoriesInLayout:ee,refreshTreeLayout:me}),De=L.clear,{openFileError:Oe,openFilePendingPath:ke,openFilePath:Ae,setOpenFileError:je}=Qu({agentId:n,onClearSearch:De,onOpenFile:d,onRevealFilePath:Te,onSelectOpenFile:f}),Me=Au(x?null:n,u),[Ne,Pe]=(0,B.useState)(!0),Fe=(0,B.useCallback)(()=>{if(ie.current)return;ie.current=!0;let e=ae.current+1;ae.current=e,I.current!==null&&(window.clearTimeout(I.current),I.current=null),se(`refreshing`),je(null);let r=[``,...T],i=new Promise(e=>{window.setTimeout(e,pd)});(async()=>{let a=!1;try{let e=await Me.refreshChanges(),[o,s]=await Promise.all([j(r),n&&y?y(n,t):Promise.resolve(!0)]);await i,a=e&&o&&s}catch{await i}ae.current===e&&(ie.current=!1,se(a?`success`:c().connected?`error`:`idle`),a&&(I.current=window.setTimeout(()=>{ae.current===e&&se(`idle`),I.current=null},md)))})()},[n,Me.refreshChanges,y,T,t,j,je]);(0,B.useEffect)(()=>{ae.current+=1,ie.current=!1,I.current!==null&&(window.clearTimeout(I.current),I.current=null),se(`idle`)},[n,e]),(0,B.useEffect)(()=>()=>{ae.current+=1,I.current!==null&&window.clearTimeout(I.current)},[]),(0,B.useEffect)(()=>{Pe(!0)},[n]);let Ie=(0,B.useCallback)(()=>{Pe(e=>!e)},[]),Le=(0,B.useCallback)(e=>{Ae(e.path,{...h(e),transient:!0})},[Ae]),{fileOperation:Re,fileOperationInputRef:ze,clearFileOperation:Be,closeFileOperation:Ve,rememberFileOperationName:He,startFileOperation:Ue,submitFileOperation:We,updateFileOperationName:Ge}=td({agentId:n,fileOperationActiveRef:te,ensureDirectoryLoaded:O,focusFileTreePath:xe,onDeleteEntries:v,onMoveEntries:_,onOpenFile:d,onWorkspaceChange:Me.refreshChanges,refreshDirectories:j,setOpenFileError:je}),{fileMenu:H,fileMenuRef:Ke,clearFileMenu:qe,closeFileMenuWithFocusRestore:Je,closeFileMenuWithoutFocus:Ye,copyFileMenuPath:Xe,copyFileMenuShareUrl:Ze,fileMenuTargetDirectory:Qe,openFileContextMenu:$e,refreshFileMenuTarget:et,startFileMenuOperation:tt}=Xu({agentId:n,agentLaunchOptionCount:r.length,cancelPendingFileFocus:ve,clearFileOperation:Be,focusFileTreeTarget:Se,projectWorkspace:t,refreshDirectories:j,shareLinkFailed:S.shareLinkFailed,setOpenFileError:je,startFileOperation:Ue}),nt=(0,B.useCallback)(e=>{je(null),L.setQuery(e)},[L.setQuery,je]),rt=(0,B.useCallback)(()=>_d(t,Qe()),[Qe,t]),it=(0,B.useCallback)(()=>{m&&(Ye(),m(t))},[Ye,m,t]),at=(0,B.useCallback)(e=>{if(!g)return;let n=rt();Ye(),g(e,n,n===t?void 0:{projectWorkspace:t})},[Ye,rt,g,t]),ot=(0,B.useCallback)((e,t,n)=>{$e(e,t,yd(n))},[$e]),{filesCollapsed:U,openEditorsCollapsed:st,toggleFilesCollapsed:ct,toggleOpenEditorsCollapsed:lt}=ad({agentId:n,workspaceKey:e,clearFileMenu:qe,clearFileOperation:Be,clearFileSearch:De,focusFileSearchInput:ye,focusSearchRequest:o,loadRootDirectory:D,openFilesCount:u.length,refreshTreeLayout:me,revealExplorerPath:we,revealRequest:a,rootDirectoryLoaded:!!(C[``]&&!C[``].loading),setFileSearchQuery:L.setQuery,setOpenFileError:je,treeData:w});(0,B.useEffect)(()=>{b?.(U)},[U,b]);let ut=(0,B.useMemo)(()=>u.length===0?{"--code-open-editors-sticky-height":`0px`}:st?{"--code-open-editors-sticky-height":`25px`}:{"--code-open-editors-sticky-height":`${25+Math.min(u.length,7)*28}px`},[st,u.length]);(0,B.useEffect)(()=>{!i||U||!C[``]||re.current!==i&&(re.current=i,Te(i))},[i,C,U,Te]);let{focusStickyDirectory:dt,stickyContextItems:ft}=ld({filesCollapsed:U,focusFileTreePath:xe,lastFocusedFilePathRef:de,openDirectoryPaths:T,refreshTreeLayout:me,resetKey:n,treeData:w,treeViewportRef:ue}),{activeOptionId:mt,handleFileSearchKeyDown:ht,openFileJumpQuery:gt,openFileSearchMatch:W}=id({fileMenuOpen:!!H,fileOperationActive:!!Re,fileSearch:L,fileSearchResultsRef:F,filesCollapsed:U,focusFileTreeFromSearch:be,listboxId:ce,onOpenFilePath:Ae,onRevealDirectoryPath:e=>we(e,`directory`)}),{handleTreeKeyDownCapture:_t}=dd({treeRef:le,treeViewportRef:ue,lastFocusedFilePathRef:de,fileOperation:Re,openDirectoryPaths:T,cancelPendingFileFocus:ve,closeFileOperation:Ve,focusFileSearchInput:ye,focusFileTreePath:xe,focusFileTreeTarget:Se,openFileContextMenu:$e,openFilePath:Ae,setDirectoryOpen:z,startFileOperation:tt,toggleDirectoryOpen:_e}),vt=Eu({activeFilePath:i,activeSearchOptionId:mt,agentId:n??``,agentLaunchOptions:r,copy:S,editorDirtyFilePaths:s,editorExternalChangedFilePaths:l,fileMenu:H,fileMenuRef:Ke,fileOperation:Re,fileOperationInputRef:ze,fileSearch:L,fileSearchInputRef:ne,fileSearchListboxId:ce,fileSearchResultsRef:F,filesCollapsed:U,handleFileSearchKeyDown:ht,handleTreeKeyDownCapture:_t,lastFocusedFilePathRef:de,locatedFilePath:Ce,openEditorsCollapsed:st,openFileError:Oe,openFilePendingPath:ke,projectId:e,renderFileTreeRow:ge,rootDirectoryError:C[``]?.error??null,rootDirectoryHasItems:!!C[``]?.items.length,rootDirectoryLoading:!!C[``]?.loading,rowHeight:fd,readOnly:x,stickyContextItems:ft,treeData:w,treeHeight:fe,treeRef:le,treeViewportRef:ue,visibleTreeRowCount:E,onCancelPendingFileFocus:ve,onCloseFileMenuWithFocusRestore:Je,onCloseFileMenuWithoutFocus:Ye,onCloseFileOperation:Ve,onCloseOpenFile:p,onCopyFileMenuPath:Xe,onCopyFileMenuShareUrl:Ze,onFocusFileTreeTarget:Se,onFocusStickyDirectory:dt,onOpenFileContextMenu:$e,onOpenFileJumpQuery:gt,onOpenFilePath:Ae,onOpenFileSearchMatch:W,onOpenNewAgentFromFileMenu:it,onRefreshFileMenuTarget:et,onRememberFileOperationName:He,onSearchQueryChange:nt,onSelectOpenFile:f,onSelectSearchMatchIndex:L.selectMatchIndex,onToggleDirectory:_e,onStartAgentFromFileMenu:at,onStartFileMenuOperation:tt,onSubmitFileOperation:We,onToggleFilesCollapsed:ct,onToggleOpenEditorsCollapsed:lt,onToggleTreeNode:pe,onTreeFocus:he,onTreeSelect:R,onUpdateFileOperationName:Ge});return n?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Tu,{...vt.openEditors,files:u,onOpenFileContextMenu:ot}),(0,V.jsxs)(`div`,{className:`code-files-section ${U?`collapsed`:``}`,"data-testid":`code-files-section`,"data-project-id":e,style:ut,children:[(0,V.jsx)(Ql,{...vt.sectionHeader,refreshStatus:oe,onRefreshFiles:Fe}),!U&&(0,V.jsxs)(V.Fragment,{children:[!x&&(0,V.jsx)(Ee,{activeFilePath:i,projectWorkspace:t,changes:Me,collapsed:Ne,copy:S,projectId:e,refreshing:oe===`refreshing`,onOpenChange:Le,onToggleCollapsed:Ie}),!x&&(0,V.jsx)(Cu,{agentId:n,copy:S,projectId:e,projectWorkspace:t}),(0,V.jsx)(Zl,{...vt.sectionBody})]})]}),U&&(0,V.jsx)(pt,{agentId:n,copy:S,agentLaunchOptions:r,fileMenu:H,fileOperation:Re,fileMenuRef:Ke,fileOperationInputRef:ze,onCloseFileMenu:Ye,onCloseFileMenuWithFocusRestore:Je,onCloseFileOperation:Ve,onCopyFileMenuPath:Xe,onCopyFileMenuShareUrl:Ze,onOpenNewAgent:it,onRefreshFileMenuTarget:et,onRememberFileOperationName:He,onStartAgent:at,onStartFileMenuOperation:tt,onSubmitFileOperation:We,onUpdateFileOperationName:Ge,readOnly:x})]}):null}export{bd as ProjectFilesSection};
|