@dahawa/hawa-code 2.7.17 → 2.7.18

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 +3 -3
  2. package/hands.js +3 -3
  3. package/package.json +1 -1
package/cli.js CHANGED
@@ -653,7 +653,7 @@ globstar while`,e,d,t,f,p),this.matchOne(e.slice(d),t.slice(f),r))return this.de
653
653
  `)),UYr(e,o,{encoding:r,flush:!0})}var Zot=new Lj.default({fetchMethod:e=>VYr(e),ttl:300*1e3,ttlAutopurge:!1,max:1e3});async function sit(e){let t=EU(e);return Zot.get(t)||Zot.fetchMethod?.(t)}async function VYr(e){let t=new AbortController;setTimeout(()=>{t.abort()},1e3);let r=await _et(e,t.signal,15),n=0;for(let o of r)M1(o)==="CRLF"&&n++;return n>3?"CRLF":"LF"}function ait(e,t,r){if(e.has(t))return e.get(t);let n=r();return e.set(t,n),n}var WYr=new Lj.default({fetchMethod:e=>lit(e),ttl:300*1e3,ttlAutopurge:!1,max:1e3});function Zd(e){let t=EU(e);return ait(WYr,t,()=>lit(t))}function lit(e){let r=Buffer.alloc(4096),n;try{n=Xot(e,"r");let o=eit(n,r,0,4096,0);return o===0?"utf8":o>=2&&r[0]===255&&r[1]===254?"utf16le":o>=3&&r[0]===239&&r[1]===187&&r[2]===191||r.slice(0,o).toString("utf8").length>0?"utf8":"ascii"}catch(o){return be(`Error detecting encoding for file ${e}: ${o}`),"utf8"}finally{n&&tit(n)}}var jYr=new Lj.default({fetchMethod:e=>cit(e),ttl:300*1e3,ttlAutopurge:!1,max:1e3});function M1(e){let t=EU(e);return ait(jYr,t,()=>cit(t))}function cit(e,t="utf8"){try{if(!rit(e).isFile())return"LF";let n=Buffer.alloc(4096),o=Xot(e,"r"),i=eit(o,n,0,4096,0);tit(o);let s=n.toString(t,0,i),a=0,l=0;for(let c=0;c<s.length;c++)s[c]===`
654
654
  `&&(c>0&&s[c-1]==="\r"?a++:l++);return a>l?"CRLF":"LF"}catch(r){return be(`Error detecting line endings for file ${e}: ${r}`),"LF"}}function gB(e){let t=nit(e)?e:EU(Oe(),e);return t.endsWith(" AM.png")?t.replace(" AM.png","\u202FAM.png"):t.endsWith(" PM.png")?t.replace(" PM.png","\u202FPM.png"):t}function I_e(e){return e?nit(e)?e:EU(Oe(),e):void 0}function uit(e){try{let t=I_e(e),r=t?qYr(Oe(),t):void 0;return{absolutePath:t,relativePath:r}}catch(t){return te("getAbsoluteAndRelativePaths error ",t),{absolutePath:null,relativePath:null}}}function Fj(e){try{let t=YYr(e),r=jot(e,Kot(e));if(!GYr(t))return;let i=HYr(t).filter(s=>jot(s,Kot(s))===r&&zYr(t,s)!==e)[0];return i||void 0}catch(t){be(`Error finding similar file for ${e}: ${t}`);return}}function v_e(){let e=process.env.HAWA_CODE_COMPACT_LINE_PREFIX;return!(e==="0"||e==="false")}function lC({content:e,startLine:t}){if(!e)return"";let r=e.split(/\r?\n/);return v_e()?r.map((n,o)=>`${o+t} ${n}`).join(`
655
655
  `):r.map((n,o)=>{let i=String(o+t);return i.length>=6?`${i}\u2192${n}`:`${i.padStart(6," ")}\u2192${n}`}).join(`
656
- `)}function dit(e){try{let t=$Yr(e),r=t.readSync();return t.closeSync(),r===null}catch(t){return be(`Error checking directory: ${t}`),!1}}Pe();function oC(){let e=Nn();e.hasCompletedProjectOnboarding||ti({...e,hasCompletedProjectOnboarding:!0})}function x_e({workspaceDir:e}){let r=!Nn().hasCompletedProjectOnboarding;if(!r)return null;let n=KYr(JYr(e,Qo)),o=dit(e),i=!n&&!o,s=lB.isEnabled&&!Qr().shiftEnterKeyBindingInstalled,a=re();return(0,h.jsxs)(x,{flexDirection:"column",gap:1,padding:1,paddingBottom:0,children:[r&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(I,{color:a.secondaryText,children:"Tips for getting started:"}),(0,h.jsx)(Dc,{children:(()=>{let l=[];return o&&l.push((0,h.jsx)(Dc.Item,{children:(0,h.jsxs)(I,{color:a.secondaryText,children:["Ask ",it," to create a new app or clone a repository."]})},"workspace")),i&&l.push((0,h.jsx)(Dc.Item,{children:(0,h.jsxs)(I,{color:a.secondaryText,children:["Run ",(0,h.jsx)(I,{color:a.text,children:"/init"})," to create a",Qo," file with instructions for Hawa code."]})},"claudemd")),s&&l.push((0,h.jsx)(Dc.Item,{children:(0,h.jsxs)(I,{color:a.secondaryText,children:["Run ",(0,h.jsx)(I,{color:a.text,children:"/terminal-setup"}),(0,h.jsx)(I,{bold:!1,children:" to set up terminal integration"})]})},"terminal")),l.push((0,h.jsx)(Dc.Item,{children:(0,h.jsxs)(I,{color:a.secondaryText,children:["Ask ",it," questions about your codebase."]})},"questions")),l.push((0,h.jsx)(Dc.Item,{children:(0,h.jsxs)(I,{color:a.secondaryText,children:["Ask ",it," to implement changes to your codebase."]})},"changes")),l})()})]}),e===ZYr()&&(0,h.jsxs)(I,{color:re().warning,children:["Note: You have launched ",(0,h.jsx)(I,{bold:!0,children:it})," in your home directory. For the best experience, launch it in a project directory instead."]})]})}function w_e({isFocused:e,isSelected:t,smallPointer:r,children:n}){let{styles:o}=Ai("Select");return(0,h.jsxs)(x,{...o.option({isFocused:e}),children:[e&&(0,h.jsx)(I,{...o.focusIndicator(),children:r?nr.triangleDownSmall:nr.pointer}),(0,h.jsx)(I,{...o.label({isFocused:e,isSelected:t}),children:n}),t&&(0,h.jsx)(I,{...o.selectedIndicator(),children:nr.tick})]})}var Xd=Ie(Ve(),1);import{isDeepStrictEqual as XYr}from"node:util";var bU=class extends Map{first;constructor(t){let r=[],n,o,i=0;for(let s of t){let a={...s,previous:o,next:void 0,index:i};o&&(o.next=a),n||=a;let l="value"in s?s.value:R_e(s);r.push([l,a]),i++,o=a}super(r),this.first=n}};var ezr=(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;for(;n&&!("value"in n);)n=n.next;if(!n)return e;if(!(n.index>=e.visibleToIndex))return{...e,focusedValue:n.value};let i=Math.min(e.optionMap.size,e.visibleToIndex+1),s=i-e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:s,visibleToIndex:i}}case"focus-previous-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.previous;for(;n&&!("value"in n);)n=n.previous;if(!n)return e;if(!(n.index<=e.visibleFromIndex))return{...e,focusedValue:n.value};let i=Math.max(0,e.visibleFromIndex-1),s=i+e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:i,visibleToIndex:s}}case"select-focused-option":return{...e,previousValue:e.value,value:e.focusedValue};case"reset":return t.state;case"set-focus":return{...e,focusedValue:t.value}}},N_e=e=>e.flatMap(t=>{if("options"in t){let r=N_e(t.options),n=r.flatMap(i=>"value"in i?i.value:[]);return[...t.header!==void 0?[{header:t.header,optionValues:n}]:[],...r]}return t}),pit=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=N_e(r),o=typeof e=="number"?Math.min(e,n.length):n.length,i=new bU(n),s=i.first,a=s&&"value"in s?s.value:void 0;return{optionMap:i,visibleOptionCount:o,focusedValue:a,visibleFromIndex:0,visibleToIndex:o,previousValue:t,value:t}},D_e=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n,onFocus:o,focusValue:i})=>{let s=N_e(t),[a,l]=(0,Xd.useReducer)(ezr,{visibleOptionCount:e,defaultValue:r,options:t},pit),[c,u]=(0,Xd.useState)(s);s!==c&&!XYr(s,c)&&(l({type:"reset",state:pit({visibleOptionCount:e,defaultValue:r,options:t})}),u(s));let d=(0,Xd.useCallback)(()=>{l({type:"focus-next-option"})},[]),f=(0,Xd.useCallback)(()=>{l({type:"focus-previous-option"})},[]),p=(0,Xd.useCallback)(()=>{l({type:"select-focused-option"})},[]),A=(0,Xd.useMemo)(()=>s.map((_,E)=>({..._,index:E})).slice(a.visibleFromIndex,a.visibleToIndex),[s,a.visibleFromIndex,a.visibleToIndex]);return(0,Xd.useEffect)(()=>{a.value&&a.previousValue!==a.value&&n?.(a.value)},[a.previousValue,a.value,t,n]),(0,Xd.useEffect)(()=>{a.focusedValue&&o?.(a.focusedValue)},[a.focusedValue,o]),(0,Xd.useEffect)(()=>{i&&l({type:"set-focus",value:i})},[i]),{focusedValue:a.focusedValue,visibleFromIndex:a.visibleFromIndex,visibleToIndex:a.visibleToIndex,value:a.value,visibleOptions:A,focusNextOption:d,focusPreviousOption:f,selectFocusedOption:p}};var O_e=({isDisabled:e=!1,state:t})=>{ft((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};var R_e=e=>`HEADER-${e.optionValues.join(",")}`;function Fb({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a}){let l=D_e({visibleOptionCount:t,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a});O_e({isDisabled:e,state:l});let{styles:c}=Ai("Select");return(0,h.jsx)(x,{...c.container(),children:l.visibleOptions.map(u=>{let d="value"in u?u.value:R_e(u),f=!e&&l.focusedValue!==void 0&&("value"in u?l.focusedValue===u.value:u.optionValues.includes(l.focusedValue)),p=!!l.value&&("value"in u?l.value===u.value:u.optionValues.includes(l.value)),A="header"in u,_="label"in u?u.label:u.header,E=_;if(r&&_.includes(r)){let S=_.indexOf(r);E=(0,h.jsxs)(h.Fragment,{children:[_.slice(0,S),(0,h.jsx)(I,{...c.highlightedText(),children:r}),_.slice(S+r.length)]})}return(0,h.jsx)(w_e,{isFocused:f,isSelected:p,smallPointer:A,children:E},d)})})}function mit({onDone:e}){return ft((t,r)=>{(r.ctrl&&(t==="c"||t==="d")||r.escape)&&e()}),(0,h.jsxs)(x,{flexDirection:"column",borderStyle:"round",padding:1,borderColor:re().secondaryBorder,children:[(0,h.jsx)(x,{marginBottom:1,flexDirection:"column",children:(0,h.jsx)(I,{bold:!0,children:"You've spent $5 this session."})}),(0,h.jsx)(x,{children:(0,h.jsx)(Fb,{options:[{value:"ok",label:"Got it, thanks!"}],onChange:e})})]})}var Jt=Ie(Ve(),1);Pe();lr();r_();var nzr="2.7.17",n_={VERSION:nzr,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"};var k_e=46,hit=["(\u2740\u2579\u25E1\u2579)","(\u25D5\u072B\u25D5)","\u239D(\u25D5u\u25D5)\u23A0","\u10DA(\u25C9\u25DE\u0C6A\u25DF\u25C9 )\u10DA","(\xB4\u25C9\u203F\u25C9\uFF40)","\u0E01\u0E47\u0295\u2022\u0361\u1D25\u2022\u0294 \u0E01\u0E49","\uFF0F/( \u25D5\u203F\u203F\u25D5 )\uFF3C"];function Qj({isDefaultModel:e=!1}){let t=Math.max(k_e,Oe().length+12),r=re(),n=hit[Math.floor(Math.random()*hit.length)];return(0,h.jsx)(x,{flexDirection:"column",children:(0,h.jsxs)(x,{flexDirection:"column",gap:1,paddingLeft:1,width:"100%",children:[(0,h.jsxs)(I,{children:[(0,h.jsx)(I,{children:n})," Welcome to"," ",(0,h.jsx)(I,{bold:!0,children:it}),(0,h.jsxs)(I,{color:r.secondaryText,children:[" v",n_.VERSION]})]}),(0,h.jsx)(h.Fragment,{children:(0,h.jsxs)(x,{paddingLeft:2,flexDirection:"column",gap:1,children:[(0,h.jsx)(I,{color:r.secondaryText,italic:!0,children:"/help for help"}),(0,h.jsxs)(I,{color:r.secondaryText,children:["cwd: ",Oe()]}),(0,h.jsxs)(I,{color:r.secondaryText,children:["model: ",Jn.getConfig().routing.MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A"]}),(0,h.jsxs)(I,{color:r.secondaryText,children:["small fast model: ",Jn.getConfig().routing.SMALL_FAST_MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A"]})]})})]})})}we();import{randomUUID as $g}from"crypto";ji();we();er();lr();we();Pe();import{existsSync as Gb,readdirSync as Ojr,statSync as Bjr}from"fs";import{join as mC,relative as Mjr}from"path";import{homedir as clt}from"os";import{platform as kjr}from"process";import{readFile as fC}from"fs/promises";lr();um();Kt();import{join as czr,sep as uzr}from"path";function ld(){if(!Oc())return!1;try{let e=Je();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function ep(){return(czr(Oe(),".hcode","team-memory")+uzr).normalize("NFC")}function zf(e){let t=e.normalize("NFC"),r=ep();return t.startsWith(r)}um();var ult=Ie(RU(),1);po();var X_e=(e,t,r)=>{let n=e instanceof RegExp?Pat(e,r):e,o=t instanceof RegExp?Pat(t,r):t,i=n!==null&&o!=null&&y7r(n,o,r);return i&&{start:i[0],end:i[1],pre:r.slice(0,i[0]),body:r.slice(i[0]+n.length,i[1]),post:r.slice(i[1]+o.length)}},Pat=(e,t)=>{let r=t.match(e);return r?r[0]:null},y7r=(e,t,r)=>{let n,o,i,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=[],i=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 o=n.pop(),o!==void 0&&o<i&&(i=o,s=c),c=r.indexOf(t,u+1);u=l<c&&l>=0?l:c}n.length&&s!==void 0&&(a=[i,s])}return a};var Fat="\0SLASH"+Math.random()+"\0",Qat="\0OPEN"+Math.random()+"\0",rEe="\0CLOSE"+Math.random()+"\0",Uat="\0COMMA"+Math.random()+"\0",Gat="\0PERIOD"+Math.random()+"\0",C7r=new RegExp(Fat,"g"),T7r=new RegExp(Qat,"g"),I7r=new RegExp(rEe,"g"),v7r=new RegExp(Uat,"g"),x7r=new RegExp(Gat,"g"),w7r=/\\\\/g,R7r=/\\{/g,N7r=/\\}/g,D7r=/\\,/g,O7r=/\\\./g,B7r=1e5,M7r=4e6;function eEe(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function k7r(e){return e.replace(w7r,Fat).replace(R7r,Qat).replace(N7r,rEe).replace(D7r,Uat).replace(O7r,Gat)}function L7r(e){return e.replace(C7r,"\\").replace(T7r,"{").replace(I7r,"}").replace(v7r,",").replace(x7r,".")}function Hat(e){if(!e)return[""];let t=[],r=X_e("{","}",e);if(!r)return e.split(",");let{pre:n,body:o,post:i}=r,s=n.split(",");s[s.length-1]+="{"+o+"}";let a=Hat(i);return i.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function $at(e,t={}){if(!e)return[];let{max:r=B7r,maxLength:n=M7r}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),tEe(k7r(e),r,n,!0).map(L7r)}function P7r(e){return"{"+e+"}"}function F7r(e){return/^-?0\d/.test(e)}function Q7r(e,t){return e<=t}function U7r(e,t){return e>=t}function NU(e,t,r,n,o,i){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(!(i&&!u)){if(a+u.length>o)return s;s.push(u),a+=u.length}}return s}function G7r(e,t,r,n){let o=e.split(/\.\./),i=[];if(o[0]===void 0||o[1]===void 0)return i;let s=eEe(o[0]),a=eEe(o[1]),l=Math.max(o[0].length,o[1].length),c=o.length===3&&o[2]!==void 0?Math.max(Math.abs(eEe(o[2])),1):1,u=Q7r;a<s&&(c*=-1,u=U7r);let f=o.some(F7r),p=0;for(let A=s;u(A,a)&&i.length<r;A+=c){let _;if(t)_=String.fromCharCode(A),_==="\\"&&(_="");else if(_=String(A),f){let E=l-_.length;if(E>0){let S=new Array(E+1).join("0");A<0?_="-"+S+_.slice(1):_=S+_}}if(p+_.length>n)break;i.push(_),p+=_.length}return i}function tEe(e,t,r,n){let o=[""],i=!1,s=!0;for(;;){let a=X_e("{","}",e);if(!a)return NU(o,e,[""],t,r,i);let l=a.pre;if(/\$$/.test(l)){if(o=NU(o,l+"{"+a.body+"}",[""],t,r,i&&!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,f=a.body.indexOf(",")>=0;if(!d&&!f){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+rEe+a.post,n=!0;continue}return NU(o,l+"{"+a.body+"}"+a.post,[""],t,r,i)}s&&(i=n&&!d,s=!1);let p;if(d)p=G7r(a.body,u,t,r);else{let A=Hat(a.body);if(A.length===1&&A[0]!==void 0&&(A=tEe(A[0],t,r,!1).map(P7r),A.length===1)){if(o=NU(o,l+A[0],[""],t,r,i&&!a.post.length),!a.post.length)break;e=a.post;continue}let _=i&&!a.post.length&&!l;for(let S=0;_&&S<o.length;S++)o[S]&&(_=!1);p=[];let E=0;e:for(let S=0;S<A.length;S++){let C=tEe(A[S],t,r,!1);for(let v=0;v<C.length;v++){let R=C[v];if(!(_&&!R)){if(p.length>=t||E+R.length>r)break e;p.push(R),E+=R.length}}}}if(o=NU(o,l,p,t,r,i&&!a.post.length),!a.post.length)break;e=a.post}return o}var DU=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var H7r={"[: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]},OU=e=>e.replace(/[[\]\\-]/g,"\\$&"),$7r=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),qat=e=>e.join(""),Yat=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],o=[],i=r+1,s=!1,a=!1,l=!1,c=!1,u=r,d="";e:for(;i<e.length;){let _=e.charAt(i);if((_==="!"||_==="^")&&i===r+1){c=!0,i++;continue}if(_==="]"&&s&&!l){u=i+1;break}if(s=!0,_==="\\"&&!l){l=!0,i++;continue}if(_==="["&&!l){for(let[E,[S,C,v]]of Object.entries(H7r))if(e.startsWith(E,i)){if(d)return["$.",!1,e.length-r,!0];i+=E.length,v?o.push(S):n.push(S),a=a||C;continue e}}if(l=!1,d){_>d?n.push(OU(d)+"-"+OU(_)):_===d&&n.push(OU(_)),d="",i++;continue}if(e.startsWith("-]",i+1)){n.push(OU(_+"-")),i+=2;continue}if(e.startsWith("-",i+1)){d=_,i+=2;continue}n.push(OU(_)),i++}if(u<i)return["",!1,0,!1];if(!n.length&&!o.length)return["$.",!1,e.length-r,!0];if(o.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!c){let _=n[0].length===2?n[0].slice(-1):n[0];return[$7r(_),!1,u-r,!1]}let f="["+(c?"^":"")+qat(n)+"]",p="["+(c?"":"^")+qat(o)+"]";return[n.length&&o.length?"("+f+"|"+p+")":n.length?f:p,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 rp,q7r=new Set(["!","?","+","*","@"]),nEe=e=>q7r.has(e),zat=e=>nEe(e.type),Y7r=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),z7r=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),V7r=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),Vat=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),W7r="(?!(?:^|/)\\.\\.?(?:$|/))",Jj="(?!\\.)",j7r=new Set(["[","."]),K7r=new Set(["..","."]),J7r=new Set("().*{}+?[]^$\\!"),Z7r=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),oEe="[^/]",Wat=oEe+"*?",jat=oEe+"+?",X7r=0,H1=class{type;#e;#t;#n=!1;#r=[];#i;#o;#l;#s=!1;#a;#d;#m=!1;id=++X7r;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(t,r,n={}){this.type=t,t&&(this.#t=!0),this.#i=r,this.#e=this.#i?this.#i.#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.#o=this.#i?this.#i.#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("")}#p(){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.#i;for(;n;){for(let o=r.#o+1;!n.type&&o<n.#r.length;o++)for(let i of t.#r){if(typeof i=="string")throw new Error("string part in extglob AST??");i.copyIn(n.#r[o])}r=n,n=r.#i}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof rp&&r.#i===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.#i?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#o===0)return!0;let t=this.#i;for(let r=0;r<this.#o;r++){let n=t.#r[r];if(!(n instanceof rp&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let t=this.#i?this.#i.#r.length:0;return this.#o===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new rp(this.type,t);for(let n of this.#r)r.copyIn(n);return r}static#c(t,r,n,o,i){let s=o.maxExtglobRecursion??2,a=!1,l=!1,c=-1,u=!1;if(r.type===null){let _=n,E="";for(;_<t.length;){let S=t.charAt(_++);if(a||S==="\\"){a=!a,E+=S;continue}if(l){_===c+1?(S==="^"||S==="!")&&(u=!0):S==="]"&&!(_===c+2&&u)&&(l=!1),E+=S;continue}else if(S==="["){l=!0,c=_,u=!1,E+=S;continue}if(!o.noext&&nEe(S)&&t.charAt(_)==="("&&i<=s){r.push(E),E="";let v=new rp(S,r);_=rp.#c(t,v,_,o,i+1),r.push(v);continue}E+=S}return r.push(E),_}let d=n+1,f=new rp(null,r),p=[],A="";for(;d<t.length;){let _=t.charAt(d++);if(a||_==="\\"){a=!a,A+=_;continue}if(l){d===c+1?(_==="^"||_==="!")&&(u=!0):_==="]"&&!(d===c+2&&u)&&(l=!1),A+=_;continue}else if(_==="["){l=!0,c=d,u=!1,A+=_;continue}if(!o.noext&&nEe(_)&&t.charAt(d)==="("&&(i<=s||r&&r.#_(_))){let S=r&&r.#_(_)?0:1;f.push(A),A="";let C=new rp(_,f);f.push(C),d=rp.#c(t,C,d,o,i+S);continue}if(_==="|"){f.push(A),A="",p.push(f),f=new rp(null,r);continue}if(_===")")return A===""&&r.#r.length===0&&(r.#m=!0),f.push(A),A="",r.push(...p,f),d;A+=_}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],d}#g(t){return this.#A(t,z7r)}#A(t,r=Y7r){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.#_(n.type,r)}#_(t,r=V7r){return!!r.get(this.type)?.includes(t)}#h(t,r){let n=t.#r[0],o=new rp(null,n,this.options);o.#r.push(""),n.push(o),this.#v(t,r)}#v(t,r){let n=t.#r[0];this.#r.splice(r,1,...n.#r);for(let o of n.#r)typeof o=="object"&&(o.#i=this);this.#d=void 0}#b(t){return!!Vat.get(this.type)?.has(t)}#C(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.#b(r.type)}#T(t){let r=Vat.get(this.type),n=t.#r[0],o=r?.get(n.type);if(!o)return!1;this.#r=n.#r;for(let i of this.#r)typeof i=="object"&&(i.#i=this);this.type=o,this.#d=void 0,this.#m=!1}static fromGlob(t,r={}){let n=new rp(null,void 0,r);return rp.#c(t,n,0,r,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[r,n,o,i]=this.toRegExpSource();if(!(o||this.#t||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(i?"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.#E(),this.#p()),!zat(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(p=>typeof p!="string"),c=this.#r.map(p=>{let[A,_,E,S]=typeof p=="string"?rp.#y(p,this.#t,l):p.toRegExpSource(t);return this.#t=this.#t||E,this.#n=this.#n||S,A}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&K7r.has(this.#r[0]))){let A=j7r,_=r&&A.has(c.charAt(0))||c.startsWith("\\.")&&A.has(c.charAt(2))||c.startsWith("\\.\\.")&&A.has(c.charAt(4)),E=!r&&!t&&A.has(c.charAt(0));u=_?W7r:E?Jj:""}let d="";return this.isEnd()&&this.#e.#s&&this.#i?.type==="!"&&(d="(?:$|\\/)"),[u+c+d,pC(c),this.#t=!!this.#t,this.#n]}let n=this.type==="*"||this.type==="+",o=this.type==="!"?"(?:(?!(?:":"(?:",i=this.#S(r);if(this.isStart()&&this.isEnd()&&!i&&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||!Jj?"":this.#S(!0);s===i&&(s=""),s&&(i=`(?:${i})(?:${s})*?`);let a="";if(this.type==="!"&&this.#m)a=(this.isStart()&&!r?Jj:"")+jat;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?Jj:"")+Wat+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=o+i+l}return[a,pC(i),this.#t=!!this.#t,this.#n]}#E(){if(zat(this)){let t=0,r=!1;do{r=!0;for(let n=0;n<this.#r.length;n++){let o=this.#r[n];typeof o=="object"&&(o.#E(),this.#A(o)?(r=!1,this.#v(o,n)):this.#g(o)?(r=!1,this.#h(o,n)):this.#C(o)&&(r=!1,this.#T(o)))}}while(!r&&++t<10)}else for(let t of this.#r)typeof t=="object"&&t.#E();this.#d=void 0}#S(t){return this.#r.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,o,i,s]=r.toRegExpSource(t);return this.#n=this.#n||s,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#y(t,r,n=!1){let o=!1,i="",s=!1,a=!1;for(let l=0;l<t.length;l++){let c=t.charAt(l);if(o){o=!1,i+=(J7r.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,i+=n&&/^[*]+$/.test(t)?jat:Wat,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?i+="\\\\":o=!0;continue}if(c==="["){let[u,d,f,p]=Yat(t,l);if(f){i+=u,s=s||d,l+=f-1,r=r||p;continue}}if(c==="?"){i+=oEe,r=!0;continue}i+=Z7r(c)}return[i,pC(t),!!r,s]}};rp=H1;var iEe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var Bc=(e,t,r={})=>(DU(t),!r.nocomment&&t.charAt(0)==="#"?!1:new vB(t,r).match(e)),ejr=/^\*+([^+@!?*[(]*)$/,tjr=e=>t=>!t.startsWith(".")&&t.endsWith(e),rjr=e=>t=>t.endsWith(e),njr=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),ojr=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),ijr=/^\*+\.\*+$/,sjr=e=>!e.startsWith(".")&&e.includes("."),ajr=e=>e!=="."&&e!==".."&&e.includes("."),ljr=/^\.\*+$/,cjr=e=>e!=="."&&e!==".."&&e.startsWith("."),ujr=/^\*+$/,djr=e=>e.length!==0&&!e.startsWith("."),pjr=e=>e.length!==0&&e!=="."&&e!=="..",mjr=/^\?+([^+@!?*[(]*)?$/,fjr=([e,t=""])=>{let r=Zat([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},gjr=([e,t=""])=>{let r=Xat([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},hjr=([e,t=""])=>{let r=Xat([e]);return t?n=>r(n)&&n.endsWith(t):r},Ajr=([e,t=""])=>{let r=Zat([e]);return t?n=>r(n)&&n.endsWith(t):r},Zat=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},Xat=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},elt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Kat={win32:{sep:"\\"},posix:{sep:"/"}},_jr=elt==="win32"?Kat.win32.sep:Kat.posix.sep;Bc.sep=_jr;var wu=Symbol("globstar **");Bc.GLOBSTAR=wu;var Ejr="[^/]",bjr=Ejr+"*?",Sjr="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",yjr="(?:(?!(?:\\/|^)\\.).)*?",Cjr=(e,t={})=>r=>Bc(r,e,t);Bc.filter=Cjr;var Vf=(e,t={})=>Object.assign({},e,t),Tjr=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return Bc;let t=Bc;return Object.assign((n,o,i={})=>t(n,o,Vf(e,i)),{Minimatch:class extends t.Minimatch{constructor(o,i={}){super(o,Vf(e,i))}static defaults(o){return t.defaults(Vf(e,o)).Minimatch}},AST:class extends t.AST{constructor(o,i,s={}){super(o,i,Vf(e,s))}static fromGlob(o,i={}){return t.AST.fromGlob(o,Vf(e,i))}},unescape:(n,o={})=>t.unescape(n,Vf(e,o)),escape:(n,o={})=>t.escape(n,Vf(e,o)),filter:(n,o={})=>t.filter(n,Vf(e,o)),defaults:n=>t.defaults(Vf(e,n)),makeRe:(n,o={})=>t.makeRe(n,Vf(e,o)),braceExpand:(n,o={})=>t.braceExpand(n,Vf(e,o)),match:(n,o,i={})=>t.match(n,o,Vf(e,i)),sep:t.sep,GLOBSTAR:wu})};Bc.defaults=Tjr;var tlt=(e,t={})=>(DU(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:$at(e,{max:t.braceExpandMax}));Bc.braceExpand=tlt;var Ijr=(e,t={})=>new vB(e,t).makeRe();Bc.makeRe=Ijr;var vjr=(e,t,r={})=>{let n=new vB(t,r);return e=e.filter(o=>n.match(o)),n.options.nonull&&!e.length&&e.push(t),e};Bc.match=vjr;var Jat=/[?*]|[+@!]\(.*?\)|\[|\]/,xjr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),vB=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){DU(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||elt,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=(...i)=>console.error(...i)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(i=>this.slashSplit(i));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let o=this.globParts.map((i,s,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=i[0]===""&&i[1]===""&&(i[2]==="?"||!Jat.test(i[2]))&&!Jat.test(i[3]),c=/^[a-z]:/i.test(i[0]);if(l)return[...i.slice(0,4),...i.slice(4).map(u=>this.parse(u))];if(c)return[i[0],...i.slice(1).map(u=>this.parse(u))]}return i.map(l=>this.parse(l))});if(this.debug(this.pattern,o),this.set=o.filter(i=>i.indexOf(!1)===-1),this.isWindows)for(let i=0;i<this.set.length;i++){let s=this.set[i];s[0]===""&&s[1]===""&&this.globParts[i][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 o=0;o<n.length;o++)n[o]==="**"&&(n[o]="*");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 o=n;for(;r[o+1]==="**";)o++;o!==n&&r.splice(n,o-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,o)=>{let i=n[n.length-1];return o==="**"&&i==="**"?n:o===".."&&i&&i!==".."&&i!=="."&&i!=="**"?(n.pop(),n):(n.push(o),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 o=1;o<t.length-1;o++){let i=t[o];o===1&&i===""&&t[0]===""||(i==="."||i==="")&&(r=!0,t.splice(o,1),o--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let o=t[n-1];o&&o!=="."&&o!==".."&&o!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(o))&&(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 o=-1;for(;(o=n.indexOf("**",o+1))!==-1;){let s=o;for(;n[s+1]==="**";)s++;s>o&&n.splice(o+1,s-o);let a=n[o+1],l=n[o+2],c=n[o+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(o,1);let u=n.slice(0);u[o]="**",t.push(u),o--}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 i=0;for(;(i=n.indexOf("..",i+1))!==-1;){let s=n[i-1];if(s&&s!=="."&&s!==".."&&s!=="**"){r=!0;let l=i===1&&n[i+1]==="**"?["."]:[];n.splice(i-1,2,...l),n.length===0&&n.push(""),i-=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 o=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(o){t[r]=[],t[n]=o;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let o=0,i=0,s=[],a="";for(;o<t.length&&i<r.length;)if(t[o]===r[i])s.push(a==="b"?r[i]:t[o]),o++,i++;else if(n&&t[o]==="**"&&r[i]===t[o+1])s.push(t[o]),o++;else if(n&&r[i]==="**"&&t[o]===r[i+1])s.push(r[i]),i++;else if(t[o]==="*"&&r[i]&&(this.options.dot||!r[i].startsWith("."))&&r[i]!=="**"){if(a==="b")return!1;a="a",s.push(t[o]),o++,i++}else if(r[i]==="*"&&t[o]&&(this.options.dot||!t[o].startsWith("."))&&t[o]!=="**"){if(a==="a")return!1;a="b",s.push(r[i]),o++,i++}else return!1;return t.length===r.length&&s}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let o=0;o<t.length&&t.charAt(o)==="!";o++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let o=0,i=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,f=u?3:c?0:void 0;if(typeof d=="number"&&typeof f=="number"){let[p,A]=[t[d],r[f]];p.toLowerCase()===A.toLowerCase()&&(r[f]=p,i=f,o=d)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(wu)?this.#e(t,r,n,o,i):this.#n(t,r,n,o,i)}#e(t,r,n,o,i){let s=r.indexOf(wu,i),a=r.lastIndexOf(wu),[l,c,u]=n?[r.slice(i,s),r.slice(s+1),[]]:[r.slice(i,s),r.slice(s+1,a),r.slice(a+1)];if(l.length){let C=t.slice(o,o+l.length);if(!this.#n(C,l,n,0,0))return!1;o+=l.length,i+=l.length}let d=0;if(u.length){if(u.length+o>t.length)return!1;let C=t.length-u.length;if(this.#n(t,u,n,C,0))d=u.length;else{if(t[t.length-1]!==""||o+u.length===t.length||(C--,!this.#n(t,u,n,C,0)))return!1;d=u.length+1}}if(!c.length){let C=!!d;for(let v=o;v<t.length-d;v++){let R=String(t[v]);if(C=!0,R==="."||R===".."||!this.options.dot&&R.startsWith("."))return!1}return n||C}let f=[[[],0]],p=f[0],A=0,_=[0];for(let C of c)C===wu?(_.push(A),p=[[],0],f.push(p)):(p[0].push(C),A++);let E=f.length-1,S=t.length-d;for(let C of f)C[1]=S-(_[E--]+C[0].length);return!!this.#t(t,f,o,0,n,0,!!d)}#t(t,r,n,o,i,s,a){let l=r[o];if(!l){for(let d=n;d<t.length;d++){a=!0;let f=t[d];if(f==="."||f===".."||!this.options.dot&&f.startsWith("."))return!1}return a}let[c,u]=l;for(;n<=u;){if(this.#n(t.slice(0,n+c.length),c,i,n,0)&&s<this.maxGlobstarRecursion){let p=this.#t(t,r,n+c.length,o+1,i,s+1,a);if(p!==!1)return p}let f=t[n];if(f==="."||f===".."||!this.options.dot&&f.startsWith("."))return!1;n++}return i||null}#n(t,r,n,o,i){let s,a,l,c;for(s=o,a=i,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===wu)return!1;let f;if(typeof u=="string"?(f=d===u,this.debug("string match",u,d,f)):(f=u.test(d),this.debug("pattern match",u,d,f)),!f)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 tlt(this.pattern,this.options)}parse(t){DU(t);let r=this.options;if(t==="**")return wu;if(t==="")return"";let n,o=null;(n=t.match(ujr))?o=r.dot?pjr:djr:(n=t.match(ejr))?o=(r.nocase?r.dot?ojr:njr:r.dot?rjr:tjr)(n[1]):(n=t.match(mjr))?o=(r.nocase?r.dot?gjr:fjr:r.dot?hjr:Ajr)(n):(n=t.match(ijr))?o=r.dot?ajr:sjr:(n=t.match(ljr))&&(o=cjr);let i=H1.fromGlob(t,this.options).toMMPattern();return o&&typeof i=="object"&&Reflect.defineProperty(i,"test",{value:o}),i}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?bjr:r.dot?Sjr:yjr,o=new Set(r.nocase?["i"]:[]),i=t.map(l=>{let c=l.map(d=>{if(d instanceof RegExp)for(let f of d.flags.split(""))o.add(f);return typeof d=="string"?xjr(d):d===wu?wu:d._src});c.forEach((d,f)=>{let p=c[f+1],A=c[f-1];d!==wu||A===wu||(A===void 0?p!==void 0&&p!==wu?c[f+1]="(?:\\/|"+n+"\\/)?"+p:c[f]=n:p===void 0?c[f-1]=A+"(?:\\/|\\/"+n+")?":p!==wu&&(c[f-1]=A+"(?:\\/|\\/"+n+"\\/)"+p,c[f+1]=wu))});let u=c.filter(d=>d!==wu);if(this.partial&&u.length>=1){let d=[];for(let f=1;f<=u.length;f++)d.push(u.slice(0,f).join("/"));return"(?:"+d.join("|")+")"}return u.join("/")}).join("|"),[s,a]=t.length>1?["(?:",")"]:["",""];i="^"+s+i+a+"$",this.partial&&(i="^(?:\\/|"+s+i.slice(1,-1)+a+")$"),this.negate&&(i="^(?!"+i+").+$");try{this.regexp=new RegExp(i,[...o].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 o=this.slashSplit(t);this.debug(this.pattern,"split",o);let i=this.set;this.debug(this.pattern,"set",i);let s=o[o.length-1];if(!s)for(let a=o.length-2;!s&&a>=0;a--)s=o[a];for(let a of i){let l=o;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 Bc.defaults(t).Minimatch}};Bc.AST=H1;Bc.Minimatch=vB;Bc.escape=iEe;Bc.unescape=pC;var olt=Ie(RU(),1);lr();Pe();we();nd();import{readFile as rlt}from"fs/promises";import{existsSync as sEe,readdirSync as wjr,statSync as Rjr}from"fs";import{join as aEe,relative as ilt}from"path";import{homedir as Njr}from"os";function nlt(e){try{let t=(0,olt.default)(e),r=t.data.paths,n=[];return typeof r=="string"?n=r.split(",").map(o=>o.trim()).filter(Boolean):Array.isArray(r)&&(n=r.filter(o=>typeof o=="string")),{paths:n,content:t.content.trim()}}catch(t){return be(t),{paths:[],content:e.trim()}}}function Djr(e,t){return t.length===0?!0:t.some(r=>{try{return Bc(e,r,{matchBase:!0,dot:!0})}catch(n){return be(n),!1}})}function lEe(e){let t=[];try{if(!sEe(e))return t;let r=wjr(e);for(let n of r){let o=aEe(e,n),i=Rjr(o);i.isDirectory()?t.push(...lEe(o)):i.isFile()&&n.endsWith(".md")&&t.push(o)}}catch(r){be(r)}return t}async function Zj(){let e=[];try{let t=aEe(Njr(),Tn,"rules");if(sEe(t)){let r=lEe(t);for(let n of r)try{let o=await rlt(n,"utf-8"),{paths:i,content:s}=nlt(o);i.length>0&&e.push({filePath:n,content:s,paths:i,isProjectRule:!1})}catch(o){be(o)}}}catch(t){be(t)}try{let t=aEe(Oe(),Tn,"rules");if(sEe(t)){let r=lEe(t);for(let n of r)try{let o=await rlt(n,"utf-8"),{paths:i,content:s}=nlt(o);i.length>0&&e.push({filePath:ilt(Oe(),n),content:s,paths:i,isProjectRule:!0})}catch(o){be(o)}}}catch(t){be(t)}return e}function slt(e,t){e=B7(e);let r=B7(Oe()),n=e.startsWith(r)?ilt(r,e):e;return t.filter(o=>Djr(n,o.paths))}function alt(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}):
656
+ `)}function dit(e){try{let t=$Yr(e),r=t.readSync();return t.closeSync(),r===null}catch(t){return be(`Error checking directory: ${t}`),!1}}Pe();function oC(){let e=Nn();e.hasCompletedProjectOnboarding||ti({...e,hasCompletedProjectOnboarding:!0})}function x_e({workspaceDir:e}){let r=!Nn().hasCompletedProjectOnboarding;if(!r)return null;let n=KYr(JYr(e,Qo)),o=dit(e),i=!n&&!o,s=lB.isEnabled&&!Qr().shiftEnterKeyBindingInstalled,a=re();return(0,h.jsxs)(x,{flexDirection:"column",gap:1,padding:1,paddingBottom:0,children:[r&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(I,{color:a.secondaryText,children:"Tips for getting started:"}),(0,h.jsx)(Dc,{children:(()=>{let l=[];return o&&l.push((0,h.jsx)(Dc.Item,{children:(0,h.jsxs)(I,{color:a.secondaryText,children:["Ask ",it," to create a new app or clone a repository."]})},"workspace")),i&&l.push((0,h.jsx)(Dc.Item,{children:(0,h.jsxs)(I,{color:a.secondaryText,children:["Run ",(0,h.jsx)(I,{color:a.text,children:"/init"})," to create a",Qo," file with instructions for Hawa code."]})},"claudemd")),s&&l.push((0,h.jsx)(Dc.Item,{children:(0,h.jsxs)(I,{color:a.secondaryText,children:["Run ",(0,h.jsx)(I,{color:a.text,children:"/terminal-setup"}),(0,h.jsx)(I,{bold:!1,children:" to set up terminal integration"})]})},"terminal")),l.push((0,h.jsx)(Dc.Item,{children:(0,h.jsxs)(I,{color:a.secondaryText,children:["Ask ",it," questions about your codebase."]})},"questions")),l.push((0,h.jsx)(Dc.Item,{children:(0,h.jsxs)(I,{color:a.secondaryText,children:["Ask ",it," to implement changes to your codebase."]})},"changes")),l})()})]}),e===ZYr()&&(0,h.jsxs)(I,{color:re().warning,children:["Note: You have launched ",(0,h.jsx)(I,{bold:!0,children:it})," in your home directory. For the best experience, launch it in a project directory instead."]})]})}function w_e({isFocused:e,isSelected:t,smallPointer:r,children:n}){let{styles:o}=Ai("Select");return(0,h.jsxs)(x,{...o.option({isFocused:e}),children:[e&&(0,h.jsx)(I,{...o.focusIndicator(),children:r?nr.triangleDownSmall:nr.pointer}),(0,h.jsx)(I,{...o.label({isFocused:e,isSelected:t}),children:n}),t&&(0,h.jsx)(I,{...o.selectedIndicator(),children:nr.tick})]})}var Xd=Ie(Ve(),1);import{isDeepStrictEqual as XYr}from"node:util";var bU=class extends Map{first;constructor(t){let r=[],n,o,i=0;for(let s of t){let a={...s,previous:o,next:void 0,index:i};o&&(o.next=a),n||=a;let l="value"in s?s.value:R_e(s);r.push([l,a]),i++,o=a}super(r),this.first=n}};var ezr=(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;for(;n&&!("value"in n);)n=n.next;if(!n)return e;if(!(n.index>=e.visibleToIndex))return{...e,focusedValue:n.value};let i=Math.min(e.optionMap.size,e.visibleToIndex+1),s=i-e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:s,visibleToIndex:i}}case"focus-previous-option":{if(!e.focusedValue)return e;let r=e.optionMap.get(e.focusedValue);if(!r)return e;let n=r.previous;for(;n&&!("value"in n);)n=n.previous;if(!n)return e;if(!(n.index<=e.visibleFromIndex))return{...e,focusedValue:n.value};let i=Math.max(0,e.visibleFromIndex-1),s=i+e.visibleOptionCount;return{...e,focusedValue:n.value,visibleFromIndex:i,visibleToIndex:s}}case"select-focused-option":return{...e,previousValue:e.value,value:e.focusedValue};case"reset":return t.state;case"set-focus":return{...e,focusedValue:t.value}}},N_e=e=>e.flatMap(t=>{if("options"in t){let r=N_e(t.options),n=r.flatMap(i=>"value"in i?i.value:[]);return[...t.header!==void 0?[{header:t.header,optionValues:n}]:[],...r]}return t}),pit=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=N_e(r),o=typeof e=="number"?Math.min(e,n.length):n.length,i=new bU(n),s=i.first,a=s&&"value"in s?s.value:void 0;return{optionMap:i,visibleOptionCount:o,focusedValue:a,visibleFromIndex:0,visibleToIndex:o,previousValue:t,value:t}},D_e=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n,onFocus:o,focusValue:i})=>{let s=N_e(t),[a,l]=(0,Xd.useReducer)(ezr,{visibleOptionCount:e,defaultValue:r,options:t},pit),[c,u]=(0,Xd.useState)(s);s!==c&&!XYr(s,c)&&(l({type:"reset",state:pit({visibleOptionCount:e,defaultValue:r,options:t})}),u(s));let d=(0,Xd.useCallback)(()=>{l({type:"focus-next-option"})},[]),f=(0,Xd.useCallback)(()=>{l({type:"focus-previous-option"})},[]),p=(0,Xd.useCallback)(()=>{l({type:"select-focused-option"})},[]),A=(0,Xd.useMemo)(()=>s.map((_,E)=>({..._,index:E})).slice(a.visibleFromIndex,a.visibleToIndex),[s,a.visibleFromIndex,a.visibleToIndex]);return(0,Xd.useEffect)(()=>{a.value&&a.previousValue!==a.value&&n?.(a.value)},[a.previousValue,a.value,t,n]),(0,Xd.useEffect)(()=>{a.focusedValue&&o?.(a.focusedValue)},[a.focusedValue,o]),(0,Xd.useEffect)(()=>{i&&l({type:"set-focus",value:i})},[i]),{focusedValue:a.focusedValue,visibleFromIndex:a.visibleFromIndex,visibleToIndex:a.visibleToIndex,value:a.value,visibleOptions:A,focusNextOption:d,focusPreviousOption:f,selectFocusedOption:p}};var O_e=({isDisabled:e=!1,state:t})=>{ft((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};var R_e=e=>`HEADER-${e.optionValues.join(",")}`;function Fb({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a}){let l=D_e({visibleOptionCount:t,options:n,defaultValue:o,onChange:i,onFocus:s,focusValue:a});O_e({isDisabled:e,state:l});let{styles:c}=Ai("Select");return(0,h.jsx)(x,{...c.container(),children:l.visibleOptions.map(u=>{let d="value"in u?u.value:R_e(u),f=!e&&l.focusedValue!==void 0&&("value"in u?l.focusedValue===u.value:u.optionValues.includes(l.focusedValue)),p=!!l.value&&("value"in u?l.value===u.value:u.optionValues.includes(l.value)),A="header"in u,_="label"in u?u.label:u.header,E=_;if(r&&_.includes(r)){let S=_.indexOf(r);E=(0,h.jsxs)(h.Fragment,{children:[_.slice(0,S),(0,h.jsx)(I,{...c.highlightedText(),children:r}),_.slice(S+r.length)]})}return(0,h.jsx)(w_e,{isFocused:f,isSelected:p,smallPointer:A,children:E},d)})})}function mit({onDone:e}){return ft((t,r)=>{(r.ctrl&&(t==="c"||t==="d")||r.escape)&&e()}),(0,h.jsxs)(x,{flexDirection:"column",borderStyle:"round",padding:1,borderColor:re().secondaryBorder,children:[(0,h.jsx)(x,{marginBottom:1,flexDirection:"column",children:(0,h.jsx)(I,{bold:!0,children:"You've spent $5 this session."})}),(0,h.jsx)(x,{children:(0,h.jsx)(Fb,{options:[{value:"ok",label:"Got it, thanks!"}],onChange:e})})]})}var Jt=Ie(Ve(),1);Pe();lr();r_();var nzr="2.7.18",n_={VERSION:nzr,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"};var k_e=46,hit=["(\u2740\u2579\u25E1\u2579)","(\u25D5\u072B\u25D5)","\u239D(\u25D5u\u25D5)\u23A0","\u10DA(\u25C9\u25DE\u0C6A\u25DF\u25C9 )\u10DA","(\xB4\u25C9\u203F\u25C9\uFF40)","\u0E01\u0E47\u0295\u2022\u0361\u1D25\u2022\u0294 \u0E01\u0E49","\uFF0F/( \u25D5\u203F\u203F\u25D5 )\uFF3C"];function Qj({isDefaultModel:e=!1}){let t=Math.max(k_e,Oe().length+12),r=re(),n=hit[Math.floor(Math.random()*hit.length)];return(0,h.jsx)(x,{flexDirection:"column",children:(0,h.jsxs)(x,{flexDirection:"column",gap:1,paddingLeft:1,width:"100%",children:[(0,h.jsxs)(I,{children:[(0,h.jsx)(I,{children:n})," Welcome to"," ",(0,h.jsx)(I,{bold:!0,children:it}),(0,h.jsxs)(I,{color:r.secondaryText,children:[" v",n_.VERSION]})]}),(0,h.jsx)(h.Fragment,{children:(0,h.jsxs)(x,{paddingLeft:2,flexDirection:"column",gap:1,children:[(0,h.jsx)(I,{color:r.secondaryText,italic:!0,children:"/help for help"}),(0,h.jsxs)(I,{color:r.secondaryText,children:["cwd: ",Oe()]}),(0,h.jsxs)(I,{color:r.secondaryText,children:["model: ",Jn.getConfig().routing.MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A"]}),(0,h.jsxs)(I,{color:r.secondaryText,children:["small fast model: ",Jn.getConfig().routing.SMALL_FAST_MODEL?.map(o=>`${o.source}__${o.model}`).join(", ")??"N/A"]})]})})]})})}we();import{randomUUID as $g}from"crypto";ji();we();er();lr();we();Pe();import{existsSync as Gb,readdirSync as Ojr,statSync as Bjr}from"fs";import{join as mC,relative as Mjr}from"path";import{homedir as clt}from"os";import{platform as kjr}from"process";import{readFile as fC}from"fs/promises";lr();um();Kt();import{join as czr,sep as uzr}from"path";function ld(){if(!Oc())return!1;try{let e=Je();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function ep(){return(czr(Oe(),".hcode","team-memory")+uzr).normalize("NFC")}function zf(e){let t=e.normalize("NFC"),r=ep();return t.startsWith(r)}um();var ult=Ie(RU(),1);po();var X_e=(e,t,r)=>{let n=e instanceof RegExp?Pat(e,r):e,o=t instanceof RegExp?Pat(t,r):t,i=n!==null&&o!=null&&y7r(n,o,r);return i&&{start:i[0],end:i[1],pre:r.slice(0,i[0]),body:r.slice(i[0]+n.length,i[1]),post:r.slice(i[1]+o.length)}},Pat=(e,t)=>{let r=t.match(e);return r?r[0]:null},y7r=(e,t,r)=>{let n,o,i,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=[],i=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 o=n.pop(),o!==void 0&&o<i&&(i=o,s=c),c=r.indexOf(t,u+1);u=l<c&&l>=0?l:c}n.length&&s!==void 0&&(a=[i,s])}return a};var Fat="\0SLASH"+Math.random()+"\0",Qat="\0OPEN"+Math.random()+"\0",rEe="\0CLOSE"+Math.random()+"\0",Uat="\0COMMA"+Math.random()+"\0",Gat="\0PERIOD"+Math.random()+"\0",C7r=new RegExp(Fat,"g"),T7r=new RegExp(Qat,"g"),I7r=new RegExp(rEe,"g"),v7r=new RegExp(Uat,"g"),x7r=new RegExp(Gat,"g"),w7r=/\\\\/g,R7r=/\\{/g,N7r=/\\}/g,D7r=/\\,/g,O7r=/\\\./g,B7r=1e5,M7r=4e6;function eEe(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function k7r(e){return e.replace(w7r,Fat).replace(R7r,Qat).replace(N7r,rEe).replace(D7r,Uat).replace(O7r,Gat)}function L7r(e){return e.replace(C7r,"\\").replace(T7r,"{").replace(I7r,"}").replace(v7r,",").replace(x7r,".")}function Hat(e){if(!e)return[""];let t=[],r=X_e("{","}",e);if(!r)return e.split(",");let{pre:n,body:o,post:i}=r,s=n.split(",");s[s.length-1]+="{"+o+"}";let a=Hat(i);return i.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function $at(e,t={}){if(!e)return[];let{max:r=B7r,maxLength:n=M7r}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),tEe(k7r(e),r,n,!0).map(L7r)}function P7r(e){return"{"+e+"}"}function F7r(e){return/^-?0\d/.test(e)}function Q7r(e,t){return e<=t}function U7r(e,t){return e>=t}function NU(e,t,r,n,o,i){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(!(i&&!u)){if(a+u.length>o)return s;s.push(u),a+=u.length}}return s}function G7r(e,t,r,n){let o=e.split(/\.\./),i=[];if(o[0]===void 0||o[1]===void 0)return i;let s=eEe(o[0]),a=eEe(o[1]),l=Math.max(o[0].length,o[1].length),c=o.length===3&&o[2]!==void 0?Math.max(Math.abs(eEe(o[2])),1):1,u=Q7r;a<s&&(c*=-1,u=U7r);let f=o.some(F7r),p=0;for(let A=s;u(A,a)&&i.length<r;A+=c){let _;if(t)_=String.fromCharCode(A),_==="\\"&&(_="");else if(_=String(A),f){let E=l-_.length;if(E>0){let S=new Array(E+1).join("0");A<0?_="-"+S+_.slice(1):_=S+_}}if(p+_.length>n)break;i.push(_),p+=_.length}return i}function tEe(e,t,r,n){let o=[""],i=!1,s=!0;for(;;){let a=X_e("{","}",e);if(!a)return NU(o,e,[""],t,r,i);let l=a.pre;if(/\$$/.test(l)){if(o=NU(o,l+"{"+a.body+"}",[""],t,r,i&&!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,f=a.body.indexOf(",")>=0;if(!d&&!f){if(a.post.match(/,(?!,).*\}/)){e=a.pre+"{"+a.body+rEe+a.post,n=!0;continue}return NU(o,l+"{"+a.body+"}"+a.post,[""],t,r,i)}s&&(i=n&&!d,s=!1);let p;if(d)p=G7r(a.body,u,t,r);else{let A=Hat(a.body);if(A.length===1&&A[0]!==void 0&&(A=tEe(A[0],t,r,!1).map(P7r),A.length===1)){if(o=NU(o,l+A[0],[""],t,r,i&&!a.post.length),!a.post.length)break;e=a.post;continue}let _=i&&!a.post.length&&!l;for(let S=0;_&&S<o.length;S++)o[S]&&(_=!1);p=[];let E=0;e:for(let S=0;S<A.length;S++){let C=tEe(A[S],t,r,!1);for(let v=0;v<C.length;v++){let R=C[v];if(!(_&&!R)){if(p.length>=t||E+R.length>r)break e;p.push(R),E+=R.length}}}}if(o=NU(o,l,p,t,r,i&&!a.post.length),!a.post.length)break;e=a.post}return o}var DU=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var H7r={"[: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]},OU=e=>e.replace(/[[\]\\-]/g,"\\$&"),$7r=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),qat=e=>e.join(""),Yat=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],o=[],i=r+1,s=!1,a=!1,l=!1,c=!1,u=r,d="";e:for(;i<e.length;){let _=e.charAt(i);if((_==="!"||_==="^")&&i===r+1){c=!0,i++;continue}if(_==="]"&&s&&!l){u=i+1;break}if(s=!0,_==="\\"&&!l){l=!0,i++;continue}if(_==="["&&!l){for(let[E,[S,C,v]]of Object.entries(H7r))if(e.startsWith(E,i)){if(d)return["$.",!1,e.length-r,!0];i+=E.length,v?o.push(S):n.push(S),a=a||C;continue e}}if(l=!1,d){_>d?n.push(OU(d)+"-"+OU(_)):_===d&&n.push(OU(_)),d="",i++;continue}if(e.startsWith("-]",i+1)){n.push(OU(_+"-")),i+=2;continue}if(e.startsWith("-",i+1)){d=_,i+=2;continue}n.push(OU(_)),i++}if(u<i)return["",!1,0,!1];if(!n.length&&!o.length)return["$.",!1,e.length-r,!0];if(o.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!c){let _=n[0].length===2?n[0].slice(-1):n[0];return[$7r(_),!1,u-r,!1]}let f="["+(c?"^":"")+qat(n)+"]",p="["+(c?"":"^")+qat(o)+"]";return[n.length&&o.length?"("+f+"|"+p+")":n.length?f:p,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 rp,q7r=new Set(["!","?","+","*","@"]),nEe=e=>q7r.has(e),zat=e=>nEe(e.type),Y7r=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),z7r=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),V7r=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),Vat=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),W7r="(?!(?:^|/)\\.\\.?(?:$|/))",Jj="(?!\\.)",j7r=new Set(["[","."]),K7r=new Set(["..","."]),J7r=new Set("().*{}+?[]^$\\!"),Z7r=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),oEe="[^/]",Wat=oEe+"*?",jat=oEe+"+?",X7r=0,H1=class{type;#e;#t;#n=!1;#r=[];#i;#o;#l;#s=!1;#a;#d;#m=!1;id=++X7r;get depth(){return(this.#i?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#e.id,parent:this.#i?.id,depth:this.depth,partsLength:this.#r.length,parts:this.#r}}constructor(t,r,n={}){this.type=t,t&&(this.#t=!0),this.#i=r,this.#e=this.#i?this.#i.#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.#o=this.#i?this.#i.#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("")}#p(){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.#i;for(;n;){for(let o=r.#o+1;!n.type&&o<n.#r.length;o++)for(let i of t.#r){if(typeof i=="string")throw new Error("string part in extglob AST??");i.copyIn(n.#r[o])}r=n,n=r.#i}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof rp&&r.#i===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.#i?.type==="!")&&t.push({}),t}isStart(){if(this.#e===this)return!0;if(!this.#i?.isStart())return!1;if(this.#o===0)return!0;let t=this.#i;for(let r=0;r<this.#o;r++){let n=t.#r[r];if(!(n instanceof rp&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let t=this.#i?this.#i.#r.length:0;return this.#o===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new rp(this.type,t);for(let n of this.#r)r.copyIn(n);return r}static#c(t,r,n,o,i){let s=o.maxExtglobRecursion??2,a=!1,l=!1,c=-1,u=!1;if(r.type===null){let _=n,E="";for(;_<t.length;){let S=t.charAt(_++);if(a||S==="\\"){a=!a,E+=S;continue}if(l){_===c+1?(S==="^"||S==="!")&&(u=!0):S==="]"&&!(_===c+2&&u)&&(l=!1),E+=S;continue}else if(S==="["){l=!0,c=_,u=!1,E+=S;continue}if(!o.noext&&nEe(S)&&t.charAt(_)==="("&&i<=s){r.push(E),E="";let v=new rp(S,r);_=rp.#c(t,v,_,o,i+1),r.push(v);continue}E+=S}return r.push(E),_}let d=n+1,f=new rp(null,r),p=[],A="";for(;d<t.length;){let _=t.charAt(d++);if(a||_==="\\"){a=!a,A+=_;continue}if(l){d===c+1?(_==="^"||_==="!")&&(u=!0):_==="]"&&!(d===c+2&&u)&&(l=!1),A+=_;continue}else if(_==="["){l=!0,c=d,u=!1,A+=_;continue}if(!o.noext&&nEe(_)&&t.charAt(d)==="("&&(i<=s||r&&r.#_(_))){let S=r&&r.#_(_)?0:1;f.push(A),A="";let C=new rp(_,f);f.push(C),d=rp.#c(t,C,d,o,i+S);continue}if(_==="|"){f.push(A),A="",p.push(f),f=new rp(null,r);continue}if(_===")")return A===""&&r.#r.length===0&&(r.#m=!0),f.push(A),A="",r.push(...p,f),d;A+=_}return r.type=null,r.#t=void 0,r.#r=[t.substring(n-1)],d}#g(t){return this.#A(t,z7r)}#A(t,r=Y7r){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.#_(n.type,r)}#_(t,r=V7r){return!!r.get(this.type)?.includes(t)}#h(t,r){let n=t.#r[0],o=new rp(null,n,this.options);o.#r.push(""),n.push(o),this.#v(t,r)}#v(t,r){let n=t.#r[0];this.#r.splice(r,1,...n.#r);for(let o of n.#r)typeof o=="object"&&(o.#i=this);this.#d=void 0}#b(t){return!!Vat.get(this.type)?.has(t)}#C(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.#b(r.type)}#T(t){let r=Vat.get(this.type),n=t.#r[0],o=r?.get(n.type);if(!o)return!1;this.#r=n.#r;for(let i of this.#r)typeof i=="object"&&(i.#i=this);this.type=o,this.#d=void 0,this.#m=!1}static fromGlob(t,r={}){let n=new rp(null,void 0,r);return rp.#c(t,n,0,r,0),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let t=this.toString(),[r,n,o,i]=this.toRegExpSource();if(!(o||this.#t||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(i?"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.#E(),this.#p()),!zat(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(p=>typeof p!="string"),c=this.#r.map(p=>{let[A,_,E,S]=typeof p=="string"?rp.#y(p,this.#t,l):p.toRegExpSource(t);return this.#t=this.#t||E,this.#n=this.#n||S,A}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&K7r.has(this.#r[0]))){let A=j7r,_=r&&A.has(c.charAt(0))||c.startsWith("\\.")&&A.has(c.charAt(2))||c.startsWith("\\.\\.")&&A.has(c.charAt(4)),E=!r&&!t&&A.has(c.charAt(0));u=_?W7r:E?Jj:""}let d="";return this.isEnd()&&this.#e.#s&&this.#i?.type==="!"&&(d="(?:$|\\/)"),[u+c+d,pC(c),this.#t=!!this.#t,this.#n]}let n=this.type==="*"||this.type==="+",o=this.type==="!"?"(?:(?!(?:":"(?:",i=this.#S(r);if(this.isStart()&&this.isEnd()&&!i&&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||!Jj?"":this.#S(!0);s===i&&(s=""),s&&(i=`(?:${i})(?:${s})*?`);let a="";if(this.type==="!"&&this.#m)a=(this.isStart()&&!r?Jj:"")+jat;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?Jj:"")+Wat+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=o+i+l}return[a,pC(i),this.#t=!!this.#t,this.#n]}#E(){if(zat(this)){let t=0,r=!1;do{r=!0;for(let n=0;n<this.#r.length;n++){let o=this.#r[n];typeof o=="object"&&(o.#E(),this.#A(o)?(r=!1,this.#v(o,n)):this.#g(o)?(r=!1,this.#h(o,n)):this.#C(o)&&(r=!1,this.#T(o)))}}while(!r&&++t<10)}else for(let t of this.#r)typeof t=="object"&&t.#E();this.#d=void 0}#S(t){return this.#r.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,o,i,s]=r.toRegExpSource(t);return this.#n=this.#n||s,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#y(t,r,n=!1){let o=!1,i="",s=!1,a=!1;for(let l=0;l<t.length;l++){let c=t.charAt(l);if(o){o=!1,i+=(J7r.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,i+=n&&/^[*]+$/.test(t)?jat:Wat,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?i+="\\\\":o=!0;continue}if(c==="["){let[u,d,f,p]=Yat(t,l);if(f){i+=u,s=s||d,l+=f-1,r=r||p;continue}}if(c==="?"){i+=oEe,r=!0;continue}i+=Z7r(c)}return[i,pC(t),!!r,s]}};rp=H1;var iEe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var Bc=(e,t,r={})=>(DU(t),!r.nocomment&&t.charAt(0)==="#"?!1:new vB(t,r).match(e)),ejr=/^\*+([^+@!?*[(]*)$/,tjr=e=>t=>!t.startsWith(".")&&t.endsWith(e),rjr=e=>t=>t.endsWith(e),njr=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),ojr=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),ijr=/^\*+\.\*+$/,sjr=e=>!e.startsWith(".")&&e.includes("."),ajr=e=>e!=="."&&e!==".."&&e.includes("."),ljr=/^\.\*+$/,cjr=e=>e!=="."&&e!==".."&&e.startsWith("."),ujr=/^\*+$/,djr=e=>e.length!==0&&!e.startsWith("."),pjr=e=>e.length!==0&&e!=="."&&e!=="..",mjr=/^\?+([^+@!?*[(]*)?$/,fjr=([e,t=""])=>{let r=Zat([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},gjr=([e,t=""])=>{let r=Xat([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},hjr=([e,t=""])=>{let r=Xat([e]);return t?n=>r(n)&&n.endsWith(t):r},Ajr=([e,t=""])=>{let r=Zat([e]);return t?n=>r(n)&&n.endsWith(t):r},Zat=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},Xat=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},elt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Kat={win32:{sep:"\\"},posix:{sep:"/"}},_jr=elt==="win32"?Kat.win32.sep:Kat.posix.sep;Bc.sep=_jr;var wu=Symbol("globstar **");Bc.GLOBSTAR=wu;var Ejr="[^/]",bjr=Ejr+"*?",Sjr="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",yjr="(?:(?!(?:\\/|^)\\.).)*?",Cjr=(e,t={})=>r=>Bc(r,e,t);Bc.filter=Cjr;var Vf=(e,t={})=>Object.assign({},e,t),Tjr=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return Bc;let t=Bc;return Object.assign((n,o,i={})=>t(n,o,Vf(e,i)),{Minimatch:class extends t.Minimatch{constructor(o,i={}){super(o,Vf(e,i))}static defaults(o){return t.defaults(Vf(e,o)).Minimatch}},AST:class extends t.AST{constructor(o,i,s={}){super(o,i,Vf(e,s))}static fromGlob(o,i={}){return t.AST.fromGlob(o,Vf(e,i))}},unescape:(n,o={})=>t.unescape(n,Vf(e,o)),escape:(n,o={})=>t.escape(n,Vf(e,o)),filter:(n,o={})=>t.filter(n,Vf(e,o)),defaults:n=>t.defaults(Vf(e,n)),makeRe:(n,o={})=>t.makeRe(n,Vf(e,o)),braceExpand:(n,o={})=>t.braceExpand(n,Vf(e,o)),match:(n,o,i={})=>t.match(n,o,Vf(e,i)),sep:t.sep,GLOBSTAR:wu})};Bc.defaults=Tjr;var tlt=(e,t={})=>(DU(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:$at(e,{max:t.braceExpandMax}));Bc.braceExpand=tlt;var Ijr=(e,t={})=>new vB(e,t).makeRe();Bc.makeRe=Ijr;var vjr=(e,t,r={})=>{let n=new vB(t,r);return e=e.filter(o=>n.match(o)),n.options.nonull&&!e.length&&e.push(t),e};Bc.match=vjr;var Jat=/[?*]|[+@!]\(.*?\)|\[|\]/,xjr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),vB=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){DU(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||elt,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=(...i)=>console.error(...i)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(i=>this.slashSplit(i));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let o=this.globParts.map((i,s,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=i[0]===""&&i[1]===""&&(i[2]==="?"||!Jat.test(i[2]))&&!Jat.test(i[3]),c=/^[a-z]:/i.test(i[0]);if(l)return[...i.slice(0,4),...i.slice(4).map(u=>this.parse(u))];if(c)return[i[0],...i.slice(1).map(u=>this.parse(u))]}return i.map(l=>this.parse(l))});if(this.debug(this.pattern,o),this.set=o.filter(i=>i.indexOf(!1)===-1),this.isWindows)for(let i=0;i<this.set.length;i++){let s=this.set[i];s[0]===""&&s[1]===""&&this.globParts[i][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 o=0;o<n.length;o++)n[o]==="**"&&(n[o]="*");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 o=n;for(;r[o+1]==="**";)o++;o!==n&&r.splice(n,o-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,o)=>{let i=n[n.length-1];return o==="**"&&i==="**"?n:o===".."&&i&&i!==".."&&i!=="."&&i!=="**"?(n.pop(),n):(n.push(o),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 o=1;o<t.length-1;o++){let i=t[o];o===1&&i===""&&t[0]===""||(i==="."||i==="")&&(r=!0,t.splice(o,1),o--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let o=t[n-1];o&&o!=="."&&o!==".."&&o!=="**"&&!(this.isWindows&&/^[a-z]:$/i.test(o))&&(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 o=-1;for(;(o=n.indexOf("**",o+1))!==-1;){let s=o;for(;n[s+1]==="**";)s++;s>o&&n.splice(o+1,s-o);let a=n[o+1],l=n[o+2],c=n[o+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")continue;r=!0,n.splice(o,1);let u=n.slice(0);u[o]="**",t.push(u),o--}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 i=0;for(;(i=n.indexOf("..",i+1))!==-1;){let s=n[i-1];if(s&&s!=="."&&s!==".."&&s!=="**"){r=!0;let l=i===1&&n[i+1]==="**"?["."]:[];n.splice(i-1,2,...l),n.length===0&&n.push(""),i-=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 o=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(o){t[r]=[],t[n]=o;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let o=0,i=0,s=[],a="";for(;o<t.length&&i<r.length;)if(t[o]===r[i])s.push(a==="b"?r[i]:t[o]),o++,i++;else if(n&&t[o]==="**"&&r[i]===t[o+1])s.push(t[o]),o++;else if(n&&r[i]==="**"&&t[o]===r[i+1])s.push(r[i]),i++;else if(t[o]==="*"&&r[i]&&(this.options.dot||!r[i].startsWith("."))&&r[i]!=="**"){if(a==="b")return!1;a="a",s.push(t[o]),o++,i++}else if(r[i]==="*"&&t[o]&&(this.options.dot||!t[o].startsWith("."))&&t[o]!=="**"){if(a==="a")return!1;a="b",s.push(r[i]),o++,i++}else return!1;return t.length===r.length&&s}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let o=0;o<t.length&&t.charAt(o)==="!";o++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let o=0,i=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,f=u?3:c?0:void 0;if(typeof d=="number"&&typeof f=="number"){let[p,A]=[t[d],r[f]];p.toLowerCase()===A.toLowerCase()&&(r[f]=p,i=f,o=d)}}let{optimizationLevel:s=1}=this.options;return s>=2&&(t=this.levelTwoFileOptimize(t)),r.includes(wu)?this.#e(t,r,n,o,i):this.#n(t,r,n,o,i)}#e(t,r,n,o,i){let s=r.indexOf(wu,i),a=r.lastIndexOf(wu),[l,c,u]=n?[r.slice(i,s),r.slice(s+1),[]]:[r.slice(i,s),r.slice(s+1,a),r.slice(a+1)];if(l.length){let C=t.slice(o,o+l.length);if(!this.#n(C,l,n,0,0))return!1;o+=l.length,i+=l.length}let d=0;if(u.length){if(u.length+o>t.length)return!1;let C=t.length-u.length;if(this.#n(t,u,n,C,0))d=u.length;else{if(t[t.length-1]!==""||o+u.length===t.length||(C--,!this.#n(t,u,n,C,0)))return!1;d=u.length+1}}if(!c.length){let C=!!d;for(let v=o;v<t.length-d;v++){let R=String(t[v]);if(C=!0,R==="."||R===".."||!this.options.dot&&R.startsWith("."))return!1}return n||C}let f=[[[],0]],p=f[0],A=0,_=[0];for(let C of c)C===wu?(_.push(A),p=[[],0],f.push(p)):(p[0].push(C),A++);let E=f.length-1,S=t.length-d;for(let C of f)C[1]=S-(_[E--]+C[0].length);return!!this.#t(t,f,o,0,n,0,!!d)}#t(t,r,n,o,i,s,a){let l=r[o];if(!l){for(let d=n;d<t.length;d++){a=!0;let f=t[d];if(f==="."||f===".."||!this.options.dot&&f.startsWith("."))return!1}return a}let[c,u]=l;for(;n<=u;){if(this.#n(t.slice(0,n+c.length),c,i,n,0)&&s<this.maxGlobstarRecursion){let p=this.#t(t,r,n+c.length,o+1,i,s+1,a);if(p!==!1)return p}let f=t[n];if(f==="."||f===".."||!this.options.dot&&f.startsWith("."))return!1;n++}return i||null}#n(t,r,n,o,i){let s,a,l,c;for(s=o,a=i,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===wu)return!1;let f;if(typeof u=="string"?(f=d===u,this.debug("string match",u,d,f)):(f=u.test(d),this.debug("pattern match",u,d,f)),!f)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 tlt(this.pattern,this.options)}parse(t){DU(t);let r=this.options;if(t==="**")return wu;if(t==="")return"";let n,o=null;(n=t.match(ujr))?o=r.dot?pjr:djr:(n=t.match(ejr))?o=(r.nocase?r.dot?ojr:njr:r.dot?rjr:tjr)(n[1]):(n=t.match(mjr))?o=(r.nocase?r.dot?gjr:fjr:r.dot?hjr:Ajr)(n):(n=t.match(ijr))?o=r.dot?ajr:sjr:(n=t.match(ljr))&&(o=cjr);let i=H1.fromGlob(t,this.options).toMMPattern();return o&&typeof i=="object"&&Reflect.defineProperty(i,"test",{value:o}),i}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?bjr:r.dot?Sjr:yjr,o=new Set(r.nocase?["i"]:[]),i=t.map(l=>{let c=l.map(d=>{if(d instanceof RegExp)for(let f of d.flags.split(""))o.add(f);return typeof d=="string"?xjr(d):d===wu?wu:d._src});c.forEach((d,f)=>{let p=c[f+1],A=c[f-1];d!==wu||A===wu||(A===void 0?p!==void 0&&p!==wu?c[f+1]="(?:\\/|"+n+"\\/)?"+p:c[f]=n:p===void 0?c[f-1]=A+"(?:\\/|\\/"+n+")?":p!==wu&&(c[f-1]=A+"(?:\\/|\\/"+n+"\\/)"+p,c[f+1]=wu))});let u=c.filter(d=>d!==wu);if(this.partial&&u.length>=1){let d=[];for(let f=1;f<=u.length;f++)d.push(u.slice(0,f).join("/"));return"(?:"+d.join("|")+")"}return u.join("/")}).join("|"),[s,a]=t.length>1?["(?:",")"]:["",""];i="^"+s+i+a+"$",this.partial&&(i="^(?:\\/|"+s+i.slice(1,-1)+a+")$"),this.negate&&(i="^(?!"+i+").+$");try{this.regexp=new RegExp(i,[...o].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 o=this.slashSplit(t);this.debug(this.pattern,"split",o);let i=this.set;this.debug(this.pattern,"set",i);let s=o[o.length-1];if(!s)for(let a=o.length-2;!s&&a>=0;a--)s=o[a];for(let a of i){let l=o;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 Bc.defaults(t).Minimatch}};Bc.AST=H1;Bc.Minimatch=vB;Bc.escape=iEe;Bc.unescape=pC;var olt=Ie(RU(),1);lr();Pe();we();nd();import{readFile as rlt}from"fs/promises";import{existsSync as sEe,readdirSync as wjr,statSync as Rjr}from"fs";import{join as aEe,relative as ilt}from"path";import{homedir as Njr}from"os";function nlt(e){try{let t=(0,olt.default)(e),r=t.data.paths,n=[];return typeof r=="string"?n=r.split(",").map(o=>o.trim()).filter(Boolean):Array.isArray(r)&&(n=r.filter(o=>typeof o=="string")),{paths:n,content:t.content.trim()}}catch(t){return be(t),{paths:[],content:e.trim()}}}function Djr(e,t){return t.length===0?!0:t.some(r=>{try{return Bc(e,r,{matchBase:!0,dot:!0})}catch(n){return be(n),!1}})}function lEe(e){let t=[];try{if(!sEe(e))return t;let r=wjr(e);for(let n of r){let o=aEe(e,n),i=Rjr(o);i.isDirectory()?t.push(...lEe(o)):i.isFile()&&n.endsWith(".md")&&t.push(o)}}catch(r){be(r)}return t}async function Zj(){let e=[];try{let t=aEe(Njr(),Tn,"rules");if(sEe(t)){let r=lEe(t);for(let n of r)try{let o=await rlt(n,"utf-8"),{paths:i,content:s}=nlt(o);i.length>0&&e.push({filePath:n,content:s,paths:i,isProjectRule:!1})}catch(o){be(o)}}}catch(t){be(t)}try{let t=aEe(Oe(),Tn,"rules");if(sEe(t)){let r=lEe(t);for(let n of r)try{let o=await rlt(n,"utf-8"),{paths:i,content:s}=nlt(o);i.length>0&&e.push({filePath:ilt(Oe(),n),content:s,paths:i,isProjectRule:!0})}catch(o){be(o)}}}catch(t){be(t)}return e}function slt(e,t){e=B7(e);let r=B7(Oe()),n=e.startsWith(r)?ilt(r,e):e;return t.filter(o=>Djr(n,o.paths))}function alt(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}):
657
657
 
658
658
  ${r.content}`}).join(`
659
659
 
@@ -754,7 +754,7 @@ data: ${JSON.stringify(F)}
754
754
  `);a=O.pop()||"";for(let F of O){let G=F.trim();if(!(!G||G==="data: [DONE]"))if(G.startsWith("data: ")){let P=G.slice(6);try{let $=JSON.parse(P);R($)}catch($){this.logger&&this.logger.error({err:$,line:G},"Failed to parse Gemini SSE chunk")}}else try{let P=JSON.parse(G);R(P)}catch{}}};(async()=>{try{for(;;){let{value:O,done:F}=await s.read();if(F)break;a+=n.decode(O,{stream:!0}),D()}v()}catch(O){i.error(O)}})()}})}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(i=>{if(i.text&&n.push({type:"text",text:i.text}),i.functionCall){let s=`toolu_${jB()}`,a=i.functionCall.thoughtSignature||i.functionCall.thought_signature||null;n.push({type:"tool_use",id:s,name:i.functionCall.name,input:i.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:`
755
755
 
756
756
  [Search queries used: ${r.groundingMetadata.webSearchQueries.join(", ")}]`}));let o={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(i=>i.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:o},"Conversion complete, final Anthropic response"),o}catch{throw Xen(`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"}}},ESe=new _Se;var TEt=Ie(SEt(),1);Kt();ji();function Oh(e){return e?typeof e.entries=="function"?Object.fromEntries(e.entries()):{...e}:{}}function yEt(e){let t=String(e?.["x-thinking-level"]??"medium").toLowerCase();return["off","low","medium","high"].includes(t)?t:"medium"}function mAn(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t}}function fAn(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t,summary:"auto"}}function gAn(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 w5(e,t,r){RY(t,e),NY(t,gAn(e,r),r)}function PM(e){let t=[],r=e.getReader(),n,o=new Promise(l=>n=l),i=!1,s=()=>{i||(i=!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:o}}function R5(e){let t=new Headers(e);return t.delete("content-encoding"),t.delete("content-length"),t.delete("transfer-encoding"),t}function VTe(e,t,r,n,o){let i;try{i={type:"error",error:{type:"api_error",message:JSON.parse(o).error?.message??`${e}: ${n}`,code:`${t}_${r}_ERROR`}}}catch{i={type:"error",error:{type:"api_error",message:`${e}: ${n}`,code:`${t}_${r}_ERROR`}}}return new Response(JSON.stringify(i),{status:r,statusText:n,headers:{"Content-Type":"application/json"}})}var CEt=["/v1/messages"];function WTe(e){let t;try{typeof e=="string"?t=new Dx(e):e instanceof Dx?t=e:t=new Dx(e.url)}catch{return""}let r=t.pathname;for(let n of CEt){let o=r.indexOf(n);if(o!==-1)return t.origin+r.slice(0,o)}return t.origin}function BX(e,t){let r=typeof e=="string"?e:e instanceof Dx?e.toString():e.url,n;try{n=new Dx(r).pathname}catch{return!1}return CEt.some(o=>n.includes(o))&&(t.method==="POST"||t.method==="post")}function hAn(e){return async(t,r)=>{if(!BX(t,r))return e(t,r);let n=JSON.parse(r.body),o=await MJ.transformRequestOut(n),i=WTe(t)+"/chat/completions",s=Oh(r.headers),a=s.authorization??s.Authorization??"";mAn(o,yEt(s));let l=await e(i,{method:"POST",headers:{"Content-Type":"application/json",Authorization:a},body:JSON.stringify(o),signal:r.signal});if(!l.ok){let E=await l.text();return te(`OpenAI Chat Completions API error: ${l.status}`,{url:i,errorResponse:E}),VTe("OpenAI Chat Completions API error","OPENROUTER",l.status,l.statusText,E)}let c=n.stream===!0,u=s["x-agent-id"],d={request:{url:i,method:r.method,headers:s,body:n},response:{status:l.status,statusText:l.statusText,headers:Oh(l.headers)},openai:{request:{body:o},response:{}}};if(!c){let E=await l.text(),S=new Response(E,{status:l.status,statusText:l.statusText,headers:R5(l.headers)}),C=await MJ.transformResponseIn(S,n),v=await C.text();try{w5({...d,openai:{...d.openai,response:{body:JSON.parse(E)}},response:{...d.response,body:JSON.parse(v)}},u)}catch(R){te("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u975E\u6D41\u5F0F):",R)}return new Response(v,{status:C.status,statusText:C.statusText,headers:C.headers})}let f=PM(l.body),p=new Response(f.stream,{status:l.status,statusText:l.statusText,headers:R5(l.headers)}),A=await MJ.transformResponseIn(p,n),_=PM(A.body);return Promise.all([f.done,_.done]).then(async([E,S])=>{try{w5({...d,openai:{...d.openai,response:{body:await Jct(E)}},response:{...d.response,body:await b9(S)}},u)}catch(C){te("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u6D41\u5F0F):"+C?.stack)}}).catch(E=>te("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Chat):"+E)),new Response(_.stream,{status:A.status,statusText:A.statusText,headers:A.headers})}}function AAn(e){return async(t,r)=>{if(!BX(t,r))return e(t,r);let n=JSON.parse(r.body),o=await kJ.transformRequestOut(n),i=Oh(r.headers);fAn(o,yEt(i));let s=JSON.stringify(o),l=WTe(t)+"/responses",c=i.authorization??i.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 C=await u.text();return te(`OpenAI Responses API error: ${u.status} ${u.statusText}`,{url:l,status:u.status,errorResponse:C}),VTe("OpenAI Responses API error","RESPONSES",u.status,u.statusText,C)}let d=n.stream===!0,f=i["x-agent-id"],p={request:{url:l,method:r.method,headers:i,body:n},response:{status:u.status,statusText:u.statusText,headers:Oh(u.headers)},openai:{request:{body:o},response:{}}};if(!d){let C=await u.text(),v=new Response(C,{status:u.status,statusText:u.statusText,headers:R5(u.headers)}),R=await kJ.transformResponseIn(v,n),D=await R.text();try{w5({...p,openai:{...p.openai,response:{body:JSON.parse(C)}},response:{...p.response,body:JSON.parse(D)}},f,"responses")}catch(O){te("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u975E\u6D41\u5F0F):",O)}return new Response(D,{status:R.status,statusText:R.statusText,headers:R.headers})}let A=PM(u.body),_=new Response(A.stream,{status:u.status,statusText:u.statusText,headers:R5(u.headers)}),E=await kJ.transformResponseIn(_,n),S=PM(E.body);return Promise.all([A.done,S.done]).then(async([C,v])=>{try{w5({...p,openai:{...p.openai,response:{body:await Kct(C)}},response:{...p.response,body:await b9(v)}},f,"responses")}catch(R){te("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u6D41\u5F0F):"+R?.stack)}}).catch(C=>te("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Responses):"+C)),new Response(S.stream,{status:E.status,statusText:E.statusText,headers:E.headers})}}function _An(e){return async(t,r)=>{if(!BX(t,r))return e(t,r);let n=JSON.parse(r.body),o=Oh(r.headers),i=await ESe.transformRequestOut(n),s=JSON.stringify(i),a=WTe(t)+`/models/${n.model}:streamGenerateContent?alt=sse`,l=o.authorization??o.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(S){throw te("gemini request error:",S),S}if(!c.ok){let S=await c.text();return te(`Gemini API error response: ${c.status} ${c.statusText}`,{url:a,status:c.status,errorResponse:S}),VTe("Gemini API error","Gemini",c.status,c.statusText,S)}let u=n.stream===!0,d=o["x-agent-id"],f={request:{url:a,method:r.method,headers:Oh(r.headers),body:n},response:{status:c.status,statusText:c.statusText,headers:Oh(c.headers)},openai:{request:{body:i},response:{}}},p=PM(c.body),A=new Response(p.stream,{status:c.status,statusText:c.statusText,headers:R5(c.headers)}),_=await ESe.transformResponseIn(A),E=PM(_.body);return Promise.all([p.done,E.done]).then(async([S,C])=>{try{let v=u?Zct(S):JSON.parse(S),R=u?await b9(C):JSON.parse(C);w5({...f,openai:{...f.openai,response:{body:v}},response:{...f.response,body:R}},d)}catch(v){te("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Gemini):"+v?.stack)}}).catch(S=>te("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Gemini):"+S)),new Response(E.stream,{status:_.status,statusText:_.statusText,headers:_.headers})}}function EAn(e){return async(t,r)=>{if(!BX(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 o=Oh(r.headers);["1","true"].includes(String(process.env.HAWA_CODE_X_API_KEY_DISABLED??"").toLowerCase())&&(delete o["x-api-key"],delete o["X-API-Key"]),["1","true"].includes(String(process.env.HAWA_CODE_AUTH_DISABLED??"").toLowerCase())&&(delete o.authorization,delete o.Authorization),delete o["content-length"];let a=await e(t,{method:r.method,headers:o,body:n,signal:r.signal});if(!a.ok){let d=await a.text();te(`API error response: ${a.status} ${a.statusText}`,{url:typeof t=="string"?t:t instanceof Dx?t.toString():t.url,status:a.status,errorResponse:d});let f;try{let p=JSON.parse(d);f={type:"error",error:{type:"api_error",message:p.error?.message||p.message||`API error: ${a.statusText}`,code:p.error?.code||p.code||`API_${a.status}_ERROR`}},p.error?.details&&(f.error.details=p.error.details)}catch{f={type:"error",error:{type:"api_error",message:`API error: ${a.statusText}`,code:`API_${a.status}_ERROR`}}}return new Response(JSON.stringify(f),{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 Dx?t.toString():t.url,method:r.method,headers:Oh(r.headers),body:JSON.parse(n)},response:{status:a.status,statusText:a.statusText,headers:Oh(a.headers)}};return(async()=>{if(c){let p=await a.text();u.response.body=await b9(p)}else u.response.body=await a.json();let f=Oh(r.headers)["x-agent-id"];RY(f,u),NY(f,{request:u.request.body.messages,response:u.response.body.content,usage:u.response.body?.usage})})().catch(d=>te(`\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF:
757
- Stack trace: `+d.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var OX=null,zTe=!1;function bAn(){OX=null,zTe=!1}Qt.on("proxy:changed",bAn);function SAn(){if(zTe)return OX;if(zTe=!0,Je().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(OX=new TEt.ProxyAgent({uri:e}),Dt(`[proxy] using proxy: ${e}`)),OX}function yAn(){let e=SAn();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function MX(e){let t=e||process.env.API_TYPE,r=yAn();switch(t){case"openai":return hAn(r);case"openai-responses":return AAn(r);case"gemini":return _An(r);default:return EAn(r)}}r_();we();Pe();Pe();var jTe="2.7.17";globalThis.MACRO={VERSION:jTe,PACKAGE_URL:`@dahawa/${Uo}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var kX=process.env.HAWA_CODE_USER_AGENT||`${Uo}/${jTe} (${process.env.USER_TYPE})`;we();we();er();function Du(e,t){let r=[],n=new Set;return e.filter(o=>o.type!=="progress"&&o.type!=="reminder").forEach(o=>{switch(o.type){case"user":{let i=yc(r);if(i?.type==="user"){r[r.length-1]=IEt(i,o);return}r.push(o);return}case"assistant":r.push(o);return;case"insert":{let i=yc(r);i?.type==="user"&&(r[r.length-1]=CAn(i,o));return}case"path_rules":{let i=t?.pathRules;if(!i)return;let s=o.content.paths.filter(u=>!n.has(u));if(s.length===0)return;let a=s.map(u=>i.get(u)).filter(u=>u!==void 0);if(s.forEach(u=>n.add(u)),a.length===0)return;let l=At([{type:"text",text:`<system-rules>
757
+ Stack trace: `+d.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var OX=null,zTe=!1;function bAn(){OX=null,zTe=!1}Qt.on("proxy:changed",bAn);function SAn(){if(zTe)return OX;if(zTe=!0,Je().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(OX=new TEt.ProxyAgent({uri:e}),Dt(`[proxy] using proxy: ${e}`)),OX}function yAn(){let e=SAn();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function MX(e){let t=e||process.env.API_TYPE,r=yAn();switch(t){case"openai":return hAn(r);case"openai-responses":return AAn(r);case"gemini":return _An(r);default:return EAn(r)}}r_();we();Pe();Pe();var jTe="2.7.18";globalThis.MACRO={VERSION:jTe,PACKAGE_URL:`@dahawa/${Uo}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var kX=process.env.HAWA_CODE_USER_AGENT||`${Uo}/${jTe} (${process.env.USER_TYPE})`;we();we();er();function Du(e,t){let r=[],n=new Set;return e.filter(o=>o.type!=="progress"&&o.type!=="reminder").forEach(o=>{switch(o.type){case"user":{let i=yc(r);if(i?.type==="user"){r[r.length-1]=IEt(i,o);return}r.push(o);return}case"assistant":r.push(o);return;case"insert":{let i=yc(r);i?.type==="user"&&(r[r.length-1]=CAn(i,o));return}case"path_rules":{let i=t?.pathRules;if(!i)return;let s=o.content.paths.filter(u=>!n.has(u));if(s.length===0)return;let a=s.map(u=>i.get(u)).filter(u=>u!==void 0);if(s.forEach(u=>n.add(u)),a.length===0)return;let l=At([{type:"text",text:`<system-rules>
758
758
  ${alt(a)}
759
759
  </system-rules>`}]),c=yc(r);c?.type==="user"?r[r.length-1]=IEt(c,l,{skipTrailingSystemReminders:!0}):r.push(l);return}}}),r}function CAn(e,t){return{...e,message:{...e.message,content:IAn(e.message.content,TAn(t.content.content))}}}function TAn(e){return`
760
760
  <system-reminder>
@@ -1044,7 +1044,7 @@ ${Ge.isMessageArchivingEnable()?`
1044
1044
 
1045
1045
  ${await GIt()||""}`,`
1046
1046
  ${await nw()}
1047
- `,...Ge.isTasksEnable()?[]:["IMPORTANT: Always use the TodoWrite tool to plan and track tasks throughout the conversation."],"# Code References\n\nWhen referencing specific functions or pieces of code include the pattern `file_path:line_number` to allow the user to easily navigate to the source code location.",...Ge.isMemoEnable()?["\n\n# Memo Tool Content Placeholder\n\nWhen the Memo tool is enabled, older Memo write contents are truncated in the context window. If you see a past Memo write where the content appears as `...<first 20 characters>...(argument truncated)`, the real content is stored on disk. Use the Memo tool's `read` operation with the corresponding `key` when you need the full content again. The most recent 5 messages keep their full content unchanged."]:[],...Je().language&&Je().language!=="auto"?[`
1047
+ `,"# Code References\n\nWhen referencing specific functions or pieces of code include the pattern `file_path:line_number` to allow the user to easily navigate to the source code location.",...Ge.isMemoEnable()?["\n\n# Memo Tool Content Placeholder\n\nWhen the Memo tool is enabled, older Memo write contents are truncated in the context window. If you see a past Memo write where the content appears as `...<first 20 characters>...(argument truncated)`, the real content is stored on disk. Use the Memo tool's `read` operation with the corresponding `key` when you need the full content again. The most recent 5 messages keep their full content unchanged."]:[],...Je().language&&Je().language!=="auto"?[`
1048
1048
 
1049
1049
  # Language
1050
1050
  Always respond in ${Je().language}. Use ${Je().language} for all explanations, comments, and communications with the user. Technical terms and code identifiers should remain in their original form.
package/hands.js CHANGED
@@ -623,7 +623,7 @@ data: ${JSON.stringify(z)}
623
623
  `);a=M.pop()||"";for(let z of M){let j=z.trim();if(!(!j||j==="data: [DONE]"))if(j.startsWith("data: ")){let L=j.slice(6);try{let V=JSON.parse(L);D(V)}catch(V){this.logger&&this.logger.error({err:V,line:j},"Failed to parse Gemini SSE chunk")}}else try{let L=JSON.parse(j);D(L)}catch{}}};(async()=>{try{for(;;){let{value:M,done:z}=await s.read();if(z)break;a+=n.decode(M,{stream:!0}),N()}T()}catch(M){o.error(M)}})()}})}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_${YN()}`,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:`
624
624
 
625
625
  [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 H3r(`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"}}},z_e=new G_e;var Rpt=Re(xpt(),1);Wt();ps();function cg(e){return e?typeof e.entries=="function"?Object.fromEntries(e.entries()):{...e}:{}}function wpt(e){let t=String(e?.["x-thinking-level"]??"medium").toLowerCase();return["off","low","medium","high"].includes(t)?t:"medium"}function ren(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t}}function nen(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t,summary:"auto"}}function ien(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 NU(e,t,r){TG(t,e),vG(t,ien(e,r),r)}function MB(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 BU(e){let t=new Headers(e);return t.delete("content-encoding"),t.delete("content-length"),t.delete("transfer-encoding"),t}function _1e(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 Dpt=["/v1/messages"];function y1e(e){let t;try{typeof e=="string"?t=new QT(e):e instanceof QT?t=e:t=new QT(e.url)}catch{return""}let r=t.pathname;for(let n of Dpt){let i=r.indexOf(n);if(i!==-1)return t.origin+r.slice(0,i)}return t.origin}function MJ(e,t){let r=typeof e=="string"?e:e instanceof QT?e.toString():e.url,n;try{n=new QT(r).pathname}catch{return!1}return Dpt.some(i=>n.includes(i))&&(t.method==="POST"||t.method==="post")}function oen(e){return async(t,r)=>{if(!MJ(t,r))return e(t,r);let n=JSON.parse(r.body),i=await QW.transformRequestOut(n),o=y1e(t)+"/chat/completions",s=cg(r.headers),a=s.authorization??s.Authorization??"";ren(i,wpt(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 K(`OpenAI Chat Completions API error: ${l.status}`,{url:o,errorResponse:y}),_1e("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:cg(l.headers)},openai:{request:{body:i},response:{}}};if(!c){let y=await l.text(),C=new Response(y,{status:l.status,statusText:l.statusText,headers:BU(l.headers)}),I=await QW.transformResponseIn(C,n),T=await I.text();try{NU({...d,openai:{...d.openai,response:{body:JSON.parse(y)}},response:{...d.response,body:JSON.parse(T)}},u)}catch(D){K("\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=MB(l.body),m=new Response(g.stream,{status:l.status,statusText:l.statusText,headers:BU(l.headers)}),A=await QW.transformResponseIn(m,n),h=MB(A.body);return Promise.all([g.done,h.done]).then(async([y,C])=>{try{NU({...d,openai:{...d.openai,response:{body:await nit(y)}},response:{...d.response,body:await SF(C)}},u)}catch(I){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u6D41\u5F0F):"+I?.stack)}}).catch(y=>K("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Chat):"+y)),new Response(h.stream,{status:A.status,statusText:A.statusText,headers:A.headers})}}function sen(e){return async(t,r)=>{if(!MJ(t,r))return e(t,r);let n=JSON.parse(r.body),i=await PW.transformRequestOut(n),o=cg(r.headers);nen(i,wpt(o));let s=JSON.stringify(i),l=y1e(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 K(`OpenAI Responses API error: ${u.status} ${u.statusText}`,{url:l,status:u.status,errorResponse:I}),_1e("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:cg(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:BU(u.headers)}),D=await PW.transformResponseIn(T,n),N=await D.text();try{NU({...m,openai:{...m.openai,response:{body:JSON.parse(I)}},response:{...m.response,body:JSON.parse(N)}},g,"responses")}catch(M){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u975E\u6D41\u5F0F):",M)}return new Response(N,{status:D.status,statusText:D.statusText,headers:D.headers})}let A=MB(u.body),h=new Response(A.stream,{status:u.status,statusText:u.statusText,headers:BU(u.headers)}),y=await PW.transformResponseIn(h,n),C=MB(y.body);return Promise.all([A.done,C.done]).then(async([I,T])=>{try{NU({...m,openai:{...m.openai,response:{body:await rit(I)}},response:{...m.response,body:await SF(T)}},g,"responses")}catch(D){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u6D41\u5F0F):"+D?.stack)}}).catch(I=>K("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Responses):"+I)),new Response(C.stream,{status:y.status,statusText:y.statusText,headers:y.headers})}}function aen(e){return async(t,r)=>{if(!MJ(t,r))return e(t,r);let n=JSON.parse(r.body),i=cg(r.headers),o=await z_e.transformRequestOut(n),s=JSON.stringify(o),a=y1e(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(C){throw K("gemini request error:",C),C}if(!c.ok){let C=await c.text();return K(`Gemini API error response: ${c.status} ${c.statusText}`,{url:a,status:c.status,errorResponse:C}),_1e("Gemini API error","Gemini",c.status,c.statusText,C)}let u=n.stream===!0,d=i["x-agent-id"],g={request:{url:a,method:r.method,headers:cg(r.headers),body:n},response:{status:c.status,statusText:c.statusText,headers:cg(c.headers)},openai:{request:{body:o},response:{}}},m=MB(c.body),A=new Response(m.stream,{status:c.status,statusText:c.statusText,headers:BU(c.headers)}),h=await z_e.transformResponseIn(A),y=MB(h.body);return Promise.all([m.done,y.done]).then(async([C,I])=>{try{let T=u?iit(C):JSON.parse(C),D=u?await SF(I):JSON.parse(I);NU({...g,openai:{...g.openai,response:{body:T}},response:{...g.response,body:D}},d)}catch(T){K("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Gemini):"+T?.stack)}}).catch(C=>K("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Gemini):"+C)),new Response(y.stream,{status:h.status,statusText:h.statusText,headers:h.headers})}}function len(e){return async(t,r)=>{if(!MJ(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=cg(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();K(`API error response: ${a.status} ${a.statusText}`,{url:typeof t=="string"?t:t instanceof QT?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 QT?t.toString():t.url,method:r.method,headers:cg(r.headers),body:JSON.parse(n)},response:{status:a.status,statusText:a.statusText,headers:cg(a.headers)}};return(async()=>{if(c){let m=await a.text();u.response.body=await SF(m)}else u.response.body=await a.json();let g=cg(r.headers)["x-agent-id"];TG(g,u),vG(g,{request:u.request.body.messages,response:u.response.body.content,usage:u.response.body?.usage})})().catch(d=>K(`\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF:
626
- Stack trace: `+d.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var kJ=null,E1e=!1;function cen(){kJ=null,E1e=!1}_r.on("proxy:changed",cen);function uen(){if(E1e)return kJ;if(E1e=!0,tt().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(kJ=new Rpt.ProxyAgent({uri:e}),Ct(`[proxy] using proxy: ${e}`)),kJ}function den(){let e=uen();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function QJ(e){let t=e||process.env.API_TYPE,r=den();switch(t){case"openai":return oen(r);case"openai-responses":return sen(r);case"gemini":return aen(r);default:return len(r)}}kA();var gen=Re(it(),1);function Npt(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=fen(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function fen(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||pen(t)?0:men(t)?2:1}function pen(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function men(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 O0(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 AC(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}Oe();ps();var Gl={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function PJ(e,t){Gl.totalCost+=e,Gl.totalAPIDuration+=t}function LJ(e,t){Gl.inputTokens+=e,Gl.outputTokens+=t,_r.emit("token:change",{inputTokens:Gl.inputTokens,outputTokens:Gl.outputTokens})}function FJ(e,t){Gl.cacheCreationTokens+=e,Gl.cacheReadTokens+=t}function b1e(){return{inputTokens:Gl.inputTokens,outputTokens:Gl.outputTokens,cacheCreationTokens:Gl.cacheCreationTokens,cacheReadTokens:Gl.cacheReadTokens}}function Bpt(){return Gl.totalCost}function Opt(){return Date.now()-Gl.startTime}function kpt(){return Gl.totalAPIDuration}function Mpt(e){Gl.currentContextTokens=e}function Qpt(){return Gl.currentContextTokens}Oe();He();He();var C1e="2.7.17";globalThis.MACRO={VERSION:C1e,PACKAGE_URL:`@dahawa/${Fi}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var UJ=process.env.HAWA_CODE_USER_AGENT||`${Fi}/${C1e} (${process.env.USER_TYPE})`;import{randomUUID as jh}from"crypto";ps();Oe();er();Ar();Oe();He();import{existsSync as L0,readdirSync as qin,statSync as Gin}from"fs";import{join as yC,relative as zin}from"path";import{homedir as xAt}from"os";import{platform as jin}from"process";import{readFile as bC}from"fs/promises";Ar();qp();Wt();import{join as yen,sep as ben}from"path";function Gp(){if(!au())return!1;try{let e=tt();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function Cf(){return(yen(Be(),".hcode","team-memory")+ben).normalize("NFC")}function M0(e){let t=e.normalize("NFC"),r=Cf();return t.startsWith(r)}qp();var wAt=Re($U(),1);Ci();var F1e=(e,t,r)=>{let n=e instanceof RegExp?tAt(e,r):e,i=t instanceof RegExp?tAt(t,r):t,o=n!==null&&i!=null&&Onn(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)}},tAt=(e,t)=>{let r=t.match(e);return r?r[0]:null},Onn=(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 rAt="\0SLASH"+Math.random()+"\0",nAt="\0OPEN"+Math.random()+"\0",H1e="\0CLOSE"+Math.random()+"\0",iAt="\0COMMA"+Math.random()+"\0",oAt="\0PERIOD"+Math.random()+"\0",knn=new RegExp(rAt,"g"),Mnn=new RegExp(nAt,"g"),Qnn=new RegExp(H1e,"g"),Pnn=new RegExp(iAt,"g"),Lnn=new RegExp(oAt,"g"),Fnn=/\\\\/g,Unn=/\\{/g,$nn=/\\}/g,Hnn=/\\,/g,qnn=/\\\./g,Gnn=1e5,znn=4e6;function U1e(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function jnn(e){return e.replace(Fnn,rAt).replace(Unn,nAt).replace($nn,H1e).replace(Hnn,iAt).replace(qnn,oAt)}function Ynn(e){return e.replace(knn,"\\").replace(Mnn,"{").replace(Qnn,"}").replace(Pnn,",").replace(Lnn,".")}function sAt(e){if(!e)return[""];let t=[],r=F1e("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=sAt(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function aAt(e,t={}){if(!e)return[];let{max:r=Gnn,maxLength:n=znn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),$1e(jnn(e),r,n,!0).map(Ynn)}function Vnn(e){return"{"+e+"}"}function Wnn(e){return/^-?0\d/.test(e)}function Knn(e,t){return e<=t}function Jnn(e,t){return e>=t}function HU(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 Znn(e,t,r,n){let i=e.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let s=U1e(i[0]),a=U1e(i[1]),l=Math.max(i[0].length,i[1].length),c=i.length===3&&i[2]!==void 0?Math.max(Math.abs(U1e(i[2])),1):1,u=Knn;a<s&&(c*=-1,u=Jnn);let g=i.some(Wnn),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 C=new Array(y+1).join("0");A<0?h="-"+C+h.slice(1):h=C+h}}if(m+h.length>n)break;o.push(h),m+=h.length}return o}function $1e(e,t,r,n){let i=[""],o=!1,s=!0;for(;;){let a=F1e("{","}",e);if(!a)return HU(i,e,[""],t,r,o);let l=a.pre;if(/\$$/.test(l)){if(i=HU(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+H1e+a.post,n=!0;continue}return HU(i,l+"{"+a.body+"}"+a.post,[""],t,r,o)}s&&(o=n&&!d,s=!1);let m;if(d)m=Znn(a.body,u,t,r);else{let A=sAt(a.body);if(A.length===1&&A[0]!==void 0&&(A=$1e(A[0],t,r,!1).map(Vnn),A.length===1)){if(i=HU(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 C=0;h&&C<i.length;C++)i[C]&&(h=!1);m=[];let y=0;e:for(let C=0;C<A.length;C++){let I=$1e(A[C],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=HU(i,l,m,t,r,o&&!a.post.length),!a.post.length)break;e=a.post}return i}var qU=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Xnn={"[: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]},GU=e=>e.replace(/[[\]\\-]/g,"\\$&"),ein=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),lAt=e=>e.join(""),cAt=(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,[C,I,T]]of Object.entries(Xnn))if(e.startsWith(y,o)){if(d)return["$.",!1,e.length-r,!0];o+=y.length,T?i.push(C):n.push(C),a=a||I;continue e}}if(l=!1,d){h>d?n.push(GU(d)+"-"+GU(h)):h===d&&n.push(GU(h)),d="",o++;continue}if(e.startsWith("-]",o+1)){n.push(GU(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){d=h,o+=2;continue}n.push(GU(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[ein(h),!1,u-r,!1]}let g="["+(c?"^":"")+lAt(n)+"]",m="["+(c?"":"^")+lAt(i)+"]";return[n.length&&i.length?"("+g+"|"+m+")":n.length?g:m,a,u-r,!0]};var _C=(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 fd,tin=new Set(["!","?","+","*","@"]),q1e=e=>tin.has(e),uAt=e=>q1e(e.type),rin=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),nin=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),iin=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),dAt=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),oin="(?!(?:^|/)\\.\\.?(?:$|/))",XJ="(?!\\.)",sin=new Set(["[","."]),ain=new Set(["..","."]),lin=new Set("().*{}+?[]^$\\!"),cin=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),G1e="[^/]",fAt=G1e+"*?",pAt=G1e+"+?",uin=0,GT=class{type;#e;#t;#n=!1;#r=[];#o;#i;#l;#s=!1;#a;#d;#p=!1;id=++uin;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 fd&&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 fd&&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 fd(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 C=t.charAt(h++);if(a||C==="\\"){a=!a,y+=C;continue}if(l){h===c+1?(C==="^"||C==="!")&&(u=!0):C==="]"&&!(h===c+2&&u)&&(l=!1),y+=C;continue}else if(C==="["){l=!0,c=h,u=!1,y+=C;continue}if(!i.noext&&q1e(C)&&t.charAt(h)==="("&&o<=s){r.push(y),y="";let T=new fd(C,r);h=fd.#c(t,T,h,i,o+1),r.push(T);continue}y+=C}return r.push(y),h}let d=n+1,g=new fd(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&&q1e(h)&&t.charAt(d)==="("&&(o<=s||r&&r.#E(h))){let C=r&&r.#E(h)?0:1;g.push(A),A="";let I=new fd(h,g);g.push(I),d=fd.#c(t,I,d,i,o+C);continue}if(h==="|"){g.push(A),A="",m.push(g),g=new fd(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,nin)}#h(t,r=rin){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=iin){return!!r.get(this.type)?.includes(t)}#A(t,r){let n=t.#r[0],i=new fd(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!!dAt.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=dAt.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 fd(null,void 0,r);return fd.#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()),!uAt(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(m=>typeof m!="string"),c=this.#r.map(m=>{let[A,h,y,C]=typeof m=="string"?fd.#C(m,this.#t,l):m.toRegExpSource(t);return this.#t=this.#t||y,this.#n=this.#n||C,A}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&ain.has(this.#r[0]))){let A=sin,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?oin:y?XJ:""}let d="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(d="(?:$|\\/)"),[u+c+d,_C(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,_C(this.toString()),!1,!1]}let s=!n||t||r||!XJ?"":this.#b(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?XJ:"")+pAt;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?XJ:"")+fAt+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,_C(o),this.#t=!!this.#t,this.#n]}#_(){if(uAt(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+=(lin.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?pAt:fAt,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,d,g,m]=cAt(t,l);if(g){o+=u,s=s||d,l+=g-1,r=r||m;continue}}if(c==="?"){o+=G1e,r=!0;continue}o+=cin(c)}return[o,_C(t),!!r,s]}};fd=GT;var z1e=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var jl=(e,t,r={})=>(qU(t),!r.nocomment&&t.charAt(0)==="#"?!1:new zB(t,r).match(e)),din=/^\*+([^+@!?*[(]*)$/,fin=e=>t=>!t.startsWith(".")&&t.endsWith(e),pin=e=>t=>t.endsWith(e),min=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),gin=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Ain=/^\*+\.\*+$/,hin=e=>!e.startsWith(".")&&e.includes("."),Ein=e=>e!=="."&&e!==".."&&e.includes("."),_in=/^\.\*+$/,yin=e=>e!=="."&&e!==".."&&e.startsWith("."),bin=/^\*+$/,Cin=e=>e.length!==0&&!e.startsWith("."),Sin=e=>e.length!==0&&e!=="."&&e!=="..",Iin=/^\?+([^+@!?*[(]*)?$/,Tin=([e,t=""])=>{let r=AAt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},vin=([e,t=""])=>{let r=hAt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},xin=([e,t=""])=>{let r=hAt([e]);return t?n=>r(n)&&n.endsWith(t):r},win=([e,t=""])=>{let r=AAt([e]);return t?n=>r(n)&&n.endsWith(t):r},AAt=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},hAt=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},EAt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",mAt={win32:{sep:"\\"},posix:{sep:"/"}},Din=EAt==="win32"?mAt.win32.sep:mAt.posix.sep;jl.sep=Din;var vc=Symbol("globstar **");jl.GLOBSTAR=vc;var Rin="[^/]",Nin=Rin+"*?",Bin="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Oin="(?:(?!(?:\\/|^)\\.).)*?",kin=(e,t={})=>r=>jl(r,e,t);jl.filter=kin;var zp=(e,t={})=>Object.assign({},e,t),Min=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return jl;let t=jl;return Object.assign((n,i,o={})=>t(n,i,zp(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,zp(e,o))}static defaults(i){return t.defaults(zp(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,zp(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,zp(e,o))}},unescape:(n,i={})=>t.unescape(n,zp(e,i)),escape:(n,i={})=>t.escape(n,zp(e,i)),filter:(n,i={})=>t.filter(n,zp(e,i)),defaults:n=>t.defaults(zp(e,n)),makeRe:(n,i={})=>t.makeRe(n,zp(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,zp(e,i)),match:(n,i,o={})=>t.match(n,i,zp(e,o)),sep:t.sep,GLOBSTAR:vc})};jl.defaults=Min;var _At=(e,t={})=>(qU(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:aAt(e,{max:t.braceExpandMax}));jl.braceExpand=_At;var Qin=(e,t={})=>new zB(e,t).makeRe();jl.makeRe=Qin;var Pin=(e,t,r={})=>{let n=new zB(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};jl.match=Pin;var gAt=/[?*]|[+@!]\(.*?\)|\[|\]/,Lin=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),zB=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){qU(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||EAt,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]==="?"||!gAt.test(o[2]))&&!gAt.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(vc)?this.#e(t,r,n,i,o):this.#n(t,r,n,i,o)}#e(t,r,n,i,o){let s=r.indexOf(vc,o),a=r.lastIndexOf(vc),[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===vc?(h.push(A),m=[[],0],g.push(m)):(m[0].push(I),A++);let y=g.length-1,C=t.length-d;for(let I of g)I[1]=C-(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===vc)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 _At(this.pattern,this.options)}parse(t){qU(t);let r=this.options;if(t==="**")return vc;if(t==="")return"";let n,i=null;(n=t.match(bin))?i=r.dot?Sin:Cin:(n=t.match(din))?i=(r.nocase?r.dot?gin:min:r.dot?pin:fin)(n[1]):(n=t.match(Iin))?i=(r.nocase?r.dot?vin:Tin:r.dot?xin:win)(n):(n=t.match(Ain))?i=r.dot?Ein:hin:(n=t.match(_in))&&(i=yin);let o=GT.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?Nin:r.dot?Bin:Oin,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"?Lin(d):d===vc?vc:d._src});c.forEach((d,g)=>{let m=c[g+1],A=c[g-1];d!==vc||A===vc||(A===void 0?m!==void 0&&m!==vc?c[g+1]="(?:\\/|"+n+"\\/)?"+m:c[g]=n:m===void 0?c[g-1]=A+"(?:\\/|\\/"+n+")?":m!==vc&&(c[g-1]=A+"(?:\\/|\\/"+n+"\\/)"+m,c[g+1]=vc))});let u=c.filter(d=>d!==vc);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 jl.defaults(t).Minimatch}};jl.AST=GT;jl.Minimatch=zB;jl.escape=z1e;jl.unescape=_C;var CAt=Re($U(),1);Ar();He();Oe();Xc();import{readFile as yAt}from"fs/promises";import{existsSync as j1e,readdirSync as Fin,statSync as Uin}from"fs";import{join as Y1e,relative as SAt}from"path";import{homedir as $in}from"os";function bAt(e){try{let t=(0,CAt.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 ve(t),{paths:[],content:e.trim()}}}function Hin(e,t){return t.length===0?!0:t.some(r=>{try{return jl(e,r,{matchBase:!0,dot:!0})}catch(n){return ve(n),!1}})}function V1e(e){let t=[];try{if(!j1e(e))return t;let r=Fin(e);for(let n of r){let i=Y1e(e,n),o=Uin(i);o.isDirectory()?t.push(...V1e(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){ve(r)}return t}async function eZ(){let e=[];try{let t=Y1e($in(),Jr,"rules");if(j1e(t)){let r=V1e(t);for(let n of r)try{let i=await yAt(n,"utf-8"),{paths:o,content:s}=bAt(i);o.length>0&&e.push({filePath:n,content:s,paths:o,isProjectRule:!1})}catch(i){ve(i)}}}catch(t){ve(t)}try{let t=Y1e(Be(),Jr,"rules");if(j1e(t)){let r=V1e(t);for(let n of r)try{let i=await yAt(n,"utf-8"),{paths:o,content:s}=bAt(i);o.length>0&&e.push({filePath:SAt(Be(),n),content:s,paths:o,isProjectRule:!0})}catch(i){ve(i)}}}catch(t){ve(t)}return e}function IAt(e,t){e=yY(e);let r=yY(Be()),n=e.startsWith(r)?SAt(r,e):e;return t.filter(i=>Hin(n,i.paths))}function TAt(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
+ Stack trace: `+d.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var kJ=null,E1e=!1;function cen(){kJ=null,E1e=!1}_r.on("proxy:changed",cen);function uen(){if(E1e)return kJ;if(E1e=!0,tt().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(kJ=new Rpt.ProxyAgent({uri:e}),Ct(`[proxy] using proxy: ${e}`)),kJ}function den(){let e=uen();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function QJ(e){let t=e||process.env.API_TYPE,r=den();switch(t){case"openai":return oen(r);case"openai-responses":return sen(r);case"gemini":return aen(r);default:return len(r)}}kA();var gen=Re(it(),1);function Npt(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=fen(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function fen(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||pen(t)?0:men(t)?2:1}function pen(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function men(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 O0(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 AC(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}Oe();ps();var Gl={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function PJ(e,t){Gl.totalCost+=e,Gl.totalAPIDuration+=t}function LJ(e,t){Gl.inputTokens+=e,Gl.outputTokens+=t,_r.emit("token:change",{inputTokens:Gl.inputTokens,outputTokens:Gl.outputTokens})}function FJ(e,t){Gl.cacheCreationTokens+=e,Gl.cacheReadTokens+=t}function b1e(){return{inputTokens:Gl.inputTokens,outputTokens:Gl.outputTokens,cacheCreationTokens:Gl.cacheCreationTokens,cacheReadTokens:Gl.cacheReadTokens}}function Bpt(){return Gl.totalCost}function Opt(){return Date.now()-Gl.startTime}function kpt(){return Gl.totalAPIDuration}function Mpt(e){Gl.currentContextTokens=e}function Qpt(){return Gl.currentContextTokens}Oe();He();He();var C1e="2.7.18";globalThis.MACRO={VERSION:C1e,PACKAGE_URL:`@dahawa/${Fi}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var UJ=process.env.HAWA_CODE_USER_AGENT||`${Fi}/${C1e} (${process.env.USER_TYPE})`;import{randomUUID as jh}from"crypto";ps();Oe();er();Ar();Oe();He();import{existsSync as L0,readdirSync as qin,statSync as Gin}from"fs";import{join as yC,relative as zin}from"path";import{homedir as xAt}from"os";import{platform as jin}from"process";import{readFile as bC}from"fs/promises";Ar();qp();Wt();import{join as yen,sep as ben}from"path";function Gp(){if(!au())return!1;try{let e=tt();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function Cf(){return(yen(Be(),".hcode","team-memory")+ben).normalize("NFC")}function M0(e){let t=e.normalize("NFC"),r=Cf();return t.startsWith(r)}qp();var wAt=Re($U(),1);Ci();var F1e=(e,t,r)=>{let n=e instanceof RegExp?tAt(e,r):e,i=t instanceof RegExp?tAt(t,r):t,o=n!==null&&i!=null&&Onn(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)}},tAt=(e,t)=>{let r=t.match(e);return r?r[0]:null},Onn=(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 rAt="\0SLASH"+Math.random()+"\0",nAt="\0OPEN"+Math.random()+"\0",H1e="\0CLOSE"+Math.random()+"\0",iAt="\0COMMA"+Math.random()+"\0",oAt="\0PERIOD"+Math.random()+"\0",knn=new RegExp(rAt,"g"),Mnn=new RegExp(nAt,"g"),Qnn=new RegExp(H1e,"g"),Pnn=new RegExp(iAt,"g"),Lnn=new RegExp(oAt,"g"),Fnn=/\\\\/g,Unn=/\\{/g,$nn=/\\}/g,Hnn=/\\,/g,qnn=/\\\./g,Gnn=1e5,znn=4e6;function U1e(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function jnn(e){return e.replace(Fnn,rAt).replace(Unn,nAt).replace($nn,H1e).replace(Hnn,iAt).replace(qnn,oAt)}function Ynn(e){return e.replace(knn,"\\").replace(Mnn,"{").replace(Qnn,"}").replace(Pnn,",").replace(Lnn,".")}function sAt(e){if(!e)return[""];let t=[],r=F1e("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=sAt(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function aAt(e,t={}){if(!e)return[];let{max:r=Gnn,maxLength:n=znn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),$1e(jnn(e),r,n,!0).map(Ynn)}function Vnn(e){return"{"+e+"}"}function Wnn(e){return/^-?0\d/.test(e)}function Knn(e,t){return e<=t}function Jnn(e,t){return e>=t}function HU(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 Znn(e,t,r,n){let i=e.split(/\.\./),o=[];if(i[0]===void 0||i[1]===void 0)return o;let s=U1e(i[0]),a=U1e(i[1]),l=Math.max(i[0].length,i[1].length),c=i.length===3&&i[2]!==void 0?Math.max(Math.abs(U1e(i[2])),1):1,u=Knn;a<s&&(c*=-1,u=Jnn);let g=i.some(Wnn),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 C=new Array(y+1).join("0");A<0?h="-"+C+h.slice(1):h=C+h}}if(m+h.length>n)break;o.push(h),m+=h.length}return o}function $1e(e,t,r,n){let i=[""],o=!1,s=!0;for(;;){let a=F1e("{","}",e);if(!a)return HU(i,e,[""],t,r,o);let l=a.pre;if(/\$$/.test(l)){if(i=HU(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+H1e+a.post,n=!0;continue}return HU(i,l+"{"+a.body+"}"+a.post,[""],t,r,o)}s&&(o=n&&!d,s=!1);let m;if(d)m=Znn(a.body,u,t,r);else{let A=sAt(a.body);if(A.length===1&&A[0]!==void 0&&(A=$1e(A[0],t,r,!1).map(Vnn),A.length===1)){if(i=HU(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 C=0;h&&C<i.length;C++)i[C]&&(h=!1);m=[];let y=0;e:for(let C=0;C<A.length;C++){let I=$1e(A[C],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=HU(i,l,m,t,r,o&&!a.post.length),!a.post.length)break;e=a.post}return i}var qU=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Xnn={"[: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]},GU=e=>e.replace(/[[\]\\-]/g,"\\$&"),ein=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),lAt=e=>e.join(""),cAt=(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,[C,I,T]]of Object.entries(Xnn))if(e.startsWith(y,o)){if(d)return["$.",!1,e.length-r,!0];o+=y.length,T?i.push(C):n.push(C),a=a||I;continue e}}if(l=!1,d){h>d?n.push(GU(d)+"-"+GU(h)):h===d&&n.push(GU(h)),d="",o++;continue}if(e.startsWith("-]",o+1)){n.push(GU(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){d=h,o+=2;continue}n.push(GU(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[ein(h),!1,u-r,!1]}let g="["+(c?"^":"")+lAt(n)+"]",m="["+(c?"":"^")+lAt(i)+"]";return[n.length&&i.length?"("+g+"|"+m+")":n.length?g:m,a,u-r,!0]};var _C=(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 fd,tin=new Set(["!","?","+","*","@"]),q1e=e=>tin.has(e),uAt=e=>q1e(e.type),rin=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),nin=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),iin=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),dAt=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),oin="(?!(?:^|/)\\.\\.?(?:$|/))",XJ="(?!\\.)",sin=new Set(["[","."]),ain=new Set(["..","."]),lin=new Set("().*{}+?[]^$\\!"),cin=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),G1e="[^/]",fAt=G1e+"*?",pAt=G1e+"+?",uin=0,GT=class{type;#e;#t;#n=!1;#r=[];#o;#i;#l;#s=!1;#a;#d;#p=!1;id=++uin;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 fd&&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 fd&&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 fd(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 C=t.charAt(h++);if(a||C==="\\"){a=!a,y+=C;continue}if(l){h===c+1?(C==="^"||C==="!")&&(u=!0):C==="]"&&!(h===c+2&&u)&&(l=!1),y+=C;continue}else if(C==="["){l=!0,c=h,u=!1,y+=C;continue}if(!i.noext&&q1e(C)&&t.charAt(h)==="("&&o<=s){r.push(y),y="";let T=new fd(C,r);h=fd.#c(t,T,h,i,o+1),r.push(T);continue}y+=C}return r.push(y),h}let d=n+1,g=new fd(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&&q1e(h)&&t.charAt(d)==="("&&(o<=s||r&&r.#E(h))){let C=r&&r.#E(h)?0:1;g.push(A),A="";let I=new fd(h,g);g.push(I),d=fd.#c(t,I,d,i,o+C);continue}if(h==="|"){g.push(A),A="",m.push(g),g=new fd(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,nin)}#h(t,r=rin){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=iin){return!!r.get(this.type)?.includes(t)}#A(t,r){let n=t.#r[0],i=new fd(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!!dAt.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=dAt.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 fd(null,void 0,r);return fd.#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()),!uAt(this)){let l=this.isStart()&&this.isEnd()&&!this.#r.some(m=>typeof m!="string"),c=this.#r.map(m=>{let[A,h,y,C]=typeof m=="string"?fd.#C(m,this.#t,l):m.toRegExpSource(t);return this.#t=this.#t||y,this.#n=this.#n||C,A}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&ain.has(this.#r[0]))){let A=sin,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?oin:y?XJ:""}let d="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(d="(?:$|\\/)"),[u+c+d,_C(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,_C(this.toString()),!1,!1]}let s=!n||t||r||!XJ?"":this.#b(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?XJ:"")+pAt;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?XJ:"")+fAt+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,_C(o),this.#t=!!this.#t,this.#n]}#_(){if(uAt(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+=(lin.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?pAt:fAt,r=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?o+="\\\\":i=!0;continue}if(c==="["){let[u,d,g,m]=cAt(t,l);if(g){o+=u,s=s||d,l+=g-1,r=r||m;continue}}if(c==="?"){o+=G1e,r=!0;continue}o+=cin(c)}return[o,_C(t),!!r,s]}};fd=GT;var z1e=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var jl=(e,t,r={})=>(qU(t),!r.nocomment&&t.charAt(0)==="#"?!1:new zB(t,r).match(e)),din=/^\*+([^+@!?*[(]*)$/,fin=e=>t=>!t.startsWith(".")&&t.endsWith(e),pin=e=>t=>t.endsWith(e),min=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),gin=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Ain=/^\*+\.\*+$/,hin=e=>!e.startsWith(".")&&e.includes("."),Ein=e=>e!=="."&&e!==".."&&e.includes("."),_in=/^\.\*+$/,yin=e=>e!=="."&&e!==".."&&e.startsWith("."),bin=/^\*+$/,Cin=e=>e.length!==0&&!e.startsWith("."),Sin=e=>e.length!==0&&e!=="."&&e!=="..",Iin=/^\?+([^+@!?*[(]*)?$/,Tin=([e,t=""])=>{let r=AAt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},vin=([e,t=""])=>{let r=hAt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},xin=([e,t=""])=>{let r=hAt([e]);return t?n=>r(n)&&n.endsWith(t):r},win=([e,t=""])=>{let r=AAt([e]);return t?n=>r(n)&&n.endsWith(t):r},AAt=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},hAt=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},EAt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",mAt={win32:{sep:"\\"},posix:{sep:"/"}},Din=EAt==="win32"?mAt.win32.sep:mAt.posix.sep;jl.sep=Din;var vc=Symbol("globstar **");jl.GLOBSTAR=vc;var Rin="[^/]",Nin=Rin+"*?",Bin="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Oin="(?:(?!(?:\\/|^)\\.).)*?",kin=(e,t={})=>r=>jl(r,e,t);jl.filter=kin;var zp=(e,t={})=>Object.assign({},e,t),Min=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return jl;let t=jl;return Object.assign((n,i,o={})=>t(n,i,zp(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,zp(e,o))}static defaults(i){return t.defaults(zp(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,zp(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,zp(e,o))}},unescape:(n,i={})=>t.unescape(n,zp(e,i)),escape:(n,i={})=>t.escape(n,zp(e,i)),filter:(n,i={})=>t.filter(n,zp(e,i)),defaults:n=>t.defaults(zp(e,n)),makeRe:(n,i={})=>t.makeRe(n,zp(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,zp(e,i)),match:(n,i,o={})=>t.match(n,i,zp(e,o)),sep:t.sep,GLOBSTAR:vc})};jl.defaults=Min;var _At=(e,t={})=>(qU(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:aAt(e,{max:t.braceExpandMax}));jl.braceExpand=_At;var Qin=(e,t={})=>new zB(e,t).makeRe();jl.makeRe=Qin;var Pin=(e,t,r={})=>{let n=new zB(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};jl.match=Pin;var gAt=/[?*]|[+@!]\(.*?\)|\[|\]/,Lin=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),zB=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor(t,r={}){qU(t),r=r||{},this.options=r,this.maxGlobstarRecursion=r.maxGlobstarRecursion??200,this.pattern=t,this.platform=r.platform||EAt,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]==="?"||!gAt.test(o[2]))&&!gAt.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(vc)?this.#e(t,r,n,i,o):this.#n(t,r,n,i,o)}#e(t,r,n,i,o){let s=r.indexOf(vc,o),a=r.lastIndexOf(vc),[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===vc?(h.push(A),m=[[],0],g.push(m)):(m[0].push(I),A++);let y=g.length-1,C=t.length-d;for(let I of g)I[1]=C-(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===vc)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 _At(this.pattern,this.options)}parse(t){qU(t);let r=this.options;if(t==="**")return vc;if(t==="")return"";let n,i=null;(n=t.match(bin))?i=r.dot?Sin:Cin:(n=t.match(din))?i=(r.nocase?r.dot?gin:min:r.dot?pin:fin)(n[1]):(n=t.match(Iin))?i=(r.nocase?r.dot?vin:Tin:r.dot?xin:win)(n):(n=t.match(Ain))?i=r.dot?Ein:hin:(n=t.match(_in))&&(i=yin);let o=GT.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?Nin:r.dot?Bin:Oin,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"?Lin(d):d===vc?vc:d._src});c.forEach((d,g)=>{let m=c[g+1],A=c[g-1];d!==vc||A===vc||(A===void 0?m!==void 0&&m!==vc?c[g+1]="(?:\\/|"+n+"\\/)?"+m:c[g]=n:m===void 0?c[g-1]=A+"(?:\\/|\\/"+n+")?":m!==vc&&(c[g-1]=A+"(?:\\/|\\/"+n+"\\/)"+m,c[g+1]=vc))});let u=c.filter(d=>d!==vc);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 jl.defaults(t).Minimatch}};jl.AST=GT;jl.Minimatch=zB;jl.escape=z1e;jl.unescape=_C;var CAt=Re($U(),1);Ar();He();Oe();Xc();import{readFile as yAt}from"fs/promises";import{existsSync as j1e,readdirSync as Fin,statSync as Uin}from"fs";import{join as Y1e,relative as SAt}from"path";import{homedir as $in}from"os";function bAt(e){try{let t=(0,CAt.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 ve(t),{paths:[],content:e.trim()}}}function Hin(e,t){return t.length===0?!0:t.some(r=>{try{return jl(e,r,{matchBase:!0,dot:!0})}catch(n){return ve(n),!1}})}function V1e(e){let t=[];try{if(!j1e(e))return t;let r=Fin(e);for(let n of r){let i=Y1e(e,n),o=Uin(i);o.isDirectory()?t.push(...V1e(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){ve(r)}return t}async function eZ(){let e=[];try{let t=Y1e($in(),Jr,"rules");if(j1e(t)){let r=V1e(t);for(let n of r)try{let i=await yAt(n,"utf-8"),{paths:o,content:s}=bAt(i);o.length>0&&e.push({filePath:n,content:s,paths:o,isProjectRule:!1})}catch(i){ve(i)}}}catch(t){ve(t)}try{let t=Y1e(Be(),Jr,"rules");if(j1e(t)){let r=V1e(t);for(let n of r)try{let i=await yAt(n,"utf-8"),{paths:o,content:s}=bAt(i);o.length>0&&e.push({filePath:SAt(Be(),n),content:s,paths:o,isProjectRule:!0})}catch(i){ve(i)}}}catch(t){ve(t)}return e}function IAt(e,t){e=yY(e);let r=yY(Be()),n=e.startsWith(r)?SAt(r,e):e;return t.filter(i=>Hin(n,i.paths))}function TAt(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}):
627
627
 
628
628
  ${r.content}`}).join(`
629
629
 
@@ -985,7 +985,7 @@ ${Ue.isMessageArchivingEnable()?`
985
985
 
986
986
  ${await w_t()||""}`,`
987
987
  ${await Av()}
988
- `,...Ue.isTasksEnable()?[]:["IMPORTANT: Always use the TodoWrite tool to plan and track tasks throughout the conversation."],"# Code References\n\nWhen referencing specific functions or pieces of code include the pattern `file_path:line_number` to allow the user to easily navigate to the source code location.",...Ue.isMemoEnable()?["\n\n# Memo Tool Content Placeholder\n\nWhen the Memo tool is enabled, older Memo write contents are truncated in the context window. If you see a past Memo write where the content appears as `...<first 20 characters>...(argument truncated)`, the real content is stored on disk. Use the Memo tool's `read` operation with the corresponding `key` when you need the full content again. The most recent 5 messages keep their full content unchanged."]:[],...tt().language&&tt().language!=="auto"?[`
988
+ `,"# Code References\n\nWhen referencing specific functions or pieces of code include the pattern `file_path:line_number` to allow the user to easily navigate to the source code location.",...Ue.isMemoEnable()?["\n\n# Memo Tool Content Placeholder\n\nWhen the Memo tool is enabled, older Memo write contents are truncated in the context window. If you see a past Memo write where the content appears as `...<first 20 characters>...(argument truncated)`, the real content is stored on disk. Use the Memo tool's `read` operation with the corresponding `key` when you need the full content again. The most recent 5 messages keep their full content unchanged."]:[],...tt().language&&tt().language!=="auto"?[`
989
989
 
990
990
  # Language
991
991
  Always respond in ${tt().language}. Use ${tt().language} for all explanations, comments, and communications with the user. Technical terms and code identifiers should remain in their original form.
@@ -1016,7 +1016,7 @@ You are powered by the model ${e}.`}async function hv(){return!["1","true"].incl
1016
1016
  <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:TE(c.inputSchema));return{name:c.name,description:`${u}
1017
1017
 
1018
1018
  Schema:
1019
- ${d}`}}),{messages:a}=t,l=Fcn(o);return Ucn(o,l,s,a)}},B_t=$cn;fg();var y2=Re(it(),1);Oe();Oe();import{existsSync as Hcn,readdirSync as qcn,statSync as Gcn}from"fs";import{join as zcn}from"path";function jcn(){let e=$i.plan();if(!Hcn(e))return[];try{return qcn(e).filter(r=>r.endsWith(".md")).map(r=>{let n=zcn(e,r),i=Gcn(n);return{name:r,path:n,modified:i.mtime}}).sort((r,n)=>n.modified.getTime()-r.modified.getTime())}catch{return[]}}var O_t=({onSelect:e})=>{let[t,r]=(0,y2.useState)([]),[n,i]=(0,y2.useState)(0),[o,s]=(0,y2.useState)(!1);(0,y2.useEffect)(()=>{let c=jcn();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}))];or((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=Me();return o?(0,_.jsxs)(B,{flexDirection:"column",marginY:1,children:[(0,_.jsx)(B,{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)(B,{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)(B,{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:[" ","(",$me(c.modified),")"]})]},c.isNew?"new":c.value)}),(0,_.jsx)(B,{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)(B,{flexDirection:"column",marginY:1,children:(0,_.jsx)(x,{children:"Loading plan history..."})})};var Ycn={type:"local-jsx",name:"plan",description:()=>"Enable plan mode",isEnabled:!0,isHidden:!1,disableCancel:!0,async call(e){return Ai.isPlanMode()?(e("Already in plan mode."),null):(0,_.jsx)(O_t,{onSelect:t=>{if(t==="__CANCELLED__"){e("Cancelled.");return}t&&t!=="__NEW_PLAN__"?Ai.setCurrentPlanFilePath(t):Ai.generatePlanFilePath(),Ai.setMode("plan",!0,!1),e("Enabled plan mode")}})},userFacingName(){return"plan"}},k_t=Ycn;fg();var Vcn={type:"local",name:"auto",description:()=>"Enable auto mode",isEnabled:!0,isHidden:!1,async call(){return Ai.isAutoMode()?"Already in auto mode.":(Ai.setMode("auto",!0),"Enabled auto mode")},userFacingName(){return"auto"}},M_t=Vcn;Ar();import{resolve as Wcn}from"path";var Kcn={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=Be(),n=Wcn(r,t);zs(n);let i=Be();return i===r?`Already in ${i}.`:`Changed directory to ${i}/`},userFacingName(){return"cd"}},Q_t=Kcn;var pCt=Re(it(),1);var ch=Re(it(),1);var wun=Re(it(),1);var N5=Re(it(),1),Tun=Re(U_t(),1);var $_t={info:"blue",success:"green",error:"red",warning:"yellow"},uun={styles:{container:({variant:e})=>({flexGrow:1,borderStyle:"round",borderColor:$_t[e],gap:1,paddingX:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:$_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=Zt.info),e==="success"&&(t=Zt.tick),e==="error"&&(t=Zt.cross),e==="warning"&&(t=Zt.warning),{icon:t}}},H_t=uun;var dun={styles:{container:({color:e})=>({backgroundColor:e}),label:()=>({color:"black"})}},q_t=dun;var fun={styles:{input:({isFocused:e})=>({dimColor:!e})}},G_t=fun;var pun={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})}},z_t=pun;var mun={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})}},j_t=mun;var gun={styles:{container:()=>({flexGrow:1,minWidth:0}),completed:()=>({color:"magenta"}),remaining:()=>({dimColor:!0})},config:()=>({completedCharacter:Zt.square,remainingCharacter:Zt.squareLightShade})},Y_t=gun;var Aun={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})}},V_t=Aun;var hun={styles:{container:()=>({gap:1}),frame:()=>({color:"blue"}),label:()=>({})}},W_t=hun;var Eun={success:"green",error:"red",warning:"yellow",info:"blue"},_un={success:Zt.tick,error:Zt.cross,warning:Zt.warning,info:Zt.info},yun={styles:{container:()=>({gap:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:Eun[e]}),message:()=>({})},config:({variant:e})=>({icon:_un[e]})},K_t=yun;var bun={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})},config:()=>({marker:Zt.line})},J_t=bun;var Cun={styles:{value:()=>({})}},Z_t=Cun;var Sun={styles:{value:()=>({})}},X_t=Sun;var Iun={styles:{value:()=>({})}},eyt=Iun;var vun={components:{Alert:H_t,Badge:q_t,ConfirmInput:G_t,MultiSelect:z_t,OrderedList:j_t,ProgressBar:Y_t,Select:V_t,Spinner:W_t,StatusMessage:K_t,UnorderedList:J_t,TextInput:Z_t,EmailInput:X_t,PasswordInput:eyt}},xun=(0,N5.createContext)(vun);var oo=e=>(0,N5.useContext)(xun).components[e];var Dun=Re(it(),1);var V0=Re(it(),1);var C2=Re(it(),1);var tyt=Re(it(),1);var B5=Zt.line;var sX=(0,tyt.createContext)({marker:B5});function ryt({children:e}){let{marker:t}=(0,C2.useContext)(sX),{styles:r}=oo("UnorderedList");return C2.default.createElement(B,{...r.listItem()},C2.default.createElement(x,{...r.marker()},t),C2.default.createElement(B,{...r.content()},e))}var nyt=Re(it(),1),HTe=(0,nyt.createContext)({depth:0});function Run({children:e}){let{depth:t}=(0,V0.useContext)(HTe),{styles:r,config:n}=oo("UnorderedList"),i=(0,V0.useMemo)(()=>({depth:t+1}),[t]),o=(0,V0.useMemo)(()=>{let{marker:s}=n();return typeof s=="string"?{marker:s}:Array.isArray(s)?{marker:s[t]??s.at(-1)??B5}:{marker:B5}},[n,t]);return V0.default.createElement(HTe.Provider,{value:i},V0.default.createElement(sX.Provider,{value:o},V0.default.createElement(B,{...r.list()},e)))}Run.Item=ryt;var Bun=Re(it(),1);var Nun=Re(it(),1);var O5=Re(it(),1);var S2=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 iyt=Re(it(),1);var I2=Re(it(),1);var k5=Re(it(),1);function oyt({isFocused:e,isSelected:t,children:r}){let{styles:n}=oo("Select");return k5.default.createElement(B,{...n.option({isFocused:e})},e&&k5.default.createElement(x,{...n.focusIndicator()},Zt.pointer),k5.default.createElement(x,{...n.label({isFocused:e,isSelected:t})},r),t&&k5.default.createElement(x,{...n.selectedIndicator()},Zt.tick))}var Zp=Re(it(),1);import{isDeepStrictEqual as Oun}from"node:util";var kun=(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}},syt=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=typeof e=="number"?Math.min(e,r.length):r.length,i=new S2(r);return{optionMap:i,visibleOptionCount:n,focusedValue:i.first?.value,visibleFromIndex:0,visibleToIndex:n,previousValue:t,value:t}},ayt=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n})=>{let[i,o]=(0,Zp.useReducer)(kun,{visibleOptionCount:e,defaultValue:r,options:t},syt),[s,a]=(0,Zp.useState)(t);t!==s&&!Oun(t,s)&&(o({type:"reset",state:syt({visibleOptionCount:e,defaultValue:r,options:t})}),a(t));let l=(0,Zp.useCallback)(()=>{o({type:"focus-next-option"})},[]),c=(0,Zp.useCallback)(()=>{o({type:"focus-previous-option"})},[]),u=(0,Zp.useCallback)(()=>{o({type:"select-focused-option"})},[]),d=(0,Zp.useMemo)(()=>t.map((g,m)=>({...g,index:m})).slice(i.visibleFromIndex,i.visibleToIndex),[t,i.visibleFromIndex,i.visibleToIndex]);return(0,Zp.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 lyt=({isDisabled:e=!1,state:t})=>{or((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};function T2({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:i,onChange:o}){let s=ayt({visibleOptionCount:t,options:n,defaultValue:i,onChange:o});lyt({isDisabled:e,state:s});let{styles:a}=oo("Select");return I2.default.createElement(B,{...a.container()},s.visibleOptions.map(l=>{let c=l.label;if(r&&l.label.includes(r)){let u=l.label.indexOf(r);c=I2.default.createElement(I2.default.Fragment,null,l.label.slice(0,u),I2.default.createElement(x,{...a.highlightedText()},r),l.label.slice(u+r.length))}return I2.default.createElement(oyt,{key:l.value,isFocused:!e&&s.focusedValue===l.value,isSelected:s.value===l.value},c)}))}var Mun=Re(it(),1);var cyt=Re(it(),1);var Pun=Re(it(),1);var aX=Re(it(),1);var Qun=Re(it(),1);var aki=Jt.inverse(" ");var Eg=Re(it(),1);var v2=Re(it(),1);var uyt=Re(it(),1);var lX=(0,uyt.createContext)({marker:Zt.line});function cX({children:e}){let{marker:t}=(0,v2.useContext)(lX),{styles:r}=oo("OrderedList");return v2.default.createElement(B,{...r.listItem()},v2.default.createElement(x,{...r.marker()},t),v2.default.createElement(B,{...r.content()},e))}var dyt=Re(it(),1),qTe=(0,dyt.createContext)({marker:""});function _g({children:e}){let{marker:t}=(0,Eg.useContext)(qTe),{styles:r}=oo("OrderedList"),n=0;for(let o of Eg.default.Children.toArray(e))!(0,Eg.isValidElement)(o)||o.type!==cX||n++;let i=String(n).length;return Eg.default.createElement(B,{...r.list()},Eg.default.Children.map(e,(o,s)=>{if(!(0,Eg.isValidElement)(o)||o.type!==cX)return o;let a=`${String(s+1).padStart(i)}.`,l=`${t}${a}`;return Eg.default.createElement(qTe.Provider,{value:{marker:l}},Eg.default.createElement(lX.Provider,{value:{marker:l}},o))}))}_g.Item=cX;var Fun=Re(it(),1);var GTe=Re(it(),1);var Lun=Re(it(),1);var Qki=Jt.inverse(" ");var Uun=Re(it(),1);var $un=Re(it(),1);var qun=Re(it(),1);var uX=Re(it(),1);var Hun=Re(it(),1);var sMi=Jt.inverse(" ");var R2=Re(it(),1);var zTe=Re(it(),1);YU();ps();Ci();iv();Wt();var Gun=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function DC(){let e=Gun,{frame:t}=OD({interval:120});return(0,_.jsx)(B,{flexWrap:"nowrap",height:1,width:2,children:(0,_.jsx)(x,{color:Me().claude,children:e[t%e.length]})})}var pX=Re(it(),1);var Ev=null,W0=null,fX=new Set,dX=null;function YTe(e){let{columns:t,rows:r}=e;return t&&r?{columns:t,rows:r}:(dX||(dX=xfe()),{columns:t||dX.columns||80,rows:r||dX.rows||24})}function jTe(){if(!W0)return;let e=YTe(W0);Ev&&e.columns===Ev.columns&&e.rows===Ev.rows||(Ev=e,fX.forEach(t=>t(Ev)))}function zun(e,t){return W0!==e&&(W0&&W0.off("resize",jTe),W0=e,Ev=YTe(e),e.on("resize",jTe)),fX.add(t),()=>{fX.delete(t),fX.size===0&&W0&&(W0.off("resize",jTe),W0=null,Ev=null)}}function VTe(){let{stdout:e}=Uy(),[t,r]=(0,pX.useState)(()=>YTe(e));return(0,pX.useEffect)(()=>zun(e,r),[e]),t}function mX(){return VTe()}He();Xd();Oe();RA();Oe();var KQi=Re(Xbt(),1);import{homedir as q5}from"os";import{join as D2}from"path";import{existsSync as G5,mkdirSync as tCt,appendFileSync as eCt,readFileSync as rCt,constants as Hpn,writeFileSync as qpn,unlinkSync as nCt,statSync as Gpn}from"fs";import{platform as iCt}from"process";import{accessSync as zpn}from"fs";var $pn="2.7.17",H5={VERSION:$pn,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"};He();var yv=D2(s0,".update.lock"),jpn=300*1e3;function oCt(){try{if(G5(s0)||tCt(s0,{recursive:!0}),G5(yv)){let e=Gpn(yv);if(Date.now()-e.mtimeMs<jpn)return!1;try{nCt(yv)}catch(r){return ve(`Failed to remove stale lock file: ${r}`),!1}}return qpn(yv,`${process.pid}`,"utf8"),!0}catch(e){return ve(`Failed to acquire lock: ${e}`),!1}}function sCt(){try{G5(yv)&&rCt(yv,"utf8")===`${process.pid}`&&nCt(yv)}catch(e){ve(`Failed to release lock: ${e}`)}}async function gve(){try{let e=await Wn("npm -g config get prefix");if(e.code!==0)return ve("Failed to check npm permissions"),{hasPermissions:!1,npmPrefix:null};let t=e.stdout.trim(),r=!1;try{zpn(t,Hpn.W_OK),r=!0}catch{r=!1}return r?{hasPermissions:!0,npmPrefix:t}:(ve("Insufficient permissions for global npm install."),{hasPermissions:!1,npmPrefix:t})}catch(e){return ve(`Failed to verify npm global install permissions: ${e}`),{hasPermissions:!1,npmPrefix:null}}}async function aCt(e){if(!oCt())throw Nt("tengu_auto_updater_prefix_lock_contention",{pid:String(process.pid),currentVersion:H5.VERSION,prefix:e}),new Error("Another process is currently setting up npm prefix");try{G5(e)||tCt(e,{recursive:!0});let t=await Wn(`npm -g config set prefix ${e}`);if(t.code!==0)throw new Error(`Failed to set npm prefix: ${t.stderr}`);let r=`
1019
+ ${d}`}}),{messages:a}=t,l=Fcn(o);return Ucn(o,l,s,a)}},B_t=$cn;fg();var y2=Re(it(),1);Oe();Oe();import{existsSync as Hcn,readdirSync as qcn,statSync as Gcn}from"fs";import{join as zcn}from"path";function jcn(){let e=$i.plan();if(!Hcn(e))return[];try{return qcn(e).filter(r=>r.endsWith(".md")).map(r=>{let n=zcn(e,r),i=Gcn(n);return{name:r,path:n,modified:i.mtime}}).sort((r,n)=>n.modified.getTime()-r.modified.getTime())}catch{return[]}}var O_t=({onSelect:e})=>{let[t,r]=(0,y2.useState)([]),[n,i]=(0,y2.useState)(0),[o,s]=(0,y2.useState)(!1);(0,y2.useEffect)(()=>{let c=jcn();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}))];or((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=Me();return o?(0,_.jsxs)(B,{flexDirection:"column",marginY:1,children:[(0,_.jsx)(B,{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)(B,{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)(B,{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:[" ","(",$me(c.modified),")"]})]},c.isNew?"new":c.value)}),(0,_.jsx)(B,{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)(B,{flexDirection:"column",marginY:1,children:(0,_.jsx)(x,{children:"Loading plan history..."})})};var Ycn={type:"local-jsx",name:"plan",description:()=>"Enable plan mode",isEnabled:!0,isHidden:!1,disableCancel:!0,async call(e){return Ai.isPlanMode()?(e("Already in plan mode."),null):(0,_.jsx)(O_t,{onSelect:t=>{if(t==="__CANCELLED__"){e("Cancelled.");return}t&&t!=="__NEW_PLAN__"?Ai.setCurrentPlanFilePath(t):Ai.generatePlanFilePath(),Ai.setMode("plan",!0,!1),e("Enabled plan mode")}})},userFacingName(){return"plan"}},k_t=Ycn;fg();var Vcn={type:"local",name:"auto",description:()=>"Enable auto mode",isEnabled:!0,isHidden:!1,async call(){return Ai.isAutoMode()?"Already in auto mode.":(Ai.setMode("auto",!0),"Enabled auto mode")},userFacingName(){return"auto"}},M_t=Vcn;Ar();import{resolve as Wcn}from"path";var Kcn={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=Be(),n=Wcn(r,t);zs(n);let i=Be();return i===r?`Already in ${i}.`:`Changed directory to ${i}/`},userFacingName(){return"cd"}},Q_t=Kcn;var pCt=Re(it(),1);var ch=Re(it(),1);var wun=Re(it(),1);var N5=Re(it(),1),Tun=Re(U_t(),1);var $_t={info:"blue",success:"green",error:"red",warning:"yellow"},uun={styles:{container:({variant:e})=>({flexGrow:1,borderStyle:"round",borderColor:$_t[e],gap:1,paddingX:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:$_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=Zt.info),e==="success"&&(t=Zt.tick),e==="error"&&(t=Zt.cross),e==="warning"&&(t=Zt.warning),{icon:t}}},H_t=uun;var dun={styles:{container:({color:e})=>({backgroundColor:e}),label:()=>({color:"black"})}},q_t=dun;var fun={styles:{input:({isFocused:e})=>({dimColor:!e})}},G_t=fun;var pun={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})}},z_t=pun;var mun={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})}},j_t=mun;var gun={styles:{container:()=>({flexGrow:1,minWidth:0}),completed:()=>({color:"magenta"}),remaining:()=>({dimColor:!0})},config:()=>({completedCharacter:Zt.square,remainingCharacter:Zt.squareLightShade})},Y_t=gun;var Aun={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})}},V_t=Aun;var hun={styles:{container:()=>({gap:1}),frame:()=>({color:"blue"}),label:()=>({})}},W_t=hun;var Eun={success:"green",error:"red",warning:"yellow",info:"blue"},_un={success:Zt.tick,error:Zt.cross,warning:Zt.warning,info:Zt.info},yun={styles:{container:()=>({gap:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:Eun[e]}),message:()=>({})},config:({variant:e})=>({icon:_un[e]})},K_t=yun;var bun={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})},config:()=>({marker:Zt.line})},J_t=bun;var Cun={styles:{value:()=>({})}},Z_t=Cun;var Sun={styles:{value:()=>({})}},X_t=Sun;var Iun={styles:{value:()=>({})}},eyt=Iun;var vun={components:{Alert:H_t,Badge:q_t,ConfirmInput:G_t,MultiSelect:z_t,OrderedList:j_t,ProgressBar:Y_t,Select:V_t,Spinner:W_t,StatusMessage:K_t,UnorderedList:J_t,TextInput:Z_t,EmailInput:X_t,PasswordInput:eyt}},xun=(0,N5.createContext)(vun);var oo=e=>(0,N5.useContext)(xun).components[e];var Dun=Re(it(),1);var V0=Re(it(),1);var C2=Re(it(),1);var tyt=Re(it(),1);var B5=Zt.line;var sX=(0,tyt.createContext)({marker:B5});function ryt({children:e}){let{marker:t}=(0,C2.useContext)(sX),{styles:r}=oo("UnorderedList");return C2.default.createElement(B,{...r.listItem()},C2.default.createElement(x,{...r.marker()},t),C2.default.createElement(B,{...r.content()},e))}var nyt=Re(it(),1),HTe=(0,nyt.createContext)({depth:0});function Run({children:e}){let{depth:t}=(0,V0.useContext)(HTe),{styles:r,config:n}=oo("UnorderedList"),i=(0,V0.useMemo)(()=>({depth:t+1}),[t]),o=(0,V0.useMemo)(()=>{let{marker:s}=n();return typeof s=="string"?{marker:s}:Array.isArray(s)?{marker:s[t]??s.at(-1)??B5}:{marker:B5}},[n,t]);return V0.default.createElement(HTe.Provider,{value:i},V0.default.createElement(sX.Provider,{value:o},V0.default.createElement(B,{...r.list()},e)))}Run.Item=ryt;var Bun=Re(it(),1);var Nun=Re(it(),1);var O5=Re(it(),1);var S2=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 iyt=Re(it(),1);var I2=Re(it(),1);var k5=Re(it(),1);function oyt({isFocused:e,isSelected:t,children:r}){let{styles:n}=oo("Select");return k5.default.createElement(B,{...n.option({isFocused:e})},e&&k5.default.createElement(x,{...n.focusIndicator()},Zt.pointer),k5.default.createElement(x,{...n.label({isFocused:e,isSelected:t})},r),t&&k5.default.createElement(x,{...n.selectedIndicator()},Zt.tick))}var Zp=Re(it(),1);import{isDeepStrictEqual as Oun}from"node:util";var kun=(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}},syt=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=typeof e=="number"?Math.min(e,r.length):r.length,i=new S2(r);return{optionMap:i,visibleOptionCount:n,focusedValue:i.first?.value,visibleFromIndex:0,visibleToIndex:n,previousValue:t,value:t}},ayt=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n})=>{let[i,o]=(0,Zp.useReducer)(kun,{visibleOptionCount:e,defaultValue:r,options:t},syt),[s,a]=(0,Zp.useState)(t);t!==s&&!Oun(t,s)&&(o({type:"reset",state:syt({visibleOptionCount:e,defaultValue:r,options:t})}),a(t));let l=(0,Zp.useCallback)(()=>{o({type:"focus-next-option"})},[]),c=(0,Zp.useCallback)(()=>{o({type:"focus-previous-option"})},[]),u=(0,Zp.useCallback)(()=>{o({type:"select-focused-option"})},[]),d=(0,Zp.useMemo)(()=>t.map((g,m)=>({...g,index:m})).slice(i.visibleFromIndex,i.visibleToIndex),[t,i.visibleFromIndex,i.visibleToIndex]);return(0,Zp.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 lyt=({isDisabled:e=!1,state:t})=>{or((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};function T2({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:i,onChange:o}){let s=ayt({visibleOptionCount:t,options:n,defaultValue:i,onChange:o});lyt({isDisabled:e,state:s});let{styles:a}=oo("Select");return I2.default.createElement(B,{...a.container()},s.visibleOptions.map(l=>{let c=l.label;if(r&&l.label.includes(r)){let u=l.label.indexOf(r);c=I2.default.createElement(I2.default.Fragment,null,l.label.slice(0,u),I2.default.createElement(x,{...a.highlightedText()},r),l.label.slice(u+r.length))}return I2.default.createElement(oyt,{key:l.value,isFocused:!e&&s.focusedValue===l.value,isSelected:s.value===l.value},c)}))}var Mun=Re(it(),1);var cyt=Re(it(),1);var Pun=Re(it(),1);var aX=Re(it(),1);var Qun=Re(it(),1);var aki=Jt.inverse(" ");var Eg=Re(it(),1);var v2=Re(it(),1);var uyt=Re(it(),1);var lX=(0,uyt.createContext)({marker:Zt.line});function cX({children:e}){let{marker:t}=(0,v2.useContext)(lX),{styles:r}=oo("OrderedList");return v2.default.createElement(B,{...r.listItem()},v2.default.createElement(x,{...r.marker()},t),v2.default.createElement(B,{...r.content()},e))}var dyt=Re(it(),1),qTe=(0,dyt.createContext)({marker:""});function _g({children:e}){let{marker:t}=(0,Eg.useContext)(qTe),{styles:r}=oo("OrderedList"),n=0;for(let o of Eg.default.Children.toArray(e))!(0,Eg.isValidElement)(o)||o.type!==cX||n++;let i=String(n).length;return Eg.default.createElement(B,{...r.list()},Eg.default.Children.map(e,(o,s)=>{if(!(0,Eg.isValidElement)(o)||o.type!==cX)return o;let a=`${String(s+1).padStart(i)}.`,l=`${t}${a}`;return Eg.default.createElement(qTe.Provider,{value:{marker:l}},Eg.default.createElement(lX.Provider,{value:{marker:l}},o))}))}_g.Item=cX;var Fun=Re(it(),1);var GTe=Re(it(),1);var Lun=Re(it(),1);var Qki=Jt.inverse(" ");var Uun=Re(it(),1);var $un=Re(it(),1);var qun=Re(it(),1);var uX=Re(it(),1);var Hun=Re(it(),1);var sMi=Jt.inverse(" ");var R2=Re(it(),1);var zTe=Re(it(),1);YU();ps();Ci();iv();Wt();var Gun=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function DC(){let e=Gun,{frame:t}=OD({interval:120});return(0,_.jsx)(B,{flexWrap:"nowrap",height:1,width:2,children:(0,_.jsx)(x,{color:Me().claude,children:e[t%e.length]})})}var pX=Re(it(),1);var Ev=null,W0=null,fX=new Set,dX=null;function YTe(e){let{columns:t,rows:r}=e;return t&&r?{columns:t,rows:r}:(dX||(dX=xfe()),{columns:t||dX.columns||80,rows:r||dX.rows||24})}function jTe(){if(!W0)return;let e=YTe(W0);Ev&&e.columns===Ev.columns&&e.rows===Ev.rows||(Ev=e,fX.forEach(t=>t(Ev)))}function zun(e,t){return W0!==e&&(W0&&W0.off("resize",jTe),W0=e,Ev=YTe(e),e.on("resize",jTe)),fX.add(t),()=>{fX.delete(t),fX.size===0&&W0&&(W0.off("resize",jTe),W0=null,Ev=null)}}function VTe(){let{stdout:e}=Uy(),[t,r]=(0,pX.useState)(()=>YTe(e));return(0,pX.useEffect)(()=>zun(e,r),[e]),t}function mX(){return VTe()}He();Xd();Oe();RA();Oe();var KQi=Re(Xbt(),1);import{homedir as q5}from"os";import{join as D2}from"path";import{existsSync as G5,mkdirSync as tCt,appendFileSync as eCt,readFileSync as rCt,constants as Hpn,writeFileSync as qpn,unlinkSync as nCt,statSync as Gpn}from"fs";import{platform as iCt}from"process";import{accessSync as zpn}from"fs";var $pn="2.7.18",H5={VERSION:$pn,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"};He();var yv=D2(s0,".update.lock"),jpn=300*1e3;function oCt(){try{if(G5(s0)||tCt(s0,{recursive:!0}),G5(yv)){let e=Gpn(yv);if(Date.now()-e.mtimeMs<jpn)return!1;try{nCt(yv)}catch(r){return ve(`Failed to remove stale lock file: ${r}`),!1}}return qpn(yv,`${process.pid}`,"utf8"),!0}catch(e){return ve(`Failed to acquire lock: ${e}`),!1}}function sCt(){try{G5(yv)&&rCt(yv,"utf8")===`${process.pid}`&&nCt(yv)}catch(e){ve(`Failed to release lock: ${e}`)}}async function gve(){try{let e=await Wn("npm -g config get prefix");if(e.code!==0)return ve("Failed to check npm permissions"),{hasPermissions:!1,npmPrefix:null};let t=e.stdout.trim(),r=!1;try{zpn(t,Hpn.W_OK),r=!0}catch{r=!1}return r?{hasPermissions:!0,npmPrefix:t}:(ve("Insufficient permissions for global npm install."),{hasPermissions:!1,npmPrefix:t})}catch(e){return ve(`Failed to verify npm global install permissions: ${e}`),{hasPermissions:!1,npmPrefix:null}}}async function aCt(e){if(!oCt())throw Nt("tengu_auto_updater_prefix_lock_contention",{pid:String(process.pid),currentVersion:H5.VERSION,prefix:e}),new Error("Another process is currently setting up npm prefix");try{G5(e)||tCt(e,{recursive:!0});let t=await Wn(`npm -g config set prefix ${e}`);if(t.code!==0)throw new Error(`Failed to set npm prefix: ${t.stderr}`);let r=`
1020
1020
  # npm global path
1021
1021
  export PATH="${e}/bin:$PATH"
1022
1022
  `;if(iCt==="win32"){let n=await Wn(`setx PATH "${process.env.PATH};${e}"`);if(n.code!==0)throw new Error(`Failed to update PATH on Windows: ${n.stderr}`)}else{let n=[D2(q5(),".bashrc"),D2(q5(),".bash_profile"),D2(q5(),".zshrc"),D2(q5(),".config","fish","config.fish")];for(let i of n)if(G5(i))try{if(!rCt(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.17",
3
+ "version": "2.7.18",
4
4
  "bin": {
5
5
  "hcode": "hawa.js"
6
6
  },