@dahawa/hawa-code 2.0.2 → 2.0.3

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 (4) hide show
  1. package/cli.js +517 -514
  2. package/hands.js +4 -4
  3. package/package.json +1 -1
  4. package/webServer/app.js +21 -21
package/hands.js CHANGED
@@ -566,7 +566,7 @@ data:
566
566
  Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`):new Error(`Raw mode is not supported on the stdin provided to Ink.
567
567
  Read about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported`);if(t.setEncoding("utf8"),gt){if(w.current===0){let pr=O.current;O.current=!1,pr||(t.ref(),t.setRawMode(!0)),Re()}w.current++;return}w.current!==0&&--w.current===0&&(ce(),O.current=!0,queueMicrotask(()=>{O.current&&ve()}))},[Ee,t,Re,ce,ve]),Je=(0,Zt.useCallback)(gt=>{if(r.isTTY){if(gt){Q.current===0&&r.write("\x1B[?2004h"),Q.current++;return}Q.current!==0&&--Q.current===0&&r.write("\x1B[?2004l")}},[r]),Ge=(0,Zt.useCallback)((gt,pr)=>{let Yt=gt.findIndex(cn=>cn.id===pr);for(let cn=Yt+1;cn<gt.length;cn++){let dt=gt[cn];if(dt?.isActive)return dt.id}},[]),Ve=(0,Zt.useCallback)((gt,pr)=>{let Yt=gt.findIndex(cn=>cn.id===pr);for(let cn=Yt-1;cn>=0;cn--){let dt=gt[cn];if(dt?.isActive)return dt.id}},[]),St=(0,Zt.useCallback)(()=>{_(gt=>(E(pr=>{let Yt=gt.find(dt=>dt.isActive)?.id;return Ge(gt,pr)??Yt}),gt))},[Ge]),xr=(0,Zt.useCallback)(()=>{_(gt=>(E(pr=>{let Yt=gt.findLast(dt=>dt.isActive)?.id;return Ve(gt,pr)??Yt}),gt))},[Ve]);(0,Zt.useEffect)(()=>{let gt=Yt=>{!A||C.current===0||(Yt===tcr&&St(),Yt===rcr&&xr())};z.current.on("input",gt);let pr=z.current;return()=>{pr.off("input",gt)}},[A,St,xr]);let Zr=(0,Zt.useCallback)(()=>{m(!0)},[]),zo=(0,Zt.useCallback)(()=>{m(!1)},[]),hn=(0,Zt.useCallback)(gt=>{_(pr=>(pr.some(cn=>cn?.id===gt)&&E(gt),pr))},[]),ci=(0,Zt.useCallback)((gt,{autoFocus:pr})=>{_(Yt=>(C.current=Yt.length+1,[...Yt,{id:gt,isActive:!0}])),pr&&E(Yt=>Yt||gt)},[]),Yn=(0,Zt.useCallback)(gt=>{E(pr=>{if(pr!==gt)return pr}),_(pr=>{let Yt=pr.filter(cn=>cn.id!==gt);return C.current=Yt.length,Yt})},[]),Yo=(0,Zt.useCallback)(gt=>{_(pr=>pr.map(Yt=>Yt.id!==gt?Yt:{id:gt,isActive:!0}))},[]),jo=(0,Zt.useCallback)(gt=>{E(pr=>{if(pr!==gt)return pr}),_(pr=>pr.map(Yt=>Yt.id!==gt?Yt:{id:gt,isActive:!1}))},[]);(0,Zt.useEffect)(()=>()=>{let gt=!r.destroyed&&!r.writableEnded;u&&gt&&Fpe.show(r),Ee&&(w.current>0||O.current)&&ve(),Q.current>0&&(r.isTTY&&gt&&r.write("\x1B[?2004l"),Q.current=0)},[r,Ee,ve,u]);let hs=(0,Zt.useMemo)(()=>({exit:Se,waitUntilRenderFlush:l}),[Se,l]),Vo=(0,Zt.useMemo)(()=>({stdin:t,setRawMode:We,setBracketedPasteMode:Je,isRawModeSupported:Ee,internal_exitOnCtrlC:s,internal_eventEmitter:z.current}),[t,We,Je,Ee,s]),Ns=(0,Zt.useMemo)(()=>({stdout:r,write:i}),[r,i]),Mt=(0,Zt.useMemo)(()=>({stderr:n,write:o}),[n,o]),Hr=(0,Zt.useMemo)(()=>({setCursorPosition:c}),[c]),oo=(0,Zt.useMemo)(()=>({activeId:g,add:ci,remove:Yn,activate:Yo,deactivate:jo,enableFocus:Zr,disableFocus:zo,focusNext:St,focusPrevious:xr,focus:hn}),[g,ci,Yn,Yo,jo,Zr,zo,St,xr,hn]),nn=(0,Zt.useMemo)(()=>({renderThrottleMs:f,subscribe:fe}),[fe,f]);return Zt.default.createElement(Upe.Provider,{value:hs},Zt.default.createElement(cG.Provider,{value:Vo},Zt.default.createElement(uG.Provider,{value:Ns},Zt.default.createElement(Hpe.Provider,{value:Mt},Zt.default.createElement(dG.Provider,{value:oo},Zt.default.createElement(fG.Provider,{value:nn},Zt.default.createElement(qpe.Provider,{value:Hr},Zt.default.createElement(FL,{onError:Se},e))))))))}icr.displayName="InternalApp";var Rg={shift:1,alt:2,ctrl:4,super:8,hyper:16,meta:32,capsLock:64,numLock:128};var Xjn=new TextEncoder;var eVn=lcr.platform==="win32";var dcr=Z(Aq(),1);var JE=Z(me(),1);function gG(e){let{items:t,children:r,style:n}=e,[i,o]=(0,JE.useState)(0),s=(0,JE.useMemo)(()=>t.slice(i),[t,i]);(0,JE.useLayoutEffect)(()=>{o(t.length)},[t.length]);let a=s.map((c,u)=>r(c,i+u)),l=(0,JE.useMemo)(()=>({position:"absolute",flexDirection:"column",...n}),[n]);return JE.default.createElement("ink-box",{internal_static:!0,style:l},a)}var hG=Z(me(),1);function EG({children:e,transform:t,accessibilityLabel:r}){let{isScreenReaderEnabled:n}=(0,hG.useContext)(Yy);return e==null?null:hG.default.createElement("ink-text",{style:{flexGrow:0,flexShrink:1,flexDirection:"row"},internal_transform:t},n&&r?r:e)}var B$e=Z(me(),1);function Rc({count:e=1}){return B$e.default.createElement("ink-text",null,`
568
568
  `.repeat(e))}var fcr=Z(me(),1);var UL=Z(me(),1);var O$e=new TextDecoder,pcr=/^(?:\x1b)([a-zA-Z0-9])$/,mcr=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,M$e={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[P":"f1","[Q":"f2","[R":"f3","[S":"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"},Q$e=[...Object.values(M$e),"backspace"],Acr=e=>["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(e),gcr=e=>["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(e),L$e=/^\x1b\[(\d+)(?:;(\d+)(?::(\d+))?(?:;([\d:]+))?)?u$/,hcr=/^\x1b\[(\d+);(\d+):(\d+)([A-Za-z~])$/,Ecr={A:"up",B:"down",C:"right",D:"left",E:"clear",F:"end",H:"home",P:"f1",Q:"f2",R:"f3",S:"f4"},_cr={2:"insert",3:"delete",5:"pageup",6:"pagedown",7:"home",8:"end",11:"f1",12:"f2",13:"f3",14:"f4",15:"f5",17:"f6",18:"f7",19:"f8",20:"f9",21:"f10",23:"f11",24:"f12"},k$e={27:"escape",9:"tab",127:"backspace",8:"backspace",57358:"capslock",57359:"scrolllock",57360:"numlock",57361:"printscreen",57362:"pause",57363:"menu",57376:"f13",57377:"f14",57378:"f15",57379:"f16",57380:"f17",57381:"f18",57382:"f19",57383:"f20",57384:"f21",57385:"f22",57386:"f23",57387:"f24",57388:"f25",57389:"f26",57390:"f27",57391:"f28",57392:"f29",57393:"f30",57394:"f31",57395:"f32",57396:"f33",57397:"f34",57398:"f35",57399:"kp0",57400:"kp1",57401:"kp2",57402:"kp3",57403:"kp4",57404:"kp5",57405:"kp6",57406:"kp7",57407:"kp8",57408:"kp9",57409:"kpdecimal",57410:"kpdivide",57411:"kpmultiply",57412:"kpsubtract",57413:"kpadd",57414:"kpenter",57415:"kpequal",57416:"kpseparator",57417:"kpleft",57418:"kpright",57419:"kpup",57420:"kpdown",57421:"kppageup",57422:"kppagedown",57423:"kphome",57424:"kpend",57425:"kpinsert",57426:"kpdelete",57427:"kpbegin",57428:"mediaplay",57429:"mediapause",57430:"mediaplaypause",57431:"mediareverse",57432:"mediastop",57433:"mediafastforward",57434:"mediarewind",57435:"mediatracknext",57436:"mediatrackprevious",57437:"mediarecord",57438:"lowervolume",57439:"raisevolume",57440:"mutevolume",57441:"leftshift",57442:"leftcontrol",57443:"leftalt",57444:"leftsuper",57445:"lefthyper",57446:"leftmeta",57447:"rightshift",57448:"rightcontrol",57449:"rightalt",57450:"rightsuper",57451:"righthyper",57452:"rightmeta",57453:"isoLevel3Shift",57454:"isoLevel5Shift"},P$e=e=>e>=0&&e<=1114111&&!(e>=55296&&e<=57343),jpe=e=>P$e(e)?String.fromCodePoint(e):"?";function F$e(e){return e===3?"release":e===2?"repeat":"press"}function U$e(e){return{ctrl:!!(e&Rg.ctrl),shift:!!(e&Rg.shift),meta:!!(e&(Rg.meta|Rg.alt)),super:!!(e&Rg.super),hyper:!!(e&Rg.hyper),capsLock:!!(e&Rg.capsLock),numLock:!!(e&Rg.numLock)}}var ycr=e=>{let t=L$e.exec(e);if(!t)return null;let r=parseInt(t[1],10),n=t[2]?Math.max(0,parseInt(t[2],10)-1):0,i=t[3]?parseInt(t[3],10):1,o=t[4];if(!P$e(r))return null;let s;o&&(s=o.split(":").map(c=>jpe(parseInt(c,10))).join(""));let a,l;return r===32?(a="space",l=!0):r===13?(a="return",l=!0):k$e[r]?(a=k$e[r],l=!1):r>=1&&r<=26?(a=String.fromCodePoint(r+96),l=!1):(a=jpe(r).toLowerCase(),l=!0),l&&!s&&(s=jpe(r)),{name:a,...U$e(n),eventType:F$e(i),sequence:e,raw:e,isKittyProtocol:!0,isPrintable:l,text:s}},bcr=e=>{let t=hcr.exec(e);if(!t)return null;let r=parseInt(t[1],10),n=Math.max(0,parseInt(t[2],10)-1),i=parseInt(t[3],10),o=t[4],s=o==="~"?_cr[r]:Ecr[o];return s?{name:s,...U$e(n),eventType:F$e(i),sequence:e,raw:e,isKittyProtocol:!0,isPrintable:!1}:null},Ccr=(e="")=>{let t;e instanceof Uint8Array?e[0]>127&&e[1]===void 0?(e[0]-=128,e="\x1B"+O$e.decode(e)):e=O$e.decode(e):e!==void 0&&typeof e!="string"?e=String(e):e||(e="");let r=ycr(e);if(r)return r;let n=bcr(e);if(n)return n;if(L$e.test(e))return{name:"",ctrl:!1,meta:!1,shift:!1,sequence:e,raw:e,isKittyProtocol:!0,isPrintable:!1};let i={name:"",ctrl:!1,meta:!1,shift:!1,sequence:e,raw:e};if(i.sequence=i.sequence||e||i.name,e==="\r"||e==="\x1B\r")i.raw=void 0,i.name="return",i.meta=e.length===2;else if(e===`
569
- `)i.name="enter";else if(e===" ")i.name="tab";else if(e==="\b"||e==="\x1B\b")i.name="backspace",i.meta=e.charAt(0)==="\x1B";else if(e==="\x7F"||e==="\x1B\x7F")i.name="backspace",i.meta=e.charAt(0)==="\x1B";else if(e==="\x1B"||e==="\x1B\x1B")i.name="escape",i.meta=e.length===2;else if(e===" "||e==="\x1B ")i.name="space",i.meta=e.length===2;else if(e.length===1&&e<="")i.name=String.fromCharCode(e.charCodeAt(0)+97-1),i.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")i.name="number";else if(e.length===1&&e>="a"&&e<="z")i.name=e;else if(e.length===1&&e>="A"&&e<="Z")i.name=e.toLowerCase(),i.shift=!0;else if(t=pcr.exec(e))i.name=t[1].toLowerCase(),i.meta=!0,i.shift=/^[A-Z]$/.test(t[1]);else if(t=mcr.exec(e)){let o=[...e];o[0]==="\x1B"&&o[1]==="\x1B"&&(i.meta=!0);let s=[t[1],t[2],t[4],t[6]].filter(Boolean).join(""),a=(t[3]||t[5]||1)-1;i.ctrl=!!(a&4),i.meta=i.meta||!!(a&10),i.shift=!!(a&1),i.code=s,i.name=M$e[s]??"",i.shift=Acr(s)||i.shift,i.ctrl=gcr(s)||i.ctrl}return i},H$e=Ccr;var q$e=Z(me(),1);var _G=()=>(0,q$e.useContext)(cG);var Scr=(e,t={})=>{let{setRawMode:r,internal_exitOnCtrlC:n,internal_eventEmitter:i}=_G();(0,UL.useEffect)(()=>{if(t.isActive!==!1)return r(!0),()=>{r(!1)}},[t.isActive,r]);let o=(0,UL.useEffectEvent)(s=>{let a=H$e(s),l={upArrow:a.name==="up",downArrow:a.name==="down",leftArrow:a.name==="left",rightArrow:a.name==="right",pageDown:a.name==="pagedown",pageUp:a.name==="pageup",home:a.name==="home",end:a.name==="end",return:a.name==="return",escape:a.name==="escape",ctrl:a.ctrl,shift:a.shift,tab:a.name==="tab",backspace:a.name==="backspace",delete:a.name==="delete",meta:a.meta,super:a.super??!1,hyper:a.hyper??!1,capsLock:a.capsLock??!1,numLock:a.numLock??!1,eventType:a.eventType},c;a.isKittyProtocol?a.isPrintable?c=a.text??a.name:a.ctrl&&a.name.length===1?c=a.name:c="":a.ctrl?c=a.name??"":c=a.sequence,!a.isKittyProtocol&&Q$e.includes(a.name)&&(c=""),c.startsWith("\x1B")&&(c=c.slice(1)),c.length===1&&/[A-Z]/.test(c)&&(l.shift=!0),!(c==="c"&&l.ctrl&&n)&&MD.discreteUpdates(()=>{e(c,l)})});(0,UL.useEffect)(()=>{if(t.isActive!==!1)return i.on("input",o),()=>{i.removeListener("input",o)}},[t.isActive,i])},Nr=Scr;var HL=Z(me(),1);var Icr=(e,t={})=>{let{setRawMode:r,setBracketedPasteMode:n,internal_eventEmitter:i}=_G();(0,HL.useEffect)(()=>{if(t.isActive!==!1)return r(!0),n(!0),()=>{r(!1),n(!1)}},[t.isActive,r,n]);let o=(0,HL.useEffectEvent)(s=>{MD.discreteUpdates(()=>{e(s)})});(0,HL.useEffect)(()=>{if(t.isActive!==!1)return i.on("paste",o),()=>{i.removeListener("paste",o)}},[t.isActive,i])},Vpe=Icr;var Tcr=Z(me(),1);var G$e=Z(me(),1);var vcr=()=>(0,G$e.useContext)(uG),qD=vcr;var xcr=Z(me(),1);var Wpe=Z(me(),1);var Dcr=Z(me(),1);var Rcr=Z(me(),1);var yG=Z(me(),1);var ld=Z(me(),1);var $$e=100,Ncr=2147483647,Kpe={frame:0,time:0,delta:0};function GD(e){let{interval:t=$$e,isActive:r=!0}=e??{},n=Bcr(t),{subscribe:i,renderThrottleMs:o}=(0,ld.useContext)(fG),[s,a]=(0,ld.useState)(0),[l,c]=(0,ld.useState)(Kpe),u=(0,ld.useRef)(0),f=(0,ld.useRef)(0),A=(0,ld.useRef)({isActive:r,safeInterval:n,resetKey:s}),m=A.current,g=r&&(n!==m.safeInterval||!m.isActive||s!==m.resetKey),E=(0,ld.useCallback)(()=>{a(_=>_+1)},[]);return(0,ld.useLayoutEffect)(()=>{if(!r)return;c(Kpe);let _=0,{startTime:C,unsubscribe:S}=i(T=>{if(o>0&&T<u.current)return;let O=T-_,Q=T-f.current;f.current=T,u.current=T+o,c({frame:Math.floor(O/n),time:O,delta:Q})},n);return _=C,f.current=C,u.current=_+o,S},[n,r,i,o,s]),(0,ld.useLayoutEffect)(()=>{A.current={isActive:r,safeInterval:n,resetKey:s}},[r,n,s]),g?{...Kpe,reset:E}:{...l,reset:E}}function Bcr(e){return Number.isFinite(e)?Math.min(Ncr,Math.max(1,e)):$$e}var z$e=Z(me(),1);var bG=Z(me(),1);jr();er();var iEe=Z(me(),1);er();import{existsSync as rEe,readFileSync as nEe,writeFileSync as hMr}from"fs";import{resolve as pet,join as det}from"path";import{homedir as EMr}from"os";er();import{join as Oj}from"path";import{homedir as dMr}from"os";import{cwd as fMr}from"process";Fe();hr();JI();vN();async function oi(e,t="",r={}){return pt.isPowerShellToolEnable()?await Op.runPowerShellCommand(e,t,r):await pl.runCommandConcurrent(e,t,r)}hr();var XI=process.env.CLAUDE_CONFIG_DIR??Oj(dMr(),Xr),Vg=process.env.CLAUDE_CONFIG_DIR?Oj(XI,"config.json"):Oj(XI,`${Ki}.json`),Vdi=Oj(XI,"memory");var WXe=Le(async()=>{if(process.platform!=="linux")return!1;let{code:e}=await oi("test -f /.dockerenv");return e===0}),KXe=Le(async()=>{try{let e=new AbortController,t=setTimeout(()=>e.abort(),1e3);return await fetch("http://1.1.1.1",{method:"HEAD",signal:e.signal}),clearTimeout(t),!0}catch{return!1}}),JXe=Le(()=>fMr()),ZXe=Le(async()=>{let{code:e}=await oi("git rev-parse --git-dir");return e===0}),XXe=Le(async()=>{let{stdout:e,code:t}=await oi("git rev-parse --show-toplevel");return t===0?e.trim():null}),eet=Le(async()=>{let{stdout:e,code:t}=await oi("git rev-parse --abbrev-ref HEAD");return t===0?e.trim():null}),tet=Le(async()=>{let e=process.platform;try{if(e==="win32"){let t=pt.isPowerShellToolEnable()?'Get-CimInstance Win32_OperatingSystem | ForEach-Object { "$($_.Caption) $($_.Version)" }':"wmic os get Caption,Version /format:list",{stdout:r,code:n}=await oi(t);if(n!==0)return"Windows";if(pt.isPowerShellToolEnable())return r.trim()||"Windows";let i=r.split(`
569
+ `)i.name="enter";else if(e===" ")i.name="tab";else if(e==="\b"||e==="\x1B\b")i.name="backspace",i.meta=e.charAt(0)==="\x1B";else if(e==="\x7F"||e==="\x1B\x7F")i.name="backspace",i.meta=e.charAt(0)==="\x1B";else if(e==="\x1B"||e==="\x1B\x1B")i.name="escape",i.meta=e.length===2;else if(e===" "||e==="\x1B ")i.name="space",i.meta=e.length===2;else if(e.length===1&&e<="")i.name=String.fromCharCode(e.charCodeAt(0)+97-1),i.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")i.name="number";else if(e.length===1&&e>="a"&&e<="z")i.name=e;else if(e.length===1&&e>="A"&&e<="Z")i.name=e.toLowerCase(),i.shift=!0;else if(t=pcr.exec(e))i.name=t[1].toLowerCase(),i.meta=!0,i.shift=/^[A-Z]$/.test(t[1]);else if(t=mcr.exec(e)){let o=[...e];o[0]==="\x1B"&&o[1]==="\x1B"&&(i.meta=!0);let s=[t[1],t[2],t[4],t[6]].filter(Boolean).join(""),a=(t[3]||t[5]||1)-1;i.ctrl=!!(a&4),i.meta=i.meta||!!(a&10),i.shift=!!(a&1),i.code=s,i.name=M$e[s]??"",i.shift=Acr(s)||i.shift,i.ctrl=gcr(s)||i.ctrl}return i},H$e=Ccr;var q$e=Z(me(),1);var _G=()=>(0,q$e.useContext)(cG);var Scr=(e,t={})=>{let{setRawMode:r,internal_exitOnCtrlC:n,internal_eventEmitter:i}=_G();(0,UL.useEffect)(()=>{if(t.isActive!==!1)return r(!0),()=>{r(!1)}},[t.isActive,r]);let o=(0,UL.useEffectEvent)(s=>{let a=H$e(s),l={upArrow:a.name==="up",downArrow:a.name==="down",leftArrow:a.name==="left",rightArrow:a.name==="right",pageDown:a.name==="pagedown",pageUp:a.name==="pageup",home:a.name==="home",end:a.name==="end",return:a.name==="return",escape:a.name==="escape",ctrl:a.ctrl,shift:a.shift,tab:a.name==="tab",backspace:a.name==="backspace",delete:a.name==="delete",meta:a.meta,super:a.super??!1,hyper:a.hyper??!1,capsLock:a.capsLock??!1,numLock:a.numLock??!1,eventType:a.eventType},c;a.isKittyProtocol?a.isPrintable?c=a.text??a.name:a.ctrl&&a.name.length===1?c=a.name:c="":a.ctrl?c=a.name??"":c=a.sequence,!a.isKittyProtocol&&Q$e.includes(a.name)&&(c=""),c.startsWith("\x1B")&&(c=c.slice(1)),c.length===1&&/[A-Z]/.test(c)&&(l.shift=!0),!(c==="c"&&l.ctrl&&n)&&MD.discreteUpdates(()=>{e(c,l)})});(0,UL.useEffect)(()=>{if(t.isActive!==!1)return i.on("input",o),()=>{i.removeListener("input",o)}},[t.isActive,i])},Nr=Scr;var HL=Z(me(),1);var Icr=(e,t={})=>{let{setRawMode:r,setBracketedPasteMode:n,internal_eventEmitter:i}=_G();(0,HL.useEffect)(()=>{if(t.isActive!==!1)return r(!0),n(!0),()=>{r(!1),n(!1)}},[t.isActive,r,n]);let o=(0,HL.useEffectEvent)(s=>{MD.discreteUpdates(()=>{e(s)})});(0,HL.useEffect)(()=>{if(t.isActive!==!1)return i.on("paste",o),()=>{i.removeListener("paste",o)}},[t.isActive,i])},Vpe=Icr;var Tcr=Z(me(),1);var G$e=Z(me(),1);var vcr=()=>(0,G$e.useContext)(uG),qD=vcr;var xcr=Z(me(),1);var Wpe=Z(me(),1);var Dcr=Z(me(),1);var Rcr=Z(me(),1);var yG=Z(me(),1);var ld=Z(me(),1);var $$e=100,Ncr=2147483647,Kpe={frame:0,time:0,delta:0};function GD(e){let{interval:t=$$e,isActive:r=!0}=e??{},n=Bcr(t),{subscribe:i,renderThrottleMs:o}=(0,ld.useContext)(fG),[s,a]=(0,ld.useState)(0),[l,c]=(0,ld.useState)(Kpe),u=(0,ld.useRef)(0),f=(0,ld.useRef)(0),A=(0,ld.useRef)({isActive:r,safeInterval:n,resetKey:s}),m=A.current,g=r&&(n!==m.safeInterval||!m.isActive||s!==m.resetKey),E=(0,ld.useCallback)(()=>{a(_=>_+1)},[]);return(0,ld.useLayoutEffect)(()=>{if(!r)return;c(Kpe);let _=0,{startTime:C,unsubscribe:S}=i(T=>{if(o>0&&T<u.current)return;let O=T-_,Q=T-f.current;f.current=T,u.current=T+o,c({frame:Math.floor(O/n),time:O,delta:Q})},n);return _=C,f.current=C,u.current=_+o,S},[n,r,i,o,s]),(0,ld.useLayoutEffect)(()=>{A.current={isActive:r,safeInterval:n,resetKey:s}},[r,n,s]),g?{...Kpe,reset:E}:{...l,reset:E}}function Bcr(e){return Number.isFinite(e)?Math.min(Ncr,Math.max(1,e)):$$e}var z$e=Z(me(),1);var bG=Z(me(),1);jr();er();var iEe=Z(me(),1);er();import{existsSync as rEe,readFileSync as nEe,writeFileSync as hMr}from"fs";import{resolve as pet,join as det}from"path";import{homedir as EMr}from"os";er();import{join as Oj}from"path";import{homedir as dMr}from"os";import{cwd as fMr}from"process";Fe();hr();JI();vN();async function oi(e,t="",r={}){return pt.isPowerShellToolEnable()?await Op.runPowerShellCommand(e,t,r):await pl.runCommandConcurrent(e,t,r)}hr();var XI=process.env.HCODE_CONFIG_DIR??Oj(dMr(),Xr),Vg=process.env.HCODE_CONFIG_DIR?Oj(XI,"config.json"):Oj(XI,`${Ki}.json`),Vdi=Oj(XI,"memory");var WXe=Le(async()=>{if(process.platform!=="linux")return!1;let{code:e}=await oi("test -f /.dockerenv");return e===0}),KXe=Le(async()=>{try{let e=new AbortController,t=setTimeout(()=>e.abort(),1e3);return await fetch("http://1.1.1.1",{method:"HEAD",signal:e.signal}),clearTimeout(t),!0}catch{return!1}}),JXe=Le(()=>fMr()),ZXe=Le(async()=>{let{code:e}=await oi("git rev-parse --git-dir");return e===0}),XXe=Le(async()=>{let{stdout:e,code:t}=await oi("git rev-parse --show-toplevel");return t===0?e.trim():null}),eet=Le(async()=>{let{stdout:e,code:t}=await oi("git rev-parse --abbrev-ref HEAD");return t===0?e.trim():null}),tet=Le(async()=>{let e=process.platform;try{if(e==="win32"){let t=pt.isPowerShellToolEnable()?'Get-CimInstance Win32_OperatingSystem | ForEach-Object { "$($_.Caption) $($_.Version)" }':"wmic os get Caption,Version /format:list",{stdout:r,code:n}=await oi(t);if(n!==0)return"Windows";if(pt.isPowerShellToolEnable())return r.trim()||"Windows";let i=r.split(`
570
570
  `).filter(a=>a.trim()),o=i.find(a=>a.startsWith("Caption="))?.split("=")[1]?.trim(),s=i.find(a=>a.startsWith("Version="))?.split("=")[1]?.trim();return o&&s?`${o} ${s}`:"Windows"}else if(e==="darwin"){let{stdout:t,code:r}=await oi("sw_vers -productVersion");return r===0?`macOS ${t.trim()}`:"macOS"}else{let{stdout:t,code:r}=await oi("lsb_release -d -s");return r===0&&t.trim()||"Linux"}}catch{return e==="win32"?"Windows":e==="darwin"?"macOS":"Linux"}}),ret=Le(()=>new Date().toISOString().split("T")[0]),Wdi=Le(async()=>{let[e,t,r,n,i,o,s,a,l]=await Promise.all([JXe(),ZXe(),XXe(),eet(),tet(),ret(),WXe(),KXe(),ml.isCI]),c=[`Working directory: ${e}`,`Is directory a git repo: ${t?"Yes":"No"}`,`Platform: ${process.platform}`,`OS Version: ${i}`,`Today's date: ${o}`,`Node version: ${ml.nodeVersion}`,`Terminal: ${ml.terminal||"Unknown"}`,`Is Docker: ${s?"Yes":"No"}`,`Has internet access: ${a?"Yes":"No"}`,`Is CI: ${l?"Yes":"No"}`];return t&&r&&c.push(`Git repo root: ${r}`),t&&n&&c.push(`Current branch: ${n}`),`<env>
571
571
  ${c.join(`
572
572
  `)}
