@dahawa/hawa-code 2.4.46 → 2.4.47

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.
Files changed (3) hide show
  1. package/cli.js +563 -563
  2. package/hands.js +2 -2
  3. package/package.json +1 -1
package/hands.js CHANGED
@@ -758,7 +758,7 @@ data: ${JSON.stringify(G)}
758
758
  `);a=Q.pop()||"";for(let G of Q){let j=G.trim();if(!(!j||j==="data: [DONE]"))if(j.startsWith("data: ")){let q=j.slice(6);try{let V=JSON.parse(q);w(V)}catch(V){this.logger&&this.logger.error({err:V,line:j},"Failed to parse Gemini SSE chunk")}}else try{let q=JSON.parse(j);w(q)}catch{}}};(async()=>{try{for(;;){let{value:Q,done:G}=await s.read();if(G)break;a+=n.decode(Q,{stream:!0}),O()}I()}catch(Q){o.error(Q)}})()}})}convertGeminiResponseToAnthropic(t){this.logger&&this.logger.debug({response:t},"Original Gemini response");try{if(!t.candidates||!t.candidates[0])throw new Error("No candidates found in Gemini response");let r=t.candidates[0],n=[];r.content&&r.content.parts&&r.content.parts.forEach(o=>{if(o.text&&n.push({type:"text",text:o.text}),o.functionCall){let s=`toolu_${zB()}`,a=o.functionCall.thoughtSignature||o.functionCall.thought_signature||null;n.push({type:"tool_use",id:s,name:o.functionCall.name,input:o.functionCall.args||{},thought_signature:a})}}),r.groundingMetadata&&(this.logger&&this.logger.debug({groundingMetadata:r.groundingMetadata},"Processing grounding metadata"),r.groundingMetadata.webSearchQueries&&n.push({type:"text",text:`
759
759
 
760
760
  [Search queries used: ${r.groundingMetadata.webSearchQueries.join(", ")}]`}));let i={id:`msg_${Math.random().toString(36).slice(2)}`,type:"message",role:"assistant",model:t.modelVersion||"gemini",content:n,stop_reason:r.finishReason?r.finishReason==="STOP"&&n.some(o=>o.type==="tool_use")?"tool_use":this.mapGeminiFinishReason(r.finishReason):"end_turn",stop_sequence:null,usage:{input_tokens:t.usageMetadata?.promptTokenCount||0,output_tokens:t.usageMetadata?.candidatesTokenCount||0}};return this.logger&&this.logger.debug({result:i},"Conversion complete, final Anthropic response"),i}catch{throw $8r(`Provider error: ${JSON.stringify(t)}`,500,"provider_error")}}mapGeminiFinishReason(t){switch(t){case"STOP":return"end_turn";case"MAX_TOKENS":return"max_tokens";case"SAFETY":case"RECITATION":return"stop_sequence";default:return"end_turn"}}},cbe=new lbe;var pgt=ee(ugt(),1);dr();Rs();function $g(e){return e?typeof e.entries=="function"?Object.fromEntries(e.entries()):{...e}:{}}function dgt(e){let t=String(e?.["x-thinking-level"]??"medium").toLowerCase();return["off","low","medium","high"].includes(t)?t:"medium"}function rrn(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t}}function nrn(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t,summary:"auto"}}function irn(e,t="chat"){let r={request:{},response:{},openai:{request:{},response:{}}};return r.request.model=e.request.body.model,r.request.messages=e.request.body.messages,r.request.system=e.request.body.system,r.response.content=e.response.body.content,r.response.usage=e.response.body?.usage,t==="responses"?(r.openai.request.model=e.openai.request.body.model,r.openai.request.input=e.openai.request.body.input,r.openai.response.output=e.openai.response.body?.output,r.openai.response.usage=e.openai.response.body?.usage):(r.openai.request.model=e.openai.request.body.model,r.openai.request.messages=e.openai.request.body.messages,r.openai.response.choices=e.openai.response.body.choices,r.openai.response.usage=e.openai.response.body?.usage),r}function H5(e,t,r){Qz(t,e),Pz(t,irn(e,r),r)}function O2(e){let t=[],r=e.getReader(),n,i=new Promise(l=>n=l),o=!1,s=()=>{o||(o=!0,n(Buffer.concat(t).toString("utf8")))};return{stream:new ReadableStream({async pull(l){try{let{done:c,value:u}=await r.read();if(c){l.close(),s();return}t.push(u),l.enqueue(u)}catch(c){l.error(c),s()}},cancel(l){r.cancel(l).catch(()=>{}),s()}}),done:i}}function $5(e){let t=new Headers(e);return t.delete("content-encoding"),t.delete("content-length"),t.delete("transfer-encoding"),t}function PIe(e,t,r,n,i){let o;try{o={type:"error",error:{type:"api_error",message:JSON.parse(i).error?.message??`${e}: ${n}`,code:`${t}_${r}_ERROR`}}}catch{o={type:"error",error:{type:"api_error",message:`${e}: ${n}`,code:`${t}_${r}_ERROR`}}}return new Response(JSON.stringify(o),{status:r,statusText:n,headers:{"Content-Type":"application/json"}})}var fgt=["/v1/messages"];function LIe(e){let t;try{typeof e=="string"?t=new Ov(e):e instanceof Ov?t=e:t=new Ov(e.url)}catch{return""}let r=t.pathname;for(let n of fgt){let i=r.indexOf(n);if(i!==-1)return t.origin+r.slice(0,i)}return t.origin}function jZ(e,t){let r=typeof e=="string"?e:e instanceof Ov?e.toString():e.url,n;try{n=new Ov(r).pathname}catch{return!1}return fgt.some(i=>n.includes(i))&&(t.method==="POST"||t.method==="post")}function orn(e){return async(t,r)=>{if(!jZ(t,r))return e(t,r);let n=JSON.parse(r.body),i=await YK.transformRequestOut(n),o=LIe(t)+"/chat/completions",s=$g(r.headers),a=s.authorization??s.Authorization??"";rrn(i,dgt(s));let l=await e(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:a},body:JSON.stringify(i),signal:r.signal});if(!l.ok){let _=await l.text();return K(`OpenAI Chat Completions API error: ${l.status}`,{url:o,errorResponse:_}),PIe("OpenAI Chat Completions API error","OPENROUTER",l.status,l.statusText,_)}let c=n.stream===!0,u=s["x-agent-id"],f={request:{url:o,method:r.method,headers:s,body:n},response:{status:l.status,statusText:l.statusText,headers:$g(l.headers)},openai:{request:{body:i},response:{}}};if(!c){let _=await l.text(),y=new Response(_,{status:l.status,statusText:l.statusText,headers:$5(l.headers)}),S=await YK.transformResponseIn(y,n),I=await S.text();try{H5({...f,openai:{...f.openai,response:{body:JSON.parse(_)}},response:{...f.response,body:JSON.parse(I)}},u)}catch(w){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u975E\u6D41\u5F0F):",w)}return new Response(I,{status:S.status,statusText:S.statusText,headers:S.headers})}let g=O2(l.body),m=new Response(g.stream,{status:l.status,statusText:l.statusText,headers:$5(l.headers)}),A=await YK.transformResponseIn(m,n),h=O2(A.body);return Promise.all([g.done,h.done]).then(async([_,y])=>{try{H5({...f,openai:{...f.openai,response:{body:await Uot(_)}},response:{...f.response,body:await OU(y)}},u)}catch(S){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u6D41\u5F0F):"+S?.stack)}}).catch(_=>K("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Chat):"+_)),new Response(h.stream,{status:A.status,statusText:A.statusText,headers:A.headers})}}function srn(e){return async(t,r)=>{if(!jZ(t,r))return e(t,r);let n=JSON.parse(r.body),i=await VK.transformRequestOut(n),o=$g(r.headers);nrn(i,dgt(o));let s=JSON.stringify(i),l=LIe(t)+"/responses",c=o.authorization??o.Authorization??"";if(!c)return new Response(JSON.stringify({type:"error",error:{type:"api_error",message:"Missing Authorization header",code:"RESPONSES_AUTH_MISSING"}}),{status:401,headers:{"Content-Type":"application/json"}});let u=await e(l,{method:"POST",headers:{"Content-Type":"application/json",Authorization:c,"x-api-key":c.replace(/^Bearer\s+/i,"").trim()},body:s,signal:r.signal});if(!u.ok){let S=await u.text();return K(`OpenAI Responses API error: ${u.status} ${u.statusText}`,{url:l,status:u.status,errorResponse:S}),PIe("OpenAI Responses API error","RESPONSES",u.status,u.statusText,S)}let f=n.stream===!0,g=o["x-agent-id"],m={request:{url:l,method:r.method,headers:o,body:n},response:{status:u.status,statusText:u.statusText,headers:$g(u.headers)},openai:{request:{body:i},response:{}}};if(!f){let S=await u.text(),I=new Response(S,{status:u.status,statusText:u.statusText,headers:$5(u.headers)}),w=await VK.transformResponseIn(I,n),O=await w.text();try{H5({...m,openai:{...m.openai,response:{body:JSON.parse(S)}},response:{...m.response,body:JSON.parse(O)}},g,"responses")}catch(Q){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u975E\u6D41\u5F0F):",Q)}return new Response(O,{status:w.status,statusText:w.statusText,headers:w.headers})}let A=O2(u.body),h=new Response(A.stream,{status:u.status,statusText:u.statusText,headers:$5(u.headers)}),_=await VK.transformResponseIn(h,n),y=O2(_.body);return Promise.all([A.done,y.done]).then(async([S,I])=>{try{H5({...m,openai:{...m.openai,response:{body:await Fot(S)}},response:{...m.response,body:await OU(I)}},g,"responses")}catch(w){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u6D41\u5F0F):"+w?.stack)}}).catch(S=>K("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Responses):"+S)),new Response(y.stream,{status:_.status,statusText:_.statusText,headers:_.headers})}}function arn(e){return async(t,r)=>{if(!jZ(t,r))return e(t,r);let n=JSON.parse(r.body),i=$g(r.headers),o=await cbe.transformRequestOut(n),s=JSON.stringify(o),a=LIe(t)+`/models/${n.model}:streamGenerateContent?alt=sse`,l=i.authorization??i.Authorization??"",c;try{c=await e(a,{method:"POST",headers:{"Content-Type":"application/json","x-goog-api-key":String(l).replace(/^Bearer\s+/i,"").trim()},body:s,signal:r.signal})}catch(y){throw K("gemini request error:",y),y}if(!c.ok){let y=await c.text();return K(`Gemini API error response: ${c.status} ${c.statusText}`,{url:a,status:c.status,errorResponse:y}),PIe("Gemini API error","Gemini",c.status,c.statusText,y)}let u=n.stream===!0,f=i["x-agent-id"],g={request:{url:a,method:r.method,headers:$g(r.headers),body:n},response:{status:c.status,statusText:c.statusText,headers:$g(c.headers)},openai:{request:{body:o},response:{}}},m=O2(c.body),A=new Response(m.stream,{status:c.status,statusText:c.statusText,headers:$5(c.headers)}),h=await cbe.transformResponseIn(A),_=O2(h.body);return Promise.all([m.done,_.done]).then(async([y,S])=>{try{let I=u?Hot(y):JSON.parse(y),w=u?await OU(S):JSON.parse(S);H5({...g,openai:{...g.openai,response:{body:I}},response:{...g.response,body:w}},f)}catch(I){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Gemini):"+I?.stack)}}).catch(y=>K("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Gemini):"+y)),new Response(_.stream,{status:h.status,statusText:h.statusText,headers:h.headers})}}function lrn(e){return async(t,r)=>{if(!jZ(t,r))return e(t,r);let n=r.body;if(r.body)try{let f=JSON.parse(r.body);n=JSON.stringify(f)}catch{}let i=$g(r.headers);["1","true"].includes(String(process.env.HAWA_CODE_X_API_KEY_DISABLED??"").toLowerCase())&&(delete i["x-api-key"],delete i["X-API-Key"]),["1","true"].includes(String(process.env.HAWA_CODE_AUTH_DISABLED??"").toLowerCase())&&(delete i.authorization,delete i.Authorization),delete i["content-length"];let a=await e(t,{method:r.method,headers:i,body:n,signal:r.signal});if(!a.ok){let f=await a.text();K(`API error response: ${a.status} ${a.statusText}`,{url:typeof t=="string"?t:t instanceof Ov?t.toString():t.url,status:a.status,errorResponse:f});let g;try{let m=JSON.parse(f);g={type:"error",error:{type:"api_error",message:m.error?.message||m.message||`API error: ${a.statusText}`,code:m.error?.code||m.code||`API_${a.status}_ERROR`}},m.error?.details&&(g.error.details=m.error.details)}catch{g={type:"error",error:{type:"api_error",message:`API error: ${a.statusText}`,code:`API_${a.status}_ERROR`}}}return new Response(JSON.stringify(g),{status:a.status,statusText:a.statusText,headers:{"Content-Type":"application/json"}})}let l=a.clone(),c=!(Object.hasOwn(JSON.parse(n),"stream")&&!JSON.parse(n).stream),u={request:{url:typeof t=="string"?t:t instanceof Ov?t.toString():t.url,method:r.method,headers:$g(r.headers),body:JSON.parse(n)},response:{status:a.status,statusText:a.statusText,headers:$g(a.headers)}};return(async()=>{if(c){let m=await a.text();u.response.body=await OU(m)}else u.response.body=await a.json();let g=$g(r.headers)["x-agent-id"];Qz(g,u),Pz(g,{request:u.request.body.messages,response:u.response.body.content,usage:u.response.body?.usage})})().catch(f=>K(`\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF:
