| 3029 | `)[0]??null,fileContent:_,style:Y,verbose:$,previewHint:A?"/plan to preview":void 0})}function d$K(q,K){let{style:_,verbose:z}=K,Y=q.file_path,$=q.old_string??"",A=q.new_string??"",O=q.replace_all??!1;if("edits"in q&&q.edits!=null)return A$.createElement(yK6,{file_path:Y,operation:"update",firstLine:null,verbose:z});if($==="")return A$.createElement(yK6,{file_path:Y,operation:"write",content:A,firstLine:ce(A),verbose:z});return A$.createElement(Baz,{filePath:Y,oldString:$,newString:A,replaceAll:O,style:_,verbose:z})}function c$K(q,K){let{verbose:_}=K;if(!_&&typeof q==="string"&&o4(q,"tool_use_error")){let z=o4(q,"tool_use_error");if(z?.includes("File has not been read yet"))return A$.createElement(s8,null,A$.createElement(k,{dimColor:!0},"File must be read first"));if(z?.includes(uZ))return A$.createElement(s8,null,A$.createElement(k,{color:"error"},"File not found"));return A$.createElement(s8,null,A$.createElement(k,{color:"error"},"Error editing file"))}return A$.createElement(Y2,{result:q,verbose:_})}function Baz(q){let K=z6(16),{filePath:_,oldString:z,newString:Y,replaceAll:$,style:A,verbose:O}=q,w;if(K[0]!==_||K[1]!==Y||K[2]!==z||K[3]!==$)w=()=>Faz(_,z,Y,$),K[0]=_,K[1]=Y,K[2]=z,K[3]=$,K[4]=w;else w=K[4];let[j]=iL6.useState(w),H;if(K[5]!==_||K[6]!==O)H=A$.createElement(yK6,{file_path:_,operation:"update",firstLine:null,verbose:O}),K[5]=_,K[6]=O,K[7]=H;else H=K[7];let J;if(K[8]!==j||K[9]!==_||K[10]!==A||K[11]!==O)J=A$.createElement(gaz,{promise:j,filePath:_,style:A,verbose:O}),K[8]=j,K[9]=_,K[10]=A,K[11]=O,K[12]=J;else J=K[12];let M;if(K[13]!==H||K[14]!==J)M=A$.createElement(iL6.Suspense,{fallback:H},J),K[13]=H,K[14]=J,K[15]=M;else M=K[15];return M}function gaz(q){let K=z6(7),{promise:_,filePath:z,style:Y,verbose:$}=q,{patch:A,firstLine:O,fileContent:w}=iL6.use(_),j;if(K[0]!==w||K[1]!==z||K[2]!==O||K[3]!==A||K[4]!==Y||K[5]!==$)j=A$.createElement(yK6,{file_path:z,operation:"update",patch:A,firstLine:O,fileContent:w,style:Y,verbose:$}),K[0]=w,K[1]=z,K[2]=O,K[3]=A,K[4]=Y,K[5]=$,K[6]=j;else j=K[6];return j}async function Faz(q,K,_,z){try{let Y=await x$K(q,K,dL6);if(Y===null||Y.truncated||Y.content===""){let{patch:w}=_88({filePath:q,fileContents:K,oldString:K,newString:_});return{patch:w,firstLine:null,fileContent:void 0}}let $=Fj6(Y.content,K)||K,A=nL6(K,$,_),{patch:O}=_88({filePath:q,fileContents:Y.content,oldString:$,newString:A,replaceAll:z});return{patch:Ku8(O,Y.lineOffset-1),firstLine:Y.lineOffset===1?ce(Y.content):null,fileContent:Y.content}}catch(Y){return H6(Y),{patch:[],firstLine:null,fileContent:void 0}}}var A$,iL6;var hs1=y(()=>{q8();Gs1();gK();i1();bN();Ts1();YK6();s6();BQ();bK();E8();SJ();Zu8();Uj6();A$=O6(D6(),1),iL6=O6(D6(),1)});import{dirname as Uaz,isAbsolute as Ss1,sep as Qaz}from"path";function daz(q){try{let K=vB(q);return{content:K.content,fileExists:!0,encoding:K.encoding,lineEndings:K.lineEndings}}catch(K){if(_7(K))return{content:"",fileExists:!1,encoding:"utf8",lineEndings:"LF"};throw K}}var l$K=1073741824,UX;var LK6=y(()=>{k8();o1();Pj6();OL6();uQ();VV6();Ga();Bq();I7();_8();BQ();m8();y8();bK();oN();zu8();ZE();U7();e7();Au8();E8();dz();Tz();br();tYK();q$K();wu8();hs1();Uj6();UX=sq({name:X4,searchHint:"modify file contents in place",maxResultSizeChars:1e5,strict:!0,async description(){return"A tool for editing files"},async prompt(){return eYK()},userFacingName:Tu8,getToolUseSummary:Rs1,getActivityDescription(q){let K=Rs1(q);return K?`Editing ${K}`:"Editing file"},get inputSchema(){return Ou8()},get outputSchema(){return K$K()},toAutoClassifierInput(q){return`${q.file_path}: ${q.new_string}`},getPath(q){return q.file_path},backfillObservableInput(q){if(typeof q.file_path==="string")q.file_path=lq(q.file_path)},async preparePermissionMatcher({file_path:q}){return(K)=>lv(K,q)},async checkPermissions(q,K){let _=K.getAppState();return Qj6(UX,q,_.toolPermissionContext)},renderToolUseMessage:U$K,renderToolResultMessage:Q$K,renderToolUseRejectedMessage:d$K,renderToolUseErrorMessage:c$K,async validateInput(q,K){let{file_path:_,old_string:z,new_string:Y,replace_all:$=!1}=q,A=lq(_),O=$I8(A,Y);if(O)return{result:!1,message:O,errorCode:0};if(z===Y)return{result:!1,behavior:"ask",message:"No changes to make: old_string and new_string are exactly the same.",errorCode:1};let w=K.getAppState();if(VH(A,w.toolPermissionContext,"edit","deny")!==null)return{result:!1,behavior:"ask",message:"File is in a directory that is denied by your permission settings.",errorCode:2};if(A.startsWith("\\\\")||A.startsWith("//"))return{result:!0};let H=X8();try{let{size:f}=await H.stat(A);if(f>l$K)return{result:!1,behavior:"ask",message:`File is too large to edit (${m4(f)}). Maximum editable file size is ${m4(l$K)}.`,errorCode:10}}catch(f){if(!_7(f))throw f}let J;try{let f=await H.readFileBytes(A),G=f.length>=2&&f[0]===255&&f[1]===254?"utf16le":"utf8";J=f.toString(G).replaceAll(`\r |