@@ -577,7 +577,7 @@ ${c.join(`
577
577
  `,r:"\r",t:" "};function oa(e){let t=0,r="";c(["```","[```","{```"]),o()||k(),c(["```","```]","```}"]);let i=f(",");for(i&&s(),Jhe(e[t])&&uet(r)?(i||(r=kp(r,",")),C()):i&&(r=xN(r,","));e[t]==="}"||e[t]==="]";)t++,s();if(t>=e.length)return r;pe();function o(){s();let ce=E()||_()||S()||w()||O()||z(!1)||V();return s(),ce}function s(){let ce=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,ve=t,Se=a(ce);do Se=l(),Se&&(Se=a(ce));while(Se);return t>ve}function a(ce){let ve=ce?qb:set,Se="";for(;;)if(ve(e,t))Se+=e[t],t++;else if(aet(e,t))Se+=" ",t++;else break;return Se.length>0?(r+=Se,!0):!1}function l(){if(e[t]==="/"&&e[t+1]==="*"){for(;t<e.length&&!gMr(e,t);)t++;return t+=2,!0}if(e[t]==="/"&&e[t+1]==="/"){for(;t<e.length&&e[t]!==`
578
578
  `;)t++;return!0}return!1}function c(ce){if(u(ce)){if(Yhe(e[t]))for(;t<e.length&&jhe(e[t]);)t++;return s(),!0}return!1}function u(ce){a(!0);for(let ve of ce){let Se=t+ve.length;if(e.slice(t,Se)===ve)return t=Se,!0}return!1}function f(ce){return e[t]===ce?(r+=e[t],t++,!0):!1}function A(ce){return e[t]===ce?(t++,!0):!1}function m(){return A("\\")}function g(){return s(),e[t]==="."&&e[t+1]==="."&&e[t+2]==="."?(t+=3,s(),A(","),!0):!1}function E(){if(e[t]==="{"){r+="{",t++,s(),A(",")&&s();let ce=!0;for(;t<e.length&&e[t]!=="}";){let ve;if(ce?(ve=!0,ce=!1):(ve=f(","),ve||(r=kp(r,",")),s()),g(),!(S()||z(!0))){e[t]==="}"||e[t]==="{"||e[t]==="]"||e[t]==="["||e[t]===void 0?r=xN(r,","):fe();break}s();let _e=f(":"),De=t>=e.length;_e||(Jhe(e[t])||De?r=kp(r,":"):Ee()),o()||(_e||De?r+="null":Ee())}return e[t]==="}"?(r+="}",t++):r=kp(r,"}"),!0}return!1}function _(){if(e[t]==="["){r+="[",t++,s(),A(",")&&s();let ce=!0;for(;t<e.length&&e[t]!=="]";)if(ce?ce=!1:f(",")||(r=kp(r,",")),g(),!o()){r=xN(r,",");break}return e[t]==="]"?(r+="]",t++):r=kp(r,"]"),!0}return!1}function C(){let ce=!0,ve=!0;for(;ve;)ce?ce=!1:f(",")||(r=kp(r,",")),ve=o();ve||(r=xN(r,",")),r=`[
579
579
  ${r}
580
- ]`}function S(){let ce=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,ve=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,Se=e[t]==="\\";if(Se&&(t++,Se=!0),OP(e[t])){let _e=Xhe(e[t])?Xhe:eEe(e[t])?eEe:kj(e[t])?kj:Zhe,De=t,K=r.length,Y='"';for(t++;;){if(t>=e.length){let Re=M(t-1);return!ce&&BP(e.charAt(Re))?(t=De,r=r.substring(0,K),S(!0)):(Y=kp(Y,'"'),r+=Y,!0)}if(t===ve)return Y=kp(Y,'"'),r+=Y,!0;if(_e(e[t])){let Re=t,We=Y.length;if(Y+='"',t++,r+=Y,s(!1),ce||t>=e.length||BP(e[t])||OP(e[t])||Gb(e[t]))return T(),!0;let Je=M(Re-1),Ge=e.charAt(Je);if(Ge===",")return t=De,r=r.substring(0,K),S(!1,Je);if(BP(Ge))return t=De,r=r.substring(0,K),S(!0);r=r.substring(0,K),t=Re+1,Y=`${Y.substring(0,We)}\\${Y.substring(We)}`}else if(ce&&Khe(e[t])){if(e[t-1]===":"&&Vhe.test(e.substring(De+1,t+2)))for(;t<e.length&&Whe.test(e[t]);)Y+=e[t],t++;return Y=kp(Y,'"'),r+=Y,T(),!0}else if(e[t]==="\\"){let Re=e.charAt(t+1);if(AMr[Re]!==void 0)Y+=e.slice(t,t+2),t+=2;else if(Re==="u"){let Je=2;for(;Je<6&&net(e[t+Je]);)Je++;Je===6?(Y+=e.slice(t,t+6),t+=6):t+Je>=e.length?t=e.length:xe()}else Y+=Re,t+=2}else{let Re=e.charAt(t);Re==='"'&&e[t-1]!=="\\"?(Y+=`\\${Re}`,t++):oet(Re)?(Y+=mMr[Re],t++):(iet(Re)||le(Re),Y+=Re,t++)}Se&&m()}}return!1}function T(){let ce=!1;for(s();e[t]==="+";){ce=!0,t++,s(),r=xN(r,'"',!0);let ve=r.length;S()?r=cet(r,ve,1):r=kp(r,'"')}return ce}function w(){let ce=t;if(e[t]==="-"){if(t++,G())return H(ce),!0;if(!Gb(e[t]))return t=ce,!1}for(;Gb(e[t]);)t++;if(e[t]==="."){if(t++,G())return H(ce),!0;if(!Gb(e[t]))return t=ce,!1;for(;Gb(e[t]);)t++}if(e[t]==="e"||e[t]==="E"){if(t++,(e[t]==="-"||e[t]==="+")&&t++,G())return H(ce),!0;if(!Gb(e[t]))return t=ce,!1;for(;Gb(e[t]);)t++}if(!G())return t=ce,!1;if(t>ce){let ve=e.slice(ce,t),Se=/^0\d/.test(ve);return r+=Se?`"${ve}"`:ve,!0}return!1}function O(){return Q("true","true")||Q("false","false")||Q("null","null")||Q("True","true")||Q("False","false")||Q("None","null")}function Q(ce,ve){return e.slice(t,t+ce.length)===ce?(r+=ve,t+=ce.length,!0):!1}function z(ce){let ve=t;if(Yhe(e[t])){for(;t<e.length&&jhe(e[t]);)t++;let Se=t;for(;qb(e,Se);)Se++;if(e[Se]==="(")return t=Se+1,o(),e[t]===")"&&(t++,e[t]===";"&&t++),!0}for(;t<e.length&&!Khe(e[t])&&!OP(e[t])&&(!ce||e[t]!==":");)t++;if(e[t-1]===":"&&Vhe.test(e.substring(ve,t+2)))for(;t<e.length&&Whe.test(e[t]);)t++;if(t>ve){for(;qb(e,t-1)&&t>0;)t--;let Se=e.slice(ve,t);return r+=Se==="undefined"?"null":JSON.stringify(Se),e[t]==='"'&&t++,!0}}function V(){if(e[t]==="/"){let ce=t;for(t++;t<e.length&&(e[t]!=="/"||e[t-1]==="\\");)t++;return t++,r+=JSON.stringify(e.substring(ce,t)),!0}}function M(ce){let ve=ce;for(;ve>0&&qb(e,ve);)ve--;return ve}function G(){return t>=e.length||BP(e[t])||qb(e,t)}function H(ce){r+=`${e.slice(ce,t)}0`}function le(ce){throw new h0(`Invalid character ${JSON.stringify(ce)}`,t)}function pe(){throw new h0(`Unexpected character ${JSON.stringify(e[t])}`,t)}function k(){throw new h0("Unexpected end of json string",e.length)}function fe(){throw new h0("Object key expected",t)}function Ee(){throw new h0("Colon expected",t)}function xe(){let ce=e.slice(t,t+6);throw new h0(`Invalid unicode character "${ce}"`,t)}}function gMr(e,t){return e[t]==="*"&&e[t+1]==="/"}He();function $b(e){if(!e)return null;try{return JSON.parse(e)}catch(t){return ae(`Failed to parse JSON: ${e}`,t),null}}function tEe(e){if(!e)return null;try{let t=e.match(/(\{[\s\S]*\})|(\[[\s\S]*\])/);return t&&(e=t[0]),e=oa(e),JSON.parse(e)}catch(t){return ae(`Failed to parse JSON: ${e}`,t),null}}He();wN();var met={allowedTools:[],context:{},history:[],dontCrawlDirectory:!1,enableArchitectTool:!1,mcpContextUris:[],mcpServers:{},approvedMcprcServers:[],rejectedMcprcServers:[],hasTrustDialogAccepted:!1};function fet(e){let t={...met};return e===EMr()&&(t.dontCrawlDirectory=!0),t}var E0={mcpServers:{},numStartups:0,autoUpdaterStatus:"disabled",theme:"dark",preferredNotifChannel:"iterm2",verbose:!1,customApiKeyResponses:{approved:[],rejected:[]}};var _fi={...E0,autoUpdaterStatus:"disabled"},yfi={...met};function Io(e){get(Vg,{...e,projects:Mj(Vg,E0).projects},E0)}function pn(){return Mj(Vg,E0)}function Kg(e){return e.slice(-20)}function Aet(e){let t=pn();return t.customApiKeyResponses?.approved?.includes(e)?"approved":t.customApiKeyResponses?.rejected?.includes(e)?"rejected":"new"}function get(e,t,r){let n=Object.fromEntries(Object.entries(t).filter(([i,o])=>JSON.stringify(o)!==JSON.stringify(r[i])||i=="mcpServers"));hMr(e,JSON.stringify(n,null,2),"utf-8")}var yMr=!1;function Mj(e,t,r){if(!yMr)throw new Error("Config accessed before allowed.");if(!rEe(e))return II(t);try{let n=nEe(e,"utf-8");try{let i=JSON.parse(n);return{...II(t),...i}}catch(i){let o=i instanceof Error?i.message:String(i);throw new kP(o,e,t)}}catch(n){if(n instanceof kP&&r)throw n;return II(t)}}function het(e){let t=gd();t.rejectedMcprcServers&&t.rejectedMcprcServers.includes(e)&&(t.rejectedMcprcServers=t.rejectedMcprcServers.filter(r=>r!==e)),eT(t)}function Eet(e){let t=gd();t.rejectedMcprcServers||(t.rejectedMcprcServers=[]),t.rejectedMcprcServers.includes(e)||t.rejectedMcprcServers.push(e),t.approvedMcprcServers&&t.approvedMcprcServers.includes(e)&&(t.approvedMcprcServers=t.approvedMcprcServers.filter(r=>r!==e)),eT(t)}function gd(){let e=pet(ke()),t=Mj(Vg,E0);if(!t.projects)return fet(e);let r=t.projects[e]??fet(e);return typeof r.allowedTools=="string"&&(r.allowedTools=$b(r.allowedTools)??[]),r}function eT(e){let t=Mj(Vg,E0);get(Vg,{...t,projects:{...t.projects,[pet(ke())]:e}},E0)}var MP=Le(()=>{let e=det(ke(),".mcp.json");if(!rEe(e))return{};try{let t=nEe(e,"utf-8"),r=$b(t);if(r&&typeof r=="object")return r=r.mcpServers,ft("tengu_mcprc_found",{numServers:Object.keys(r).length.toString()}),r}catch{}return{}},()=>{let e=ke(),t=det(e,".mcp.json");if(rEe(t))try{let r=nEe(t,"utf-8");return`${e}:${r}`}catch{return e}return e});function Qj(){let e=pn();if(e.userID)return e.userID;let t=_Mr(32).toString("hex");return Io({...e,userID:t}),t}var bMr={bashBorder:"#ff0087",claude:"#D97757",permission:"#5769f7",secondaryBorder:"#999",text:"#000",secondaryText:"#666",suggestion:"#5769f7",success:"#2c7a39",error:"#ab2b3f",warning:"#966c1e",diff:{added:"#69db7c",removed:"#ffa8b4",addedDimmed:"#c7e1cb",removedDimmed:"#fdd2d8"}},CMr={bashBorder:"#0066cc",claude:"#ff9933",permission:"#3366ff",secondaryBorder:"#999",text:"#000",secondaryText:"#666",suggestion:"#3366ff",success:"#006699",error:"#cc0000",warning:"#ff9900",diff:{added:"#99ccff",removed:"#ffcccc",addedDimmed:"#d1e7fd",removedDimmed:"#ffe9e9"}},SMr={bashBorder:"#fd5db1",claude:"#D97757",permission:"#b1b9f9",secondaryBorder:"#888",text:"#fff",secondaryText:"#999",suggestion:"#b1b9f9",success:"#4eba65",error:"#ff6b80",warning:"#ffc107",diff:{added:"#225c2b",removed:"#7a2936",addedDimmed:"#47584a",removedDimmed:"#69484d"}},IMr={bashBorder:"#3399ff",claude:"#ff9933",permission:"#99ccff",secondaryBorder:"#888",text:"#fff",secondaryText:"#999",suggestion:"#99ccff",success:"#3399ff",error:"#ff6666",warning:"#ffcc00",diff:{added:"#004466",removed:"#660000",addedDimmed:"#3e515b",removedDimmed:"#3e2c2c"}};function Me(e){let t=pn();switch(e??t.theme){case"light":return bMr;case"light-daltonized":return CMr;case"dark-daltonized":return IMr;default:return SMr}}Fe();function tn(){return iEe.createElement(v,null,"\xA0\xA0\u23BF \xA0",iEe.createElement(v,{color:Me().error},"No (tell ",At," what to do differently)"))}Fe();er();import{resolve as oEe,dirname as TMr,join as vMr}from"path";import{createRequire as xMr}from"module";import{fileURLToPath as wMr}from"node:url";import{existsSync as sEe}from"fs";var DMr=xMr(import.meta.url),RMr=wMr(import.meta.url),_et=TMr(RMr),uEe=Le(()=>{let e=process.platform,t=process.arch,r=process.env.HCODE_TREE_SITTER_BASH_PATH?oEe(process.env.HCODE_TREE_SITTER_BASH_PATH,`${t}-${e}`,"tree-sitter-bash.node"):null,n=oEe(_et,"vendor/tree-sitter-bash",`${t}-${e}`,"tree-sitter-bash.node"),i=oEe(_et,"../../vendor/tree-sitter-bash",`${t}-${e}`,"tree-sitter-bash.node"),o=vMr(process.cwd(),"vendor/tree-sitter-bash",`${t}-${e}`,"tree-sitter-bash.node"),s=r&&sEe(r)?r:sEe(n)?n:sEe(i)?i:o;return DMr(s)});function DN(e){let r=uEe().parse(e),n=[];function i(o){if(o.type==="list"&&o.children){for(let s of o.children)if(s.type==="command"||s.type==="pipeline"){let a=s.text.trim();a&&n.push(a)}else s.type==="list"&&i(s);return}if(o.type==="program"&&o.children){for(let s of o.children)if(s.type==="command"){let a=s.text.trim();a&&n.push(a)}else if(s.type==="list")i(s);else if(s.type==="pipeline"){let a=s.text.trim();a&&n.push(a)}return}if(o.type==="pipeline"&&o.children){let s=o.text.trim();s&&n.push(s);return}if(o.type==="command"){let s=o.text.trim();s&&n.push(s);return}if(o.children)for(let s of o.children)i(s)}return i(r),n.length===0&&e.trim()?[e.trim()]:n}function bet(e){let t=DN(e),r=yet(e),n=new Map;for(let i of t){let o=yet(i);n.set(i,o)}return{...r,subcommandPrefixes:n}}function yet(e){let t=e.trim(),r=[/\$\([^)]*\)/,/`[^`]*`/,/\$\{[^}]*\}/,/\$[A-Za-z_][A-Za-z0-9_]*/];for(let i of r)if(i.test(t))return{commandInjectionDetected:!0};return{commandPrefix:BMr(t),commandInjectionDetected:!1}}var NMr=new Map([["git",new Set(["add","branch","checkout","clone","commit","config","diff","fetch","grep","init","log","merge","mv","pull","push","rebase","remote","reset","restore","revert","rm","show","stash","status","switch","tag"])],["npm",new Set(["ci","install","publish","run","test","uninstall","exec"])],["npx",new Set([])],["yarn",new Set(["add","install","remove","run","test","exec"])],["docker",new Set(["build","compose","exec","logs","ps","pull","push","run","stop","buildx"])],["cargo",new Set(["build","check","clean","clippy","doc","fmt","install","new","run","test","update"])],["go",new Set(["build","fmt","get","install","mod","run","test","vet"])],["pip",new Set(["install","uninstall"])],["python",new Set(["-m"])],["pytest",new Set([])]]);function BMr(e){let t=e.trim();if(!t)return null;try{let i=function(c){if(c.type==="command")return c;if(c.children)for(let u of c.children){let f=i(u);if(f)return f}return null},n=uEe().parse(e),o=i(n);if(!o||!o.children)return t.split(/\s+/)[0]||null;let s=[];for(let c of o.children)if(c.type==="command_name"&&c.children){for(let u of c.children)if(u.type==="word"){s.push(u);break}}else c.type==="word"&&s.push(c);if(s.length===0)return t.split(/\s+/)[0]||null;let a=s[0].text,l=NMr.get(a);if(l&&s.length>=2){let c=s[1].text;if(l.has(c))return`${a} ${c}`}return a}catch{return t.split(/\s+/)[0]||null}}var OMr=new Set(["docker ps","docker images","cal","uptime","cat","head","tail","wc","stat","strings","hexdump","od","nl","id","uname","free","df","du","locale","groups","nproc","basename","dirname","realpath","cut","paste","tr","column","tac","rev","fold","expand","unexpand","fmt","comm","cmp","numfmt","readlink","diff","true","false","sleep","which","type","expr","test","getconf","seq","tsort","pr","printf"]),kMr=[/^echo(?:\s+(?:'[^']*'|"[^"$<>\n\r]*"|[^|;&`$(){}><#\\"'\s]+))*(?:\s+2>&1)?\s*$/,/^pwd$/,/^whoami$/,/^node -v$/,/^node --version$/,/^python --version$/,/^python3 --version$/,/^history(?:\s+\d+)?\s*$/,/^alias$/,/^arch(?:\s+(?:--help|-h))?\s*$/,/^ip addr$/,/^ifconfig(?:\s+[a-zA-Z][a-zA-Z0-9_-]*)?\s*$/,/^hcode -h$/,/^hcode --help$/,/^uniq(?:\s+(?:-[a-zA-Z]+|--[a-zA-Z-]+(?:=\S+)?|-[fsw]\s+\d+))*(?:\s|$)\s*$/,/^jq(?!\s+.*(?:-f\b|--from-file|--rawfile|--slurpfile|--run-tests|-L\b|--library-path|\benv\b|\$ENV\b))(?:\s+(?:-[a-zA-Z]+|--[a-zA-Z-]+(?:=\S+)?))*(?:\s+'[^'`]*'|\s+"[^"`]*"|\s+[^-\s'"][^\s]*)+\s*$/,/^cd(?:\s+(?:'[^']*'|"[^"]*"|[^\s;|&`$(){}><#\\]+))?$/,/^ls(?:\s+[^<>()$`|{}&;\n\r]*)?$/,/^find(?:\s+(?:\\[()]|(?!-delete\b|-exec\b|-execdir\b|-ok\b|-okdir\b|-fprint0?\b|-fls\b|-fprintf\b)[^<>()$`|{}&;\n\r\s]|\s)+)?$/],QP={"--all":"none","--branches":"none","--tags":"none","--remotes":"none"},Lj={"--since":"string","--after":"string","--until":"string","--before":"string"},Pj={"--oneline":"none","--graph":"none","--decorate":"none","--no-decorate":"none","--date":"string","--relative-date":"none"},Fj={"--max-count":"number","-n":"number"},Uj={"--stat":"none","--numstat":"none","--shortstat":"none","--name-only":"none","--name-status":"none"},LP={"--color":"none","--no-color":"none"},aEe={"--patch":"none","-p":"none","--no-patch":"none","--no-ext-diff":"none","-s":"none"},lEe={"--author":"string","--committer":"string","--grep":"string"},Hj={xargs:{safeFlags:{"-I":"{}","-n":"number","-P":"number","-L":"number","-s":"number","-E":"EOF","-0":"none","-t":"none","-r":"none","-x":"none","-d":"char"}},"git diff":{safeFlags:{...Uj,...LP,"--dirstat":"none","--summary":"none","--patch-with-stat":"none","--word-diff":"none","--word-diff-regex":"string","--color-words":"none","--no-renames":"none","--no-ext-diff":"none","--check":"none","--ws-error-highlight":"string","--full-index":"none","--binary":"none","--abbrev":"number","--break-rewrites":"none","--find-renames":"none","--find-copies":"none","--find-copies-harder":"none","--irreversible-delete":"none","--diff-algorithm":"string","--histogram":"none","--patience":"none","--minimal":"none","--ignore-space-at-eol":"none","--ignore-space-change":"none","--ignore-all-space":"none","--ignore-blank-lines":"none","--inter-hunk-context":"number","--function-context":"none","--exit-code":"none","--quiet":"none","--cached":"none","--staged":"none","--pickaxe-regex":"none","--pickaxe-all":"none","--no-index":"none","--relative":"string","--diff-filter":"string","-p":"none","-u":"none","-U":"number","--unified":"number","-s":"none","-M":"none","-C":"none","-B":"none","-D":"none","-l":"none","-S":"string","-G":"string","-O":"string","-R":"none"}},"git log":{safeFlags:{...Pj,...QP,...Lj,...Fj,...Uj,...LP,...aEe,...lEe,"--abbrev-commit":"none","--full-history":"none","--dense":"none","--sparse":"none","--simplify-merges":"none","--ancestry-path":"none","--source":"none","--first-parent":"none","--merges":"none","--no-merges":"none","--reverse":"none","--walk-reflogs":"none","--skip":"number","--max-age":"number","--min-age":"number","--no-min-parents":"none","--no-max-parents":"none","--follow":"none","--no-walk":"none","--left-right":"none","--cherry-mark":"none","--cherry-pick":"none","--boundary":"none","--topo-order":"none","--date-order":"none","--author-date-order":"none","--pretty":"string","--format":"string","--diff-filter":"string","-S":"string","-G":"string","--pickaxe-regex":"none","--pickaxe-all":"none"}},"git show":{safeFlags:{...Pj,...Uj,...LP,...aEe,"--abbrev-commit":"none","--word-diff":"none","--word-diff-regex":"string","--color-words":"none","--pretty":"string","--format":"string","--first-parent":"none","--raw":"none","--diff-filter":"string","-m":"none","--quiet":"none"}},"git shortlog":{safeFlags:{...QP,...Lj,"-s":"none","--summary":"none","-n":"none","--numbered":"none","-e":"none","--email":"none","-c":"none","--committer":"none","--group":"string","--format":"string","--no-merges":"none","--author":"string"}},"git reflog":{safeFlags:{...Pj,...QP,...Lj,...Fj,...lEe},additionalCommandIsDangerousCallback:(e,t)=>{let r=new Set(["expire","delete","exists"]);for(let n of t)if(!(!n||n.startsWith("-")))return!!r.has(n);return!1}},"git stash list":{safeFlags:{...Pj,...QP,...Fj}},"git stash show":{safeFlags:{...Uj,...LP,...aEe,"--word-diff":"none","--word-diff-regex":"string","--diff-filter":"string","--abbrev":"number"}},"git ls-remote":{safeFlags:{"--branches":"none","-b":"none","--tags":"none","-t":"none","--heads":"none","-h":"none","--refs":"none","--quiet":"none","-q":"none","--exit-code":"none","--get-url":"none","--symref":"none","--sort":"string"}},"git status":{safeFlags:{"--short":"none","-s":"none","--branch":"none","-b":"none","--porcelain":"none","--long":"none","--verbose":"none","-v":"none","--untracked-files":"string","-u":"string","--ignored":"none","--ignore-submodules":"string","--column":"none","--no-column":"none","--ahead-behind":"none","--no-ahead-behind":"none","--renames":"none","--no-renames":"none","--find-renames":"string","-M":"string"}},"git blame":{safeFlags:{...LP,"-L":"string","--porcelain":"none","-p":"none","--line-porcelain":"none","--incremental":"none","--root":"none","--show-stats":"none","--show-name":"none","--show-number":"none","-n":"none","--show-email":"none","-e":"none","-f":"none","--date":"string","-w":"none","--ignore-rev":"string","--ignore-revs-file":"string","-M":"none","-C":"none","--score-debug":"none","--abbrev":"number","-s":"none","-l":"none","-t":"none"}},"git ls-files":{safeFlags:{"--cached":"none","-c":"none","--deleted":"none","-d":"none","--modified":"none","-m":"none","--others":"none","-o":"none","--ignored":"none","-i":"none","--stage":"none","-s":"none","--killed":"none","-k":"none","--unmerged":"none","-u":"none","--directory":"none","--no-empty-directory":"none","--eol":"none","--full-name":"none","--abbrev":"number","--debug":"none","-z":"none","-t":"none","-v":"none","-f":"none","--exclude":"string","-x":"string","--exclude-from":"string","-X":"string","--exclude-per-directory":"string","--exclude-standard":"none","--error-unmatch":"none","--recurse-submodules":"none"}},"git config --get":{safeFlags:{"--local":"none","--global":"none","--system":"none","--worktree":"none","--default":"string","--type":"string","--bool":"none","--int":"none","--bool-or-int":"none","--path":"none","--expiry-date":"none","-z":"none","--null":"none","--name-only":"none","--show-origin":"none","--show-scope":"none"}},"git remote show":{safeFlags:{"-n":"none"},additionalCommandIsDangerousCallback:(e,t)=>{let r=t.filter(n=>n!=="-n");return r.length!==1?!0:!/^[a-zA-Z0-9_-]+$/.test(r[0])}},"git remote":{safeFlags:{"-v":"none","--verbose":"none"},additionalCommandIsDangerousCallback:(e,t)=>t.some(r=>r!=="-v"&&r!=="--verbose")},"git merge-base":{safeFlags:{"--is-ancestor":"none","--fork-point":"none","--octopus":"none","--independent":"none","--all":"none"}},"git rev-parse":{safeFlags:{"--verify":"none","--short":"string","--abbrev-ref":"none","--symbolic":"none","--symbolic-full-name":"none","--show-toplevel":"none","--show-cdup":"none","--show-prefix":"none","--git-dir":"none","--git-common-dir":"none","--absolute-git-dir":"none","--show-superproject-working-tree":"none","--is-inside-work-tree":"none","--is-inside-git-dir":"none","--is-bare-repository":"none","--is-shallow-repository":"none","--is-shallow-update":"none","--path-prefix":"none"}},"git rev-list":{safeFlags:{...QP,...Lj,...Fj,...lEe,"--count":"none","--reverse":"none","--first-parent":"none","--ancestry-path":"none","--merges":"none","--no-merges":"none","--min-parents":"number","--max-parents":"number","--no-min-parents":"none","--no-max-parents":"none","--skip":"number","--max-age":"number","--min-age":"number","--walk-reflogs":"none","--oneline":"none","--abbrev-commit":"none","--pretty":"string","--format":"string","--abbrev":"number","--full-history":"none","--dense":"none","--sparse":"none","--source":"none","--graph":"none"}},"git describe":{safeFlags:{"--tags":"none","--match":"string","--exclude":"string","--long":"none","--abbrev":"number","--always":"none","--contains":"none","--first-match":"none","--exact-match":"none","--candidates":"number","--dirty":"none","--broken":"none"}},"git cat-file":{safeFlags:{"-t":"none","-s":"none","-p":"none","-e":"none","--batch-check":"none","--allow-undetermined-type":"none"}},"git for-each-ref":{safeFlags:{"--format":"string","--sort":"string","--count":"number","--contains":"string","--no-contains":"string","--merged":"string","--no-merged":"string","--points-at":"string"}},"git grep":{safeFlags:{"-e":"string","-E":"none","--extended-regexp":"none","-G":"none","--basic-regexp":"none","-F":"none","--fixed-strings":"none","-P":"none","--perl-regexp":"none","-i":"none","--ignore-case":"none","-v":"none","--invert-match":"none","-w":"none","--word-regexp":"none","-n":"none","--line-number":"none","-c":"none","--count":"none","-l":"none","--files-with-matches":"none","-L":"none","--files-without-match":"none","-h":"none","-H":"none","--heading":"none","--break":"none","--full-name":"none","--color":"none","--no-color":"none","-o":"none","--only-matching":"none","-A":"number","--after-context":"number","-B":"number","--before-context":"number","-C":"number","--context":"number","--and":"none","--or":"none","--not":"none","--max-depth":"number","--untracked":"none","--no-index":"none","--recurse-submodules":"none","--cached":"none","--threads":"number","-q":"none","--quiet":"none"}},"git worktree list":{safeFlags:{"--porcelain":"none","-v":"none","--verbose":"none","--expire":"string"}},"git tag":{safeFlags:{"-l":"none","--list":"none","-n":"number","--contains":"string","--no-contains":"string","--merged":"string","--no-merged":"string","--sort":"string","--format":"string","--points-at":"string","--column":"none","--no-column":"none","-i":"none","--ignore-case":"none"},additionalCommandIsDangerousCallback:(e,t)=>{let r=new Set(["--contains","--no-contains","--merged","--no-merged","--points-at","--sort","--format","-n"]),n=!1,i=0,o=!1;for(;i<t.length;){let s=t[i];if(!s){i++;continue}if(s==="--"&&!o){o=!0,i++;continue}if(!o&&s.startsWith("-"))(s==="--list"||s==="-l"||s[0]==="-"&&s[1]!=="-"&&s.length>2&&!s.includes("=")&&s.slice(1).includes("l"))&&(n=!0),s.includes("=")?i++:r.has(s)?i+=2:i++;else{if(!n)return!0;i++}}return!1}},"git branch":{safeFlags:{"-l":"none","--list":"none","-a":"none","--all":"none","-r":"none","--remotes":"none","-v":"none","-vv":"none","--verbose":"none","--color":"none","--no-color":"none","--column":"none","--no-column":"none","--abbrev":"number","--no-abbrev":"none","--contains":"string","--no-contains":"string","--merged":"none","--no-merged":"none","--points-at":"string","--sort":"string","--show-current":"none","-i":"none","--ignore-case":"none"},additionalCommandIsDangerousCallback:(e,t)=>{let r=new Set(["--contains","--no-contains","--points-at","--sort"]),n=new Set(["--merged","--no-merged"]),i=!1,o="",s=0,a=!1;for(;s<t.length;){let l=t[s];if(!l){s++;continue}if(l==="--"&&!a){a=!0,o="",s++;continue}if(!a&&l.startsWith("-"))(l==="--list"||l==="-l"||l[0]==="-"&&l[1]!=="-"&&l.length>2&&!l.includes("=")&&l.slice(1).includes("l"))&&(i=!0),l.includes("=")?(o=l.split("=")[0]??"",s++):r.has(l)?(o=l,s+=2):(o=l,s++);else{let c=n.has(o);if(!i&&!c)return!0;o="",s++}}return!1}},file:{safeFlags:{"--brief":"none","-b":"none","--mime":"none","-i":"none","--mime-type":"none","--mime-encoding":"none","--apple":"none","--check-encoding":"none","-c":"none","--exclude":"string","--exclude-quiet":"string","--print0":"none","-0":"none","-f":"string","-F":"string","--separator":"string","--help":"none","--version":"none","-v":"none","--no-dereference":"none","-h":"none","--dereference":"none","-L":"none","--magic-file":"string","-m":"string","--keep-going":"none","-k":"none","--list":"none","-l":"none","--no-buffer":"none","-n":"none","--preserve-date":"none","-p":"none","--raw":"none","-r":"none","-s":"none","--special-files":"none","--uncompress":"none","-z":"none"}},sed:{safeFlags:{"--expression":"string","-e":"string","--quiet":"none","--silent":"none","-n":"none","--regexp-extended":"none","-r":"none","--posix":"none","-E":"none","--line-length":"number","-l":"number","--zero-terminated":"none","-z":"none","--separate":"none","-s":"none","--unbuffered":"none","-u":"none","--debug":"none","--help":"none","--version":"none"},additionalCommandIsDangerousCallback:e=>/(?:^|\s)(?:-i\S*|--in-place\S*)(?:\s|$)/.test(e)},sort:{safeFlags:{"--ignore-leading-blanks":"none","-b":"none","--dictionary-order":"none","-d":"none","--ignore-case":"none","-f":"none","--general-numeric-sort":"none","-g":"none","--human-numeric-sort":"none","-h":"none","--ignore-nonprinting":"none","-i":"none","--month-sort":"none","-M":"none","--numeric-sort":"none","-n":"none","--random-sort":"none","-R":"none","--reverse":"none","-r":"none","--sort":"string","--stable":"none","-s":"none","--unique":"none","-u":"none","--version-sort":"none","-V":"none","--zero-terminated":"none","-z":"none","--key":"string","-k":"string","--field-separator":"string","-t":"string","--check":"none","-c":"none","--check-char-order":"none","-C":"none","--merge":"none","-m":"none","--buffer-size":"string","-S":"string","--parallel":"number","--batch-size":"number","--help":"none","--version":"none"}},grep:{safeFlags:{"-e":"string","--regexp":"string","-f":"string","--file":"string","-F":"none","--fixed-strings":"none","-G":"none","--basic-regexp":"none","-E":"none","--extended-regexp":"none","-P":"none","--perl-regexp":"none","-i":"none","--ignore-case":"none","--no-ignore-case":"none","-v":"none","--invert-match":"none","-w":"none","--word-regexp":"none","-x":"none","--line-regexp":"none","-c":"none","--count":"none","--color":"string","--colour":"string","-L":"none","--files-without-match":"none","-l":"none","--files-with-matches":"none","-m":"number","--max-count":"number","-o":"none","--only-matching":"none","-q":"none","--quiet":"none","--silent":"none","-s":"none","--no-messages":"none","-b":"none","--byte-offset":"none","-H":"none","--with-filename":"none","-h":"none","--no-filename":"none","--label":"string","-n":"none","--line-number":"none","-T":"none","--initial-tab":"none","-u":"none","--unix-byte-offsets":"none","-Z":"none","--null":"none","-z":"none","--null-data":"none","-A":"number","--after-context":"number","-B":"number","--before-context":"number","-C":"number","--context":"number","--group-separator":"string","--no-group-separator":"none","-a":"none","--text":"none","--binary-files":"string","-D":"string","--devices":"string","-d":"string","--directories":"string","--exclude":"string","--exclude-from":"string","--exclude-dir":"string","--include":"string","-r":"none","--recursive":"none","-R":"none","--dereference-recursive":"none","--line-buffered":"none","-U":"none","--binary":"none","--help":"none","-V":"none","--version":"none"}},rg:{safeFlags:{"-e":"string","--regexp":"string","-f":"string","-i":"none","--ignore-case":"none","-S":"none","--smart-case":"none","-F":"none","--fixed-strings":"none","-w":"none","--word-regexp":"none","-v":"none","--invert-match":"none","-c":"none","--count":"none","-l":"none","--files-with-matches":"none","--files-without-match":"none","-n":"none","--line-number":"none","-o":"none","--only-matching":"none","-A":"number","--after-context":"number","-B":"number","--before-context":"number","-C":"number","--context":"number","-H":"none","-h":"none","--heading":"none","--no-heading":"none","-q":"none","--quiet":"none","--column":"none","-g":"string","--glob":"string","-t":"string","--type":"string","-T":"string","--type-not":"string","--type-list":"none","--hidden":"none","--no-ignore":"none","-u":"none","-m":"number","--max-count":"number","-d":"number","--max-depth":"number","-a":"none","--text":"none","-z":"none","-L":"none","--follow":"none","--color":"string","--json":"none","--stats":"none","--help":"none","--version":"none","--debug":"none","--":"none"}},fd:{safeFlags:{"-h":"none","--help":"none","-V":"none","--version":"none","-H":"none","--hidden":"none","-I":"none","--no-ignore":"none","--no-ignore-vcs":"none","--no-ignore-parent":"none","-s":"none","--case-sensitive":"none","-i":"none","--ignore-case":"none","-g":"none","--glob":"none","--regex":"none","-F":"none","--fixed-strings":"none","-a":"none","--absolute-path":"none","-L":"none","--follow":"none","-p":"none","--full-path":"none","-0":"none","--print0":"none","-d":"number","--max-depth":"number","--min-depth":"number","--exact-depth":"number","-t":"string","--type":"string","-e":"string","--extension":"string","-S":"string","--size":"string","--changed-within":"string","--changed-before":"string","-o":"string","--owner":"string","-E":"string","--exclude":"string","--ignore-file":"string","-c":"string","--color":"string","-j":"number","--threads":"number","--max-buffer-time":"string","--max-results":"number","-1":"none","-q":"none","--quiet":"none","--show-errors":"none","--strip-cwd-prefix":"none","--one-file-system":"none","--prune":"none","--search-path":"string","--base-directory":"string","--path-separator":"string","--batch-size":"number","--no-require-git":"none","--hyperlink":"string","--and":"string","--format":"string"}},fdfind:{safeFlags:{}},sha256sum:{safeFlags:{"-b":"none","--binary":"none","-t":"none","--text":"none","-c":"none","--check":"none","--ignore-missing":"none","--quiet":"none","--status":"none","--strict":"none","-w":"none","--warn":"none","--tag":"none","-z":"none","--zero":"none","--help":"none","--version":"none"}},sha1sum:{safeFlags:{"-b":"none","--binary":"none","-t":"none","--text":"none","-c":"none","--check":"none","--ignore-missing":"none","--quiet":"none","--status":"none","--strict":"none","-w":"none","--warn":"none","--tag":"none","-z":"none","--zero":"none","--help":"none","--version":"none"}},md5sum:{safeFlags:{"-b":"none","--binary":"none","-t":"none","--text":"none","-c":"none","--check":"none","--ignore-missing":"none","--quiet":"none","--status":"none","--strict":"none","-w":"none","--warn":"none","--tag":"none","-z":"none","--zero":"none","--help":"none","--version":"none"}},tree:{safeFlags:{"-a":"none","-d":"none","-l":"none","-f":"none","-x":"none","-L":"number","-P":"string","-I":"string","--gitignore":"none","--gitfile":"string","--ignore-case":"none","--matchdirs":"none","--metafirst":"none","--prune":"none","--info":"none","--infofile":"string","--noreport":"none","--charset":"string","--filelimit":"number","-q":"none","-N":"none","-Q":"none","-p":"none","-u":"none","-g":"none","-s":"none","-h":"none","--si":"none","--du":"none","-D":"none","--timefmt":"string","-F":"none","--inodes":"none","--device":"none","-v":"none","-t":"none","-c":"none","-U":"none","-r":"none","--dirsfirst":"none","--filesfirst":"none","--sort":"string","-i":"none","-A":"none","-S":"none","-n":"none","-C":"none","-X":"none","-J":"none","-H":"string","--nolinks":"none","--hintro":"string","--houtro":"string","-T":"string","--hyperlink":"none","--scheme":"string","--authority":"string","--fromfile":"none","--fromtabfile":"none","--fflinks":"none","--help":"none","--version":"none"}},date:{safeFlags:{"-d":"string","--date":"string","-r":"string","--reference":"string","-u":"none","--utc":"none","--universal":"none","-I":"none","--iso-8601":"string","-R":"none","--rfc-email":"none","--rfc-3339":"string","--debug":"none","--help":"none","--version":"none"},additionalCommandIsDangerousCallback:(e,t)=>{let r=new Set(["-d","--date","-r","--reference","--iso-8601","--rfc-3339"]),n=0;for(;n<t.length;){let i=t[n];if(i.startsWith("--")&&i.includes("=")){n++;continue}if(i.startsWith("-"))r.has(i)?n+=2:n++;else{if(!i.startsWith("+"))return!0;n++}}return!1}},hostname:{safeFlags:{"-f":"none","--fqdn":"none","--long":"none","-s":"none","--short":"none","-i":"none","--ip-address":"none","-I":"none","--all-ip-addresses":"none","-a":"none","--alias":"none","-d":"none","--domain":"none","-A":"none","--all-fqdns":"none","-v":"none","--verbose":"none","-h":"none","--help":"none","-V":"none","--version":"none"},regex:/^hostname(?:\s+(?:-[a-zA-Z]|--[a-zA-Z-]+))*\s*$/},info:{safeFlags:{"-f":"string","--file":"string","-d":"string","--directory":"string","-n":"string","--node":"string","-a":"none","--all":"none","-k":"string","--apropos":"string","-w":"none","--where":"none","--location":"none","--show-options":"none","--vi-keys":"none","--subnodes":"none","-h":"none","--help":"none","--usage":"none","--version":"none"}},man:{safeFlags:{"-a":"none","--all":"none","-d":"none","-f":"none","--whatis":"none","-h":"none","-k":"none","--apropos":"none","-l":"string","-w":"none","-S":"string","-s":"string"}},help:{safeFlags:{"-d":"none","-m":"none","-s":"none"}},ps:{safeFlags:{"-e":"none","-A":"none","-a":"none","-d":"none","-N":"none","--deselect":"none","-f":"none","-F":"none","-l":"none","-j":"none","-y":"none","-w":"none","-ww":"none","--width":"number","-c":"none","-H":"none","--forest":"none","--headers":"none","--no-headers":"none","-n":"string","--sort":"string","-L":"none","-T":"none","-m":"none","-C":"string","-G":"string","-g":"string","-p":"string","--pid":"string","-q":"string","--quick-pid":"string","-s":"string","--sid":"string","-t":"string","--tty":"string","-U":"string","-u":"string","--user":"string","--help":"none","--info":"none","-V":"none","--version":"none"},additionalCommandIsDangerousCallback:(e,t)=>t.some(r=>!r.startsWith("-")&&/^[a-zA-Z]*e[a-zA-Z]*$/.test(r))},base64:{respectsDoubleDash:!1,safeFlags:{"-d":"none","-D":"none","--decode":"none","-b":"number","--break":"number","-w":"number","--wrap":"number","-i":"string","--input":"string","--ignore-garbage":"none","-h":"none","--help":"none","--version":"none"}},netstat:{safeFlags:{"-a":"none","-L":"none","-l":"none","-n":"none","-f":"string","-g":"none","-i":"none","-I":"string","-s":"none","-r":"none","-m":"none","-v":"none"}},ss:{safeFlags:{"-h":"none","--help":"none","-V":"none","--version":"none","-n":"none","--numeric":"none","-r":"none","--resolve":"none","-a":"none","--all":"none","-l":"none","--listening":"none","-o":"none","--options":"none","-e":"none","--extended":"none","-m":"none","--memory":"none","-p":"none","--processes":"none","-i":"none","--info":"none","-s":"none","--summary":"none","-4":"none","--ipv4":"none","-6":"none","--ipv6":"none","-0":"none","--packet":"none","-t":"none","--tcp":"none","-M":"none","--mptcp":"none","-S":"none","--sctp":"none","-u":"none","--udp":"none","-d":"none","--dccp":"none","-w":"none","--raw":"none","-x":"none","--unix":"none","--tipc":"none","--vsock":"none","-f":"string","--family":"string","-A":"string","--query":"string","--socket":"string","-Z":"none","--context":"none","-z":"none","--contexts":"none","-b":"none","--bpf":"none","-E":"none","--events":"none","-H":"none","--no-header":"none","-O":"none","--oneline":"none","--tipcinfo":"none","--tos":"none","--cgroup":"none","--inet-sockopt":"none"}},lsof:{safeFlags:{"-?":"none","-h":"none","-v":"none","-a":"none","-b":"none","-C":"none","-l":"none","-n":"none","-N":"none","-O":"none","-P":"none","-Q":"none","-R":"none","-t":"none","-U":"none","-V":"none","-X":"none","-H":"none","-E":"none","-F":"none","-g":"none","-i":"none","-K":"none","-L":"none","-o":"none","-r":"none","-s":"none","-S":"none","-T":"none","-x":"none","-A":"string","-c":"string","-d":"string","-e":"string","-k":"string","-p":"string","-u":"string"},additionalCommandIsDangerousCallback:(e,t)=>t.some(r=>r==="+m"||r.startsWith("+m"))},pgrep:{safeFlags:{"-d":"string","--delimiter":"string","-l":"none","--list-name":"none","-a":"none","--list-full":"none","-v":"none","--inverse":"none","-w":"none","--lightweight":"none","-c":"none","--count":"none","-f":"none","--full":"none","-g":"string","--pgroup":"string","-G":"string","--group":"string","-i":"none","--ignore-case":"none","-n":"none","--newest":"none","-o":"none","--oldest":"none","-O":"string","--older":"string","-P":"string","--parent":"string","-s":"string","--session":"string","-t":"string","--terminal":"string","-u":"string","--euid":"string","-U":"string","--uid":"string","-x":"none","--exact":"none","-F":"string","--pidfile":"string","-L":"none","--logpidfile":"none","-r":"string","--runstates":"string","--ns":"string","--nslist":"string","--help":"none","-V":"none","--version":"none"}},tput:{safeFlags:{"-T":"string","-V":"none","-x":"none"},additionalCommandIsDangerousCallback:(e,t)=>{let r=new Set(["init","reset","rs1","rs2","rs3","is1","is2","is3","iprog","if","rf","clear","flash","mc0","mc4","mc5","mc5i","mc5p","pfkey","pfloc","pfx","pfxl","smcup","rmcup"]),n=new Set(["-T"]),i=0,o=!1;for(;i<t.length;){let s=t[i];if(s==="--"){o=!0,i++;continue}if(!o&&s.startsWith("-")){if(s==="-S"||!s.startsWith("--")&&s.length>2&&s.includes("S"))return!0;n.has(s)?i+=2:i++}else{if(r.has(s))return!0;i++}}return!1}},"docker logs":{safeFlags:{"--follow":"none","-f":"none","--tail":"string","-n":"string","--timestamps":"none","-t":"none","--since":"string","--until":"string","--details":"none"}},"docker inspect":{safeFlags:{"--format":"string","-f":"string","--type":"string","--size":"none","-s":"none"}},pyright:{respectsDoubleDash:!1,safeFlags:{"--outputjson":"none","--project":"string","-p":"string","--pythonversion":"string","--pythonplatform":"string","--typeshedpath":"string","--venvpath":"string","--level":"string","--stats":"none","--verbose":"none","--version":"none","--dependencies":"none","--warnings":"none"},additionalCommandIsDangerousCallback:(e,t)=>t.some(r=>r==="--watch"||r==="-w")},"gh pr view":{safeFlags:{"--json":"string","--comments":"none","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh pr list":{safeFlags:{"--state":"string","-s":"string","--author":"string","--assignee":"string","--label":"string","--limit":"number","-L":"number","--base":"string","--head":"string","--search":"string","--json":"string","--draft":"none","--app":"string","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh pr diff":{safeFlags:{"--color":"string","--name-only":"none","--patch":"none","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh pr checks":{safeFlags:{"--watch":"none","--required":"none","--fail-fast":"none","--json":"string","--interval":"number","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh pr status":{safeFlags:{"--conflict-status":"none","-c":"none","--json":"string","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh issue view":{safeFlags:{"--json":"string","--comments":"none","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh issue list":{safeFlags:{"--state":"string","-s":"string","--assignee":"string","--author":"string","--label":"string","--limit":"number","-L":"number","--milestone":"string","--search":"string","--json":"string","--app":"string","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh issue status":{safeFlags:{"--json":"string","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh repo view":{safeFlags:{"--json":"string"},additionalCommandIsDangerousCallback:Xl},"gh run list":{safeFlags:{"--branch":"string","-b":"string","--status":"string","-s":"string","--workflow":"string","-w":"string","--limit":"number","-L":"number","--json":"string","--repo":"string","-R":"string","--event":"string","-e":"string","--user":"string","-u":"string","--created":"string","--commit":"string","-c":"string"},additionalCommandIsDangerousCallback:Xl},"gh run view":{safeFlags:{"--log":"none","--log-failed":"none","--exit-status":"none","--verbose":"none","-v":"none","--json":"string","--repo":"string","-R":"string","--job":"string","-j":"string","--attempt":"number","-a":"number"},additionalCommandIsDangerousCallback:Xl},"gh auth status":{safeFlags:{"--active":"none","-a":"none","--hostname":"string","-h":"string","--json":"string"},additionalCommandIsDangerousCallback:Xl},"gh release list":{safeFlags:{"--exclude-drafts":"none","--exclude-pre-releases":"none","--json":"string","--limit":"number","-L":"number","--order":"string","-O":"string","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh release view":{safeFlags:{"--json":"string","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh workflow list":{safeFlags:{"--all":"none","-a":"none","--json":"string","--limit":"number","-L":"number","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh workflow view":{safeFlags:{"--ref":"string","-r":"string","--yaml":"none","-y":"none","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh label list":{safeFlags:{"--json":"string","--limit":"number","-L":"number","--order":"string","--search":"string","-S":"string","--sort":"string","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh search repos":{safeFlags:{"--archived":"none","--created":"string","--followers":"string","--forks":"string","--good-first-issues":"string","--help-wanted-issues":"string","--include-forks":"string","--json":"string","--language":"string","--license":"string","--limit":"number","-L":"number","--match":"string","--number-topics":"string","--order":"string","--owner":"string","--size":"string","--sort":"string","--stars":"string","--topic":"string","--updated":"string","--visibility":"string"}},"gh search issues":{safeFlags:{"--app":"string","--assignee":"string","--author":"string","--closed":"string","--commenter":"string","--comments":"string","--created":"string","--include-prs":"none","--interactions":"string","--involves":"string","--json":"string","--label":"string","--language":"string","--limit":"number","-L":"number","--locked":"none","--match":"string","--mentions":"string","--milestone":"string","--no-assignee":"none","--no-label":"none","--no-milestone":"none","--no-project":"none","--order":"string","--owner":"string","--project":"string","--reactions":"string","--repo":"string","-R":"string","--sort":"string","--state":"string","--team-mentions":"string","--updated":"string","--visibility":"string"}},"gh search prs":{safeFlags:{"--app":"string","--assignee":"string","--author":"string","--base":"string","-B":"string","--checks":"string","--closed":"string","--commenter":"string","--comments":"string","--created":"string","--draft":"none","--head":"string","-H":"string","--interactions":"string","--involves":"string","--json":"string","--label":"string","--language":"string","--limit":"number","-L":"number","--locked":"none","--match":"string","--mentions":"string","--merged":"none","--merged-at":"string","--milestone":"string","--no-assignee":"none","--no-label":"none","--no-milestone":"none","--no-project":"none","--order":"string","--owner":"string","--project":"string","--reactions":"string","--repo":"string","-R":"string","--review":"string","--review-requested":"string","--reviewed-by":"string","--sort":"string","--state":"string","--team-mentions":"string","--updated":"string","--visibility":"string"}},"gh search commits":{safeFlags:{"--author":"string","--author-date":"string","--author-email":"string","--author-name":"string","--committer":"string","--committer-date":"string","--committer-email":"string","--committer-name":"string","--hash":"string","--json":"string","--limit":"number","-L":"number","--merge":"none","--order":"string","--owner":"string","--parent":"string","--repo":"string","-R":"string","--sort":"string","--tree":"string","--visibility":"string"}},"gh search code":{safeFlags:{"--extension":"string","--filename":"string","--json":"string","--language":"string","--limit":"number","-L":"number","--match":"string","--owner":"string","--repo":"string","-R":"string","--size":"string"}}};function Xl(e,t){for(let r of t){if(!r)continue;let n=r;if(r.startsWith("-")){let i=r.indexOf("=");if(i===-1||(n=r.slice(i+1),!n))continue}if(!(!n.includes("/")&&!n.includes("://")&&!n.includes("@"))&&(n.includes("://")||n.includes("@")||(n.match(/\//g)??[]).length>=2))return!0}return!1}Hj.fdfind=Hj.fd;var MMr=Object.keys(Hj).sort((e,t)=>t.split(" ").length-e.split(" ").length),QMr=new Set(["command_substitution","arithmetic_expansion","expansion","simple_expansion"]),Cet=new Set(["file_redirect","heredoc_redirect","redirected_statement"]);function Iet(e){if(QMr.has(e.type))return!0;if(e.children){for(let t of e.children)if(Iet(t))return!0}return!1}function LMr(e){return Iet(e)?null:e.text}function Tet(e){if(e.type==="command")return 1;if(e.type==="list"&&e.children){let t=0;for(let r of e.children)(r.type==="command"||r.type==="pipeline")&&t++;return t}if(e.children){let t=0;for(let r of e.children)t+=Tet(r);return t}return 0}function vet(e){if(e.type==="command")return e;if(e.children)for(let t of e.children){let r=vet(t);if(r)return r}return null}function xet(e){if(Cet.has(e.type))return"redirect";if(e.type==="variable_assignment")return"env-var";if(e.children)for(let t of e.children){let r=xet(t);if(r)return r}return null}function wet(e,t){if(e.type==="word"){t.push(e);return}if(!Cet.has(e.type)&&e.children)for(let r of e.children)wet(r,t)}function PMr(e){let t;try{t=uEe().parse(e.trim())}catch(s){return{ok:!1,reason:`parse error: ${s}`}}if(Tet(t)!==1)return{ok:!1,reason:"multiple commands"};let r=vet(t);if(!r)return{ok:!1,reason:"no command found"};let n=xet(r);if(n)return{ok:!1,reason:`prefix (${n})`};let i=[],o=[];if(wet(r,o),o.length===0)return{ok:!1,reason:"no command name"};for(let s of o){let a=LMr(s);if(a===null)return{ok:!1,reason:"expansion in arg"};i.push(a)}return{ok:!0,tokens:i}}function cEe(e,t){switch(t){case"none":return!1;case"string":return!0;case"number":return/^-?\d+$/.test(e);case"char":return e.length===1;case"{}":return e==="{}";case"EOF":return e==="EOF"}}var FMr=new Set(["echo","printf","wc","grep","head","tail"]);function UMr(e,t,r,n){let i=t;for(;i<e.length;){let o=e[i];if(n.isXargs&&!o.startsWith("-")&&o!=="--")return FMr.has(o);if(o==="--"){if(r.respectsDoubleDash!==!1){i++;break}i++;continue}if(!o.startsWith("-")||o==="-"){i++;continue}if(!o.startsWith("--")&&o.length>2&&!o.includes("=")){let f=o.slice(0,2),A=o.slice(2),m=r.safeFlags[f];if(m&&m!=="none"){if(cEe(A,m)){i++;continue}return!1}}let s=o.indexOf("="),a=s!==-1,l=a?o.slice(0,s):o,c=a?o.slice(s+1):"";if(!l)return!1;let u=r.safeFlags[l];if(!u){if(n.commandName==="git"&&/^-\d+$/.test(l)){i++;continue}let f=l.match(/^(-[A-Za-z])(\d+)$/);if(f){let A=r.safeFlags[f[1]];if((A==="number"||A==="string")&&cEe(f[2],"number")){i++;continue}}if(!l.startsWith("--")&&l.length>2&&l.slice(1).split("").every(A=>r.safeFlags[`-${A}`]==="none")){i++;continue}return!1}if(u==="none"){if(a)return!1;i++}else{let f;if(a)f=c,i++;else{if(i+1>=e.length)return!1;let A=e[i+1];if(A.startsWith("-")&&A.length>1&&A!=="--"){let m=/^-\d+$/.test(A),g=l==="--sort"&&n.commandName==="git"&&/^-[a-zA-Z]/.test(A);if(!m&&!g)return!1}f=A,i+=2}if(!cEe(f,u))return!1}}return!0}function Det(e){let t=e.trim();if(kMr.some(s=>s.test(t)))return!0;let r=PMr(t);if(!r.ok)return!1;let{tokens:n}=r;if(n.length===0)return!1;for(let s of[...OMr].sort((a,l)=>l.split(" ").length-a.split(" ").length)){let a=s.split(" ");if(n.length>=a.length&&a.every((l,c)=>n[c]===l))return!0}let i=null,o=0;for(let s of MMr){let a=s.split(" ");if(!(n.length<a.length)&&a.every((l,c)=>n[c]===l)){i=Hj[s],o=a.length;break}}if(!i)return!1;if(n[0]==="git"&&n[1]==="ls-remote")for(let s=2;s<n.length;s++){let a=n[s];if(a&&!a.startsWith("-")&&(a.includes("://")||a.includes("@")||a.includes(":")||a.includes("$")))return!1}for(let s of n.slice(o))if(s&&(s.includes("$")||s.includes("{")&&(s.includes(",")||s.includes(".."))))return!1;return!(!i.regex&&t.includes("`")||!UMr(n,o,i,{commandName:n[0],isXargs:n[0]==="xargs"})||i.regex&&!i.regex.test(t)||i.additionalCommandIsDangerousCallback?.(t,n.slice(o)))}He();import{readFileSync as RLr,writeFileSync as NLr,openSync as Mtt,readSync as Qtt,closeSync as Ltt,existsSync as BLr,readdirSync as OLr,opendirSync as Vpi,lstatSync as Ptt}from"fs";import{isAbsolute as Ftt,normalize as Dtt,resolve as tF,resolve as Rtt,relative as kLr,sep as lV,basename as Ntt,dirname as MLr,extname as Btt,join as QLr}from"path";var dEe=(e,t,r)=>{let n=e instanceof RegExp?Ret(e,r):e,i=t instanceof RegExp?Ret(t,r):t,o=n!==null&&i!=null&&HMr(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)}},Ret=(e,t)=>{let r=t.match(e);return r?r[0]:null},HMr=(e,t,r)=>{let n,i,o,s,a,l=r.indexOf(e),c=r.indexOf(t,l+1),u=l;if(l>=0&&c>0){if(e===t)return[l,c];for(n=[],o=r.length;u>=0&&!a;){if(u===l)n.push(u),l=r.indexOf(e,u+1);else if(n.length===1){let f=n.pop();f!==void 0&&(a=[f,c])}else i=n.pop(),i!==void 0&&i<o&&(o=i,s=c),c=r.indexOf(t,u+1);u=l<c&&l>=0?l:c}n.length&&s!==void 0&&(a=[o,s])}return a};var Net="\0SLASH"+Math.random()+"\0",Bet="\0OPEN"+Math.random()+"\0",pEe="\0CLOSE"+Math.random()+"\0",Oet="\0COMMA"+Math.random()+"\0",ket="\0PERIOD"+Math.random()+"\0",qMr=new RegExp(Net,"g"),GMr=new RegExp(Bet,"g"),$Mr=new RegExp(pEe,"g"),zMr=new RegExp(Oet,"g"),YMr=new RegExp(ket,"g"),jMr=/\\\\/g,VMr=/\\{/g,WMr=/\\}/g,KMr=/\\,/g,JMr=/\\./g,ZMr=1e5;function fEe(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function XMr(e){return e.replace(jMr,Net).replace(VMr,Bet).replace(WMr,pEe).replace(KMr,Oet).replace(JMr,ket)}function eQr(e){return e.replace(qMr,"\\").replace(GMr,"{").replace($Mr,"}").replace(zMr,",").replace(YMr,".")}function Met(e){if(!e)return[""];let t=[],r=dEe("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=Met(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function Qet(e,t={}){if(!e)return[];let{max:r=ZMr}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),PP(XMr(e),r,!0).map(eQr)}function tQr(e){return"{"+e+"}"}function rQr(e){return/^-?0\d/.test(e)}function nQr(e,t){return e<=t}function iQr(e,t){return e>=t}function PP(e,t,r){let n=[],i=dEe("{","}",e);if(!i)return[e];let o=i.pre,s=i.post.length?PP(i.post,t,!1):[""];if(/\$$/.test(i.pre))for(let a=0;a<s.length&&a<t;a++){let l=o+"{"+i.body+"}"+s[a];n.push(l)}else{let a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),c=a||l,u=i.body.indexOf(",")>=0;if(!c&&!u)return i.post.match(/,(?!,).*\}/)?(e=i.pre+"{"+i.body+pEe+i.post,PP(e,t,!0)):[e];let f;if(c)f=i.body.split(/\.\./);else if(f=Met(i.body),f.length===1&&f[0]!==void 0&&(f=PP(f[0],t,!1).map(tQr),f.length===1))return s.map(m=>i.pre+f[0]+m);let A;if(c&&f[0]!==void 0&&f[1]!==void 0){let m=fEe(f[0]),g=fEe(f[1]),E=Math.max(f[0].length,f[1].length),_=f.length===3&&f[2]!==void 0?Math.abs(fEe(f[2])):1,C=nQr;g<m&&(_*=-1,C=iQr);let T=f.some(rQr);A=[];for(let w=m;C(w,g);w+=_){let O;if(l)O=String.fromCharCode(w),O==="\\"&&(O="");else if(O=String(w),T){let Q=E-O.length;if(Q>0){let z=new Array(Q+1).join("0");w<0?O="-"+z+O.slice(1):O=z+O}}A.push(O)}}else{A=[];for(let m=0;m<f.length;m++)A.push.apply(A,PP(f[m],t,!1))}for(let m=0;m<A.length;m++)for(let g=0;g<s.length&&n.length<t;g++){let E=o+A[m]+s[g];(!r||c||E)&&n.push(E)}}return n}var FP=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var oQr={"[: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]},UP=e=>e.replace(/[[\]\\-]/g,"\\$&"),sQr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Let=e=>e.join(""),Pet=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],o=r+1,s=!1,a=!1,l=!1,c=!1,u=r,f="";e:for(;o<e.length;){let E=e.charAt(o);if((E==="!"||E==="^")&&o===r+1){c=!0,o++;continue}if(E==="]"&&s&&!l){u=o+1;break}if(s=!0,E==="\\"&&!l){l=!0,o++;continue}if(E==="["&&!l){for(let[_,[C,S,T]]of Object.entries(oQr))if(e.startsWith(_,o)){if(f)return["$.",!1,e.length-r,!0];o+=_.length,T?i.push(C):n.push(C),a=a||S;continue e}}if(l=!1,f){E>f?n.push(UP(f)+"-"+UP(E)):E===f&&n.push(UP(E)),f="",o++;continue}if(e.startsWith("-]",o+1)){n.push(UP(E+"-")),o+=2;continue}if(e.startsWith("-",o+1)){f=E,o+=2;continue}n.push(UP(E)),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 E=n[0].length===2?n[0].slice(-1):n[0];return[sQr(E),!1,u-r,!1]}let A="["+(c?"^":"")+Let(n)+"]",m="["+(c?"":"^")+Let(i)+"]";return[n.length&&i.length?"("+A+"|"+m+")":n.length?A:m,a,u-r,!0]};var dA=(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 aQr=new Set(["!","?","+","*","@"]),Fet=e=>aQr.has(e),lQr="(?!(?:^|/)\\.\\.?(?:$|/))",qj="(?!\\.)",cQr=new Set(["[","."]),uQr=new Set(["..","."]),dQr=new Set("().*{}+?[]^$\\!"),fQr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),mEe="[^/]",Uet=mEe+"*?",Het=mEe+"+?",RN=class e{type;#e;#t;#r=!1;#n=[];#o;#i;#l;#s=!1;#a;#d;#p=!1;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.#n.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let t of this.#n)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.#n.map(t=>String(t)).join("|")+")":this.#d=this.#n.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.#n.length;i++)for(let o of t.#n){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#n[i])}r=n,n=r.#o}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof e&&r.#o===this))throw new Error("invalid part: "+r);this.#n.push(r)}}toJSON(){let t=this.type===null?this.#n.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#n.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.#n[r];if(!(n instanceof e&&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.#n.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 e(this.type,t);for(let n of this.#n)r.copyIn(n);return r}static#c(t,r,n,i){let o=!1,s=!1,a=-1,l=!1;if(r.type===null){let m=n,g="";for(;m<t.length;){let E=t.charAt(m++);if(o||E==="\\"){o=!o,g+=E;continue}if(s){m===a+1?(E==="^"||E==="!")&&(l=!0):E==="]"&&!(m===a+2&&l)&&(s=!1),g+=E;continue}else if(E==="["){s=!0,a=m,l=!1,g+=E;continue}if(!i.noext&&Fet(E)&&t.charAt(m)==="("){r.push(g),g="";let _=new e(E,r);m=e.#c(t,_,m,i),r.push(_);continue}g+=E}return r.push(g),m}let c=n+1,u=new e(null,r),f=[],A="";for(;c<t.length;){let m=t.charAt(c++);if(o||m==="\\"){o=!o,A+=m;continue}if(s){c===a+1?(m==="^"||m==="!")&&(l=!0):m==="]"&&!(c===a+2&&l)&&(s=!1),A+=m;continue}else if(m==="["){s=!0,a=c,l=!1,A+=m;continue}if(Fet(m)&&t.charAt(c)==="("){u.push(A),A="";let g=new e(m,u);u.push(g),c=e.#c(t,g,c,i);continue}if(m==="|"){u.push(A),A="",f.push(u),u=new e(null,r);continue}if(m===")")return A===""&&r.#n.length===0&&(r.#p=!0),u.push(A),A="",r.push(...f,u),c;A+=m}return r.type=null,r.#t=void 0,r.#n=[t.substring(n-1)],c}static fromGlob(t,r={}){let n=new e(null,void 0,r);return e.#c(t,n,0,r),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.#f(),!this.type){let l=this.isStart()&&this.isEnd()&&!this.#n.some(m=>typeof m!="string"),c=this.#n.map(m=>{let[g,E,_,C]=typeof m=="string"?e.#h(m,this.#t,l):m.toRegExpSource(t);return this.#t=this.#t||_,this.#r=this.#r||C,g}).join(""),u="";if(this.isStart()&&typeof this.#n[0]=="string"&&!(this.#n.length===1&&uQr.has(this.#n[0]))){let g=cQr,E=r&&g.has(c.charAt(0))||c.startsWith("\\.")&&g.has(c.charAt(2))||c.startsWith("\\.\\.")&&g.has(c.charAt(4)),_=!r&&!t&&g.has(c.charAt(0));u=E?lQr:_?qj:""}let f="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(f="(?:$|\\/)"),[u+c+f,dA(c),this.#t=!!this.#t,this.#r]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#A(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString();return this.#n=[l],this.type=null,this.#t=void 0,[l,dA(this.toString()),!1,!1]}let s=!n||t||r||!qj?"":this.#A(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?qj:"")+Het;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?qj:"")+Uet+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,dA(o),this.#t=!!this.#t,this.#r]}#A(t){return this.#n.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,o,s]=r.toRegExpSource(t);return this.#r=this.#r||s,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#h(t,r,n=!1){let i=!1,o="",s=!1;for(let a=0;a<t.length;a++){let l=t.charAt(a);if(i){i=!1,o+=(dQr.has(l)?"\\":"")+l;continue}if(l==="\\"){a===t.length-1?o+="\\\\":i=!0;continue}if(l==="["){let[c,u,f,A]=Pet(t,a);if(f){o+=c,s=s||u,a+=f-1,r=r||A;continue}}if(l==="*"){o+=n&&t==="*"?Het:Uet,r=!0;continue}if(l==="?"){o+=mEe,r=!0;continue}o+=fQr(l)}return[o,dA(t),!!r,s]}};var NN=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var tc=(e,t,r={})=>(FP(t),!r.nocomment&&t.charAt(0)==="#"?!1:new pf(t,r).match(e)),pQr=/^\*+([^+@!?\*\[\(]*)$/,mQr=e=>t=>!t.startsWith(".")&&t.endsWith(e),AQr=e=>t=>t.endsWith(e),gQr=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),hQr=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),EQr=/^\*+\.\*+$/,_Qr=e=>!e.startsWith(".")&&e.includes("."),yQr=e=>e!=="."&&e!==".."&&e.includes("."),bQr=/^\.\*+$/,CQr=e=>e!=="."&&e!==".."&&e.startsWith("."),SQr=/^\*+$/,IQr=e=>e.length!==0&&!e.startsWith("."),TQr=e=>e.length!==0&&e!=="."&&e!=="..",vQr=/^\?+([^+@!?\*\[\(]*)?$/,xQr=([e,t=""])=>{let r=$et([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},wQr=([e,t=""])=>{let r=zet([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},DQr=([e,t=""])=>{let r=zet([e]);return t?n=>r(n)&&n.endsWith(t):r},RQr=([e,t=""])=>{let r=$et([e]);return t?n=>r(n)&&n.endsWith(t):r},$et=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},zet=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},Yet=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",qet={win32:{sep:"\\"},posix:{sep:"/"}},NQr=Yet==="win32"?qet.win32.sep:qet.posix.sep;tc.sep=NQr;var ec=Symbol("globstar **");tc.GLOBSTAR=ec;var BQr="[^/]",OQr=BQr+"*?",kQr="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",MQr="(?:(?!(?:\\/|^)\\.).)*?",QQr=(e,t={})=>r=>tc(r,e,t);tc.filter=QQr;var Mp=(e,t={})=>Object.assign({},e,t),LQr=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return tc;let t=tc;return Object.assign((n,i,o={})=>t(n,i,Mp(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,Mp(e,o))}static defaults(i){return t.defaults(Mp(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,Mp(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,Mp(e,o))}},unescape:(n,i={})=>t.unescape(n,Mp(e,i)),escape:(n,i={})=>t.escape(n,Mp(e,i)),filter:(n,i={})=>t.filter(n,Mp(e,i)),defaults:n=>t.defaults(Mp(e,n)),makeRe:(n,i={})=>t.makeRe(n,Mp(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,Mp(e,i)),match:(n,i,o={})=>t.match(n,i,Mp(e,o)),sep:t.sep,GLOBSTAR:ec})};tc.defaults=LQr;var jet=(e,t={})=>(FP(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Qet(e));tc.braceExpand=jet;var PQr=(e,t={})=>new pf(e,t).makeRe();tc.makeRe=PQr;var FQr=(e,t,r={})=>{let n=new pf(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};tc.match=FQr;var Get=/[?*]|[+@!]\(.*?\)|\[|\]/,UQr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),pf=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,r={}){FP(t),r=r||{},this.options=r,this.pattern=t,this.platform=r.platform||Yet,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!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]==="?"||!Get.test(o[2]))&&!Get.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=0;n<t.length;n++)for(let i=0;i<t[n].length;i++)t[n][i]==="**"&&(t[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!=="**"&&(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=this.options;if(this.isWindows){let E=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),_=!E&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),C=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),S=!C&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),T=_?3:E?0:void 0,w=S?3:C?0:void 0;if(typeof T=="number"&&typeof w=="number"){let[O,Q]=[t[T],r[w]];O.toLowerCase()===Q.toLowerCase()&&(r[w]=O,w>T?r=r.slice(w):T>w&&(t=t.slice(T)))}}let{optimizationLevel:o=1}=this.options;o>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:r}),this.debug("matchOne",t.length,r.length);for(var s=0,a=0,l=t.length,c=r.length;s<l&&a<c;s++,a++){this.debug("matchOne loop");var u=r[a],f=t[s];if(this.debug(r,u,f),u===!1)return!1;if(u===ec){this.debug("GLOBSTAR",[r,u,f]);var A=s,m=a+1;if(m===c){for(this.debug("** at the end");s<l;s++)if(t[s]==="."||t[s]===".."||!i.dot&&t[s].charAt(0)===".")return!1;return!0}for(;A<l;){var g=t[A];if(this.debug(`
580
+ ]`}function S(){let ce=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,ve=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,Se=e[t]==="\\";if(Se&&(t++,Se=!0),OP(e[t])){let _e=Xhe(e[t])?Xhe:eEe(e[t])?eEe:kj(e[t])?kj:Zhe,De=t,K=r.length,Y='"';for(t++;;){if(t>=e.length){let Re=M(t-1);return!ce&&BP(e.charAt(Re))?(t=De,r=r.substring(0,K),S(!0)):(Y=kp(Y,'"'),r+=Y,!0)}if(t===ve)return Y=kp(Y,'"'),r+=Y,!0;if(_e(e[t])){let Re=t,We=Y.length;if(Y+='"',t++,r+=Y,s(!1),ce||t>=e.length||BP(e[t])||OP(e[t])||Gb(e[t]))return T(),!0;let Je=M(Re-1),Ge=e.charAt(Je);if(Ge===",")return t=De,r=r.substring(0,K),S(!1,Je);if(BP(Ge))return t=De,r=r.substring(0,K),S(!0);r=r.substring(0,K),t=Re+1,Y=`${Y.substring(0,We)}\\${Y.substring(We)}`}else if(ce&&Khe(e[t])){if(e[t-1]===":"&&Vhe.test(e.substring(De+1,t+2)))for(;t<e.length&&Whe.test(e[t]);)Y+=e[t],t++;return Y=kp(Y,'"'),r+=Y,T(),!0}else if(e[t]==="\\"){let Re=e.charAt(t+1);if(AMr[Re]!==void 0)Y+=e.slice(t,t+2),t+=2;else if(Re==="u"){let Je=2;for(;Je<6&&net(e[t+Je]);)Je++;Je===6?(Y+=e.slice(t,t+6),t+=6):t+Je>=e.length?t=e.length:xe()}else Y+=Re,t+=2}else{let Re=e.charAt(t);Re==='"'&&e[t-1]!=="\\"?(Y+=`\\${Re}`,t++):oet(Re)?(Y+=mMr[Re],t++):(iet(Re)||le(Re),Y+=Re,t++)}Se&&m()}}return!1}function T(){let ce=!1;for(s();e[t]==="+";){ce=!0,t++,s(),r=xN(r,'"',!0);let ve=r.length;S()?r=cet(r,ve,1):r=kp(r,'"')}return ce}function w(){let ce=t;if(e[t]==="-"){if(t++,G())return H(ce),!0;if(!Gb(e[t]))return t=ce,!1}for(;Gb(e[t]);)t++;if(e[t]==="."){if(t++,G())return H(ce),!0;if(!Gb(e[t]))return t=ce,!1;for(;Gb(e[t]);)t++}if(e[t]==="e"||e[t]==="E"){if(t++,(e[t]==="-"||e[t]==="+")&&t++,G())return H(ce),!0;if(!Gb(e[t]))return t=ce,!1;for(;Gb(e[t]);)t++}if(!G())return t=ce,!1;if(t>ce){let ve=e.slice(ce,t),Se=/^0\d/.test(ve);return r+=Se?`"${ve}"`:ve,!0}return!1}function O(){return Q("true","true")||Q("false","false")||Q("null","null")||Q("True","true")||Q("False","false")||Q("None","null")}function Q(ce,ve){return e.slice(t,t+ce.length)===ce?(r+=ve,t+=ce.length,!0):!1}function z(ce){let ve=t;if(Yhe(e[t])){for(;t<e.length&&jhe(e[t]);)t++;let Se=t;for(;qb(e,Se);)Se++;if(e[Se]==="(")return t=Se+1,o(),e[t]===")"&&(t++,e[t]===";"&&t++),!0}for(;t<e.length&&!Khe(e[t])&&!OP(e[t])&&(!ce||e[t]!==":");)t++;if(e[t-1]===":"&&Vhe.test(e.substring(ve,t+2)))for(;t<e.length&&Whe.test(e[t]);)t++;if(t>ve){for(;qb(e,t-1)&&t>0;)t--;let Se=e.slice(ve,t);return r+=Se==="undefined"?"null":JSON.stringify(Se),e[t]==='"'&&t++,!0}}function V(){if(e[t]==="/"){let ce=t;for(t++;t<e.length&&(e[t]!=="/"||e[t-1]==="\\");)t++;return t++,r+=JSON.stringify(e.substring(ce,t)),!0}}function M(ce){let ve=ce;for(;ve>0&&qb(e,ve);)ve--;return ve}function G(){return t>=e.length||BP(e[t])||qb(e,t)}function H(ce){r+=`${e.slice(ce,t)}0`}function le(ce){throw new h0(`Invalid character ${JSON.stringify(ce)}`,t)}function pe(){throw new h0(`Unexpected character ${JSON.stringify(e[t])}`,t)}function k(){throw new h0("Unexpected end of json string",e.length)}function fe(){throw new h0("Object key expected",t)}function Ee(){throw new h0("Colon expected",t)}function xe(){let ce=e.slice(t,t+6);throw new h0(`Invalid unicode character "${ce}"`,t)}}function gMr(e,t){return e[t]==="*"&&e[t+1]==="/"}He();function $b(e){if(!e)return null;try{return JSON.parse(e)}catch(t){return ae(`Failed to parse JSON: ${e}`,t),null}}function tEe(e){if(!e)return null;try{let t=e.match(/(\{[\s\S]*\})|(\[[\s\S]*\])/);return t&&(e=t[0]),e=oa(e),JSON.parse(e)}catch(t){return ae(`Failed to parse JSON: ${e}`,t),null}}He();wN();var met={allowedTools:[],context:{},dontCrawlDirectory:!1,enableArchitectTool:!1,mcpContextUris:[],mcpServers:{},approvedMcprcServers:[],rejectedMcprcServers:[],hasTrustDialogAccepted:!1};function fet(e){let t={...met};return e===EMr()&&(t.dontCrawlDirectory=!0),t}var E0={mcpServers:{},numStartups:0,autoUpdaterStatus:"disabled",theme:"dark",preferredNotifChannel:"iterm2",verbose:!1,customApiKeyResponses:{approved:[],rejected:[]}};var _fi={...E0,autoUpdaterStatus:"disabled"},yfi={...met};function Io(e){get(Vg,{...e,projects:Mj(Vg,E0).projects},E0)}function pn(){return Mj(Vg,E0)}function Kg(e){return e.slice(-20)}function Aet(e){let t=pn();return t.customApiKeyResponses?.approved?.includes(e)?"approved":t.customApiKeyResponses?.rejected?.includes(e)?"rejected":"new"}function get(e,t,r){let n=Object.fromEntries(Object.entries(t).filter(([i,o])=>JSON.stringify(o)!==JSON.stringify(r[i])||i=="mcpServers"));hMr(e,JSON.stringify(n,null,2),"utf-8")}var yMr=!1;function Mj(e,t,r){if(!yMr)throw new Error("Config accessed before allowed.");if(!rEe(e))return II(t);try{let n=nEe(e,"utf-8");try{let i=JSON.parse(n);return{...II(t),...i}}catch(i){let o=i instanceof Error?i.message:String(i);throw new kP(o,e,t)}}catch(n){if(n instanceof kP&&r)throw n;return II(t)}}function het(e){let t=gd();t.rejectedMcprcServers&&t.rejectedMcprcServers.includes(e)&&(t.rejectedMcprcServers=t.rejectedMcprcServers.filter(r=>r!==e)),eT(t)}function Eet(e){let t=gd();t.rejectedMcprcServers||(t.rejectedMcprcServers=[]),t.rejectedMcprcServers.includes(e)||t.rejectedMcprcServers.push(e),t.approvedMcprcServers&&t.approvedMcprcServers.includes(e)&&(t.approvedMcprcServers=t.approvedMcprcServers.filter(r=>r!==e)),eT(t)}function gd(){let e=pet(ke()),t=Mj(Vg,E0);if(!t.projects)return fet(e);let r=t.projects[e]??fet(e);return typeof r.allowedTools=="string"&&(r.allowedTools=$b(r.allowedTools)??[]),r}function eT(e){let t=Mj(Vg,E0);get(Vg,{...t,projects:{...t.projects,[pet(ke())]:e}},E0)}var MP=Le(()=>{let e=det(ke(),".mcp.json");if(!rEe(e))return{};try{let t=nEe(e,"utf-8"),r=$b(t);if(r&&typeof r=="object")return r=r.mcpServers,ft("tengu_mcprc_found",{numServers:Object.keys(r).length.toString()}),r}catch{}return{}},()=>{let e=ke(),t=det(e,".mcp.json");if(rEe(t))try{let r=nEe(t,"utf-8");return`${e}:${r}`}catch{return e}return e});function Qj(){let e=pn();if(e.userID)return e.userID;let t=_Mr(32).toString("hex");return Io({...e,userID:t}),t}var bMr={bashBorder:"#ff0087",claude:"#D97757",permission:"#5769f7",secondaryBorder:"#999",text:"#000",secondaryText:"#666",suggestion:"#5769f7",success:"#2c7a39",error:"#ab2b3f",warning:"#966c1e",diff:{added:"#69db7c",removed:"#ffa8b4",addedDimmed:"#c7e1cb",removedDimmed:"#fdd2d8"}},CMr={bashBorder:"#0066cc",claude:"#ff9933",permission:"#3366ff",secondaryBorder:"#999",text:"#000",secondaryText:"#666",suggestion:"#3366ff",success:"#006699",error:"#cc0000",warning:"#ff9900",diff:{added:"#99ccff",removed:"#ffcccc",addedDimmed:"#d1e7fd",removedDimmed:"#ffe9e9"}},SMr={bashBorder:"#fd5db1",claude:"#D97757",permission:"#b1b9f9",secondaryBorder:"#888",text:"#fff",secondaryText:"#999",suggestion:"#b1b9f9",success:"#4eba65",error:"#ff6b80",warning:"#ffc107",diff:{added:"#225c2b",removed:"#7a2936",addedDimmed:"#47584a",removedDimmed:"#69484d"}},IMr={bashBorder:"#3399ff",claude:"#ff9933",permission:"#99ccff",secondaryBorder:"#888",text:"#fff",secondaryText:"#999",suggestion:"#99ccff",success:"#3399ff",error:"#ff6666",warning:"#ffcc00",diff:{added:"#004466",removed:"#660000",addedDimmed:"#3e515b",removedDimmed:"#3e2c2c"}};function Me(e){let t=pn();switch(e??t.theme){case"light":return bMr;case"light-daltonized":return CMr;case"dark-daltonized":return IMr;default:return SMr}}Fe();function tn(){return iEe.createElement(v,null,"\xA0\xA0\u23BF \xA0",iEe.createElement(v,{color:Me().error},"No (tell ",At," what to do differently)"))}Fe();er();import{resolve as oEe,dirname as TMr,join as vMr}from"path";import{createRequire as xMr}from"module";import{fileURLToPath as wMr}from"node:url";import{existsSync as sEe}from"fs";var DMr=xMr(import.meta.url),RMr=wMr(import.meta.url),_et=TMr(RMr),uEe=Le(()=>{let e=process.platform,t=process.arch,r=process.env.HCODE_TREE_SITTER_BASH_PATH?oEe(process.env.HCODE_TREE_SITTER_BASH_PATH,`${t}-${e}`,"tree-sitter-bash.node"):null,n=oEe(_et,"vendor/tree-sitter-bash",`${t}-${e}`,"tree-sitter-bash.node"),i=oEe(_et,"../../vendor/tree-sitter-bash",`${t}-${e}`,"tree-sitter-bash.node"),o=vMr(process.cwd(),"vendor/tree-sitter-bash",`${t}-${e}`,"tree-sitter-bash.node"),s=r&&sEe(r)?r:sEe(n)?n:sEe(i)?i:o;return DMr(s)});function DN(e){let r=uEe().parse(e),n=[];function i(o){if(o.type==="list"&&o.children){for(let s of o.children)if(s.type==="command"||s.type==="pipeline"){let a=s.text.trim();a&&n.push(a)}else s.type==="list"&&i(s);return}if(o.type==="program"&&o.children){for(let s of o.children)if(s.type==="command"){let a=s.text.trim();a&&n.push(a)}else if(s.type==="list")i(s);else if(s.type==="pipeline"){let a=s.text.trim();a&&n.push(a)}return}if(o.type==="pipeline"&&o.children){let s=o.text.trim();s&&n.push(s);return}if(o.type==="command"){let s=o.text.trim();s&&n.push(s);return}if(o.children)for(let s of o.children)i(s)}return i(r),n.length===0&&e.trim()?[e.trim()]:n}function bet(e){let t=DN(e),r=yet(e),n=new Map;for(let i of t){let o=yet(i);n.set(i,o)}return{...r,subcommandPrefixes:n}}function yet(e){let t=e.trim(),r=[/\$\([^)]*\)/,/`[^`]*`/,/\$\{[^}]*\}/,/\$[A-Za-z_][A-Za-z0-9_]*/];for(let i of r)if(i.test(t))return{commandInjectionDetected:!0};return{commandPrefix:BMr(t),commandInjectionDetected:!1}}var NMr=new Map([["git",new Set(["add","branch","checkout","clone","commit","config","diff","fetch","grep","init","log","merge","mv","pull","push","rebase","remote","reset","restore","revert","rm","show","stash","status","switch","tag"])],["npm",new Set(["ci","install","publish","run","test","uninstall","exec"])],["npx",new Set([])],["yarn",new Set(["add","install","remove","run","test","exec"])],["docker",new Set(["build","compose","exec","logs","ps","pull","push","run","stop","buildx"])],["cargo",new Set(["build","check","clean","clippy","doc","fmt","install","new","run","test","update"])],["go",new Set(["build","fmt","get","install","mod","run","test","vet"])],["pip",new Set(["install","uninstall"])],["python",new Set(["-m"])],["pytest",new Set([])]]);function BMr(e){let t=e.trim();if(!t)return null;try{let i=function(c){if(c.type==="command")return c;if(c.children)for(let u of c.children){let f=i(u);if(f)return f}return null},n=uEe().parse(e),o=i(n);if(!o||!o.children)return t.split(/\s+/)[0]||null;let s=[];for(let c of o.children)if(c.type==="command_name"&&c.children){for(let u of c.children)if(u.type==="word"){s.push(u);break}}else c.type==="word"&&s.push(c);if(s.length===0)return t.split(/\s+/)[0]||null;let a=s[0].text,l=NMr.get(a);if(l&&s.length>=2){let c=s[1].text;if(l.has(c))return`${a} ${c}`}return a}catch{return t.split(/\s+/)[0]||null}}var OMr=new Set(["docker ps","docker images","cal","uptime","cat","head","tail","wc","stat","strings","hexdump","od","nl","id","uname","free","df","du","locale","groups","nproc","basename","dirname","realpath","cut","paste","tr","column","tac","rev","fold","expand","unexpand","fmt","comm","cmp","numfmt","readlink","diff","true","false","sleep","which","type","expr","test","getconf","seq","tsort","pr","printf"]),kMr=[/^echo(?:\s+(?:'[^']*'|"[^"$<>\n\r]*"|[^|;&`$(){}><#\\"'\s]+))*(?:\s+2>&1)?\s*$/,/^pwd$/,/^whoami$/,/^node -v$/,/^node --version$/,/^python --version$/,/^python3 --version$/,/^history(?:\s+\d+)?\s*$/,/^alias$/,/^arch(?:\s+(?:--help|-h))?\s*$/,/^ip addr$/,/^ifconfig(?:\s+[a-zA-Z][a-zA-Z0-9_-]*)?\s*$/,/^hcode -h$/,/^hcode --help$/,/^uniq(?:\s+(?:-[a-zA-Z]+|--[a-zA-Z-]+(?:=\S+)?|-[fsw]\s+\d+))*(?:\s|$)\s*$/,/^jq(?!\s+.*(?:-f\b|--from-file|--rawfile|--slurpfile|--run-tests|-L\b|--library-path|\benv\b|\$ENV\b))(?:\s+(?:-[a-zA-Z]+|--[a-zA-Z-]+(?:=\S+)?))*(?:\s+'[^'`]*'|\s+"[^"`]*"|\s+[^-\s'"][^\s]*)+\s*$/,/^cd(?:\s+(?:'[^']*'|"[^"]*"|[^\s;|&`$(){}><#\\]+))?$/,/^ls(?:\s+[^<>()$`|{}&;\n\r]*)?$/,/^find(?:\s+(?:\\[()]|(?!-delete\b|-exec\b|-execdir\b|-ok\b|-okdir\b|-fprint0?\b|-fls\b|-fprintf\b)[^<>()$`|{}&;\n\r\s]|\s)+)?$/],QP={"--all":"none","--branches":"none","--tags":"none","--remotes":"none"},Lj={"--since":"string","--after":"string","--until":"string","--before":"string"},Pj={"--oneline":"none","--graph":"none","--decorate":"none","--no-decorate":"none","--date":"string","--relative-date":"none"},Fj={"--max-count":"number","-n":"number"},Uj={"--stat":"none","--numstat":"none","--shortstat":"none","--name-only":"none","--name-status":"none"},LP={"--color":"none","--no-color":"none"},aEe={"--patch":"none","-p":"none","--no-patch":"none","--no-ext-diff":"none","-s":"none"},lEe={"--author":"string","--committer":"string","--grep":"string"},Hj={xargs:{safeFlags:{"-I":"{}","-n":"number","-P":"number","-L":"number","-s":"number","-E":"EOF","-0":"none","-t":"none","-r":"none","-x":"none","-d":"char"}},"git diff":{safeFlags:{...Uj,...LP,"--dirstat":"none","--summary":"none","--patch-with-stat":"none","--word-diff":"none","--word-diff-regex":"string","--color-words":"none","--no-renames":"none","--no-ext-diff":"none","--check":"none","--ws-error-highlight":"string","--full-index":"none","--binary":"none","--abbrev":"number","--break-rewrites":"none","--find-renames":"none","--find-copies":"none","--find-copies-harder":"none","--irreversible-delete":"none","--diff-algorithm":"string","--histogram":"none","--patience":"none","--minimal":"none","--ignore-space-at-eol":"none","--ignore-space-change":"none","--ignore-all-space":"none","--ignore-blank-lines":"none","--inter-hunk-context":"number","--function-context":"none","--exit-code":"none","--quiet":"none","--cached":"none","--staged":"none","--pickaxe-regex":"none","--pickaxe-all":"none","--no-index":"none","--relative":"string","--diff-filter":"string","-p":"none","-u":"none","-U":"number","--unified":"number","-s":"none","-M":"none","-C":"none","-B":"none","-D":"none","-l":"none","-S":"string","-G":"string","-O":"string","-R":"none"}},"git log":{safeFlags:{...Pj,...QP,...Lj,...Fj,...Uj,...LP,...aEe,...lEe,"--abbrev-commit":"none","--full-history":"none","--dense":"none","--sparse":"none","--simplify-merges":"none","--ancestry-path":"none","--source":"none","--first-parent":"none","--merges":"none","--no-merges":"none","--reverse":"none","--walk-reflogs":"none","--skip":"number","--max-age":"number","--min-age":"number","--no-min-parents":"none","--no-max-parents":"none","--follow":"none","--no-walk":"none","--left-right":"none","--cherry-mark":"none","--cherry-pick":"none","--boundary":"none","--topo-order":"none","--date-order":"none","--author-date-order":"none","--pretty":"string","--format":"string","--diff-filter":"string","-S":"string","-G":"string","--pickaxe-regex":"none","--pickaxe-all":"none"}},"git show":{safeFlags:{...Pj,...Uj,...LP,...aEe,"--abbrev-commit":"none","--word-diff":"none","--word-diff-regex":"string","--color-words":"none","--pretty":"string","--format":"string","--first-parent":"none","--raw":"none","--diff-filter":"string","-m":"none","--quiet":"none"}},"git shortlog":{safeFlags:{...QP,...Lj,"-s":"none","--summary":"none","-n":"none","--numbered":"none","-e":"none","--email":"none","-c":"none","--committer":"none","--group":"string","--format":"string","--no-merges":"none","--author":"string"}},"git reflog":{safeFlags:{...Pj,...QP,...Lj,...Fj,...lEe},additionalCommandIsDangerousCallback:(e,t)=>{let r=new Set(["expire","delete","exists"]);for(let n of t)if(!(!n||n.startsWith("-")))return!!r.has(n);return!1}},"git stash list":{safeFlags:{...Pj,...QP,...Fj}},"git stash show":{safeFlags:{...Uj,...LP,...aEe,"--word-diff":"none","--word-diff-regex":"string","--diff-filter":"string","--abbrev":"number"}},"git ls-remote":{safeFlags:{"--branches":"none","-b":"none","--tags":"none","-t":"none","--heads":"none","-h":"none","--refs":"none","--quiet":"none","-q":"none","--exit-code":"none","--get-url":"none","--symref":"none","--sort":"string"}},"git status":{safeFlags:{"--short":"none","-s":"none","--branch":"none","-b":"none","--porcelain":"none","--long":"none","--verbose":"none","-v":"none","--untracked-files":"string","-u":"string","--ignored":"none","--ignore-submodules":"string","--column":"none","--no-column":"none","--ahead-behind":"none","--no-ahead-behind":"none","--renames":"none","--no-renames":"none","--find-renames":"string","-M":"string"}},"git blame":{safeFlags:{...LP,"-L":"string","--porcelain":"none","-p":"none","--line-porcelain":"none","--incremental":"none","--root":"none","--show-stats":"none","--show-name":"none","--show-number":"none","-n":"none","--show-email":"none","-e":"none","-f":"none","--date":"string","-w":"none","--ignore-rev":"string","--ignore-revs-file":"string","-M":"none","-C":"none","--score-debug":"none","--abbrev":"number","-s":"none","-l":"none","-t":"none"}},"git ls-files":{safeFlags:{"--cached":"none","-c":"none","--deleted":"none","-d":"none","--modified":"none","-m":"none","--others":"none","-o":"none","--ignored":"none","-i":"none","--stage":"none","-s":"none","--killed":"none","-k":"none","--unmerged":"none","-u":"none","--directory":"none","--no-empty-directory":"none","--eol":"none","--full-name":"none","--abbrev":"number","--debug":"none","-z":"none","-t":"none","-v":"none","-f":"none","--exclude":"string","-x":"string","--exclude-from":"string","-X":"string","--exclude-per-directory":"string","--exclude-standard":"none","--error-unmatch":"none","--recurse-submodules":"none"}},"git config --get":{safeFlags:{"--local":"none","--global":"none","--system":"none","--worktree":"none","--default":"string","--type":"string","--bool":"none","--int":"none","--bool-or-int":"none","--path":"none","--expiry-date":"none","-z":"none","--null":"none","--name-only":"none","--show-origin":"none","--show-scope":"none"}},"git remote show":{safeFlags:{"-n":"none"},additionalCommandIsDangerousCallback:(e,t)=>{let r=t.filter(n=>n!=="-n");return r.length!==1?!0:!/^[a-zA-Z0-9_-]+$/.test(r[0])}},"git remote":{safeFlags:{"-v":"none","--verbose":"none"},additionalCommandIsDangerousCallback:(e,t)=>t.some(r=>r!=="-v"&&r!=="--verbose")},"git merge-base":{safeFlags:{"--is-ancestor":"none","--fork-point":"none","--octopus":"none","--independent":"none","--all":"none"}},"git rev-parse":{safeFlags:{"--verify":"none","--short":"string","--abbrev-ref":"none","--symbolic":"none","--symbolic-full-name":"none","--show-toplevel":"none","--show-cdup":"none","--show-prefix":"none","--git-dir":"none","--git-common-dir":"none","--absolute-git-dir":"none","--show-superproject-working-tree":"none","--is-inside-work-tree":"none","--is-inside-git-dir":"none","--is-bare-repository":"none","--is-shallow-repository":"none","--is-shallow-update":"none","--path-prefix":"none"}},"git rev-list":{safeFlags:{...QP,...Lj,...Fj,...lEe,"--count":"none","--reverse":"none","--first-parent":"none","--ancestry-path":"none","--merges":"none","--no-merges":"none","--min-parents":"number","--max-parents":"number","--no-min-parents":"none","--no-max-parents":"none","--skip":"number","--max-age":"number","--min-age":"number","--walk-reflogs":"none","--oneline":"none","--abbrev-commit":"none","--pretty":"string","--format":"string","--abbrev":"number","--full-history":"none","--dense":"none","--sparse":"none","--source":"none","--graph":"none"}},"git describe":{safeFlags:{"--tags":"none","--match":"string","--exclude":"string","--long":"none","--abbrev":"number","--always":"none","--contains":"none","--first-match":"none","--exact-match":"none","--candidates":"number","--dirty":"none","--broken":"none"}},"git cat-file":{safeFlags:{"-t":"none","-s":"none","-p":"none","-e":"none","--batch-check":"none","--allow-undetermined-type":"none"}},"git for-each-ref":{safeFlags:{"--format":"string","--sort":"string","--count":"number","--contains":"string","--no-contains":"string","--merged":"string","--no-merged":"string","--points-at":"string"}},"git grep":{safeFlags:{"-e":"string","-E":"none","--extended-regexp":"none","-G":"none","--basic-regexp":"none","-F":"none","--fixed-strings":"none","-P":"none","--perl-regexp":"none","-i":"none","--ignore-case":"none","-v":"none","--invert-match":"none","-w":"none","--word-regexp":"none","-n":"none","--line-number":"none","-c":"none","--count":"none","-l":"none","--files-with-matches":"none","-L":"none","--files-without-match":"none","-h":"none","-H":"none","--heading":"none","--break":"none","--full-name":"none","--color":"none","--no-color":"none","-o":"none","--only-matching":"none","-A":"number","--after-context":"number","-B":"number","--before-context":"number","-C":"number","--context":"number","--and":"none","--or":"none","--not":"none","--max-depth":"number","--untracked":"none","--no-index":"none","--recurse-submodules":"none","--cached":"none","--threads":"number","-q":"none","--quiet":"none"}},"git worktree list":{safeFlags:{"--porcelain":"none","-v":"none","--verbose":"none","--expire":"string"}},"git tag":{safeFlags:{"-l":"none","--list":"none","-n":"number","--contains":"string","--no-contains":"string","--merged":"string","--no-merged":"string","--sort":"string","--format":"string","--points-at":"string","--column":"none","--no-column":"none","-i":"none","--ignore-case":"none"},additionalCommandIsDangerousCallback:(e,t)=>{let r=new Set(["--contains","--no-contains","--merged","--no-merged","--points-at","--sort","--format","-n"]),n=!1,i=0,o=!1;for(;i<t.length;){let s=t[i];if(!s){i++;continue}if(s==="--"&&!o){o=!0,i++;continue}if(!o&&s.startsWith("-"))(s==="--list"||s==="-l"||s[0]==="-"&&s[1]!=="-"&&s.length>2&&!s.includes("=")&&s.slice(1).includes("l"))&&(n=!0),s.includes("=")?i++:r.has(s)?i+=2:i++;else{if(!n)return!0;i++}}return!1}},"git branch":{safeFlags:{"-l":"none","--list":"none","-a":"none","--all":"none","-r":"none","--remotes":"none","-v":"none","-vv":"none","--verbose":"none","--color":"none","--no-color":"none","--column":"none","--no-column":"none","--abbrev":"number","--no-abbrev":"none","--contains":"string","--no-contains":"string","--merged":"none","--no-merged":"none","--points-at":"string","--sort":"string","--show-current":"none","-i":"none","--ignore-case":"none"},additionalCommandIsDangerousCallback:(e,t)=>{let r=new Set(["--contains","--no-contains","--points-at","--sort"]),n=new Set(["--merged","--no-merged"]),i=!1,o="",s=0,a=!1;for(;s<t.length;){let l=t[s];if(!l){s++;continue}if(l==="--"&&!a){a=!0,o="",s++;continue}if(!a&&l.startsWith("-"))(l==="--list"||l==="-l"||l[0]==="-"&&l[1]!=="-"&&l.length>2&&!l.includes("=")&&l.slice(1).includes("l"))&&(i=!0),l.includes("=")?(o=l.split("=")[0]??"",s++):r.has(l)?(o=l,s+=2):(o=l,s++);else{let c=n.has(o);if(!i&&!c)return!0;o="",s++}}return!1}},file:{safeFlags:{"--brief":"none","-b":"none","--mime":"none","-i":"none","--mime-type":"none","--mime-encoding":"none","--apple":"none","--check-encoding":"none","-c":"none","--exclude":"string","--exclude-quiet":"string","--print0":"none","-0":"none","-f":"string","-F":"string","--separator":"string","--help":"none","--version":"none","-v":"none","--no-dereference":"none","-h":"none","--dereference":"none","-L":"none","--magic-file":"string","-m":"string","--keep-going":"none","-k":"none","--list":"none","-l":"none","--no-buffer":"none","-n":"none","--preserve-date":"none","-p":"none","--raw":"none","-r":"none","-s":"none","--special-files":"none","--uncompress":"none","-z":"none"}},sed:{safeFlags:{"--expression":"string","-e":"string","--quiet":"none","--silent":"none","-n":"none","--regexp-extended":"none","-r":"none","--posix":"none","-E":"none","--line-length":"number","-l":"number","--zero-terminated":"none","-z":"none","--separate":"none","-s":"none","--unbuffered":"none","-u":"none","--debug":"none","--help":"none","--version":"none"},additionalCommandIsDangerousCallback:e=>/(?:^|\s)(?:-i\S*|--in-place\S*)(?:\s|$)/.test(e)},sort:{safeFlags:{"--ignore-leading-blanks":"none","-b":"none","--dictionary-order":"none","-d":"none","--ignore-case":"none","-f":"none","--general-numeric-sort":"none","-g":"none","--human-numeric-sort":"none","-h":"none","--ignore-nonprinting":"none","-i":"none","--month-sort":"none","-M":"none","--numeric-sort":"none","-n":"none","--random-sort":"none","-R":"none","--reverse":"none","-r":"none","--sort":"string","--stable":"none","-s":"none","--unique":"none","-u":"none","--version-sort":"none","-V":"none","--zero-terminated":"none","-z":"none","--key":"string","-k":"string","--field-separator":"string","-t":"string","--check":"none","-c":"none","--check-char-order":"none","-C":"none","--merge":"none","-m":"none","--buffer-size":"string","-S":"string","--parallel":"number","--batch-size":"number","--help":"none","--version":"none"}},grep:{safeFlags:{"-e":"string","--regexp":"string","-f":"string","--file":"string","-F":"none","--fixed-strings":"none","-G":"none","--basic-regexp":"none","-E":"none","--extended-regexp":"none","-P":"none","--perl-regexp":"none","-i":"none","--ignore-case":"none","--no-ignore-case":"none","-v":"none","--invert-match":"none","-w":"none","--word-regexp":"none","-x":"none","--line-regexp":"none","-c":"none","--count":"none","--color":"string","--colour":"string","-L":"none","--files-without-match":"none","-l":"none","--files-with-matches":"none","-m":"number","--max-count":"number","-o":"none","--only-matching":"none","-q":"none","--quiet":"none","--silent":"none","-s":"none","--no-messages":"none","-b":"none","--byte-offset":"none","-H":"none","--with-filename":"none","-h":"none","--no-filename":"none","--label":"string","-n":"none","--line-number":"none","-T":"none","--initial-tab":"none","-u":"none","--unix-byte-offsets":"none","-Z":"none","--null":"none","-z":"none","--null-data":"none","-A":"number","--after-context":"number","-B":"number","--before-context":"number","-C":"number","--context":"number","--group-separator":"string","--no-group-separator":"none","-a":"none","--text":"none","--binary-files":"string","-D":"string","--devices":"string","-d":"string","--directories":"string","--exclude":"string","--exclude-from":"string","--exclude-dir":"string","--include":"string","-r":"none","--recursive":"none","-R":"none","--dereference-recursive":"none","--line-buffered":"none","-U":"none","--binary":"none","--help":"none","-V":"none","--version":"none"}},rg:{safeFlags:{"-e":"string","--regexp":"string","-f":"string","-i":"none","--ignore-case":"none","-S":"none","--smart-case":"none","-F":"none","--fixed-strings":"none","-w":"none","--word-regexp":"none","-v":"none","--invert-match":"none","-c":"none","--count":"none","-l":"none","--files-with-matches":"none","--files-without-match":"none","-n":"none","--line-number":"none","-o":"none","--only-matching":"none","-A":"number","--after-context":"number","-B":"number","--before-context":"number","-C":"number","--context":"number","-H":"none","-h":"none","--heading":"none","--no-heading":"none","-q":"none","--quiet":"none","--column":"none","-g":"string","--glob":"string","-t":"string","--type":"string","-T":"string","--type-not":"string","--type-list":"none","--hidden":"none","--no-ignore":"none","-u":"none","-m":"number","--max-count":"number","-d":"number","--max-depth":"number","-a":"none","--text":"none","-z":"none","-L":"none","--follow":"none","--color":"string","--json":"none","--stats":"none","--help":"none","--version":"none","--debug":"none","--":"none"}},fd:{safeFlags:{"-h":"none","--help":"none","-V":"none","--version":"none","-H":"none","--hidden":"none","-I":"none","--no-ignore":"none","--no-ignore-vcs":"none","--no-ignore-parent":"none","-s":"none","--case-sensitive":"none","-i":"none","--ignore-case":"none","-g":"none","--glob":"none","--regex":"none","-F":"none","--fixed-strings":"none","-a":"none","--absolute-path":"none","-L":"none","--follow":"none","-p":"none","--full-path":"none","-0":"none","--print0":"none","-d":"number","--max-depth":"number","--min-depth":"number","--exact-depth":"number","-t":"string","--type":"string","-e":"string","--extension":"string","-S":"string","--size":"string","--changed-within":"string","--changed-before":"string","-o":"string","--owner":"string","-E":"string","--exclude":"string","--ignore-file":"string","-c":"string","--color":"string","-j":"number","--threads":"number","--max-buffer-time":"string","--max-results":"number","-1":"none","-q":"none","--quiet":"none","--show-errors":"none","--strip-cwd-prefix":"none","--one-file-system":"none","--prune":"none","--search-path":"string","--base-directory":"string","--path-separator":"string","--batch-size":"number","--no-require-git":"none","--hyperlink":"string","--and":"string","--format":"string"}},fdfind:{safeFlags:{}},sha256sum:{safeFlags:{"-b":"none","--binary":"none","-t":"none","--text":"none","-c":"none","--check":"none","--ignore-missing":"none","--quiet":"none","--status":"none","--strict":"none","-w":"none","--warn":"none","--tag":"none","-z":"none","--zero":"none","--help":"none","--version":"none"}},sha1sum:{safeFlags:{"-b":"none","--binary":"none","-t":"none","--text":"none","-c":"none","--check":"none","--ignore-missing":"none","--quiet":"none","--status":"none","--strict":"none","-w":"none","--warn":"none","--tag":"none","-z":"none","--zero":"none","--help":"none","--version":"none"}},md5sum:{safeFlags:{"-b":"none","--binary":"none","-t":"none","--text":"none","-c":"none","--check":"none","--ignore-missing":"none","--quiet":"none","--status":"none","--strict":"none","-w":"none","--warn":"none","--tag":"none","-z":"none","--zero":"none","--help":"none","--version":"none"}},tree:{safeFlags:{"-a":"none","-d":"none","-l":"none","-f":"none","-x":"none","-L":"number","-P":"string","-I":"string","--gitignore":"none","--gitfile":"string","--ignore-case":"none","--matchdirs":"none","--metafirst":"none","--prune":"none","--info":"none","--infofile":"string","--noreport":"none","--charset":"string","--filelimit":"number","-q":"none","-N":"none","-Q":"none","-p":"none","-u":"none","-g":"none","-s":"none","-h":"none","--si":"none","--du":"none","-D":"none","--timefmt":"string","-F":"none","--inodes":"none","--device":"none","-v":"none","-t":"none","-c":"none","-U":"none","-r":"none","--dirsfirst":"none","--filesfirst":"none","--sort":"string","-i":"none","-A":"none","-S":"none","-n":"none","-C":"none","-X":"none","-J":"none","-H":"string","--nolinks":"none","--hintro":"string","--houtro":"string","-T":"string","--hyperlink":"none","--scheme":"string","--authority":"string","--fromfile":"none","--fromtabfile":"none","--fflinks":"none","--help":"none","--version":"none"}},date:{safeFlags:{"-d":"string","--date":"string","-r":"string","--reference":"string","-u":"none","--utc":"none","--universal":"none","-I":"none","--iso-8601":"string","-R":"none","--rfc-email":"none","--rfc-3339":"string","--debug":"none","--help":"none","--version":"none"},additionalCommandIsDangerousCallback:(e,t)=>{let r=new Set(["-d","--date","-r","--reference","--iso-8601","--rfc-3339"]),n=0;for(;n<t.length;){let i=t[n];if(i.startsWith("--")&&i.includes("=")){n++;continue}if(i.startsWith("-"))r.has(i)?n+=2:n++;else{if(!i.startsWith("+"))return!0;n++}}return!1}},hostname:{safeFlags:{"-f":"none","--fqdn":"none","--long":"none","-s":"none","--short":"none","-i":"none","--ip-address":"none","-I":"none","--all-ip-addresses":"none","-a":"none","--alias":"none","-d":"none","--domain":"none","-A":"none","--all-fqdns":"none","-v":"none","--verbose":"none","-h":"none","--help":"none","-V":"none","--version":"none"},regex:/^hostname(?:\s+(?:-[a-zA-Z]|--[a-zA-Z-]+))*\s*$/},info:{safeFlags:{"-f":"string","--file":"string","-d":"string","--directory":"string","-n":"string","--node":"string","-a":"none","--all":"none","-k":"string","--apropos":"string","-w":"none","--where":"none","--location":"none","--show-options":"none","--vi-keys":"none","--subnodes":"none","-h":"none","--help":"none","--usage":"none","--version":"none"}},man:{safeFlags:{"-a":"none","--all":"none","-d":"none","-f":"none","--whatis":"none","-h":"none","-k":"none","--apropos":"none","-l":"string","-w":"none","-S":"string","-s":"string"}},help:{safeFlags:{"-d":"none","-m":"none","-s":"none"}},ps:{safeFlags:{"-e":"none","-A":"none","-a":"none","-d":"none","-N":"none","--deselect":"none","-f":"none","-F":"none","-l":"none","-j":"none","-y":"none","-w":"none","-ww":"none","--width":"number","-c":"none","-H":"none","--forest":"none","--headers":"none","--no-headers":"none","-n":"string","--sort":"string","-L":"none","-T":"none","-m":"none","-C":"string","-G":"string","-g":"string","-p":"string","--pid":"string","-q":"string","--quick-pid":"string","-s":"string","--sid":"string","-t":"string","--tty":"string","-U":"string","-u":"string","--user":"string","--help":"none","--info":"none","-V":"none","--version":"none"},additionalCommandIsDangerousCallback:(e,t)=>t.some(r=>!r.startsWith("-")&&/^[a-zA-Z]*e[a-zA-Z]*$/.test(r))},base64:{respectsDoubleDash:!1,safeFlags:{"-d":"none","-D":"none","--decode":"none","-b":"number","--break":"number","-w":"number","--wrap":"number","-i":"string","--input":"string","--ignore-garbage":"none","-h":"none","--help":"none","--version":"none"}},netstat:{safeFlags:{"-a":"none","-L":"none","-l":"none","-n":"none","-f":"string","-g":"none","-i":"none","-I":"string","-s":"none","-r":"none","-m":"none","-v":"none"}},ss:{safeFlags:{"-h":"none","--help":"none","-V":"none","--version":"none","-n":"none","--numeric":"none","-r":"none","--resolve":"none","-a":"none","--all":"none","-l":"none","--listening":"none","-o":"none","--options":"none","-e":"none","--extended":"none","-m":"none","--memory":"none","-p":"none","--processes":"none","-i":"none","--info":"none","-s":"none","--summary":"none","-4":"none","--ipv4":"none","-6":"none","--ipv6":"none","-0":"none","--packet":"none","-t":"none","--tcp":"none","-M":"none","--mptcp":"none","-S":"none","--sctp":"none","-u":"none","--udp":"none","-d":"none","--dccp":"none","-w":"none","--raw":"none","-x":"none","--unix":"none","--tipc":"none","--vsock":"none","-f":"string","--family":"string","-A":"string","--query":"string","--socket":"string","-Z":"none","--context":"none","-z":"none","--contexts":"none","-b":"none","--bpf":"none","-E":"none","--events":"none","-H":"none","--no-header":"none","-O":"none","--oneline":"none","--tipcinfo":"none","--tos":"none","--cgroup":"none","--inet-sockopt":"none"}},lsof:{safeFlags:{"-?":"none","-h":"none","-v":"none","-a":"none","-b":"none","-C":"none","-l":"none","-n":"none","-N":"none","-O":"none","-P":"none","-Q":"none","-R":"none","-t":"none","-U":"none","-V":"none","-X":"none","-H":"none","-E":"none","-F":"none","-g":"none","-i":"none","-K":"none","-L":"none","-o":"none","-r":"none","-s":"none","-S":"none","-T":"none","-x":"none","-A":"string","-c":"string","-d":"string","-e":"string","-k":"string","-p":"string","-u":"string"},additionalCommandIsDangerousCallback:(e,t)=>t.some(r=>r==="+m"||r.startsWith("+m"))},pgrep:{safeFlags:{"-d":"string","--delimiter":"string","-l":"none","--list-name":"none","-a":"none","--list-full":"none","-v":"none","--inverse":"none","-w":"none","--lightweight":"none","-c":"none","--count":"none","-f":"none","--full":"none","-g":"string","--pgroup":"string","-G":"string","--group":"string","-i":"none","--ignore-case":"none","-n":"none","--newest":"none","-o":"none","--oldest":"none","-O":"string","--older":"string","-P":"string","--parent":"string","-s":"string","--session":"string","-t":"string","--terminal":"string","-u":"string","--euid":"string","-U":"string","--uid":"string","-x":"none","--exact":"none","-F":"string","--pidfile":"string","-L":"none","--logpidfile":"none","-r":"string","--runstates":"string","--ns":"string","--nslist":"string","--help":"none","-V":"none","--version":"none"}},tput:{safeFlags:{"-T":"string","-V":"none","-x":"none"},additionalCommandIsDangerousCallback:(e,t)=>{let r=new Set(["init","reset","rs1","rs2","rs3","is1","is2","is3","iprog","if","rf","clear","flash","mc0","mc4","mc5","mc5i","mc5p","pfkey","pfloc","pfx","pfxl","smcup","rmcup"]),n=new Set(["-T"]),i=0,o=!1;for(;i<t.length;){let s=t[i];if(s==="--"){o=!0,i++;continue}if(!o&&s.startsWith("-")){if(s==="-S"||!s.startsWith("--")&&s.length>2&&s.includes("S"))return!0;n.has(s)?i+=2:i++}else{if(r.has(s))return!0;i++}}return!1}},"docker logs":{safeFlags:{"--follow":"none","-f":"none","--tail":"string","-n":"string","--timestamps":"none","-t":"none","--since":"string","--until":"string","--details":"none"}},"docker inspect":{safeFlags:{"--format":"string","-f":"string","--type":"string","--size":"none","-s":"none"}},pyright:{respectsDoubleDash:!1,safeFlags:{"--outputjson":"none","--project":"string","-p":"string","--pythonversion":"string","--pythonplatform":"string","--typeshedpath":"string","--venvpath":"string","--level":"string","--stats":"none","--verbose":"none","--version":"none","--dependencies":"none","--warnings":"none"},additionalCommandIsDangerousCallback:(e,t)=>t.some(r=>r==="--watch"||r==="-w")},"gh pr view":{safeFlags:{"--json":"string","--comments":"none","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh pr list":{safeFlags:{"--state":"string","-s":"string","--author":"string","--assignee":"string","--label":"string","--limit":"number","-L":"number","--base":"string","--head":"string","--search":"string","--json":"string","--draft":"none","--app":"string","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh pr diff":{safeFlags:{"--color":"string","--name-only":"none","--patch":"none","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh pr checks":{safeFlags:{"--watch":"none","--required":"none","--fail-fast":"none","--json":"string","--interval":"number","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh pr status":{safeFlags:{"--conflict-status":"none","-c":"none","--json":"string","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh issue view":{safeFlags:{"--json":"string","--comments":"none","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh issue list":{safeFlags:{"--state":"string","-s":"string","--assignee":"string","--author":"string","--label":"string","--limit":"number","-L":"number","--milestone":"string","--search":"string","--json":"string","--app":"string","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh issue status":{safeFlags:{"--json":"string","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh repo view":{safeFlags:{"--json":"string"},additionalCommandIsDangerousCallback:Xl},"gh run list":{safeFlags:{"--branch":"string","-b":"string","--status":"string","-s":"string","--workflow":"string","-w":"string","--limit":"number","-L":"number","--json":"string","--repo":"string","-R":"string","--event":"string","-e":"string","--user":"string","-u":"string","--created":"string","--commit":"string","-c":"string"},additionalCommandIsDangerousCallback:Xl},"gh run view":{safeFlags:{"--log":"none","--log-failed":"none","--exit-status":"none","--verbose":"none","-v":"none","--json":"string","--repo":"string","-R":"string","--job":"string","-j":"string","--attempt":"number","-a":"number"},additionalCommandIsDangerousCallback:Xl},"gh auth status":{safeFlags:{"--active":"none","-a":"none","--hostname":"string","-h":"string","--json":"string"},additionalCommandIsDangerousCallback:Xl},"gh release list":{safeFlags:{"--exclude-drafts":"none","--exclude-pre-releases":"none","--json":"string","--limit":"number","-L":"number","--order":"string","-O":"string","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh release view":{safeFlags:{"--json":"string","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh workflow list":{safeFlags:{"--all":"none","-a":"none","--json":"string","--limit":"number","-L":"number","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh workflow view":{safeFlags:{"--ref":"string","-r":"string","--yaml":"none","-y":"none","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh label list":{safeFlags:{"--json":"string","--limit":"number","-L":"number","--order":"string","--search":"string","-S":"string","--sort":"string","--repo":"string","-R":"string"},additionalCommandIsDangerousCallback:Xl},"gh search repos":{safeFlags:{"--archived":"none","--created":"string","--followers":"string","--forks":"string","--good-first-issues":"string","--help-wanted-issues":"string","--include-forks":"string","--json":"string","--language":"string","--license":"string","--limit":"number","-L":"number","--match":"string","--number-topics":"string","--order":"string","--owner":"string","--size":"string","--sort":"string","--stars":"string","--topic":"string","--updated":"string","--visibility":"string"}},"gh search issues":{safeFlags:{"--app":"string","--assignee":"string","--author":"string","--closed":"string","--commenter":"string","--comments":"string","--created":"string","--include-prs":"none","--interactions":"string","--involves":"string","--json":"string","--label":"string","--language":"string","--limit":"number","-L":"number","--locked":"none","--match":"string","--mentions":"string","--milestone":"string","--no-assignee":"none","--no-label":"none","--no-milestone":"none","--no-project":"none","--order":"string","--owner":"string","--project":"string","--reactions":"string","--repo":"string","-R":"string","--sort":"string","--state":"string","--team-mentions":"string","--updated":"string","--visibility":"string"}},"gh search prs":{safeFlags:{"--app":"string","--assignee":"string","--author":"string","--base":"string","-B":"string","--checks":"string","--closed":"string","--commenter":"string","--comments":"string","--created":"string","--draft":"none","--head":"string","-H":"string","--interactions":"string","--involves":"string","--json":"string","--label":"string","--language":"string","--limit":"number","-L":"number","--locked":"none","--match":"string","--mentions":"string","--merged":"none","--merged-at":"string","--milestone":"string","--no-assignee":"none","--no-label":"none","--no-milestone":"none","--no-project":"none","--order":"string","--owner":"string","--project":"string","--reactions":"string","--repo":"string","-R":"string","--review":"string","--review-requested":"string","--reviewed-by":"string","--sort":"string","--state":"string","--team-mentions":"string","--updated":"string","--visibility":"string"}},"gh search commits":{safeFlags:{"--author":"string","--author-date":"string","--author-email":"string","--author-name":"string","--committer":"string","--committer-date":"string","--committer-email":"string","--committer-name":"string","--hash":"string","--json":"string","--limit":"number","-L":"number","--merge":"none","--order":"string","--owner":"string","--parent":"string","--repo":"string","-R":"string","--sort":"string","--tree":"string","--visibility":"string"}},"gh search code":{safeFlags:{"--extension":"string","--filename":"string","--json":"string","--language":"string","--limit":"number","-L":"number","--match":"string","--owner":"string","--repo":"string","-R":"string","--size":"string"}}};function Xl(e,t){for(let r of t){if(!r)continue;let n=r;if(r.startsWith("-")){let i=r.indexOf("=");if(i===-1||(n=r.slice(i+1),!n))continue}if(!(!n.includes("/")&&!n.includes("://")&&!n.includes("@"))&&(n.includes("://")||n.includes("@")||(n.match(/\//g)??[]).length>=2))return!0}return!1}Hj.fdfind=Hj.fd;var MMr=Object.keys(Hj).sort((e,t)=>t.split(" ").length-e.split(" ").length),QMr=new Set(["command_substitution","arithmetic_expansion","expansion","simple_expansion"]),Cet=new Set(["file_redirect","heredoc_redirect","redirected_statement"]);function Iet(e){if(QMr.has(e.type))return!0;if(e.children){for(let t of e.children)if(Iet(t))return!0}return!1}function LMr(e){return Iet(e)?null:e.text}function Tet(e){if(e.type==="command")return 1;if(e.type==="list"&&e.children){let t=0;for(let r of e.children)(r.type==="command"||r.type==="pipeline")&&t++;return t}if(e.children){let t=0;for(let r of e.children)t+=Tet(r);return t}return 0}function vet(e){if(e.type==="command")return e;if(e.children)for(let t of e.children){let r=vet(t);if(r)return r}return null}function xet(e){if(Cet.has(e.type))return"redirect";if(e.type==="variable_assignment")return"env-var";if(e.children)for(let t of e.children){let r=xet(t);if(r)return r}return null}function wet(e,t){if(e.type==="word"){t.push(e);return}if(!Cet.has(e.type)&&e.children)for(let r of e.children)wet(r,t)}function PMr(e){let t;try{t=uEe().parse(e.trim())}catch(s){return{ok:!1,reason:`parse error: ${s}`}}if(Tet(t)!==1)return{ok:!1,reason:"multiple commands"};let r=vet(t);if(!r)return{ok:!1,reason:"no command found"};let n=xet(r);if(n)return{ok:!1,reason:`prefix (${n})`};let i=[],o=[];if(wet(r,o),o.length===0)return{ok:!1,reason:"no command name"};for(let s of o){let a=LMr(s);if(a===null)return{ok:!1,reason:"expansion in arg"};i.push(a)}return{ok:!0,tokens:i}}function cEe(e,t){switch(t){case"none":return!1;case"string":return!0;case"number":return/^-?\d+$/.test(e);case"char":return e.length===1;case"{}":return e==="{}";case"EOF":return e==="EOF"}}var FMr=new Set(["echo","printf","wc","grep","head","tail"]);function UMr(e,t,r,n){let i=t;for(;i<e.length;){let o=e[i];if(n.isXargs&&!o.startsWith("-")&&o!=="--")return FMr.has(o);if(o==="--"){if(r.respectsDoubleDash!==!1){i++;break}i++;continue}if(!o.startsWith("-")||o==="-"){i++;continue}if(!o.startsWith("--")&&o.length>2&&!o.includes("=")){let f=o.slice(0,2),A=o.slice(2),m=r.safeFlags[f];if(m&&m!=="none"){if(cEe(A,m)){i++;continue}return!1}}let s=o.indexOf("="),a=s!==-1,l=a?o.slice(0,s):o,c=a?o.slice(s+1):"";if(!l)return!1;let u=r.safeFlags[l];if(!u){if(n.commandName==="git"&&/^-\d+$/.test(l)){i++;continue}let f=l.match(/^(-[A-Za-z])(\d+)$/);if(f){let A=r.safeFlags[f[1]];if((A==="number"||A==="string")&&cEe(f[2],"number")){i++;continue}}if(!l.startsWith("--")&&l.length>2&&l.slice(1).split("").every(A=>r.safeFlags[`-${A}`]==="none")){i++;continue}return!1}if(u==="none"){if(a)return!1;i++}else{let f;if(a)f=c,i++;else{if(i+1>=e.length)return!1;let A=e[i+1];if(A.startsWith("-")&&A.length>1&&A!=="--"){let m=/^-\d+$/.test(A),g=l==="--sort"&&n.commandName==="git"&&/^-[a-zA-Z]/.test(A);if(!m&&!g)return!1}f=A,i+=2}if(!cEe(f,u))return!1}}return!0}function Det(e){let t=e.trim();if(kMr.some(s=>s.test(t)))return!0;let r=PMr(t);if(!r.ok)return!1;let{tokens:n}=r;if(n.length===0)return!1;for(let s of[...OMr].sort((a,l)=>l.split(" ").length-a.split(" ").length)){let a=s.split(" ");if(n.length>=a.length&&a.every((l,c)=>n[c]===l))return!0}let i=null,o=0;for(let s of MMr){let a=s.split(" ");if(!(n.length<a.length)&&a.every((l,c)=>n[c]===l)){i=Hj[s],o=a.length;break}}if(!i)return!1;if(n[0]==="git"&&n[1]==="ls-remote")for(let s=2;s<n.length;s++){let a=n[s];if(a&&!a.startsWith("-")&&(a.includes("://")||a.includes("@")||a.includes(":")||a.includes("$")))return!1}for(let s of n.slice(o))if(s&&(s.includes("$")||s.includes("{")&&(s.includes(",")||s.includes(".."))))return!1;return!(!i.regex&&t.includes("`")||!UMr(n,o,i,{commandName:n[0],isXargs:n[0]==="xargs"})||i.regex&&!i.regex.test(t)||i.additionalCommandIsDangerousCallback?.(t,n.slice(o)))}He();import{readFileSync as RLr,writeFileSync as NLr,openSync as Mtt,readSync as Qtt,closeSync as Ltt,existsSync as BLr,readdirSync as OLr,opendirSync as Vpi,lstatSync as Ptt}from"fs";import{isAbsolute as Ftt,normalize as Dtt,resolve as tF,resolve as Rtt,relative as kLr,sep as lV,basename as Ntt,dirname as MLr,extname as Btt,join as QLr}from"path";var dEe=(e,t,r)=>{let n=e instanceof RegExp?Ret(e,r):e,i=t instanceof RegExp?Ret(t,r):t,o=n!==null&&i!=null&&HMr(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)}},Ret=(e,t)=>{let r=t.match(e);return r?r[0]:null},HMr=(e,t,r)=>{let n,i,o,s,a,l=r.indexOf(e),c=r.indexOf(t,l+1),u=l;if(l>=0&&c>0){if(e===t)return[l,c];for(n=[],o=r.length;u>=0&&!a;){if(u===l)n.push(u),l=r.indexOf(e,u+1);else if(n.length===1){let f=n.pop();f!==void 0&&(a=[f,c])}else i=n.pop(),i!==void 0&&i<o&&(o=i,s=c),c=r.indexOf(t,u+1);u=l<c&&l>=0?l:c}n.length&&s!==void 0&&(a=[o,s])}return a};var Net="\0SLASH"+Math.random()+"\0",Bet="\0OPEN"+Math.random()+"\0",pEe="\0CLOSE"+Math.random()+"\0",Oet="\0COMMA"+Math.random()+"\0",ket="\0PERIOD"+Math.random()+"\0",qMr=new RegExp(Net,"g"),GMr=new RegExp(Bet,"g"),$Mr=new RegExp(pEe,"g"),zMr=new RegExp(Oet,"g"),YMr=new RegExp(ket,"g"),jMr=/\\\\/g,VMr=/\\{/g,WMr=/\\}/g,KMr=/\\,/g,JMr=/\\./g,ZMr=1e5;function fEe(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function XMr(e){return e.replace(jMr,Net).replace(VMr,Bet).replace(WMr,pEe).replace(KMr,Oet).replace(JMr,ket)}function eQr(e){return e.replace(qMr,"\\").replace(GMr,"{").replace($Mr,"}").replace(zMr,",").replace(YMr,".")}function Met(e){if(!e)return[""];let t=[],r=dEe("{","}",e);if(!r)return e.split(",");let{pre:n,body:i,post:o}=r,s=n.split(",");s[s.length-1]+="{"+i+"}";let a=Met(o);return o.length&&(s[s.length-1]+=a.shift(),s.push.apply(s,a)),t.push.apply(t,s),t}function Qet(e,t={}){if(!e)return[];let{max:r=ZMr}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),PP(XMr(e),r,!0).map(eQr)}function tQr(e){return"{"+e+"}"}function rQr(e){return/^-?0\d/.test(e)}function nQr(e,t){return e<=t}function iQr(e,t){return e>=t}function PP(e,t,r){let n=[],i=dEe("{","}",e);if(!i)return[e];let o=i.pre,s=i.post.length?PP(i.post,t,!1):[""];if(/\$$/.test(i.pre))for(let a=0;a<s.length&&a<t;a++){let l=o+"{"+i.body+"}"+s[a];n.push(l)}else{let a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),c=a||l,u=i.body.indexOf(",")>=0;if(!c&&!u)return i.post.match(/,(?!,).*\}/)?(e=i.pre+"{"+i.body+pEe+i.post,PP(e,t,!0)):[e];let f;if(c)f=i.body.split(/\.\./);else if(f=Met(i.body),f.length===1&&f[0]!==void 0&&(f=PP(f[0],t,!1).map(tQr),f.length===1))return s.map(m=>i.pre+f[0]+m);let A;if(c&&f[0]!==void 0&&f[1]!==void 0){let m=fEe(f[0]),g=fEe(f[1]),E=Math.max(f[0].length,f[1].length),_=f.length===3&&f[2]!==void 0?Math.abs(fEe(f[2])):1,C=nQr;g<m&&(_*=-1,C=iQr);let T=f.some(rQr);A=[];for(let w=m;C(w,g);w+=_){let O;if(l)O=String.fromCharCode(w),O==="\\"&&(O="");else if(O=String(w),T){let Q=E-O.length;if(Q>0){let z=new Array(Q+1).join("0");w<0?O="-"+z+O.slice(1):O=z+O}}A.push(O)}}else{A=[];for(let m=0;m<f.length;m++)A.push.apply(A,PP(f[m],t,!1))}for(let m=0;m<A.length;m++)for(let g=0;g<s.length&&n.length<t;g++){let E=o+A[m]+s[g];(!r||c||E)&&n.push(E)}}return n}var FP=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var oQr={"[: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]},UP=e=>e.replace(/[[\]\\-]/g,"\\$&"),sQr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Let=e=>e.join(""),Pet=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],o=r+1,s=!1,a=!1,l=!1,c=!1,u=r,f="";e:for(;o<e.length;){let E=e.charAt(o);if((E==="!"||E==="^")&&o===r+1){c=!0,o++;continue}if(E==="]"&&s&&!l){u=o+1;break}if(s=!0,E==="\\"&&!l){l=!0,o++;continue}if(E==="["&&!l){for(let[_,[C,S,T]]of Object.entries(oQr))if(e.startsWith(_,o)){if(f)return["$.",!1,e.length-r,!0];o+=_.length,T?i.push(C):n.push(C),a=a||S;continue e}}if(l=!1,f){E>f?n.push(UP(f)+"-"+UP(E)):E===f&&n.push(UP(E)),f="",o++;continue}if(e.startsWith("-]",o+1)){n.push(UP(E+"-")),o+=2;continue}if(e.startsWith("-",o+1)){f=E,o+=2;continue}n.push(UP(E)),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 E=n[0].length===2?n[0].slice(-1):n[0];return[sQr(E),!1,u-r,!1]}let A="["+(c?"^":"")+Let(n)+"]",m="["+(c?"":"^")+Let(i)+"]";return[n.length&&i.length?"("+A+"|"+m+")":n.length?A:m,a,u-r,!0]};var dA=(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 aQr=new Set(["!","?","+","*","@"]),Fet=e=>aQr.has(e),lQr="(?!(?:^|/)\\.\\.?(?:$|/))",qj="(?!\\.)",cQr=new Set(["[","."]),uQr=new Set(["..","."]),dQr=new Set("().*{}+?[]^$\\!"),fQr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),mEe="[^/]",Uet=mEe+"*?",Het=mEe+"+?",RN=class e{type;#e;#t;#r=!1;#n=[];#o;#i;#l;#s=!1;#a;#d;#p=!1;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.#n.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let t of this.#n)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.#n.map(t=>String(t)).join("|")+")":this.#d=this.#n.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.#n.length;i++)for(let o of t.#n){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#n[i])}r=n,n=r.#o}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof e&&r.#o===this))throw new Error("invalid part: "+r);this.#n.push(r)}}toJSON(){let t=this.type===null?this.#n.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#n.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.#n[r];if(!(n instanceof e&&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.#n.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 e(this.type,t);for(let n of this.#n)r.copyIn(n);return r}static#c(t,r,n,i){let o=!1,s=!1,a=-1,l=!1;if(r.type===null){let m=n,g="";for(;m<t.length;){let E=t.charAt(m++);if(o||E==="\\"){o=!o,g+=E;continue}if(s){m===a+1?(E==="^"||E==="!")&&(l=!0):E==="]"&&!(m===a+2&&l)&&(s=!1),g+=E;continue}else if(E==="["){s=!0,a=m,l=!1,g+=E;continue}if(!i.noext&&Fet(E)&&t.charAt(m)==="("){r.push(g),g="";let _=new e(E,r);m=e.#c(t,_,m,i),r.push(_);continue}g+=E}return r.push(g),m}let c=n+1,u=new e(null,r),f=[],A="";for(;c<t.length;){let m=t.charAt(c++);if(o||m==="\\"){o=!o,A+=m;continue}if(s){c===a+1?(m==="^"||m==="!")&&(l=!0):m==="]"&&!(c===a+2&&l)&&(s=!1),A+=m;continue}else if(m==="["){s=!0,a=c,l=!1,A+=m;continue}if(Fet(m)&&t.charAt(c)==="("){u.push(A),A="";let g=new e(m,u);u.push(g),c=e.#c(t,g,c,i);continue}if(m==="|"){u.push(A),A="",f.push(u),u=new e(null,r);continue}if(m===")")return A===""&&r.#n.length===0&&(r.#p=!0),u.push(A),A="",r.push(...f,u),c;A+=m}return r.type=null,r.#t=void 0,r.#n=[t.substring(n-1)],c}static fromGlob(t,r={}){let n=new e(null,void 0,r);return e.#c(t,n,0,r),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.#f(),!this.type){let l=this.isStart()&&this.isEnd()&&!this.#n.some(m=>typeof m!="string"),c=this.#n.map(m=>{let[g,E,_,C]=typeof m=="string"?e.#h(m,this.#t,l):m.toRegExpSource(t);return this.#t=this.#t||_,this.#r=this.#r||C,g}).join(""),u="";if(this.isStart()&&typeof this.#n[0]=="string"&&!(this.#n.length===1&&uQr.has(this.#n[0]))){let g=cQr,E=r&&g.has(c.charAt(0))||c.startsWith("\\.")&&g.has(c.charAt(2))||c.startsWith("\\.\\.")&&g.has(c.charAt(4)),_=!r&&!t&&g.has(c.charAt(0));u=E?lQr:_?qj:""}let f="";return this.isEnd()&&this.#e.#s&&this.#o?.type==="!"&&(f="(?:$|\\/)"),[u+c+f,dA(c),this.#t=!!this.#t,this.#r]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#A(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString();return this.#n=[l],this.type=null,this.#t=void 0,[l,dA(this.toString()),!1,!1]}let s=!n||t||r||!qj?"":this.#A(!0);s===o&&(s=""),s&&(o=`(?:${o})(?:${s})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?qj:"")+Het;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?qj:"")+Uet+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&s?")":this.type==="*"&&s?")?":`)${this.type}`;a=i+o+l}return[a,dA(o),this.#t=!!this.#t,this.#r]}#A(t){return this.#n.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,o,s]=r.toRegExpSource(t);return this.#r=this.#r||s,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#h(t,r,n=!1){let i=!1,o="",s=!1;for(let a=0;a<t.length;a++){let l=t.charAt(a);if(i){i=!1,o+=(dQr.has(l)?"\\":"")+l;continue}if(l==="\\"){a===t.length-1?o+="\\\\":i=!0;continue}if(l==="["){let[c,u,f,A]=Pet(t,a);if(f){o+=c,s=s||u,a+=f-1,r=r||A;continue}}if(l==="*"){o+=n&&t==="*"?Het:Uet,r=!0;continue}if(l==="?"){o+=mEe,r=!0;continue}o+=fQr(l)}return[o,dA(t),!!r,s]}};var NN=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var tc=(e,t,r={})=>(FP(t),!r.nocomment&&t.charAt(0)==="#"?!1:new pf(t,r).match(e)),pQr=/^\*+([^+@!?\*\[\(]*)$/,mQr=e=>t=>!t.startsWith(".")&&t.endsWith(e),AQr=e=>t=>t.endsWith(e),gQr=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),hQr=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),EQr=/^\*+\.\*+$/,_Qr=e=>!e.startsWith(".")&&e.includes("."),yQr=e=>e!=="."&&e!==".."&&e.includes("."),bQr=/^\.\*+$/,CQr=e=>e!=="."&&e!==".."&&e.startsWith("."),SQr=/^\*+$/,IQr=e=>e.length!==0&&!e.startsWith("."),TQr=e=>e.length!==0&&e!=="."&&e!=="..",vQr=/^\?+([^+@!?\*\[\(]*)?$/,xQr=([e,t=""])=>{let r=$et([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},wQr=([e,t=""])=>{let r=zet([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},DQr=([e,t=""])=>{let r=zet([e]);return t?n=>r(n)&&n.endsWith(t):r},RQr=([e,t=""])=>{let r=$et([e]);return t?n=>r(n)&&n.endsWith(t):r},$et=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},zet=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},Yet=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",qet={win32:{sep:"\\"},posix:{sep:"/"}},NQr=Yet==="win32"?qet.win32.sep:qet.posix.sep;tc.sep=NQr;var ec=Symbol("globstar **");tc.GLOBSTAR=ec;var BQr="[^/]",OQr=BQr+"*?",kQr="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",MQr="(?:(?!(?:\\/|^)\\.).)*?",QQr=(e,t={})=>r=>tc(r,e,t);tc.filter=QQr;var Mp=(e,t={})=>Object.assign({},e,t),LQr=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return tc;let t=tc;return Object.assign((n,i,o={})=>t(n,i,Mp(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,Mp(e,o))}static defaults(i){return t.defaults(Mp(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,s={}){super(i,o,Mp(e,s))}static fromGlob(i,o={}){return t.AST.fromGlob(i,Mp(e,o))}},unescape:(n,i={})=>t.unescape(n,Mp(e,i)),escape:(n,i={})=>t.escape(n,Mp(e,i)),filter:(n,i={})=>t.filter(n,Mp(e,i)),defaults:n=>t.defaults(Mp(e,n)),makeRe:(n,i={})=>t.makeRe(n,Mp(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,Mp(e,i)),match:(n,i,o={})=>t.match(n,i,Mp(e,o)),sep:t.sep,GLOBSTAR:ec})};tc.defaults=LQr;var jet=(e,t={})=>(FP(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Qet(e));tc.braceExpand=jet;var PQr=(e,t={})=>new pf(e,t).makeRe();tc.makeRe=PQr;var FQr=(e,t,r={})=>{let n=new pf(t,r);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};tc.match=FQr;var Get=/[?*]|[+@!]\(.*?\)|\[|\]/,UQr=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),pf=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,r={}){FP(t),r=r||{},this.options=r,this.pattern=t,this.platform=r.platform||Yet,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!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]==="?"||!Get.test(o[2]))&&!Get.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=0;n<t.length;n++)for(let i=0;i<t[n].length;i++)t[n][i]==="**"&&(t[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!=="**"&&(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=this.options;if(this.isWindows){let E=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),_=!E&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),C=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),S=!C&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),T=_?3:E?0:void 0,w=S?3:C?0:void 0;if(typeof T=="number"&&typeof w=="number"){let[O,Q]=[t[T],r[w]];O.toLowerCase()===Q.toLowerCase()&&(r[w]=O,w>T?r=r.slice(w):T>w&&(t=t.slice(T)))}}let{optimizationLevel:o=1}=this.options;o>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:r}),this.debug("matchOne",t.length,r.length);for(var s=0,a=0,l=t.length,c=r.length;s<l&&a<c;s++,a++){this.debug("matchOne loop");var u=r[a],f=t[s];if(this.debug(r,u,f),u===!1)return!1;if(u===ec){this.debug("GLOBSTAR",[r,u,f]);var A=s,m=a+1;if(m===c){for(this.debug("** at the end");s<l;s++)if(t[s]==="."||t[s]===".."||!i.dot&&t[s].charAt(0)===".")return!1;return!0}for(;A<l;){var g=t[A];if(this.debug(`
581
581
  globstar while`,t,A,r,m,g),this.matchOne(t.slice(A),r.slice(m),n))return this.debug("globstar found match!",A,l,g),!0;if(g==="."||g===".."||!i.dot&&g.charAt(0)==="."){this.debug("dot detected!",t,A,r,m);break}this.debug("globstar swallow a segment, and continue"),A++}return!!(n&&(this.debug(`
582
582
  >>> no match, partial?`,t,A,r,m),A===l))}let E;if(typeof u=="string"?(E=f===u,this.debug("string match",u,f,E)):(E=u.test(f),this.debug("pattern match",u,f,E)),!E)return!1}if(s===l&&a===c)return!0;if(s===l)return n;if(a===c)return s===l-1&&t[s]==="";throw new Error("wtf?")}braceExpand(){return jet(this.pattern,this.options)}parse(t){FP(t);let r=this.options;if(t==="**")return ec;if(t==="")return"";let n,i=null;(n=t.match(SQr))?i=r.dot?TQr:IQr:(n=t.match(pQr))?i=(r.nocase?r.dot?hQr:gQr:r.dot?AQr:mQr)(n[1]):(n=t.match(vQr))?i=(r.nocase?r.dot?wQr:xQr:r.dot?DQr:RQr)(n):(n=t.match(EQr))?i=r.dot?yQr:_Qr:(n=t.match(bQr))&&(i=CQr);let o=RN.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?OQr:r.dot?kQr:MQr,i=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let c=l.map(f=>{if(f instanceof RegExp)for(let A of f.flags.split(""))i.add(A);return typeof f=="string"?UQr(f):f===ec?ec:f._src});c.forEach((f,A)=>{let m=c[A+1],g=c[A-1];f!==ec||g===ec||(g===void 0?m!==void 0&&m!==ec?c[A+1]="(?:\\/|"+n+"\\/)?"+m:c[A]=n:m===void 0?c[A-1]=g+"(?:\\/|\\/"+n+")?":m!==ec&&(c[A-1]=g+"(?:\\/|\\/"+n+"\\/)"+m,c[A+1]=ec))});let u=c.filter(f=>f!==ec);if(this.partial&&u.length>=1){let f=[];for(let A=1;A<=u.length;A++)f.push(u.slice(0,A).join("/"));return"(?:"+f.join("|")+")"}return u.join("/")}).join("|"),[s,a]=t.length>1?["(?:",")"]:["",""];o="^"+s+o+a+"$",this.partial&&(o="^(?:\\/|"+s+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let o=this.set;this.debug(this.pattern,"set",o);let s=i[i.length-1];if(!s)for(let a=i.length-2;!s&&a>=0;a--)s=i[a];for(let a=0;a<o.length;a++){let l=o[a],c=i;if(n.matchBase&&l.length===1&&(c=[s]),this.matchOne(c,l,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return tc.defaults(t).Minimatch}};tc.AST=RN;tc.Minimatch=pf;tc.escape=NN;tc.unescape=dA;import{fileURLToPath as _Lr}from"node:url";var HQr=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Wet=new Set,AEe=typeof process=="object"&&process?process:{},Ket=(e,t,r,n)=>{typeof AEe.emitWarning=="function"?AEe.emitWarning(e,t,r,n):console.error(`[${r}] ${t}: ${e}`)},Gj=globalThis.AbortController,Vet=globalThis.AbortSignal;if(typeof Gj>"u"){Vet=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(n,i){this._onabort.push(i)}},Gj=class{constructor(){t()}signal=new Vet;abort(n){if(!this.signal.aborted){this.signal.reason=n,this.signal.aborted=!0;for(let i of this.signal._onabort)i(n);this.signal.onabort?.(n)}}};let e=AEe.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=!1,Ket("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}var qQr=e=>!Wet.has(e),npi=Symbol("type"),zb=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Jet=e=>zb(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?BN:null:null,BN=class extends Array{constructor(t){super(t),this.fill(0)}},gEe=class e{heap;length;static#e=!1;static create(t){let r=Jet(t);if(!r)return[];e.#e=!0;let n=new e(t,r);return e.#e=!1,n}constructor(t,r){if(!e.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},tT=class e{#e;#t;#r;#n;#o;#i;#l;#s;get perf(){return this.#s}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#d;#p;#f;#c;#A;#h;#E;#g;#w;#_;#I;#T;#y;#b;#C;#v;#u;#k;static unsafeExposeInternals(t){return{starts:t.#T,ttls:t.#y,autopurgeTimers:t.#b,sizes:t.#I,keyMap:t.#p,keyList:t.#f,valList:t.#c,next:t.#A,prev:t.#h,get head(){return t.#E},get tail(){return t.#g},free:t.#w,isBackgroundFetch:r=>t.#m(r),backgroundFetch:(r,n,i,o)=>t.#q(r,n,i,o),moveToTail:r=>t.#Q(r),indexes:r=>t.#R(r),rindexes:r=>t.#N(r),isStale:r=>t.#S(r)}}get max(){return this.#e}get maxSize(){return this.#t}get calculatedSize(){return this.#d}get size(){return this.#a}get fetchMethod(){return this.#i}get memoMethod(){return this.#l}get dispose(){return this.#r}get onInsert(){return this.#n}get disposeAfter(){return this.#o}constructor(t){let{max:r=0,ttl:n,ttlResolution:i=1,ttlAutopurge:o,updateAgeOnGet:s,updateAgeOnHas:a,allowStale:l,dispose:c,onInsert:u,disposeAfter:f,noDisposeOnSet:A,noUpdateTTL:m,maxSize:g=0,maxEntrySize:E=0,sizeCalculation:_,fetchMethod:C,memoMethod:S,noDeleteOnFetchRejection:T,noDeleteOnStaleGet:w,allowStaleOnFetchRejection:O,allowStaleOnFetchAbort:Q,ignoreFetchAbort:z,perf:V}=t;if(V!==void 0&&typeof V?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#s=V??HQr,r!==0&&!zb(r))throw new TypeError("max option must be a nonnegative integer");let M=r?Jet(r):Array;if(!M)throw new Error("invalid max value: "+r);if(this.#e=r,this.#t=g,this.maxEntrySize=E||this.#t,this.sizeCalculation=_,this.sizeCalculation){if(!this.#t&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(S!==void 0&&typeof S!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#l=S,C!==void 0&&typeof C!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#i=C,this.#v=!!C,this.#p=new Map,this.#f=new Array(r).fill(void 0),this.#c=new Array(r).fill(void 0),this.#A=new M(r),this.#h=new M(r),this.#E=0,this.#g=0,this.#w=gEe.create(r),this.#a=0,this.#d=0,typeof c=="function"&&(this.#r=c),typeof u=="function"&&(this.#n=u),typeof f=="function"?(this.#o=f,this.#_=[]):(this.#o=void 0,this.#_=void 0),this.#C=!!this.#r,this.#k=!!this.#n,this.#u=!!this.#o,this.noDisposeOnSet=!!A,this.noUpdateTTL=!!m,this.noDeleteOnFetchRejection=!!T,this.allowStaleOnFetchRejection=!!O,this.allowStaleOnFetchAbort=!!Q,this.ignoreFetchAbort=!!z,this.maxEntrySize!==0){if(this.#t!==0&&!zb(this.#t))throw new TypeError("maxSize must be a positive integer if specified");if(!zb(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#$()}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!w,this.updateAgeOnGet=!!s,this.updateAgeOnHas=!!a,this.ttlResolution=zb(i)||i===0?i:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!zb(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#B()}if(this.#e===0&&this.ttl===0&&this.#t===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#t){let G="LRU_CACHE_UNBOUNDED";qQr(G)&&(Wet.add(G),Ket("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",G,e))}}getRemainingTTL(t){return this.#p.has(t)?1/0:0}#B(){let t=new BN(this.#e),r=new BN(this.#e);this.#y=t,this.#T=r;let n=this.ttlAutopurge?new Array(this.#e):void 0;this.#b=n,this.#P=(s,a,l=this.#s.now())=>{if(r[s]=a!==0?l:0,t[s]=a,n?.[s]&&(clearTimeout(n[s]),n[s]=void 0),a!==0&&n){let c=setTimeout(()=>{this.#S(s)&&this.#D(this.#f[s],"expire")},a+1);c.unref&&c.unref(),n[s]=c}},this.#x=s=>{r[s]=t[s]!==0?this.#s.now():0},this.#O=(s,a)=>{if(t[a]){let l=t[a],c=r[a];if(!l||!c)return;s.ttl=l,s.start=c,s.now=i||o();let u=s.now-c;s.remainingTTL=l-u}};let i=0,o=()=>{let s=this.#s.now();if(this.ttlResolution>0){i=s;let a=setTimeout(()=>i=0,this.ttlResolution);a.unref&&a.unref()}return s};this.getRemainingTTL=s=>{let a=this.#p.get(s);if(a===void 0)return 0;let l=t[a],c=r[a];if(!l||!c)return 1/0;let u=(i||o())-c;return l-u},this.#S=s=>{let a=r[s],l=t[s];return!!l&&!!a&&(i||o())-a>l}}#x=()=>{};#O=()=>{};#P=()=>{};#S=()=>!1;#$(){let t=new BN(this.#e);this.#d=0,this.#I=t,this.#L=r=>{this.#d-=t[r],t[r]=0},this.#F=(r,n,i,o)=>{if(this.#m(n))return 0;if(!zb(i))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(i=o(n,r),!zb(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.#M=(r,n,i)=>{if(t[r]=n,this.#t){let o=this.#t-t[r];for(;this.#d>o;)this.#H(!0)}this.#d+=t[r],i&&(i.entrySize=n,i.totalCalculatedSize=this.#d)}}#L=t=>{};#M=(t,r,n)=>{};#F=(t,r,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#R({allowStale:t=this.allowStale}={}){if(this.#a)for(let r=this.#g;!(!this.#U(r)||((t||!this.#S(r))&&(yield r),r===this.#E));)r=this.#h[r]}*#N({allowStale:t=this.allowStale}={}){if(this.#a)for(let r=this.#E;!(!this.#U(r)||((t||!this.#S(r))&&(yield r),r===this.#g));)r=this.#A[r]}#U(t){return t!==void 0&&this.#p.get(this.#f[t])===t}*entries(){for(let t of this.#R())this.#c[t]!==void 0&&this.#f[t]!==void 0&&!this.#m(this.#c[t])&&(yield[this.#f[t],this.#c[t]])}*rentries(){for(let t of this.#N())this.#c[t]!==void 0&&this.#f[t]!==void 0&&!this.#m(this.#c[t])&&(yield[this.#f[t],this.#c[t]])}*keys(){for(let t of this.#R()){let r=this.#f[t];r!==void 0&&!this.#m(this.#c[t])&&(yield r)}}*rkeys(){for(let t of this.#N()){let r=this.#f[t];r!==void 0&&!this.#m(this.#c[t])&&(yield r)}}*values(){for(let t of this.#R())this.#c[t]!==void 0&&!this.#m(this.#c[t])&&(yield this.#c[t])}*rvalues(){for(let t of this.#N())this.#c[t]!==void 0&&!this.#m(this.#c[t])&&(yield this.#c[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,r={}){for(let n of this.#R()){let i=this.#c[n],o=this.#m(i)?i.__staleWhileFetching:i;if(o!==void 0&&t(o,this.#f[n],this))return this.get(this.#f[n],r)}}forEach(t,r=this){for(let n of this.#R()){let i=this.#c[n],o=this.#m(i)?i.__staleWhileFetching:i;o!==void 0&&t.call(r,o,this.#f[n],this)}}rforEach(t,r=this){for(let n of this.#N()){let i=this.#c[n],o=this.#m(i)?i.__staleWhileFetching:i;o!==void 0&&t.call(r,o,this.#f[n],this)}}purgeStale(){let t=!1;for(let r of this.#N({allowStale:!0}))this.#S(r)&&(this.#D(this.#f[r],"expire"),t=!0);return t}info(t){let r=this.#p.get(t);if(r===void 0)return;let n=this.#c[r],i=this.#m(n)?n.__staleWhileFetching:n;if(i===void 0)return;let o={value:i};if(this.#y&&this.#T){let s=this.#y[r],a=this.#T[r];if(s&&a){let l=s-(this.#s.now()-a);o.ttl=l,o.start=Date.now()}}return this.#I&&(o.size=this.#I[r]),o}dump(){let t=[];for(let r of this.#R({allowStale:!0})){let n=this.#f[r],i=this.#c[r],o=this.#m(i)?i.__staleWhileFetching:i;if(o===void 0||n===void 0)continue;let s={value:o};if(this.#y&&this.#T){s.ttl=this.#y[r];let a=this.#s.now()-this.#T[r];s.start=Math.floor(Date.now()-a)}this.#I&&(s.size=this.#I[r]),t.unshift([n,s])}return t}load(t){this.clear();for(let[r,n]of t){if(n.start){let i=Date.now()-n.start;n.start=this.#s.now()-i}this.set(r,n.value,n)}}set(t,r,n={}){if(r===void 0)return this.delete(t),this;let{ttl:i=this.ttl,start:o,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:l}=n,{noUpdateTTL:c=this.noUpdateTTL}=n,u=this.#F(t,r,n.size||0,a);if(this.maxEntrySize&&u>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=!0),this.#D(t,"set"),this;let f=this.#a===0?void 0:this.#p.get(t);if(f===void 0)f=this.#a===0?this.#g:this.#w.length!==0?this.#w.pop():this.#a===this.#e?this.#H(!1):this.#a,this.#f[f]=t,this.#c[f]=r,this.#p.set(t,f),this.#A[this.#g]=f,this.#h[f]=this.#g,this.#g=f,this.#a++,this.#M(f,u,l),l&&(l.set="add"),c=!1,this.#k&&this.#n?.(r,t,"add");else{this.#Q(f);let A=this.#c[f];if(r!==A){if(this.#v&&this.#m(A)){A.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:m}=A;m!==void 0&&!s&&(this.#C&&this.#r?.(m,t,"set"),this.#u&&this.#_?.push([m,t,"set"]))}else s||(this.#C&&this.#r?.(A,t,"set"),this.#u&&this.#_?.push([A,t,"set"]));if(this.#L(f),this.#M(f,u,l),this.#c[f]=r,l){l.set="replace";let m=A&&this.#m(A)?A.__staleWhileFetching:A;m!==void 0&&(l.oldValue=m)}}else l&&(l.set="update");this.#k&&this.onInsert?.(r,t,r===A?"update":"replace")}if(i!==0&&!this.#y&&this.#B(),this.#y&&(c||this.#P(f,i,o),l&&this.#O(l,f)),!s&&this.#u&&this.#_){let A=this.#_,m;for(;m=A?.shift();)this.#o?.(...m)}return this}pop(){try{for(;this.#a;){let t=this.#c[this.#E];if(this.#H(!0),this.#m(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#u&&this.#_){let t=this.#_,r;for(;r=t?.shift();)this.#o?.(...r)}}}#H(t){let r=this.#E,n=this.#f[r],i=this.#c[r];return this.#v&&this.#m(i)?i.__abortController.abort(new Error("evicted")):(this.#C||this.#u)&&(this.#C&&this.#r?.(i,n,"evict"),this.#u&&this.#_?.push([i,n,"evict"])),this.#L(r),this.#b?.[r]&&(clearTimeout(this.#b[r]),this.#b[r]=void 0),t&&(this.#f[r]=void 0,this.#c[r]=void 0,this.#w.push(r)),this.#a===1?(this.#E=this.#g=0,this.#w.length=0):this.#E=this.#A[r],this.#p.delete(n),this.#a--,r}has(t,r={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=r,o=this.#p.get(t);if(o!==void 0){let s=this.#c[o];if(this.#m(s)&&s.__staleWhileFetching===void 0)return!1;if(this.#S(o))i&&(i.has="stale",this.#O(i,o));else return n&&this.#x(o),i&&(i.has="hit",this.#O(i,o)),!0}else i&&(i.has="miss");return!1}peek(t,r={}){let{allowStale:n=this.allowStale}=r,i=this.#p.get(t);if(i===void 0||!n&&this.#S(i))return;let o=this.#c[i];return this.#m(o)?o.__staleWhileFetching:o}#q(t,r,n,i){let o=r===void 0?void 0:this.#c[r];if(this.#m(o))return o;let s=new Gj,{signal:a}=n;a?.addEventListener("abort",()=>s.abort(a.reason),{signal:s.signal});let l={signal:s.signal,options:n,context:i},c=(E,_=!1)=>{let{aborted:C}=s.signal,S=n.ignoreFetchAbort&&E!==void 0;if(n.status&&(C&&!_?(n.status.fetchAborted=!0,n.status.fetchError=s.signal.reason,S&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),C&&!S&&!_)return f(s.signal.reason);let T=m,w=this.#c[r];return(w===m||S&&_&&w===void 0)&&(E===void 0?T.__staleWhileFetching!==void 0?this.#c[r]=T.__staleWhileFetching:this.#D(t,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(t,E,l.options))),E},u=E=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=E),f(E)),f=E=>{let{aborted:_}=s.signal,C=_&&n.allowStaleOnFetchAbort,S=C||n.allowStaleOnFetchRejection,T=S||n.noDeleteOnFetchRejection,w=m;if(this.#c[r]===m&&(!T||w.__staleWhileFetching===void 0?this.#D(t,"fetch"):C||(this.#c[r]=w.__staleWhileFetching)),S)return n.status&&w.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),w.__staleWhileFetching;if(w.__returned===w)throw E},A=(E,_)=>{let C=this.#i?.(t,o,l);C&&C instanceof Promise&&C.then(S=>E(S===void 0?void 0:S),_),s.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(E(void 0),n.allowStaleOnFetchAbort&&(E=S=>c(S,!0)))})};n.status&&(n.status.fetchDispatched=!0);let m=new Promise(A).then(c,u),g=Object.assign(m,{__abortController:s,__staleWhileFetching:o,__returned:void 0});return r===void 0?(this.set(t,g,{...l.options,status:void 0}),r=this.#p.get(t)):this.#c[r]=g,g}#m(t){if(!this.#v)return!1;let r=t;return!!r&&r instanceof Promise&&r.hasOwnProperty("__staleWhileFetching")&&r.__abortController instanceof Gj}async fetch(t,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:l=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:f=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:A=this.allowStaleOnFetchRejection,ignoreFetchAbort:m=this.ignoreFetchAbort,allowStaleOnFetchAbort:g=this.allowStaleOnFetchAbort,context:E,forceRefresh:_=!1,status:C,signal:S}=r;if(!this.#v)return C&&(C.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:o,status:C});let T={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:o,ttl:s,noDisposeOnSet:a,size:l,sizeCalculation:c,noUpdateTTL:u,noDeleteOnFetchRejection:f,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:g,ignoreFetchAbort:m,status:C,signal:S},w=this.#p.get(t);if(w===void 0){C&&(C.fetch="miss");let O=this.#q(t,w,T,E);return O.__returned=O}else{let O=this.#c[w];if(this.#m(O)){let G=n&&O.__staleWhileFetching!==void 0;return C&&(C.fetch="inflight",G&&(C.returnedStale=!0)),G?O.__staleWhileFetching:O.__returned=O}let Q=this.#S(w);if(!_&&!Q)return C&&(C.fetch="hit"),this.#Q(w),i&&this.#x(w),C&&this.#O(C,w),O;let z=this.#q(t,w,T,E),M=z.__staleWhileFetching!==void 0&&n;return C&&(C.fetch=Q?"stale":"refresh",M&&Q&&(C.returnedStale=!0)),M?z.__staleWhileFetching:z.__returned=z}}async forceFetch(t,r={}){let n=await this.fetch(t,r);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(t,r={}){let n=this.#l;if(!n)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:o,...s}=r,a=this.get(t,s);if(!o&&a!==void 0)return a;let l=n(t,a,{options:s,context:i});return this.set(t,l,s),l}get(t,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:s}=r,a=this.#p.get(t);if(a!==void 0){let l=this.#c[a],c=this.#m(l);return s&&this.#O(s,a),this.#S(a)?(s&&(s.get="stale"),c?(s&&n&&l.__staleWhileFetching!==void 0&&(s.returnedStale=!0),n?l.__staleWhileFetching:void 0):(o||this.#D(t,"expire"),s&&n&&(s.returnedStale=!0),n?l:void 0)):(s&&(s.get="hit"),c?l.__staleWhileFetching:(this.#Q(a),i&&this.#x(a),l))}else s&&(s.get="miss")}#G(t,r){this.#h[r]=t,this.#A[t]=r}#Q(t){t!==this.#g&&(t===this.#E?this.#E=this.#A[t]:this.#G(this.#h[t],this.#A[t]),this.#G(this.#g,t),this.#g=t)}delete(t){return this.#D(t,"delete")}#D(t,r){let n=!1;if(this.#a!==0){let i=this.#p.get(t);if(i!==void 0)if(this.#b?.[i]&&(clearTimeout(this.#b?.[i]),this.#b[i]=void 0),n=!0,this.#a===1)this.#z(r);else{this.#L(i);let o=this.#c[i];if(this.#m(o)?o.__abortController.abort(new Error("deleted")):(this.#C||this.#u)&&(this.#C&&this.#r?.(o,t,r),this.#u&&this.#_?.push([o,t,r])),this.#p.delete(t),this.#f[i]=void 0,this.#c[i]=void 0,i===this.#g)this.#g=this.#h[i];else if(i===this.#E)this.#E=this.#A[i];else{let s=this.#h[i];this.#A[s]=this.#A[i];let a=this.#A[i];this.#h[a]=this.#h[i]}this.#a--,this.#w.push(i)}}if(this.#u&&this.#_?.length){let i=this.#_,o;for(;o=i?.shift();)this.#o?.(...o)}return n}clear(){return this.#z("delete")}#z(t){for(let r of this.#N({allowStale:!0})){let n=this.#c[r];if(this.#m(n))n.__abortController.abort(new Error("deleted"));else{let i=this.#f[r];this.#C&&this.#r?.(n,i,t),this.#u&&this.#_?.push([n,i,t])}}if(this.#p.clear(),this.#c.fill(void 0),this.#f.fill(void 0),this.#y&&this.#T){this.#y.fill(0),this.#T.fill(0);for(let r of this.#b??[])r!==void 0&&clearTimeout(r);this.#b?.fill(void 0)}if(this.#I&&this.#I.fill(0),this.#E=0,this.#g=0,this.#w.length=0,this.#d=0,this.#a=0,this.#u&&this.#_){let r=this.#_,n;for(;n=r?.shift();)this.#o?.(...n)}}};import{posix as XQr,win32 as vEe}from"node:path";import{fileURLToPath as eLr}from"node:url";import{lstatSync as tLr,readdir as rLr,readdirSync as nLr,readlinkSync as iLr,realpathSync as oLr}from"fs";import*as sLr from"node:fs";import{lstat as lLr,readdir as cLr,readlink as uLr,realpath as dLr}from"node:fs/promises";import{EventEmitter as SEe}from"node:events";import rtt from"node:stream";import{StringDecoder as GQr}from"node:string_decoder";var Zet=typeof process=="object"&&process?process:{stdout:null,stderr:null},$Qr=e=>!!e&&typeof e=="object"&&(e instanceof jb||e instanceof rtt||zQr(e)||YQr(e)),zQr=e=>!!e&&typeof e=="object"&&e instanceof SEe&&typeof e.pipe=="function"&&e.pipe!==rtt.Writable.prototype.pipe,YQr=e=>!!e&&typeof e=="object"&&e instanceof SEe&&typeof e.write=="function"&&typeof e.end=="function",_0=Symbol("EOF"),y0=Symbol("maybeEmitEnd"),Yb=Symbol("emittedEnd"),$j=Symbol("emittingEnd"),HP=Symbol("emittedError"),zj=Symbol("closed"),Xet=Symbol("read"),Yj=Symbol("flush"),ett=Symbol("flushChunk"),fA=Symbol("encoding"),ON=Symbol("decoder"),Al=Symbol("flowing"),qP=Symbol("paused"),kN=Symbol("resume"),gl=Symbol("buffer"),Eu=Symbol("pipes"),hl=Symbol("bufferLength"),hEe=Symbol("bufferPush"),jj=Symbol("bufferShift"),Fc=Symbol("objectMode"),sa=Symbol("destroyed"),EEe=Symbol("error"),_Ee=Symbol("emitData"),ttt=Symbol("emitEnd"),yEe=Symbol("emitEnd2"),Jg=Symbol("async"),bEe=Symbol("abort"),Vj=Symbol("aborted"),GP=Symbol("signal"),rT=Symbol("dataListeners"),mf=Symbol("discarded"),$P=e=>Promise.resolve().then(e),jQr=e=>e(),VQr=e=>e==="end"||e==="finish"||e==="prefinish",WQr=e=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,KQr=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),Wj=class{src;dest;opts;ondrain;constructor(t,r,n){this.src=t,this.dest=r,this.opts=n,this.ondrain=()=>t[kN](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},CEe=class extends Wj{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,r,n){super(t,r,n),this.proxyErrors=i=>r.emit("error",i),t.on("error",this.proxyErrors)}},JQr=e=>!!e.objectMode,ZQr=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",jb=class extends SEe{[Al]=!1;[qP]=!1;[Eu]=[];[gl]=[];[Fc];[fA];[Jg];[ON];[_0]=!1;[Yb]=!1;[$j]=!1;[zj]=!1;[HP]=null;[hl]=0;[sa]=!1;[GP];[Vj]=!1;[rT]=0;[mf]=!1;writable=!0;readable=!0;constructor(...t){let r=t[0]||{};if(super(),r.objectMode&&typeof r.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");JQr(r)?(this[Fc]=!0,this[fA]=null):ZQr(r)?(this[fA]=r.encoding,this[Fc]=!1):(this[Fc]=!1,this[fA]=null),this[Jg]=!!r.async,this[ON]=this[fA]?new GQr(this[fA]):null,r&&r.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[gl]}),r&&r.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Eu]});let{signal:n}=r;n&&(this[GP]=n,n.aborted?this[bEe]():n.addEventListener("abort",()=>this[bEe]()))}get bufferLength(){return this[hl]}get encoding(){return this[fA]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[Fc]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Jg]}set async(t){this[Jg]=this[Jg]||!!t}[bEe](){this[Vj]=!0,this.emit("abort",this[GP]?.reason),this.destroy(this[GP]?.reason)}get aborted(){return this[Vj]}set aborted(t){}write(t,r,n){if(this[Vj])return!1;if(this[_0])throw new Error("write after end");if(this[sa])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof r=="function"&&(n=r,r="utf8"),r||(r="utf8");let i=this[Jg]?$P:jQr;if(!this[Fc]&&!Buffer.isBuffer(t)){if(KQr(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(WQr(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Fc]?(this[Al]&&this[hl]!==0&&this[Yj](!0),this[Al]?this.emit("data",t):this[hEe](t),this[hl]!==0&&this.emit("readable"),n&&i(n),this[Al]):t.length?(typeof t=="string"&&!(r===this[fA]&&!this[ON]?.lastNeed)&&(t=Buffer.from(t,r)),Buffer.isBuffer(t)&&this[fA]&&(t=this[ON].write(t)),this[Al]&&this[hl]!==0&&this[Yj](!0),this[Al]?this.emit("data",t):this[hEe](t),this[hl]!==0&&this.emit("readable"),n&&i(n),this[Al]):(this[hl]!==0&&this.emit("readable"),n&&i(n),this[Al])}read(t){if(this[sa])return null;if(this[mf]=!1,this[hl]===0||t===0||t&&t>this[hl])return this[y0](),null;this[Fc]&&(t=null),this[gl].length>1&&!this[Fc]&&(this[gl]=[this[fA]?this[gl].join(""):Buffer.concat(this[gl],this[hl])]);let r=this[Xet](t||null,this[gl][0]);return this[y0](),r}[Xet](t,r){if(this[Fc])this[jj]();else{let n=r;t===n.length||t===null?this[jj]():typeof n=="string"?(this[gl][0]=n.slice(t),r=n.slice(0,t),this[hl]-=t):(this[gl][0]=n.subarray(t),r=n.subarray(0,t),this[hl]-=t)}return this.emit("data",r),!this[gl].length&&!this[_0]&&this.emit("drain"),r}end(t,r,n){return typeof t=="function"&&(n=t,t=void 0),typeof r=="function"&&(n=r,r="utf8"),t!==void 0&&this.write(t,r),n&&this.once("end",n),this[_0]=!0,this.writable=!1,(this[Al]||!this[qP])&&this[y0](),this}[kN](){this[sa]||(!this[rT]&&!this[Eu].length&&(this[mf]=!0),this[qP]=!1,this[Al]=!0,this.emit("resume"),this[gl].length?this[Yj]():this[_0]?this[y0]():this.emit("drain"))}resume(){return this[kN]()}pause(){this[Al]=!1,this[qP]=!0,this[mf]=!1}get destroyed(){return this[sa]}get flowing(){return this[Al]}get paused(){return this[qP]}[hEe](t){this[Fc]?this[hl]+=1:this[hl]+=t.length,this[gl].push(t)}[jj](){return this[Fc]?this[hl]-=1:this[hl]-=this[gl][0].length,this[gl].shift()}[Yj](t=!1){do;while(this[ett](this[jj]())&&this[gl].length);!t&&!this[gl].length&&!this[_0]&&this.emit("drain")}[ett](t){return this.emit("data",t),this[Al]}pipe(t,r){if(this[sa])return t;this[mf]=!1;let n=this[Yb];return r=r||{},t===Zet.stdout||t===Zet.stderr?r.end=!1:r.end=r.end!==!1,r.proxyErrors=!!r.proxyErrors,n?r.end&&t.end():(this[Eu].push(r.proxyErrors?new CEe(this,t,r):new Wj(this,t,r)),this[Jg]?$P(()=>this[kN]()):this[kN]()),t}unpipe(t){let r=this[Eu].find(n=>n.dest===t);r&&(this[Eu].length===1?(this[Al]&&this[rT]===0&&(this[Al]=!1),this[Eu]=[]):this[Eu].splice(this[Eu].indexOf(r),1),r.unpipe())}addListener(t,r){return this.on(t,r)}on(t,r){let n=super.on(t,r);if(t==="data")this[mf]=!1,this[rT]++,!this[Eu].length&&!this[Al]&&this[kN]();else if(t==="readable"&&this[hl]!==0)super.emit("readable");else if(VQr(t)&&this[Yb])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[HP]){let i=r;this[Jg]?$P(()=>i.call(this,this[HP])):i.call(this,this[HP])}return n}removeListener(t,r){return this.off(t,r)}off(t,r){let n=super.off(t,r);return t==="data"&&(this[rT]=this.listeners("data").length,this[rT]===0&&!this[mf]&&!this[Eu].length&&(this[Al]=!1)),n}removeAllListeners(t){let r=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[rT]=0,!this[mf]&&!this[Eu].length&&(this[Al]=!1)),r}get emittedEnd(){return this[Yb]}[y0](){!this[$j]&&!this[Yb]&&!this[sa]&&this[gl].length===0&&this[_0]&&(this[$j]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[zj]&&this.emit("close"),this[$j]=!1)}emit(t,...r){let n=r[0];if(t!=="error"&&t!=="close"&&t!==sa&&this[sa])return!1;if(t==="data")return!this[Fc]&&!n?!1:this[Jg]?($P(()=>this[_Ee](n)),!0):this[_Ee](n);if(t==="end")return this[ttt]();if(t==="close"){if(this[zj]=!0,!this[Yb]&&!this[sa])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[HP]=n,super.emit(EEe,n);let o=!this[GP]||this.listeners("error").length?super.emit("error",n):!1;return this[y0](),o}else if(t==="resume"){let o=super.emit("resume");return this[y0](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let i=super.emit(t,...r);return this[y0](),i}[_Ee](t){for(let n of this[Eu])n.dest.write(t)===!1&&this.pause();let r=this[mf]?!1:super.emit("data",t);return this[y0](),r}[ttt](){return this[Yb]?!1:(this[Yb]=!0,this.readable=!1,this[Jg]?($P(()=>this[yEe]()),!0):this[yEe]())}[yEe](){if(this[ON]){let r=this[ON].end();if(r){for(let n of this[Eu])n.dest.write(r);this[mf]||super.emit("data",r)}}for(let r of this[Eu])r.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[Fc]||(t.dataLength=0);let r=this.promise();return this.on("data",n=>{t.push(n),this[Fc]||(t.dataLength+=n.length)}),await r,t}async concat(){if(this[Fc])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[fA]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,r)=>{this.on(sa,()=>r(new Error("stream destroyed"))),this.on("error",n=>r(n)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[mf]=!1;let t=!1,r=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return r();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[_0])return r();let o,s,a=f=>{this.off("data",l),this.off("end",c),this.off(sa,u),r(),s(f)},l=f=>{this.off("error",a),this.off("end",c),this.off(sa,u),this.pause(),o({value:f,done:!!this[_0]})},c=()=>{this.off("error",a),this.off("data",l),this.off(sa,u),r(),o({done:!0,value:void 0})},u=()=>a(new Error("stream destroyed"));return new Promise((f,A)=>{s=A,o=f,this.once(sa,u),this.once("error",a),this.once("end",c),this.once("data",l)})},throw:r,return:r,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[mf]=!1;let t=!1,r=()=>(this.pause(),this.off(EEe,r),this.off(sa,r),this.off("end",r),t=!0,{done:!0,value:void 0}),n=()=>{if(t)return r();let i=this.read();return i===null?r():{done:!1,value:i}};return this.once("end",r),this.once(EEe,r),this.once(sa,r),{next:n,throw:r,return:r,[Symbol.iterator](){return this}}}destroy(t){if(this[sa])return t?this.emit("error",t):this.emit(sa),this;this[sa]=!0,this[mf]=!0,this[gl].length=0,this[hl]=0;let r=this;return typeof r.close=="function"&&!this[zj]&&r.close(),t?this.emit("error",t):this.emit(sa),this}static get isStream(){return $Qr}};var aLr=oLr.native,YP={lstatSync:tLr,readdir:rLr,readdirSync:nLr,readlinkSync:iLr,realpathSync:aLr,promises:{lstat:lLr,readdir:cLr,readlink:uLr,realpath:dLr}},att=e=>!e||e===YP||e===sLr?YP:{...YP,...e,promises:{...YP.promises,...e.promises||{}}},ltt=/^\\\\\?\\([a-z]:)\\?$/i,fLr=e=>e.replace(/\//g,"\\").replace(ltt,"$1\\"),pLr=/[\\\/]/,Lp=0,ctt=1,utt=2,Zg=4,dtt=6,ftt=8,nT=10,ptt=12,Qp=15,zP=~Qp,IEe=16,ntt=32,jP=64,pA=128,Kj=256,Zj=512,itt=jP|pA|Zj,mLr=1023,TEe=e=>e.isFile()?ftt:e.isDirectory()?Zg:e.isSymbolicLink()?nT:e.isCharacterDevice()?utt:e.isBlockDevice()?dtt:e.isSocket()?ptt:e.isFIFO()?ctt:Lp,ott=new tT({max:2**12}),VP=e=>{let t=ott.get(e);if(t)return t;let r=e.normalize("NFKD");return ott.set(e,r),r},stt=new tT({max:2**12}),Jj=e=>{let t=stt.get(e);if(t)return t;let r=VP(e.toLowerCase());return stt.set(e,r),r},Xj=class extends tT{constructor(){super({max:256})}},xEe=class extends tT{constructor(t=16*1024){super({maxSize:t,sizeCalculation:r=>r.length+1})}},mtt=Symbol("PathScurry setAsCwd"),Uc=class{name;root;roots;parent;nocase;isCWD=!1;#e;#t;get dev(){return this.#t}#r;get mode(){return this.#r}#n;get nlink(){return this.#n}#o;get uid(){return this.#o}#i;get gid(){return this.#i}#l;get rdev(){return this.#l}#s;get blksize(){return this.#s}#a;get ino(){return this.#a}#d;get size(){return this.#d}#p;get blocks(){return this.#p}#f;get atimeMs(){return this.#f}#c;get mtimeMs(){return this.#c}#A;get ctimeMs(){return this.#A}#h;get birthtimeMs(){return this.#h}#E;get atime(){return this.#E}#g;get mtime(){return this.#g}#w;get ctime(){return this.#w}#_;get birthtime(){return this.#_}#I;#T;#y;#b;#C;#v;#u;#k;#B;#x;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(t,r=Lp,n,i,o,s,a){this.name=t,this.#I=o?Jj(t):VP(t),this.#u=r&mLr,this.nocase=o,this.roots=i,this.root=n||this,this.#k=s,this.#y=a.fullpath,this.#C=a.relative,this.#v=a.relativePosix,this.parent=a.parent,this.parent?this.#e=this.parent.#e:this.#e=att(a.fs)}depth(){return this.#T!==void 0?this.#T:this.parent?this.#T=this.parent.depth()+1:this.#T=0}childrenCache(){return this.#k}resolve(t){if(!t)return this;let r=this.getRootString(t),i=t.substring(r.length).split(this.splitSep);return r?this.getRoot(r).#O(i):this.#O(i)}#O(t){let r=this;for(let n of t)r=r.child(n);return r}children(){let t=this.#k.get(this);if(t)return t;let r=Object.assign([],{provisional:0});return this.#k.set(this,r),this.#u&=~IEe,r}child(t,r){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let n=this.children(),i=this.nocase?Jj(t):VP(t);for(let l of n)if(l.#I===i)return l;let o=this.parent?this.sep:"",s=this.#y?this.#y+o+t:void 0,a=this.newChild(t,Lp,{...r,parent:this,fullpath:s});return this.canReaddir()||(a.#u|=pA),n.push(a),a}relative(){if(this.isCWD)return"";if(this.#C!==void 0)return this.#C;let t=this.name,r=this.parent;if(!r)return this.#C=this.name;let n=r.relative();return n+(!n||!r.parent?"":this.sep)+t}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#v!==void 0)return this.#v;let t=this.name,r=this.parent;if(!r)return this.#v=this.fullpathPosix();let n=r.relativePosix();return n+(!n||!r.parent?"":"/")+t}fullpath(){if(this.#y!==void 0)return this.#y;let t=this.name,r=this.parent;if(!r)return this.#y=this.name;let i=r.fullpath()+(r.parent?this.sep:"")+t;return this.#y=i}fullpathPosix(){if(this.#b!==void 0)return this.#b;if(this.sep==="/")return this.#b=this.fullpath();if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(i)?this.#b=`//?/${i}`:this.#b=i}let t=this.parent,r=t.fullpathPosix(),n=r+(!r||!t.parent?"":"/")+this.name;return this.#b=n}isUnknown(){return(this.#u&Qp)===Lp}isType(t){return this[`is${t}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#u&Qp)===ftt}isDirectory(){return(this.#u&Qp)===Zg}isCharacterDevice(){return(this.#u&Qp)===utt}isBlockDevice(){return(this.#u&Qp)===dtt}isFIFO(){return(this.#u&Qp)===ctt}isSocket(){return(this.#u&Qp)===ptt}isSymbolicLink(){return(this.#u&nT)===nT}lstatCached(){return this.#u&ntt?this:void 0}readlinkCached(){return this.#B}realpathCached(){return this.#x}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(this.#B)return!0;if(!this.parent)return!1;let t=this.#u&Qp;return!(t!==Lp&&t!==nT||this.#u&Kj||this.#u&pA)}calledReaddir(){return!!(this.#u&IEe)}isENOENT(){return!!(this.#u&pA)}isNamed(t){return this.nocase?this.#I===Jj(t):this.#I===VP(t)}async readlink(){let t=this.#B;if(t)return t;if(this.canReadlink()&&this.parent)try{let r=await this.#e.promises.readlink(this.fullpath()),n=(await this.parent.realpath())?.resolve(r);if(n)return this.#B=n}catch(r){this.#N(r.code);return}}readlinkSync(){let t=this.#B;if(t)return t;if(this.canReadlink()&&this.parent)try{let r=this.#e.readlinkSync(this.fullpath()),n=this.parent.realpathSync()?.resolve(r);if(n)return this.#B=n}catch(r){this.#N(r.code);return}}#P(t){this.#u|=IEe;for(let r=t.provisional;r<t.length;r++){let n=t[r];n&&n.#S()}}#S(){this.#u&pA||(this.#u=(this.#u|pA)&zP,this.#$())}#$(){let t=this.children();t.provisional=0;for(let r of t)r.#S()}#L(){this.#u|=Zj,this.#M()}#M(){if(this.#u&jP)return;let t=this.#u;(t&Qp)===Zg&&(t&=zP),this.#u=t|jP,this.#$()}#F(t=""){t==="ENOTDIR"||t==="EPERM"?this.#M():t==="ENOENT"?this.#S():this.children().provisional=0}#R(t=""){t==="ENOTDIR"?this.parent.#M():t==="ENOENT"&&this.#S()}#N(t=""){let r=this.#u;r|=Kj,t==="ENOENT"&&(r|=pA),(t==="EINVAL"||t==="UNKNOWN")&&(r&=zP),this.#u=r,t==="ENOTDIR"&&this.parent&&this.parent.#M()}#U(t,r){return this.#q(t,r)||this.#H(t,r)}#H(t,r){let n=TEe(t),i=this.newChild(t.name,n,{parent:this}),o=i.#u&Qp;return o!==Zg&&o!==nT&&o!==Lp&&(i.#u|=jP),r.unshift(i),r.provisional++,i}#q(t,r){for(let n=r.provisional;n<r.length;n++){let i=r[n];if((this.nocase?Jj(t.name):VP(t.name))===i.#I)return this.#m(t,i,n,r)}}#m(t,r,n,i){let o=r.name;return r.#u=r.#u&zP|TEe(t),o!==t.name&&(r.name=t.name),n!==i.provisional&&(n===i.length-1?i.pop():i.splice(n,1),i.unshift(r)),i.provisional++,r}async lstat(){if((this.#u&pA)===0)try{return this.#G(await this.#e.promises.lstat(this.fullpath())),this}catch(t){this.#R(t.code)}}lstatSync(){if((this.#u&pA)===0)try{return this.#G(this.#e.lstatSync(this.fullpath())),this}catch(t){this.#R(t.code)}}#G(t){let{atime:r,atimeMs:n,birthtime:i,birthtimeMs:o,blksize:s,blocks:a,ctime:l,ctimeMs:c,dev:u,gid:f,ino:A,mode:m,mtime:g,mtimeMs:E,nlink:_,rdev:C,size:S,uid:T}=t;this.#E=r,this.#f=n,this.#_=i,this.#h=o,this.#s=s,this.#p=a,this.#w=l,this.#A=c,this.#t=u,this.#i=f,this.#a=A,this.#r=m,this.#g=g,this.#c=E,this.#n=_,this.#l=C,this.#d=S,this.#o=T;let w=TEe(t);this.#u=this.#u&zP|w|ntt,w!==Lp&&w!==Zg&&w!==nT&&(this.#u|=jP)}#Q=[];#D=!1;#z(t){this.#D=!1;let r=this.#Q.slice();this.#Q.length=0,r.forEach(n=>n(null,t))}readdirCB(t,r=!1){if(!this.canReaddir()){r?t(null,[]):queueMicrotask(()=>t(null,[]));return}let n=this.children();if(this.calledReaddir()){let o=n.slice(0,n.provisional);r?t(null,o):queueMicrotask(()=>t(null,o));return}if(this.#Q.push(t),this.#D)return;this.#D=!0;let i=this.fullpath();this.#e.readdir(i,{withFileTypes:!0},(o,s)=>{if(o)this.#F(o.code),n.provisional=0;else{for(let a of s)this.#U(a,n);this.#P(n)}this.#z(n.slice(0,n.provisional))})}#Y;async readdir(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let r=this.fullpath();if(this.#Y)await this.#Y;else{let n=()=>{};this.#Y=new Promise(i=>n=i);try{for(let i of await this.#e.promises.readdir(r,{withFileTypes:!0}))this.#U(i,t);this.#P(t)}catch(i){this.#F(i.code),t.provisional=0}this.#Y=void 0,n()}return t.slice(0,t.provisional)}readdirSync(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let r=this.fullpath();try{for(let n of this.#e.readdirSync(r,{withFileTypes:!0}))this.#U(n,t);this.#P(t)}catch(n){this.#F(n.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(this.#u&itt)return!1;let t=Qp&this.#u;return t===Lp||t===Zg||t===nT}shouldWalk(t,r){return(this.#u&Zg)===Zg&&!(this.#u&itt)&&!t.has(this)&&(!r||r(this))}async realpath(){if(this.#x)return this.#x;if(!((Zj|Kj|pA)&this.#u))try{let t=await this.#e.promises.realpath(this.fullpath());return this.#x=this.resolve(t)}catch{this.#L()}}realpathSync(){if(this.#x)return this.#x;if(!((Zj|Kj|pA)&this.#u))try{let t=this.#e.realpathSync(this.fullpath());return this.#x=this.resolve(t)}catch{this.#L()}}[mtt](t){if(t===this)return;t.isCWD=!1,this.isCWD=!0;let r=new Set([]),n=[],i=this;for(;i&&i.parent;)r.add(i),i.#C=n.join(this.sep),i.#v=n.join("/"),i=i.parent,n.push("..");for(i=t;i&&i.parent&&!r.has(i);)i.#C=void 0,i.#v=void 0,i=i.parent}},eV=class e extends Uc{sep="\\";splitSep=pLr;constructor(t,r=Lp,n,i,o,s,a){super(t,r,n,i,o,s,a)}newChild(t,r=Lp,n={}){return new e(t,r,this.root,this.roots,this.nocase,this.childrenCache(),n)}getRootString(t){return vEe.parse(t).root}getRoot(t){if(t=fLr(t.toUpperCase()),t===this.root.name)return this.root;for(let[r,n]of Object.entries(this.roots))if(this.sameRoot(t,r))return this.roots[t]=n;return this.roots[t]=new MN(t,this).root}sameRoot(t,r=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(ltt,"$1\\"),t===r}},tV=class e extends Uc{splitSep="/";sep="/";constructor(t,r=Lp,n,i,o,s,a){super(t,r,n,i,o,s,a)}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,r=Lp,n={}){return new e(t,r,this.root,this.roots,this.nocase,this.childrenCache(),n)}},rV=class{root;rootPath;roots;cwd;#e;#t;#r;nocase;#n;constructor(t=process.cwd(),r,n,{nocase:i,childrenCacheSize:o=16*1024,fs:s=YP}={}){this.#n=att(s),(t instanceof URL||t.startsWith("file://"))&&(t=eLr(t));let a=r.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),this.#e=new Xj,this.#t=new Xj,this.#r=new xEe(o);let l=a.substring(this.rootPath.length).split(n);if(l.length===1&&!l[0]&&l.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(this.#n),this.roots[this.rootPath]=this.root;let c=this.root,u=l.length-1,f=r.sep,A=this.rootPath,m=!1;for(let g of l){let E=u--;c=c.child(g,{relative:new Array(E).fill("..").join(f),relativePosix:new Array(E).fill("..").join("/"),fullpath:A+=(m?"":f)+g}),m=!0}this.cwd=c}depth(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.depth()}childrenCache(){return this.#r}resolve(...t){let r="";for(let o=t.length-1;o>=0;o--){let s=t[o];if(!(!s||s===".")&&(r=r?`${s}/${r}`:s,this.isAbsolute(s)))break}let n=this.#e.get(r);if(n!==void 0)return n;let i=this.cwd.resolve(r).fullpath();return this.#e.set(r,i),i}resolvePosix(...t){let r="";for(let o=t.length-1;o>=0;o--){let s=t[o];if(!(!s||s===".")&&(r=r?`${s}/${r}`:s,this.isAbsolute(s)))break}let n=this.#t.get(r);if(n!==void 0)return n;let i=this.cwd.resolve(r).fullpathPosix();return this.#t.set(r,i),i}relative(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relative()}relativePosix(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relativePosix()}basename(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.name}dirname(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),(t.parent||t).fullpath()}async readdir(t=this.cwd,r={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Uc||(r=t,t=this.cwd);let{withFileTypes:n}=r;if(t.canReaddir()){let i=await t.readdir();return n?i:i.map(o=>o.name)}else return[]}readdirSync(t=this.cwd,r={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Uc||(r=t,t=this.cwd);let{withFileTypes:n=!0}=r;return t.canReaddir()?n?t.readdirSync():t.readdirSync().map(i=>i.name):[]}async lstat(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstat()}lstatSync(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstatSync()}async readlink(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Uc||(r=t.withFileTypes,t=this.cwd);let n=await t.readlink();return r?n:n?.fullpath()}readlinkSync(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Uc||(r=t.withFileTypes,t=this.cwd);let n=t.readlinkSync();return r?n:n?.fullpath()}async realpath(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Uc||(r=t.withFileTypes,t=this.cwd);let n=await t.realpath();return r?n:n?.fullpath()}realpathSync(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Uc||(r=t.withFileTypes,t=this.cwd);let n=t.realpathSync();return r?n:n?.fullpath()}async walk(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Uc||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:o,walkFilter:s}=r,a=[];(!o||o(t))&&a.push(n?t:t.fullpath());let l=new Set,c=(f,A)=>{l.add(f),f.readdirCB((m,g)=>{if(m)return A(m);let E=g.length;if(!E)return A();let _=()=>{--E===0&&A()};for(let C of g)(!o||o(C))&&a.push(n?C:C.fullpath()),i&&C.isSymbolicLink()?C.realpath().then(S=>S?.isUnknown()?S.lstat():S).then(S=>S?.shouldWalk(l,s)?c(S,_):_()):C.shouldWalk(l,s)?c(C,_):_()},!0)},u=t;return new Promise((f,A)=>{c(u,m=>{if(m)return A(m);f(a)})})}walkSync(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Uc||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:o,walkFilter:s}=r,a=[];(!o||o(t))&&a.push(n?t:t.fullpath());let l=new Set([t]);for(let c of l){let u=c.readdirSync();for(let f of u){(!o||o(f))&&a.push(n?f:f.fullpath());let A=f;if(f.isSymbolicLink()){if(!(i&&(A=f.realpathSync())))continue;A.isUnknown()&&A.lstatSync()}A.shouldWalk(l,s)&&l.add(A)}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(t=this.cwd,r={}){return typeof t=="string"?t=this.cwd.resolve(t):t instanceof Uc||(r=t,t=this.cwd),this.stream(t,r)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Uc||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:o,walkFilter:s}=r;(!o||o(t))&&(yield n?t:t.fullpath());let a=new Set([t]);for(let l of a){let c=l.readdirSync();for(let u of c){(!o||o(u))&&(yield n?u:u.fullpath());let f=u;if(u.isSymbolicLink()){if(!(i&&(f=u.realpathSync())))continue;f.isUnknown()&&f.lstatSync()}f.shouldWalk(a,s)&&a.add(f)}}}stream(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Uc||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:o,walkFilter:s}=r,a=new jb({objectMode:!0});(!o||o(t))&&a.write(n?t:t.fullpath());let l=new Set,c=[t],u=0,f=()=>{let A=!1;for(;!A;){let m=c.shift();if(!m){u===0&&a.end();return}u++,l.add(m);let g=(_,C,S=!1)=>{if(_)return a.emit("error",_);if(i&&!S){let T=[];for(let w of C)w.isSymbolicLink()&&T.push(w.realpath().then(O=>O?.isUnknown()?O.lstat():O));if(T.length){Promise.all(T).then(()=>g(null,C,!0));return}}for(let T of C)T&&(!o||o(T))&&(a.write(n?T:T.fullpath())||(A=!0));u--;for(let T of C){let w=T.realpathCached()||T;w.shouldWalk(l,s)&&c.push(w)}A&&!a.flowing?a.once("drain",f):E||f()},E=!0;m.readdirCB(g,!0),E=!1}};return f(),a}streamSync(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof Uc||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:o,walkFilter:s}=r,a=new jb({objectMode:!0}),l=new Set;(!o||o(t))&&a.write(n?t:t.fullpath());let c=[t],u=0,f=()=>{let A=!1;for(;!A;){let m=c.shift();if(!m){u===0&&a.end();return}u++,l.add(m);let g=m.readdirSync();for(let E of g)(!o||o(E))&&(a.write(n?E:E.fullpath())||(A=!0));u--;for(let E of g){let _=E;if(E.isSymbolicLink()){if(!(i&&(_=E.realpathSync())))continue;_.isUnknown()&&_.lstatSync()}_.shouldWalk(l,s)&&c.push(_)}}A&&!a.flowing&&a.once("drain",f)};return f(),a}chdir(t=this.cwd){let r=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[mtt](r)}},MN=class extends rV{sep="\\";constructor(t=process.cwd(),r={}){let{nocase:n=!0}=r;super(t,vEe,"\\",{...r,nocase:n}),this.nocase=n;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(t){return vEe.parse(t).root.toUpperCase()}newRoot(t){return new eV(this.rootPath,Zg,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},QN=class extends rV{sep="/";constructor(t=process.cwd(),r={}){let{nocase:n=!1}=r;super(t,XQr,"/",{...r,nocase:n}),this.nocase=n}parseRootPath(t){return"/"}newRoot(t){return new tV(this.rootPath,Zg,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},WP=class extends QN{constructor(t=process.cwd(),r={}){let{nocase:n=!0}=r;super(t,{...r,nocase:n})}},Api=process.platform==="win32"?eV:tV,Att=process.platform==="win32"?MN:process.platform==="darwin"?WP:QN;var ALr=e=>e.length>=1,gLr=e=>e.length>=1,LN=class e{#e;#t;#r;length;#n;#o;#i;#l;#s;#a;#d=!0;constructor(t,r,n,i){if(!ALr(t))throw new TypeError("empty pattern list");if(!gLr(r))throw new TypeError("empty glob list");if(r.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,n<0||n>=this.length)throw new TypeError("index out of range");if(this.#e=t,this.#t=r,this.#r=n,this.#n=i,this.#r===0){if(this.isUNC()){let[o,s,a,l,...c]=this.#e,[u,f,A,m,...g]=this.#t;c[0]===""&&(c.shift(),g.shift());let E=[o,s,a,l,""].join("/"),_=[u,f,A,m,""].join("/");this.#e=[E,...c],this.#t=[_,...g],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[o,...s]=this.#e,[a,...l]=this.#t;s[0]===""&&(s.shift(),l.shift());let c=o+"/",u=a+"/";this.#e=[c,...s],this.#t=[u,...l],this.length=this.#e.length}}}pattern(){return this.#e[this.#r]}isString(){return typeof this.#e[this.#r]=="string"}isGlobstar(){return this.#e[this.#r]===ec}isRegExp(){return this.#e[this.#r]instanceof RegExp}globString(){return this.#i=this.#i||(this.#r===0?this.isAbsolute()?this.#t[0]+this.#t.slice(1).join("/"):this.#t.join("/"):this.#t.slice(this.#r).join("/"))}hasMore(){return this.length>this.#r+1}rest(){return this.#o!==void 0?this.#o:this.hasMore()?(this.#o=new e(this.#e,this.#t,this.#r+1,this.#n),this.#o.#a=this.#a,this.#o.#s=this.#s,this.#o.#l=this.#l,this.#o):this.#o=null}isUNC(){let t=this.#e;return this.#s!==void 0?this.#s:this.#s=this.#n==="win32"&&this.#r===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3]}isDrive(){let t=this.#e;return this.#l!==void 0?this.#l:this.#l=this.#n==="win32"&&this.#r===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0])}isAbsolute(){let t=this.#e;return this.#a!==void 0?this.#a:this.#a=t[0]===""&&t.length>1||this.isDrive()||this.isUNC()}root(){let t=this.#e[0];return typeof t=="string"&&this.isAbsolute()&&this.#r===0?t:""}checkFollowGlobstar(){return!(this.#r===0||!this.isGlobstar()||!this.#d)}markFollowGlobstar(){return this.#r===0||!this.isGlobstar()||!this.#d?!1:(this.#d=!1,!0)}};var hLr=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",PN=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(t,{nobrace:r,nocase:n,noext:i,noglobstar:o,platform:s=hLr}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=s,this.mmopts={dot:!0,nobrace:r,nocase:n,noext:i,noglobstar:o,optimizationLevel:2,platform:s,nocomment:!0,nonegate:!0};for(let a of t)this.add(a)}add(t){let r=new pf(t,this.mmopts);for(let n=0;n<r.set.length;n++){let i=r.set[n],o=r.globParts[n];if(!i||!o)throw new Error("invalid pattern object");for(;i[0]==="."&&o[0]===".";)i.shift(),o.shift();let s=new LN(i,o,0,this.platform),a=new pf(s.globString(),this.mmopts),l=o[o.length-1]==="**",c=s.isAbsolute();c?this.absolute.push(a):this.relative.push(a),l&&(c?this.absoluteChildren.push(a):this.relativeChildren.push(a))}}ignored(t){let r=t.fullpath(),n=`${r}/`,i=t.relative()||".",o=`${i}/`;for(let s of this.relative)if(s.match(i)||s.match(o))return!0;for(let s of this.absolute)if(s.match(r)||s.match(n))return!0;return!1}childrenIgnored(t){let r=t.fullpath()+"/",n=(t.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(n))return!0;for(let i of this.absoluteChildren)if(i.match(r))return!0;return!1}};var wEe=class e{store;constructor(t=new Map){this.store=t}copy(){return new e(new Map(this.store))}hasWalked(t,r){return this.store.get(t.fullpath())?.has(r.globString())}storeWalked(t,r){let n=t.fullpath(),i=this.store.get(n);i?i.add(r.globString()):this.store.set(n,new Set([r.globString()]))}},DEe=class{store=new Map;add(t,r,n){let i=(r?2:0)|(n?1:0),o=this.store.get(t);this.store.set(t,o===void 0?i:i&o)}entries(){return[...this.store.entries()].map(([t,r])=>[t,!!(r&2),!!(r&1)])}},REe=class{store=new Map;add(t,r){if(!t.canReaddir())return;let n=this.store.get(t);n?n.find(i=>i.globString()===r.globString())||n.push(r):this.store.set(t,[r])}get(t){let r=this.store.get(t);if(!r)throw new Error("attempting to walk unknown path");return r}entries(){return this.keys().map(t=>[t,this.store.get(t)])}keys(){return[...this.store.keys()].filter(t=>t.canReaddir())}},KP=class e{hasWalkedCache;matches=new DEe;subwalks=new REe;patterns;follow;dot;opts;constructor(t,r){this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=r?r.copy():new wEe}processPatterns(t,r){this.patterns=r;let n=r.map(i=>[t,i]);for(let[i,o]of n){this.hasWalkedCache.storeWalked(i,o);let s=o.root(),a=o.isAbsolute()&&this.opts.absolute!==!1;if(s){i=i.resolve(s==="/"&&this.opts.root!==void 0?this.opts.root:s);let f=o.rest();if(f)o=f;else{this.matches.add(i,!0,!1);continue}}if(i.isENOENT())continue;let l,c,u=!1;for(;typeof(l=o.pattern())=="string"&&(c=o.rest());)i=i.resolve(l),o=c,u=!0;if(l=o.pattern(),c=o.rest(),u){if(this.hasWalkedCache.hasWalked(i,o))continue;this.hasWalkedCache.storeWalked(i,o)}if(typeof l=="string"){let f=l===".."||l===""||l===".";this.matches.add(i.resolve(l),a,f);continue}else if(l===ec){(!i.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(i,o);let f=c?.pattern(),A=c?.rest();if(!c||(f===""||f===".")&&!A)this.matches.add(i,a,f===""||f===".");else if(f===".."){let m=i.parent||i;A?this.hasWalkedCache.hasWalked(m,A)||this.subwalks.add(m,A):this.matches.add(m,a,!0)}}else l instanceof RegExp&&this.subwalks.add(i,o)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new e(this.opts,this.hasWalkedCache)}filterEntries(t,r){let n=this.subwalks.get(t),i=this.child();for(let o of r)for(let s of n){let a=s.isAbsolute(),l=s.pattern(),c=s.rest();l===ec?i.testGlobstar(o,s,c,a):l instanceof RegExp?i.testRegExp(o,l,c,a):i.testString(o,l,c,a)}return i}testGlobstar(t,r,n,i){if((this.dot||!t.name.startsWith("."))&&(r.hasMore()||this.matches.add(t,i,!1),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,r):t.isSymbolicLink()&&(n&&r.checkFollowGlobstar()?this.subwalks.add(t,n):r.markFollowGlobstar()&&this.subwalks.add(t,r)))),n){let o=n.pattern();if(typeof o=="string"&&o!==".."&&o!==""&&o!==".")this.testString(t,o,n.rest(),i);else if(o===".."){let s=t.parent||t;this.subwalks.add(s,n)}else o instanceof RegExp&&this.testRegExp(t,o,n.rest(),i)}}testRegExp(t,r,n,i){r.test(t.name)&&(n?this.subwalks.add(t,n):this.matches.add(t,i,!1))}testString(t,r,n,i){t.isNamed(r)&&(n?this.subwalks.add(t,n):this.matches.add(t,i,!1))}};var ELr=(e,t)=>typeof e=="string"?new PN([e],t):Array.isArray(e)?new PN(e,t):e,nV=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#e=[];#t;#r;signal;maxDepth;includeChildMatches;constructor(t,r,n){if(this.patterns=t,this.path=r,this.opts=n,this.#r=!n.posix&&n.platform==="win32"?"\\":"/",this.includeChildMatches=n.includeChildMatches!==!1,(n.ignore||!this.includeChildMatches)&&(this.#t=ELr(n.ignore??[],n),!this.includeChildMatches&&typeof this.#t.add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=n.maxDepth||1/0,n.signal&&(this.signal=n.signal,this.signal.addEventListener("abort",()=>{this.#e.length=0}))}#n(t){return this.seen.has(t)||!!this.#t?.ignored?.(t)}#o(t){return!!this.#t?.childrenIgnored?.(t)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let t;for(;!this.paused&&(t=this.#e.shift());)t()}onResume(t){this.signal?.aborted||(this.paused?this.#e.push(t):t())}async matchCheck(t,r){if(r&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=t.realpathCached()||await t.realpath(),!n)return;t=n}let o=t.isUnknown()||this.opts.stat?await t.lstat():t;if(this.opts.follow&&this.opts.nodir&&o?.isSymbolicLink()){let s=await o.realpath();s&&(s.isUnknown()||this.opts.stat)&&await s.lstat()}return this.matchCheckTest(o,r)}matchCheckTest(t,r){return t&&(this.maxDepth===1/0||t.depth()<=this.maxDepth)&&(!r||t.canReaddir())&&(!this.opts.nodir||!t.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!t.isSymbolicLink()||!t.realpathCached()?.isDirectory())&&!this.#n(t)?t:void 0}matchCheckSync(t,r){if(r&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=t.realpathCached()||t.realpathSync(),!n)return;t=n}let o=t.isUnknown()||this.opts.stat?t.lstatSync():t;if(this.opts.follow&&this.opts.nodir&&o?.isSymbolicLink()){let s=o.realpathSync();s&&(s?.isUnknown()||this.opts.stat)&&s.lstatSync()}return this.matchCheckTest(o,r)}matchFinish(t,r){if(this.#n(t))return;if(!this.includeChildMatches&&this.#t?.add){let o=`${t.relativePosix()}/**`;this.#t.add(o)}let n=this.opts.absolute===void 0?r:this.opts.absolute;this.seen.add(t);let i=this.opts.mark&&t.isDirectory()?this.#r:"";if(this.opts.withFileTypes)this.matchEmit(t);else if(n){let o=this.opts.posix?t.fullpathPosix():t.fullpath();this.matchEmit(o+i)}else{let o=this.opts.posix?t.relativePosix():t.relative(),s=this.opts.dotRelative&&!o.startsWith(".."+this.#r)?"."+this.#r:"";this.matchEmit(o?s+o+i:"."+i)}}async match(t,r,n){let i=await this.matchCheck(t,n);i&&this.matchFinish(i,r)}matchSync(t,r,n){let i=this.matchCheckSync(t,n);i&&this.matchFinish(i,r)}walkCB(t,r,n){this.signal?.aborted&&n(),this.walkCB2(t,r,new KP(this.opts),n)}walkCB2(t,r,n,i){if(this.#o(t))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(t,r,n,i));return}n.processPatterns(t,r);let o=1,s=()=>{--o===0&&i()};for(let[a,l,c]of n.matches.entries())this.#n(a)||(o++,this.match(a,l,c).then(()=>s()));for(let a of n.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;o++;let l=a.readdirCached();a.calledReaddir()?this.walkCB3(a,l,n,s):a.readdirCB((c,u)=>this.walkCB3(a,u,n,s),!0)}s()}walkCB3(t,r,n,i){n=n.filterEntries(t,r);let o=1,s=()=>{--o===0&&i()};for(let[a,l,c]of n.matches.entries())this.#n(a)||(o++,this.match(a,l,c).then(()=>s()));for(let[a,l]of n.subwalks.entries())o++,this.walkCB2(a,l,n.child(),s);s()}walkCBSync(t,r,n){this.signal?.aborted&&n(),this.walkCB2Sync(t,r,new KP(this.opts),n)}walkCB2Sync(t,r,n,i){if(this.#o(t))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(t,r,n,i));return}n.processPatterns(t,r);let o=1,s=()=>{--o===0&&i()};for(let[a,l,c]of n.matches.entries())this.#n(a)||this.matchSync(a,l,c);for(let a of n.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;o++;let l=a.readdirSync();this.walkCB3Sync(a,l,n,s)}s()}walkCB3Sync(t,r,n,i){n=n.filterEntries(t,r);let o=1,s=()=>{--o===0&&i()};for(let[a,l,c]of n.matches.entries())this.#n(a)||this.matchSync(a,l,c);for(let[a,l]of n.subwalks.entries())o++,this.walkCB2Sync(a,l,n.child(),s);s()}},JP=class extends nV{matches=new Set;constructor(t,r,n){super(t,r,n)}matchEmit(t){this.matches.add(t)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((t,r)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?r(this.signal.reason):t(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},ZP=class extends nV{results;constructor(t,r,n){super(t,r,n),this.results=new jb({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(t){this.results.write(t),this.results.flowing||this.pause()}stream(){let t=this.path;return t.isUnknown()?t.lstat().then(()=>{this.walkCB(t,this.patterns,()=>this.results.end())}):this.walkCB(t,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}};var yLr=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",mA=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(t,r){if(!r)throw new TypeError("glob options required");if(this.withFileTypes=!!r.withFileTypes,this.signal=r.signal,this.follow=!!r.follow,this.dot=!!r.dot,this.dotRelative=!!r.dotRelative,this.nodir=!!r.nodir,this.mark=!!r.mark,r.cwd?(r.cwd instanceof URL||r.cwd.startsWith("file://"))&&(r.cwd=_Lr(r.cwd)):this.cwd="",this.cwd=r.cwd||"",this.root=r.root,this.magicalBraces=!!r.magicalBraces,this.nobrace=!!r.nobrace,this.noext=!!r.noext,this.realpath=!!r.realpath,this.absolute=r.absolute,this.includeChildMatches=r.includeChildMatches!==!1,this.noglobstar=!!r.noglobstar,this.matchBase=!!r.matchBase,this.maxDepth=typeof r.maxDepth=="number"?r.maxDepth:1/0,this.stat=!!r.stat,this.ignore=r.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof t=="string"&&(t=[t]),this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(t=t.map(l=>l.replace(/\\/g,"/"))),this.matchBase){if(r.noglobstar)throw new TypeError("base matching requires globstar");t=t.map(l=>l.includes("/")?l:`./**/${l}`)}if(this.pattern=t,this.platform=r.platform||yLr,this.opts={...r,platform:this.platform},r.scurry){if(this.scurry=r.scurry,r.nocase!==void 0&&r.nocase!==r.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let l=r.platform==="win32"?MN:r.platform==="darwin"?WP:r.platform?QN:Att;this.scurry=new l(this.cwd,{nocase:r.nocase,fs:r.fs})}this.nocase=this.scurry.nocase;let n=this.platform==="darwin"||this.platform==="win32",i={...r,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:n,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},o=this.pattern.map(l=>new pf(l,i)),[s,a]=o.reduce((l,c)=>(l[0].push(...c.set),l[1].push(...c.globParts),l),[[],[]]);this.patterns=s.map((l,c)=>{let u=a[c];if(!u)throw new Error("invalid pattern object");return new LN(l,u,0,this.platform)})}async walk(){return[...await new JP(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new JP(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new ZP(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new ZP(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}};var NEe=(e,t={})=>{Array.isArray(e)||(e=[e]);for(let r of e)if(new pf(r,t).hasMagic())return!0;return!1};function oV(e,t={}){return new mA(e,t).streamSync()}function htt(e,t={}){return new mA(e,t).stream()}function Ett(e,t={}){return new mA(e,t).walkSync()}async function gtt(e,t={}){return new mA(e,t).walk()}function sV(e,t={}){return new mA(e,t).iterateSync()}function _tt(e,t={}){return new mA(e,t).iterate()}var bLr=oV,CLr=Object.assign(htt,{sync:oV}),SLr=sV,ILr=Object.assign(_tt,{sync:sV}),TLr=Object.assign(Ett,{stream:oV,iterate:sV}),iV=Object.assign(gtt,{glob:gtt,globSync:Ett,sync:TLr,globStream:htt,stream:CLr,globStreamSync:oV,streamSync:bLr,globIterate:_tt,iterate:ILr,globIterateSync:sV,iterateSync:SLr,Glob:mA,hasMagic:NEe,escape:NN,unescape:dA});iV.glob=iV;CN();var cV=Z(wtt(),1);Ir();He();import{cwd as Ott}from"process";async function Utt(e,t,{limit:r,offset:n},i){let s=(await iV([e],{cwd:t,nocase:!0,nodir:!0,signal:i,stat:!0,withFileTypes:!0})).sort((l,c)=>(l.mtimeMs??0)-(c.mtimeMs??0)),a=s.length>n+r;return{files:s.slice(n,n+r).map(l=>l.fullpath()),truncated:a}}function Htt(e,t){if(e===".")return!0;if(e.startsWith("~")||e.includes("\0")||t.includes("\0"))return!1;let r=Dtt(e),n=Dtt(t);r=r.endsWith(lV)?r:r+lV,n=n.endsWith(lV)?n:n+lV;let i=Rtt(Ott(),n,r),o=Rtt(Ott(),n);return i.startsWith(o)}function uV(e,t=0,r){try{if(!Ptt(e).isFile())return{content:"",lineCount:0,totalLines:0}}catch(a){return Ce(`Error accessing file ${e}: ${a}`),{content:"",lineCount:0,totalLines:0}}let n=Pp(e),i=RLr(e,n),o=i.length===0?[]:i.split(/\r?\n/),s=r!==void 0&&o.length-t>r?o.slice(t,t+r):o.slice(t);return{content:s.join(`
583
583
  `),lineCount:s.length,totalLines:o.length}}function HN(e,t,r,n){let i=t;n==="CRLF"&&(i=t.split(`
@@ -750,7 +750,7 @@ data: ${JSON.stringify(z)}
750
750
  `);a=Q.pop()||"";for(let z of Q){let V=z.trim();if(!(!V||V==="data: [DONE]"))if(V.startsWith("data: ")){let M=V.slice(6);try{let G=JSON.parse(M);w(G)}catch(G){this.logger&&this.logger.error({err:G,line:V},"Failed to parse Gemini SSE chunk")}}else try{let M=JSON.parse(V);w(M)}catch{}}};(async()=>{try{for(;;){let{value:Q,done:z}=await s.read();if(z)break;a+=n.decode(Q,{stream:!0}),O()}T()}catch(Q){o.error(Q)}})()}})}convertGeminiResponseToAnthropic(t){this.logger&&this.logger.debug({response:t},"Original Gemini response");try{if(!t.candidates||!t.candidates[0])throw new Error("No candidates found in Gemini response");let r=t.candidates[0],n=[];r.content&&r.content.parts&&r.content.parts.forEach(o=>{if(o.text&&n.push({type:"text",text:o.text}),o.functionCall){let s=`toolu_${dB()}`,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:`
751
751
 
752
752
  [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 $9r(`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"}}},V_e=new j_e;var rpt=Z(Xft(),1);hr();ls();function IA(e){return e?typeof e.entries=="function"?Object.fromEntries(e.entries()):{...e}:{}}function ept(e){let t=String(e?.["x-thinking-level"]??"medium").toLowerCase();return["off","low","medium","high"].includes(t)?t:"medium"}function iZr(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t}}function oZr(e,t){if(t==="off"){delete e.reasoning;return}e.reasoning={effort:t,summary:"auto"}}function sZr(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,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.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}function JU(e,t,r){O$(t,e),k$(t,sZr(e,r),r)}function XB(e){let t=[],r=e.getReader(),n,i=new Promise(l=>n=l),o=!1,s=()=>{o||(o=!0,n(Buffer.concat(t).toString("utf8")))};return{stream:new ReadableStream({async pull(l){try{let{done:c,value:u}=await r.read();if(c){l.close(),s();return}t.push(u),l.enqueue(u)}catch(c){l.error(c),s()}},cancel(l){r.cancel(l).catch(()=>{}),s()}}),done:i}}function ZU(e){let t=new Headers(e);return t.delete("content-encoding"),t.delete("content-length"),t.delete("transfer-encoding"),t}function CSe(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 tpt=["/v1/messages"];function SSe(e){let t;try{typeof e=="string"?t=new KT(e):e instanceof KT?t=e:t=new KT(e.url)}catch{return""}let r=t.pathname;for(let n of tpt){let i=r.indexOf(n);if(i!==-1)return t.origin+r.slice(0,i)}return t.origin}function YJ(e,t){let r=typeof e=="string"?e:e instanceof KT?e.toString():e.url,n;try{n=new KT(r).pathname}catch{return!1}return tpt.some(i=>n.includes(i))&&(t.method==="POST"||t.method==="post")}function aZr(e){return async(t,r)=>{if(!YJ(t,r))return e(t,r);let n=JSON.parse(r.body),i=await jW.transformRequestOut(n),o=SSe(t)+"/chat/completions",s=IA(r.headers),a=s.authorization??s.Authorization??"";iZr(i,ept(s));let l=await e(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:a},body:JSON.stringify(i),signal:r.signal});if(!l.ok){let _=await l.text();return ae(`OpenAI Chat Completions API error: ${l.status}`,{url:o,errorResponse:_}),CSe("OpenAI Chat Completions API error","OPENROUTER",l.status,l.statusText,_)}let c=n.stream===!0,u=s["x-agent-id"],f={request:{url:o,method:r.method,headers:s,body:n},response:{status:l.status,statusText:l.statusText,headers:IA(l.headers)},openai:{request:{body:i},response:{}}};if(!c){let _=await l.text(),C=new Response(_,{status:l.status,statusText:l.statusText,headers:ZU(l.headers)}),S=await jW.transformResponseIn(C,n),T=await S.text();try{JU({...f,openai:{...f.openai,response:{body:JSON.parse(_)}},response:{...f.response,body:JSON.parse(T)}},u)}catch(w){ae("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u975E\u6D41\u5F0F):",w)}return new Response(T,{status:S.status,statusText:S.statusText,headers:S.headers})}let A=XB(l.body),m=new Response(A.stream,{status:l.status,statusText:l.statusText,headers:ZU(l.headers)}),g=await jW.transformResponseIn(m,n),E=XB(g.body);return Promise.all([A.done,E.done]).then(async([_,C])=>{try{JU({...f,openai:{...f.openai,response:{body:await Dnt(_)}},response:{...f.response,body:await GF(C)}},u)}catch(S){ae("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Chat \u6D41\u5F0F):"+S?.stack)}}).catch(_=>ae("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Chat):"+_)),new Response(E.stream,{status:g.status,statusText:g.statusText,headers:g.headers})}}function lZr(e){return async(t,r)=>{if(!YJ(t,r))return e(t,r);let n=JSON.parse(r.body),i=await VW.transformRequestOut(n),o=IA(r.headers);oZr(i,ept(o));let s=JSON.stringify(i),l=SSe(t)+"/responses",c=o.authorization??o.Authorization??"";if(!c)return new Response(JSON.stringify({type:"error",error:{type:"api_error",message:"Missing Authorization header",code:"RESPONSES_AUTH_MISSING"}}),{status:401,headers:{"Content-Type":"application/json"}});let u=await e(l,{method:"POST",headers:{"Content-Type":"application/json",Authorization:c,"x-api-key":c.replace(/^Bearer\s+/i,"").trim()},body:s,signal:r.signal});if(!u.ok){let S=await u.text();return ae(`OpenAI Responses API error: ${u.status} ${u.statusText}`,{url:l,status:u.status,errorResponse:S}),CSe("OpenAI Responses API error","RESPONSES",u.status,u.statusText,S)}let f=n.stream===!0,A=o["x-agent-id"],m={request:{url:l,method:r.method,headers:o,body:n},response:{status:u.status,statusText:u.statusText,headers:IA(u.headers)},openai:{request:{body:i},response:{}}};if(!f){let S=await u.text(),T=new Response(S,{status:u.status,statusText:u.statusText,headers:ZU(u.headers)}),w=await VW.transformResponseIn(T,n),O=await w.text();try{JU({...m,openai:{...m.openai,response:{body:JSON.parse(S)}},response:{...m.response,body:JSON.parse(O)}},A,"responses")}catch(Q){ae("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u975E\u6D41\u5F0F):",Q)}return new Response(O,{status:w.status,statusText:w.statusText,headers:w.headers})}let g=XB(u.body),E=new Response(g.stream,{status:u.status,statusText:u.statusText,headers:ZU(u.headers)}),_=await VW.transformResponseIn(E,n),C=XB(_.body);return Promise.all([g.done,C.done]).then(async([S,T])=>{try{JU({...m,openai:{...m.openai,response:{body:await wnt(S)}},response:{...m.response,body:await GF(T)}},A,"responses")}catch(w){ae("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Responses \u6D41\u5F0F):"+w?.stack)}}).catch(S=>ae("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Responses):"+S)),new Response(C.stream,{status:_.status,statusText:_.statusText,headers:_.headers})}}function cZr(e){return async(t,r)=>{if(!YJ(t,r))return e(t,r);let n=JSON.parse(r.body),i=IA(r.headers),o=await V_e.transformRequestOut(n),s=JSON.stringify(o),a=SSe(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 ae("gemini request error:",C),C}if(!c.ok){let C=await c.text();return ae(`Gemini API error response: ${c.status} ${c.statusText}`,{url:a,status:c.status,errorResponse:C}),CSe("Gemini API error","Gemini",c.status,c.statusText,C)}let u=n.stream===!0,f=i["x-agent-id"],A={request:{url:a,method:r.method,headers:IA(r.headers),body:n},response:{status:c.status,statusText:c.statusText,headers:IA(c.headers)},openai:{request:{body:o},response:{}}},m=XB(c.body),g=new Response(m.stream,{status:c.status,statusText:c.statusText,headers:ZU(c.headers)}),E=await V_e.transformResponseIn(g),_=XB(E.body);return Promise.all([m.done,_.done]).then(async([C,S])=>{try{let T=u?Rnt(C):JSON.parse(C),w=u?await GF(S):JSON.parse(S);JU({...A,openai:{...A.openai,response:{body:T}},response:{...A.response,body:w}},f)}catch(T){ae("\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF(Gemini):"+T?.stack)}}).catch(C=>ae("\u65E5\u5FD7\u805A\u5408\u9519\u8BEF(Gemini):"+C)),new Response(_.stream,{status:E.status,statusText:E.statusText,headers:E.headers})}}function uZr(e){return async(t,r)=>{if(!YJ(t,r))return e(t,r);let n=r.body;if(r.body)try{let f=JSON.parse(r.body);n=JSON.stringify(f)}catch{}let i=IA(r.headers);["1","true"].includes(String(process.env.HAWA_CODE_X_API_KEY_DISABLED??"").toLowerCase())&&(delete i["x-api-key"],delete i["X-API-Key"]),["1","true"].includes(String(process.env.HAWA_CODE_AUTH_DISABLED??"").toLowerCase())&&(delete i.authorization,delete i.Authorization),delete i["content-length"];let a=await e(t,{method:r.method,headers:i,body:n,signal:r.signal});if(!a.ok){let f=await a.text();ae(`API error response: ${a.status} ${a.statusText}`,{url:typeof t=="string"?t:t instanceof KT?t.toString():t.url,status:a.status,errorResponse:f});let A;try{let m=JSON.parse(f);A={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&&(A.error.details=m.error.details)}catch{A={type:"error",error:{type:"api_error",message:`API error: ${a.statusText}`,code:`API_${a.status}_ERROR`}}}return new Response(JSON.stringify(A),{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 KT?t.toString():t.url,method:r.method,headers:IA(r.headers),body:JSON.parse(n)},response:{status:a.status,statusText:a.statusText,headers:IA(a.headers)}};return(async()=>{if(c){let m=await a.text();u.response.body=await GF(m)}else u.response.body=await a.json();let A=IA(r.headers)["x-agent-id"];O$(A,u),k$(A,{request:u.request.body.messages,response:u.response.body.content})})().catch(f=>ae(`\u65E5\u5FD7\u89E3\u6790\u9519\u8BEF:
753
- Stack trace: `+f.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var zJ=null,bSe=!1;function dZr(){zJ=null,bSe=!1}ur.on("proxy:changed",dZr);function fZr(){if(bSe)return zJ;if(bSe=!0,Et().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(zJ=new rpt.ProxyAgent({uri:e}),zt(`[proxy] using proxy: ${e}`)),zJ}function pZr(){let e=fZr();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function jJ(e){let t=e||process.env.API_TYPE,r=pZr();switch(t){case"openai":return aZr(r);case"openai-responses":return lZr(r);case"gemini":return cZr(r);default:return uZr(r)}}Xg();var hZr=Z(me(),1);function npt(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=mZr(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function mZr(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||AZr(t)?0:gZr(t)?2:1}function AZr(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function gZr(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 q0(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 TC(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}He();ls();var oc={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function VJ(e,t){oc.totalCost+=e,oc.totalAPIDuration+=t}function WJ(e,t){oc.inputTokens+=e,oc.outputTokens+=t,ur.emit("token:change",{inputTokens:oc.inputTokens,outputTokens:oc.outputTokens})}function KJ(e,t){oc.cacheCreationTokens+=e,oc.cacheReadTokens+=t}function ISe(){return{inputTokens:oc.inputTokens,outputTokens:oc.outputTokens,cacheCreationTokens:oc.cacheCreationTokens,cacheReadTokens:oc.cacheReadTokens}}function ipt(){return oc.totalCost}function opt(){return Date.now()-oc.startTime}function spt(){return oc.totalAPIDuration}function apt(e){oc.currentContextTokens=e}function lpt(){return oc.currentContextTokens}He();Fe();Fe();var TSe="2.0.2";globalThis.MACRO={VERSION:TSe,PACKAGE_URL:`@dahawa/${Ki}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var JJ=process.env.HAWA_CODE_USER_AGENT||`${Ki}/${TSe} (${process.env.USER_TYPE})`;import{randomUUID as V_}from"crypto";ls();He();er();Ir();He();Fe();import{existsSync as Y0,readdirSync as Ftn,statSync as Utn}from"fs";import{join as wC,relative as Htn}from"path";import{homedir as OAt}from"os";import{platform as qtn}from"process";import{readFile as DC}from"fs/promises";Ir();G0();hr();import{join as CZr,sep as SZr}from"path";function tm(){if(!em())return!1;try{let e=Et();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function kf(){return(CZr(ke(),".hcode","team-memory")+SZr).normalize("NFC")}function xSe(e){let t=e.normalize("NFC"),r=kf();return t.startsWith(r)}var kAt=Z(a5(),1);Qi();var DAt=Z(a5(),1);Ir();Fe();He();hu();import{readFile as xAt}from"fs/promises";import{existsSync as $Se,readdirSync as Mtn,statSync as Qtn}from"fs";import{join as zSe,relative as RAt}from"path";import{homedir as Ltn}from"os";function wAt(e){try{let t=(0,DAt.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 Ce(t),{paths:[],content:e.trim()}}}function Ptn(e,t){return t.length===0?!0:t.some(r=>{try{return tc(e,r,{matchBase:!0,dot:!0})}catch(n){return Ce(n),!1}})}function YSe(e){let t=[];try{if(!$Se(e))return t;let r=Mtn(e);for(let n of r){let i=zSe(e,n),o=Qtn(i);o.isDirectory()?t.push(...YSe(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){Ce(r)}return t}async function NAt(){let e=[];try{let t=zSe(Ltn(),Xr,"rules");if($Se(t)){let r=YSe(t);for(let n of r)try{let i=await xAt(n,"utf-8"),{paths:o,content:s}=wAt(i);o.length>0&&e.push({filePath:n,content:s,paths:o,isProjectRule:!1})}catch(i){Ce(i)}}}catch(t){Ce(t)}try{let t=zSe(ke(),Xr,"rules");if($Se(t)){let r=YSe(t);for(let n of r)try{let i=await xAt(n,"utf-8"),{paths:o,content:s}=wAt(i);o.length>0&&e.push({filePath:RAt(ke(),n),content:s,paths:o,isProjectRule:!0})}catch(i){Ce(i)}}}catch(t){Ce(t)}return e}function BAt(e,t){e=Rj(e);let r=Rj(ke()),n=e.startsWith(r)?RAt(r,e):e;return t.filter(i=>Ptn(n,i.paths))}var Gtn=`# hawaCodeMd
753
+ Stack trace: `+f.stack)),new Response(l.body,{status:a.status,statusText:a.statusText,headers:a.headers})}}var zJ=null,bSe=!1;function dZr(){zJ=null,bSe=!1}ur.on("proxy:changed",dZr);function fZr(){if(bSe)return zJ;if(bSe=!0,Et().proxy!==!0)return null;let e=process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.https_proxy||process.env.http_proxy;return e&&(zJ=new rpt.ProxyAgent({uri:e}),zt(`[proxy] using proxy: ${e}`)),zJ}function pZr(){let e=fZr();return e?((t,r={})=>global.fetch(t,{...r,dispatcher:e})):global.fetch}function jJ(e){let t=e||process.env.API_TYPE,r=pZr();switch(t){case"openai":return aZr(r);case"openai-responses":return lZr(r);case"gemini":return cZr(r);default:return uZr(r)}}Xg();var hZr=Z(me(),1);function npt(e,t){let r=[],n=Math.max(1,Math.floor(t)),i="",o=0;for(let s of e){let a=mZr(s);i&&o+a>n?(r.push(i),i=s,o=a):(i+=s,o+=a)}return i&&r.push(i),r}function mZr(e){if(e===" ")return 4;let t=e.codePointAt(0);return t===void 0||t===0||t<32||t>=127&&t<160||AZr(t)?0:gZr(t)?2:1}function AZr(e){return e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071}function gZr(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 q0(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 TC(e){return new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e).toLowerCase()}He();ls();var oc={totalCost:0,totalAPIDuration:0,startTime:Date.now(),inputTokens:0,outputTokens:0,cacheCreationTokens:0,cacheReadTokens:0,currentContextTokens:0};function VJ(e,t){oc.totalCost+=e,oc.totalAPIDuration+=t}function WJ(e,t){oc.inputTokens+=e,oc.outputTokens+=t,ur.emit("token:change",{inputTokens:oc.inputTokens,outputTokens:oc.outputTokens})}function KJ(e,t){oc.cacheCreationTokens+=e,oc.cacheReadTokens+=t}function ISe(){return{inputTokens:oc.inputTokens,outputTokens:oc.outputTokens,cacheCreationTokens:oc.cacheCreationTokens,cacheReadTokens:oc.cacheReadTokens}}function ipt(){return oc.totalCost}function opt(){return Date.now()-oc.startTime}function spt(){return oc.totalAPIDuration}function apt(e){oc.currentContextTokens=e}function lpt(){return oc.currentContextTokens}He();Fe();Fe();var TSe="2.0.3";globalThis.MACRO={VERSION:TSe,PACKAGE_URL:`@dahawa/${Ki}`,README_URL:"https://github.com/italking/hawa-code",ISSUES_EXPLAINER:"report the issue at https://github.com/italking/hawa-code/issues"};var JJ=process.env.HAWA_CODE_USER_AGENT||`${Ki}/${TSe} (${process.env.USER_TYPE})`;import{randomUUID as V_}from"crypto";ls();He();er();Ir();He();Fe();import{existsSync as Y0,readdirSync as Ftn,statSync as Utn}from"fs";import{join as wC,relative as Htn}from"path";import{homedir as OAt}from"os";import{platform as qtn}from"process";import{readFile as DC}from"fs/promises";Ir();G0();hr();import{join as CZr,sep as SZr}from"path";function tm(){if(!em())return!1;try{let e=Et();if(e.autoMemory?.teamMemoryEnabled!==void 0)return e.autoMemory.teamMemoryEnabled}catch{}return!1}function kf(){return(CZr(ke(),".hcode","team-memory")+SZr).normalize("NFC")}function xSe(e){let t=e.normalize("NFC"),r=kf();return t.startsWith(r)}var kAt=Z(a5(),1);Qi();var DAt=Z(a5(),1);Ir();Fe();He();hu();import{readFile as xAt}from"fs/promises";import{existsSync as $Se,readdirSync as Mtn,statSync as Qtn}from"fs";import{join as zSe,relative as RAt}from"path";import{homedir as Ltn}from"os";function wAt(e){try{let t=(0,DAt.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 Ce(t),{paths:[],content:e.trim()}}}function Ptn(e,t){return t.length===0?!0:t.some(r=>{try{return tc(e,r,{matchBase:!0,dot:!0})}catch(n){return Ce(n),!1}})}function YSe(e){let t=[];try{if(!$Se(e))return t;let r=Mtn(e);for(let n of r){let i=zSe(e,n),o=Qtn(i);o.isDirectory()?t.push(...YSe(i)):o.isFile()&&n.endsWith(".md")&&t.push(i)}}catch(r){Ce(r)}return t}async function NAt(){let e=[];try{let t=zSe(Ltn(),Xr,"rules");if($Se(t)){let r=YSe(t);for(let n of r)try{let i=await xAt(n,"utf-8"),{paths:o,content:s}=wAt(i);o.length>0&&e.push({filePath:n,content:s,paths:o,isProjectRule:!1})}catch(i){Ce(i)}}}catch(t){Ce(t)}try{let t=zSe(ke(),Xr,"rules");if($Se(t)){let r=YSe(t);for(let n of r)try{let i=await xAt(n,"utf-8"),{paths:o,content:s}=wAt(i);o.length>0&&e.push({filePath:RAt(ke(),n),content:s,paths:o,isProjectRule:!0})}catch(i){Ce(i)}}}catch(t){Ce(t)}return e}function BAt(e,t){e=Rj(e);let r=Rj(ke()),n=e.startsWith(r)?RAt(r,e):e;return t.filter(i=>Ptn(n,i.paths))}var Gtn=`# hawaCodeMd
754
754
  Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.`;function $tn(e="default"){let r=Ye.getSessionContext(e).getData("matchedPathRules");return!r||r.length===0?"":r.map(i=>{let o=i.isProjectRule?"project instructions, checked into the codebase":"user's private global instructions for all projects";return`Contents of ${i.filePath} (${o}):
755
755
 
756
756
  ${i.content}`}).join(`
@@ -1121,7 +1121,7 @@ You are powered by the model ${e}.`}async function Tv(){return l5()?`gitStatus:
1121
1121
  <context name="${c}">${u}</context>`;let s=i.map(c=>{let u=c.prompt({},t),f=JSON.stringify("inputJSONSchema"in c&&c.inputJSONSchema?c.inputJSONSchema:jS(c.inputSchema));return{name:c.name,description:`${u}
1122
1122
 
1123
1123
  Schema:
1124
- ${f}`}}),{messages:a}=t,l=Fon(o);return Uon(o,l,s,a)}},a0t=Hon;vA();var Du=Z(me(),1),B2=Z(me(),1);He();He();import{existsSync as qon,readdirSync as Gon,statSync as $on}from"fs";import{join as zon}from"path";function Yon(){let e=Ji.plan();if(!qon(e))return[];try{return Gon(e).filter(r=>r.endsWith(".md")).map(r=>{let n=zon(e,r),i=$on(n);return{name:r,path:n,modified:i.mtime}}).sort((r,n)=>n.modified.getTime()-r.modified.getTime())}catch{return[]}}var l0t=({onSelect:e})=>{let[t,r]=(0,B2.useState)([]),[n,i]=(0,B2.useState)(0),[o,s]=(0,B2.useState)(!1);(0,B2.useEffect)(()=>{let c=Yon();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}))];Nr((c,u)=>{if(u.upArrow)i(f=>f>0?f-1:a.length-1);else if(u.downArrow)i(f=>f<a.length-1?f+1:0);else if(u.return){let f=a[n];f&&e(f.value)}else u.escape&&e("__CANCELLED__")});let l=Me();return o?Du.createElement(N,{flexDirection:"column",marginY:1},Du.createElement(N,{marginBottom:1},Du.createElement(v,{bold:!0,color:l.claude},"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),Du.createElement(N,{marginBottom:1},Du.createElement(v,{bold:!0,color:l.claude}," Select a plan to continue, or create a new one")),a.map((c,u)=>{let f=u===n;return Du.createElement(N,{key:c.isNew?"new":c.value,flexDirection:"row",marginLeft:2},Du.createElement(v,{color:f?l.claude:l.text},f?"\u276F":" "),Du.createElement(v,{color:f?l.claude:l.text}," "),Du.createElement(v,{color:f?l.claude:l.text,bold:c.isNew},c.isNew?c.label:c.label.replace(".md","")),!c.isNew&&c.modified&&Du.createElement(v,{dimColor:!0}," ","(",Mme(c.modified),")"))}),Du.createElement(N,{marginTop:1,marginLeft:2},Du.createElement(v,{dimColor:!0},"\u2191/\u2193 to select \xB7 Enter to confirm \xB7 Esc to cancel"))):Du.createElement(N,{flexDirection:"column",marginY:1},Du.createElement(v,null,"Loading plan history..."))};var c0t=Z(me(),1),jon={type:"local-jsx",name:"plan",description:()=>"Enable plan mode",isEnabled:!0,isHidden:!1,disableCancel:!0,async call(e){return Ti.isPlanMode()?(e("Already in plan mode."),null):c0t.createElement(l0t,{onSelect:t=>{if(t==="__CANCELLED__"){e("Cancelled.");return}t&&t!=="__NEW_PLAN__"?Ti.setCurrentPlanFilePath(t):Ti.generatePlanFilePath(),Ti.setMode("plan",!0,!1),e("Enabled plan mode")}})},userFacingName(){return"plan"}},u0t=jon;vA();var Von={type:"local",name:"auto",description:()=>"Enable auto mode",isEnabled:!0,isHidden:!1,async call(){return Ti.isAutoMode()?"Already in auto mode.":(Ti.setMode("auto",!0),"Enabled auto mode")},userFacingName(){return"auto"}},d0t=Von;Ir();import{resolve as Won}from"path";var Kon={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=ke(),n=Won(r,t);ia(n);let i=ke();return i===r?`Already in ${i}.`:`Changed directory to ${i}/`},userFacingName(){return"cd"}},f0t=Kon;var Gyt=Z(me(),1);var Hn=Z(me(),1);var wsn=Z(me(),1);var L5=Z(me(),1),Tsn=Z(g0t(),1);var h0t={info:"blue",success:"green",error:"red",warning:"yellow"},usn={styles:{container:({variant:e})=>({flexGrow:1,borderStyle:"round",borderColor:h0t[e],gap:1,paddingX:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:h0t[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=Mr.info),e==="success"&&(t=Mr.tick),e==="error"&&(t=Mr.cross),e==="warning"&&(t=Mr.warning),{icon:t}}},E0t=usn;var dsn={styles:{container:({color:e})=>({backgroundColor:e}),label:()=>({color:"black"})}},_0t=dsn;var fsn={styles:{input:({isFocused:e})=>({dimColor:!e})}},y0t=fsn;var psn={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})}},b0t=psn;var msn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})}},C0t=msn;var Asn={styles:{container:()=>({flexGrow:1,minWidth:0}),completed:()=>({color:"magenta"}),remaining:()=>({dimColor:!0})},config:()=>({completedCharacter:Mr.square,remainingCharacter:Mr.squareLightShade})},S0t=Asn;var gsn={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})}},I0t=gsn;var hsn={styles:{container:()=>({gap:1}),frame:()=>({color:"blue"}),label:()=>({})}},T0t=hsn;var Esn={success:"green",error:"red",warning:"yellow",info:"blue"},_sn={success:Mr.tick,error:Mr.cross,warning:Mr.warning,info:Mr.info},ysn={styles:{container:()=>({gap:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:Esn[e]}),message:()=>({})},config:({variant:e})=>({icon:_sn[e]})},v0t=ysn;var bsn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})},config:()=>({marker:Mr.line})},x0t=bsn;var Csn={styles:{value:()=>({})}},w0t=Csn;var Ssn={styles:{value:()=>({})}},D0t=Ssn;var Isn={styles:{value:()=>({})}},R0t=Isn;var vsn={components:{Alert:E0t,Badge:_0t,ConfirmInput:y0t,MultiSelect:b0t,OrderedList:C0t,ProgressBar:S0t,Select:I0t,Spinner:T0t,StatusMessage:v0t,UnorderedList:x0t,TextInput:w0t,EmailInput:D0t,PasswordInput:R0t}},xsn=(0,L5.createContext)(vsn);var po=e=>(0,L5.useContext)(xsn).components[e];var Dsn=Z(me(),1);var X0=Z(me(),1);var k2=Z(me(),1);var N0t=Z(me(),1);var P5=Mr.line;var iX=(0,N0t.createContext)({marker:P5});function B0t({children:e}){let{marker:t}=(0,k2.useContext)(iX),{styles:r}=po("UnorderedList");return k2.default.createElement(N,{...r.listItem()},k2.default.createElement(v,{...r.marker()},t),k2.default.createElement(N,{...r.content()},e))}var O0t=Z(me(),1),fTe=(0,O0t.createContext)({depth:0});function Rsn({children:e}){let{depth:t}=(0,X0.useContext)(fTe),{styles:r,config:n}=po("UnorderedList"),i=(0,X0.useMemo)(()=>({depth:t+1}),[t]),o=(0,X0.useMemo)(()=>{let{marker:s}=n();return typeof s=="string"?{marker:s}:Array.isArray(s)?{marker:s[t]??s.at(-1)??P5}:{marker:P5}},[n,t]);return X0.default.createElement(fTe.Provider,{value:i},X0.default.createElement(iX.Provider,{value:o},X0.default.createElement(N,{...r.list()},e)))}Rsn.Item=B0t;var Bsn=Z(me(),1);var Nsn=Z(me(),1);var F5=Z(me(),1);var M2=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 k0t=Z(me(),1);var Q2=Z(me(),1);var U5=Z(me(),1);function M0t({isFocused:e,isSelected:t,children:r}){let{styles:n}=po("Select");return U5.default.createElement(N,{...n.option({isFocused:e})},e&&U5.default.createElement(v,{...n.focusIndicator()},Mr.pointer),U5.default.createElement(v,{...n.label({isFocused:e,isSelected:t})},r),t&&U5.default.createElement(v,{...n.selectedIndicator()},Mr.tick))}var am=Z(me(),1);import{isDeepStrictEqual as Osn}from"node:util";var ksn=(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}},Q0t=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=typeof e=="number"?Math.min(e,r.length):r.length,i=new M2(r);return{optionMap:i,visibleOptionCount:n,focusedValue:i.first?.value,visibleFromIndex:0,visibleToIndex:n,previousValue:t,value:t}},L0t=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n})=>{let[i,o]=(0,am.useReducer)(ksn,{visibleOptionCount:e,defaultValue:r,options:t},Q0t),[s,a]=(0,am.useState)(t);t!==s&&!Osn(t,s)&&(o({type:"reset",state:Q0t({visibleOptionCount:e,defaultValue:r,options:t})}),a(t));let l=(0,am.useCallback)(()=>{o({type:"focus-next-option"})},[]),c=(0,am.useCallback)(()=>{o({type:"focus-previous-option"})},[]),u=(0,am.useCallback)(()=>{o({type:"select-focused-option"})},[]),f=(0,am.useMemo)(()=>t.map((A,m)=>({...A,index:m})).slice(i.visibleFromIndex,i.visibleToIndex),[t,i.visibleFromIndex,i.visibleToIndex]);return(0,am.useEffect)(()=>{i.value&&i.previousValue!==i.value&&n?.(i.value)},[i.previousValue,i.value,t,n]),{focusedValue:i.focusedValue,visibleFromIndex:i.visibleFromIndex,visibleToIndex:i.visibleToIndex,value:i.value,visibleOptions:f,focusNextOption:l,focusPreviousOption:c,selectFocusedOption:u}};var P0t=({isDisabled:e=!1,state:t})=>{Nr((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};function L2({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:i,onChange:o}){let s=L0t({visibleOptionCount:t,options:n,defaultValue:i,onChange:o});P0t({isDisabled:e,state:s});let{styles:a}=po("Select");return Q2.default.createElement(N,{...a.container()},s.visibleOptions.map(l=>{let c=l.label;if(r&&l.label.includes(r)){let u=l.label.indexOf(r);c=Q2.default.createElement(Q2.default.Fragment,null,l.label.slice(0,u),Q2.default.createElement(v,{...a.highlightedText()},r),l.label.slice(u+r.length))}return Q2.default.createElement(M0t,{key:l.value,isFocused:!e&&s.focusedValue===l.value,isSelected:s.value===l.value},c)}))}var Msn=Z(me(),1);var F0t=Z(me(),1);var Lsn=Z(me(),1);var oX=Z(me(),1);var Qsn=Z(me(),1);var zxi=mr.inverse(" ");var RA=Z(me(),1);var P2=Z(me(),1);var U0t=Z(me(),1);var sX=(0,U0t.createContext)({marker:Mr.line});function aX({children:e}){let{marker:t}=(0,P2.useContext)(sX),{styles:r}=po("OrderedList");return P2.default.createElement(N,{...r.listItem()},P2.default.createElement(v,{...r.marker()},t),P2.default.createElement(N,{...r.content()},e))}var H0t=Z(me(),1),pTe=(0,H0t.createContext)({marker:""});function NA({children:e}){let{marker:t}=(0,RA.useContext)(pTe),{styles:r}=po("OrderedList"),n=0;for(let o of RA.default.Children.toArray(e))!(0,RA.isValidElement)(o)||o.type!==aX||n++;let i=String(n).length;return RA.default.createElement(N,{...r.list()},RA.default.Children.map(e,(o,s)=>{if(!(0,RA.isValidElement)(o)||o.type!==aX)return o;let a=`${String(s+1).padStart(i)}.`,l=`${t}${a}`;return RA.default.createElement(pTe.Provider,{value:{marker:l}},RA.default.createElement(sX.Provider,{value:{marker:l}},o))}))}NA.Item=aX;var Fsn=Z(me(),1);var mTe=Z(me(),1);var Psn=Z(me(),1);var ywi=mr.inverse(" ");var Usn=Z(me(),1);var Hsn=Z(me(),1);var Gsn=Z(me(),1);var lX=Z(me(),1);var qsn=Z(me(),1);var $wi=mr.inverse(" ");var qi=Z(me(),1);var ATe=Z(me(),1),gTe=Z(me(),1);u5();ls();Qi();hv();hr();var q0t=process.platform==="darwin"?["\xB7","\u2722","\u2733","\u2217","\u273B","\u273D"]:["\xB7","\u2722","*","\u2217","\u273B","\u273D"];function vv(){let e=[...q0t,...[...q0t].reverse()],{frame:t}=GD({interval:120});return ATe.createElement(N,{flexWrap:"nowrap",height:1,width:2},ATe.createElement(v,{color:Me().claude},e[t%e.length]))}var dX=Z(me(),1);var uX=null,e_=null,cX=new Set;function ETe(e){let{columns:t,rows:r}=e;if(t&&r)return{columns:t,rows:r};let n=wfe();return{columns:t||n.columns||80,rows:r||n.rows||24}}function hTe(){e_&&(uX=ETe(e_),cX.forEach(e=>e(uX)))}function $sn(e,t){return e_!==e&&(e_&&e_.off("resize",hTe),e_=e,uX=ETe(e),e.on("resize",hTe)),cX.add(t),()=>{cX.delete(t),cX.size===0&&e_&&(e_.off("resize",hTe),e_=null,uX=null)}}function _Te(){let{stdout:e}=qD(),[t,r]=(0,dX.useState)(()=>ETe(e));return(0,dX.useEffect)(()=>$sn(e,r),[e]),t}function F2(){return _Te()}Fe();import{homedir as W5}from"os";import{join as q2}from"path";import{existsSync as K5,mkdirSync as Nyt,appendFileSync as Ryt,readFileSync as Byt,constants as Hcn,writeFileSync as qcn,unlinkSync as Oyt,statSync as Gcn}from"fs";import{platform as kyt}from"process";He();import{accessSync as $cn}from"fs";He();var ORi=Z(UTe(),1);var Ucn="2.0.2",V5={VERSION:Ucn,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"};Fe();var wv=q2(XI,".update.lock"),zcn=300*1e3;function Myt(){try{if(K5(XI)||Nyt(XI,{recursive:!0}),K5(wv)){let e=Gcn(wv);if(Date.now()-e.mtimeMs<zcn)return!1;try{Oyt(wv)}catch(r){return Ce(`Failed to remove stale lock file: ${r}`),!1}}return qcn(wv,`${process.pid}`,"utf8"),!0}catch(e){return Ce(`Failed to acquire lock: ${e}`),!1}}function Qyt(){try{K5(wv)&&Byt(wv,"utf8")===`${process.pid}`&&Oyt(wv)}catch(e){Ce(`Failed to release lock: ${e}`)}}async function HTe(){try{let e=await oi("npm -g config get prefix");if(e.code!==0)return Ce("Failed to check npm permissions"),{hasPermissions:!1,npmPrefix:null};let t=e.stdout.trim(),r=!1;try{$cn(t,Hcn.W_OK),r=!0}catch{r=!1}return r?{hasPermissions:!0,npmPrefix:t}:(Ce("Insufficient permissions for global npm install."),{hasPermissions:!1,npmPrefix:t})}catch(e){return Ce(`Failed to verify npm global install permissions: ${e}`),{hasPermissions:!1,npmPrefix:null}}}async function Lyt(e){if(!Myt())throw ft("tengu_auto_updater_prefix_lock_contention",{pid:String(process.pid),currentVersion:V5.VERSION,prefix:e}),new Error("Another process is currently setting up npm prefix");try{K5(e)||Nyt(e,{recursive:!0});let t=await oi(`npm -g config set prefix ${e}`);if(t.code!==0)throw new Error(`Failed to set npm prefix: ${t.stderr}`);let r=`
1124
+ ${f}`}}),{messages:a}=t,l=Fon(o);return Uon(o,l,s,a)}},a0t=Hon;vA();var Du=Z(me(),1),B2=Z(me(),1);He();He();import{existsSync as qon,readdirSync as Gon,statSync as $on}from"fs";import{join as zon}from"path";function Yon(){let e=Ji.plan();if(!qon(e))return[];try{return Gon(e).filter(r=>r.endsWith(".md")).map(r=>{let n=zon(e,r),i=$on(n);return{name:r,path:n,modified:i.mtime}}).sort((r,n)=>n.modified.getTime()-r.modified.getTime())}catch{return[]}}var l0t=({onSelect:e})=>{let[t,r]=(0,B2.useState)([]),[n,i]=(0,B2.useState)(0),[o,s]=(0,B2.useState)(!1);(0,B2.useEffect)(()=>{let c=Yon();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}))];Nr((c,u)=>{if(u.upArrow)i(f=>f>0?f-1:a.length-1);else if(u.downArrow)i(f=>f<a.length-1?f+1:0);else if(u.return){let f=a[n];f&&e(f.value)}else u.escape&&e("__CANCELLED__")});let l=Me();return o?Du.createElement(N,{flexDirection:"column",marginY:1},Du.createElement(N,{marginBottom:1},Du.createElement(v,{bold:!0,color:l.claude},"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),Du.createElement(N,{marginBottom:1},Du.createElement(v,{bold:!0,color:l.claude}," Select a plan to continue, or create a new one")),a.map((c,u)=>{let f=u===n;return Du.createElement(N,{key:c.isNew?"new":c.value,flexDirection:"row",marginLeft:2},Du.createElement(v,{color:f?l.claude:l.text},f?"\u276F":" "),Du.createElement(v,{color:f?l.claude:l.text}," "),Du.createElement(v,{color:f?l.claude:l.text,bold:c.isNew},c.isNew?c.label:c.label.replace(".md","")),!c.isNew&&c.modified&&Du.createElement(v,{dimColor:!0}," ","(",Mme(c.modified),")"))}),Du.createElement(N,{marginTop:1,marginLeft:2},Du.createElement(v,{dimColor:!0},"\u2191/\u2193 to select \xB7 Enter to confirm \xB7 Esc to cancel"))):Du.createElement(N,{flexDirection:"column",marginY:1},Du.createElement(v,null,"Loading plan history..."))};var c0t=Z(me(),1),jon={type:"local-jsx",name:"plan",description:()=>"Enable plan mode",isEnabled:!0,isHidden:!1,disableCancel:!0,async call(e){return Ti.isPlanMode()?(e("Already in plan mode."),null):c0t.createElement(l0t,{onSelect:t=>{if(t==="__CANCELLED__"){e("Cancelled.");return}t&&t!=="__NEW_PLAN__"?Ti.setCurrentPlanFilePath(t):Ti.generatePlanFilePath(),Ti.setMode("plan",!0,!1),e("Enabled plan mode")}})},userFacingName(){return"plan"}},u0t=jon;vA();var Von={type:"local",name:"auto",description:()=>"Enable auto mode",isEnabled:!0,isHidden:!1,async call(){return Ti.isAutoMode()?"Already in auto mode.":(Ti.setMode("auto",!0),"Enabled auto mode")},userFacingName(){return"auto"}},d0t=Von;Ir();import{resolve as Won}from"path";var Kon={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=ke(),n=Won(r,t);ia(n);let i=ke();return i===r?`Already in ${i}.`:`Changed directory to ${i}/`},userFacingName(){return"cd"}},f0t=Kon;var Gyt=Z(me(),1);var Hn=Z(me(),1);var wsn=Z(me(),1);var L5=Z(me(),1),Tsn=Z(g0t(),1);var h0t={info:"blue",success:"green",error:"red",warning:"yellow"},usn={styles:{container:({variant:e})=>({flexGrow:1,borderStyle:"round",borderColor:h0t[e],gap:1,paddingX:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:h0t[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=Mr.info),e==="success"&&(t=Mr.tick),e==="error"&&(t=Mr.cross),e==="warning"&&(t=Mr.warning),{icon:t}}},E0t=usn;var dsn={styles:{container:({color:e})=>({backgroundColor:e}),label:()=>({color:"black"})}},_0t=dsn;var fsn={styles:{input:({isFocused:e})=>({dimColor:!e})}},y0t=fsn;var psn={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})}},b0t=psn;var msn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})}},C0t=msn;var Asn={styles:{container:()=>({flexGrow:1,minWidth:0}),completed:()=>({color:"magenta"}),remaining:()=>({dimColor:!0})},config:()=>({completedCharacter:Mr.square,remainingCharacter:Mr.squareLightShade})},S0t=Asn;var gsn={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})}},I0t=gsn;var hsn={styles:{container:()=>({gap:1}),frame:()=>({color:"blue"}),label:()=>({})}},T0t=hsn;var Esn={success:"green",error:"red",warning:"yellow",info:"blue"},_sn={success:Mr.tick,error:Mr.cross,warning:Mr.warning,info:Mr.info},ysn={styles:{container:()=>({gap:1}),iconContainer:()=>({flexShrink:0}),icon:({variant:e})=>({color:Esn[e]}),message:()=>({})},config:({variant:e})=>({icon:_sn[e]})},v0t=ysn;var bsn={styles:{list:()=>({flexDirection:"column"}),listItem:()=>({gap:1}),marker:()=>({dimColor:!0}),content:()=>({flexDirection:"column"})},config:()=>({marker:Mr.line})},x0t=bsn;var Csn={styles:{value:()=>({})}},w0t=Csn;var Ssn={styles:{value:()=>({})}},D0t=Ssn;var Isn={styles:{value:()=>({})}},R0t=Isn;var vsn={components:{Alert:E0t,Badge:_0t,ConfirmInput:y0t,MultiSelect:b0t,OrderedList:C0t,ProgressBar:S0t,Select:I0t,Spinner:T0t,StatusMessage:v0t,UnorderedList:x0t,TextInput:w0t,EmailInput:D0t,PasswordInput:R0t}},xsn=(0,L5.createContext)(vsn);var po=e=>(0,L5.useContext)(xsn).components[e];var Dsn=Z(me(),1);var X0=Z(me(),1);var k2=Z(me(),1);var N0t=Z(me(),1);var P5=Mr.line;var iX=(0,N0t.createContext)({marker:P5});function B0t({children:e}){let{marker:t}=(0,k2.useContext)(iX),{styles:r}=po("UnorderedList");return k2.default.createElement(N,{...r.listItem()},k2.default.createElement(v,{...r.marker()},t),k2.default.createElement(N,{...r.content()},e))}var O0t=Z(me(),1),fTe=(0,O0t.createContext)({depth:0});function Rsn({children:e}){let{depth:t}=(0,X0.useContext)(fTe),{styles:r,config:n}=po("UnorderedList"),i=(0,X0.useMemo)(()=>({depth:t+1}),[t]),o=(0,X0.useMemo)(()=>{let{marker:s}=n();return typeof s=="string"?{marker:s}:Array.isArray(s)?{marker:s[t]??s.at(-1)??P5}:{marker:P5}},[n,t]);return X0.default.createElement(fTe.Provider,{value:i},X0.default.createElement(iX.Provider,{value:o},X0.default.createElement(N,{...r.list()},e)))}Rsn.Item=B0t;var Bsn=Z(me(),1);var Nsn=Z(me(),1);var F5=Z(me(),1);var M2=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 k0t=Z(me(),1);var Q2=Z(me(),1);var U5=Z(me(),1);function M0t({isFocused:e,isSelected:t,children:r}){let{styles:n}=po("Select");return U5.default.createElement(N,{...n.option({isFocused:e})},e&&U5.default.createElement(v,{...n.focusIndicator()},Mr.pointer),U5.default.createElement(v,{...n.label({isFocused:e,isSelected:t})},r),t&&U5.default.createElement(v,{...n.selectedIndicator()},Mr.tick))}var am=Z(me(),1);import{isDeepStrictEqual as Osn}from"node:util";var ksn=(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}},Q0t=({visibleOptionCount:e,defaultValue:t,options:r})=>{let n=typeof e=="number"?Math.min(e,r.length):r.length,i=new M2(r);return{optionMap:i,visibleOptionCount:n,focusedValue:i.first?.value,visibleFromIndex:0,visibleToIndex:n,previousValue:t,value:t}},L0t=({visibleOptionCount:e=5,options:t,defaultValue:r,onChange:n})=>{let[i,o]=(0,am.useReducer)(ksn,{visibleOptionCount:e,defaultValue:r,options:t},Q0t),[s,a]=(0,am.useState)(t);t!==s&&!Osn(t,s)&&(o({type:"reset",state:Q0t({visibleOptionCount:e,defaultValue:r,options:t})}),a(t));let l=(0,am.useCallback)(()=>{o({type:"focus-next-option"})},[]),c=(0,am.useCallback)(()=>{o({type:"focus-previous-option"})},[]),u=(0,am.useCallback)(()=>{o({type:"select-focused-option"})},[]),f=(0,am.useMemo)(()=>t.map((A,m)=>({...A,index:m})).slice(i.visibleFromIndex,i.visibleToIndex),[t,i.visibleFromIndex,i.visibleToIndex]);return(0,am.useEffect)(()=>{i.value&&i.previousValue!==i.value&&n?.(i.value)},[i.previousValue,i.value,t,n]),{focusedValue:i.focusedValue,visibleFromIndex:i.visibleFromIndex,visibleToIndex:i.visibleToIndex,value:i.value,visibleOptions:f,focusNextOption:l,focusPreviousOption:c,selectFocusedOption:u}};var P0t=({isDisabled:e=!1,state:t})=>{Nr((r,n)=>{n.downArrow&&t.focusNextOption(),n.upArrow&&t.focusPreviousOption(),n.return&&t.selectFocusedOption()},{isActive:!e})};function L2({isDisabled:e=!1,visibleOptionCount:t=5,highlightText:r,options:n,defaultValue:i,onChange:o}){let s=L0t({visibleOptionCount:t,options:n,defaultValue:i,onChange:o});P0t({isDisabled:e,state:s});let{styles:a}=po("Select");return Q2.default.createElement(N,{...a.container()},s.visibleOptions.map(l=>{let c=l.label;if(r&&l.label.includes(r)){let u=l.label.indexOf(r);c=Q2.default.createElement(Q2.default.Fragment,null,l.label.slice(0,u),Q2.default.createElement(v,{...a.highlightedText()},r),l.label.slice(u+r.length))}return Q2.default.createElement(M0t,{key:l.value,isFocused:!e&&s.focusedValue===l.value,isSelected:s.value===l.value},c)}))}var Msn=Z(me(),1);var F0t=Z(me(),1);var Lsn=Z(me(),1);var oX=Z(me(),1);var Qsn=Z(me(),1);var zxi=mr.inverse(" ");var RA=Z(me(),1);var P2=Z(me(),1);var U0t=Z(me(),1);var sX=(0,U0t.createContext)({marker:Mr.line});function aX({children:e}){let{marker:t}=(0,P2.useContext)(sX),{styles:r}=po("OrderedList");return P2.default.createElement(N,{...r.listItem()},P2.default.createElement(v,{...r.marker()},t),P2.default.createElement(N,{...r.content()},e))}var H0t=Z(me(),1),pTe=(0,H0t.createContext)({marker:""});function NA({children:e}){let{marker:t}=(0,RA.useContext)(pTe),{styles:r}=po("OrderedList"),n=0;for(let o of RA.default.Children.toArray(e))!(0,RA.isValidElement)(o)||o.type!==aX||n++;let i=String(n).length;return RA.default.createElement(N,{...r.list()},RA.default.Children.map(e,(o,s)=>{if(!(0,RA.isValidElement)(o)||o.type!==aX)return o;let a=`${String(s+1).padStart(i)}.`,l=`${t}${a}`;return RA.default.createElement(pTe.Provider,{value:{marker:l}},RA.default.createElement(sX.Provider,{value:{marker:l}},o))}))}NA.Item=aX;var Fsn=Z(me(),1);var mTe=Z(me(),1);var Psn=Z(me(),1);var ywi=mr.inverse(" ");var Usn=Z(me(),1);var Hsn=Z(me(),1);var Gsn=Z(me(),1);var lX=Z(me(),1);var qsn=Z(me(),1);var $wi=mr.inverse(" ");var qi=Z(me(),1);var ATe=Z(me(),1),gTe=Z(me(),1);u5();ls();Qi();hv();hr();var q0t=process.platform==="darwin"?["\xB7","\u2722","\u2733","\u2217","\u273B","\u273D"]:["\xB7","\u2722","*","\u2217","\u273B","\u273D"];function vv(){let e=[...q0t,...[...q0t].reverse()],{frame:t}=GD({interval:120});return ATe.createElement(N,{flexWrap:"nowrap",height:1,width:2},ATe.createElement(v,{color:Me().claude},e[t%e.length]))}var dX=Z(me(),1);var uX=null,e_=null,cX=new Set;function ETe(e){let{columns:t,rows:r}=e;if(t&&r)return{columns:t,rows:r};let n=wfe();return{columns:t||n.columns||80,rows:r||n.rows||24}}function hTe(){e_&&(uX=ETe(e_),cX.forEach(e=>e(uX)))}function $sn(e,t){return e_!==e&&(e_&&e_.off("resize",hTe),e_=e,uX=ETe(e),e.on("resize",hTe)),cX.add(t),()=>{cX.delete(t),cX.size===0&&e_&&(e_.off("resize",hTe),e_=null,uX=null)}}function _Te(){let{stdout:e}=qD(),[t,r]=(0,dX.useState)(()=>ETe(e));return(0,dX.useEffect)(()=>$sn(e,r),[e]),t}function F2(){return _Te()}Fe();import{homedir as W5}from"os";import{join as q2}from"path";import{existsSync as K5,mkdirSync as Nyt,appendFileSync as Ryt,readFileSync as Byt,constants as Hcn,writeFileSync as qcn,unlinkSync as Oyt,statSync as Gcn}from"fs";import{platform as kyt}from"process";He();import{accessSync as $cn}from"fs";He();var ORi=Z(UTe(),1);var Ucn="2.0.3",V5={VERSION:Ucn,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"};Fe();var wv=q2(XI,".update.lock"),zcn=300*1e3;function Myt(){try{if(K5(XI)||Nyt(XI,{recursive:!0}),K5(wv)){let e=Gcn(wv);if(Date.now()-e.mtimeMs<zcn)return!1;try{Oyt(wv)}catch(r){return Ce(`Failed to remove stale lock file: ${r}`),!1}}return qcn(wv,`${process.pid}`,"utf8"),!0}catch(e){return Ce(`Failed to acquire lock: ${e}`),!1}}function Qyt(){try{K5(wv)&&Byt(wv,"utf8")===`${process.pid}`&&Oyt(wv)}catch(e){Ce(`Failed to release lock: ${e}`)}}async function HTe(){try{let e=await oi("npm -g config get prefix");if(e.code!==0)return Ce("Failed to check npm permissions"),{hasPermissions:!1,npmPrefix:null};let t=e.stdout.trim(),r=!1;try{$cn(t,Hcn.W_OK),r=!0}catch{r=!1}return r?{hasPermissions:!0,npmPrefix:t}:(Ce("Insufficient permissions for global npm install."),{hasPermissions:!1,npmPrefix:t})}catch(e){return Ce(`Failed to verify npm global install permissions: ${e}`),{hasPermissions:!1,npmPrefix:null}}}async function Lyt(e){if(!Myt())throw ft("tengu_auto_updater_prefix_lock_contention",{pid:String(process.pid),currentVersion:V5.VERSION,prefix:e}),new Error("Another process is currently setting up npm prefix");try{K5(e)||Nyt(e,{recursive:!0});let t=await oi(`npm -g config set prefix ${e}`);if(t.code!==0)throw new Error(`Failed to set npm prefix: ${t.stderr}`);let r=`
1125
1125
  # npm global path
1126
1126
  export PATH="${e}/bin:$PATH"
1127
1127
  `;if(kyt==="win32"){let n=await oi(`setx PATH "${process.env.PATH};${e}"`);if(n.code!==0)throw new Error(`Failed to update PATH on Windows: ${n.stderr}`)}else{let n=[q2(W5(),".bashrc"),q2(W5(),".bash_profile"),q2(W5(),".zshrc"),q2(W5(),".config","fish","config.fish")];for(let i of n)if(K5(i))try{if(!Byt(i,"utf8").includes(e)){if(i.includes("fish")){let s=`