761
- Stack trace: `+f.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var zZ=null,QIe=!1;function crn(){zZ=null,QIe=!1}Sr.on("proxy:changed",crn);function urn(){if(QIe)return zZ;if(QIe=!0,ut().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(zZ=new pgt.ProxyAgent({uri:e}),tr(`[proxy] using proxy: ${e}`)),zZ}function drn(){let e=urn();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function YZ(e){let t=e||process.env.API_TYPE,r=drn();switch(t){case"openai":return orn(r);case"openai-responses":return srn(r);case"gemini":return arn(r);default:return lrn(r)}}gh();var grn=ee(ge(),1);function mgt(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=frn(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function frn(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||prn(t)?0:mrn(t)?2:1}function prn(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function mrn(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=128591||e>=129280&&e<=129535||e>=131072&&e<=262141)}function h_(e){if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/36e5),r=Math.floor(e%36e5/6e4),n=(e%6e4/1e3).toFixed(1);return t>0?`${t}h ${r}m ${n}s`:r>0?`${r}m ${n}s`:`${n}s`}function oS(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}Qe();Rs();var pc={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function VZ(e,t){pc.totalCost+=e,pc.totalAPIDuration+=t}function WZ(e,t){pc.inputTokens+=e,pc.outputTokens+=t,Sr.emit("token:change",{inputTokens:pc.inputTokens,outputTokens:pc.outputTokens})}function KZ(e,t){pc.cacheCreationTokens+=e,pc.cacheReadTokens+=t}function FIe(){return{inputTokens:pc.inputTokens,outputTokens:pc.outputTokens,cacheCreationTokens:pc.cacheCreationTokens,cacheReadTokens:pc.cacheReadTokens}}function ggt(){return pc.totalCost}function Agt(){return Date.now()-pc.startTime}function hgt(){return pc.totalAPIDuration}function Egt(e){pc.currentContextTokens=e}function _gt(){return pc.currentContextTokens}Qe();Ue();Ue();var UIe="2.4.46";globalThis.MACRO={VERSION:UIe,PACKAGE_URL:`@dahawa/${Ji}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var JZ=process.env.HAWA_CODE_USER_AGENT||`${Ji}/${UIe} (${process.env.USER_TYPE})`;import{randomUUID as RE}from"crypto";Rs();Qe();Zt();_r();Qe();Ue();import{existsSync as C_,readdirSync as qsn,statSync as Gsn}from"fs";import{join as cS,relative as zsn}from"path";import{homedir as uEt}from"os";import{platform as jsn}from"process";import{readFile as uS}from"fs/promises";_r();_m();dr();import{join as yrn,sep as brn}from"path";function ym(){if(!Ud())return!1;try{let e=ut();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function Zf(){return(yrn(Re(),".hcode","team-memory")+brn).normalize("NFC")}function __(e){let t=e.normalize("NFC"),r=Zf();return t.startsWith(r)}_m();var dEt=ee(J5(),1);Pi();var nTe=(e,t,r)=>{let n=e instanceof RegExp?Lht(e,r):e,i=t instanceof RegExp?Lht(t,r):t,o=n!==null&&i!=null&&Oon(n,i,r);return o&&{start:o[0],end:o[1],pre:r.slice(0,o[0]),body:r.slice(o[0]+n.length,o[1]),post:r.slice(o[1]+i.length)}},Lht=(e,t)=>{let r=t.match(e);return r?r[0]:null},Oon=(e,t,r)=>{let n,i,o,s,a,l=r.indexOf(e),c=r.indexOf(t,l+1),u=l;if(l>=0&&c>0){if(e===t)return[l,c];for(n=[],o=r.length;u>=0&&!a;){if(u===l)n.push(u),l=r.indexOf(e,u+1);else if(n.length===1){let f=n.pop();f!==void 0&&(a=[f,c])}else i=n.pop(),i!==void 0&&i<o&&(o=i,s=c),c=r.indexOf(t,u+1);u=l<c&&l>=0?l:c}n.length&&s!==void 0&&(a=[o,s])}return a};var Fht="\0SLASH"+Math.random()+"\0",Uht="\0OPEN"+Math.random()+"\0",sTe="\0CLOSE"+Math.random()+"\0",Hht="\0COMMA"+Math.random()+"\0",$ht="\0PERIOD"+Math.random()+"\0",kon=new RegExp(Fht,"g"),Mon=new RegExp(Uht,"g"),Qon=new RegExp(sTe,"g"),Pon=new RegExp(Hht,"g"),Lon=new RegExp($ht,"g"),Fon=/\\\\/g,Uon=/\\{/g,Hon=/\\}/g,$on=/\\,/g,qon=/\\\./g,Gon=1e5,zon=4e6;function iTe(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function jon(e){return e.replace(Fon,Fht).replace(Uon,Uht).replace(Hon,sTe).replace($on,Hht).replace(qon,$ht)}function Yon(e){return e.replace(kon,"\\").replace(Mon,"{").replace(Qon,"}").replace(Pon,",").replace(Lon,".")}function qht(e){if(!e)return[""];let t=[],r=nTe("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=qht(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function Ght(e,t={}){if(!e)return[];let{max:r=Gon,maxLength:n=zon}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),oTe(jon(e),r,n,!0).map(Yon)}function Von(e){return"{"+e+"}"}function Won(e){return/^-?0\d/.test(e)}function Kon(e,t){return e<=t}function Jon(e,t){return e>=t}function Z5(e,t,r,n,i,o){let s=[],a=0;for(let l=0;l<e.length;l++)for(let c=0;c<r.length;c++){if(s.length>=n)return s;let u=e[l]+t+r[c];if(!(o&&!u)){if(a+u.length>i)return s;s.push(u),a+=u.length}}return s}function Zon(e,t,r,n){let i=e.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let s=iTe(i[0]),a=iTe(i[1]),l=Math.max(i[0].length,i[1].length),c=i.length===3&&i[2]!==void 0?Math.max(Math.abs(iTe(i[2])),1):1,u=Kon;a<s&&(c*=-1,u=Jon);let g=i.some(Won),m=0;for(let A=s;u(A,a)&&o.length<r;A+=c){let h;if(t)h=String.fromCharCode(A),h==="\\"&&(h="");else if(h=String(A),g){let _=l-h.length;if(_>0){let y=new Array(_+1).join("0");A<0?h="-"+y+h.slice(1):h=y+h}}if(m+h.length>n)break;o.push(h),m+=h.length}return o}function oTe(e,t,r,n){let i=[""],o=!1,s=!0;for(;;){let a=nTe("{","}",e);if(!a)return Z5(i,e,[""],t,r,o);let l=a.pre;if(/\$$/.test(l)){if(i=Z5(i,l+"{"+a.body+"}",[""],t,r,o&&!a.post.length),s=!1,!a.post.length)break;e=a.post;continue}let c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),f=c||u,g=a.body.indexOf(",")>=0;if(!f&&!g){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+sTe+a.post,n=!0;continue}return Z5(i,l+"{"+a.body+"}"+a.post,[""],t,r,o)}s&&(o=n&&!f,s=!1);let m;if(f)m=Zon(a.body,u,t,r);else{let A=qht(a.body);if(A.length===1&&A[0]!==void 0&&(A=oTe(A[0],t,r,!1).map(Von),A.length===1)){if(i=Z5(i,l+A[0],[""],t,r,o&&!a.post.length),!a.post.length)break;e=a.post;continue}let h=o&&!a.post.length&&!l;for(let y=0;h&&y<i.length;y++)i[y]&&(h=!1);m=[];let _=0;e:for(let y=0;y<A.length;y++){let S=oTe(A[y],t,r,!1);for(let I=0;I<S.length;I++){let w=S[I];if(!(h&&!w)){if(m.length>=t||_+w.length>r)break e;m.push(w),_+=w.length}}}}if(i=Z5(i,l,m,t,r,o&&!a.post.length),!a.post.length)break;e=a.post}return i}var X5=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Xon={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},e9=e=>e.replace(/[[\]\\-]/g,"\\$&"),esn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),zht=e=>e.join(""),jht=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],o=r+1,s=!1,a=!1,l=!1,c=!1,u=r,f="";e:for(;o<e.length;){let h=e.charAt(o);if((h==="!"||h==="^")&&o===r+1){c=!0,o++;continue}if(h==="]"&&s&&!l){u=o+1;break}if(s=!0,h==="\\"&&!l){l=!0,o++;continue}if(h==="["&&!l){for(let[_,[y,S,I]]of Object.entries(Xon))if(e.startsWith(_,o)){if(f)return["$.",!1,e.length-r,!0];o+=_.length,I?i.push(y):n.push(y),a=a||S;continue e}}if(l=!1,f){h>f?n.push(e9(f)+"-"+e9(h)):h===f&&n.push(e9(h)),f="",o++;continue}if(e.startsWith("-]",o+1)){n.push(e9(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){f=h,o+=2;continue}n.push(e9(h)),o++}if(u<o)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,e.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!c){let h=n[0].length===2?n[0].slice(-1):n[0];return[esn(h),!1,u-r,!1]}let g="["+(c?"^":"")+zht(n)+"]",m="["+(c?"":"^")+zht(i)+"]";return[n.length&&i.length?"("+g+"|"+m+")":n.length?g:m,a,u-r,!0]};var lS=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!0}={})=>r?t?e.replace(/\[([^/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?e.replace(/\[([^/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var $d,tsn=new Set(["!","?","+","*","@"]),aTe=e=>tsn.has(e),Yht=e=>aTe(e.type),rsn=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),nsn=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),isn=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),Vht=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),osn="(?!(?:^|/)\\.\\.?(?:$|/))",uX="(?!\\.)",ssn=new Set(["[","."]),asn=new Set(["..","."]),lsn=new Set("().*{}+?[]^$\\!"),csn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),lTe="[^/]",Wht=lTe+"*?",Kht=lTe+"+?",usn=0,Hv=class{type;#e;#t;#n=!1;#r=[];#o;#i;#l;#s=!1;#a;#d;#p=!1;id=++usn;get depth(){return(this.#o?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#o?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(t,r,n={}){this.type=t,t&&(this.#t=!0),this.#o=r,this.#e=this.#o?this.#o.#e:this,this.#a=this.#e===this?n:this.#e.#a,this.#l=this.#e===this?[]:this.#e.#l,t==="!"&&!this.#e.#s&&this.#l.push(this),this.#i=this.#o?this.#o.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let t of this.#r)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#d!==void 0?this.#d:this.type?this.#d=this.type+"("+this.#r.map(t=>String(t)).join("|")+")":this.#d=this.#r.map(t=>String(t)).join("")}#f(){if(this!==this.#e)throw new Error("should only call on root");if(this.#s)return this;this.toString(),this.#s=!0;let t;for(;t=this.#l.pop();){if(t.type!=="!")continue;let r=t,n=r.#o;for(;n;){for(let i=r.#i+1;!n.type&&i<n.#r.length;i++)for(let o of t.#r){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#r[i])}r=n,n=r.#o}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof $d&&r.#o===this))throw new Error("invalid part: "+r);this.#r.push(r)}}toJSON(){let t=this.type===null?this.#r.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#r.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#o?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#o?.isStart())return!1;if(this.#i===0)return!0;let t=this.#o;for(let r=0;r<this.#i;r++){let n=t.#r[r];if(!(n instanceof $d&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let t=this.#o?this.#o.#r.length:0;return this.#i===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new $d(this.type,t);for(let n of this.#r)r.copyIn(n);return r}static#c(t,r,n,i,o){let s=i.maxExtglobRecursion??2,a=!1,l=!1,c=-1,u=!1;if(r.type===null){let h=n,_="";for(;h<t.length;){let y=t.charAt(h++);if(a||y==="\\"){a=!a,_+=y;continue}if(l){h===c+1?(y==="^"||y==="!")&&(u=!0):y==="]"&&!(h===c+2&&u)&&(l=!1),_+=y;continue}else if(y==="["){l=!0,c=h,u=!1,_+=y;continue}if(!i.noext&&aTe(y)&&t.charAt(h)==="("&&o<=s){r.push(_),_="";let I=new $d(y,r);h=$d.#c(t,I,h,i,o+1),r.push(I);continue}_+=y}return r.push(_),h}let f=n+1,g=new $d(null,r),m=[],A="";for(;f<t.length;){let h=t.charAt(f++);if(a||h==="\\"){a=!a,A+=h;continue}if(l){f===c+1?(h==="^"||h==="!")&&(u=!0):h==="]"&&!(f===c+2&&u)&&(l=!1),A+=h;continue}else if(h==="["){l=!0,c=f,u=!1,A+=h;continue}if(!i.noext&&aTe(h)&&t.charAt(f)==="("&&(o<=s||r&&r.#E(h))){let y=r&&r.#E(h)?0:1;g.push(A),A="";let S=new $d(h,g);g.push(S),f=$d.#c(t,S,f,i,o+y);continue}if(h==="|"){g.push(A),A="",m.push(g),g=new $d(null,r);continue}if(h===")")return A===""&&r.#r.length===0&&(r.#p=!0),g.push(A),A="",r.push(...m,g),f;A+=h}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],f}#g(t){return this.#h(t,nsn)}#h(t,r=rsn){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null)return!1;let n=t.#r[0];return!n||typeof n!="object"||n.type===null?!1:this.#E(n.type,r)}#E(t,r=isn){return!!r.get(this.type)?.includes(t)}#A(t,r){let n=t.#r[0],i=new $d(null,n,this.options);i.#r.push(""),n.push(i),this.#v(t,r)}#v(t,r){let n=t.#r[0];this.#r.splice(r,1,...n.#r);for(let i of n.#r)typeof i=="object"&&(i.#o=this);this.#d=void 0}#y(t){return!!Vht.get(this.type)?.has(t)}#S(t){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let r=t.#r[0];return!r||typeof r!="object"||r.type===null?!1:this.#y(r.type)}#I(t){let r=Vht.get(this.type),n=t.#r[0],i=r?.get(n.type);if(!i)return!1;this.#r=n.#r;for(let o of this.#r)typeof o=="object"&&(o.#o=this);this.type=i,this.#d=void 0,this.#p=!1}static fromGlob(t,r={}){let n=new $d(null,void 0,r);return $d.#c(t,n,0,r,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[r,n,i,o]=this.toRegExpSource();if(!(i||this.#t||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#a}toRegExpSource(t){let r=t??!!this.#a.dot;if(this.#e===this&&(this.#_(),this.#f()),!Yht(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(m=>typeof m!="string"),c=this.#r.map(m=>{let[A,h,_,y]=typeof m=="string"?$d.#C(m,this.#t,l):m.toRegExpSource(t);return this.#t=this.#t||_,this.#n=this.#n||y,A}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&asn.has(this.#r[0]))){let A=ssn,h=r&&A.has(c.charAt(0))||c.startsWith("\\.")&&A.has(c.charAt(2))||c.startsWith("\\.\\.")&&A.has(c.charAt(4)),_=!r&&!t&&A.has(c.charAt(0));u=h?osn:_?uX:""}let f="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(f="(?:$|\\/)"),[u+c+f,lS(c),this.#t=!!this.#t,this.#n]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#b(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString(),c=this;return c.#r=[l],c.type=null,c.#t=void 0,[l,lS(this.toString()),!1,!1]}let s=!n||t||r||!uX?"":this.#b(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?uX:"")+Kht;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?uX:"")+Wht+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,lS(o),this.#t=!!this.#t,this.#n]}#_(){if(Yht(this)){let t=0,r=!1;do{r=!0;for(let n=0;n<this.#r.length;n++){let i=this.#r[n];typeof i=="object"&&(i.#_(),this.#h(i)?(r=!1,this.#v(i,n)):this.#g(i)?(r=!1,this.#A(i,n)):this.#S(i)&&(r=!1,this.#I(i)))}}while(!r&&++t<10)}else for(let t of this.#r)typeof t=="object"&&t.#_();this.#d=void 0}#b(t){return this.#r.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,o,s]=r.toRegExpSource(t);return this.#n=this.#n||s,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#C(t,r,n=!1){let i=!1,o="",s=!1,a=!1;for(let l=0;l<t.length;l++){let c=t.charAt(l);if(i){i=!1,o+=(lsn.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?Kht:Wht,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,f,g,m]=jht(t,l);if(g){o+=u,s=s||f,l+=g-1,r=r||m;continue}}if(c==="?"){o+=lTe,r=!0;continue}o+=csn(c)}return[o,lS(t),!!r,s]}};$d=Hv;var cTe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var gc=(e,t,r={})=>(X5(t),!r.nocomment&&t.charAt(0)==="#"?!1:new q2(t,r).match(e)),dsn=/^\*+([^+@!?*[(]*)$/,fsn=e=>t=>!t.startsWith(".")&&t.endsWith(e),psn=e=>t=>t.endsWith(e),msn=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),gsn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Asn=/^\*+\.\*+$/,hsn=e=>!e.startsWith(".")&&e.includes("."),Esn=e=>e!=="."&&e!==".."&&e.includes("."),_sn=/^\.\*+$/,ysn=e=>e!=="."&&e!==".."&&e.startsWith("."),bsn=/^\*+$/,Csn=e=>e.length!==0&&!e.startsWith("."),Ssn=e=>e.length!==0&&e!=="."&&e!=="..",Isn=/^\?+([^+@!?*[(]*)?$/,Tsn=([e,t=""])=>{let r=Xht([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},vsn=([e,t=""])=>{let r=eEt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},xsn=([e,t=""])=>{let r=eEt([e]);return t?n=>r(n)&&n.endsWith(t):r},wsn=([e,t=""])=>{let r=Xht([e]);return t?n=>r(n)&&n.endsWith(t):r},Xht=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},eEt=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},tEt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Jht={win32:{sep:"\\"},posix:{sep:"/"}},Dsn=tEt==="win32"?Jht.win32.sep:Jht.posix.sep;gc.sep=Dsn;var Kc=Symbol("globstar **");gc.GLOBSTAR=Kc;var Rsn="[^/]",Nsn=Rsn+"*?",Bsn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Osn="(?:(?!(?:\\/|^)\\.).)*?",ksn=(e,t={})=>r=>gc(r,e,t);gc.filter=ksn;var bm=(e,t={})=>Object.assign({},e,t),Msn=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return gc;let t=gc;return Object.assign((n,i,o={})=>t(n,i,bm(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,bm(e,o))}static defaults(i){return t.defaults(bm(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,bm(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,bm(e,o))}},unescape:(n,i={})=>t.unescape(n,bm(e,i)),escape:(n,i={})=>t.escape(n,bm(e,i)),filter:(n,i={})=>t.filter(n,bm(e,i)),defaults:n=>t.defaults(bm(e,n)),makeRe:(n,i={})=>t.makeRe(n,bm(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,bm(e,i)),match:(n,i,o={})=>t.match(n,i,bm(e,o)),sep:t.sep,GLOBSTAR:Kc})};gc.defaults=Msn;var rEt=(e,t={})=>(X5(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Ght(e,{max:t.braceExpandMax}));gc.braceExpand=rEt;var Qsn=(e,t={})=>new q2(e,t).makeRe();gc.makeRe=Qsn;var Psn=(e,t,r={})=>{let n=new q2(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};gc.match=Psn;var Zht=/[?*]|[+@!]\(.*?\)|\[|\]/,Lsn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),q2=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){X5(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||tEt,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((o,s,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=o[0]===""&&o[1]===""&&(o[2]==="?"||!Zht.test(o[2]))&&!Zht.test(o[3]),c=/^[a-z]:/i.test(o[0]);if(l)return[...o.slice(0,4),...o.slice(4).map(u=>this.parse(u))];if(c)return[o[0],...o.slice(1).map(u=>this.parse(u))]}return o.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let s=this.set[o];s[0]===""&&s[1]===""&&this.globParts[o][2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3])&&(s[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n of t)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,i)=>{let o=n[n.length-1];return i==="**"&&o==="**"?n:i===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let o=t[i];i===1&&o===""&&t[0]===""||(o==="."||o==="")&&(r=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let s=i;for(;n[s+1]==="**";)s++;s>i&&n.splice(i+1,s-i);let a=n[i+1],l=n[i+2],c=n[i+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",t.push(u),i--}if(!this.preserveMultipleSlashes){for(let s=1;s<n.length-1;s++){let a=n[s];s===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(s,1),s--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let s=n[o-1];if(s&&s!=="."&&s!==".."&&s!=="**"){r=!0;let l=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...l),n.length===0&&n.push(""),o-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let i=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(i){t[r]=[],t[n]=i;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let i=0,o=0,s=[],a="";for(;i<t.length&&o<r.length;)if(t[i]===r[o])s.push(a==="b"?r[o]:t[i]),i++,o++;else if(n&&t[i]==="**"&&r[o]===t[i+1])s.push(t[i]),i++;else if(n&&r[o]==="**"&&t[i]===r[o+1])s.push(r[o]),o++;else if(t[i]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",s.push(t[i]),i++,o++}else if(r[o]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(a==="a")return!1;a="b",s.push(r[o]),i++,o++}else return!1;return t.length===r.length&&s}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let i=0,o=0;if(this.isWindows){let a=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),l=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),c=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),u=!c&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),f=l?3:a?0:void 0,g=u?3:c?0:void 0;if(typeof f=="number"&&typeof g=="number"){let[m,A]=[t[f],r[g]];m.toLowerCase()===A.toLowerCase()&&(r[g]=m,o=g,i=f)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(Kc)?this.#e(t,r,n,i,o):this.#n(t,r,n,i,o)}#e(t,r,n,i,o){let s=r.indexOf(Kc,o),a=r.lastIndexOf(Kc),[l,c,u]=n?[r.slice(o,s),r.slice(s+1),[]]:[r.slice(o,s),r.slice(s+1,a),r.slice(a+1)];if(l.length){let S=t.slice(i,i+l.length);if(!this.#n(S,l,n,0,0))return!1;i+=l.length,o+=l.length}let f=0;if(u.length){if(u.length+i>t.length)return!1;let S=t.length-u.length;if(this.#n(t,u,n,S,0))f=u.length;else{if(t[t.length-1]!==""||i+u.length===t.length||(S--,!this.#n(t,u,n,S,0)))return!1;f=u.length+1}}if(!c.length){let S=!!f;for(let I=i;I<t.length-f;I++){let w=String(t[I]);if(S=!0,w==="."||w===".."||!this.options.dot&&w.startsWith("."))return!1}return n||S}let g=[[[],0]],m=g[0],A=0,h=[0];for(let S of c)S===Kc?(h.push(A),m=[[],0],g.push(m)):(m[0].push(S),A++);let _=g.length-1,y=t.length-f;for(let S of g)S[1]=y-(h[_--]+S[0].length);return!!this.#t(t,g,i,0,n,0,!!f)}#t(t,r,n,i,o,s,a){let l=r[i];if(!l){for(let f=n;f<t.length;f++){a=!0;let g=t[f];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1}return a}let[c,u]=l;for(;n<=u;){if(this.#n(t.slice(0,n+c.length),c,o,n,0)&&s<this.maxGlobstarRecursion){let m=this.#t(t,r,n+c.length,i+1,o,s+1,a);if(m!==!1)return m}let g=t[n];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1;n++}return o||null}#n(t,r,n,i,o){let s,a,l,c;for(s=i,a=o,c=t.length,l=r.length;s<c&&a<l;s++,a++){this.debug("matchOne loop");let u=r[a],f=t[s];if(this.debug(r,u,f),u===!1||u===Kc)return!1;let g;if(typeof u=="string"?(g=f===u,this.debug("string match",u,f,g)):(g=u.test(f),this.debug("pattern match",u,f,g)),!g)return!1}if(s===c&&a===l)return!0;if(s===c)return n;if(a===l)return s===c-1&&t[s]==="";throw new Error("wtf?")}braceExpand(){return rEt(this.pattern,this.options)}parse(t){X5(t);let r=this.options;if(t==="**")return Kc;if(t==="")return"";let n,i=null;(n=t.match(bsn))?i=r.dot?Ssn:Csn:(n=t.match(dsn))?i=(r.nocase?r.dot?gsn:msn:r.dot?psn:fsn)(n[1]):(n=t.match(Isn))?i=(r.nocase?r.dot?vsn:Tsn:r.dot?xsn:wsn)(n):(n=t.match(Asn))?i=r.dot?Esn:hsn:(n=t.match(_sn))&&(i=ysn);let o=Hv.fromGlob(t,this.options).toMMPattern();return i&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:i}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?Nsn:r.dot?Bsn:Osn,i=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let c=l.map(f=>{if(f instanceof RegExp)for(let g of f.flags.split(""))i.add(g);return typeof f=="string"?Lsn(f):f===Kc?Kc:f._src});c.forEach((f,g)=>{let m=c[g+1],A=c[g-1];f!==Kc||A===Kc||(A===void 0?m!==void 0&&m!==Kc?c[g+1]="(?:\\/|"+n+"\\/)?"+m:c[g]=n:m===void 0?c[g-1]=A+"(?:\\/|\\/"+n+")?":m!==Kc&&(c[g-1]=A+"(?:\\/|\\/"+n+"\\/)"+m,c[g+1]=Kc))});let u=c.filter(f=>f!==Kc);if(this.partial&&u.length>=1){let f=[];for(let g=1;g<=u.length;g++)f.push(u.slice(0,g).join("/"));return"(?:"+f.join("|")+")"}return u.join("/")}).join("|"),[s,a]=t.length>1?["(?:",")"]:["",""];o="^"+s+o+a+"$",this.partial&&(o="^(?:\\/|"+s+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let o=this.set;this.debug(this.pattern,"set",o);let s=i[i.length-1];if(!s)for(let a=i.length-2;!s&&a>=0;a--)s=i[a];for(let a of o){let l=i;if(n.matchBase&&a.length===1&&(l=[s]),this.matchOne(l,a,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return gc.defaults(t).Minimatch}};gc.AST=Hv;gc.Minimatch=q2;gc.escape=cTe;gc.unescape=lS;var oEt=ee(J5(),1);_r();Ue();Qe();Tu();import{readFile as nEt}from"fs/promises";import{existsSync as uTe,readdirSync as Fsn,statSync as Usn}from"fs";import{join as dTe,relative as sEt}from"path";import{homedir as Hsn}from"os";function iEt(e){try{let t=(0,oEt.default)(e),r=t.data.paths,n=[];return typeof r=="string"?n=r.split(",").map(i=>i.trim()).filter(Boolean):Array.isArray(r)&&(n=r.filter(i=>typeof i=="string")),{paths:n,content:t.content.trim()}}catch(t){return Te(t),{paths:[],content:e.trim()}}}function $sn(e,t){return t.length===0?!0:t.some(r=>{try{return gc(e,r,{matchBase:!0,dot:!0})}catch(n){return Te(n),!1}})}function fTe(e){let t=[];try{if(!uTe(e))return t;let r=Fsn(e);for(let n of r){let i=dTe(e,n),o=Usn(i);o.isDirectory()?t.push(...fTe(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){Te(r)}return t}async function dX(){let e=[];try{let t=dTe(Hsn(),en,"rules");if(uTe(t)){let r=fTe(t);for(let n of r)try{let i=await nEt(n,"utf-8"),{paths:o,content:s}=iEt(i);o.length>0&&e.push({filePath:n,content:s,paths:o,isProjectRule:!1})}catch(i){Te(i)}}}catch(t){Te(t)}try{let t=dTe(Re(),en,"rules");if(uTe(t)){let r=fTe(t);for(let n of r)try{let i=await nEt(n,"utf-8"),{paths:o,content:s}=iEt(i);o.length>0&&e.push({filePath:sEt(Re(),n),content:s,paths:o,isProjectRule:!0})}catch(i){Te(i)}}}catch(t){Te(t)}return e}function aEt(e,t){e=OV(e);let r=OV(Re()),n=e.startsWith(r)?sEt(r,e):e;return t.filter(i=>$sn(n,i.paths))}function lEt(e){return e.length===0?"":e.map(r=>{let n=r.isProjectRule?"project instructions, checked into the codebase":"user's private global instructions for all projects";return`Contents of ${r.filePath} (${n}):
761
+ Stack trace: `+f.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var zZ=null,QIe=!1;function crn(){zZ=null,QIe=!1}Sr.on("proxy:changed",crn);function urn(){if(QIe)return zZ;if(QIe=!0,ut().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(zZ=new pgt.ProxyAgent({uri:e}),tr(`[proxy] using proxy: ${e}`)),zZ}function drn(){let e=urn();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function YZ(e){let t=e||process.env.API_TYPE,r=drn();switch(t){case"openai":return orn(r);case"openai-responses":return srn(r);case"gemini":return arn(r);default:return lrn(r)}}gh();var grn=ee(ge(),1);function mgt(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=frn(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function frn(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||prn(t)?0:mrn(t)?2:1}function prn(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function mrn(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=42191&&e!==12351||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=127744&&e<=128591||e>=129280&&e<=129535||e>=131072&&e<=262141)}function h_(e){if(e<6e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.floor(e/36e5),r=Math.floor(e%36e5/6e4),n=(e%6e4/1e3).toFixed(1);return t>0?`${t}h ${r}m ${n}s`:r>0?`${r}m ${n}s`:`${n}s`}function oS(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}Qe();Rs();var pc={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function VZ(e,t){pc.totalCost+=e,pc.totalAPIDuration+=t}function WZ(e,t){pc.inputTokens+=e,pc.outputTokens+=t,Sr.emit("token:change",{inputTokens:pc.inputTokens,outputTokens:pc.outputTokens})}function KZ(e,t){pc.cacheCreationTokens+=e,pc.cacheReadTokens+=t}function FIe(){return{inputTokens:pc.inputTokens,outputTokens:pc.outputTokens,cacheCreationTokens:pc.cacheCreationTokens,cacheReadTokens:pc.cacheReadTokens}}function ggt(){return pc.totalCost}function Agt(){return Date.now()-pc.startTime}function hgt(){return pc.totalAPIDuration}function Egt(e){pc.currentContextTokens=e}function _gt(){return pc.currentContextTokens}Qe();Ue();Ue();var UIe="2.4.47";globalThis.MACRO={VERSION:UIe,PACKAGE_URL:`@dahawa/${Ji}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var JZ=process.env.HAWA_CODE_USER_AGENT||`${Ji}/${UIe} (${process.env.USER_TYPE})`;import{randomUUID as RE}from"crypto";Rs();Qe();Zt();_r();Qe();Ue();import{existsSync as C_,readdirSync as qsn,statSync as Gsn}from"fs";import{join as cS,relative as zsn}from"path";import{homedir as uEt}from"os";import{platform as jsn}from"process";import{readFile as uS}from"fs/promises";_r();_m();dr();import{join as yrn,sep as brn}from"path";function ym(){if(!Ud())return!1;try{let e=ut();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function Zf(){return(yrn(Re(),".hcode","team-memory")+brn).normalize("NFC")}function __(e){let t=e.normalize("NFC"),r=Zf();return t.startsWith(r)}_m();var dEt=ee(J5(),1);Pi();var nTe=(e,t,r)=>{let n=e instanceof RegExp?Lht(e,r):e,i=t instanceof RegExp?Lht(t,r):t,o=n!==null&&i!=null&&Oon(n,i,r);return o&&{start:o[0],end:o[1],pre:r.slice(0,o[0]),body:r.slice(o[0]+n.length,o[1]),post:r.slice(o[1]+i.length)}},Lht=(e,t)=>{let r=t.match(e);return r?r[0]:null},Oon=(e,t,r)=>{let n,i,o,s,a,l=r.indexOf(e),c=r.indexOf(t,l+1),u=l;if(l>=0&&c>0){if(e===t)return[l,c];for(n=[],o=r.length;u>=0&&!a;){if(u===l)n.push(u),l=r.indexOf(e,u+1);else if(n.length===1){let f=n.pop();f!==void 0&&(a=[f,c])}else i=n.pop(),i!==void 0&&i<o&&(o=i,s=c),c=r.indexOf(t,u+1);u=l<c&&l>=0?l:c}n.length&&s!==void 0&&(a=[o,s])}return a};var Fht="\0SLASH"+Math.random()+"\0",Uht="\0OPEN"+Math.random()+"\0",sTe="\0CLOSE"+Math.random()+"\0",Hht="\0COMMA"+Math.random()+"\0",$ht="\0PERIOD"+Math.random()+"\0",kon=new RegExp(Fht,"g"),Mon=new RegExp(Uht,"g"),Qon=new RegExp(sTe,"g"),Pon=new RegExp(Hht,"g"),Lon=new RegExp($ht,"g"),Fon=/\\\\/g,Uon=/\\{/g,Hon=/\\}/g,$on=/\\,/g,qon=/\\\./g,Gon=1e5,zon=4e6;function iTe(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function jon(e){return e.replace(Fon,Fht).replace(Uon,Uht).replace(Hon,sTe).replace($on,Hht).replace(qon,$ht)}function Yon(e){return e.replace(kon,"\\").replace(Mon,"{").replace(Qon,"}").replace(Pon,",").replace(Lon,".")}function qht(e){if(!e)return[""];let t=[],r=nTe("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=qht(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function Ght(e,t={}){if(!e)return[];let{max:r=Gon,maxLength:n=zon}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),oTe(jon(e),r,n,!0).map(Yon)}function Von(e){return"{"+e+"}"}function Won(e){return/^-?0\d/.test(e)}function Kon(e,t){return e<=t}function Jon(e,t){return e>=t}function Z5(e,t,r,n,i,o){let s=[],a=0;for(let l=0;l<e.length;l++)for(let c=0;c<r.length;c++){if(s.length>=n)return s;let u=e[l]+t+r[c];if(!(o&&!u)){if(a+u.length>i)return s;s.push(u),a+=u.length}}return s}function Zon(e,t,r,n){let i=e.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let s=iTe(i[0]),a=iTe(i[1]),l=Math.max(i[0].length,i[1].length),c=i.length===3&&i[2]!==void 0?Math.max(Math.abs(iTe(i[2])),1):1,u=Kon;a<s&&(c*=-1,u=Jon);let g=i.some(Won),m=0;for(let A=s;u(A,a)&&o.length<r;A+=c){let h;if(t)h=String.fromCharCode(A),h==="\\"&&(h="");else if(h=String(A),g){let _=l-h.length;if(_>0){let y=new Array(_+1).join("0");A<0?h="-"+y+h.slice(1):h=y+h}}if(m+h.length>n)break;o.push(h),m+=h.length}return o}function oTe(e,t,r,n){let i=[""],o=!1,s=!0;for(;;){let a=nTe("{","}",e);if(!a)return Z5(i,e,[""],t,r,o);let l=a.pre;if(/\$$/.test(l)){if(i=Z5(i,l+"{"+a.body+"}",[""],t,r,o&&!a.post.length),s=!1,!a.post.length)break;e=a.post;continue}let c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(a.body),u=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(a.body),f=c||u,g=a.body.indexOf(",")>=0;if(!f&&!g){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+sTe+a.post,n=!0;continue}return Z5(i,l+"{"+a.body+"}"+a.post,[""],t,r,o)}s&&(o=n&&!f,s=!1);let m;if(f)m=Zon(a.body,u,t,r);else{let A=qht(a.body);if(A.length===1&&A[0]!==void 0&&(A=oTe(A[0],t,r,!1).map(Von),A.length===1)){if(i=Z5(i,l+A[0],[""],t,r,o&&!a.post.length),!a.post.length)break;e=a.post;continue}let h=o&&!a.post.length&&!l;for(let y=0;h&&y<i.length;y++)i[y]&&(h=!1);m=[];let _=0;e:for(let y=0;y<A.length;y++){let S=oTe(A[y],t,r,!1);for(let I=0;I<S.length;I++){let w=S[I];if(!(h&&!w)){if(m.length>=t||_+w.length>r)break e;m.push(w),_+=w.length}}}}if(i=Z5(i,l,m,t,r,o&&!a.post.length),!a.post.length)break;e=a.post}return i}var X5=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Xon={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},e9=e=>e.replace(/[[\]\\-]/g,"\\$&"),esn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),zht=e=>e.join(""),jht=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],o=r+1,s=!1,a=!1,l=!1,c=!1,u=r,f="";e:for(;o<e.length;){let h=e.charAt(o);if((h==="!"||h==="^")&&o===r+1){c=!0,o++;continue}if(h==="]"&&s&&!l){u=o+1;break}if(s=!0,h==="\\"&&!l){l=!0,o++;continue}if(h==="["&&!l){for(let[_,[y,S,I]]of Object.entries(Xon))if(e.startsWith(_,o)){if(f)return["$.",!1,e.length-r,!0];o+=_.length,I?i.push(y):n.push(y),a=a||S;continue e}}if(l=!1,f){h>f?n.push(e9(f)+"-"+e9(h)):h===f&&n.push(e9(h)),f="",o++;continue}if(e.startsWith("-]",o+1)){n.push(e9(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){f=h,o+=2;continue}n.push(e9(h)),o++}if(u<o)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,e.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!c){let h=n[0].length===2?n[0].slice(-1):n[0];return[esn(h),!1,u-r,!1]}let g="["+(c?"^":"")+zht(n)+"]",m="["+(c?"":"^")+zht(i)+"]";return[n.length&&i.length?"("+g+"|"+m+")":n.length?g:m,a,u-r,!0]};var lS=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!0}={})=>r?t?e.replace(/\[([^/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\])\]/g,"$1$2").replace(/\\([^/])/g,"$1"):t?e.replace(/\[([^/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^/\\{}])\]/g,"$1$2").replace(/\\([^/{}])/g,"$1");var $d,tsn=new Set(["!","?","+","*","@"]),aTe=e=>tsn.has(e),Yht=e=>aTe(e.type),rsn=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),nsn=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),isn=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),Vht=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),osn="(?!(?:^|/)\\.\\.?(?:$|/))",uX="(?!\\.)",ssn=new Set(["[","."]),asn=new Set(["..","."]),lsn=new Set("().*{}+?[]^$\\!"),csn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),lTe="[^/]",Wht=lTe+"*?",Kht=lTe+"+?",usn=0,Hv=class{type;#e;#t;#n=!1;#r=[];#o;#i;#l;#s=!1;#a;#d;#p=!1;id=++usn;get depth(){return(this.#o?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#o?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(t,r,n={}){this.type=t,t&&(this.#t=!0),this.#o=r,this.#e=this.#o?this.#o.#e:this,this.#a=this.#e===this?n:this.#e.#a,this.#l=this.#e===this?[]:this.#e.#l,t==="!"&&!this.#e.#s&&this.#l.push(this),this.#i=this.#o?this.#o.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let t of this.#r)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#d!==void 0?this.#d:this.type?this.#d=this.type+"("+this.#r.map(t=>String(t)).join("|")+")":this.#d=this.#r.map(t=>String(t)).join("")}#f(){if(this!==this.#e)throw new Error("should only call on root");if(this.#s)return this;this.toString(),this.#s=!0;let t;for(;t=this.#l.pop();){if(t.type!=="!")continue;let r=t,n=r.#o;for(;n;){for(let i=r.#i+1;!n.type&&i<n.#r.length;i++)for(let o of t.#r){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#r[i])}r=n,n=r.#o}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof $d&&r.#o===this))throw new Error("invalid part: "+r);this.#r.push(r)}}toJSON(){let t=this.type===null?this.#r.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#r.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#s&&this.#o?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#o?.isStart())return!1;if(this.#i===0)return!0;let t=this.#o;for(let r=0;r<this.#i;r++){let n=t.#r[r];if(!(n instanceof $d&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let t=this.#o?this.#o.#r.length:0;return this.#i===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new $d(this.type,t);for(let n of this.#r)r.copyIn(n);return r}static#c(t,r,n,i,o){let s=i.maxExtglobRecursion??2,a=!1,l=!1,c=-1,u=!1;if(r.type===null){let h=n,_="";for(;h<t.length;){let y=t.charAt(h++);if(a||y==="\\"){a=!a,_+=y;continue}if(l){h===c+1?(y==="^"||y==="!")&&(u=!0):y==="]"&&!(h===c+2&&u)&&(l=!1),_+=y;continue}else if(y==="["){l=!0,c=h,u=!1,_+=y;continue}if(!i.noext&&aTe(y)&&t.charAt(h)==="("&&o<=s){r.push(_),_="";let I=new $d(y,r);h=$d.#c(t,I,h,i,o+1),r.push(I);continue}_+=y}return r.push(_),h}let f=n+1,g=new $d(null,r),m=[],A="";for(;f<t.length;){let h=t.charAt(f++);if(a||h==="\\"){a=!a,A+=h;continue}if(l){f===c+1?(h==="^"||h==="!")&&(u=!0):h==="]"&&!(f===c+2&&u)&&(l=!1),A+=h;continue}else if(h==="["){l=!0,c=f,u=!1,A+=h;continue}if(!i.noext&&aTe(h)&&t.charAt(f)==="("&&(o<=s||r&&r.#E(h))){let y=r&&r.#E(h)?0:1;g.push(A),A="";let S=new $d(h,g);g.push(S),f=$d.#c(t,S,f,i,o+y);continue}if(h==="|"){g.push(A),A="",m.push(g),g=new $d(null,r);continue}if(h===")")return A===""&&r.#r.length===0&&(r.#p=!0),g.push(A),A="",r.push(...m,g),f;A+=h}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],f}#g(t){return this.#h(t,nsn)}#h(t,r=rsn){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null)return!1;let n=t.#r[0];return!n||typeof n!="object"||n.type===null?!1:this.#E(n.type,r)}#E(t,r=isn){return!!r.get(this.type)?.includes(t)}#A(t,r){let n=t.#r[0],i=new $d(null,n,this.options);i.#r.push(""),n.push(i),this.#v(t,r)}#v(t,r){let n=t.#r[0];this.#r.splice(r,1,...n.#r);for(let i of n.#r)typeof i=="object"&&(i.#o=this);this.#d=void 0}#y(t){return!!Vht.get(this.type)?.has(t)}#S(t){if(!t||typeof t!="object"||t.type!==null||t.#r.length!==1||this.type===null||this.#r.length!==1)return!1;let r=t.#r[0];return!r||typeof r!="object"||r.type===null?!1:this.#y(r.type)}#I(t){let r=Vht.get(this.type),n=t.#r[0],i=r?.get(n.type);if(!i)return!1;this.#r=n.#r;for(let o of this.#r)typeof o=="object"&&(o.#o=this);this.type=i,this.#d=void 0,this.#p=!1}static fromGlob(t,r={}){let n=new $d(null,void 0,r);return $d.#c(t,n,0,r,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[r,n,i,o]=this.toRegExpSource();if(!(i||this.#t||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#a}toRegExpSource(t){let r=t??!!this.#a.dot;if(this.#e===this&&(this.#_(),this.#f()),!Yht(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(m=>typeof m!="string"),c=this.#r.map(m=>{let[A,h,_,y]=typeof m=="string"?$d.#C(m,this.#t,l):m.toRegExpSource(t);return this.#t=this.#t||_,this.#n=this.#n||y,A}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&asn.has(this.#r[0]))){let A=ssn,h=r&&A.has(c.charAt(0))||c.startsWith("\\.")&&A.has(c.charAt(2))||c.startsWith("\\.\\.")&&A.has(c.charAt(4)),_=!r&&!t&&A.has(c.charAt(0));u=h?osn:_?uX:""}let f="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(f="(?:$|\\/)"),[u+c+f,lS(c),this.#t=!!this.#t,this.#n]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#b(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString(),c=this;return c.#r=[l],c.type=null,c.#t=void 0,[l,lS(this.toString()),!1,!1]}let s=!n||t||r||!uX?"":this.#b(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?uX:"")+Kht;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?uX:"")+Wht+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,lS(o),this.#t=!!this.#t,this.#n]}#_(){if(Yht(this)){let t=0,r=!1;do{r=!0;for(let n=0;n<this.#r.length;n++){let i=this.#r[n];typeof i=="object"&&(i.#_(),this.#h(i)?(r=!1,this.#v(i,n)):this.#g(i)?(r=!1,this.#A(i,n)):this.#S(i)&&(r=!1,this.#I(i)))}}while(!r&&++t<10)}else for(let t of this.#r)typeof t=="object"&&t.#_();this.#d=void 0}#b(t){return this.#r.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,o,s]=r.toRegExpSource(t);return this.#n=this.#n||s,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#C(t,r,n=!1){let i=!1,o="",s=!1,a=!1;for(let l=0;l<t.length;l++){let c=t.charAt(l);if(i){i=!1,o+=(lsn.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?Kht:Wht,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,f,g,m]=jht(t,l);if(g){o+=u,s=s||f,l+=g-1,r=r||m;continue}}if(c==="?"){o+=lTe,r=!0;continue}o+=csn(c)}return[o,lS(t),!!r,s]}};$d=Hv;var cTe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var gc=(e,t,r={})=>(X5(t),!r.nocomment&&t.charAt(0)==="#"?!1:new q2(t,r).match(e)),dsn=/^\*+([^+@!?*[(]*)$/,fsn=e=>t=>!t.startsWith(".")&&t.endsWith(e),psn=e=>t=>t.endsWith(e),msn=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),gsn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Asn=/^\*+\.\*+$/,hsn=e=>!e.startsWith(".")&&e.includes("."),Esn=e=>e!=="."&&e!==".."&&e.includes("."),_sn=/^\.\*+$/,ysn=e=>e!=="."&&e!==".."&&e.startsWith("."),bsn=/^\*+$/,Csn=e=>e.length!==0&&!e.startsWith("."),Ssn=e=>e.length!==0&&e!=="."&&e!=="..",Isn=/^\?+([^+@!?*[(]*)?$/,Tsn=([e,t=""])=>{let r=Xht([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},vsn=([e,t=""])=>{let r=eEt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},xsn=([e,t=""])=>{let r=eEt([e]);return t?n=>r(n)&&n.endsWith(t):r},wsn=([e,t=""])=>{let r=Xht([e]);return t?n=>r(n)&&n.endsWith(t):r},Xht=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},eEt=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},tEt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Jht={win32:{sep:"\\"},posix:{sep:"/"}},Dsn=tEt==="win32"?Jht.win32.sep:Jht.posix.sep;gc.sep=Dsn;var Kc=Symbol("globstar **");gc.GLOBSTAR=Kc;var Rsn="[^/]",Nsn=Rsn+"*?",Bsn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Osn="(?:(?!(?:\\/|^)\\.).)*?",ksn=(e,t={})=>r=>gc(r,e,t);gc.filter=ksn;var bm=(e,t={})=>Object.assign({},e,t),Msn=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return gc;let t=gc;return Object.assign((n,i,o={})=>t(n,i,bm(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,bm(e,o))}static defaults(i){return t.defaults(bm(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,bm(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,bm(e,o))}},unescape:(n,i={})=>t.unescape(n,bm(e,i)),escape:(n,i={})=>t.escape(n,bm(e,i)),filter:(n,i={})=>t.filter(n,bm(e,i)),defaults:n=>t.defaults(bm(e,n)),makeRe:(n,i={})=>t.makeRe(n,bm(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,bm(e,i)),match:(n,i,o={})=>t.match(n,i,bm(e,o)),sep:t.sep,GLOBSTAR:Kc})};gc.defaults=Msn;var rEt=(e,t={})=>(X5(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Ght(e,{max:t.braceExpandMax}));gc.braceExpand=rEt;var Qsn=(e,t={})=>new q2(e,t).makeRe();gc.makeRe=Qsn;var Psn=(e,t,r={})=>{let n=new q2(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};gc.match=Psn;var Zht=/[?*]|[+@!]\(.*?\)|\[|\]/,Lsn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),q2=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){X5(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||tEt,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((o,s,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=o[0]===""&&o[1]===""&&(o[2]==="?"||!Zht.test(o[2]))&&!Zht.test(o[3]),c=/^[a-z]:/i.test(o[0]);if(l)return[...o.slice(0,4),...o.slice(4).map(u=>this.parse(u))];if(c)return[o[0],...o.slice(1).map(u=>this.parse(u))]}return o.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let s=this.set[o];s[0]===""&&s[1]===""&&this.globParts[o][2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3])&&(s[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n of t)for(let i=0;i<n.length;i++)n[i]==="**"&&(n[i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,i)=>{let o=n[n.length-1];return i==="**"&&o==="**"?n:i===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let o=t[i];i===1&&o===""&&t[0]===""||(o==="."||o==="")&&(r=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(i))&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let s=i;for(;n[s+1]==="**";)s++;s>i&&n.splice(i+1,s-i);let a=n[i+1],l=n[i+2],c=n[i+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",t.push(u),i--}if(!this.preserveMultipleSlashes){for(let s=1;s<n.length-1;s++){let a=n[s];s===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(s,1),s--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let s=n[o-1];if(s&&s!=="."&&s!==".."&&s!=="**"){r=!0;let l=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...l),n.length===0&&n.push(""),o-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let i=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(i){t[r]=[],t[n]=i;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let i=0,o=0,s=[],a="";for(;i<t.length&&o<r.length;)if(t[i]===r[o])s.push(a==="b"?r[o]:t[i]),i++,o++;else if(n&&t[i]==="**"&&r[o]===t[i+1])s.push(t[i]),i++;else if(n&&r[o]==="**"&&t[i]===r[o+1])s.push(r[o]),o++;else if(t[i]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",s.push(t[i]),i++,o++}else if(r[o]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(a==="a")return!1;a="b",s.push(r[o]),i++,o++}else return!1;return t.length===r.length&&s}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let i=0,o=0;if(this.isWindows){let a=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),l=!a&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),c=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),u=!c&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),f=l?3:a?0:void 0,g=u?3:c?0:void 0;if(typeof f=="number"&&typeof g=="number"){let[m,A]=[t[f],r[g]];m.toLowerCase()===A.toLowerCase()&&(r[g]=m,o=g,i=f)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(Kc)?this.#e(t,r,n,i,o):this.#n(t,r,n,i,o)}#e(t,r,n,i,o){let s=r.indexOf(Kc,o),a=r.lastIndexOf(Kc),[l,c,u]=n?[r.slice(o,s),r.slice(s+1),[]]:[r.slice(o,s),r.slice(s+1,a),r.slice(a+1)];if(l.length){let S=t.slice(i,i+l.length);if(!this.#n(S,l,n,0,0))return!1;i+=l.length,o+=l.length}let f=0;if(u.length){if(u.length+i>t.length)return!1;let S=t.length-u.length;if(this.#n(t,u,n,S,0))f=u.length;else{if(t[t.length-1]!==""||i+u.length===t.length||(S--,!this.#n(t,u,n,S,0)))return!1;f=u.length+1}}if(!c.length){let S=!!f;for(let I=i;I<t.length-f;I++){let w=String(t[I]);if(S=!0,w==="."||w===".."||!this.options.dot&&w.startsWith("."))return!1}return n||S}let g=[[[],0]],m=g[0],A=0,h=[0];for(let S of c)S===Kc?(h.push(A),m=[[],0],g.push(m)):(m[0].push(S),A++);let _=g.length-1,y=t.length-f;for(let S of g)S[1]=y-(h[_--]+S[0].length);return!!this.#t(t,g,i,0,n,0,!!f)}#t(t,r,n,i,o,s,a){let l=r[i];if(!l){for(let f=n;f<t.length;f++){a=!0;let g=t[f];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1}return a}let[c,u]=l;for(;n<=u;){if(this.#n(t.slice(0,n+c.length),c,o,n,0)&&s<this.maxGlobstarRecursion){let m=this.#t(t,r,n+c.length,i+1,o,s+1,a);if(m!==!1)return m}let g=t[n];if(g==="."||g===".."||!this.options.dot&&g.startsWith("."))return!1;n++}return o||null}#n(t,r,n,i,o){let s,a,l,c;for(s=i,a=o,c=t.length,l=r.length;s<c&&a<l;s++,a++){this.debug("matchOne loop");let u=r[a],f=t[s];if(this.debug(r,u,f),u===!1||u===Kc)return!1;let g;if(typeof u=="string"?(g=f===u,this.debug("string match",u,f,g)):(g=u.test(f),this.debug("pattern match",u,f,g)),!g)return!1}if(s===c&&a===l)return!0;if(s===c)return n;if(a===l)return s===c-1&&t[s]==="";throw new Error("wtf?")}braceExpand(){return rEt(this.pattern,this.options)}parse(t){X5(t);let r=this.options;if(t==="**")return Kc;if(t==="")return"";let n,i=null;(n=t.match(bsn))?i=r.dot?Ssn:Csn:(n=t.match(dsn))?i=(r.nocase?r.dot?gsn:msn:r.dot?psn:fsn)(n[1]):(n=t.match(Isn))?i=(r.nocase?r.dot?vsn:Tsn:r.dot?xsn:wsn)(n):(n=t.match(Asn))?i=r.dot?Esn:hsn:(n=t.match(_sn))&&(i=ysn);let o=Hv.fromGlob(t,this.options).toMMPattern();return i&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:i}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?Nsn:r.dot?Bsn:Osn,i=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let c=l.map(f=>{if(f instanceof RegExp)for(let g of f.flags.split(""))i.add(g);return typeof f=="string"?Lsn(f):f===Kc?Kc:f._src});c.forEach((f,g)=>{let m=c[g+1],A=c[g-1];f!==Kc||A===Kc||(A===void 0?m!==void 0&&m!==Kc?c[g+1]="(?:\\/|"+n+"\\/)?"+m:c[g]=n:m===void 0?c[g-1]=A+"(?:\\/|\\/"+n+")?":m!==Kc&&(c[g-1]=A+"(?:\\/|\\/"+n+"\\/)"+m,c[g+1]=Kc))});let u=c.filter(f=>f!==Kc);if(this.partial&&u.length>=1){let f=[];for(let g=1;g<=u.length;g++)f.push(u.slice(0,g).join("/"));return"(?:"+f.join("|")+")"}return u.join("/")}).join("|"),[s,a]=t.length>1?["(?:",")"]:["",""];o="^"+s+o+a+"$",this.partial&&(o="^(?:\\/|"+s+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let o=this.set;this.debug(this.pattern,"set",o);let s=i[i.length-1];if(!s)for(let a=i.length-2;!s&&a>=0;a--)s=i[a];for(let a of o){let l=i;if(n.matchBase&&a.length===1&&(l=[s]),this.matchOne(l,a,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return gc.defaults(t).Minimatch}};gc.AST=Hv;gc.Minimatch=q2;gc.escape=cTe;gc.unescape=lS;var oEt=ee(J5(),1);_r();Ue();Qe();Tu();import{readFile as nEt}from"fs/promises";import{existsSync as uTe,readdirSync as Fsn,statSync as Usn}from"fs";import{join as dTe,relative as sEt}from"path";import{homedir as Hsn}from"os";function iEt(e){try{let t=(0,oEt.default)(e),r=t.data.paths,n=[];return typeof r=="string"?n=r.split(",").map(i=>i.trim()).filter(Boolean):Array.isArray(r)&&(n=r.filter(i=>typeof i=="string")),{paths:n,content:t.content.trim()}}catch(t){return Te(t),{paths:[],content:e.trim()}}}function $sn(e,t){return t.length===0?!0:t.some(r=>{try{return gc(e,r,{matchBase:!0,dot:!0})}catch(n){return Te(n),!1}})}function fTe(e){let t=[];try{if(!uTe(e))return t;let r=Fsn(e);for(let n of r){let i=dTe(e,n),o=Usn(i);o.isDirectory()?t.push(...fTe(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){Te(r)}return t}async function dX(){let e=[];try{let t=dTe(Hsn(),en,"rules");if(uTe(t)){let r=fTe(t);for(let n of r)try{let i=await nEt(n,"utf-8"),{paths:o,content:s}=iEt(i);o.length>0&&e.push({filePath:n,content:s,paths:o,isProjectRule:!1})}catch(i){Te(i)}}}catch(t){Te(t)}try{let t=dTe(Re(),en,"rules");if(uTe(t)){let r=fTe(t);for(let n of r)try{let i=await nEt(n,"utf-8"),{paths:o,content:s}=iEt(i);o.length>0&&e.push({filePath:sEt(Re(),n),content:s,paths:o,isProjectRule:!0})}catch(i){Te(i)}}}catch(t){Te(t)}return e}function aEt(e,t){e=OV(e);let r=OV(Re()),n=e.startsWith(r)?sEt(r,e):e;return t.filter(i=>$sn(n,i.paths))}function lEt(e){return e.length===0?"":e.map(r=>{let n=r.isProjectRule?"project instructions, checked into the codebase":"user's private global instructions for all projects";return`Contents of ${r.filePath} (${n}):
762
762
 
763
763
  ${r.content}`}).join(`
764
764
 
@@ -1131,7 +1131,7 @@ You are powered by the model ${e}.`}async function fx(){return t9()?`gitStatus:
1131
1131
  <context name="${c}">${u}</context>`;let s=i.map(c=>{let u=c.prompt({},t),f=JSON.stringify("inputJSONSchema"in c&&c.inputJSONSchema?c.inputJSONSchema:l0(c.inputSchema));return{name:c.name,description:`${u}
1132
1132
 
1133
1133
  Schema:
1134
- ${f}`}}),{messages:a}=t,l=hdn(o);return Edn(o,l,s,a)}},lbt=_dn;zg();var Fu=ee(ge(),1),yO=ee(ge(),1);Qe();Qe();import{existsSync as ydn,readdirSync as bdn,statSync as Cdn}from"fs";import{join as Sdn}from"path";function Idn(){let e=Zi.plan();if(!ydn(e))return[];try{return bdn(e).filter(r=>r.endsWith(".md")).map(r=>{let n=Sdn(e,r),i=Cdn(n);return{name:r,path:n,modified:i.mtime}}).sort((r,n)=>n.modified.getTime()-r.modified.getTime())}catch{return[]}}var cbt=({onSelect:e})=>{let[t,r]=(0,yO.useState)([]),[n,i]=(0,yO.useState)(0),[o,s]=(0,yO.useState)(!1);(0,yO.useEffect)(()=>{let c=Idn();r(c),s(!0)},[]);let a=[{label:"New plan",value:"__NEW_PLAN__",isNew:!0},...t.map(c=>({label:c.name,value:c.path,isNew:!1,modified:c.modified}))];sr((c,u)=>{if(u.upArrow)i(f=>f>0?f-1:a.length-1);else if(u.downArrow)i(f=>f<a.length-1?f+1:0);else if(u.return){let f=a[n];f&&e(f.value)}else u.escape&&e("__CANCELLED__")});let l=Ne();return o?Fu.createElement(R,{flexDirection:"column",marginY:1},Fu.createElement(R,{marginBottom:1},Fu.createElement(v,{bold:!0,color:l.claude},"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),Fu.createElement(R,{marginBottom:1},Fu.createElement(v,{bold:!0,color:l.claude}," Select a plan to continue, or create a new one")),a.map((c,u)=>{let f=u===n;return Fu.createElement(R,{key:c.isNew?"new":c.value,flexDirection:"row",marginLeft:2},Fu.createElement(v,{color:f?l.claude:l.text},f?"\u276F":" "),Fu.createElement(v,{color:f?l.claude:l.text}," "),Fu.createElement(v,{color:f?l.claude:l.text,bold:c.isNew},c.isNew?c.label:c.label.replace(".md","")),!c.isNew&&c.modified&&Fu.createElement(v,{dimColor:!0}," ","(",rAe(c.modified),")"))}),Fu.createElement(R,{marginTop:1,marginLeft:2},Fu.createElement(v,{dimColor:!0},"\u2191/\u2193 to select \xB7 Enter to confirm \xB7 Esc to cancel"))):Fu.createElement(R,{flexDirection:"column",marginY:1},Fu.createElement(v,null,"Loading plan history..."))};var ubt=ee(ge(),1),Tdn={type:"local-jsx",name:"plan",description:()=>"Enable plan mode",isEnabled:!0,isHidden:!1,disableCancel:!0,async call(e){return vi.isPlanMode()?(e("Already in plan mode."),null):ubt.createElement(cbt,{onSelect:t=>{if(t==="__CANCELLED__"){e("Cancelled.");return}t&&t!=="__NEW_PLAN__"?vi.setCurrentPlanFilePath(t):vi.generatePlanFilePath(),vi.setMode("plan",!0,!1),e("Enabled plan mode")}})},userFacingName(){return"plan"}},dbt=Tdn;zg();var vdn={type:"local",name:"auto",description:()=>"Enable auto mode",isEnabled:!0,isHidden:!1,async call(){return vi.isAutoMode()?"Already in auto mode.":(vi.setMode("auto",!0),"Enabled auto mode")},userFacingName(){return"auto"}},fbt=vdn;_r();import{resolve as xdn}from"path";var wdn={type:"local",name:"cd",description:()=>"Move this session to a new working directory",isEnabled:!0,isHidden:!1,argNames:["path"],async call(e){let t=e.trim();if(t==="")throw new Error("Missing directory path. Usage: /cd <path>");let r=Re(),n=xdn(r,t);ua(n);let i=Re();return i===r?`Already in ${i}.`:`Changed directory to ${i}/`},userFacingName(){return"cd"}},pbt=wdn;var GSt=ee(ge(),1);var $n=ee(ge(),1);var sfn=ee(ge(),1);var L9=ee(ge(),1),nfn=ee(hbt(),1);var Ebt={info:"blue",success:"green",error:"red",warning:"yellow"},$dn={styles:{container:({variant:e})=>({flexGrow:1,borderStyle:"round",borderColor:Ebt[e],gap:1,paddingX:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:Ebt[e]}),content:()=>({flexShrink:1,flexGrow:1,minWidth:0,flexDirection:"column",gap:1}),title:()=>({bold:!0}),message:()=>({})},config({variant:e}){let t;return e==="info"&&(t=Jt.info),e==="success"&&(t=Jt.tick),e==="error"&&(t=Jt.cross),e==="warning"&&(t=Jt.warning),{icon:t}}},_bt=$dn;var qdn={styles:{container:({color:e})=>({backgroundColor:e}),label:()=>({color:"black"})}},ybt=qdn;var Gdn={styles:{input:({isFocused:e})=>({dimColor:!e})}},bbt=Gdn;var zdn={styles:{container:()=>({flexDirection:"column"}),option:({isFocused:e})=>({gap:1,paddingLeft:e?0:2}),selectedIndicator:()=>({color:"green"}),focusIndicator:()=>({color:"blue"}),label({isFocused:e,isSelected:t}){let r;return t&&(r="green"),e&&(r="blue"),{color:r}},highlightedText:()=>({bold:!0})}},Cbt=zdn;var jdn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})}},Sbt=jdn;var Ydn={styles:{container:()=>({flexGrow:1,minWidth:0}),completed:()=>({color:"magenta"}),remaining:()=>({dimColor:!0})},config:()=>({completedCharacter:Jt.square,remainingCharacter:Jt.squareLightShade})},Ibt=Ydn;var Vdn={styles:{container:()=>({flexDirection:"column"}),option:({isFocused:e})=>({gap:1,paddingLeft:e?0:2}),selectedIndicator:()=>({color:"green"}),focusIndicator:()=>({color:"blue"}),label({isFocused:e,isSelected:t}){let r;return t&&(r="green"),e&&(r="blue"),{color:r}},highlightedText:()=>({bold:!0})}},Tbt=Vdn;var Wdn={styles:{container:()=>({gap:1}),frame:()=>({color:"blue"}),label:()=>({})}},vbt=Wdn;var Kdn={success:"green",error:"red",warning:"yellow",info:"blue"},Jdn={success:Jt.tick,error:Jt.cross,warning:Jt.warning,info:Jt.info},Zdn={styles:{container:()=>({gap:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:Kdn[e]}),message:()=>({})},config:({variant:e})=>({icon:Jdn[e]})},xbt=Zdn;var Xdn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})},config:()=>({marker:Jt.line})},wbt=Xdn;var efn={styles:{value:()=>({})}},Dbt=efn;var tfn={styles:{value:()=>({})}},Rbt=tfn;var rfn={styles:{value:()=>({})}},Nbt=rfn;var ifn={components:{Alert:_bt,Badge:ybt,ConfirmInput:bbt,MultiSelect:Cbt,OrderedList:Sbt,ProgressBar:Ibt,Select:Tbt,Spinner:vbt,StatusMessage:xbt,UnorderedList:wbt,TextInput:Dbt,EmailInput:Rbt,PasswordInput:Nbt}},ofn=(0,L9.createContext)(ifn);var mo=e=>(0,L9.useContext)(ofn).components[e];var afn=ee(ge(),1);var N_=ee(ge(),1);var CO=ee(ge(),1);var Bbt=ee(ge(),1);var F9=Jt.line;var gee=(0,Bbt.createContext)({marker:F9});function Obt({children:e}){let{marker:t}=(0,CO.useContext)(gee),{styles:r}=mo("UnorderedList");return CO.default.createElement(R,{...r.listItem()},CO.default.createElement(v,{...r.marker()},t),CO.default.createElement(R,{...r.content()},e))}var kbt=ee(ge(),1),Jve=(0,kbt.createContext)({depth:0});function lfn({children:e}){let{depth:t}=(0,N_.useContext)(Jve),{styles:r,config:n}=mo("UnorderedList"),i=(0,N_.useMemo)(()=>({depth:t+1}),[t]),o=(0,N_.useMemo)(()=>{let{marker:s}=n();return typeof s=="string"?{marker:s}:Array.isArray(s)?{marker:s[t]??s.at(-1)??F9}:{marker:F9}},[n,t]);return N_.default.createElement(Jve.Provider,{value:i},N_.default.createElement(gee.Provider,{value:o},N_.default.createElement(R,{...r.list()},e)))}lfn.Item=Obt;var ufn=ee(ge(),1);var cfn=ee(ge(),1);var U9=ee(ge(),1);var SO=class extends Map{first;constructor(t){let r=[],n,i,o=0;for(let s of t){let a={...s,previous:i,next:void 0,index:o};i&&(i.next=a),n||=a,r.push([s.value,a]),o++,i=a}super(r),this.first=n}};var Mbt=ee(ge(),1);var IO=ee(ge(),1);var H9=ee(ge(),1);function Qbt({isFocused:e,isSelected:t,children:r}){let{styles:n}=mo("Select");return H9.default.createElement(R,{...n.option({isFocused:e})},e&&H9.default.createElement(v,{...n.focusIndicator()},Jt.pointer),H9.default.createElement(v,{...n.label({isFocused:e,isSelected:t})},r),t&&H9.default.createElement(v,{...n.selectedIndicator()},Jt.tick))}var xm=ee(ge(),1);import{isDeepStrictEqual as dfn}from"node:util";var ffn=(e,t)=>{switch(t.type){case"focus-next-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.next;if(!n)return e;if(!(n.index>=e.visibleToIndex))return{...e,focusedValue:n.value};let o=Math.min(e.optionMap.size,e.visibleToIndex+1),s=o-e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:s,visibleToIndex:o}}case"focus-previous-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.previous;if(!n)return e;if(!(n.index<=e.visibleFromIndex))return{...e,focusedValue:n.value};let o=Math.max(0,e.visibleFromIndex-1),s=o+e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:o,visibleToIndex:s}}case"select-focused-option":return{...e,previousValue:e.value,value:e.focusedValue};case"reset":return t.state}},Pbt=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=typeof e=="number"?Math.min(e,r.length):r.length,i=new SO(r);return{optionMap:i,visibleOptionCount:n,focusedValue:i.first?.value,visibleFromIndex:0,visibleToIndex:n,previousValue:t,value:t}},Lbt=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n})=>{let[i,o]=(0,xm.useReducer)(ffn,{visibleOptionCount:e,defaultValue:r,options:t},Pbt),[s,a]=(0,xm.useState)(t);t!==s&&!dfn(t,s)&&(o({type:"reset",state:Pbt({visibleOptionCount:e,defaultValue:r,options:t})}),a(t));let l=(0,xm.useCallback)(()=>{o({type:"focus-next-option"})},[]),c=(0,xm.useCallback)(()=>{o({type:"focus-previous-option"})},[]),u=(0,xm.useCallback)(()=>{o({type:"select-focused-option"})},[]),f=(0,xm.useMemo)(()=>t.map((g,m)=>({...g,index:m})).slice(i.visibleFromIndex,i.visibleToIndex),[t,i.visibleFromIndex,i.visibleToIndex]);return(0,xm.useEffect)(()=>{i.value&&i.previousValue!==i.value&&n?.(i.value)},[i.previousValue,i.value,t,n]),{focusedValue:i.focusedValue,visibleFromIndex:i.visibleFromIndex,visibleToIndex:i.visibleToIndex,value:i.value,visibleOptions:f,focusNextOption:l,focusPreviousOption:c,selectFocusedOption:u}};var Fbt=({isDisabled:e=!1,state:t})=>{sr((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};function TO({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:i,onChange:o}){let s=Lbt({visibleOptionCount:t,options:n,defaultValue:i,onChange:o});Fbt({isDisabled:e,state:s});let{styles:a}=mo("Select");return IO.default.createElement(R,{...a.container()},s.visibleOptions.map(l=>{let c=l.label;if(r&&l.label.includes(r)){let u=l.label.indexOf(r);c=IO.default.createElement(IO.default.Fragment,null,l.label.slice(0,u),IO.default.createElement(v,{...a.highlightedText()},r),l.label.slice(u+r.length))}return IO.default.createElement(Qbt,{key:l.value,isFocused:!e&&s.focusedValue===l.value,isSelected:s.value===l.value},c)}))}var pfn=ee(ge(),1);var Ubt=ee(ge(),1);var gfn=ee(ge(),1);var Aee=ee(ge(),1);var mfn=ee(ge(),1);var jki=ur.inverse(" ");var Kg=ee(ge(),1);var vO=ee(ge(),1);var Hbt=ee(ge(),1);var hee=(0,Hbt.createContext)({marker:Jt.line});function Eee({children:e}){let{marker:t}=(0,vO.useContext)(hee),{styles:r}=mo("OrderedList");return vO.default.createElement(R,{...r.listItem()},vO.default.createElement(v,{...r.marker()},t),vO.default.createElement(R,{...r.content()},e))}var $bt=ee(ge(),1),Zve=(0,$bt.createContext)({marker:""});function Jg({children:e}){let{marker:t}=(0,Kg.useContext)(Zve),{styles:r}=mo("OrderedList"),n=0;for(let o of Kg.default.Children.toArray(e))!(0,Kg.isValidElement)(o)||o.type!==Eee||n++;let i=String(n).length;return Kg.default.createElement(R,{...r.list()},Kg.default.Children.map(e,(o,s)=>{if(!(0,Kg.isValidElement)(o)||o.type!==Eee)return o;let a=`${String(s+1).padStart(i)}.`,l=`${t}${a}`;return Kg.default.createElement(Zve.Provider,{value:{marker:l}},Kg.default.createElement(hee.Provider,{value:{marker:l}},o))}))}Jg.Item=Eee;var hfn=ee(ge(),1);var Xve=ee(ge(),1);var Afn=ee(ge(),1);var bMi=ur.inverse(" ");var Efn=ee(ge(),1);var _fn=ee(ge(),1);var bfn=ee(ge(),1);var _ee=ee(ge(),1);var yfn=ee(ge(),1);var zMi=ur.inverse(" ");var qi=ee(ge(),1);var exe=ee(ge(),1),txe=ee(ge(),1);n9();Rs();Pi();tx();dr();var Cfn=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function ES(){let e=Cfn,{frame:t}=wR({interval:120});return exe.createElement(R,{flexWrap:"nowrap",height:1,width:2},exe.createElement(v,{color:Ne().claude},e[t%e.length]))}var Cee=ee(ge(),1);var bee=null,B_=null,yee=new Set;function nxe(e){let{columns:t,rows:r}=e;if(t&&r)return{columns:t,rows:r};let n=Gpe();return{columns:t||n.columns||80,rows:r||n.rows||24}}function rxe(){B_&&(bee=nxe(B_),yee.forEach(e=>e(bee)))}function Sfn(e,t){return B_!==e&&(B_&&B_.off("resize",rxe),B_=e,bee=nxe(e),e.on("resize",rxe)),yee.add(t),()=>{yee.delete(t),yee.size===0&&B_&&(B_.off("resize",rxe),B_=null,bee=null)}}function ixe(){let{stdout:e}=xb(),[t,r]=(0,Cee.useState)(()=>nxe(e));return(0,Cee.useEffect)(()=>Sfn(e,r),[e]),t}function See(){return ixe()}Ue();Rf();Qe();dh();Qe();var kPi=ee(RSt(),1);import{homedir as K9}from"os";import{join as DO}from"path";import{existsSync as J9,mkdirSync as BSt,appendFileSync as NSt,readFileSync as OSt,constants as ygn,writeFileSync as bgn,unlinkSync as kSt,statSync as Cgn}from"fs";import{platform as MSt}from"process";import{accessSync as Sgn}from"fs";var _gn="2.4.46",W9={VERSION:_gn,PACKAGE_URL:"@dahawa/hawa-code",README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};Ue();var mx=DO(G0,".update.lock"),Ign=300*1e3;function QSt(){try{if(J9(G0)||BSt(G0,{recursive:!0}),J9(mx)){let e=Cgn(mx);if(Date.now()-e.mtimeMs<Ign)return!1;try{kSt(mx)}catch(r){return Te(`Failed to remove stale lock file: ${r}`),!1}}return bgn(mx,`${process.pid}`,"utf8"),!0}catch(e){return Te(`Failed to acquire lock: ${e}`),!1}}function PSt(){try{J9(mx)&&OSt(mx,"utf8")===`${process.pid}`&&kSt(mx)}catch(e){Te(`Failed to release lock: ${e}`)}}async function Txe(){try{let e=await ai("npm -g config get prefix");if(e.code!==0)return Te("Failed to check npm permissions"),{hasPermissions:!1,npmPrefix:null};let t=e.stdout.trim(),r=!1;try{Sgn(t,ygn.W_OK),r=!0}catch{r=!1}return r?{hasPermissions:!0,npmPrefix:t}:(Te("Insufficient permissions for global npm install."),{hasPermissions:!1,npmPrefix:t})}catch(e){return Te(`Failed to verify npm global install permissions: ${e}`),{hasPermissions:!1,npmPrefix:null}}}async function LSt(e){if(!QSt())throw Rt("tengu_auto_updater_prefix_lock_contention",{pid:String(process.pid),currentVersion:W9.VERSION,prefix:e}),new Error("Another process is currently setting up npm prefix");try{J9(e)||BSt(e,{recursive:!0});let t=await ai(`npm -g config set prefix ${e}`);if(t.code!==0)throw new Error(`Failed to set npm prefix: ${t.stderr}`);let r=`
1134
+ ${f}`}}),{messages:a}=t,l=hdn(o);return Edn(o,l,s,a)}},lbt=_dn;zg();var Fu=ee(ge(),1),yO=ee(ge(),1);Qe();Qe();import{existsSync as ydn,readdirSync as bdn,statSync as Cdn}from"fs";import{join as Sdn}from"path";function Idn(){let e=Zi.plan();if(!ydn(e))return[];try{return bdn(e).filter(r=>r.endsWith(".md")).map(r=>{let n=Sdn(e,r),i=Cdn(n);return{name:r,path:n,modified:i.mtime}}).sort((r,n)=>n.modified.getTime()-r.modified.getTime())}catch{return[]}}var cbt=({onSelect:e})=>{let[t,r]=(0,yO.useState)([]),[n,i]=(0,yO.useState)(0),[o,s]=(0,yO.useState)(!1);(0,yO.useEffect)(()=>{let c=Idn();r(c),s(!0)},[]);let a=[{label:"New plan",value:"__NEW_PLAN__",isNew:!0},...t.map(c=>({label:c.name,value:c.path,isNew:!1,modified:c.modified}))];sr((c,u)=>{if(u.upArrow)i(f=>f>0?f-1:a.length-1);else if(u.downArrow)i(f=>f<a.length-1?f+1:0);else if(u.return){let f=a[n];f&&e(f.value)}else u.escape&&e("__CANCELLED__")});let l=Ne();return o?Fu.createElement(R,{flexDirection:"column",marginY:1},Fu.createElement(R,{marginBottom:1},Fu.createElement(v,{bold:!0,color:l.claude},"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),Fu.createElement(R,{marginBottom:1},Fu.createElement(v,{bold:!0,color:l.claude}," Select a plan to continue, or create a new one")),a.map((c,u)=>{let f=u===n;return Fu.createElement(R,{key:c.isNew?"new":c.value,flexDirection:"row",marginLeft:2},Fu.createElement(v,{color:f?l.claude:l.text},f?"\u276F":" "),Fu.createElement(v,{color:f?l.claude:l.text}," "),Fu.createElement(v,{color:f?l.claude:l.text,bold:c.isNew},c.isNew?c.label:c.label.replace(".md","")),!c.isNew&&c.modified&&Fu.createElement(v,{dimColor:!0}," ","(",rAe(c.modified),")"))}),Fu.createElement(R,{marginTop:1,marginLeft:2},Fu.createElement(v,{dimColor:!0},"\u2191/\u2193 to select \xB7 Enter to confirm \xB7 Esc to cancel"))):Fu.createElement(R,{flexDirection:"column",marginY:1},Fu.createElement(v,null,"Loading plan history..."))};var ubt=ee(ge(),1),Tdn={type:"local-jsx",name:"plan",description:()=>"Enable plan mode",isEnabled:!0,isHidden:!1,disableCancel:!0,async call(e){return vi.isPlanMode()?(e("Already in plan mode."),null):ubt.createElement(cbt,{onSelect:t=>{if(t==="__CANCELLED__"){e("Cancelled.");return}t&&t!=="__NEW_PLAN__"?vi.setCurrentPlanFilePath(t):vi.generatePlanFilePath(),vi.setMode("plan",!0,!1),e("Enabled plan mode")}})},userFacingName(){return"plan"}},dbt=Tdn;zg();var vdn={type:"local",name:"auto",description:()=>"Enable auto mode",isEnabled:!0,isHidden:!1,async call(){return vi.isAutoMode()?"Already in auto mode.":(vi.setMode("auto",!0),"Enabled auto mode")},userFacingName(){return"auto"}},fbt=vdn;_r();import{resolve as xdn}from"path";var wdn={type:"local",name:"cd",description:()=>"Move this session to a new working directory",isEnabled:!0,isHidden:!1,argNames:["path"],async call(e){let t=e.trim();if(t==="")throw new Error("Missing directory path. Usage: /cd <path>");let r=Re(),n=xdn(r,t);ua(n);let i=Re();return i===r?`Already in ${i}.`:`Changed directory to ${i}/`},userFacingName(){return"cd"}},pbt=wdn;var GSt=ee(ge(),1);var $n=ee(ge(),1);var sfn=ee(ge(),1);var L9=ee(ge(),1),nfn=ee(hbt(),1);var Ebt={info:"blue",success:"green",error:"red",warning:"yellow"},$dn={styles:{container:({variant:e})=>({flexGrow:1,borderStyle:"round",borderColor:Ebt[e],gap:1,paddingX:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:Ebt[e]}),content:()=>({flexShrink:1,flexGrow:1,minWidth:0,flexDirection:"column",gap:1}),title:()=>({bold:!0}),message:()=>({})},config({variant:e}){let t;return e==="info"&&(t=Jt.info),e==="success"&&(t=Jt.tick),e==="error"&&(t=Jt.cross),e==="warning"&&(t=Jt.warning),{icon:t}}},_bt=$dn;var qdn={styles:{container:({color:e})=>({backgroundColor:e}),label:()=>({color:"black"})}},ybt=qdn;var Gdn={styles:{input:({isFocused:e})=>({dimColor:!e})}},bbt=Gdn;var zdn={styles:{container:()=>({flexDirection:"column"}),option:({isFocused:e})=>({gap:1,paddingLeft:e?0:2}),selectedIndicator:()=>({color:"green"}),focusIndicator:()=>({color:"blue"}),label({isFocused:e,isSelected:t}){let r;return t&&(r="green"),e&&(r="blue"),{color:r}},highlightedText:()=>({bold:!0})}},Cbt=zdn;var jdn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})}},Sbt=jdn;var Ydn={styles:{container:()=>({flexGrow:1,minWidth:0}),completed:()=>({color:"magenta"}),remaining:()=>({dimColor:!0})},config:()=>({completedCharacter:Jt.square,remainingCharacter:Jt.squareLightShade})},Ibt=Ydn;var Vdn={styles:{container:()=>({flexDirection:"column"}),option:({isFocused:e})=>({gap:1,paddingLeft:e?0:2}),selectedIndicator:()=>({color:"green"}),focusIndicator:()=>({color:"blue"}),label({isFocused:e,isSelected:t}){let r;return t&&(r="green"),e&&(r="blue"),{color:r}},highlightedText:()=>({bold:!0})}},Tbt=Vdn;var Wdn={styles:{container:()=>({gap:1}),frame:()=>({color:"blue"}),label:()=>({})}},vbt=Wdn;var Kdn={success:"green",error:"red",warning:"yellow",info:"blue"},Jdn={success:Jt.tick,error:Jt.cross,warning:Jt.warning,info:Jt.info},Zdn={styles:{container:()=>({gap:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:Kdn[e]}),message:()=>({})},config:({variant:e})=>({icon:Jdn[e]})},xbt=Zdn;var Xdn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})},config:()=>({marker:Jt.line})},wbt=Xdn;var efn={styles:{value:()=>({})}},Dbt=efn;var tfn={styles:{value:()=>({})}},Rbt=tfn;var rfn={styles:{value:()=>({})}},Nbt=rfn;var ifn={components:{Alert:_bt,Badge:ybt,ConfirmInput:bbt,MultiSelect:Cbt,OrderedList:Sbt,ProgressBar:Ibt,Select:Tbt,Spinner:vbt,StatusMessage:xbt,UnorderedList:wbt,TextInput:Dbt,EmailInput:Rbt,PasswordInput:Nbt}},ofn=(0,L9.createContext)(ifn);var mo=e=>(0,L9.useContext)(ofn).components[e];var afn=ee(ge(),1);var N_=ee(ge(),1);var CO=ee(ge(),1);var Bbt=ee(ge(),1);var F9=Jt.line;var gee=(0,Bbt.createContext)({marker:F9});function Obt({children:e}){let{marker:t}=(0,CO.useContext)(gee),{styles:r}=mo("UnorderedList");return CO.default.createElement(R,{...r.listItem()},CO.default.createElement(v,{...r.marker()},t),CO.default.createElement(R,{...r.content()},e))}var kbt=ee(ge(),1),Jve=(0,kbt.createContext)({depth:0});function lfn({children:e}){let{depth:t}=(0,N_.useContext)(Jve),{styles:r,config:n}=mo("UnorderedList"),i=(0,N_.useMemo)(()=>({depth:t+1}),[t]),o=(0,N_.useMemo)(()=>{let{marker:s}=n();return typeof s=="string"?{marker:s}:Array.isArray(s)?{marker:s[t]??s.at(-1)??F9}:{marker:F9}},[n,t]);return N_.default.createElement(Jve.Provider,{value:i},N_.default.createElement(gee.Provider,{value:o},N_.default.createElement(R,{...r.list()},e)))}lfn.Item=Obt;var ufn=ee(ge(),1);var cfn=ee(ge(),1);var U9=ee(ge(),1);var SO=class extends Map{first;constructor(t){let r=[],n,i,o=0;for(let s of t){let a={...s,previous:i,next:void 0,index:o};i&&(i.next=a),n||=a,r.push([s.value,a]),o++,i=a}super(r),this.first=n}};var Mbt=ee(ge(),1);var IO=ee(ge(),1);var H9=ee(ge(),1);function Qbt({isFocused:e,isSelected:t,children:r}){let{styles:n}=mo("Select");return H9.default.createElement(R,{...n.option({isFocused:e})},e&&H9.default.createElement(v,{...n.focusIndicator()},Jt.pointer),H9.default.createElement(v,{...n.label({isFocused:e,isSelected:t})},r),t&&H9.default.createElement(v,{...n.selectedIndicator()},Jt.tick))}var xm=ee(ge(),1);import{isDeepStrictEqual as dfn}from"node:util";var ffn=(e,t)=>{switch(t.type){case"focus-next-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.next;if(!n)return e;if(!(n.index>=e.visibleToIndex))return{...e,focusedValue:n.value};let o=Math.min(e.optionMap.size,e.visibleToIndex+1),s=o-e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:s,visibleToIndex:o}}case"focus-previous-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.previous;if(!n)return e;if(!(n.index<=e.visibleFromIndex))return{...e,focusedValue:n.value};let o=Math.max(0,e.visibleFromIndex-1),s=o+e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:o,visibleToIndex:s}}case"select-focused-option":return{...e,previousValue:e.value,value:e.focusedValue};case"reset":return t.state}},Pbt=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=typeof e=="number"?Math.min(e,r.length):r.length,i=new SO(r);return{optionMap:i,visibleOptionCount:n,focusedValue:i.first?.value,visibleFromIndex:0,visibleToIndex:n,previousValue:t,value:t}},Lbt=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n})=>{let[i,o]=(0,xm.useReducer)(ffn,{visibleOptionCount:e,defaultValue:r,options:t},Pbt),[s,a]=(0,xm.useState)(t);t!==s&&!dfn(t,s)&&(o({type:"reset",state:Pbt({visibleOptionCount:e,defaultValue:r,options:t})}),a(t));let l=(0,xm.useCallback)(()=>{o({type:"focus-next-option"})},[]),c=(0,xm.useCallback)(()=>{o({type:"focus-previous-option"})},[]),u=(0,xm.useCallback)(()=>{o({type:"select-focused-option"})},[]),f=(0,xm.useMemo)(()=>t.map((g,m)=>({...g,index:m})).slice(i.visibleFromIndex,i.visibleToIndex),[t,i.visibleFromIndex,i.visibleToIndex]);return(0,xm.useEffect)(()=>{i.value&&i.previousValue!==i.value&&n?.(i.value)},[i.previousValue,i.value,t,n]),{focusedValue:i.focusedValue,visibleFromIndex:i.visibleFromIndex,visibleToIndex:i.visibleToIndex,value:i.value,visibleOptions:f,focusNextOption:l,focusPreviousOption:c,selectFocusedOption:u}};var Fbt=({isDisabled:e=!1,state:t})=>{sr((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};function TO({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:i,onChange:o}){let s=Lbt({visibleOptionCount:t,options:n,defaultValue:i,onChange:o});Fbt({isDisabled:e,state:s});let{styles:a}=mo("Select");return IO.default.createElement(R,{...a.container()},s.visibleOptions.map(l=>{let c=l.label;if(r&&l.label.includes(r)){let u=l.label.indexOf(r);c=IO.default.createElement(IO.default.Fragment,null,l.label.slice(0,u),IO.default.createElement(v,{...a.highlightedText()},r),l.label.slice(u+r.length))}return IO.default.createElement(Qbt,{key:l.value,isFocused:!e&&s.focusedValue===l.value,isSelected:s.value===l.value},c)}))}var pfn=ee(ge(),1);var Ubt=ee(ge(),1);var gfn=ee(ge(),1);var Aee=ee(ge(),1);var mfn=ee(ge(),1);var jki=ur.inverse(" ");var Kg=ee(ge(),1);var vO=ee(ge(),1);var Hbt=ee(ge(),1);var hee=(0,Hbt.createContext)({marker:Jt.line});function Eee({children:e}){let{marker:t}=(0,vO.useContext)(hee),{styles:r}=mo("OrderedList");return vO.default.createElement(R,{...r.listItem()},vO.default.createElement(v,{...r.marker()},t),vO.default.createElement(R,{...r.content()},e))}var $bt=ee(ge(),1),Zve=(0,$bt.createContext)({marker:""});function Jg({children:e}){let{marker:t}=(0,Kg.useContext)(Zve),{styles:r}=mo("OrderedList"),n=0;for(let o of Kg.default.Children.toArray(e))!(0,Kg.isValidElement)(o)||o.type!==Eee||n++;let i=String(n).length;return Kg.default.createElement(R,{...r.list()},Kg.default.Children.map(e,(o,s)=>{if(!(0,Kg.isValidElement)(o)||o.type!==Eee)return o;let a=`${String(s+1).padStart(i)}.`,l=`${t}${a}`;return Kg.default.createElement(Zve.Provider,{value:{marker:l}},Kg.default.createElement(hee.Provider,{value:{marker:l}},o))}))}Jg.Item=Eee;var hfn=ee(ge(),1);var Xve=ee(ge(),1);var Afn=ee(ge(),1);var bMi=ur.inverse(" ");var Efn=ee(ge(),1);var _fn=ee(ge(),1);var bfn=ee(ge(),1);var _ee=ee(ge(),1);var yfn=ee(ge(),1);var zMi=ur.inverse(" ");var qi=ee(ge(),1);var exe=ee(ge(),1),txe=ee(ge(),1);n9();Rs();Pi();tx();dr();var Cfn=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function ES(){let e=Cfn,{frame:t}=wR({interval:120});return exe.createElement(R,{flexWrap:"nowrap",height:1,width:2},exe.createElement(v,{color:Ne().claude},e[t%e.length]))}var Cee=ee(ge(),1);var bee=null,B_=null,yee=new Set;function nxe(e){let{columns:t,rows:r}=e;if(t&&r)return{columns:t,rows:r};let n=Gpe();return{columns:t||n.columns||80,rows:r||n.rows||24}}function rxe(){B_&&(bee=nxe(B_),yee.forEach(e=>e(bee)))}function Sfn(e,t){return B_!==e&&(B_&&B_.off("resize",rxe),B_=e,bee=nxe(e),e.on("resize",rxe)),yee.add(t),()=>{yee.delete(t),yee.size===0&&B_&&(B_.off("resize",rxe),B_=null,bee=null)}}function ixe(){let{stdout:e}=xb(),[t,r]=(0,Cee.useState)(()=>nxe(e));return(0,Cee.useEffect)(()=>Sfn(e,r),[e]),t}function See(){return ixe()}Ue();Rf();Qe();dh();Qe();var kPi=ee(RSt(),1);import{homedir as K9}from"os";import{join as DO}from"path";import{existsSync as J9,mkdirSync as BSt,appendFileSync as NSt,readFileSync as OSt,constants as ygn,writeFileSync as bgn,unlinkSync as kSt,statSync as Cgn}from"fs";import{platform as MSt}from"process";import{accessSync as Sgn}from"fs";var _gn="2.4.47",W9={VERSION:_gn,PACKAGE_URL:"@dahawa/hawa-code",README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};Ue();var mx=DO(G0,".update.lock"),Ign=300*1e3;function QSt(){try{if(J9(G0)||BSt(G0,{recursive:!0}),J9(mx)){let e=Cgn(mx);if(Date.now()-e.mtimeMs<Ign)return!1;try{kSt(mx)}catch(r){return Te(`Failed to remove stale lock file: ${r}`),!1}}return bgn(mx,`${process.pid}`,"utf8"),!0}catch(e){return Te(`Failed to acquire lock: ${e}`),!1}}function PSt(){try{J9(mx)&&OSt(mx,"utf8")===`${process.pid}`&&kSt(mx)}catch(e){Te(`Failed to release lock: ${e}`)}}async function Txe(){try{let e=await ai("npm -g config get prefix");if(e.code!==0)return Te("Failed to check npm permissions"),{hasPermissions:!1,npmPrefix:null};let t=e.stdout.trim(),r=!1;try{Sgn(t,ygn.W_OK),r=!0}catch{r=!1}return r?{hasPermissions:!0,npmPrefix:t}:(Te("Insufficient permissions for global npm install."),{hasPermissions:!1,npmPrefix:t})}catch(e){return Te(`Failed to verify npm global install permissions: ${e}`),{hasPermissions:!1,npmPrefix:null}}}async function LSt(e){if(!QSt())throw Rt("tengu_auto_updater_prefix_lock_contention",{pid:String(process.pid),currentVersion:W9.VERSION,prefix:e}),new Error("Another process is currently setting up npm prefix");try{J9(e)||BSt(e,{recursive:!0});let t=await ai(`npm -g config set prefix ${e}`);if(t.code!==0)throw new Error(`Failed to set npm prefix: ${t.stderr}`);let r=`
1135
1135
  # npm global path
1136
1136
  export PATH="${e}/bin:$PATH"
1137
1137
  `;if(MSt==="win32"){let n=await ai(`setx PATH "${process.env.PATH};${e}"`);if(n.code!==0)throw new Error(`Failed to update PATH on Windows: ${n.stderr}`)}else{let n=[DO(K9(),".bashrc"),DO(K9(),".bash_profile"),DO(K9(),".zshrc"),DO(K9(),".config","fish","config.fish")];for(let i of n)if(J9(i))try{if(!OSt(i,"utf8").includes(e)){if(i.includes("fish")){let s=`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dahawa/hawa-code",
3
- "version": "2.4.46",
3
+ "version": "2.4.47",
4
4
  "bin": {
5
5
  "hcode": "hawa.js"
6
6
  },