@dahawa/hawa-code 2.7.4 → 2.7.5

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 +685 -685
  2. package/hands.js +2 -2
  3. package/package.json +1 -1
package/hands.js CHANGED
@@ -622,7 +622,7 @@ data: ${JSON.stringify(z)}
622
622
  `);a=P.pop()||"";for(let z of P){let Y=z.trim();if(!(!Y||Y==="data: [DONE]"))if(Y.startsWith("data: ")){let G=Y.slice(6);try{let W=JSON.parse(G);D(W)}catch(W){this.logger&&this.logger.error({err:W,line:Y},"Failed to parse Gemini SSE chunk")}}else try{let G=JSON.parse(Y);D(G)}catch{}}};(async()=>{try{for(;;){let{value:P,done:z}=await s.read();if(z)break;a+=n.decode(P,{stream:!0}),k()}T()}catch(P){o.error(P)}})()}})}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_${FN()}`,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:`
623
623
 
624
624
  [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 o3r(`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"}}},R_e=new D_e;var opt=we(rpt(),1);er();ds();function ng(e){return e?typeof e.entries=="function"?Object.fromEntries(e.entries()):{...e}:{}}function npt(e){let t=String(e?.["x-thinking-level"]??"medium").toLowerCase();return["off","low","medium","high"].includes(t)?t:"medium"}function _Xr(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t}}function yXr(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t,summary:"auto"}}function bXr(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 TU(e,t,r){mG(t,e),gG(t,bXr(e,r),r)}function xB(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 vU(e){let t=new Headers(e);return t.delete("content-encoding"),t.delete("content-length"),t.delete("transfer-encoding"),t}function i1e(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 ipt=["/v1/messages"];function o1e(e){let t;try{typeof e=="string"?t=new RT(e):e instanceof RT?t=e:t=new RT(e.url)}catch{return""}let r=t.pathname;for(let n of ipt){let i=r.indexOf(n);if(i!==-1)return t.origin+r.slice(0,i)}return t.origin}function IJ(e,t){let r=typeof e=="string"?e:e instanceof RT?e.toString():e.url,n;try{n=new RT(r).pathname}catch{return!1}return ipt.some(i=>n.includes(i))&&(t.method==="POST"||t.method==="post")}function CXr(e){return async(t,r)=>{if(!IJ(t,r))return e(t,r);let n=JSON.parse(r.body),i=await TW.transformRequestOut(n),o=o1e(t)+"/chat/completions",s=ng(r.headers),a=s.authorization??s.Authorization??"";_Xr(i,npt(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 y=await l.text();return J(`OpenAI Chat Completions API error: ${l.status}`,{url:o,errorResponse:y}),i1e("OpenAI Chat Completions API error","OPENROUTER",l.status,l.statusText,y)}let c=n.stream===!0,u=s["x-agent-id"],d={request:{url:o,method:r.method,headers:s,body:n},response:{status:l.status,statusText:l.statusText,headers:ng(l.headers)},openai:{request:{body:i},response:{}}};if(!c){let y=await l.text(),b=new Response(y,{status:l.status,statusText:l.statusText,headers:vU(l.headers)}),I=await TW.transformResponseIn(b,n),T=await I.text();try{TU({...d,openai:{...d.openai,response:{body:JSON.parse(y)}},response:{...d.response,body:JSON.parse(T)}},u)}catch(D){J("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u975E\u6D41\u5F0F):",D)}return new Response(T,{status:I.status,statusText:I.statusText,headers:I.headers})}let g=xB(l.body),m=new Response(g.stream,{status:l.status,statusText:l.statusText,headers:vU(l.headers)}),A=await TW.transformResponseIn(m,n),h=xB(A.body);return Promise.all([g.done,h.done]).then(async([y,b])=>{try{TU({...d,openai:{...d.openai,response:{body:await Bnt(y)}},response:{...d.response,body:await hF(b)}},u)}catch(I){J("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u6D41\u5F0F):"+I?.stack)}}).catch(y=>J("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Chat):"+y)),new Response(h.stream,{status:A.status,statusText:A.statusText,headers:A.headers})}}function SXr(e){return async(t,r)=>{if(!IJ(t,r))return e(t,r);let n=JSON.parse(r.body),i=await vW.transformRequestOut(n),o=ng(r.headers);yXr(i,npt(o));let s=JSON.stringify(i),l=o1e(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 I=await u.text();return J(`OpenAI Responses API error: ${u.status} ${u.statusText}`,{url:l,status:u.status,errorResponse:I}),i1e("OpenAI Responses API error","RESPONSES",u.status,u.statusText,I)}let d=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:ng(u.headers)},openai:{request:{body:i},response:{}}};if(!d){let I=await u.text(),T=new Response(I,{status:u.status,statusText:u.statusText,headers:vU(u.headers)}),D=await vW.transformResponseIn(T,n),k=await D.text();try{TU({...m,openai:{...m.openai,response:{body:JSON.parse(I)}},response:{...m.response,body:JSON.parse(k)}},g,"responses")}catch(P){J("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u975E\u6D41\u5F0F):",P)}return new Response(k,{status:D.status,statusText:D.statusText,headers:D.headers})}let A=xB(u.body),h=new Response(A.stream,{status:u.status,statusText:u.statusText,headers:vU(u.headers)}),y=await vW.transformResponseIn(h,n),b=xB(y.body);return Promise.all([A.done,b.done]).then(async([I,T])=>{try{TU({...m,openai:{...m.openai,response:{body:await Nnt(I)}},response:{...m.response,body:await hF(T)}},g,"responses")}catch(D){J("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u6D41\u5F0F):"+D?.stack)}}).catch(I=>J("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Responses):"+I)),new Response(b.stream,{status:y.status,statusText:y.statusText,headers:y.headers})}}function IXr(e){return async(t,r)=>{if(!IJ(t,r))return e(t,r);let n=JSON.parse(r.body),i=ng(r.headers),o=await R_e.transformRequestOut(n),s=JSON.stringify(o),a=o1e(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(b){throw J("gemini request error:",b),b}if(!c.ok){let b=await c.text();return J(`Gemini API error response: ${c.status} ${c.statusText}`,{url:a,status:c.status,errorResponse:b}),i1e("Gemini API error","Gemini",c.status,c.statusText,b)}let u=n.stream===!0,d=i["x-agent-id"],g={request:{url:a,method:r.method,headers:ng(r.headers),body:n},response:{status:c.status,statusText:c.statusText,headers:ng(c.headers)},openai:{request:{body:o},response:{}}},m=xB(c.body),A=new Response(m.stream,{status:c.status,statusText:c.statusText,headers:vU(c.headers)}),h=await R_e.transformResponseIn(A),y=xB(h.body);return Promise.all([m.done,y.done]).then(async([b,I])=>{try{let T=u?Ont(b):JSON.parse(b),D=u?await hF(I):JSON.parse(I);TU({...g,openai:{...g.openai,response:{body:T}},response:{...g.response,body:D}},d)}catch(T){J("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Gemini):"+T?.stack)}}).catch(b=>J("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Gemini):"+b)),new Response(y.stream,{status:h.status,statusText:h.statusText,headers:h.headers})}}function TXr(e){return async(t,r)=>{if(!IJ(t,r))return e(t,r);let n=r.body;if(r.body)try{let d=JSON.parse(r.body);n=JSON.stringify(d)}catch{}let i=ng(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 d=await a.text();J(`API error response: ${a.status} ${a.statusText}`,{url:typeof t=="string"?t:t instanceof RT?t.toString():t.url,status:a.status,errorResponse:d});let g;try{let m=JSON.parse(d);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 RT?t.toString():t.url,method:r.method,headers:ng(r.headers),body:JSON.parse(n)},response:{status:a.status,statusText:a.statusText,headers:ng(a.headers)}};return(async()=>{if(c){let m=await a.text();u.response.body=await hF(m)}else u.response.body=await a.json();let g=ng(r.headers)["x-agent-id"];mG(g,u),gG(g,{request:u.request.body.messages,response:u.response.body.content,usage:u.response.body?.usage})})().catch(d=>J(`\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF:
