| 3012 | `||_==="\r"||_==="("||_==="["||_==="{"||_==="—"||_==="–"}function baz(q){let K=[...q],_=[];for(let z=0;z<K.length;z++)if(K[z]==='"')_.push(m$K(K,z)?ys1:Es1);else _.push(K[z]);return _.join("")}function xaz(q){let K=[...q],_=[];for(let z=0;z<K.length;z++)if(K[z]==="'"){let Y=z>0?K[z-1]:void 0,$=z<K.length-1?K[z+1]:void 0,A=Y!==void 0&&/\p{L}/u.test(Y),O=$!==void 0&&/\p{L}/u.test($);if(A&&O)_.push(Gu8);else _.push(m$K(K,z)?Ns1:Gu8)}else _.push(K[z]);return _.join("")}function Iaz(q,K,_,z=!1){let Y=z?(A,O,w)=>A.replaceAll(O,()=>w):(A,O,w)=>A.replace(O,()=>w);if(_!=="")return Y(q,K,_);return!K.endsWith(` |
| 3013 | `)&&q.includes(K+` |
| 3014 | `)?Y(q,K+` |
| 3015 | `,_):Y(q,K,_)}function _88({filePath:q,fileContents:K,oldString:_,newString:z,replaceAll:Y=!1}){return K88({filePath:q,fileContents:K,edits:[{old_string:_,new_string:z,replace_all:Y}]})}function K88({filePath:q,fileContents:K,edits:_}){let z=K,Y=[];if(!K&&_.length===1&&_[0]&&_[0].old_string===""&&_[0].new_string==="")return{patch:_y({filePath:q,fileContents:K,edits:[{old_string:K,new_string:z,replace_all:!1}]}),updatedFile:""};for(let A of _){let O=A.old_string.replace(/\n+$/,"");for(let j of Y)if(O!==""&&j.includes(O))throw Error("Cannot edit file: old_string is a substring of a new_string from a previous edit.");let w=z;if(z=A.old_string===""?A.new_string:Iaz(z,A.old_string,A.new_string,A.replace_all),z===w)throw Error("String not found in file. Failed to apply edit.");Y.push(A.new_string)}if(z===K)throw Error("Original and edited file match exactly. Failed to apply edit.");return{patch:_u8({filePath:q,oldContent:jl(K),newContent:jl(z)}),updatedFile:z}}function p$K(q,K){let _=Ck6("file.txt","file.txt",q,K,void 0,void 0,{context:8,timeout:qu8});if(!_)return"";let z=_.hunks.map((O)=>({startLine:O.oldStart,content:O.lines.filter((w)=>!w.startsWith("-")&&!w.startsWith("\\")).map((w)=>w.slice(1)).join(` |
| 3016 | `)})).map(Q$8).join(` |
| 3017 | ... |
| 3018 | `);if(z.length<=Vs1)return z;let Y=z.lastIndexOf(` |
| 3019 | `,Vs1),$=Y>0?z.slice(0,Y):z.slice(0,Vs1),A=G$(z,` |
| 3020 | `,$.length)+1;return`${$} |
| 3021 | |
| 3022 | ... [${A} lines truncated] ...`}function B$K(q){return q.map((K)=>{let _=[],z=[],Y=[];for(let $ of K.lines)if($.startsWith(" "))_.push($.slice(1)),z.push($.slice(1)),Y.push($.slice(1));else if($.startsWith("-"))z.push($.slice(1));else if($.startsWith("+"))Y.push($.slice(1));return{old_string:z.join(` |
| 3023 | `),new_string:Y.join(` |
| 3024 | `),replace_all:!1}})}function maz(q){let K=q,_=[];for(let[z,Y]of Object.entries(uaz)){let $=K;if(K=K.replaceAll(z,Y),$!==K)_.push({from:z,to:Y})}return{result:K,appliedReplacements:_}}function g$K({file_path:q,edits:K}){if(K.length===0)return{file_path:q,edits:K};let _=/\.(md|mdx)$/i.test(q);try{let z=lq(q),Y=v41(z);return{file_path:q,edits:K.map(({old_string:$,new_string:A,replace_all:O})=>{let w=_?A:Ls1(A);if(Y.includes($))return{old_string:$,new_string:w,replace_all:O};let{result:j,appliedReplacements:H}=maz($);if(Y.includes(j)){let J=w;for(let{from:M,to:X}of H)J=J.replaceAll(M,X);return{old_string:j,new_string:J,replace_all:O}}return{old_string:$,new_string:w,replace_all:O}})}}catch(z){if(!_7(z))H6(z)}return{file_path:q,edits:K}}function paz(q,K,_){if(q.length===K.length&&q.every((O,w)=>{let j=K[w];return j!==void 0&&O.old_string===j.old_string&&O.new_string===j.new_string&&O.replace_all===j.replace_all}))return!0;let z=null,Y=null,$=null,A=null;try{z=K88({filePath:"temp",fileContents:_,edits:q})}catch(O){Y=d6(O)}try{$=K88({filePath:"temp",fileContents:_,edits:K})}catch(O){A=d6(O)}if(Y!==null&&A!==null)return Y===A;if(Y!==null||A!==null)return!1;return z.updatedFile===$.updatedFile}function F$K(q,K){if(q.file_path!==K.file_path)return!1;if(q.edits.length===K.edits.length&&q.edits.every((z,Y)=>{let $=K.edits[Y];return $!==void 0&&z.old_string===$.old_string&&z.new_string===$.new_string&&z.replace_all===$.replace_all}))return!0;let _="";try{_=v41(q.file_path)}catch(z){if(!_7(z))throw z}return paz(q.edits,K.edits,_)}var Ns1="‘",Gu8="’",ys1="“",Es1="”",Vs1=8192,uaz;var Uj6=y(()=>{RO6();E8();dz();BQ();y8();bK();uaz={"<fnr>":"<function_results>","<n>":"<name>","</n>":"</name>","<o>":"<output>","</o>":"</output>","<e>":"<error>","</e>":"</error>","<s>":"<system>","</s>":"</system>","<r>":"<result>","</r>":"</result>","< META_START >":"<META_START>","< META_END >":"<META_END>","< EOT >":"<EOT>","< META >":"<META>","< SOS >":"<SOS>","\n\nH:":` |