625
- Stack trace: `+d.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var SJ=null,n1e=!1;function vXr(){SJ=null,n1e=!1}yr.on("proxy:changed",vXr);function xXr(){if(n1e)return SJ;if(n1e=!0,it().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(SJ=new opt.ProxyAgent({uri:e}),Xt(`[proxy] using proxy: ${e}`)),SJ}function wXr(){let e=xXr();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function TJ(e){let t=e||process.env.API_TYPE,r=wXr();switch(t){case"openai":return CXr(r);case"openai-responses":return SXr(r);case"gemini":return IXr(r);default:return TXr(r)}}xA();var BXr=we(tt(),1);function spt(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=DXr(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function DXr(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||RXr(t)?0:NXr(t)?2:1}function RXr(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function NXr(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 w0(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 uC(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}Qe();ds();var Ul={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function vJ(e,t){Ul.totalCost+=e,Ul.totalAPIDuration+=t}function xJ(e,t){Ul.inputTokens+=e,Ul.outputTokens+=t,yr.emit("token:change",{inputTokens:Ul.inputTokens,outputTokens:Ul.outputTokens})}function wJ(e,t){Ul.cacheCreationTokens+=e,Ul.cacheReadTokens+=t}function s1e(){return{inputTokens:Ul.inputTokens,outputTokens:Ul.outputTokens,cacheCreationTokens:Ul.cacheCreationTokens,cacheReadTokens:Ul.cacheReadTokens}}function apt(){return Ul.totalCost}function lpt(){return Date.now()-Ul.startTime}function cpt(){return Ul.totalAPIDuration}function upt(e){Ul.currentContextTokens=e}function dpt(){return Ul.currentContextTokens}Qe();Le();Le();var a1e="2.7.4";globalThis.MACRO={VERSION:a1e,PACKAGE_URL:`@dahawa/${$i}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var DJ=process.env.HAWA_CODE_USER_AGENT||`${$i}/${a1e} (${process.env.USER_TYPE})`;import{randomUUID as Uh}from"crypto";ds();Qe();Jt();hr();Qe();Le();import{existsSync as O0,readdirSync as sin,statSync as ain}from"fs";import{join as mC,relative as lin}from"path";import{homedir as rAt}from"os";import{platform as cin}from"process";import{readFile as gC}from"fs/promises";hr();Lp();er();import{join as PXr,sep as LXr}from"path";function Fp(){if(!ou())return!1;try{let e=it();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function Ef(){return(PXr(Re(),".hcode","team-memory")+LXr).normalize("NFC")}function R0(e){let t=e.normalize("NFC"),r=Ef();return t.startsWith(r)}Lp();var nAt=we(MU(),1);Ri();var I1e=(e,t,r)=>{let n=e instanceof RegExp?Rgt(e,r):e,i=t instanceof RegExp?Rgt(t,r):t,o=n!==null&&i!=null&&Krn(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)}},Rgt=(e,t)=>{let r=t.match(e);return r?r[0]:null},Krn=(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 d=n.pop();d!==void 0&&(a=[d,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 Ngt="\0SLASH"+Math.random()+"\0",Bgt="\0OPEN"+Math.random()+"\0",x1e="\0CLOSE"+Math.random()+"\0",Ogt="\0COMMA"+Math.random()+"\0",kgt="\0PERIOD"+Math.random()+"\0",Jrn=new RegExp(Ngt,"g"),Zrn=new RegExp(Bgt,"g"),Xrn=new RegExp(x1e,"g"),enn=new RegExp(Ogt,"g"),tnn=new RegExp(kgt,"g"),rnn=/\\\\/g,nnn=/\\{/g,inn=/\\}/g,onn=/\\,/g,snn=/\\\./g,ann=1e5,lnn=4e6;function T1e(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function cnn(e){return e.replace(rnn,Ngt).replace(nnn,Bgt).replace(inn,x1e).replace(onn,Ogt).replace(snn,kgt)}function unn(e){return e.replace(Jrn,"\\").replace(Zrn,"{").replace(Xrn,"}").replace(enn,",").replace(tnn,".")}function Mgt(e){if(!e)return[""];let t=[],r=I1e("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=Mgt(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function Qgt(e,t={}){if(!e)return[];let{max:r=ann,maxLength:n=lnn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),v1e(cnn(e),r,n,!0).map(unn)}function dnn(e){return"{"+e+"}"}function fnn(e){return/^-?0\d/.test(e)}function pnn(e,t){return e<=t}function mnn(e,t){return e>=t}function QU(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 gnn(e,t,r,n){let i=e.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let s=T1e(i[0]),a=T1e(i[1]),l=Math.max(i[0].length,i[1].length),c=i.length===3&&i[2]!==void 0?Math.max(Math.abs(T1e(i[2])),1):1,u=pnn;a<s&&(c*=-1,u=mnn);let g=i.some(fnn),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 y=l-h.length;if(y>0){let b=new Array(y+1).join("0");A<0?h="-"+b+h.slice(1):h=b+h}}if(m+h.length>n)break;o.push(h),m+=h.length}return o}function v1e(e,t,r,n){let i=[""],o=!1,s=!0;for(;;){let a=I1e("{","}",e);if(!a)return QU(i,e,[""],t,r,o);let l=a.pre;if(/\$$/.test(l)){if(i=QU(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),d=c||u,g=a.body.indexOf(",")>=0;if(!d&&!g){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+x1e+a.post,n=!0;continue}return QU(i,l+"{"+a.body+"}"+a.post,[""],t,r,o)}s&&(o=n&&!d,s=!1);let m;if(d)m=gnn(a.body,u,t,r);else{let A=Mgt(a.body);if(A.length===1&&A[0]!==void 0&&(A=v1e(A[0],t,r,!1).map(dnn),A.length===1)){if(i=QU(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 b=0;h&&b<i.length;b++)i[b]&&(h=!1);m=[];let y=0;e:for(let b=0;b<A.length;b++){let I=v1e(A[b],t,r,!1);for(let T=0;T<I.length;T++){let D=I[T];if(!(h&&!D)){if(m.length>=t||y+D.length>r)break e;m.push(D),y+=D.length}}}}if(i=QU(i,l,m,t,r,o&&!a.post.length),!a.post.length)break;e=a.post}return i}var PU=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Ann={"[: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]},LU=e=>e.replace(/[[\]\\-]/g,"\\$&"),hnn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Pgt=e=>e.join(""),Lgt=(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,d="";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,[b,I,T]]of Object.entries(Ann))if(e.startsWith(y,o)){if(d)return["$.",!1,e.length-r,!0];o+=y.length,T?i.push(b):n.push(b),a=a||I;continue e}}if(l=!1,d){h>d?n.push(LU(d)+"-"+LU(h)):h===d&&n.push(LU(h)),d="",o++;continue}if(e.startsWith("-]",o+1)){n.push(LU(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){d=h,o+=2;continue}n.push(LU(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[hnn(h),!1,u-r,!1]}let g="["+(c?"^":"")+Pgt(n)+"]",m="["+(c?"":"^")+Pgt(i)+"]";return[n.length&&i.length?"("+g+"|"+m+")":n.length?g:m,a,u-r,!0]};var pC=(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 cd,Enn=new Set(["!","?","+","*","@"]),w1e=e=>Enn.has(e),Fgt=e=>w1e(e.type),_nn=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),ynn=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),bnn=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),Ugt=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Cnn="(?!(?:^|/)\\.\\.?(?:$|/))",$J="(?!\\.)",Snn=new Set(["[","."]),Inn=new Set(["..","."]),Tnn=new Set("().*{}+?[]^$\\!"),vnn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),D1e="[^/]",Hgt=D1e+"*?",$gt=D1e+"+?",xnn=0,LT=class{type;#e;#t;#n=!1;#r=[];#o;#i;#l;#s=!1;#a;#d;#p=!1;id=++xnn;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 cd&&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 cd&&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 cd(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,y="";for(;h<t.length;){let b=t.charAt(h++);if(a||b==="\\"){a=!a,y+=b;continue}if(l){h===c+1?(b==="^"||b==="!")&&(u=!0):b==="]"&&!(h===c+2&&u)&&(l=!1),y+=b;continue}else if(b==="["){l=!0,c=h,u=!1,y+=b;continue}if(!i.noext&&w1e(b)&&t.charAt(h)==="("&&o<=s){r.push(y),y="";let T=new cd(b,r);h=cd.#c(t,T,h,i,o+1),r.push(T);continue}y+=b}return r.push(y),h}let d=n+1,g=new cd(null,r),m=[],A="";for(;d<t.length;){let h=t.charAt(d++);if(a||h==="\\"){a=!a,A+=h;continue}if(l){d===c+1?(h==="^"||h==="!")&&(u=!0):h==="]"&&!(d===c+2&&u)&&(l=!1),A+=h;continue}else if(h==="["){l=!0,c=d,u=!1,A+=h;continue}if(!i.noext&&w1e(h)&&t.charAt(d)==="("&&(o<=s||r&&r.#E(h))){let b=r&&r.#E(h)?0:1;g.push(A),A="";let I=new cd(h,g);g.push(I),d=cd.#c(t,I,d,i,o+b);continue}if(h==="|"){g.push(A),A="",m.push(g),g=new cd(null,r);continue}if(h===")")return A===""&&r.#r.length===0&&(r.#p=!0),g.push(A),A="",r.push(...m,g),d;A+=h}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],d}#g(t){return this.#h(t,ynn)}#h(t,r=_nn){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=bnn){return!!r.get(this.type)?.includes(t)}#A(t,r){let n=t.#r[0],i=new cd(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!!Ugt.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=Ugt.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 cd(null,void 0,r);return cd.#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()),!Fgt(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(m=>typeof m!="string"),c=this.#r.map(m=>{let[A,h,y,b]=typeof m=="string"?cd.#C(m,this.#t,l):m.toRegExpSource(t);return this.#t=this.#t||y,this.#n=this.#n||b,A}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&Inn.has(this.#r[0]))){let A=Snn,h=r&&A.has(c.charAt(0))||c.startsWith("\\.")&&A.has(c.charAt(2))||c.startsWith("\\.\\.")&&A.has(c.charAt(4)),y=!r&&!t&&A.has(c.charAt(0));u=h?Cnn:y?$J:""}let d="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(d="(?:$|\\/)"),[u+c+d,pC(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,pC(this.toString()),!1,!1]}let s=!n||t||r||!$J?"":this.#b(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?$J:"")+$gt;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?$J:"")+Hgt+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,pC(o),this.#t=!!this.#t,this.#n]}#_(){if(Fgt(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+=(Tnn.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?$gt:Hgt,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,d,g,m]=Lgt(t,l);if(g){o+=u,s=s||d,l+=g-1,r=r||m;continue}}if(c==="?"){o+=D1e,r=!0;continue}o+=vnn(c)}return[o,pC(t),!!r,s]}};cd=LT;var R1e=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var $l=(e,t,r={})=>(PU(t),!r.nocomment&&t.charAt(0)==="#"?!1:new PB(t,r).match(e)),wnn=/^\*+([^+@!?*[(]*)$/,Dnn=e=>t=>!t.startsWith(".")&&t.endsWith(e),Rnn=e=>t=>t.endsWith(e),Nnn=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Bnn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Onn=/^\*+\.\*+$/,knn=e=>!e.startsWith(".")&&e.includes("."),Mnn=e=>e!=="."&&e!==".."&&e.includes("."),Qnn=/^\.\*+$/,Pnn=e=>e!=="."&&e!==".."&&e.startsWith("."),Lnn=/^\*+$/,Fnn=e=>e.length!==0&&!e.startsWith("."),Unn=e=>e.length!==0&&e!=="."&&e!=="..",Hnn=/^\?+([^+@!?*[(]*)?$/,$nn=([e,t=""])=>{let r=zgt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},qnn=([e,t=""])=>{let r=jgt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Gnn=([e,t=""])=>{let r=jgt([e]);return t?n=>r(n)&&n.endsWith(t):r},znn=([e,t=""])=>{let r=zgt([e]);return t?n=>r(n)&&n.endsWith(t):r},zgt=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},jgt=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},Ygt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",qgt={win32:{sep:"\\"},posix:{sep:"/"}},jnn=Ygt==="win32"?qgt.win32.sep:qgt.posix.sep;$l.sep=jnn;var Sc=Symbol("globstar **");$l.GLOBSTAR=Sc;var Ynn="[^/]",Vnn=Ynn+"*?",Wnn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Knn="(?:(?!(?:\\/|^)\\.).)*?",Jnn=(e,t={})=>r=>$l(r,e,t);$l.filter=Jnn;var Up=(e,t={})=>Object.assign({},e,t),Znn=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return $l;let t=$l;return Object.assign((n,i,o={})=>t(n,i,Up(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,Up(e,o))}static defaults(i){return t.defaults(Up(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,Up(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,Up(e,o))}},unescape:(n,i={})=>t.unescape(n,Up(e,i)),escape:(n,i={})=>t.escape(n,Up(e,i)),filter:(n,i={})=>t.filter(n,Up(e,i)),defaults:n=>t.defaults(Up(e,n)),makeRe:(n,i={})=>t.makeRe(n,Up(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,Up(e,i)),match:(n,i,o={})=>t.match(n,i,Up(e,o)),sep:t.sep,GLOBSTAR:Sc})};$l.defaults=Znn;var Vgt=(e,t={})=>(PU(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Qgt(e,{max:t.braceExpandMax}));$l.braceExpand=Vgt;var Xnn=(e,t={})=>new PB(e,t).makeRe();$l.makeRe=Xnn;var ein=(e,t,r={})=>{let n=new PB(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};$l.match=ein;var Ggt=/[?*]|[+@!]\(.*?\)|\[|\]/,tin=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),PB=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){PU(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||Ygt,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]==="?"||!Ggt.test(o[2]))&&!Ggt.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]),d=l?3:a?0:void 0,g=u?3:c?0:void 0;if(typeof d=="number"&&typeof g=="number"){let[m,A]=[t[d],r[g]];m.toLowerCase()===A.toLowerCase()&&(r[g]=m,o=g,i=d)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(Sc)?this.#e(t,r,n,i,o):this.#n(t,r,n,i,o)}#e(t,r,n,i,o){let s=r.indexOf(Sc,o),a=r.lastIndexOf(Sc),[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 I=t.slice(i,i+l.length);if(!this.#n(I,l,n,0,0))return!1;i+=l.length,o+=l.length}let d=0;if(u.length){if(u.length+i>t.length)return!1;let I=t.length-u.length;if(this.#n(t,u,n,I,0))d=u.length;else{if(t[t.length-1]!==""||i+u.length===t.length||(I--,!this.#n(t,u,n,I,0)))return!1;d=u.length+1}}if(!c.length){let I=!!d;for(let T=i;T<t.length-d;T++){let D=String(t[T]);if(I=!0,D==="."||D===".."||!this.options.dot&&D.startsWith("."))return!1}return n||I}let g=[[[],0]],m=g[0],A=0,h=[0];for(let I of c)I===Sc?(h.push(A),m=[[],0],g.push(m)):(m[0].push(I),A++);let y=g.length-1,b=t.length-d;for(let I of g)I[1]=b-(h[y--]+I[0].length);return!!this.#t(t,g,i,0,n,0,!!d)}#t(t,r,n,i,o,s,a){let l=r[i];if(!l){for(let d=n;d<t.length;d++){a=!0;let g=t[d];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],d=t[s];if(this.debug(r,u,d),u===!1||u===Sc)return!1;let g;if(typeof u=="string"?(g=d===u,this.debug("string match",u,d,g)):(g=u.test(d),this.debug("pattern match",u,d,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 Vgt(this.pattern,this.options)}parse(t){PU(t);let r=this.options;if(t==="**")return Sc;if(t==="")return"";let n,i=null;(n=t.match(Lnn))?i=r.dot?Unn:Fnn:(n=t.match(wnn))?i=(r.nocase?r.dot?Bnn:Nnn:r.dot?Rnn:Dnn)(n[1]):(n=t.match(Hnn))?i=(r.nocase?r.dot?qnn:$nn:r.dot?Gnn:znn)(n):(n=t.match(Onn))?i=r.dot?Mnn:knn:(n=t.match(Qnn))&&(i=Pnn);let o=LT.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?Vnn:r.dot?Wnn:Knn,i=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let c=l.map(d=>{if(d instanceof RegExp)for(let g of d.flags.split(""))i.add(g);return typeof d=="string"?tin(d):d===Sc?Sc:d._src});c.forEach((d,g)=>{let m=c[g+1],A=c[g-1];d!==Sc||A===Sc||(A===void 0?m!==void 0&&m!==Sc?c[g+1]="(?:\\/|"+n+"\\/)?"+m:c[g]=n:m===void 0?c[g-1]=A+"(?:\\/|\\/"+n+")?":m!==Sc&&(c[g-1]=A+"(?:\\/|\\/"+n+"\\/)"+m,c[g+1]=Sc))});let u=c.filter(d=>d!==Sc);if(this.partial&&u.length>=1){let d=[];for(let g=1;g<=u.length;g++)d.push(u.slice(0,g).join("/"));return"(?:"+d.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 $l.defaults(t).Minimatch}};$l.AST=LT;$l.Minimatch=PB;$l.escape=R1e;$l.unescape=pC;var Jgt=we(MU(),1);hr();Le();Qe();Jc();import{readFile as Wgt}from"fs/promises";import{existsSync as N1e,readdirSync as rin,statSync as nin}from"fs";import{join as B1e,relative as Zgt}from"path";import{homedir as iin}from"os";function Kgt(e){try{let t=(0,Jgt.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 Ie(t),{paths:[],content:e.trim()}}}function oin(e,t){return t.length===0?!0:t.some(r=>{try{return $l(e,r,{matchBase:!0,dot:!0})}catch(n){return Ie(n),!1}})}function O1e(e){let t=[];try{if(!N1e(e))return t;let r=rin(e);for(let n of r){let i=B1e(e,n),o=nin(i);o.isDirectory()?t.push(...O1e(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){Ie(r)}return t}async function qJ(){let e=[];try{let t=B1e(iin(),Xr,"rules");if(N1e(t)){let r=O1e(t);for(let n of r)try{let i=await Wgt(n,"utf-8"),{paths:o,content:s}=Kgt(i);o.length>0&&e.push({filePath:n,content:s,paths:o,isProjectRule:!1})}catch(i){Ie(i)}}}catch(t){Ie(t)}try{let t=B1e(Re(),Xr,"rules");if(N1e(t)){let r=O1e(t);for(let n of r)try{let i=await Wgt(n,"utf-8"),{paths:o,content:s}=Kgt(i);o.length>0&&e.push({filePath:Zgt(Re(),n),content:s,paths:o,isProjectRule:!0})}catch(i){Ie(i)}}}catch(t){Ie(t)}return e}function Xgt(e,t){e=cY(e);let r=cY(Re()),n=e.startsWith(r)?Zgt(r,e):e;return t.filter(i=>oin(n,i.paths))}function eAt(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}):
625
+ Stack trace: `+d.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var SJ=null,n1e=!1;function vXr(){SJ=null,n1e=!1}yr.on("proxy:changed",vXr);function xXr(){if(n1e)return SJ;if(n1e=!0,it().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(SJ=new opt.ProxyAgent({uri:e}),Xt(`[proxy] using proxy: ${e}`)),SJ}function wXr(){let e=xXr();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function TJ(e){let t=e||process.env.API_TYPE,r=wXr();switch(t){case"openai":return CXr(r);case"openai-responses":return SXr(r);case"gemini":return IXr(r);default:return TXr(r)}}xA();var BXr=we(tt(),1);function spt(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=DXr(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function DXr(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||RXr(t)?0:NXr(t)?2:1}function RXr(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function NXr(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 w0(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 uC(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}Qe();ds();var Ul={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function vJ(e,t){Ul.totalCost+=e,Ul.totalAPIDuration+=t}function xJ(e,t){Ul.inputTokens+=e,Ul.outputTokens+=t,yr.emit("token:change",{inputTokens:Ul.inputTokens,outputTokens:Ul.outputTokens})}function wJ(e,t){Ul.cacheCreationTokens+=e,Ul.cacheReadTokens+=t}function s1e(){return{inputTokens:Ul.inputTokens,outputTokens:Ul.outputTokens,cacheCreationTokens:Ul.cacheCreationTokens,cacheReadTokens:Ul.cacheReadTokens}}function apt(){return Ul.totalCost}function lpt(){return Date.now()-Ul.startTime}function cpt(){return Ul.totalAPIDuration}function upt(e){Ul.currentContextTokens=e}function dpt(){return Ul.currentContextTokens}Qe();Le();Le();var a1e="2.7.5";globalThis.MACRO={VERSION:a1e,PACKAGE_URL:`@dahawa/${$i}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var DJ=process.env.HAWA_CODE_USER_AGENT||`${$i}/${a1e} (${process.env.USER_TYPE})`;import{randomUUID as Uh}from"crypto";ds();Qe();Jt();hr();Qe();Le();import{existsSync as O0,readdirSync as sin,statSync as ain}from"fs";import{join as mC,relative as lin}from"path";import{homedir as rAt}from"os";import{platform as cin}from"process";import{readFile as gC}from"fs/promises";hr();Lp();er();import{join as PXr,sep as LXr}from"path";function Fp(){if(!ou())return!1;try{let e=it();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function Ef(){return(PXr(Re(),".hcode","team-memory")+LXr).normalize("NFC")}function R0(e){let t=e.normalize("NFC"),r=Ef();return t.startsWith(r)}Lp();var nAt=we(MU(),1);Ri();var I1e=(e,t,r)=>{let n=e instanceof RegExp?Rgt(e,r):e,i=t instanceof RegExp?Rgt(t,r):t,o=n!==null&&i!=null&&Krn(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)}},Rgt=(e,t)=>{let r=t.match(e);return r?r[0]:null},Krn=(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 d=n.pop();d!==void 0&&(a=[d,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 Ngt="\0SLASH"+Math.random()+"\0",Bgt="\0OPEN"+Math.random()+"\0",x1e="\0CLOSE"+Math.random()+"\0",Ogt="\0COMMA"+Math.random()+"\0",kgt="\0PERIOD"+Math.random()+"\0",Jrn=new RegExp(Ngt,"g"),Zrn=new RegExp(Bgt,"g"),Xrn=new RegExp(x1e,"g"),enn=new RegExp(Ogt,"g"),tnn=new RegExp(kgt,"g"),rnn=/\\\\/g,nnn=/\\{/g,inn=/\\}/g,onn=/\\,/g,snn=/\\\./g,ann=1e5,lnn=4e6;function T1e(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function cnn(e){return e.replace(rnn,Ngt).replace(nnn,Bgt).replace(inn,x1e).replace(onn,Ogt).replace(snn,kgt)}function unn(e){return e.replace(Jrn,"\\").replace(Zrn,"{").replace(Xrn,"}").replace(enn,",").replace(tnn,".")}function Mgt(e){if(!e)return[""];let t=[],r=I1e("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=Mgt(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function Qgt(e,t={}){if(!e)return[];let{max:r=ann,maxLength:n=lnn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),v1e(cnn(e),r,n,!0).map(unn)}function dnn(e){return"{"+e+"}"}function fnn(e){return/^-?0\d/.test(e)}function pnn(e,t){return e<=t}function mnn(e,t){return e>=t}function QU(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 gnn(e,t,r,n){let i=e.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let s=T1e(i[0]),a=T1e(i[1]),l=Math.max(i[0].length,i[1].length),c=i.length===3&&i[2]!==void 0?Math.max(Math.abs(T1e(i[2])),1):1,u=pnn;a<s&&(c*=-1,u=mnn);let g=i.some(fnn),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 y=l-h.length;if(y>0){let b=new Array(y+1).join("0");A<0?h="-"+b+h.slice(1):h=b+h}}if(m+h.length>n)break;o.push(h),m+=h.length}return o}function v1e(e,t,r,n){let i=[""],o=!1,s=!0;for(;;){let a=I1e("{","}",e);if(!a)return QU(i,e,[""],t,r,o);let l=a.pre;if(/\$$/.test(l)){if(i=QU(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),d=c||u,g=a.body.indexOf(",")>=0;if(!d&&!g){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+x1e+a.post,n=!0;continue}return QU(i,l+"{"+a.body+"}"+a.post,[""],t,r,o)}s&&(o=n&&!d,s=!1);let m;if(d)m=gnn(a.body,u,t,r);else{let A=Mgt(a.body);if(A.length===1&&A[0]!==void 0&&(A=v1e(A[0],t,r,!1).map(dnn),A.length===1)){if(i=QU(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 b=0;h&&b<i.length;b++)i[b]&&(h=!1);m=[];let y=0;e:for(let b=0;b<A.length;b++){let I=v1e(A[b],t,r,!1);for(let T=0;T<I.length;T++){let D=I[T];if(!(h&&!D)){if(m.length>=t||y+D.length>r)break e;m.push(D),y+=D.length}}}}if(i=QU(i,l,m,t,r,o&&!a.post.length),!a.post.length)break;e=a.post}return i}var PU=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Ann={"[: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]},LU=e=>e.replace(/[[\]\\-]/g,"\\$&"),hnn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Pgt=e=>e.join(""),Lgt=(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,d="";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,[b,I,T]]of Object.entries(Ann))if(e.startsWith(y,o)){if(d)return["$.",!1,e.length-r,!0];o+=y.length,T?i.push(b):n.push(b),a=a||I;continue e}}if(l=!1,d){h>d?n.push(LU(d)+"-"+LU(h)):h===d&&n.push(LU(h)),d="",o++;continue}if(e.startsWith("-]",o+1)){n.push(LU(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){d=h,o+=2;continue}n.push(LU(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[hnn(h),!1,u-r,!1]}let g="["+(c?"^":"")+Pgt(n)+"]",m="["+(c?"":"^")+Pgt(i)+"]";return[n.length&&i.length?"("+g+"|"+m+")":n.length?g:m,a,u-r,!0]};var pC=(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 cd,Enn=new Set(["!","?","+","*","@"]),w1e=e=>Enn.has(e),Fgt=e=>w1e(e.type),_nn=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),ynn=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),bnn=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),Ugt=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),Cnn="(?!(?:^|/)\\.\\.?(?:$|/))",$J="(?!\\.)",Snn=new Set(["[","."]),Inn=new Set(["..","."]),Tnn=new Set("().*{}+?[]^$\\!"),vnn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),D1e="[^/]",Hgt=D1e+"*?",$gt=D1e+"+?",xnn=0,LT=class{type;#e;#t;#n=!1;#r=[];#o;#i;#l;#s=!1;#a;#d;#p=!1;id=++xnn;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 cd&&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 cd&&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 cd(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,y="";for(;h<t.length;){let b=t.charAt(h++);if(a||b==="\\"){a=!a,y+=b;continue}if(l){h===c+1?(b==="^"||b==="!")&&(u=!0):b==="]"&&!(h===c+2&&u)&&(l=!1),y+=b;continue}else if(b==="["){l=!0,c=h,u=!1,y+=b;continue}if(!i.noext&&w1e(b)&&t.charAt(h)==="("&&o<=s){r.push(y),y="";let T=new cd(b,r);h=cd.#c(t,T,h,i,o+1),r.push(T);continue}y+=b}return r.push(y),h}let d=n+1,g=new cd(null,r),m=[],A="";for(;d<t.length;){let h=t.charAt(d++);if(a||h==="\\"){a=!a,A+=h;continue}if(l){d===c+1?(h==="^"||h==="!")&&(u=!0):h==="]"&&!(d===c+2&&u)&&(l=!1),A+=h;continue}else if(h==="["){l=!0,c=d,u=!1,A+=h;continue}if(!i.noext&&w1e(h)&&t.charAt(d)==="("&&(o<=s||r&&r.#E(h))){let b=r&&r.#E(h)?0:1;g.push(A),A="";let I=new cd(h,g);g.push(I),d=cd.#c(t,I,d,i,o+b);continue}if(h==="|"){g.push(A),A="",m.push(g),g=new cd(null,r);continue}if(h===")")return A===""&&r.#r.length===0&&(r.#p=!0),g.push(A),A="",r.push(...m,g),d;A+=h}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],d}#g(t){return this.#h(t,ynn)}#h(t,r=_nn){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=bnn){return!!r.get(this.type)?.includes(t)}#A(t,r){let n=t.#r[0],i=new cd(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!!Ugt.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=Ugt.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 cd(null,void 0,r);return cd.#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()),!Fgt(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(m=>typeof m!="string"),c=this.#r.map(m=>{let[A,h,y,b]=typeof m=="string"?cd.#C(m,this.#t,l):m.toRegExpSource(t);return this.#t=this.#t||y,this.#n=this.#n||b,A}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&Inn.has(this.#r[0]))){let A=Snn,h=r&&A.has(c.charAt(0))||c.startsWith("\\.")&&A.has(c.charAt(2))||c.startsWith("\\.\\.")&&A.has(c.charAt(4)),y=!r&&!t&&A.has(c.charAt(0));u=h?Cnn:y?$J:""}let d="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(d="(?:$|\\/)"),[u+c+d,pC(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,pC(this.toString()),!1,!1]}let s=!n||t||r||!$J?"":this.#b(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?$J:"")+$gt;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?$J:"")+Hgt+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,pC(o),this.#t=!!this.#t,this.#n]}#_(){if(Fgt(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+=(Tnn.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?$gt:Hgt,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,d,g,m]=Lgt(t,l);if(g){o+=u,s=s||d,l+=g-1,r=r||m;continue}}if(c==="?"){o+=D1e,r=!0;continue}o+=vnn(c)}return[o,pC(t),!!r,s]}};cd=LT;var R1e=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var $l=(e,t,r={})=>(PU(t),!r.nocomment&&t.charAt(0)==="#"?!1:new PB(t,r).match(e)),wnn=/^\*+([^+@!?*[(]*)$/,Dnn=e=>t=>!t.startsWith(".")&&t.endsWith(e),Rnn=e=>t=>t.endsWith(e),Nnn=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Bnn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Onn=/^\*+\.\*+$/,knn=e=>!e.startsWith(".")&&e.includes("."),Mnn=e=>e!=="."&&e!==".."&&e.includes("."),Qnn=/^\.\*+$/,Pnn=e=>e!=="."&&e!==".."&&e.startsWith("."),Lnn=/^\*+$/,Fnn=e=>e.length!==0&&!e.startsWith("."),Unn=e=>e.length!==0&&e!=="."&&e!=="..",Hnn=/^\?+([^+@!?*[(]*)?$/,$nn=([e,t=""])=>{let r=zgt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},qnn=([e,t=""])=>{let r=jgt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Gnn=([e,t=""])=>{let r=jgt([e]);return t?n=>r(n)&&n.endsWith(t):r},znn=([e,t=""])=>{let r=zgt([e]);return t?n=>r(n)&&n.endsWith(t):r},zgt=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},jgt=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},Ygt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",qgt={win32:{sep:"\\"},posix:{sep:"/"}},jnn=Ygt==="win32"?qgt.win32.sep:qgt.posix.sep;$l.sep=jnn;var Sc=Symbol("globstar **");$l.GLOBSTAR=Sc;var Ynn="[^/]",Vnn=Ynn+"*?",Wnn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Knn="(?:(?!(?:\\/|^)\\.).)*?",Jnn=(e,t={})=>r=>$l(r,e,t);$l.filter=Jnn;var Up=(e,t={})=>Object.assign({},e,t),Znn=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return $l;let t=$l;return Object.assign((n,i,o={})=>t(n,i,Up(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,Up(e,o))}static defaults(i){return t.defaults(Up(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,Up(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,Up(e,o))}},unescape:(n,i={})=>t.unescape(n,Up(e,i)),escape:(n,i={})=>t.escape(n,Up(e,i)),filter:(n,i={})=>t.filter(n,Up(e,i)),defaults:n=>t.defaults(Up(e,n)),makeRe:(n,i={})=>t.makeRe(n,Up(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,Up(e,i)),match:(n,i,o={})=>t.match(n,i,Up(e,o)),sep:t.sep,GLOBSTAR:Sc})};$l.defaults=Znn;var Vgt=(e,t={})=>(PU(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Qgt(e,{max:t.braceExpandMax}));$l.braceExpand=Vgt;var Xnn=(e,t={})=>new PB(e,t).makeRe();$l.makeRe=Xnn;var ein=(e,t,r={})=>{let n=new PB(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};$l.match=ein;var Ggt=/[?*]|[+@!]\(.*?\)|\[|\]/,tin=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),PB=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){PU(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||Ygt,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]==="?"||!Ggt.test(o[2]))&&!Ggt.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]),d=l?3:a?0:void 0,g=u?3:c?0:void 0;if(typeof d=="number"&&typeof g=="number"){let[m,A]=[t[d],r[g]];m.toLowerCase()===A.toLowerCase()&&(r[g]=m,o=g,i=d)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(Sc)?this.#e(t,r,n,i,o):this.#n(t,r,n,i,o)}#e(t,r,n,i,o){let s=r.indexOf(Sc,o),a=r.lastIndexOf(Sc),[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 I=t.slice(i,i+l.length);if(!this.#n(I,l,n,0,0))return!1;i+=l.length,o+=l.length}let d=0;if(u.length){if(u.length+i>t.length)return!1;let I=t.length-u.length;if(this.#n(t,u,n,I,0))d=u.length;else{if(t[t.length-1]!==""||i+u.length===t.length||(I--,!this.#n(t,u,n,I,0)))return!1;d=u.length+1}}if(!c.length){let I=!!d;for(let T=i;T<t.length-d;T++){let D=String(t[T]);if(I=!0,D==="."||D===".."||!this.options.dot&&D.startsWith("."))return!1}return n||I}let g=[[[],0]],m=g[0],A=0,h=[0];for(let I of c)I===Sc?(h.push(A),m=[[],0],g.push(m)):(m[0].push(I),A++);let y=g.length-1,b=t.length-d;for(let I of g)I[1]=b-(h[y--]+I[0].length);return!!this.#t(t,g,i,0,n,0,!!d)}#t(t,r,n,i,o,s,a){let l=r[i];if(!l){for(let d=n;d<t.length;d++){a=!0;let g=t[d];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],d=t[s];if(this.debug(r,u,d),u===!1||u===Sc)return!1;let g;if(typeof u=="string"?(g=d===u,this.debug("string match",u,d,g)):(g=u.test(d),this.debug("pattern match",u,d,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 Vgt(this.pattern,this.options)}parse(t){PU(t);let r=this.options;if(t==="**")return Sc;if(t==="")return"";let n,i=null;(n=t.match(Lnn))?i=r.dot?Unn:Fnn:(n=t.match(wnn))?i=(r.nocase?r.dot?Bnn:Nnn:r.dot?Rnn:Dnn)(n[1]):(n=t.match(Hnn))?i=(r.nocase?r.dot?qnn:$nn:r.dot?Gnn:znn)(n):(n=t.match(Onn))?i=r.dot?Mnn:knn:(n=t.match(Qnn))&&(i=Pnn);let o=LT.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?Vnn:r.dot?Wnn:Knn,i=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let c=l.map(d=>{if(d instanceof RegExp)for(let g of d.flags.split(""))i.add(g);return typeof d=="string"?tin(d):d===Sc?Sc:d._src});c.forEach((d,g)=>{let m=c[g+1],A=c[g-1];d!==Sc||A===Sc||(A===void 0?m!==void 0&&m!==Sc?c[g+1]="(?:\\/|"+n+"\\/)?"+m:c[g]=n:m===void 0?c[g-1]=A+"(?:\\/|\\/"+n+")?":m!==Sc&&(c[g-1]=A+"(?:\\/|\\/"+n+"\\/)"+m,c[g+1]=Sc))});let u=c.filter(d=>d!==Sc);if(this.partial&&u.length>=1){let d=[];for(let g=1;g<=u.length;g++)d.push(u.slice(0,g).join("/"));return"(?:"+d.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 $l.defaults(t).Minimatch}};$l.AST=LT;$l.Minimatch=PB;$l.escape=R1e;$l.unescape=pC;var Jgt=we(MU(),1);hr();Le();Qe();Jc();import{readFile as Wgt}from"fs/promises";import{existsSync as N1e,readdirSync as rin,statSync as nin}from"fs";import{join as B1e,relative as Zgt}from"path";import{homedir as iin}from"os";function Kgt(e){try{let t=(0,Jgt.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 Ie(t),{paths:[],content:e.trim()}}}function oin(e,t){return t.length===0?!0:t.some(r=>{try{return $l(e,r,{matchBase:!0,dot:!0})}catch(n){return Ie(n),!1}})}function O1e(e){let t=[];try{if(!N1e(e))return t;let r=rin(e);for(let n of r){let i=B1e(e,n),o=nin(i);o.isDirectory()?t.push(...O1e(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){Ie(r)}return t}async function qJ(){let e=[];try{let t=B1e(iin(),Xr,"rules");if(N1e(t)){let r=O1e(t);for(let n of r)try{let i=await Wgt(n,"utf-8"),{paths:o,content:s}=Kgt(i);o.length>0&&e.push({filePath:n,content:s,paths:o,isProjectRule:!1})}catch(i){Ie(i)}}}catch(t){Ie(t)}try{let t=B1e(Re(),Xr,"rules");if(N1e(t)){let r=O1e(t);for(let n of r)try{let i=await Wgt(n,"utf-8"),{paths:o,content:s}=Kgt(i);o.length>0&&e.push({filePath:Zgt(Re(),n),content:s,paths:o,isProjectRule:!0})}catch(i){Ie(i)}}}catch(t){Ie(t)}return e}function Xgt(e,t){e=cY(e);let r=cY(Re()),n=e.startsWith(r)?Zgt(r,e):e;return t.filter(i=>oin(n,i.paths))}function eAt(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}):
626
626
 
627
627
  ${r.content}`}).join(`
628
628
 
@@ -992,7 +992,7 @@ You are powered by the model ${e}.`}async function cv(){return!["1","true"].incl
992
992
  <context name="${c}">${u}</context>`;let s=i.map(c=>{let u=c.prompt({},t),d=JSON.stringify("inputJSONSchema"in c&&c.inputJSONSchema?c.inputJSONSchema:_E(c.inputSchema));return{name:c.name,description:`${u}
993
993
 
994
994
  Schema:
995
- ${d}`}}),{messages:a}=t,l=kln(o);return Mln(o,l,s,a)}},X0t=Qln;sg();var m2=we(tt(),1);Qe();Qe();import{existsSync as Pln,readdirSync as Lln,statSync as Fln}from"fs";import{join as Uln}from"path";function Hln(){let e=Gi.plan();if(!Pln(e))return[];try{return Lln(e).filter(r=>r.endsWith(".md")).map(r=>{let n=Uln(e,r),i=Fln(n);return{name:r,path:n,modified:i.mtime}}).sort((r,n)=>n.modified.getTime()-r.modified.getTime())}catch{return[]}}var e_t=({onSelect:e})=>{let[t,r]=(0,m2.useState)([]),[n,i]=(0,m2.useState)(0),[o,s]=(0,m2.useState)(!1);(0,m2.useEffect)(()=>{let c=Hln();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(d=>d>0?d-1:a.length-1);else if(u.downArrow)i(d=>d<a.length-1?d+1:0);else if(u.return){let d=a[n];d&&e(d.value)}else u.escape&&e("__CANCELLED__")});let l=Oe();return o?(0,_.jsxs)(N,{flexDirection:"column",marginY:1,children:[(0,_.jsx)(N,{marginBottom:1,children:(0,_.jsx)(x,{bold:!0,color:l.claude,children:"\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"})}),(0,_.jsx)(N,{marginBottom:1,children:(0,_.jsx)(x,{bold:!0,color:l.claude,children:" Select a plan to continue, or create a new one"})}),a.map((c,u)=>{let d=u===n;return(0,_.jsxs)(N,{flexDirection:"row",marginLeft:2,children:[(0,_.jsx)(x,{color:d?l.claude:l.text,children:d?"\u276F":" "}),(0,_.jsx)(x,{color:d?l.claude:l.text,children:" "}),(0,_.jsx)(x,{color:d?l.claude:l.text,bold:c.isNew,children:c.isNew?c.label:c.label.replace(".md","")}),!c.isNew&&c.modified&&(0,_.jsxs)(x,{dimColor:!0,children:[" ","(",vme(c.modified),")"]})]},c.isNew?"new":c.value)}),(0,_.jsx)(N,{marginTop:1,marginLeft:2,children:(0,_.jsx)(x,{dimColor:!0,children:"\u2191/\u2193 to select \xB7 Enter to confirm \xB7 Esc to cancel"})})]}):(0,_.jsx)(N,{flexDirection:"column",marginY:1,children:(0,_.jsx)(x,{children:"Loading plan history..."})})};var $ln={type:"local-jsx",name:"plan",description:()=>"Enable plan mode",isEnabled:!0,isHidden:!1,disableCancel:!0,async call(e){return Ei.isPlanMode()?(e("Already in plan mode."),null):(0,_.jsx)(e_t,{onSelect:t=>{if(t==="__CANCELLED__"){e("Cancelled.");return}t&&t!=="__NEW_PLAN__"?Ei.setCurrentPlanFilePath(t):Ei.generatePlanFilePath(),Ei.setMode("plan",!0,!1),e("Enabled plan mode")}})},userFacingName(){return"plan"}},t_t=$ln;sg();var qln={type:"local",name:"auto",description:()=>"Enable auto mode",isEnabled:!0,isHidden:!1,async call(){return Ei.isAutoMode()?"Already in auto mode.":(Ei.setMode("auto",!0),"Enabled auto mode")},userFacingName(){return"auto"}},r_t=qln;hr();import{resolve as Gln}from"path";var zln={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=Gln(r,t);$s(n);let i=Re();return i===r?`Already in ${i}.`:`Changed directory to ${i}/`},userFacingName(){return"cd"}},n_t=zln;var kbt=we(tt(),1);var nh=we(tt(),1);var Scn=we(tt(),1);var C5=we(tt(),1),ycn=we(a_t(),1);var l_t={info:"blue",success:"green",error:"red",warning:"yellow"},ocn={styles:{container:({variant:e})=>({flexGrow:1,borderStyle:"round",borderColor:l_t[e],gap:1,paddingX:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:l_t[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=Kt.info),e==="success"&&(t=Kt.tick),e==="error"&&(t=Kt.cross),e==="warning"&&(t=Kt.warning),{icon:t}}},c_t=ocn;var scn={styles:{container:({color:e})=>({backgroundColor:e}),label:()=>({color:"black"})}},u_t=scn;var acn={styles:{input:({isFocused:e})=>({dimColor:!e})}},d_t=acn;var lcn={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})}},f_t=lcn;var ccn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})}},p_t=ccn;var ucn={styles:{container:()=>({flexGrow:1,minWidth:0}),completed:()=>({color:"magenta"}),remaining:()=>({dimColor:!0})},config:()=>({completedCharacter:Kt.square,remainingCharacter:Kt.squareLightShade})},m_t=ucn;var dcn={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})}},g_t=dcn;var fcn={styles:{container:()=>({gap:1}),frame:()=>({color:"blue"}),label:()=>({})}},A_t=fcn;var pcn={success:"green",error:"red",warning:"yellow",info:"blue"},mcn={success:Kt.tick,error:Kt.cross,warning:Kt.warning,info:Kt.info},gcn={styles:{container:()=>({gap:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:pcn[e]}),message:()=>({})},config:({variant:e})=>({icon:mcn[e]})},h_t=gcn;var Acn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})},config:()=>({marker:Kt.line})},E_t=Acn;var hcn={styles:{value:()=>({})}},__t=hcn;var Ecn={styles:{value:()=>({})}},y_t=Ecn;var _cn={styles:{value:()=>({})}},b_t=_cn;var bcn={components:{Alert:c_t,Badge:u_t,ConfirmInput:d_t,MultiSelect:f_t,OrderedList:p_t,ProgressBar:m_t,Select:g_t,Spinner:A_t,StatusMessage:h_t,UnorderedList:E_t,TextInput:__t,EmailInput:y_t,PasswordInput:b_t}},Ccn=(0,C5.createContext)(bcn);var oo=e=>(0,C5.useContext)(Ccn).components[e];var Icn=we(tt(),1);var $0=we(tt(),1);var A2=we(tt(),1);var C_t=we(tt(),1);var S5=Kt.line;var YZ=(0,C_t.createContext)({marker:S5});function S_t({children:e}){let{marker:t}=(0,A2.useContext)(YZ),{styles:r}=oo("UnorderedList");return A2.default.createElement(N,{...r.listItem()},A2.default.createElement(x,{...r.marker()},t),A2.default.createElement(N,{...r.content()},e))}var I_t=we(tt(),1),ETe=(0,I_t.createContext)({depth:0});function Tcn({children:e}){let{depth:t}=(0,$0.useContext)(ETe),{styles:r,config:n}=oo("UnorderedList"),i=(0,$0.useMemo)(()=>({depth:t+1}),[t]),o=(0,$0.useMemo)(()=>{let{marker:s}=n();return typeof s=="string"?{marker:s}:Array.isArray(s)?{marker:s[t]??s.at(-1)??S5}:{marker:S5}},[n,t]);return $0.default.createElement(ETe.Provider,{value:i},$0.default.createElement(YZ.Provider,{value:o},$0.default.createElement(N,{...r.list()},e)))}Tcn.Item=S_t;var xcn=we(tt(),1);var vcn=we(tt(),1);var I5=we(tt(),1);var h2=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 T_t=we(tt(),1);var E2=we(tt(),1);var T5=we(tt(),1);function v_t({isFocused:e,isSelected:t,children:r}){let{styles:n}=oo("Select");return T5.default.createElement(N,{...n.option({isFocused:e})},e&&T5.default.createElement(x,{...n.focusIndicator()},Kt.pointer),T5.default.createElement(x,{...n.label({isFocused:e,isSelected:t})},r),t&&T5.default.createElement(x,{...n.selectedIndicator()},Kt.tick))}var jp=we(tt(),1);import{isDeepStrictEqual as wcn}from"node:util";var Dcn=(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}},x_t=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=typeof e=="number"?Math.min(e,r.length):r.length,i=new h2(r);return{optionMap:i,visibleOptionCount:n,focusedValue:i.first?.value,visibleFromIndex:0,visibleToIndex:n,previousValue:t,value:t}},w_t=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n})=>{let[i,o]=(0,jp.useReducer)(Dcn,{visibleOptionCount:e,defaultValue:r,options:t},x_t),[s,a]=(0,jp.useState)(t);t!==s&&!wcn(t,s)&&(o({type:"reset",state:x_t({visibleOptionCount:e,defaultValue:r,options:t})}),a(t));let l=(0,jp.useCallback)(()=>{o({type:"focus-next-option"})},[]),c=(0,jp.useCallback)(()=>{o({type:"focus-previous-option"})},[]),u=(0,jp.useCallback)(()=>{o({type:"select-focused-option"})},[]),d=(0,jp.useMemo)(()=>t.map((g,m)=>({...g,index:m})).slice(i.visibleFromIndex,i.visibleToIndex),[t,i.visibleFromIndex,i.visibleToIndex]);return(0,jp.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:d,focusNextOption:l,focusPreviousOption:c,selectFocusedOption:u}};var D_t=({isDisabled:e=!1,state:t})=>{sr((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};function _2({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:i,onChange:o}){let s=w_t({visibleOptionCount:t,options:n,defaultValue:i,onChange:o});D_t({isDisabled:e,state:s});let{styles:a}=oo("Select");return E2.default.createElement(N,{...a.container()},s.visibleOptions.map(l=>{let c=l.label;if(r&&l.label.includes(r)){let u=l.label.indexOf(r);c=E2.default.createElement(E2.default.Fragment,null,l.label.slice(0,u),E2.default.createElement(x,{...a.highlightedText()},r),l.label.slice(u+r.length))}return E2.default.createElement(v_t,{key:l.value,isFocused:!e&&s.focusedValue===l.value,isSelected:s.value===l.value},c)}))}var Rcn=we(tt(),1);var R_t=we(tt(),1);var Bcn=we(tt(),1);var VZ=we(tt(),1);var Ncn=we(tt(),1);var y2i=rr.inverse(" ");var dg=we(tt(),1);var y2=we(tt(),1);var N_t=we(tt(),1);var WZ=(0,N_t.createContext)({marker:Kt.line});function KZ({children:e}){let{marker:t}=(0,y2.useContext)(WZ),{styles:r}=oo("OrderedList");return y2.default.createElement(N,{...r.listItem()},y2.default.createElement(x,{...r.marker()},t),y2.default.createElement(N,{...r.content()},e))}var B_t=we(tt(),1),_Te=(0,B_t.createContext)({marker:""});function fg({children:e}){let{marker:t}=(0,dg.useContext)(_Te),{styles:r}=oo("OrderedList"),n=0;for(let o of dg.default.Children.toArray(e))!(0,dg.isValidElement)(o)||o.type!==KZ||n++;let i=String(n).length;return dg.default.createElement(N,{...r.list()},dg.default.Children.map(e,(o,s)=>{if(!(0,dg.isValidElement)(o)||o.type!==KZ)return o;let a=`${String(s+1).padStart(i)}.`,l=`${t}${a}`;return dg.default.createElement(_Te.Provider,{value:{marker:l}},dg.default.createElement(WZ.Provider,{value:{marker:l}},o))}))}fg.Item=KZ;var kcn=we(tt(),1);var yTe=we(tt(),1);var Ocn=we(tt(),1);var W2i=rr.inverse(" ");var Mcn=we(tt(),1);var Qcn=we(tt(),1);var Lcn=we(tt(),1);var JZ=we(tt(),1);var Pcn=we(tt(),1);var _Oi=rr.inverse(" ");var I2=we(tt(),1);var bTe=we(tt(),1);HU();ds();Ri();ZT();er();var Fcn=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function SC(){let e=Fcn,{frame:t}=TD({interval:120});return(0,_.jsx)(N,{flexWrap:"nowrap",height:1,width:2,children:(0,_.jsx)(x,{color:Oe().claude,children:e[t%e.length]})})}var eX=we(tt(),1);var uv=null,q0=null,XZ=new Set,ZZ=null;function STe(e){let{columns:t,rows:r}=e;return t&&r?{columns:t,rows:r}:(ZZ||(ZZ=ffe()),{columns:t||ZZ.columns||80,rows:r||ZZ.rows||24})}function CTe(){if(!q0)return;let e=STe(q0);uv&&e.columns===uv.columns&&e.rows===uv.rows||(uv=e,XZ.forEach(t=>t(uv)))}function Ucn(e,t){return q0!==e&&(q0&&q0.off("resize",CTe),q0=e,uv=STe(e),e.on("resize",CTe)),XZ.add(t),()=>{XZ.delete(t),XZ.size===0&&q0&&(q0.off("resize",CTe),q0=null,uv=null)}}function ITe(){let{stdout:e}=ky(),[t,r]=(0,eX.useState)(()=>STe(e));return(0,eX.useEffect)(()=>Ucn(e,r),[e]),t}function tX(){return ITe()}Le();Wd();Qe();SA();Qe();var cMi=we(ybt(),1);import{homedir as k5}from"os";import{join as S2}from"path";import{existsSync as M5,mkdirSync as Cbt,appendFileSync as bbt,readFileSync as Sbt,constants as Pfn,writeFileSync as Lfn,unlinkSync as Ibt,statSync as Ffn}from"fs";import{platform as Tbt}from"process";import{accessSync as Ufn}from"fs";var Qfn="2.7.4",O5={VERSION:Qfn,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"};Le();var fv=S2(t0,".update.lock"),Hfn=300*1e3;function vbt(){try{if(M5(t0)||Cbt(t0,{recursive:!0}),M5(fv)){let e=Ffn(fv);if(Date.now()-e.mtimeMs<Hfn)return!1;try{Ibt(fv)}catch(r){return Ie(`Failed to remove stale lock file: ${r}`),!1}}return Lfn(fv,`${process.pid}`,"utf8"),!0}catch(e){return Ie(`Failed to acquire lock: ${e}`),!1}}function xbt(){try{M5(fv)&&Sbt(fv,"utf8")===`${process.pid}`&&Ibt(fv)}catch(e){Ie(`Failed to release lock: ${e}`)}}async function zTe(){try{let e=await Xn("npm -g config get prefix");if(e.code!==0)return Ie("Failed to check npm permissions"),{hasPermissions:!1,npmPrefix:null};let t=e.stdout.trim(),r=!1;try{Ufn(t,Pfn.W_OK),r=!0}catch{r=!1}return r?{hasPermissions:!0,npmPrefix:t}:(Ie("Insufficient permissions for global npm install."),{hasPermissions:!1,npmPrefix:t})}catch(e){return Ie(`Failed to verify npm global install permissions: ${e}`),{hasPermissions:!1,npmPrefix:null}}}async function wbt(e){if(!vbt())throw Bt("tengu_auto_updater_prefix_lock_contention",{pid:String(process.pid),currentVersion:O5.VERSION,prefix:e}),new Error("Another process is currently setting up npm prefix");try{M5(e)||Cbt(e,{recursive:!0});let t=await Xn(`npm -g config set prefix ${e}`);if(t.code!==0)throw new Error(`Failed to set npm prefix: ${t.stderr}`);let r=`
995
+ ${d}`}}),{messages:a}=t,l=kln(o);return Mln(o,l,s,a)}},X0t=Qln;sg();var m2=we(tt(),1);Qe();Qe();import{existsSync as Pln,readdirSync as Lln,statSync as Fln}from"fs";import{join as Uln}from"path";function Hln(){let e=Gi.plan();if(!Pln(e))return[];try{return Lln(e).filter(r=>r.endsWith(".md")).map(r=>{let n=Uln(e,r),i=Fln(n);return{name:r,path:n,modified:i.mtime}}).sort((r,n)=>n.modified.getTime()-r.modified.getTime())}catch{return[]}}var e_t=({onSelect:e})=>{let[t,r]=(0,m2.useState)([]),[n,i]=(0,m2.useState)(0),[o,s]=(0,m2.useState)(!1);(0,m2.useEffect)(()=>{let c=Hln();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(d=>d>0?d-1:a.length-1);else if(u.downArrow)i(d=>d<a.length-1?d+1:0);else if(u.return){let d=a[n];d&&e(d.value)}else u.escape&&e("__CANCELLED__")});let l=Oe();return o?(0,_.jsxs)(N,{flexDirection:"column",marginY:1,children:[(0,_.jsx)(N,{marginBottom:1,children:(0,_.jsx)(x,{bold:!0,color:l.claude,children:"\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"})}),(0,_.jsx)(N,{marginBottom:1,children:(0,_.jsx)(x,{bold:!0,color:l.claude,children:" Select a plan to continue, or create a new one"})}),a.map((c,u)=>{let d=u===n;return(0,_.jsxs)(N,{flexDirection:"row",marginLeft:2,children:[(0,_.jsx)(x,{color:d?l.claude:l.text,children:d?"\u276F":" "}),(0,_.jsx)(x,{color:d?l.claude:l.text,children:" "}),(0,_.jsx)(x,{color:d?l.claude:l.text,bold:c.isNew,children:c.isNew?c.label:c.label.replace(".md","")}),!c.isNew&&c.modified&&(0,_.jsxs)(x,{dimColor:!0,children:[" ","(",vme(c.modified),")"]})]},c.isNew?"new":c.value)}),(0,_.jsx)(N,{marginTop:1,marginLeft:2,children:(0,_.jsx)(x,{dimColor:!0,children:"\u2191/\u2193 to select \xB7 Enter to confirm \xB7 Esc to cancel"})})]}):(0,_.jsx)(N,{flexDirection:"column",marginY:1,children:(0,_.jsx)(x,{children:"Loading plan history..."})})};var $ln={type:"local-jsx",name:"plan",description:()=>"Enable plan mode",isEnabled:!0,isHidden:!1,disableCancel:!0,async call(e){return Ei.isPlanMode()?(e("Already in plan mode."),null):(0,_.jsx)(e_t,{onSelect:t=>{if(t==="__CANCELLED__"){e("Cancelled.");return}t&&t!=="__NEW_PLAN__"?Ei.setCurrentPlanFilePath(t):Ei.generatePlanFilePath(),Ei.setMode("plan",!0,!1),e("Enabled plan mode")}})},userFacingName(){return"plan"}},t_t=$ln;sg();var qln={type:"local",name:"auto",description:()=>"Enable auto mode",isEnabled:!0,isHidden:!1,async call(){return Ei.isAutoMode()?"Already in auto mode.":(Ei.setMode("auto",!0),"Enabled auto mode")},userFacingName(){return"auto"}},r_t=qln;hr();import{resolve as Gln}from"path";var zln={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=Gln(r,t);$s(n);let i=Re();return i===r?`Already in ${i}.`:`Changed directory to ${i}/`},userFacingName(){return"cd"}},n_t=zln;var kbt=we(tt(),1);var nh=we(tt(),1);var Scn=we(tt(),1);var C5=we(tt(),1),ycn=we(a_t(),1);var l_t={info:"blue",success:"green",error:"red",warning:"yellow"},ocn={styles:{container:({variant:e})=>({flexGrow:1,borderStyle:"round",borderColor:l_t[e],gap:1,paddingX:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:l_t[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=Kt.info),e==="success"&&(t=Kt.tick),e==="error"&&(t=Kt.cross),e==="warning"&&(t=Kt.warning),{icon:t}}},c_t=ocn;var scn={styles:{container:({color:e})=>({backgroundColor:e}),label:()=>({color:"black"})}},u_t=scn;var acn={styles:{input:({isFocused:e})=>({dimColor:!e})}},d_t=acn;var lcn={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})}},f_t=lcn;var ccn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})}},p_t=ccn;var ucn={styles:{container:()=>({flexGrow:1,minWidth:0}),completed:()=>({color:"magenta"}),remaining:()=>({dimColor:!0})},config:()=>({completedCharacter:Kt.square,remainingCharacter:Kt.squareLightShade})},m_t=ucn;var dcn={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})}},g_t=dcn;var fcn={styles:{container:()=>({gap:1}),frame:()=>({color:"blue"}),label:()=>({})}},A_t=fcn;var pcn={success:"green",error:"red",warning:"yellow",info:"blue"},mcn={success:Kt.tick,error:Kt.cross,warning:Kt.warning,info:Kt.info},gcn={styles:{container:()=>({gap:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:pcn[e]}),message:()=>({})},config:({variant:e})=>({icon:mcn[e]})},h_t=gcn;var Acn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})},config:()=>({marker:Kt.line})},E_t=Acn;var hcn={styles:{value:()=>({})}},__t=hcn;var Ecn={styles:{value:()=>({})}},y_t=Ecn;var _cn={styles:{value:()=>({})}},b_t=_cn;var bcn={components:{Alert:c_t,Badge:u_t,ConfirmInput:d_t,MultiSelect:f_t,OrderedList:p_t,ProgressBar:m_t,Select:g_t,Spinner:A_t,StatusMessage:h_t,UnorderedList:E_t,TextInput:__t,EmailInput:y_t,PasswordInput:b_t}},Ccn=(0,C5.createContext)(bcn);var oo=e=>(0,C5.useContext)(Ccn).components[e];var Icn=we(tt(),1);var $0=we(tt(),1);var A2=we(tt(),1);var C_t=we(tt(),1);var S5=Kt.line;var YZ=(0,C_t.createContext)({marker:S5});function S_t({children:e}){let{marker:t}=(0,A2.useContext)(YZ),{styles:r}=oo("UnorderedList");return A2.default.createElement(N,{...r.listItem()},A2.default.createElement(x,{...r.marker()},t),A2.default.createElement(N,{...r.content()},e))}var I_t=we(tt(),1),ETe=(0,I_t.createContext)({depth:0});function Tcn({children:e}){let{depth:t}=(0,$0.useContext)(ETe),{styles:r,config:n}=oo("UnorderedList"),i=(0,$0.useMemo)(()=>({depth:t+1}),[t]),o=(0,$0.useMemo)(()=>{let{marker:s}=n();return typeof s=="string"?{marker:s}:Array.isArray(s)?{marker:s[t]??s.at(-1)??S5}:{marker:S5}},[n,t]);return $0.default.createElement(ETe.Provider,{value:i},$0.default.createElement(YZ.Provider,{value:o},$0.default.createElement(N,{...r.list()},e)))}Tcn.Item=S_t;var xcn=we(tt(),1);var vcn=we(tt(),1);var I5=we(tt(),1);var h2=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 T_t=we(tt(),1);var E2=we(tt(),1);var T5=we(tt(),1);function v_t({isFocused:e,isSelected:t,children:r}){let{styles:n}=oo("Select");return T5.default.createElement(N,{...n.option({isFocused:e})},e&&T5.default.createElement(x,{...n.focusIndicator()},Kt.pointer),T5.default.createElement(x,{...n.label({isFocused:e,isSelected:t})},r),t&&T5.default.createElement(x,{...n.selectedIndicator()},Kt.tick))}var jp=we(tt(),1);import{isDeepStrictEqual as wcn}from"node:util";var Dcn=(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}},x_t=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=typeof e=="number"?Math.min(e,r.length):r.length,i=new h2(r);return{optionMap:i,visibleOptionCount:n,focusedValue:i.first?.value,visibleFromIndex:0,visibleToIndex:n,previousValue:t,value:t}},w_t=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n})=>{let[i,o]=(0,jp.useReducer)(Dcn,{visibleOptionCount:e,defaultValue:r,options:t},x_t),[s,a]=(0,jp.useState)(t);t!==s&&!wcn(t,s)&&(o({type:"reset",state:x_t({visibleOptionCount:e,defaultValue:r,options:t})}),a(t));let l=(0,jp.useCallback)(()=>{o({type:"focus-next-option"})},[]),c=(0,jp.useCallback)(()=>{o({type:"focus-previous-option"})},[]),u=(0,jp.useCallback)(()=>{o({type:"select-focused-option"})},[]),d=(0,jp.useMemo)(()=>t.map((g,m)=>({...g,index:m})).slice(i.visibleFromIndex,i.visibleToIndex),[t,i.visibleFromIndex,i.visibleToIndex]);return(0,jp.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:d,focusNextOption:l,focusPreviousOption:c,selectFocusedOption:u}};var D_t=({isDisabled:e=!1,state:t})=>{sr((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};function _2({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:i,onChange:o}){let s=w_t({visibleOptionCount:t,options:n,defaultValue:i,onChange:o});D_t({isDisabled:e,state:s});let{styles:a}=oo("Select");return E2.default.createElement(N,{...a.container()},s.visibleOptions.map(l=>{let c=l.label;if(r&&l.label.includes(r)){let u=l.label.indexOf(r);c=E2.default.createElement(E2.default.Fragment,null,l.label.slice(0,u),E2.default.createElement(x,{...a.highlightedText()},r),l.label.slice(u+r.length))}return E2.default.createElement(v_t,{key:l.value,isFocused:!e&&s.focusedValue===l.value,isSelected:s.value===l.value},c)}))}var Rcn=we(tt(),1);var R_t=we(tt(),1);var Bcn=we(tt(),1);var VZ=we(tt(),1);var Ncn=we(tt(),1);var y2i=rr.inverse(" ");var dg=we(tt(),1);var y2=we(tt(),1);var N_t=we(tt(),1);var WZ=(0,N_t.createContext)({marker:Kt.line});function KZ({children:e}){let{marker:t}=(0,y2.useContext)(WZ),{styles:r}=oo("OrderedList");return y2.default.createElement(N,{...r.listItem()},y2.default.createElement(x,{...r.marker()},t),y2.default.createElement(N,{...r.content()},e))}var B_t=we(tt(),1),_Te=(0,B_t.createContext)({marker:""});function fg({children:e}){let{marker:t}=(0,dg.useContext)(_Te),{styles:r}=oo("OrderedList"),n=0;for(let o of dg.default.Children.toArray(e))!(0,dg.isValidElement)(o)||o.type!==KZ||n++;let i=String(n).length;return dg.default.createElement(N,{...r.list()},dg.default.Children.map(e,(o,s)=>{if(!(0,dg.isValidElement)(o)||o.type!==KZ)return o;let a=`${String(s+1).padStart(i)}.`,l=`${t}${a}`;return dg.default.createElement(_Te.Provider,{value:{marker:l}},dg.default.createElement(WZ.Provider,{value:{marker:l}},o))}))}fg.Item=KZ;var kcn=we(tt(),1);var yTe=we(tt(),1);var Ocn=we(tt(),1);var W2i=rr.inverse(" ");var Mcn=we(tt(),1);var Qcn=we(tt(),1);var Lcn=we(tt(),1);var JZ=we(tt(),1);var Pcn=we(tt(),1);var _Oi=rr.inverse(" ");var I2=we(tt(),1);var bTe=we(tt(),1);HU();ds();Ri();ZT();er();var Fcn=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function SC(){let e=Fcn,{frame:t}=TD({interval:120});return(0,_.jsx)(N,{flexWrap:"nowrap",height:1,width:2,children:(0,_.jsx)(x,{color:Oe().claude,children:e[t%e.length]})})}var eX=we(tt(),1);var uv=null,q0=null,XZ=new Set,ZZ=null;function STe(e){let{columns:t,rows:r}=e;return t&&r?{columns:t,rows:r}:(ZZ||(ZZ=ffe()),{columns:t||ZZ.columns||80,rows:r||ZZ.rows||24})}function CTe(){if(!q0)return;let e=STe(q0);uv&&e.columns===uv.columns&&e.rows===uv.rows||(uv=e,XZ.forEach(t=>t(uv)))}function Ucn(e,t){return q0!==e&&(q0&&q0.off("resize",CTe),q0=e,uv=STe(e),e.on("resize",CTe)),XZ.add(t),()=>{XZ.delete(t),XZ.size===0&&q0&&(q0.off("resize",CTe),q0=null,uv=null)}}function ITe(){let{stdout:e}=ky(),[t,r]=(0,eX.useState)(()=>STe(e));return(0,eX.useEffect)(()=>Ucn(e,r),[e]),t}function tX(){return ITe()}Le();Wd();Qe();SA();Qe();var cMi=we(ybt(),1);import{homedir as k5}from"os";import{join as S2}from"path";import{existsSync as M5,mkdirSync as Cbt,appendFileSync as bbt,readFileSync as Sbt,constants as Pfn,writeFileSync as Lfn,unlinkSync as Ibt,statSync as Ffn}from"fs";import{platform as Tbt}from"process";import{accessSync as Ufn}from"fs";var Qfn="2.7.5",O5={VERSION:Qfn,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"};Le();var fv=S2(t0,".update.lock"),Hfn=300*1e3;function vbt(){try{if(M5(t0)||Cbt(t0,{recursive:!0}),M5(fv)){let e=Ffn(fv);if(Date.now()-e.mtimeMs<Hfn)return!1;try{Ibt(fv)}catch(r){return Ie(`Failed to remove stale lock file: ${r}`),!1}}return Lfn(fv,`${process.pid}`,"utf8"),!0}catch(e){return Ie(`Failed to acquire lock: ${e}`),!1}}function xbt(){try{M5(fv)&&Sbt(fv,"utf8")===`${process.pid}`&&Ibt(fv)}catch(e){Ie(`Failed to release lock: ${e}`)}}async function zTe(){try{let e=await Xn("npm -g config get prefix");if(e.code!==0)return Ie("Failed to check npm permissions"),{hasPermissions:!1,npmPrefix:null};let t=e.stdout.trim(),r=!1;try{Ufn(t,Pfn.W_OK),r=!0}catch{r=!1}return r?{hasPermissions:!0,npmPrefix:t}:(Ie("Insufficient permissions for global npm install."),{hasPermissions:!1,npmPrefix:t})}catch(e){return Ie(`Failed to verify npm global install permissions: ${e}`),{hasPermissions:!1,npmPrefix:null}}}async function wbt(e){if(!vbt())throw Bt("tengu_auto_updater_prefix_lock_contention",{pid:String(process.pid),currentVersion:O5.VERSION,prefix:e}),new Error("Another process is currently setting up npm prefix");try{M5(e)||Cbt(e,{recursive:!0});let t=await Xn(`npm -g config set prefix ${e}`);if(t.code!==0)throw new Error(`Failed to set npm prefix: ${t.stderr}`);let r=`
996
996
  # npm global path
997
997
  export PATH="${e}/bin:$PATH"
998
998
  `;if(Tbt==="win32"){let n=await Xn(`setx PATH "${process.env.PATH};${e}"`);if(n.code!==0)throw new Error(`Failed to update PATH on Windows: ${n.stderr}`)}else{let n=[S2(k5(),".bashrc"),S2(k5(),".bash_profile"),S2(k5(),".zshrc"),S2(k5(),".config","fish","config.fish")];for(let i of n)if(M5(i))try{if(!Sbt(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.7.4",
3
+ "version": "2.7.5",
4
4
  "bin": {
5
5
  "hcode": "hawa.js"
6
6
  },