@hasna/hooks 0.12.18 → 0.12.19

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.
@@ -1,34 +1,37 @@
1
- var{defineProperty:G0,getOwnPropertyNames:_3,getOwnPropertyDescriptor:D3}=Object,I3=Object.prototype.hasOwnProperty;function T3(Z){return this[Z]}var q3=(Z)=>{var z=(X2??=new WeakMap).get(Z),$;if(z)return z;if(z=G0({},"__esModule",{value:!0}),Z&&typeof Z==="object"||typeof Z==="function"){for(var J of _3(Z))if(!I3.call(z,J))G0(z,J,{get:T3.bind(Z,J),enumerable:!($=D3(Z,J))||$.enumerable})}return X2.set(Z,z),z},X2;var C3=(Z)=>Z;function P3(Z,z){this[Z]=C3.bind(null,z)}var O3=(Z,z)=>{for(var $ in z)G0(Z,$,{get:z[$],enumerable:!0,configurable:!0,set:P3.bind(z,$)})};var v6={};O3(v6,{version:()=>A6,evaluate:()=>R6,abi:()=>y6});module.exports=q3(v6);var K0=require("node:os"),Z2=require("node:path");var x=require("node:path");var v=require("node:path"),P=require("node:fs"),K2=require("node:child_process"),H2={missing:"No verified @hasna/trash guard was found on PATH.",unsafe_executable:"The Trash candidate is not an owned executable file or is writable by group or others.",unsafe_manifest:"The Trash package manifest is not a safe owned regular file.",unsafe_directory:"A Trash PATH or package directory is not owned safely or is writable by group or others.",unsafe_interpreter:"The Trash interpreter is missing, unsupported, or not a safe owned executable on its actual PATH.",unrecognized_package:"The candidate is not the registered @hasna/trash executable.",identity_failed:"The installed Trash identity probe failed or exceeded its deadline.",unsupported_protocol:"The installed Trash version does not expose the required guard protocol."};function OZ(Z){return Z===0||Z===process.getuid?.()}function pZ(Z,z=!1){let $=Z;for(let J=0;J<32;J++){if(!v.isAbsolute($)||$.length>4096||!LZ("/"))return!1;let Y=$.split("/"),Q=Y.pop();if(!Q||Q==="."||Q==="..")return!1;let X="/";for(let B of Y){if(!B||B===".")continue;if(B===".."){X=v.dirname(X);continue}let M=v.join(X,B),V=P.lstatSync(M);if(z&&M==="/bin"&&V.isSymbolicLink()&&V.uid===0){let G=P.realpathSync(M);if(!LZ(G))return!1;X=G;continue}if(!V.isDirectory()||!OZ(V.uid)||V.mode&18)return!1;X=M}let H=v.join(X,Q),K=P.lstatSync(H);if(!OZ(K.uid))return!1;if(K.isSymbolicLink()){let B=P.readlinkSync(H);$=v.isAbsolute(B)?B:X+"/"+B;continue}return K.isFile()&&Boolean(K.mode&73)&&!(K.mode&18)}return!1}function L3(Z){if(!v.isAbsolute(Z)||v.resolve(Z)!==(Z.replace(/\/+$/,"")||"/"))return!1;for(let z=v.resolve(Z);;z=v.dirname(z)){try{return P.lstatSync(z),LZ(z)}catch($){if($.code!=="ENOENT")return!1}if(v.dirname(z)===z)return!1}}function y3(Z,z){let $=P.openSync(Z,P.constants.O_RDONLY|P.constants.O_NONBLOCK|P.constants.O_NOFOLLOW),J;try{if(!P.fstatSync($).isFile())return!1;let Q=Buffer.alloc(256),X=P.readSync($,Q,0,Q.length,0);J=Q.subarray(0,X).toString("utf8").split(`
2
- `)[0]}finally{P.closeSync($)}let Y=/^#!(\/[A-Za-z0-9_./-]+)$/.exec(J);if(Y&&Y[1]!=="/usr/bin/env")return pZ(Y[1],!0);if(J!=="#!/usr/bin/env bun"||!pZ("/usr/bin/env",!0))return!1;for(let Q of z.split(":").slice(0,64)){if(!L3(Q))return!1;let X=v.resolve(Q,"bun");try{if(!P.statSync(X).isFile())continue;P.accessSync(X,P.constants.X_OK)}catch{continue}return pZ(X,!0)}return!1}function LZ(Z){let z=Z;for(;;){let $=P.lstatSync(z);if(!$.isDirectory()||!OZ($.uid)||($.mode&18)!==0)return!1;let J=v.dirname(z);if(J===z)return!0;z=J}}function yZ(Z=process.env){let z=Z.PATH??"",$=Date.now()+2000,J="missing",Y=(Q)=>{if(J==="missing"||J==="unrecognized_package"||Q.startsWith("unsafe_"))J=Q};for(let Q of z.split(":").slice(0,64)){if(!v.isAbsolute(Q)||Date.now()>=$)continue;let X=v.resolve(Q,"trash");try{let H=P.statSync(X);if(!H.isFile()||!OZ(H.uid)||(H.mode&73)===0||(H.mode&18)!==0){Y("unsafe_executable");continue}let K=P.realpathSync(X);if(!LZ(v.resolve(Q))||!LZ(v.dirname(K))){Y("unsafe_directory");continue}if(!pZ(X)){Y("unsafe_directory");continue}let B=v.resolve(v.dirname(K),"../.."),M=v.join(B,"package.json"),V=P.statSync(M);if(!V.isFile()||!OZ(V.uid)||V.size>16384||(V.mode&18)!==0||P.lstatSync(M).isSymbolicLink()){Y("unsafe_manifest");continue}let G=JSON.parse(P.readFileSync(M,"utf8"));if(G.name!=="@hasna/trash"||typeof G.version!=="string"||typeof G.bin?.trash!=="string"||P.realpathSync(v.resolve(B,G.bin.trash))!==K){Y("unrecognized_package");continue}try{if(!y3(K,z)){Y("unsafe_interpreter");continue}}catch{Y("unsafe_interpreter");continue}let U=$-Date.now();if(U<=0){Y("identity_failed");break}let W=K2.spawnSync(X,["--identity"],{encoding:"utf8",timeout:U,maxBuffer:2048,env:{PATH:z},stdio:["ignore","pipe","pipe"]});if(W.error||W.status!==0||Date.now()>=$){Y("identity_failed");continue}let N=JSON.parse(W.stdout);if(N.name==="@hasna/trash"&&N.version===G.version&&N.guardProtocol==="hasna.trash.guard.v1")return{ok:!0,path:X,version:G.version};Y("unsupported_protocol")}catch{}}return{ok:!1,code:J}}function cZ(Z=process.env){let z=yZ(Z);return z.ok?z.path:null}function UZ(Z){let z=Z.tool_input?.command;return typeof z==="string"?z:""}var B2=["/","/bin","/boot","/dev","/etc","/home","/lib","/lib32","/lib64","/libx32","/opt","/proc","/root","/run","/sbin","/srv","/sys","/usr","/var","/Applications","/Library","/System","/Users","/Volumes","/private"];var RZ=/^[A-Za-z_][A-Za-z0-9_]*\+?=/,a=(Z)=>Z.split("/").pop()??"";function iZ(Z){let z=Z.startsWith("~")?Z.slice(1).split("/",1)[0]:"";if(z&&!/['"\\]/.test(z))return!0;let $=null,J=0;for(let Y=0;Y<Z.length;Y++){let Q=Z[Y];if($==="'"){if(Q==="'")$=null;continue}if(Q==="\\"){Y++;continue}if($==='"'){if(Q==='"')$=null;continue}if(Q==="'"||Q==='"')$=Q;else if(Q==="$"&&Z[Y+1]==="{")J++,Y++;else if(Q==="}"&&J>0)J--;else if(Q==="{"||Q==="}")return!0}return!1}var U0=64;function M2(Z,z){let $=0;for(let J=z;J<Z.length;J++)if(Z[J]==="\\")J++;else if(Z[J]==="{")$++;else if(Z[J]==="}"&&--$===0)return J;return Z.length-1}function A3(Z){let z=Z.match(/^([-+]?\d+)\.\.([-+]?\d+)(?:\.\.([-+]?\d+))?$/),$=z?null:Z.match(/^([A-Za-z])\.\.([A-Za-z])(?:\.\.([-+]?\d+))?$/),J=z??$;if(!J)return null;let Y=z?Number(J[1]):J[1].charCodeAt(0),Q=z?Number(J[2]):J[2].charCodeAt(0),X=Math.abs(Number(J[3]??1))||1;if(!Number.isSafeInteger(Y)||!Number.isSafeInteger(Q)||!Number.isSafeInteger(X))return"overflow";if(Math.floor(Math.abs(Q-Y)/X)+1>U0)return"overflow";let H=z&&(/^[-+]?0\d/.test(J[1])||/^[-+]?0\d/.test(J[2]))?Math.max(J[1].length,J[2].length):0,K=[];for(let B=Y;Y<=Q?B<=Q:B>=Q;B+=Y<=Q?X:-X)if(!z)K.push(String.fromCharCode(B));else K.push(B<0?`-${String(-B).padStart(H-1,"0")}`:String(B).padStart(H,"0"));return K}function R3(Z){let z=null,$=0;for(let J=0;J<Z.length;J++){let Y=Z[J];if(z==="'"){if(Y==="'")z=null;continue}if(Y==="\\"){J++;continue}if(z==='"'){if(Y==='"')z=null;continue}if(Y==="'"||Y==='"')z=Y;else if(Y==="$"&&Z[J+1]==="{")J=M2(Z,J+1);else if(Y==="{"){if(++$>U0)return"overflow";let Q=null,X=0,H=!0,K=[];for(let B=J;B<Z.length;B++){let M=Z[B];if(Q==="'"){if(M==="'")Q=null;continue}if(M==="\\"){H=!1,B++;continue}if(Q==='"'){if(M==='"')Q=null;continue}if(M==="'"||M==='"')Q=M,H=!1;else if(M==="$"&&Z[B+1]==="{")B=M2(Z,B+1),H=!1;else if(M==="{")X++;else if(M===","&&X===1)K.push(B);else if(M==="}"&&--X===0){if(K.length>0){let G=[J,...K,B];return{open:J,close:B,parts:G.slice(0,-1).map((U,W)=>Z.slice(U+1,G[W+1]))}}let V=H?A3(Z.slice(J+1,B)):null;if(V==="overflow")return V;if(V)return{open:J,close:B,parts:V};break}}}}return null}function QZ(Z){if(Z.length>4096&&Z.includes("{"))return null;let z=R3(Z);if(z===null)return[Z];if(z==="overflow")return null;let $=[];for(let J of z.parts){let Y=QZ(Z.slice(0,z.open)+J+Z.slice(z.close+1));if(Y===null||$.push(...Y)>U0)return null}return $}var j={arg:"none"},D={arg:"value"},AZ={arg:"optional"},t={arg:"none",effect:"lookup"},C={arg:"none",effect:"refuse"},ZZ={help:C,version:C},v3=/^(?:\d+(?:\.\d*)?|\.\d+)[smhd]?$/,j0={timeout:{short:{k:D,s:D,v:j},long:{"kill-after":D,signal:D,verbose:j,foreground:j,"preserve-status":j,...ZZ},positionals:[v3]},env:{short:{i:j,"0":j,v:j,u:D,a:D,C,S:C},long:{"ignore-environment":j,null:j,debug:j,unset:D,argv0:D,chdir:C,"split-string":C,"block-signal":AZ,"default-signal":AZ,"ignore-signal":AZ,"list-signal-handling":C,...ZZ},env:!0},nice:{short:{n:D},long:{adjustment:D,...ZZ},numericOption:!0},nohup:{short:{},long:{...ZZ}},command:{short:{p:j,v:t,V:t},long:{}},exec:{short:{c:j,l:j,a:D},long:{}},builtin:{short:{},long:{}},stdbuf:{short:{i:D,o:D,e:D},long:{input:D,output:D,error:D,...ZZ}},time:{short:{p:j,a:j,q:j,v:j,f:D,o:C,V:C},long:{portability:j,append:j,quiet:j,verbose:j,format:D,output:C,...ZZ}},ionice:{short:{c:D,n:D,t:j,p:C,P:C,u:C,h:C,V:C},long:{class:D,classdata:D,ignore:j,pid:C,pgid:C,uid:C,...ZZ}},setsid:{short:{c:j,f:j,w:j,h:C,V:C},long:{ctty:j,fork:j,wait:j,...ZZ}}},b3=new Set(["!","{","}","then","do","else","elif","if","while","until","for","case","esac","fi","done","select","function"]);function E3(Z,z,$){let J=!1,Y=(Q)=>{if(!Q||Q.effect==="refuse")return!1;if(Q.effect==="lookup")J=!0;return!0};while($<z.length){let Q=z[$];if(Q.opaque)return null;let X=Q.text;if(X==="--"){$++;break}if(X==="-"&&Z.env){$++;continue}if(!X.startsWith("-")||X==="-")break;if(Z.numericOption&&/^-[-+]?\d+$/.test(X)){$++;continue}if(X.startsWith("--")){let H=X.indexOf("="),K=H<0?X.slice(2):X.slice(2,H),B=Object.keys(Z.long),M=B.includes(K)?[K]:B.filter((G)=>K&&G.startsWith(K));if(M.length!==1)return null;let V=Z.long[M[0]];if(!Y(V))return null;if(V.arg==="none"&&H>=0)return null;if(V.arg==="value"&&H<0){let G=z[++$];if(!G||G.opaque)return null}$++;continue}for(let H=1;H<X.length;H++){let K=Z.short[X[H]];if(!Y(K))return null;if(K.arg==="value"){if(H===X.length-1){let B=z[++$];if(!B||B.opaque)return null}break}}$++}if(J)return-1;for(let Q of Z.positionals??[]){let X=z[$];if(!X||X.opaque||!Q.test(X.text))return null;$++}if(Z.env||Z.assignments){for(;$<z.length&&RZ.test(z[$].text);$++)if(z[$].opaque)return null}return $}function XZ(Z,z=j0){let $=0;while($<Z.length&&(RZ.test(Z[$].text)||b3.has(Z[$].text)))$++;for(let J=0;J<16;J++){if($>=Z.length)return{index:-1};if(Z[$].opaque)return J===0?{index:$}:null;let Y=Object.hasOwn(z,a(Z[$].text))?z[a(Z[$].text)]:void 0;if(!Y)return{index:$};let Q=E3(Y,Z,$+1);if(Q===null)return null;if(Q<0)return{index:-1};$=Q}return null}function S3(Z){return/(^|[^A-Za-z0-9_.-])(rm|rmdir|unlink|shred|trash)(?![A-Za-z0-9_.-])/.test(Z)}var F0=(Z)=>Z.split("/").pop()??"",N0={perl:{letters:new Set(["e","E"]),long:new Set},python:{letters:new Set(["c"]),long:new Set},python2:{letters:new Set(["c"]),long:new Set},python3:{letters:new Set(["c"]),long:new Set},ruby:{letters:new Set(["e"]),long:new Set},node:{letters:new Set(["e","p"]),long:new Set(["--eval","--print"])},nodejs:{letters:new Set(["e","p"]),long:new Set(["--eval","--print"])},bun:{letters:new Set(["e"]),long:new Set(["--eval"])},deno:{letters:new Set(["e"]),long:new Set(["--eval"])},php:{letters:new Set(["r"]),long:new Set},lua:{letters:new Set(["e"]),long:new Set},luajit:{letters:new Set(["e"]),long:new Set},Rscript:{letters:new Set(["e"]),long:new Set}},j2=/^(python|perl|ruby|lua|php|node)[0-9.]+$/,f3=new Set(["awk","gawk","mawk","nawk","busybox-awk"]),k3=new Set(["ssh","scp","sftp"]),x3=new Set("bcDEeFIiJLlmOoPpQRSWw".split("")),V2=new Set(["proxycommand","localcommand","knownhostscommand"]),h3=/(?:`|\$\()|\b(?:system|exec|execve|execvp|popen|spawn|posix_spawn|fork|subprocess|Popen|check_output|check_call|shell_exec|passthru|proc_open|pcntl_exec|qx|open|fopen|sysopen|unlink|remove|delete|rmtree|rmdir|mkdir|rename|truncate|ftruncate|chmod|chown|symlink|writeFile|createWriteStream|appendFile|child_process|FileUtils|shutil|Kernel|require|import|load|eval|os|sys|io|fs|File|IO|Dir|Path|pathlib|Deno|Bun)|%x\W/,w3=/[|>]|\b(?:system|getline|close|fflush|print\w*\s*>>?)/;function W2(Z){if(S3(Z.text))return!1;if(Z.kind==="awk")return!w3.test(Z.text);if(Z.kind==="c-interp")return!h3.test(Z.text);return!1}function g3(Z,z,$,J){let Y=N0[Z]??(j2.test(Z)?N0[Z.replace(/[0-9.]+$/,"")]:void 0);if(!Y)return null;let Q=[],X=!1,H=(K)=>{if(K+1>=z.length||J(K+1))return X=!0,K;return Q.push({text:z[K+1],kind:"c-interp"}),K+1};for(let K=$+1;K<z.length;K++){let B=z[K];if(B==="--")break;if(!B.startsWith("-")||B==="-")break;if(B.startsWith("--")){let V=B.indexOf("="),G=V<0?B:B.slice(0,V);if(Y.long.has(G))if(V>=0)Q.push({text:B.slice(V+1),kind:"c-interp"});else K=H(K);continue}let M=B.slice(1);for(let V=0;V<M.length;V++){if(!Y.letters.has(M[V]))continue;if(V<M.length-1)Q.push({text:M.slice(V+1),kind:"c-interp"});else K=H(K);break}}if(Q.length===0&&!X)return null;return{programs:Q,unresolved:X}}function l3(Z,z,$){let J=z+1;for(;J<Z.length&&Z[J].startsWith("-");J++)if(Z[J]==="-L"||Z[J]==="--log-level")J++;if(Z[J]!=="eval"||$(J))return null;let Y=[],Q=!1;for(J++;J<Z.length;J++){if($(J)){Q=!0;continue}if(!Z[J].startsWith("-"))Y.push({text:Z[J],kind:"c-interp"})}return Y.length===0&&!Q?null:{programs:Y,unresolved:Q}}function u3(Z,z,$){let J=[],Y=!1,Q=z+1;for(;Q<Z.length;Q++){let X=Z[Q];if(X==="--"){Q++;break}if(!X.startsWith("-")||X==="-")break;if(X==="-e"||X.startsWith("-e")){let H=X==="-e"?null:X.slice(2);if(H!==null)J.push({text:H,kind:"awk"});else if(Q+1<Z.length&&!$(Q+1))J.push({text:Z[++Q],kind:"awk"});else Y=!0}else if(X==="-f"||X.startsWith("-f")){if(Y=!0,X==="-f")Q++}else if(X==="-v"||X.startsWith("-v")){if(X==="-v")Q++}}if(J.length===0&&!Y){if(Q<Z.length)if($(Q))Y=!0;else J.push({text:Z[Q],kind:"awk"})}return{programs:J,unresolved:Y}}function m3(Z,z,$){let J=Z[z],Y,Q=z;if(J==="-o"){if(z+1>=Z.length)return{value:null,next:z};if($(z+1))return{value:null,next:z+1};Y=Z[z+1],Q=z+1}else Y=J.slice(2);return{value:Y,next:Q}}function p3(Z,z,$){let J=[],Y=!1;for(let Q=z+1;Q<Z.length;Q++){let X=Z[Q];if(X==="--")break;if(!X.startsWith("-")||X==="-")break;if(X.startsWith("--"))continue;if(X==="-o"||X.startsWith("-o")){let{value:K,next:B}=m3(Z,Q,$);if(Q=B,K===null){Y=!0;continue}let M=K.indexOf("="),V=M>=0?M:K.search(/\s/),G=(V>=0?K.slice(0,V):K).trim().toLowerCase(),U=V>=0?K.slice(V+1).trim():"";if(V2.has(G))J.push({text:U,kind:"shell"});continue}if(X==="-F"||X.startsWith("-F")){if(Y=!0,X==="-F")Q++;continue}if(X==="-S"||X.startsWith("-S")){let K=X==="-S"?Q+1<Z.length&&!$(Q+1)?Z[++Q]:null:X.slice(2);if(K===null)Y=!0;else J.push({text:K,kind:"shell"});continue}let H=X.slice(1);for(let K=0;K<H.length;K++){if(!x3.has(H[K]))continue;if(K<H.length-1)break;if(H[K]==="o"||H[K]==="F"||H[K]==="S"){if(Q+1<Z.length){let B=Z[Q+1];if(H[K]==="o")if(!$(Q+1)){let M=B.indexOf("="),V=M>=0?M:B.search(/\s/),G=(V>=0?B.slice(0,V):B).trim().toLowerCase();if(V2.has(G))J.push({text:V>=0?B.slice(V+1).trim():"",kind:"shell"})}else Y=!0;else if(H[K]==="F")Y=!0;else if(!$(Q+1))J.push({text:B,kind:"shell"});Q++}}else if(Q+1<Z.length)Q++}}return{programs:J,unresolved:Y}}function c3(Z,z,$){let J=[],Y=!1,Q=!1;for(let X=z+1;X<Z.length;X++){let H=Z[X];if(H==="--")break;if(H==="-e"||H==="--rsh")if(Q=!0,X+1<Z.length&&!$(X+1))J.push({text:Z[++X],kind:"shell"});else Y=!0;else if(H.startsWith("--rsh="))Q=!0,J.push({text:H.slice(6),kind:"shell"});else if(/^-[A-Za-z]*e/.test(H)&&H.length>2&&!H.startsWith("--"))Q=!0,J.push({text:H.slice(H.indexOf("e")+1),kind:"shell"})}return Q?{programs:J,unresolved:Y}:null}var i3=/^(?:true|false|yes|no|on|off|1|0|)$/i,d3=[/^core\.(?:pager|editor|sshcommand|askpass|alternaterefscommand)$/,/^sequence\.editor$/,/^diff\.external$/,/^interactive\.difffilter$/,/^imap\.tunnel$/,/^gc\.recentobjectshook$/,/^gpg\.program$/,/^gpg\.ssh\.defaultkeycommand$/,/^uploadpack\.packobjectshook$/,/^instaweb\.(?:browser|httpd)$/,/^credential\.(?:.+\.)?helper$/,/^diff\..+\.(?:command|textconv)$/,/^(?:difftool|mergetool|man|browser)\..+\.(?:cmd|path)$/,/^guitool\..+\.cmd$/,/^merge\..+\.driver$/,/^gpg\..+\.program$/,/^remote\..+\.(?:uploadpack|receivepack)$/,/^filter\..+\.(?:clean|smudge|process)$/,/^tar\..+\.command$/,/^trailer\..+\.(?:cmd|command)$/,/^sendemail\.(?:.+\.)?(?:tocmd|cccmd|headercmd|sendmailcmd)$/];function N2(Z,z){let $=Z.toLowerCase(),J=(Y)=>Y===void 0?{kind:"unresolved"}:{kind:"command",text:Y};if(/^alias\./.test($))return z!==void 0&&z.trimStart().startsWith("!")?J(z.trimStart().slice(1)):{kind:"unresolved"};if(/^pager\./.test($)||$==="core.fsmonitor")return z!==void 0&&i3.test(z)?{kind:"harmless"}:J(z);if($==="core.gitproxy")return z!==void 0&&/^none(?:\s+for\s+\S+)?$/.test(z)?{kind:"harmless"}:J(z?.replace(/\s+for\s+\S+$/,""));if(/^submodule\..+\.update$/.test($))return z!==void 0&&z.trimStart().startsWith("!")?J(z.trimStart().slice(1)):z===void 0?{kind:"unresolved"}:{kind:"harmless"};if(/^sendemail\.(?:.+\.)?smtpserver$/.test($))return z!==void 0&&!z.startsWith("/")?{kind:"harmless"}:J(z);if(/^credential\.(?:.+\.)?helper$/.test($)){if(z==="")return{kind:"harmless"};if(z===void 0)return{kind:"unresolved"};let Y=z.trimStart();return J(Y.startsWith("!")?Y.slice(1):Y.startsWith("/")?Y:`git credential-${Y}`)}if(d3.some((Y)=>Y.test($)))return J(z);if($==="core.hookspath")return z==="/dev/null"?{kind:"harmless"}:{kind:"unresolved"};if($==="include.path"||/^includeif\..+\.path$/.test($))return{kind:"unresolved"};if($==="protocol.allow")return z!==void 0&&/^(?:never|user)$/i.test(z)?{kind:"harmless"}:{kind:"unresolved"};if($==="protocol.ext.allow")return z!==void 0&&/^never$/i.test(z)?{kind:"harmless"}:{kind:"unresolved"};return{kind:"harmless"}}function G2(Z){return/[$\x60]/.test(Z)||["","x","/x","!x"].some((z)=>N2(Z,z).kind!=="harmless")}var s3=new Set(["GIT_PAGER","GIT_EDITOR","GIT_SEQUENCE_EDITOR","GIT_EXTERNAL_DIFF","GIT_SSH","GIT_SSH_COMMAND","GIT_ASKPASS","SSH_ASKPASS","GIT_PROXY_COMMAND","PAGER","EDITOR","VISUAL"]),n3=new Set(["GIT_EXEC_PATH","GIT_TEMPLATE_DIR","GIT_CONFIG_GLOBAL","GIT_CONFIG_SYSTEM"]);function a3(Z){let z=/'((?:[^']|'\\'')*)'/y,$=(Q)=>Q.replace(/'\\''/g,"'"),J=[],Y=0;while(Y<Z.length){if(/\s/.test(Z[Y])){Y++;continue}z.lastIndex=Y;let Q=z.exec(Z);if(!Q)return null;if(Y=z.lastIndex,Z[Y]==="="){z.lastIndex=Y+1;let X=z.exec(Z);if(!X)return null;Y=z.lastIndex,J.push([$(Q[1]),$(X[1])])}else{let X=$(Q[1]),H=X.indexOf("=");J.push(H<0?[X,void 0]:[X.slice(0,H),X.slice(H+1)])}}return J}function o3(Z,z,$){let J=[],Y=!1,Q=(B,M,V=!0)=>{if(!V||/[$\x60]/.test(B)){Y=!0;return}let G=N2(B,M);if(G.kind==="unresolved")Y=!0;else if(G.kind==="command")J.push({text:G.text,kind:"shell"})},X=(B,M)=>{let V=B.indexOf("="),G=V<0?B:B.slice(0,V),U=V<0?"true":B.slice(V+1);if(!M)return Q(G,U);if(G2(G))Y=!0},H=new Set(["-C","--git-dir","--work-tree","--namespace","--attr-source","--list-cmds","--super-prefix"]);for(let B=z+1;B<Z.length;B++){let M=Z[B];if(!M.startsWith("-")||M==="-")break;if(M==="--")break;if(M==="-c"){if(B+1>=Z.length)break;X(Z[B+1],$(B+1)),B++}else if(M.startsWith("-c")&&!M.startsWith("--"))X(M.slice(2),$(B));else if(M==="--config-env"||M.startsWith("--config-env=")){let V=M==="--config-env"?Z[++B]??"":M.slice(13),G=V.indexOf("="),U=G<0?V:V.slice(0,G);if($(B)||G2(U))Y=!0}else if(M.startsWith("--exec-path="))Y=!0;else if(H.has(M))B++}let K=new Map;for(let B=0;B<z;B++){let M=Z[B].match(/^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/s);if(!M)continue;let[,V,G]=M,U=$(B);if(s3.has(V))if(U)Y=!0;else J.push({text:G,kind:"shell"});else if(n3.has(V)){if(U||G!=="/dev/null"||V==="GIT_EXEC_PATH"||V==="GIT_TEMPLATE_DIR")Y=!0}else if(V==="GIT_ALLOW_PROTOCOL"){if(U||G.split(":").includes("ext"))Y=!0}else if(V==="GIT_CONFIG_PARAMETERS"){let W=U?null:a3(G);if(W===null)Y=!0;else for(let[N,R]of W)Q(N,R??"true")}else if(/^GIT_CONFIG_(?:KEY|VALUE)_\d+$/.test(V)){let W=V.replace(/^GIT_CONFIG_(?:KEY|VALUE)_/,""),N=K.get(W)??{};if(V.startsWith("GIT_CONFIG_KEY_"))N.key=G;else N.value=G;if(U)N.opaque=!0;K.set(W,N)}}for(let B of K.values()){if(B.key===void 0)continue;if(B.opaque)X(`${B.key}=`,!0);else Q(B.key,B.value)}if(J.length===0&&!Y)return null;return{programs:J,unresolved:Y}}function vZ(Z){if(/^~/.test(Z))return null;let z="";for(let $=0;$<Z.length;$++){let J=Z[$];if(J==="'"){let Y=Z.indexOf("'",$+1);if(Y<0)return null;z+=Z.slice($+1,Y),$=Y}else if(J==="$"||J==="`")return null;else if(J==='"'){let Y=$+1;for(;Y<Z.length&&Z[Y]!=='"';Y++){let Q=Z[Y];if(Q==="$"||Q==="`")return null;if(Q==="\\"&&Y+1<Z.length&&/[$\x60"\\\n]/.test(Z[Y+1])){z+=Z[++Y];continue}z+=Q}if(Y>=Z.length)return null;$=Y}else if(J==="\\"){if($+1>=Z.length)return null;z+=Z[++$]}else if("*?[{}".includes(J))return null;else z+=J}return z}function U2(Z){let z=null;for(let $=0;$<Z.length;$++){let J=Z[$];if(z==="'"){if(J==="'")z=null;continue}if(J==="\\"){$++;continue}if(J==="$"||J==="`")return!1;if(z==='"'){if(J==='"')z=null;continue}if(J==="'"||J==='"'){z=J;continue}if(J==="<"&&Z[$+1]==="<"&&Z[$+2]!=="<")return!1}return z===null}var r3=new Set(["sh","bash","zsh","dash","ksh","ash","mksh"]),t3=new Set(["--rcfile","--init-file"]),jZ=(Z)=>Z.replace(/\$'(?:[^'\\]|\\[\s\S])*'/g,(z)=>z.replace(/\\[\s\S]/g,($)=>$==="\\'"?"\\x27":$));function EZ(Z,z,$=vZ){if(z<0||z>=Z.length)return null;let J=F0($(Z[z])??"");if(J==="eval"){let H=z+1;if(vZ(Z[H]??"")==="--")H++;let K=Z.slice(H);if(K.length===0)return null;if(K.length>1)return{program:null,literal:!1};let B=vZ(K[0]);return B!==null&&U2(B)?{program:B,literal:!0}:{program:B,literal:!1}}if(!r3.has(J))return null;let Y=!1,Q=z+1;for(;Q<Z.length;Q++){let H=vZ(Z[Q]);if(H===null){if(Y)break;return/^"[^"]*"$/.test(Z[Q])?null:{program:null,literal:!1}}if(H==="--"){Q++;break}if(!/^[-+]./.test(H))break;if(H.startsWith("--")){if(t3.has(H))Q++;continue}let K=H.slice(1);if(H[0]==="-"&&K.includes("c"))Y=!0;if(/[oO]/.test(K))Q++}if(!Y||Q>=Z.length)return null;let X=vZ(Z[Q]);return X!==null&&U2(X)?{program:X,literal:!0}:{program:X,literal:!1}}function e3(Z,z,$){let J=Z4(Z,z,$);if(J===null)return{programs:[],unresolved:!0};let Y=new Set;for(let{scripts:Q,mayFail:X}of J){let H=$4(Q.join(`
3
- `));if(H===null){if(X)continue;return{programs:[],unresolved:!0}}if(H.executes)return{programs:Q.map((K)=>({text:K,kind:"shell"})),unresolved:!0};for(let K of H.writes)Y.add(K)}if(Y.size===0)return null;return{programs:[],unresolved:!1,writes:[...Y]}}var W0="quiet silent debug follow-symlinks posix regexp-extended separate sandbox unbuffered null-data zero-terminated binary help version in-place file expression line-length".split(" ");function Z4(Z,z,$){let J=[],Y=[],Q=!1,X=-1,H=!1,K=!1;for(let V=z+1;V<Z.length;V++){let G=Z[V];if(K||!/^-./.test(G)){Y.push(V);continue}if($(V))return null;if(G==="--"){K=!0;continue}let U,W;if(G[1]==="-"){let N=G.indexOf("="),R=(N<0?G:G.slice(0,N)).slice(2),f=W0.filter((i)=>i.startsWith(R)),k=W0.includes(R)?R:f.length===1?f[0]:"";if(W0.indexOf(k)<15){if(!k)return null;continue}if(U=k[0],N>=0)W=G.slice(N+1)}else{let N=1;while("nrEsuzb".includes(G[N]??"_"))N++;if(U=G[N]??"",U==="i"||U==="I"){let R=N===G.length-1&&V+1<Z.length&&!$(V+1)?Z[V+1]:void 0;if(U==="I"){if(H=Q=!0,N===G.length-1){if(R===void 0)return null;X=V+1}}else if(R===""||R?.startsWith("."))Q=!0,X=V+1;continue}if(U==="")continue;if(!"efl".includes(U))return null;W=G.slice(N+1)||void 0}if(U==="f")return null;if(W===void 0){if(W=Z[++V],W===void 0||$(V))return null}if(U==="e")J.push(W)}let B=(V)=>{if(J.length>0)return J;let G=Y.find((U)=>U!==V);return G===void 0?[]:$(G)?null:[Z[G]]},M=[];if(!H)M.push({scripts:B(-1),mayFail:X>=0&&J.length===0&&Y[0]===X});if(Q)M.push({scripts:B(X),mayFail:!1});return M.some((V)=>V.scripts===null)?null:M}function $4(Z){let z=[],$=!1,J=0,Y=Z.length,Q=()=>Z[J]??"",X=()=>{while(Q()===" "||Q()==="\t")J++;let B=J,M=Z.indexOf(`
4
- `,J);return J=M<0?Y:M,Z.slice(B,J)},H=()=>{let B=X();if(B&&!/^\/dev\/std(?:out|err)$/.test(B))z.push(B)},K=(B,M)=>{for(;J<Y;J++){let V=Z[J];if(V===`
1
+ var{defineProperty:W0,getOwnPropertyNames:C3,getOwnPropertyDescriptor:P3}=Object,O3=Object.prototype.hasOwnProperty;function L3(Z){return this[Z]}var A3=(Z)=>{var z=(H2??=new WeakMap).get(Z),$;if(z)return z;if(z=W0({},"__esModule",{value:!0}),Z&&typeof Z==="object"||typeof Z==="function"){for(var J of C3(Z))if(!O3.call(z,J))W0(z,J,{get:L3.bind(Z,J),enumerable:!($=P3(Z,J))||$.enumerable})}return H2.set(Z,z),z},H2;var y3=(Z)=>Z;function R3(Z,z){this[Z]=y3.bind(null,z)}var v3=(Z,z)=>{for(var $ in z)W0(Z,$,{get:z[$],enumerable:!0,configurable:!0,set:R3.bind(z,$)})};var k6={};v3(k6,{version:()=>S6,evaluate:()=>f6,abi:()=>E6});module.exports=A3(k6);var M0=require("node:os"),J2=require("node:path");var x=require("node:path");var v=require("node:path"),P=require("node:fs"),B2=require("node:child_process"),M2={missing:"No verified @hasna/trash guard was found on PATH.",unsafe_executable:"The Trash candidate is not an owned executable file or is writable by group or others.",unsafe_manifest:"The Trash package manifest is not a safe owned regular file.",unsafe_directory:"A Trash PATH or package directory is not owned safely or is writable by group or others.",unsafe_interpreter:"The Trash interpreter is missing, unsupported, or not a safe owned executable on its actual PATH.",unrecognized_package:"The candidate is not the registered @hasna/trash executable.",identity_failed:"The installed Trash identity probe failed or exceeded its deadline.",unsupported_protocol:"The installed Trash version does not expose the required guard protocol."};function AZ(Z){return Z===0||Z===process.getuid?.()}function iZ(Z,z=!1){let $=Z;for(let J=0;J<32;J++){if(!v.isAbsolute($)||$.length>4096||!yZ("/"))return!1;let Y=$.split("/"),X=Y.pop();if(!X||X==="."||X==="..")return!1;let Q="/";for(let B of Y){if(!B||B===".")continue;if(B===".."){Q=v.dirname(Q);continue}let M=v.join(Q,B),V=P.lstatSync(M);if(z&&M==="/bin"&&V.isSymbolicLink()&&V.uid===0){let G=P.realpathSync(M);if(!yZ(G))return!1;Q=G;continue}if(!V.isDirectory()||!AZ(V.uid)||V.mode&18)return!1;Q=M}let H=v.join(Q,X),K=P.lstatSync(H);if(!AZ(K.uid))return!1;if(K.isSymbolicLink()){let B=P.readlinkSync(H);$=v.isAbsolute(B)?B:Q+"/"+B;continue}return K.isFile()&&Boolean(K.mode&73)&&!(K.mode&18)}return!1}function b3(Z){if(!v.isAbsolute(Z)||v.resolve(Z)!==(Z.replace(/\/+$/,"")||"/"))return!1;for(let z=v.resolve(Z);;z=v.dirname(z)){try{return P.lstatSync(z),yZ(z)}catch($){if($.code!=="ENOENT")return!1}if(v.dirname(z)===z)return!1}}function E3(Z,z){let $=P.openSync(Z,P.constants.O_RDONLY|P.constants.O_NONBLOCK|P.constants.O_NOFOLLOW),J;try{if(!P.fstatSync($).isFile())return!1;let X=Buffer.alloc(256),Q=P.readSync($,X,0,X.length,0);J=X.subarray(0,Q).toString("utf8").split(`
2
+ `)[0]}finally{P.closeSync($)}let Y=/^#!(\/[A-Za-z0-9_./-]+)$/.exec(J);if(Y&&Y[1]!=="/usr/bin/env")return iZ(Y[1],!0);if(J!=="#!/usr/bin/env bun"||!iZ("/usr/bin/env",!0))return!1;for(let X of z.split(":").slice(0,64)){if(!b3(X))return!1;let Q=v.resolve(X,"bun");try{if(!P.statSync(Q).isFile())continue;P.accessSync(Q,P.constants.X_OK)}catch{continue}return iZ(Q,!0)}return!1}function yZ(Z){let z=Z;for(;;){let $=P.lstatSync(z);if(!$.isDirectory()||!AZ($.uid)||($.mode&18)!==0)return!1;let J=v.dirname(z);if(J===z)return!0;z=J}}function RZ(Z=process.env){let z=Z.PATH??"",$=Date.now()+2000,J="missing",Y=(X)=>{if(J==="missing"||J==="unrecognized_package"||X.startsWith("unsafe_"))J=X};for(let X of z.split(":").slice(0,64)){if(!v.isAbsolute(X)||Date.now()>=$)continue;let Q=v.resolve(X,"trash");try{let H=P.statSync(Q);if(!H.isFile()||!AZ(H.uid)||(H.mode&73)===0||(H.mode&18)!==0){Y("unsafe_executable");continue}let K=P.realpathSync(Q);if(!yZ(v.resolve(X))||!yZ(v.dirname(K))){Y("unsafe_directory");continue}if(!iZ(Q)){Y("unsafe_directory");continue}let B=v.resolve(v.dirname(K),"../.."),M=v.join(B,"package.json"),V=P.statSync(M);if(!V.isFile()||!AZ(V.uid)||V.size>16384||(V.mode&18)!==0||P.lstatSync(M).isSymbolicLink()){Y("unsafe_manifest");continue}let G=JSON.parse(P.readFileSync(M,"utf8"));if(G.name!=="@hasna/trash"||typeof G.version!=="string"||typeof G.bin?.trash!=="string"||P.realpathSync(v.resolve(B,G.bin.trash))!==K){Y("unrecognized_package");continue}try{if(!E3(K,z)){Y("unsafe_interpreter");continue}}catch{Y("unsafe_interpreter");continue}let U=$-Date.now();if(U<=0){Y("identity_failed");break}let j=B2.spawnSync(Q,["--identity"],{encoding:"utf8",timeout:U,maxBuffer:2048,env:{PATH:z},stdio:["ignore","pipe","pipe"]});if(j.error||j.status!==0||Date.now()>=$){Y("identity_failed");continue}let N=JSON.parse(j.stdout);if(N.name==="@hasna/trash"&&N.version===G.version&&N.guardProtocol==="hasna.trash.guard.v1")return{ok:!0,path:Q,version:G.version};Y("unsupported_protocol")}catch{}}return{ok:!1,code:J}}function dZ(Z=process.env){let z=RZ(Z);return z.ok?z.path:null}function WZ(Z){let z=Z.tool_input?.command;return typeof z==="string"?z:""}var V2=["/","/bin","/boot","/dev","/etc","/home","/lib","/lib32","/lib64","/libx32","/opt","/proc","/root","/run","/sbin","/srv","/sys","/usr","/var","/Applications","/Library","/System","/Users","/Volumes","/private"];var bZ=/^[A-Za-z_][A-Za-z0-9_]*\+?=/,o=(Z)=>Z.split("/").pop()??"";function sZ(Z){let z=Z.startsWith("~")?Z.slice(1).split("/",1)[0]:"";if(z&&!/['"\\]/.test(z))return!0;let $=null,J=0;for(let Y=0;Y<Z.length;Y++){let X=Z[Y];if($==="'"){if(X==="'")$=null;continue}if(X==="\\"){Y++;continue}if($==='"'){if(X==='"')$=null;continue}if(X==="'"||X==='"')$=X;else if(X==="$"&&Z[Y+1]==="{")J++,Y++;else if(X==="}"&&J>0)J--;else if(X==="{"||X==="}")return!0}return!1}var N0=64;function G2(Z,z){let $=0;for(let J=z;J<Z.length;J++)if(Z[J]==="\\")J++;else if(Z[J]==="{")$++;else if(Z[J]==="}"&&--$===0)return J;return Z.length-1}function S3(Z){let z=Z.match(/^([-+]?\d+)\.\.([-+]?\d+)(?:\.\.([-+]?\d+))?$/),$=z?null:Z.match(/^([A-Za-z])\.\.([A-Za-z])(?:\.\.([-+]?\d+))?$/),J=z??$;if(!J)return null;let Y=z?Number(J[1]):J[1].charCodeAt(0),X=z?Number(J[2]):J[2].charCodeAt(0),Q=Math.abs(Number(J[3]??1))||1;if(!Number.isSafeInteger(Y)||!Number.isSafeInteger(X)||!Number.isSafeInteger(Q))return"overflow";if(Math.floor(Math.abs(X-Y)/Q)+1>N0)return"overflow";let H=z&&(/^[-+]?0\d/.test(J[1])||/^[-+]?0\d/.test(J[2]))?Math.max(J[1].length,J[2].length):0,K=[];for(let B=Y;Y<=X?B<=X:B>=X;B+=Y<=X?Q:-Q)if(!z)K.push(String.fromCharCode(B));else K.push(B<0?`-${String(-B).padStart(H-1,"0")}`:String(B).padStart(H,"0"));return K}function f3(Z){let z=null,$=0;for(let J=0;J<Z.length;J++){let Y=Z[J];if(z==="'"){if(Y==="'")z=null;continue}if(Y==="\\"){J++;continue}if(z==='"'){if(Y==='"')z=null;continue}if(Y==="'"||Y==='"')z=Y;else if(Y==="$"&&Z[J+1]==="{")J=G2(Z,J+1);else if(Y==="{"){if(++$>N0)return"overflow";let X=null,Q=0,H=!0,K=[];for(let B=J;B<Z.length;B++){let M=Z[B];if(X==="'"){if(M==="'")X=null;continue}if(M==="\\"){H=!1,B++;continue}if(X==='"'){if(M==='"')X=null;continue}if(M==="'"||M==='"')X=M,H=!1;else if(M==="$"&&Z[B+1]==="{")B=G2(Z,B+1),H=!1;else if(M==="{")Q++;else if(M===","&&Q===1)K.push(B);else if(M==="}"&&--Q===0){if(K.length>0){let G=[J,...K,B];return{open:J,close:B,parts:G.slice(0,-1).map((U,j)=>Z.slice(U+1,G[j+1]))}}let V=H?S3(Z.slice(J+1,B)):null;if(V==="overflow")return V;if(V)return{open:J,close:B,parts:V};break}}}}return null}function QZ(Z){if(Z.length>4096&&Z.includes("{"))return null;let z=f3(Z);if(z===null)return[Z];if(z==="overflow")return null;let $=[];for(let J of z.parts){let Y=QZ(Z.slice(0,z.open)+J+Z.slice(z.close+1));if(Y===null||$.push(...Y)>N0)return null}return $}var W={arg:"none"},D={arg:"value"},vZ={arg:"optional"},t={arg:"none",effect:"lookup"},C={arg:"none",effect:"refuse"},ZZ={help:C,version:C},k3=/^(?:\d+(?:\.\d*)?|\.\d+)[smhd]?$/,F0={timeout:{short:{k:D,s:D,v:W},long:{"kill-after":D,signal:D,verbose:W,foreground:W,"preserve-status":W,...ZZ},positionals:[k3]},env:{short:{i:W,"0":W,v:W,u:D,a:D,C,S:C},long:{"ignore-environment":W,null:W,debug:W,unset:D,argv0:D,chdir:C,"split-string":C,"block-signal":vZ,"default-signal":vZ,"ignore-signal":vZ,"list-signal-handling":C,...ZZ},env:!0},nice:{short:{n:D},long:{adjustment:D,...ZZ},numericOption:!0},nohup:{short:{},long:{...ZZ}},command:{short:{p:W,v:t,V:t},long:{}},exec:{short:{c:W,l:W,a:D},long:{}},builtin:{short:{},long:{}},stdbuf:{short:{i:D,o:D,e:D},long:{input:D,output:D,error:D,...ZZ}},time:{short:{p:W,a:W,q:W,v:W,f:D,o:C,V:C},long:{portability:W,append:W,quiet:W,verbose:W,format:D,output:C,...ZZ}},ionice:{short:{c:D,n:D,t:W,p:C,P:C,u:C,h:C,V:C},long:{class:D,classdata:D,ignore:W,pid:C,pgid:C,uid:C,...ZZ}},setsid:{short:{c:W,f:W,w:W,h:C,V:C},long:{ctty:W,fork:W,wait:W,...ZZ}}},x3=new Set(["!","{","}","then","do","else","elif","if","while","until","for","case","esac","fi","done","select","function"]);function h3(Z,z,$){let J=!1,Y=(X)=>{if(!X||X.effect==="refuse")return!1;if(X.effect==="lookup")J=!0;return!0};while($<z.length){let X=z[$];if(X.opaque)return null;let Q=X.text;if(Q==="--"){$++;break}if(Q==="-"&&Z.env){$++;continue}if(!Q.startsWith("-")||Q==="-")break;if(Z.numericOption&&/^-[-+]?\d+$/.test(Q)){$++;continue}if(Q.startsWith("--")){let H=Q.indexOf("="),K=H<0?Q.slice(2):Q.slice(2,H),B=Object.keys(Z.long),M=B.includes(K)?[K]:B.filter((G)=>K&&G.startsWith(K));if(M.length!==1)return null;let V=Z.long[M[0]];if(!Y(V))return null;if(V.arg==="none"&&H>=0)return null;if(V.arg==="value"&&H<0){let G=z[++$];if(!G||G.opaque)return null}$++;continue}for(let H=1;H<Q.length;H++){let K=Z.short[Q[H]];if(!Y(K))return null;if(K.arg==="value"){if(H===Q.length-1){let B=z[++$];if(!B||B.opaque)return null}break}}$++}if(J)return-1;for(let X of Z.positionals??[]){let Q=z[$];if(!Q||Q.opaque||!X.test(Q.text))return null;$++}if(Z.env||Z.assignments){for(;$<z.length&&bZ.test(z[$].text);$++)if(z[$].opaque)return null}return $}function KZ(Z,z=F0){let $=0;while($<Z.length&&(bZ.test(Z[$].text)||x3.has(Z[$].text)))$++;for(let J=0;J<16;J++){if($>=Z.length)return{index:-1};if(Z[$].opaque)return J===0?{index:$}:null;let Y=Object.hasOwn(z,o(Z[$].text))?z[o(Z[$].text)]:void 0;if(!Y)return{index:$};let X=h3(Y,Z,$+1);if(X===null)return null;if(X<0)return{index:-1};$=X}return null}function w3(Z){return/(^|[^A-Za-z0-9_.-])(rm|rmdir|unlink|shred|trash)(?![A-Za-z0-9_.-])/.test(Z)}var $Z={on:!1};function HZ(Z,z){if(!Z.includes("\\")||!Z.includes('"'))return;let $=$Z.on;$Z.on=!0;try{return z()}finally{$Z.on=$}}var I0=(Z)=>Z.split("/").pop()??"",D0={perl:{letters:new Set(["e","E"]),long:new Set},python:{letters:new Set(["c"]),long:new Set},python2:{letters:new Set(["c"]),long:new Set},python3:{letters:new Set(["c"]),long:new Set},ruby:{letters:new Set(["e"]),long:new Set},node:{letters:new Set(["e","p"]),long:new Set(["--eval","--print"])},nodejs:{letters:new Set(["e","p"]),long:new Set(["--eval","--print"])},bun:{letters:new Set(["e"]),long:new Set(["--eval"])},deno:{letters:new Set(["e"]),long:new Set(["--eval"])},php:{letters:new Set(["r"]),long:new Set},lua:{letters:new Set(["e"]),long:new Set},luajit:{letters:new Set(["e"]),long:new Set},Rscript:{letters:new Set(["e"]),long:new Set}},N2=/^(python|perl|ruby|lua|php|node)[0-9.]+$/,g3=new Set(["awk","gawk","mawk","nawk","busybox-awk"]),u3=new Set(["ssh","scp","sftp"]),l3=new Set("bcDEeFIiJLlmOoPpQRSWw".split("")),U2=new Set(["proxycommand","localcommand","knownhostscommand"]),m3=/(?:`|\$\()|\b(?:system|exec|execve|execvp|popen|spawn|posix_spawn|fork|subprocess|Popen|check_output|check_call|shell_exec|passthru|proc_open|pcntl_exec|qx|open|fopen|sysopen|unlink|remove|delete|rmtree|rmdir|mkdir|rename|truncate|ftruncate|chmod|chown|symlink|writeFile|createWriteStream|appendFile|child_process|FileUtils|shutil|Kernel|require|import|load|eval|os|sys|io|fs|File|IO|Dir|Path|pathlib|Deno|Bun)|%x\W/,p3=/[|>]|\b(?:system|getline|close|fflush|print\w*\s*>>?)/;function F2(Z){if(w3(Z.text))return!1;if(Z.kind==="awk")return!p3.test(Z.text);if(Z.kind==="c-interp")return!m3.test(Z.text);return!1}function c3(Z,z,$,J){let Y=D0[Z]??(N2.test(Z)?D0[Z.replace(/[0-9.]+$/,"")]:void 0);if(!Y)return null;let X=[],Q=!1,H=(K)=>{if(K+1>=z.length||J(K+1))return Q=!0,K;return X.push({text:z[K+1],kind:"c-interp"}),K+1};for(let K=$+1;K<z.length;K++){let B=z[K];if(B==="--")break;if(!B.startsWith("-")||B==="-")break;if(B.startsWith("--")){let V=B.indexOf("="),G=V<0?B:B.slice(0,V);if(Y.long.has(G))if(V>=0)X.push({text:B.slice(V+1),kind:"c-interp"});else K=H(K);continue}let M=B.slice(1);for(let V=0;V<M.length;V++){if(!Y.letters.has(M[V]))continue;if(V<M.length-1)X.push({text:M.slice(V+1),kind:"c-interp"});else K=H(K);break}}if(X.length===0&&!Q)return null;return{programs:X,unresolved:Q}}function i3(Z,z,$){let J=z+1;for(;J<Z.length&&Z[J].startsWith("-");J++)if(Z[J]==="-L"||Z[J]==="--log-level")J++;if(Z[J]!=="eval"||$(J))return null;let Y=[],X=!1;for(J++;J<Z.length;J++){if($(J)){X=!0;continue}if(!Z[J].startsWith("-"))Y.push({text:Z[J],kind:"c-interp"})}return Y.length===0&&!X?null:{programs:Y,unresolved:X}}function d3(Z,z,$){let J=[],Y=!1,X=z+1;for(;X<Z.length;X++){let Q=Z[X];if(Q==="--"){X++;break}if(!Q.startsWith("-")||Q==="-")break;if(Q==="-e"||Q.startsWith("-e")){let H=Q==="-e"?null:Q.slice(2);if(H!==null)J.push({text:H,kind:"awk"});else if(X+1<Z.length&&!$(X+1))J.push({text:Z[++X],kind:"awk"});else Y=!0}else if(Q==="-f"||Q.startsWith("-f")){if(Y=!0,Q==="-f")X++}else if(Q==="-v"||Q.startsWith("-v")){if(Q==="-v")X++}}if(J.length===0&&!Y){if(X<Z.length)if($(X))Y=!0;else J.push({text:Z[X],kind:"awk"})}return{programs:J,unresolved:Y}}function s3(Z,z,$){let J=Z[z],Y,X=z;if(J==="-o"){if(z+1>=Z.length)return{value:null,next:z};if($(z+1))return{value:null,next:z+1};Y=Z[z+1],X=z+1}else Y=J.slice(2);return{value:Y,next:X}}function n3(Z,z,$){let J=[],Y=!1;for(let X=z+1;X<Z.length;X++){let Q=Z[X];if(Q==="--")break;if(!Q.startsWith("-")||Q==="-")break;if(Q.startsWith("--"))continue;if(Q==="-o"||Q.startsWith("-o")){let{value:K,next:B}=s3(Z,X,$);if(X=B,K===null){Y=!0;continue}let M=K.indexOf("="),V=M>=0?M:K.search(/\s/),G=(V>=0?K.slice(0,V):K).trim().toLowerCase(),U=V>=0?K.slice(V+1).trim():"";if(U2.has(G))J.push({text:U,kind:"shell"});continue}if(Q==="-F"||Q.startsWith("-F")){if(Y=!0,Q==="-F")X++;continue}if(Q==="-S"||Q.startsWith("-S")){let K=Q==="-S"?X+1<Z.length&&!$(X+1)?Z[++X]:null:Q.slice(2);if(K===null)Y=!0;else J.push({text:K,kind:"shell"});continue}let H=Q.slice(1);for(let K=0;K<H.length;K++){if(!l3.has(H[K]))continue;if(K<H.length-1)break;if(H[K]==="o"||H[K]==="F"||H[K]==="S"){if(X+1<Z.length){let B=Z[X+1];if(H[K]==="o")if(!$(X+1)){let M=B.indexOf("="),V=M>=0?M:B.search(/\s/),G=(V>=0?B.slice(0,V):B).trim().toLowerCase();if(U2.has(G))J.push({text:V>=0?B.slice(V+1).trim():"",kind:"shell"})}else Y=!0;else if(H[K]==="F")Y=!0;else if(!$(X+1))J.push({text:B,kind:"shell"});X++}}else if(X+1<Z.length)X++}}return{programs:J,unresolved:Y}}function o3(Z,z,$){let J=[],Y=!1,X=!1;for(let Q=z+1;Q<Z.length;Q++){let H=Z[Q];if(H==="--")break;if(H==="-e"||H==="--rsh")if(X=!0,Q+1<Z.length&&!$(Q+1))J.push({text:Z[++Q],kind:"shell"});else Y=!0;else if(H.startsWith("--rsh="))X=!0,J.push({text:H.slice(6),kind:"shell"});else if(/^-[A-Za-z]*e/.test(H)&&H.length>2&&!H.startsWith("--"))X=!0,J.push({text:H.slice(H.indexOf("e")+1),kind:"shell"})}return X?{programs:J,unresolved:Y}:null}var a3=/^(?:true|false|yes|no|on|off|1|0|)$/i,r3=[/^core\.(?:pager|editor|sshcommand|askpass|alternaterefscommand)$/,/^sequence\.editor$/,/^diff\.external$/,/^interactive\.difffilter$/,/^imap\.tunnel$/,/^gc\.recentobjectshook$/,/^gpg\.program$/,/^gpg\.ssh\.defaultkeycommand$/,/^uploadpack\.packobjectshook$/,/^instaweb\.(?:browser|httpd)$/,/^credential\.(?:.+\.)?helper$/,/^diff\..+\.(?:command|textconv)$/,/^(?:difftool|mergetool|man|browser)\..+\.(?:cmd|path)$/,/^guitool\..+\.cmd$/,/^merge\..+\.driver$/,/^gpg\..+\.program$/,/^remote\..+\.(?:uploadpack|receivepack)$/,/^filter\..+\.(?:clean|smudge|process)$/,/^tar\..+\.command$/,/^trailer\..+\.(?:cmd|command)$/,/^sendemail\.(?:.+\.)?(?:tocmd|cccmd|headercmd|sendmailcmd)$/];function _2(Z,z){let $=Z.toLowerCase(),J=(Y)=>Y===void 0?{kind:"unresolved"}:{kind:"command",text:Y};if(/^alias\./.test($))return z!==void 0&&z.trimStart().startsWith("!")?J(z.trimStart().slice(1)):{kind:"unresolved"};if(/^pager\./.test($)||$==="core.fsmonitor")return z!==void 0&&a3.test(z)?{kind:"harmless"}:J(z);if($==="core.gitproxy")return z!==void 0&&/^none(?:\s+for\s+\S+)?$/.test(z)?{kind:"harmless"}:J(z?.replace(/\s+for\s+\S+$/,""));if(/^submodule\..+\.update$/.test($))return z!==void 0&&z.trimStart().startsWith("!")?J(z.trimStart().slice(1)):z===void 0?{kind:"unresolved"}:{kind:"harmless"};if(/^sendemail\.(?:.+\.)?smtpserver$/.test($))return z!==void 0&&!z.startsWith("/")?{kind:"harmless"}:J(z);if(/^credential\.(?:.+\.)?helper$/.test($)){if(z==="")return{kind:"harmless"};if(z===void 0)return{kind:"unresolved"};let Y=z.trimStart();return J(Y.startsWith("!")?Y.slice(1):Y.startsWith("/")?Y:`git credential-${Y}`)}if(r3.some((Y)=>Y.test($)))return J(z);if($==="core.hookspath")return z==="/dev/null"?{kind:"harmless"}:{kind:"unresolved"};if($==="include.path"||/^includeif\..+\.path$/.test($))return{kind:"unresolved"};if($==="protocol.allow")return z!==void 0&&/^(?:never|user)$/i.test(z)?{kind:"harmless"}:{kind:"unresolved"};if($==="protocol.ext.allow")return z!==void 0&&/^never$/i.test(z)?{kind:"harmless"}:{kind:"unresolved"};return{kind:"harmless"}}function j2(Z){return/[$\x60]/.test(Z)||["","x","/x","!x"].some((z)=>_2(Z,z).kind!=="harmless")}var t3=new Set(["GIT_PAGER","GIT_EDITOR","GIT_SEQUENCE_EDITOR","GIT_EXTERNAL_DIFF","GIT_SSH","GIT_SSH_COMMAND","GIT_ASKPASS","SSH_ASKPASS","GIT_PROXY_COMMAND","PAGER","EDITOR","VISUAL"]),e3=new Set(["GIT_EXEC_PATH","GIT_TEMPLATE_DIR","GIT_CONFIG_GLOBAL","GIT_CONFIG_SYSTEM"]);function Z4(Z){let z=/'((?:[^']|'\\'')*)'/y,$=(X)=>X.replace(/'\\''/g,"'"),J=[],Y=0;while(Y<Z.length){if(/\s/.test(Z[Y])){Y++;continue}z.lastIndex=Y;let X=z.exec(Z);if(!X)return null;if(Y=z.lastIndex,Z[Y]==="="){z.lastIndex=Y+1;let Q=z.exec(Z);if(!Q)return null;Y=z.lastIndex,J.push([$(X[1]),$(Q[1])])}else{let Q=$(X[1]),H=Q.indexOf("=");J.push(H<0?[Q,void 0]:[Q.slice(0,H),Q.slice(H+1)])}}return J}function $4(Z,z,$){let J=[],Y=!1,X=(B,M,V=!0)=>{if(!V||/[$\x60]/.test(B)){Y=!0;return}let G=_2(B,M);if(G.kind==="unresolved")Y=!0;else if(G.kind==="command")J.push({text:G.text,kind:"shell"})},Q=(B,M)=>{let V=B.indexOf("="),G=V<0?B:B.slice(0,V),U=V<0?"true":B.slice(V+1);if(!M)return X(G,U);if(j2(G))Y=!0},H=new Set(["-C","--git-dir","--work-tree","--namespace","--attr-source","--list-cmds","--super-prefix"]);for(let B=z+1;B<Z.length;B++){let M=Z[B];if(!M.startsWith("-")||M==="-")break;if(M==="--")break;if(M==="-c"){if(B+1>=Z.length)break;Q(Z[B+1],$(B+1)),B++}else if(M.startsWith("-c")&&!M.startsWith("--"))Q(M.slice(2),$(B));else if(M==="--config-env"||M.startsWith("--config-env=")){let V=M==="--config-env"?Z[++B]??"":M.slice(13),G=V.indexOf("="),U=G<0?V:V.slice(0,G);if($(B)||j2(U))Y=!0}else if(M.startsWith("--exec-path="))Y=!0;else if(H.has(M))B++}let K=new Map;for(let B=0;B<z;B++){let M=Z[B].match(/^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/s);if(!M)continue;let[,V,G]=M,U=$(B);if(t3.has(V))if(U)Y=!0;else J.push({text:G,kind:"shell"});else if(e3.has(V)){if(U||G!=="/dev/null"||V==="GIT_EXEC_PATH"||V==="GIT_TEMPLATE_DIR")Y=!0}else if(V==="GIT_ALLOW_PROTOCOL"){if(U||G.split(":").includes("ext"))Y=!0}else if(V==="GIT_CONFIG_PARAMETERS"){let j=U?null:Z4(G);if(j===null)Y=!0;else for(let[N,y]of j)X(N,y??"true")}else if(/^GIT_CONFIG_(?:KEY|VALUE)_\d+$/.test(V)){let j=V.replace(/^GIT_CONFIG_(?:KEY|VALUE)_/,""),N=K.get(j)??{};if(V.startsWith("GIT_CONFIG_KEY_"))N.key=G;else N.value=G;if(U)N.opaque=!0;K.set(j,N)}}for(let B of K.values()){if(B.key===void 0)continue;if(B.opaque)Q(`${B.key}=`,!0);else X(B.key,B.value)}if(J.length===0&&!Y)return null;return{programs:J,unresolved:Y}}function EZ(Z){if(/^~/.test(Z))return null;let z="";for(let $=0;$<Z.length;$++){let J=Z[$];if(J==="'"){let Y=Z.indexOf("'",$+1);if(Y<0)return null;z+=Z.slice($+1,Y),$=Y}else if(J==="$"||J==="`")return null;else if(J==='"'){let Y=$+1;for(;Y<Z.length&&Z[Y]!=='"';Y++){let X=Z[Y];if(X==="$"||X==="`")return null;if(X==="\\"&&Y+1<Z.length&&/[$\x60"\\\n]/.test(Z[Y+1])){if(Z[++Y]!==`
3
+ `||$Z.on)z+=Z[Y];continue}z+=X}if(Y>=Z.length)return null;$=Y}else if(J==="\\"){if($+1>=Z.length)return null;z+=Z[++$]}else if("*?[{}".includes(J))return null;else z+=J}return z}function W2(Z){let z=null;for(let $=0;$<Z.length;$++){let J=Z[$];if(z==="'"){if(J==="'")z=null;continue}if(J==="\\"){$++;continue}if(J==="$"||J==="`")return!1;if(z==='"'){if(J==='"')z=null;continue}if(J==="'"||J==='"'){z=J;continue}if(J==="<"&&Z[$+1]==="<"&&Z[$+2]!=="<")return!1}return z===null}var J4=new Set(["sh","bash","zsh","dash","ksh","ash","mksh"]),z4=new Set(["--rcfile","--init-file"]),NZ=(Z)=>Z.replace(/\$'(?:[^'\\]|\\[\s\S])*'/g,(z)=>z.replace(/\\[\s\S]/g,($)=>$==="\\'"?"\\x27":$));function fZ(Z,z,$=EZ){if(z<0||z>=Z.length)return null;let J=I0($(Z[z])??"");if(J==="eval"){let H=z+1;if(EZ(Z[H]??"")==="--")H++;let K=Z.slice(H);if(K.length===0)return null;if(K.length>1)return{program:null,literal:!1};let B=EZ(K[0]);return B!==null&&W2(B)?{program:B,literal:!0}:{program:B,literal:!1}}if(!J4.has(J))return null;let Y=!1,X=z+1;for(;X<Z.length;X++){let H=EZ(Z[X]);if(H===null){if(Y)break;return/^"[^"]*"$/.test(Z[X])?null:{program:null,literal:!1}}if(H==="--"){X++;break}if(!/^[-+]./.test(H))break;if(H.startsWith("--")){if(z4.has(H))X++;continue}let K=H.slice(1);if(H[0]==="-"&&K.includes("c"))Y=!0;if(/[oO]/.test(K))X++}if(!Y||X>=Z.length)return null;let Q=EZ(Z[X]);return Q!==null&&W2(Q)?{program:Q,literal:!0}:{program:Q,literal:!1}}function Y4(Z,z,$){let J=X4(Z,z,$);if(J===null)return{programs:[],unresolved:!0};let Y=new Set;for(let{scripts:X,mayFail:Q}of J){let H=Q4(X.join(`
4
+ `));if(H===null){if(Q)continue;return{programs:[],unresolved:!0}}if(H.executes)return{programs:X.map((K)=>({text:K,kind:"shell"})),unresolved:!0};for(let K of H.writes)Y.add(K)}if(Y.size===0)return null;return{programs:[],unresolved:!1,writes:[...Y]}}var _0="quiet silent debug follow-symlinks posix regexp-extended separate sandbox unbuffered null-data zero-terminated binary help version in-place file expression line-length".split(" ");function X4(Z,z,$){let J=[],Y=[],X=!1,Q=-1,H=!1,K=!1;for(let V=z+1;V<Z.length;V++){let G=Z[V];if(K||!/^-./.test(G)){Y.push(V);continue}if($(V))return null;if(G==="--"){K=!0;continue}let U,j;if(G[1]==="-"){let N=G.indexOf("="),y=(N<0?G:G.slice(0,N)).slice(2),b=_0.filter((d)=>d.startsWith(y)),k=_0.includes(y)?y:b.length===1?b[0]:"";if(_0.indexOf(k)<15){if(!k)return null;continue}if(U=k[0],N>=0)j=G.slice(N+1)}else{let N=1;while("nrEsuzb".includes(G[N]??"_"))N++;if(U=G[N]??"",U==="i"||U==="I"){let y=N===G.length-1&&V+1<Z.length&&!$(V+1)?Z[V+1]:void 0;if(U==="I"){if(H=X=!0,N===G.length-1){if(y===void 0)return null;Q=V+1}}else if(y===""||y?.startsWith("."))X=!0,Q=V+1;continue}if(U==="")continue;if(!"efl".includes(U))return null;j=G.slice(N+1)||void 0}if(U==="f")return null;if(j===void 0){if(j=Z[++V],j===void 0||$(V))return null}if(U==="e")J.push(j)}let B=(V)=>{if(J.length>0)return J;let G=Y.find((U)=>U!==V);return G===void 0?[]:$(G)?null:[Z[G]]},M=[];if(!H)M.push({scripts:B(-1),mayFail:Q>=0&&J.length===0&&Y[0]===Q});if(X)M.push({scripts:B(Q),mayFail:!1});return M.some((V)=>V.scripts===null)?null:M}function Q4(Z){let z=[],$=!1,J=0,Y=Z.length,X=()=>Z[J]??"",Q=()=>{while(X()===" "||X()==="\t")J++;let B=J,M=Z.indexOf(`
5
+ `,J);return J=M<0?Y:M,Z.slice(B,J)},H=()=>{let B=Q();if(B&&!/^\/dev\/std(?:out|err)$/.test(B))z.push(B)},K=(B,M)=>{for(;J<Y;J++){let V=Z[J];if(V===`
5
6
  `)return!1;if(V==="\\"){if(++J>=Y)return!1}else if(V===B)return J++,!0;else if(M&&V==="["){let G=J+1;if(Z[G]==="^")G++;if(Z[G]==="]")G++;for(;Z[G]!=="]";G++){if(G>=Y||Z[G]===`
6
7
  `)return!1;if(Z[G]==="["&&":.=".includes(Z[G+1]||`
7
8
  `)){let U=Z.indexOf(Z[G+1]+"]",G+2);if(U<0||Z.slice(G,U).includes(`
8
9
  `))return!1;G=U+1}}J=G}}return!1};while(J<Y){let B=Z[J++];if(B==="/"||B==="\\"){let M=B==="\\"?Z[J++]??"":"/";if(!M||M===`
9
- `||!K(M,!0))return null}else if(B==="#")X();else if(":btTv".includes(B)){while(Q()===" "||Q()==="\t")J++;while(J<Y&&!/[\s;]/.test(Q()))J++}else if("aic".includes(B)){while(Q()===" "||Q()==="\t")J++;if(Q()==="\\")J+=2;for(;J<Y&&Z[J]!==`
10
- `;J++)if(Z[J]==="\\")J++}else if(B==="e")$=!0,X();else if(B==="r"||B==="R")X();else if(B==="w"||B==="W")H();else if(B==="s"||B==="y"){let M=Z[J++]??"";if(!M||M===`
11
- `||M==="\\"||!K(M,B==="s")||!K(M,!1))return null;for(;B==="s"&&" \tgpiImMe0123456789w".includes(Q()||"_");J++){if(Q()==="e")$=!0;if(Q()==="w"){J++,H();break}}}}return{writes:z,executes:$}}var J4=new Set(["-exec","-execdir","-ok","-okdir"]),z4=new Set(["-exec","-execdir"]),Y4=new Set("0oprtx"),Q4=new Set("adEILnPsJRS"),X4=new Set("eil"),dZ={"--null":"flag","--open-tty":"flag","--interactive":"flag","--no-run-if-empty":"flag","--verbose":"flag","--exit":"flag","--show-limits":"flag","--help":"flag","--version":"flag","--arg-file":"value","--delimiter":"value","--max-args":"value","--max-procs":"value","--max-chars":"value","--process-slot-var":"value","--max-lines":"value","--eof":"optional","--replace":"optional"};function K4(Z){if(Object.hasOwn(dZ,Z))return dZ[Z];let z=Object.keys(dZ).filter(($)=>$.startsWith(Z));return z.length===1?dZ[z[0]]:null}function bZ(Z,z,$,J=0){while(z<Z.length){if($(z)){z++;continue}let Y=Z[z];if(Y==="--"){z++;break}if(!Y.startsWith("-")||Y==="-")break;if(Y.startsWith("--")){let H=Y.indexOf("="),K=K4(H<0?Y:Y.slice(0,H));if(K===null){if(J>=4)return[];return[...bZ(Z,z+1,$,J+1),...bZ(Z,z+2,$,J+1)]}z+=K==="value"&&H<0?2:1;continue}let Q=!1,X=!1;for(let H=1;H<Y.length;H++){let K=Y[H];if(Y4.has(K))continue;if(X4.has(K))break;if(Q4.has(K)){Q=H===Y.length-1;break}X=!0;break}if(X){if(J>=4)return[];return[...bZ(Z,z+1,$,J+1),...bZ(Z,z+2,$,J+1)]}z+=Q?2:1}while(z<Z.length&&$(z))z++;return z<Z.length?[z]:[]}function SZ(Z,z,$=()=>!1){if(z<0||z>=Z.length)return[];let J=F0(Z[z]);if(J==="xargs")return[...new Set(bZ(Z,z+1,$))].map((Q)=>({start:Q,end:Z.length}));if(J!=="find")return[];let Y=[];for(let Q=z+1;Q<Z.length;Q++){if($(Q)||!J4.has(Z[Q]))continue;let X=Q+1,H=X;for(;H<Z.length;H++){if($(H))continue;if(Z[H]===";")break;if(Z[H]==="+"&&H>X&&Z[H-1]==="{}"&&z4.has(Z[Q]))break}if(X<H)Y.push({start:X,end:H});Q=H}return Y}function fZ(Z,z,$){if(z<0||z>=Z.length)return null;let J=F0(Z[z]);if(J==="deno"){let Y=l3(Z,z,$);if(Y)return Y}if(Object.hasOwn(N0,J)||j2.test(J))return g3(J,Z,z,$);if(f3.has(J))return u3(Z,z,$);if(k3.has(J))return p3(Z,z,$);if(J==="rsync")return c3(Z,z,$);if(J==="git")return o3(Z,z,$);if(J==="sed")return e3(Z,z,$);return null}var B4=600000,M4="Delete via trash guard (rm intercepted and made recoverable)",V4=[".hasna/repos/clones","workspace/repos"],G4=[".hasna",".ssh",".aws"],_0={rmdir:"`rmdir` is a delete that trash-guard does not rewrite (it takes rmdir's flags, not rm's). Re-run it as `rm -d -- <path>` for an empty directory, or `rm -r -- <path>` for a non-empty one, and it is redirected into trash.",unlink:"`unlink` is a delete that trash-guard does not rewrite. Re-run it as `rm -- <path>` and it is redirected into trash.",shred:"`shred` destroys content irrecoverably and is never allowed. Re-run it as `rm -- <path>` and it is redirected into trash."},U4=new Set(["sh","bash","zsh","dash","ksh","ash","eval","source",".","su","runuser","env"]),j4={sudo:["-u","--user","-g","--group","-p","--prompt","-C","--chdir","-h","--host","-r","--role","-t","--type","-U","--other-user"],doas:["-u","-C"],env:["-u","--unset","-C","--chdir","-S","--split-string"],nice:["-n","--adjustment"],ionice:["-c","--class","-n","--classdata","-p","--pid"],stdbuf:["-i","-o","-e","--input","--output","--error"],time:["-f","--format","-o","--output"],timeout:["-s","--signal","-k","--kill-after"],nohup:[],setsid:[],command:[],builtin:[],exec:["-a"]},W4={timeout:1},N4={sudo:{short:{A:j,B:j,b:j,E:j,H:j,i:j,k:j,N:j,n:j,P:j,S:j,s:j,C:D,g:D,p:D,r:D,T:D,t:D,U:D,u:D,e:t,l:t,v:t,D:C,R:C,h:C,K:C,V:C},long:{askpass:j,bell:j,background:j,"close-from":D,chdir:C,"preserve-env":AZ,edit:t,group:D,"set-home":j,help:C,host:C,login:j,"remove-timestamp":C,"reset-timestamp":j,list:t,"no-update":j,"non-interactive":j,"preserve-groups":j,prompt:D,chroot:C,role:D,stdin:j,shell:j,type:D,"command-timeout":D,"other-user":D,user:D,version:C,validate:t},assignments:!0},doas:{short:{n:j,s:j,u:D,C,L:C},long:{}},flock:{short:{s:j,x:j,e:j,n:j,u:j,o:j,F:j,w:D,E:D,h:C,V:C},long:{shared:j,exclusive:j,unlock:j,nonblock:j,nonblocking:j,nb:j,timeout:D,wait:D,"conflict-exit-code":D,close:j,"no-fork":j,fcntl:j,verbose:j,help:C,version:C},positionals:[/^[\s\S]+$/]}},F4={...j0,...N4},C2=new Set(["-c","--command"]),_4=new Set(["busybox","toybox"]),T0=new Set(["rm","rmdir","unlink","shred"]),D4=new Set(["!","{","}","then","do","else","elif","if","while","until","for","case","esac","fi","done","select","function"]),I4=new Set(["-C","-c","--git-dir","--work-tree","--namespace","--exec-path","--config-env"]),T4=/(^|[^A-Za-z0-9_.-])(rm|rmdir|unlink|shred)(?![A-Za-z0-9_.-])/;function o(Z){return T4.test(b(Z))}function xZ(Z){return Z.map((z)=>z.replace(/^-[iv0]*S|^--split-string=/," ")).join(" ")}var P2=/^[A-Za-z_][A-Za-z0-9_]*=/;function nZ(Z){let z=Z.lastIndexOf("/");return z>=0?Z.slice(z+1):Z}var F2={a:"\x07",b:"\b",e:"\x1B",E:"\x1B",f:"\f",n:`
12
- `,r:"\r",t:"\t",v:"\v","\\":"\\","'":"'",'"':'"',"?":"?"};function q4(Z,z){let $="",J=z;while(J<Z.length&&Z[J]!=="'"){if(Z[J]!=="\\"||J+1>=Z.length){$+=Z[J++];continue}let Y=Z[J+1],Q=Z.slice(J+1),X;if(Object.hasOwn(F2,Y))$+=F2[Y],J+=2;else if(X=Q.match(/^[0-7]{1,3}/))$+=String.fromCharCode(parseInt(X[0],8)&255),J+=1+X[0].length;else if((X=Q.match(/^x([0-9A-Fa-f]{1,2})/))||(X=Q.match(/^u([0-9A-Fa-f]{1,4})/))||(X=Q.match(/^U([0-9A-Fa-f]{1,8})/))){let H=parseInt(X[1],16);$+=H<=1114111?String.fromCodePoint(H):"",J+=1+X[0].length}else if(Y==="c"&&J+2<Z.length)$+=String.fromCharCode(Z.charCodeAt(J+2)&31),J+=3;else $+=`\\${Y}`,J+=2}return{text:$,end:Math.min(J+1,Z.length)}}function E(Z){let z="",$=0;while($<Z.length){let J=Z[$];if(J==="$"&&Z[$+1]==="'"){let Y=q4(Z,$+2);z+=Y.text,$=Y.end;continue}if(J==="$"&&Z[$+1]==='"'){$++;continue}if(J==="\\"){if($+1<Z.length)z+=Z[$+1];$+=2;continue}if(J==="'"){let Y=Z.indexOf("'",$+1);if(Y===-1){z+=Z.slice($+1);break}z+=Z.slice($+1,Y),$=Y+1;continue}if(J==='"'){$++;while($<Z.length&&Z[$]!=='"'){if(Z[$]==="\\"&&$+1<Z.length){z+=Z[$+1],$+=2;continue}z+=Z[$],$++}$++;continue}z+=J,$++}return z}function aZ(Z){if(iZ(Z))return!0;let z=null;for(let $=0;$<Z.length;$++){let J=Z[$];if(z==="'"){if(J==="'")z=null;continue}if(J==="\\"){$++;continue}if(J==="`"||J==="$")return!0;if(J==='"'){z=z===null?'"':null;continue}if(z!==null)continue;if(J==="'")z="'";else if(J==="*"||J==="?")return!0;else if(J==="["&&C4(Z,$+1,"]"))return!0}return!1}function C4(Z,z,$){let J=null;for(let Y=z;Y<Z.length;Y++){let Q=Z[Y];if(J!=="'"&&Q==="\\")Y++;else if(J===null&&Q===$)return!0;else if(Q==="'"&&J!=='"')J=J==="'"?null:"'";else if(Q==='"'&&J!=="'")J=J==='"'?null:'"'}return!1}function P4(Z){if(!aZ(Z))return!1;let z=QZ(Z);return z===null||z.some(($)=>E($).split(/[^A-Za-z0-9_]+/).some((J)=>T0.has(J)))}function WZ(Z){return nZ(E(Z))}var O2={deep:!0};function q0(Z,z){return Z.replace(/\\([$`\\"])/g,($,J)=>J==='"'&&!z?$:J)}function O4(Z,z,$){let J=[],Y=z+1;while(Y<$-1){let Q=Z[Y];if(Q==="\\"){Y+=2;continue}if(Q==="`"){let X=hZ(Z,Y);if(X<0)return null;J.push(q0(Z.slice(Y+1,X-1),!0)),Y=X;continue}if(Q==="$"&&Z[Y+1]==="("){let X=KZ(Z,Y+1);if(X<0)return null;J.push(Z.slice(Y+2,X-1)),Y=X;continue}Y++}return J}function L4(Z){let z=[],$=0;while($<Z.length){let J=Z[$];if(J==="\\"){$+=2;continue}if(J==="`"){let Y=hZ(Z,$);if(Y<0)return null;z.push(q0(Z.slice($+1,Y-1),!1)),$=Y;continue}if(J==="$"&&Z[$+1]==="("){let Y=KZ(Z,$+1);if(Y<0)return null;z.push(Z.slice($+2,Y-1)),$=Y;continue}$++}return z}function _2(Z,z,$,J){let Y=z+1;for(let Q of $){let X=Math.min(Y,Z.length);for(;;){if(Y>Z.length){Y=Z.length+1;break}let K=Z.indexOf(`
13
- `,Y),B=K===-1?Z.length:K,M=Z.slice(Y,B).replace(/\r$/,"");if(Q.stripTabs)M=M.replace(/^\t+/,"");if(M===Q.delimiter)break;Y=B+1}let H=Z.slice(X,Math.min(Y,Z.length));if(Q.owner.push(H),!Q.quoted){let K=L4(H);if(!K)return-1;J.push(...K)}if(Y<=Z.length){let K=Z.indexOf(`
14
- `,Y);Y=(K===-1?Z.length:K)+1}}return Math.min(Y-1,Z.length)}function L2(Z,z){let $=Z.indexOf("'",z+1);return $===-1?-1:$+1}function hZ(Z,z){let $=z+1;while($<Z.length){if(Z[$]==="\\"){$+=2;continue}if(Z[$]==="`")return $+1;$++}return-1}function y2(Z,z){let $=z+1;while($<Z.length){let J=Z[$];if(J==="\\"){$+=2;continue}if(J==='"')return $+1;if(J==="`"){let Y=hZ(Z,$);if(Y<0)return-1;$=Y;continue}if(J==="$"&&Z[$+1]==="("){let Y=KZ(Z,$+1);if(Y<0)return-1;$=Y;continue}$++}return-1}function FZ(Z,z){if(Z[z]!=="<"||Z[z+1]!=="<"||Z[z+2]==="<")return null;let $=z+2,J=Z[$]==="-";if(J)$++;while(Z[$]===" "||Z[$]==="\t")$++;let Y="",Q=!1;while($<Z.length&&!/[\s;|&<>()]/.test(Z[$])){let X=Z[$];if(X==="'"||X==='"'){let H=Z.indexOf(X,$+1);if(H<0)return null;Y+=Z.slice($+1,H),Q=!0,$=H+1;continue}if(X==="\\"){if($+1>=Z.length)return null;Y+=Z[$+1],Q=!0,$+=2;continue}Y+=X,$++}return Y?{delimiter:Y,stripTabs:J,quoted:Q,end:$}:null}function oZ(Z,z,$){let J=z+1;for(let Y of $)for(;;){if(J>Z.length)return-1;let Q=Z.indexOf(`
15
- `,J),X=Q===-1?Z.length:Q,H=Z.slice(J,X);if(H.endsWith("\r"))H=H.slice(0,-1);let K=Y.stripTabs?H.length-H.replace(/^\t+/,"").length:0;if(Y.stripTabs)H=H.slice(K);if(H===Y.delimiter){J=X+1;break}if(H.startsWith(Y.delimiter)&&/^\s*\)/.test(H.slice(Y.delimiter.length))){if(Y===$[$.length-1])return J+K+Y.delimiter.length;return-1}if(Q===-1)return-1;J=Q+1}return J-1}function KZ(Z,z){let $=Z.length,J=Z[z+1]==="(",Y=0,Q=z,X=[];while(Q<$){let H=Z[Q];if(H==="\\"){Q+=2;continue}if(H==="'"){let K=L2(Z,Q);if(K<0)return-1;Q=K;continue}if(H==='"'){let K=y2(Z,Q);if(K<0)return-1;Q=K;continue}if(H==="`"){let K=hZ(Z,Q);if(K<0)return-1;Q=K;continue}if(!J&&H==="<"&&Z[Q+1]==="<"){if(Z[Q+2]==="<"){Q+=3;continue}let K=FZ(Z,Q);if(!K)return-1;X.push(K),Q=K.end;continue}if(H===`
16
- `&&X.length>0){let K=oZ(Z,Q,X);if(K<0)return-1;X=[],Q=K;continue}if(!J&&H==="#"&&/[\s;&|(]/.test(Z[Q-1])){let K=Z.indexOf(`
17
- `,Q);if(K<0)return-1;Q=K;continue}if(H==="(")Y++;else if(H===")"){if(Y--,Y===0)return X.length>0?-1:Q+1}Q++}return-1}function S(Z,z={}){let $=z.deep===!0,J=[],Y=[],Q=[],X=new Set,H=[],K=[],B=-1,M=!1,V=!0,G=0,U=Z.length,W=(q)=>{if(B>=0){let F=Q.length;if(Q.push({text:Z.slice(B,q),start:B,end:q}),M)X.add(F);B=-1,M=!1}},N=(q)=>{if(W(q),Q.length>0)J.push($?{words:Q,redirects:X,heredocs:H}:{words:Q,redirects:X});if(Q=[],X=new Set,$)H=[];M=!1},R=(q)=>L2(Z,q),f=(q)=>hZ(Z,q),k=(q)=>KZ(Z,q),i=(q)=>y2(Z,q);while(G<U){let q=Z[G];if(q===" "||q==="\t"||q==="\r"){W(G),G++;continue}if(q===`
18
- `){if(N(G),K.length>0){let F=_2(Z,G,K,Y);if(K=[],F<0)V=!1,G=U;else G=F;continue}G++;continue}if(q===";"){N(G),G++;continue}if(q==="&"){N(G),G+=Z[G+1]==="&"?2:1;continue}if(q==="|"){N(G),G+=Z[G+1]==="|"?2:1;continue}if($&&q==="("&&B>=0&&"?*+@!".includes(Z[G-1])){V=!1,G=U;continue}if(q==="("||q===")"){N(G),G++;continue}if(q==="<"&&Z[G+1]==="<"&&Z[G+2]!=="<"){let F=Z.slice(G+2).match(/^-?[ \t]*(['"]?)([A-Za-z_][A-Za-z0-9_]*)\1/);if(!F){V=!1,G=U;continue}if($){let IZ=G+2+F[0].length;if(IZ<U&&!/[\s;&|()<>]/.test(Z[IZ])){V=!1,G=U;continue}W(G),K.push({delimiter:F[2],quoted:F[1]!=="",stripTabs:F[0].startsWith("-"),owner:H}),G=IZ;continue}let A=Z.indexOf(`
19
- `,G+2+F[0].length);if(A===-1){V=!1,G=U;continue}let m=Z.slice(A+1),p=y4(m,F[2]);if(p===-1){V=!1,G=U;continue}W(G),G=A+1+p+F[2].length;continue}if(q===">"||q==="<"){if(B>=0&&/^\d+$/.test(Z.slice(B,G)))B=-1;if(W(G),M=!0,G++,Z[G]===q||Z[G]==="&"||q===">"&&Z[G]==="|"||q==="<"&&Z[G]===">")G++;continue}if(q==="'"){if(B<0)B=G;let F=R(G);if(F<0)V=!1,G=U;else G=F;continue}if(q==='"'){if(B<0)B=G;let F=i(G),A=F<0||!$?[]:O4(Z,G,F);if(F<0||!A)V=!1,G=U;else Y.push(...A),G=F;continue}if(q==="`"){if(B<0)B=G;let F=f(G);if(F<0)V=!1,G=U;else{let A=Z.slice(G+1,F-1);Y.push($?q0(A,!1):A),G=F}continue}if(q==="$"&&Z[G+1]==="("){if(B<0)B=G;let F=k(G+1);if(F<0)V=!1,G=U;else Y.push(Z.slice(G+2,F-1)),G=F;continue}if(q==="\\"){if(B<0)B=G;if(G+1>=U)V=!1,G=U;else G+=2;continue}if(B<0)B=G;G++}if(N(U),K.length>0&&_2(Z,U,K,Y)<0)V=!1;return{segments:J,trustworthy:V,substitutions:Y}}function y4(Z,z){let $=0;while($<=Z.length){let J=Z.indexOf(z,$);if(J===-1)return-1;let Y=J===0||Z[J-1]===`
20
- `,Q=J+z.length,X=Q===Z.length||Z[Q]===`
21
- `||Z[Q]==="\r";if(Y&&X)return J;$=J+1}return-1}function b(Z){let z="",$=0;while($<Z.length){let J=Z[$];if(J==="\\"){if($+1<Z.length)z+=Z[$+1];$+=2;continue}if(J==="'"){let Y=Z.indexOf("'",$+1);if(Y===-1){z+=Z.slice($+1);break}z+=Z.slice($+1,Y),$=Y+1;continue}if(J==='"'){$++;while($<Z.length&&Z[$]!=='"'){if(Z[$]==="\\"&&$+1<Z.length){z+=Z[$+1],$+=2;continue}z+=Z[$],$++}$++;continue}z+=J,$++}return z}function u(Z){let z=0,$=0;while(z<Z.words.length&&$++<32){if(Z.redirects.has(z)){z++;continue}let J=Z.words[z].text,Y=E(J);if(P2.test(Y)&&!Y.startsWith("-")){z++;continue}if(D4.has(Y)){z++;continue}let Q=nZ(Y);if(Q==="command")for(let H of Z.words.filter((K,B)=>B>z&&!Z.redirects.has(B))){let K=E(H.text);if(K==="--"||!K.startsWith("-"))break;if(/^-[pvV]*[vV][pvV]*$/.test(K))return-1}let X=j4[Q];if(X){let H=z;z++;while(z<Z.words.length){if(Z.redirects.has(z)){z++;continue}let B=E(Z.words[z].text);if(!B.startsWith("-")||B==="-")break;if(B==="--"){z++;break}if(Q==="env"&&(/^-[iv0]*S/.test(B)||/^--split-string(?:=|$)/.test(B)))return H;if(z++,X.includes(B)||Q==="exec"&&/^-[cl]*a$/.test(B)){while(Z.redirects.has(z))z++;z++}}let K=W4[Q]??0;while(K>0&&z<Z.words.length){let B=E(Z.words[z].text);if(B.startsWith("-")&&B!=="-")break;z++,K--}continue}return z}return-1}function A4(Z,z){let $=[],J=!1;for(let Y=z+1;Y<Z.words.length;Y++){if(Z.redirects.has(Y))continue;let Q=b(Z.words[Y].text);if(!J){if(Q==="--"){J=!0;continue}if(Q.startsWith("-")&&Q!=="-")continue}$.push(Z.words[Y])}return $}function C0(Z){return V4.map((z)=>x.join(Z,...z.split("/")))}function R4(Z,z){if(Z==="~"||Z==="$HOME"||Z==="${HOME}")return z;if(Z.startsWith("~/"))return x.join(z,Z.slice(2));if(Z.startsWith("$HOME/"))return x.join(z,Z.slice(6));if(Z.startsWith("${HOME}/"))return x.join(z,Z.slice(8));return Z}function sZ(Z,z,$){let J=b(Z);if(!J)return null;if(J.includes("`"))return null;if(J==="$HOME"||J==="${HOME}"||J==="$HOME/"||J==="${HOME}/")return $;if(J.replace(/\$\{HOME\}/g,"").replace(/\$HOME/g,"").includes("$"))return null;if(/[*?[\]]/.test(J))return null;if(J.startsWith("~")){let H=R4(J,$);if(H===J)return null;J=H}let X=(x.isAbsolute(J)?x.normalize(J):x.resolve(z,J)).replace(/\/+$/,"");return X===""?"/":X}function $Z(Z,z){return Z===z||Z.startsWith(`${z}${x.sep}`)}function v4(Z,z){let $=`${x.join(z,".hasna","scratchpad","scratch")}${x.sep}`;if(!Z.startsWith($))return!1;let[J,Y]=Z.slice($.length).split(x.sep);if(!J||!/^[a-z0-9][a-z0-9._-]{0,63}$/.test(J)||J.endsWith(".")||!Y)return!1;let Q=Y.normalize("NFKC").toLowerCase();return Q!=="meta.json"&&Q!==".lock"}function b4(Z,z){if(Z===z)return`\`${Z}\` is the home directory itself, which is never deleted or trashed. Delete a specific file or directory inside it instead.`;for(let $ of B2){if(Z!==$&&!$Z($,Z))continue;return $==="/"?`\`${Z}\` is the filesystem root, which is never deleted.`:`\`${Z}\` is the system root \`${$}\` (or an ancestor of it), which is never deleted or trashed.`}for(let $ of G4){let J=x.join(z,$);if($===".hasna"&&v4(Z,z))continue;if(!$Z(Z,J)&&!$Z(J,Z))continue;return`\`${Z}\` is the protected \`~/${$}\` path (or contains it), which is never deleted or trashed. Delete a specific file inside it, and only when you are sure.`}return null}function E4(Z,z,$){let J=C0($);if(J.some((Y)=>$Z(z,Y)))return!0;return Z.some((Y)=>Y!==null&&J.some((Q)=>$Z(Y,Q)))}var D2=new WeakMap;function S4(Z){let z=D2.get(Z);if(z)return z;let $=Z.words.map((X)=>E(X.text)),J=$.findIndex((X)=>X==="-exec"||X==="-execdir"||X==="-ok"||X==="-okdir"),Y=-1;Z.words.forEach((X,H)=>{if(C2.has(b(X.text)))Y=H});let Q={findDelete:$.includes("-delete"),findExecDelete:J>=0&&$.slice(J).some((X)=>T0.has(nZ(X))),namesDelete:$.some((X)=>T0.has(nZ(X))),lastFlockCommand:Y,textMention:o(u4(Z)),envMention:o(xZ(Z.words.map((X)=>b(X.text)))),bodiesMention:o((Z.heredocs??[]).join(`
22
- `))};return D2.set(Z,Q),Q}var f4=new Set(["sh","bash","zsh","dash","ksh","ash","mksh"]);function k4(Z,z){if(!f4.has(WZ(Z.words[z].text)))return!1;for(let $=z+1;$<Z.words.length;$++){if(Z.redirects.has($))continue;let J=b(Z.words[$].text);if(J==="--")return $+1>=Z.words.length;if(/^-[A-Za-z]*s/.test(J))return!0;if(/^-[A-Za-z]*c/.test(J))return!1;if(J==="-o"||J==="+o"||J==="-O"||J==="+O"){$++;continue}if(!/^[-+]/.test(J)||J==="-")return J==="-"}return!0}var D0=(Z)=>Z.kind==="rm"||Z.kind==="refuse",x4="This command's command word or wrapper arguments cannot be read before it runs (an expansion such as a variable, substitution, brace or glob pattern, an unknown or unsupported option, a working directory or a non-decimal duration), so this hook cannot tell which word runs, and one of its words could run a delete. Run the delete as a plain `rm -- <path>` command, which is redirected into trash.",h4="This delete's brace pattern names more paths than this hook will check. Run the delete on explicit paths with `rm -- <path> …`, which is redirected into trash.",w4="This delete's brace pattern expands to a path under a protected repository checkout. Deletes there are refused; run them through the owning workflow, and write any other delete out as plain paths.",g4="This command's wrapper arguments can be read as running two different deletes, so no single rewrite is safe. Run the delete as a plain `rm -- <path>` command, which is redirected into trash.";function P0(Z){let z=[];Z.words.forEach((Y,Q)=>{if(!Z.redirects.has(Q))z.push(Q)});let $=z.map((Y)=>{let Q=Z.words[Y].text;return{text:E(Q),opaque:aZ(Q)}}),J=XZ($,F4);if(J===null)return null;return J.index<0?-1:z[J.index]}function I0(Z,z,$,J){let Y=WZ(Z.words[z].text);if(Y==="cd"){let K=Z.words[z+1];if(!K)return{kind:"none"};return{kind:"cd",cwd:sZ(K.text,$,J.home)??J.cwd}}if(Object.hasOwn(_0,Y))return{kind:"refuse",reason:_0[Y]};let Q=A2(Z,z,$,J);if(Q)return Q;if(Y==="rm"){let K=A4(Z,z);if(K.length===0)return{kind:"none"};let B={word:Z.words[z],operands:K},M=C0(J.home),V=(W)=>W!==null&&M.some((N)=>$Z(W,N)),G=[],U=[];for(let W of K){let N=sZ(W.text,$,J.home);if(G.push(N),!W.text.includes("{"))continue;let R=QZ(W.text);if(R===null)return{kind:"refuse",reason:h4};for(let f of R){let k=sZ(f,$,J.home);if(k===null)continue;if(V(k)&&!V(N))return{kind:"refuse",reason:w4};U.push(k)}}if(E4(G,$,J.home))return B.cwdOnly=G.every((W)=>W!==null&&!V(W)),{kind:"rm",hit:B,handoff:!0,protectedReason:null};for(let W of[...G,...U]){if(!W)continue;let N=b4(W,J.home);if(N)return{kind:"rm",hit:B,handoff:!1,protectedReason:N}}return{kind:"rm",hit:B,handoff:!1,protectedReason:null}}if(_4.has(Y)){let K=Z.words.findIndex((M,V)=>V>z&&!b(M.text).startsWith("-")),B=K>=0?WZ(Z.words[K].text):"";if(B==="rm"||Object.hasOwn(_0,B))return{kind:"refuse",reason:`\`${Y} ${B}\` runs the ${Y} applet, whose own \`rm\` is not GNU \`rm\` and cannot be rewritten in place. Run the delete as \`rm -- <path>\`, which is redirected into trash.`};return{kind:"none"}}if(Y==="git"){let K=O0(Z,z);if(K==="rm"||K==="clean"){if(!(K==="rm"?m4(Z,z):R2(Z,z)))return{kind:"refuse",reason:K==="rm"?"`git rm` is refused: without `--cached` it deletes the working-tree file, and its semantics are not `rm`'s. Use `rm -- <path>` (intercepted and redirected into trash) to remove the file, or `git rm --cached -- <path>` to unstage it without deleting.":"`git clean` deletes untracked files irrecoverably and is refused. Remove them explicitly with `rm -- <path>` (intercepted and redirected into trash), or preview with `git clean -n`."}}return{kind:"none"}}let X=S4(Z);if(Y==="find"){if(X.findDelete)return{kind:"refuse",reason:"`find -delete` deletes files irrecoverably and is refused. List the paths first (`find … -print`), then remove them explicitly with `rm -- <path>` so the delete is redirected into trash."};if(X.findExecDelete)return{kind:"refuse",reason:"`find -exec <delete>` is refused: the delete runs through find, not through `rm`, and cannot be redirected into trash. Remove the paths explicitly with `rm -- <path>`."};return{kind:"none"}}if(Y==="xargs"&&X.namesDelete)return{kind:"refuse",reason:"`xargs rm` takes its targets from stdin, so this hook cannot verify what would be deleted. Pipe the paths into an explicit `rm -- <path> …` instead, which is redirected into trash."};let H=Y==="flock"?X.lastFlockCommand>z:C2.has(Y);if(U4.has(Y)||H){let K=k4(Z,z)?J.bodiesMention:X.bodiesMention;if((Y==="env"?X.envMention:X.textMention)||K)return{kind:"refuse",reason:`\`${H?"flock":Y}\` runs a command string this hook cannot rewrite in place. Run the delete directly as \`rm -- <path>\` (intercepted and redirected into trash), or as a script that uses \`trash guard\` itself.`}}return{kind:"none"}}function A2(Z,z,$,J,Y={segment:Z,index:z},Q=0){let X=WZ(Z.words[z].text);for(let V of SZ(Z.words.map((G)=>E(G.text)),z,(G)=>Z.redirects.has(G))){if(Q>=8)return kZ(Y.segment,Y.index,$,J.home)?{kind:"refuse",reason:l4}:null;let G={words:Z.words.slice(V.start,V.end),redirects:new Set([...Z.redirects].filter((W)=>W>=V.start&&W<V.end).map((W)=>W-V.start))},U=P0(G);for(let W of new Set([u(G),U??-1])){if(W<0)continue;let N=A2(G,W,$,J,Y,Q+1);if(N)return N}}let H=Z.words.map((V,G)=>({word:V,at:G})).filter(({at:V})=>!Z.redirects.has(V)),K=H.findIndex(({at:V})=>V===z),B=K<0?null:EZ(H.map(({word:V})=>V.text),K,E);if(B&&!B.literal&&(kZ(Z,z,$,J.home)||kZ(Y.segment,Y.index,$,J.home)))return{kind:"refuse",reason:`\`${X}\` runs a shell program that is not a plain literal (an expansion, a substitution, ANSI-C \`$'…'\` quoting or several words), so this hook cannot read what it would delete under a protected repository checkout. Write the program out literally, or run it from outside the checkout.`};let M=fZ(Z.words.map((V)=>E(V.text)),z,(V)=>V>=0&&V<Z.words.length&&(Z.redirects.has(V)||aZ(Z.words[V].text)));if(!M||!(kZ(Z,z,$,J.home)||kZ(Y.segment,Y.index,$,J.home)))return null;if(!M.unresolved&&!M.programs.some((V)=>o(V.text)))return null;return{kind:"refuse",reason:`\`${X}\` runs a program locally (an interpreter's inline program or a command-running option) this hook cannot rewrite, and it could delete a file under a protected repository checkout. Run the delete directly as \`rm -- <path>\` (intercepted and redirected into trash), or run the command from outside the checkout.`}}var l4="This command nests find/xargs launchers too deeply for this hook to read what they run under a protected repository checkout. Run the inner command directly.";function kZ(Z,z,$,J){let Y=C0(J),Q=(X)=>X!==null&&Y.some((H)=>$Z(X,H));if(Y.some((X)=>$Z($,X)))return!0;for(let X=z+1;X<Z.words.length;X++){if(Z.redirects.has(X))continue;if(Q(sZ(Z.words[X].text,$,J)))return!0}return!1}function NZ(Z,z){let $={rmHits:[],handoffHits:[],refusals:[],protectedHits:[],trustworthy:!0},J=S(Z,O2);$.trustworthy=J.trustworthy;let Y={cwd:z.cwd,home:z.home,depth:z.depth??0,bodiesMention:o(J.segments.flatMap((K)=>K.heredocs??[]).join(`
23
- `))};if(!J.trustworthy){let K=jZ(Z);return K===Z?$:{...NZ(K,z),trustworthy:!1}}let Q=[],X=(K,B=$.refusals)=>{if(K.kind==="refuse")B.push({reason:K.reason});else if(K.kind==="rm"&&K.handoff)$.handoffHits.push(K.hit);else if(K.kind==="rm"){if($.rmHits.push(K.hit),K.protectedReason)$.protectedHits.push({reason:K.protectedReason})}},H=Y.cwd;for(let K of J.segments){let B=u(K),M=P0(K),V=B<0?{kind:"none"}:I0(K,B,H,Y);if(V.kind!=="cd")X(V);let G=(U)=>U!==null&&U>=0&&aZ(K.words[U].text);if(M===null||G(B)||G(M)){if(K.words.some((U,W)=>!K.redirects.has(W)&&(D0(I0(K,W,H,Y))||P4(U.text))))Q.push({reason:x4})}else if(M>=0&&M!==B){let U=I0(K,M,H,Y);if(D0(U))if(D0(V))Q.push({reason:g4});else X(U,Q)}if(V.kind==="cd")H=V.cwd}if(Y.depth<3)for(let K of J.substitutions){let B=NZ(K,{cwd:H,home:Y.home,depth:Y.depth+1});if(B.rmHits.length>0||B.refusals.length>0||B.handoffHits.length>0||B.protectedHits.length>0||!B.trustworthy&&o(K)){$.refusals.push({reason:"This command runs a delete inside a command substitution `$(…)`, which this hook cannot rewrite. Run the delete as a separate `rm -- <path>` command, which is redirected into trash."});break}}else if(J.substitutions.some((K)=>o(K)))$.refusals.push({reason:"This command nests a delete inside command substitutions deeper than this hook will follow. Run the delete as a separate `rm -- <path>` command."});return $.refusals.push(...Q),$}function u4(Z){return Z.words.map((z)=>z.text).join(" ")}function O0(Z,z){let $=z+1;while($<Z.words.length){let J=b(Z.words[$].text);if(!J.startsWith("-"))return J;if($++,I4.has(J))$++}return null}function m4(Z,z){if(Z.words.slice(z+1).map((J)=>b(J.text)).includes("--cached"))return!0;return R2(Z,z)}function R2(Z,z){let $=Z.words.slice(z+1).map((J)=>b(J.text));return $.includes("-n")||$.includes("--dry-run")}function I2(Z){if(/^[A-Za-z0-9_\-./+=:,@%^]+$/.test(Z))return Z;return`'${Z.replace(/'/g,"'\\''")}'`}function p4(Z,z,$,J){let Y=J?["/usr/bin/env","-i",`HOME=${J.home}`,`PATH=${J.path}`,`HASNA_TRASH_AGENT=${J.agent}`,J.runtime,"--config=/dev/null","--no-env-file","--no-macros","--no-install",$,"guard"].map(I2).join(" "):`${I2($)} guard`,Q=[...z].sort((H,K)=>K.word.start-H.word.start),X=Z;for(let H of Q)X=`${X.slice(0,H.word.start)}${Y}${X.slice(H.word.end)}`;return X}function c4(Z,z,$,J,Y){if(!z||z===Z)return!1;if($.length===0)return!1;let Q=NZ(z,{cwd:J,home:Y});if(!Q.trustworthy)return!1;if(Q.rmHits.length>0||Q.handoffHits.length>0)return!1;return Q.refusals.length===0}function i4(Z,z){let $={};for(let[J,Y]of Object.entries(Z??{}))$[J]=Y;if($.command=z,typeof $.description!=="string"||$.description.trim()==="")$.description=M4;if(typeof $.timeout!=="number"||!Number.isFinite($.timeout)||$.timeout<=0)$.timeout=B4;if(typeof $.run_in_background!=="boolean")$.run_in_background=!1;if("dangerouslyDisableSandbox"in $&&typeof $.dangerouslyDisableSandbox!=="boolean")delete $.dangerouslyDisableSandbox;return $}function d4(Z,z,$,J,Y){if(typeof Z.command!=="string"||Z.command.trim()==="")return!1;if(typeof Z.description!=="string"||Z.description.trim()==="")return!1;if(typeof Z.timeout!=="number"||!Number.isFinite(Z.timeout)||Z.timeout<=0)return!1;if(typeof Z.run_in_background!=="boolean")return!1;if("dangerouslyDisableSandbox"in Z&&typeof Z.dangerouslyDisableSandbox!=="boolean")return!1;return c4(z,Z.command,$,J,Y)}function s4(Z){let z=new Set(["export","set","unset","readonly","declare","typeset","local","alias","unalias","read","readarray","mapfile","getopts","trap","enable","function","env","sudo","doas","stdbuf"]);return S(Z,O2).segments.some((J)=>{let Y=P0(J);return[u(J),...Y===null?[]:[Y]].some((Q)=>{if(J.words.slice(0,Q<0?J.words.length:Q).some((K)=>P2.test(b(K.text))||z.has(WZ(K.text))))return!0;if(Q<0)return!1;let H=J.words[Q];return z.has(WZ(H.text))||/^\s*\(\s*\)\s*\{/.test(Z.slice(H.end))})})}function d(Z){return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:Z}}}function n4(Z){return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"allow",updatedInput:Z}}}function a4(Z){try{if(Z.inspectTrash){let z=Z.inspectTrash();return z.ok?{path:z.path,error:null}:{path:null,error:`${z.code}: ${H2[z.code]}`}}return{path:Z.findTrash(),error:null}}catch(z){return{path:null,error:z instanceof Error?z.message:String(z)}}}var o4="[trash-guard] No verified @hasna/trash guard was found on PATH. This deletion is refused. Install the current @hasna/trash package with Bun and run its setup; the operating-system trash utility is not a compatible guard.";function v2(Z,z){if(Z.hook_event_name!=="PreToolUse")return{continue:!0};if(["apply_patch","ApplyPatch","functions.apply_patch"].includes(Z.tool_name??"")){let B=Z.tool_input?.command;if(typeof B!=="string")return d("[trash-guard] Unreadable patch input; deletion safety cannot be checked.");if(/^\s*\*\*\* Delete File:/m.test(B))return d("[trash-guard] Delete File would bypass recoverable deletion. First use `trash put -- <path>` or the trash_put MCP tool, then submit any remaining edits without the deletion block.");return{continue:!0}}if(Z.tool_name!=="Bash")return{continue:!0};if(typeof Z.tool_input?.command!=="string")return d("[trash-guard] The Bash tool call carried no readable `command`, so this hook cannot verify what would run. Refusing a call it cannot verify. Re-run the delete explicitly as `rm -- <path>` so it can be redirected into trash.");let J=UZ(Z);if(!J.trim())return{continue:!0};let Y=NZ(J,{cwd:z.cwd,home:z.home});if(Y.refusals.length>0)return d(`[trash-guard] ${Y.refusals[0].reason}`);if(Y.protectedHits.length>0)return d(`[trash-guard] ${Y.protectedHits[0].reason}`);if(!Y.trustworthy)return o(J)?d("[trash-guard] This command could not be parsed to the end (unterminated quote, substitution or here-document), so a delete inside it cannot be redirected. Re-run the delete as a plain `rm -- <path>` command."):{continue:!0};if(Y.rmHits.length===0){if(Y.handoffHits.some((B)=>B.cwdOnly))return d("[trash-guard] This delete runs from inside a protected repository checkout but names only paths outside it. Run it from outside the checkout (`cd /tmp && rm -- <path>`), where it is redirected into trash.");if(Y.handoffHits.length>0)return{continue:!0};return{continue:!0}}if(Y.handoffHits.length>0)return d("[trash-guard] This command mixes a delete under the protected repo-checkout roots (owned by workspace-repos-guard) with a delete outside them, and a partial rewrite would leave one of them unredirected. Re-run them as separate commands, so each delete is handled by the hook that owns it.");let Q=a4(z);if(Q.error!==null)return d(`[trash-guard] The guard could not resolve the \`trash\` binary (${Q.error}), so this \`rm\` cannot be redirected into a recoverable delete — and an unrecoverable delete is never allowed, so the command is refused rather than run. Fix the environment (PATH, permissions) and re-run the same command.`);if(Q.path===null)return d(o4);let X=Q.path;if(z.execution&&s4(J))return d("[trash-guard] A deletion combined with shell environment changes cannot use the verified native execution context. Run the deletion as a separate plain rm command.");let H=p4(J,Y.rmHits,X,z.execution),K=i4(Z.tool_input,H);if(z.execution)K.hasna_execution="hasna.hooks.execution.v1";if(!d4(K,J,Y.rmHits,z.cwd,z.home))return d("[trash-guard] The rewrite of this command did not verify (the delete could not be redirected cleanly), so the command is refused rather than run unredirected. Re-run the delete as a plain `rm -- <path>` command.");return n4(K)}var h=require("node:fs"),E0=require("node:os"),O=require("node:path");var r4=new Set(["Write","Edit","MultiEdit","NotebookEdit"]),t4=new Set(["apply_patch","ApplyPatch","functions.apply_patch"]),e4=["hasna","hasnaxyz","hasna-products"],wZ="workspace-repos-guard";function Z5(Z){return O.join(Z,".hasna","repos","clones")}function $5(Z){return O.join(Z,"workspace","repos")}function l2(Z){return[Z5(Z),$5(Z)]}function J5(Z){return O.join(Z,".hasna","hooks","config","workspace-repos-guard-orgs")}var z5=/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/;function L0(Z){let z=process.getuid?.();return z!==void 0&&(Z.uid===0||Z.uid===z)&&(Z.mode&18)===0}function Y5(Z){let z=J5(Z),$;try{let Y=h.openSync(z,h.constants.O_RDONLY|h.constants.O_NOFOLLOW);try{let X=h.fstatSync(Y);if(!X.isFile()||!L0(X)||X.size>4096)return null;$=h.readFileSync(Y,"utf8")}finally{h.closeSync(Y)}let Q=O.normalize(Z);for(let X=O.dirname(z);X!==Q;X=O.dirname(X)){let H=h.lstatSync(X);if(!H.isDirectory()||!L0(H)||X===O.dirname(X))return null}if(!L0(h.statSync(Q)))return null}catch{return null}let J=$.replace(/#[^\n]*/g,"").split(/[\s,]+/).filter(Boolean);return J.length>0&&J.every((Y)=>z5.test(Y))?new Set(J):null}function Q5(Z=process.env,z=E0.homedir()){let $=Z.WORKSPACE_REPOS_GUARD_ORGS;if(typeof $==="string"&&$.trim())return new Set($.split(",").map((J)=>J.trim()).filter(Boolean));return Y5(z)??new Set(e4)}function y0(Z,z,$,J){if(J==="read")return{blocked:!1};let Y=O.relative(z,Z);if(Y===""){if(J==="delete")return{blocked:!0,reason:`[${wZ}] delete of the protected repo-checkout root is forbidden: ${z}`};return{blocked:!0,reason:`[${wZ}] writes directly to the protected repo-checkout root are forbidden: ${z}`}}if(Y.startsWith(`..${O.sep}`)||Y===".."||O.isAbsolute(Y))return{blocked:!1};let Q=Y.split(O.sep).filter(Boolean);if(J==="delete")return{blocked:!0,reason:`[${wZ}] delete under the protected repo-checkout root (${z}) is forbidden at any depth: ${Z}`};if(Q.length<=1)return{blocked:!0,reason:`[${wZ}] writing would create a top-level entry directly under the protected repo-checkout root (${z}); only GitHub-org folders belong there: ${Z}`};let X=Q[0];if(!$.has(X))return{blocked:!0,reason:`[${wZ}] '${X}' is not an allowed GitHub org under the protected repo-checkout root (${z}); allowed: ${[...$].join(", ")}: ${Z}`};return{blocked:!1}}var u2=/\b(?:-o|--output|-O|--output-document|-out)\b/,X5=/\d*[<>]&\s*(?:\d+|-)(?=$|[\s;&|)])/g,K5=/(?:\d+|&)?(?:>>|>\||>&|<>|>)\s*([^\s;&|<>()\x60]*)/g;function m2(Z){return Z.replace(X5," ")}function H5(Z){let z=[],$=null,J=0,Y=0,Q=!1,X=0;for(let H=0;H<Z.length;H++){let K=Z[H];if($==="'"){if(K==="'")$=null;continue}if(K==="\\"){H++;continue}if(K==="("){J++;continue}if(K===")"){if(--J<0)return[Z];continue}if(K==="$"&&Z[H+1]==="{"){Y++,H++;continue}if(K==="}"&&Y>0){Y--;continue}if(K==="`"){Q=!Q;continue}if($==='"'){if(K==='"')$=null;continue}if(K==="'"||K==='"'){$=K;continue}if(K!=="|"||J>0||Y>0||Q||Z[H-1]===">")continue;if(z.push(Z.slice(X,H)),Z[H+1]==="&")H++;X=H+1}if($||J!==0||Y!==0||Q)return[Z];return z.push(Z.slice(X)),z}function B5(Z){let z=[],$="",J="",Y=null,Q=!1,X=()=>{if(!Q)return;let H=J.replace(/^"?\$\{?HOME\}?"?(?=\/|$)/,""),K=$.startsWith("~")&&!/^~(?:\/|$)/.test(J);z.push({text:K?`./${$}`:$,opaque:/[$\x60*?[]/.test(H)||/[()]/.test(H)||iZ(J)}),$="",J="",Q=!1};for(let H=0;H<Z.length;H++){let K=Z[H];if(Y==="'"){if(K==="'")Y=null;else $+=K;J+=K;continue}if(K==="\\"&&H+1<Z.length){let B=Z[H+1];$+=Y==='"'&&!/[$\x60"\\\n]/.test(B)?K+B:B,J+=K+B,Q=!0,H++;continue}if(Y==='"'){if(K==='"')Y=null;else $+=K;J+=K;continue}if(/\s/.test(K)){X();continue}if(Q=!0,J+=K,K==="'"||K==='"')Y=K;else $+=K}if(Y)J+="$";return X(),z}function A0(Z,z,$){let J=Z[z];return J==="--help"||J==="--version"||$&&(J==="-h"||J==="-V")}var b2={read:0,write:1,delete:2};function rZ(...Z){return Z.reduce((z,$)=>b2[$]>b2[z]?$:z,"read")}var M5=new Set(["status","doctor","list","info","get","pending","station","setup","backup","storage","retrieval","backup-storage","backup-inspect","backup-refresh","help"]),p2=new Set(["put","rm","delete","remove"]),V5=new Set([...p2,"restore","restore-capsule","recover","release","locks","retention","hold","unhold","pin","unpin","retrieve","backup-retrieve"]),c2=new Set(["-delete","-exec","-execdir","-ok","-okdir","-fls","-fprint","-fprint0","-fprintf"]);function S0(Z){let z=null;for(let $=0;$<Z.length;$++){let J=Z[$];if(z==="'"){if(J==="'")z=null;continue}if(J==="\\"){$++;continue}if(J==="$"||J==="`")return!0;if(z==='"'){if(J==='"')z=null;continue}if(J==="'"||J==='"')z=J;else if("*?[{".includes(J))return!0}return z!==null}function f0(Z){let z=Z.trim();if(!z)return"read";if(eZ(z))return"delete";let $=S(z);if(!$.trustworthy||$.substitutions.length||/\$\{[^}]*[|;()]|[<>]\(/.test(z))return HZ(z);let J=$.segments.flatMap((Y)=>{let Q=E2(Y),X=Y.words.filter((B,M)=>!Y.redirects.has(M)).map((B)=>B.text),H=X.map(QZ);if(H.every((B,M)=>B!==null&&B.length===1&&B[0]===X[M]))return[Q];if(H.some((B)=>B===null))return[Q,HZ(X.join(" "))];let K=S(H.flatMap((B)=>B??[]).join(" "));return[Q,...K.trustworthy?K.segments.map(E2):[HZ(X.join(" "))]]});return rZ(...J)}function E2(Z){let z=Z.words.map((Q,X)=>({word:Q,at:X})).filter(({at:Q})=>!Z.redirects.has(Q)),$=u(Z),J=$<0?"read":S2(Z,$),Y=XZ(z.map(({word:Q})=>k0(Q.text)));if(Y===null)return rZ(J,HZ(z.map(({word:Q})=>b(Q.text)).join(" ")));if(Y.index<0||z[Y.index].at===$)return J;return rZ(J,S2(Z,z[Y.index].at))}function i2(Z,z,$=0){if(z<0||$>8)return $>8;let J=Z.words.map((B,M)=>({word:B,at:M})).filter(({at:B})=>!Z.redirects.has(B)),Y=J.findIndex(({at:B})=>B===z),Q=Y<0?null:EZ(J.map(({word:B})=>B.text),Y,E);if(Q){if(!Q.literal)return!0;let B=S(Q.program);if(B.trustworthy&&B.segments.some((M)=>tZ(M,$+1)))return!0}let X=Z.words.map((B)=>E(B.text));for(let B of SZ(X,z,(M)=>Z.redirects.has(M)))if(tZ(d2(Z,B.start,B.end),$+1))return!0;let K=fZ(X,z,(B)=>B>=0&&B<Z.words.length&&(Z.redirects.has(B)||S0(Z.words[B].text)));if(!K)return!1;if(K.unresolved)return!0;return K.programs.some((B)=>B.kind==="shell"?f0(B.text)!=="read":!W2(B))}function d2(Z,z,$){let J=new Set([...Z.redirects].filter((Y)=>Y>=z&&Y<$).map((Y)=>Y-z));return{words:Z.words.slice(z,$),redirects:J}}function tZ(Z,z=0){return s2(Z).some(($)=>i2(Z,$,z))}function k0(Z){return{text:E(Z),opaque:/[$\x60]/.test(Z)&&!/^(?:[^$\x60"'\\]|\$'(?:[^'\\]|\\.)*')+$/.test(Z)}}function s2(Z){let z=new Set,$=u(Z);if($>=0)z.add($);let J=Z.words.map((Q,X)=>({word:Q,at:X})).filter(({at:Q})=>!Z.redirects.has(Q)),Y=XZ(J.map(({word:Q})=>k0(Q.text)));if(Y!==null&&Y.index>=0)z.add(J[Y.index].at);return[...z]}function gZ(Z,z=0){if(z>8)return[];let $=[];for(let J of Z.segments){let Y=J.words.map((H)=>E(H.text)),Q=(H)=>H>=0&&H<J.words.length&&(J.redirects.has(H)||S0(J.words[H].text)),X=J.words.filter((H,K)=>!J.redirects.has(K));for(let H of s2(J)){$.push(...(fZ(Y,H,Q)?.writes??[]).map((M)=>M[0]==="/"?M:`./${M}`));let K=EZ(X.map((M)=>M.text),X.indexOf(J.words[H]),E),B=K?.literal?S(K.program):null;if(B?.trustworthy)$.push(...gZ(B,z+1));for(let M of SZ(Y,H,(V)=>J.redirects.has(V)))$.push(...gZ({segments:[d2(J,M.start,M.end)]},z+1))}}for(let J of Z.substitutions??[]){let Y=S(J);if(Y.trustworthy)$.push(...gZ(Y,z+1))}return $}function eZ(Z,z=0){if(z>4)return!1;let $=S(Z),J=$.trustworthy?Z:jZ(Z);if(J!==Z)return eZ(J,z+1);if($.trustworthy&&$.segments.some((Q)=>tZ(Q)))return!0;return(o2(Z)??$.substitutions).some((Q)=>eZ(Q,z+1))}function S2(Z,z){if(i2(Z,z))return"delete";let $=Z.words.filter((Q,X)=>X>=z&&!Z.redirects.has(X)),J=$.map((Q)=>E(Q.text)),Y=J[0].split("/").pop();if(["rm","rmdir","shred"].includes(Y??""))return A0(J,1,!1)?"read":"delete";if(["unlink","rmtree","del"].includes(Y??""))return"delete";if(Y==="trash"){let Q=1;while(Q<J.length&&J[Q].startsWith("-")){let X=J[Q++];if(["--help","-h","--version","-V","--identity"].includes(X))return"read";if(["--agent","--spool","--files","--info","--config"].includes(X))Q++;else if(!["--json","--local"].includes(X))return"delete"}if(Q===J.length||M5.has(J[Q]))return"read";if(V5.has(J[Q])&&A0(J,Q+1,!0))return"read";if(["restore","restore-capsule"].includes(J[Q]))return"write";return"delete"}if(Y==="git"){let Q=O0(Z,z);if(Q==="clean"||Q==="rm")return J[1]===Q&&A0(J,2,!0)?"read":"delete";return Q==="clone"||Q==="init"?"write":"read"}if(Y==="find"&&!$.some((Q)=>S0(Q.text))&&!J.some((Q)=>c2.has(Q)))return"read";if(Y==="env"&&o(xZ(J)))return"delete";if(["sh","bash","zsh","dash","ksh","ash","eval","source",".","su","runuser","env","xargs","find","busybox","toybox"].includes(Y??""))return HZ(J.join(" "));if(["mkdir","mkfile","touch","mv","cp","ln","tee","install","dd","rsync","scp","truncate"].includes(Y??""))return"write";if(Y==="curl"||Y==="wget")return u2.test(J.join(" "))?"write":"read";if(Y==="sed"&&J.slice(1).some((Q)=>/^-i|^--in-place(?:=|$)/.test(Q)))return"write";if(["python","python3","node","bun"].includes(Y??"")&&J.some((Q)=>Q==="-c"||Q==="-e"))return"write";return"read"}function HZ(Z){let z=Z.replace(/[{},]/g," ");return z===Z?R0(Z):rZ(R0(Z),R0(z))}function R0(Z){let z=Z.trim();if(!z)return"read";if(/(?:^|\s)\\?(?:[^\s;&|<>()]*\/)?(?:rm|rmdir|unlink|shred|trash|rmtree|del)(?:\s|$)/.test(z))return"delete";if(/\bgit\b/.test(z)){if(/\bgit\b[^;&|]*\b(?:clean|rm)\b/.test(z))return"delete";if(/\bgit\b[^;&|]*\b(?:clone|init)\b/.test(z))return"write";return"read"}if(/(?:^|\s)\\?(?:[^\s;&|<>()]*\/)?(?:mkdir|mkfile|touch|mv|cp|ln|tee|install|dd)(?:\s|$)/.test(z))return"write";if(/\b(?:curl|wget)\b/.test(z)){if(u2.test(z))return"write";return"read"}if(/\bsed\b/.test(z)){if(/(?:^|\s)-i\S*(?:\s|$)|--in-place(?:\s|$)/.test(z))return"write"}else if(/\b(?:rsync|scp|truncate)\b/.test(z))return"write";else if(/(?:^|\s)(?:python3?|node|bun)\b[^;&|]*\s+-[ce](?:\s|$)/.test(z))return"write";if(/(?:^|[;&|])\s*echo\b/.test(z)||/>/.test(m2(z)))return"write";return"read"}function lZ(Z,z){let $=Z.trim(),J=$.match(/^(['"])([\s\S]*)\1$/);if(J)$=J[2];if($=$.replace(/^"*\$HOME"*\//,"$HOME/"),$=$.replace(/^"*\$\{HOME\}"*\//,"${HOME}/"),$==="~")return z;if($.startsWith("~/"))return O.join(z,$.slice(2));if($==="$HOME"||$==="${HOME}")return z;if($.startsWith("$HOME/"))return O.join(z,$.slice(6));if($.startsWith("${HOME}/"))return O.join(z,$.slice(8));let Y=$.match(new RegExp(`^"*${v0(z)}"*/`));if(Y)return z+"/"+$.slice(Y[0].length);return Z}function G5(Z){let z=Z.trim();while(z.startsWith("(")||/^\{(?:\s|$)/.test(z))z=z.slice(1).trim();while(z.endsWith(")")||/(?:^|\s)\}$/.test(z))z=z.slice(0,-1).trim();return z}function v0(Z){return Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function f2(Z,z,$){if(Z===void 0)return[$];let J=lZ(Z,$),Y=J.match(/^(['"])(.*)\1$/);if(Y)J=Y[2];if(!J||J==="-"||/[$\x60*?[\]{}~\\'"]/.test(J))return null;return[...new Set(z.map((Q)=>O.resolve(Q,J)))]}var U5=/(?:^|\s)(\.\.?|[^\s"';&|<>()\x60/]+(?:\/[^\s"';&|<>()\x60]*)?)\s*$/;function j5(Z,z){let $=XZ(z);if(!$||$.index<=0||z[$.index].opaque)return 0;let J=S(Z);if(!J.trustworthy||J.substitutions.length>0||J.segments.length!==1)return 0;let[Y]=J.segments;if(Y.redirects.size>0||Y.words.length!==z.length)return 0;if(Y.words.some((Q,X)=>b(Q.text)!==z[X].text))return 0;return u(Y)===$.index?$.index:0}function W5(Z,z){let $=0;if(Z==="git")$=z.findIndex((Y)=>Y.text==="rm"||Y.text==="clean")+1;let J=!1;return z.slice($).filter((Y)=>{if(!J&&Y.text==="--")return J=!0,!1;if(!J&&Y.text.startsWith("-")&&!Y.opaque)return!1;return J=!0,!0})}var N5=new Set(["--agent","--spool","--files","--info","--config"]),F5=new Set(["--spool","--files","--info","--config"]),_5=new Set(["--json","--local","--help","-h","--version","--identity"]),k2={"--agent":/^[^-]/,"--retention":/^(?:\d+(?:\.\d+)?|never)$/},D5=new Set(["--to"]);function I5(Z){let z=[],$=0;for(;$<Z.length&&Z[$].text.startsWith("-");$++){let Q=Z[$];if(Q.opaque)return null;if(N5.has(Q.text)){let X=Z[++$];if(!X||X.opaque)return null;if(F5.has(Q.text))z.push(X)}else if(!_5.has(Q.text))return null}let J=Z[$];if(!J||J.opaque||!p2.has(J.text))return null;let Y=!1;for($++;$<Z.length;$++){let Q=Z[$];if(Y||Q.opaque||Q.text==="-"||!Q.text.startsWith("-")){z.push(Q);continue}if(Q.text==="--"){Y=!0;continue}let X=Q.text.indexOf("="),H=X<0?Q.text:Q.text.slice(0,X);if(D5.has(H)){if(X>=0)z.push({text:Q.text.slice(X+1),opaque:!1});else if(Z[$+1]&&!Z[$+1].text.startsWith("-"))z.push(Z[++$]);continue}let K=Z[$+1];if(X<0&&Object.hasOwn(k2,H)&&K&&!K.opaque&&k2[H].test(K.text))$++}return z}function T5(Z){let z=Z.split(`
24
- `),$=[],J=[],Y=0;while(Y<z.length){let Q=Y,X=z[Y++].replace(/\r$/,""),H=[];for(let K=0;K<X.length;K++){let B=X[K],M=J[J.length-1];if(B==="\\"){K++;continue}if(B==="$"&&X[K+1]==="("&&X[K+2]==="("){let V=X.indexOf("))",K+3);if(V<0)return null;K=V+1;continue}if(B==="$"&&X[K+1]==="("){J.push(0),K++;continue}if(B==="$"&&X[K+1]==="[")return null;if(B==="$"&&X[K+1]==="{"){let V=X.indexOf("}",K+2);if(V<0||/['"\x60$]|<</.test(X.slice(K+2,V)))return null;K=V;continue}if(B==="`"){let V=X.indexOf("`",K+1);if(V<0)return null;K=V;continue}if(M==='"'){if(B==='"')J.pop();continue}if(B==="'"){let V=X.indexOf("'",K+1);if(V<0)return null;K=V;continue}if(B==='"'){J.push('"');continue}if(B==="#"&&(K===0||/[\s;&|()]/.test(X[K-1])))break;if(B==="("&&X[K+1]==="("&&(K===0||/[\s;&|(]/.test(X[K-1]))){let V=X.indexOf("))",K+2);if(V<0)return null;K=V+1;continue}if(typeof M==="number"&&(B==="("||B===")")){if(B==="(")J[J.length-1]=M+1;else if(M===0)J.pop();else J[J.length-1]=M-1;continue}if(B==="<"&&X[K+1]==="<"){if(X[K+2]==="<"){K+=2;continue}let V=FZ(X,K);if(!V)return null;H.push({marker:V,from:K}),K=V.end-1}}for(let{marker:K,from:B}of H){let M=Y;for(;;){if(Y>=z.length)return null;let V=z[Y++].replace(/\r$/,"");if(K.stripTabs)V=V.replace(/^\t+/,"");if(V===K.delimiter)break}$.push({line:Q,from:B,to:K.end,start:M,end:Y-1,quoted:K.quoted})}}return J.length===0?$:null}var q5=new Set(["sh","bash","zsh","dash","ksh","mksh","ash","fish","csh","tcsh","nu","xonsh","elvish","busybox","toybox","ssh","su","runuser","sudo","doas","pkexec","xargs","parallel","expect","script","at","batch","crontab","watch","flock","chroot","nsenter","unshare","docker","podman","kubectl","lxc","python","pypy","node","nodejs","bun","deno","tsx","ts-node","zx","npx","bunx","pnpx","perl","ruby","irb","php","lua","luajit","osascript","pwsh","powershell","Rscript","R","julia","tclsh","wish","awk","gawk","mawk","nawk","sed","make","gmake","gdb","lldb","sqlite3","psql","mysql","sftp","ftp","lftp","vim","vi","nvim","ex","ed","emacs","chmod"]),C5=new Set([".","source","eval","env","alias","hash"]),P5=new Set(["tee","cp","mv","install","ln"]),n2=new Set(["cat","tac","tee","head","tail","wc","cut","tr","nl","rev","fold","fmt","paste","uniq","grep","egrep","fgrep","jq","diff","cmp","comm","iconv","od","xxd","hexdump","base64","base32","md5sum","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","b2sum","cksum","echo","printf","true","false",":","test","[","read","cd","pwd","ls","mkdir","touch","stat","sleep","cp","mv","ln","rm","rmdir","unlink","shred","trash","todos","conversations","mementos","knowledge","files","asks"]),O5=new Set(["add","commit","tag","notes","status","diff","log","show","rev-parse","branch","switch","push","fetch","hash-object","apply"]),L5=new Set(["pr","issue","api","release","gist"]);function y5(Z,z){let $=Z[z];if($==="gh")return L5.has(Z[z+1]??"");if($!=="git")return n2.has($);for(let J=z+1;J<Z.length;J++){let Y=Z[J];if(Y==="-C")J++;else if(Y==="--no-pager"||Y==="-P")continue;else return!Y.startsWith("-")&&O5.has(Y)}return!1}function A5(Z,z){for(let $=z+1;$<Z.length;$++){let J=Z[$];if(J==="\\")$++;else if(J==='"')return $;else if(J==="$"&&Z[$+1]==="("){if($=a2(Z,$+1),$<0)return-1}else if(J==="`"){if($=Z.indexOf("`",$+1),$<0)return-1}}return-1}function a2(Z,z){let $=0;for(let J=z;J<Z.length;J++){let Y=Z[J];if(Y==="\\")J++;else if(Y==="'"||Y==="`"){if(J=Z.indexOf(Y,J+1),J<0)return-1}else if(Y==='"'){if(J=A5(Z,J),J<0)return-1}else if(Y==="(")$++;else if(Y===")"&&--$===0)return J}return-1}function o2(Z){let z=[],$=!1;for(let J=0;J<Z.length;J++){let Y=Z[J];if(Y==="\\")J++;else if(Y==="'"&&!$){let Q=Z.indexOf("'",J+1);if(Q<0)return null;J=Q}else if(Y==='"')$=!$;else if(Y==="$"&&Z[J+1]==="("){let Q=a2(Z,J+1);if(Q<0)return null;let X=Z.slice(J+2,Q);if(Z[J+2]==="("){if(/\$\(|\x60/.test(X))return null}else z.push(X);J=Q}else if(Y==="`"){let Q=Z.indexOf("`",J+1);if(Q<0)return null;z.push(Z.slice(J+1,Q)),J=Q}}return $?null:z}function R5(Z){if(/[<>]\(/.test(Z))return!0;let z=[],$=[Z];for(let Y=0;$.length>0;Y++){if(Y>64)return!0;let Q=$.shift(),X=S(Q),H=o2(Q);if(!X.trustworthy||!H)return!0;z.push(...X.segments),$.push(...new Set([...X.substitutions,...H]))}let J=new Set;for(let Y of z){let Q=Y.words.map((K)=>b(K.text));for(let K of Y.redirects)J.add(a(Q[K]??""));let X=u(Y);if(X<0)continue;let H=a(Q[X]);if(P5.has(H)){for(let K of Q.slice(X+1))if(!K.startsWith("-"))J.add(a(K))}if(H==="dd"){for(let K of Q)if(K.startsWith("of="))J.add(a(K.slice(3)))}}J.delete("");for(let Y of z){for(let B of Y.words){let M=a(b(B.text));if(q5.has(M)||/^(?:python|pypy|node|perl|ruby|php|lua)[0-9.]+$/.test(M))return!0}let Q=u(Y),X=Y.words.map((B,M)=>({text:b(B.text),at:M})).filter(({at:B})=>!Y.redirects.has(B));if(X.some(({text:B,at:M})=>(Q<0||M<Q)&&RZ.test(B)))return!0;if(Q<0)continue;let H=Y.words[Q].text,K=b(H);if(/[$\x60]/.test(H)||K.includes("/")||C5.has(K)||J.has(K))return!0;if(!y5(X.filter(({at:B})=>B>=Q).map(({text:B})=>B),0))return!0}return!1}function v5(Z){if(!Z.includes("<<"))return null;let z=T5(Z);if(!z||z.length===0)return null;let $=Z.split(`
25
- `),J=[...$],Y=[];for(let X of z){let H=$.slice(X.start,X.end);if(!X.quoted&&H.some((K)=>/\$\(|\x60/.test(K)))return null;Y.push(H.join(`
26
- `));for(let K=X.start;K<=X.end;K++)J[K]=""}let Q=[...J];for(let X of[...z].reverse()){let H=Q[X.line];Q[X.line]=H.slice(0,X.from)+" ".repeat(X.to-X.from)+H.slice(X.to)}return R5(Q.join(`
10
+ `||!K(M,!0))return null}else if(B==="#")Q();else if(":btTv".includes(B)){while(X()===" "||X()==="\t")J++;while(J<Y&&!/[\s;]/.test(X()))J++}else if("aic".includes(B)){while(X()===" "||X()==="\t")J++;if(X()==="\\")J+=2;for(;J<Y&&Z[J]!==`
11
+ `;J++)if(Z[J]==="\\")J++}else if(B==="e")$=!0,Q();else if(B==="r"||B==="R")Q();else if(B==="w"||B==="W")H();else if(B==="s"||B==="y"){let M=Z[J++]??"";if(!M||M===`
12
+ `||M==="\\"||!K(M,B==="s")||!K(M,!1))return null;for(;B==="s"&&" \tgpiImMe0123456789w".includes(X()||"_");J++){if(X()==="e")$=!0;if(X()==="w"){J++,H();break}}}}return{writes:z,executes:$}}var K4=new Set(["-exec","-execdir","-ok","-okdir"]),H4=new Set(["-exec","-execdir"]),B4=new Set("0oprtx"),M4=new Set("adEILnPsJRS"),V4=new Set("eil"),nZ={"--null":"flag","--open-tty":"flag","--interactive":"flag","--no-run-if-empty":"flag","--verbose":"flag","--exit":"flag","--show-limits":"flag","--help":"flag","--version":"flag","--arg-file":"value","--delimiter":"value","--max-args":"value","--max-procs":"value","--max-chars":"value","--process-slot-var":"value","--max-lines":"value","--eof":"optional","--replace":"optional"};function G4(Z){if(Object.hasOwn(nZ,Z))return nZ[Z];let z=Object.keys(nZ).filter(($)=>$.startsWith(Z));return z.length===1?nZ[z[0]]:null}function SZ(Z,z,$,J=0){while(z<Z.length){if($(z)){z++;continue}let Y=Z[z];if(Y==="--"){z++;break}if(!Y.startsWith("-")||Y==="-")break;if(Y.startsWith("--")){let H=Y.indexOf("="),K=G4(H<0?Y:Y.slice(0,H));if(K===null){if(J>=4)return[];return[...SZ(Z,z+1,$,J+1),...SZ(Z,z+2,$,J+1)]}z+=K==="value"&&H<0?2:1;continue}let X=!1,Q=!1;for(let H=1;H<Y.length;H++){let K=Y[H];if(B4.has(K))continue;if(V4.has(K))break;if(M4.has(K)){X=H===Y.length-1;break}Q=!0;break}if(Q){if(J>=4)return[];return[...SZ(Z,z+1,$,J+1),...SZ(Z,z+2,$,J+1)]}z+=X?2:1}while(z<Z.length&&$(z))z++;return z<Z.length?[z]:[]}function kZ(Z,z,$=()=>!1){if(z<0||z>=Z.length)return[];let J=I0(Z[z]);if(J==="xargs")return[...new Set(SZ(Z,z+1,$))].map((X)=>({start:X,end:Z.length}));if(J!=="find")return[];let Y=[];for(let X=z+1;X<Z.length;X++){if($(X)||!K4.has(Z[X]))continue;let Q=X+1,H=Q;for(;H<Z.length;H++){if($(H))continue;if(Z[H]===";")break;if(Z[H]==="+"&&H>Q&&Z[H-1]==="{}"&&H4.has(Z[X]))break}if(Q<H)Y.push({start:Q,end:H});X=H}return Y}function xZ(Z,z,$){if(z<0||z>=Z.length)return null;let J=I0(Z[z]);if(J==="deno"){let Y=i3(Z,z,$);if(Y)return Y}if(Object.hasOwn(D0,J)||N2.test(J))return c3(J,Z,z,$);if(g3.has(J))return d3(Z,z,$);if(u3.has(J))return n3(Z,z,$);if(J==="rsync")return o3(Z,z,$);if(J==="git")return $4(Z,z,$);if(J==="sed")return Y4(Z,z,$);return null}var j4=600000,W4="Delete via trash guard (rm intercepted and made recoverable)",N4=[".hasna/repos/clones","workspace/repos"],F4=[".hasna",".ssh",".aws"],T0={rmdir:"`rmdir` is a delete that trash-guard does not rewrite (it takes rmdir's flags, not rm's). Re-run it as `rm -d -- <path>` for an empty directory, or `rm -r -- <path>` for a non-empty one, and it is redirected into trash.",unlink:"`unlink` is a delete that trash-guard does not rewrite. Re-run it as `rm -- <path>` and it is redirected into trash.",shred:"`shred` destroys content irrecoverably and is never allowed. Re-run it as `rm -- <path>` and it is redirected into trash."},_4=new Set(["sh","bash","zsh","dash","ksh","ash","mksh","eval","source",".","su","runuser","env"]),D4={sudo:["-u","--user","-g","--group","-p","--prompt","-C","--chdir","-h","--host","-r","--role","-t","--type","-U","--other-user"],doas:["-u","-C"],env:["-u","--unset","-C","--chdir","-S","--split-string"],nice:["-n","--adjustment"],ionice:["-c","--class","-n","--classdata","-p","--pid"],stdbuf:["-i","-o","-e","--input","--output","--error"],time:["-f","--format","-o","--output"],timeout:["-s","--signal","-k","--kill-after"],nohup:[],setsid:[],command:[],builtin:[],exec:["-a"]},I4={timeout:1},T4={sudo:{short:{A:W,B:W,b:W,E:W,H:W,i:W,k:W,N:W,n:W,P:W,S:W,s:W,C:D,g:D,p:D,r:D,T:D,t:D,U:D,u:D,e:t,l:t,v:t,D:C,R:C,h:C,K:C,V:C},long:{askpass:W,bell:W,background:W,"close-from":D,chdir:C,"preserve-env":vZ,edit:t,group:D,"set-home":W,help:C,host:C,login:W,"remove-timestamp":C,"reset-timestamp":W,list:t,"no-update":W,"non-interactive":W,"preserve-groups":W,prompt:D,chroot:C,role:D,stdin:W,shell:W,type:D,"command-timeout":D,"other-user":D,user:D,version:C,validate:t},assignments:!0},doas:{short:{n:W,s:W,u:D,C,L:C},long:{}},flock:{short:{s:W,x:W,e:W,n:W,u:W,o:W,F:W,w:D,E:D,h:C,V:C},long:{shared:W,exclusive:W,unlock:W,nonblock:W,nonblocking:W,nb:W,timeout:D,wait:D,"conflict-exit-code":D,close:W,"no-fork":W,fcntl:W,verbose:W,help:C,version:C},positionals:[/^[\s\S]+$/]}},q4={...F0,...T4},A2=new Set(["-c","--command"]),C4=new Set(["busybox","toybox"]),P0=new Set(["rm","rmdir","unlink","shred"]),P4=new Set(["!","{","}","then","do","else","elif","if","while","until","for","case","esac","fi","done","select","function"]),O4=new Set(["-C","-c","--git-dir","--work-tree","--namespace","--exec-path","--config-env"]),L4=/(^|[^A-Za-z0-9_.-])(rm|rmdir|unlink|shred)(?![A-Za-z0-9_.-])/;function a(Z){return L4.test(E(Z))}function wZ(Z){return Z.map((z)=>z.replace(/^-[iv0]*S|^--split-string=/," ")).join(" ")}var y2=/^[A-Za-z_][A-Za-z0-9_]*=/;function aZ(Z){let z=Z.lastIndexOf("/");return z>=0?Z.slice(z+1):Z}var D2={a:"\x07",b:"\b",e:"\x1B",E:"\x1B",f:"\f",n:`
13
+ `,r:"\r",t:"\t",v:"\v","\\":"\\","'":"'",'"':'"',"?":"?"};function A4(Z,z){let $="",J=z;while(J<Z.length&&Z[J]!=="'"){if(Z[J]!=="\\"||J+1>=Z.length){$+=Z[J++];continue}let Y=Z[J+1],X=Z.slice(J+1),Q;if(Object.hasOwn(D2,Y))$+=D2[Y],J+=2;else if(Q=X.match(/^[0-7]{1,3}/))$+=String.fromCharCode(parseInt(Q[0],8)&255),J+=1+Q[0].length;else if((Q=X.match(/^x([0-9A-Fa-f]{1,2})/))||(Q=X.match(/^u([0-9A-Fa-f]{1,4})/))||(Q=X.match(/^U([0-9A-Fa-f]{1,8})/))){let H=parseInt(Q[1],16);$+=H<=1114111?String.fromCodePoint(H):"",J+=1+Q[0].length}else if(Y==="c"&&J+2<Z.length)$+=String.fromCharCode(Z.charCodeAt(J+2)&31),J+=3;else $+=`\\${Y}`,J+=2}return{text:$,end:Math.min(J+1,Z.length)}}function S(Z){return R2(Z,!0)}function R2(Z,z){let $="",J=0;while(J<Z.length){let Y=Z[J];if(z&&Y==="$"&&Z[J+1]==="'"){let X=A4(Z,J+2);$+=X.text,J=X.end;continue}if(z&&Y==="$"&&Z[J+1]==='"'){J++;continue}if(Y==="\\"){if(J+1<Z.length)$+=Z[J+1];J+=2;continue}if(Y==="'"){let X=Z.indexOf("'",J+1);if(X===-1){$+=Z.slice(J+1);break}$+=Z.slice(J+1,X),J=X+1;continue}if(Y==='"'){J++;while(J<Z.length&&Z[J]!=='"'){if(Z[J]==="\\"&&J+1<Z.length){let X=Z[J+1];$+=$Z.on||/[$`"\\]/.test(X)?X:X===`
14
+ `?"":`\\${X}`,J+=2;continue}$+=Z[J],J++}J++;continue}$+=Y,J++}return $}function rZ(Z){if(sZ(Z))return!0;let z=null;for(let $=0;$<Z.length;$++){let J=Z[$];if(z==="'"){if(J==="'")z=null;continue}if(J==="\\"){$++;continue}if(J==="`"||J==="$")return!0;if(J==='"'){z=z===null?'"':null;continue}if(z!==null)continue;if(J==="'")z="'";else if(J==="*"||J==="?")return!0;else if(J==="["&&y4(Z,$+1,"]"))return!0}return!1}function y4(Z,z,$){let J=null;for(let Y=z;Y<Z.length;Y++){let X=Z[Y];if(J!=="'"&&X==="\\")Y++;else if(J===null&&X===$)return!0;else if(X==="'"&&J!=='"')J=J==="'"?null:"'";else if(X==='"'&&J!=="'")J=J==='"'?null:'"'}return!1}function R4(Z){if(!rZ(Z))return!1;let z=QZ(Z);return z===null||z.some(($)=>S($).split(/[^A-Za-z0-9_]+/).some((J)=>P0.has(J)))}function FZ(Z){return aZ(S(Z))}var v2={deep:!0};function O0(Z,z){return Z.replace(/\\([$`\\"])/g,($,J)=>J==='"'&&!z?$:J)}function v4(Z,z,$){let J=[],Y=z+1;while(Y<$-1){let X=Z[Y];if(X==="\\"){Y+=2;continue}if(X==="`"){let Q=gZ(Z,Y);if(Q<0)return null;J.push(O0(Z.slice(Y+1,Q-1),!0)),Y=Q;continue}if(X==="$"&&Z[Y+1]==="("){let Q=BZ(Z,Y+1);if(Q<0)return null;J.push(Z.slice(Y+2,Q-1)),Y=Q;continue}Y++}return J}function b4(Z){let z=[],$=0;while($<Z.length){let J=Z[$];if(J==="\\"){$+=2;continue}if(J==="`"){let Y=gZ(Z,$);if(Y<0)return null;z.push(O0(Z.slice($+1,Y-1),!1)),$=Y;continue}if(J==="$"&&Z[$+1]==="("){let Y=BZ(Z,$+1);if(Y<0)return null;z.push(Z.slice($+2,Y-1)),$=Y;continue}$++}return z}function I2(Z,z,$,J){let Y=z+1;for(let X of $){let Q=Math.min(Y,Z.length);for(;;){if(Y>Z.length){Y=Z.length+1;break}let K=Z.indexOf(`
15
+ `,Y),B=K===-1?Z.length:K,M=Z.slice(Y,B).replace(/\r$/,"");if(X.stripTabs)M=M.replace(/^\t+/,"");if(M===X.delimiter)break;Y=B+1}let H=Z.slice(Q,Math.min(Y,Z.length));if(X.owner.push(H),!X.quoted){let K=b4(H);if(!K)return-1;J.push(...K)}if(Y<=Z.length){let K=Z.indexOf(`
16
+ `,Y);Y=(K===-1?Z.length:K)+1}}return Math.min(Y-1,Z.length)}function b2(Z,z){let $=Z.indexOf("'",z+1);return $===-1?-1:$+1}function gZ(Z,z){let $=z+1;while($<Z.length){if(Z[$]==="\\"){$+=2;continue}if(Z[$]==="`")return $+1;$++}return-1}function E2(Z,z){let $=z+1;while($<Z.length){let J=Z[$];if(J==="\\"){$+=2;continue}if(J==='"')return $+1;if(J==="`"){let Y=gZ(Z,$);if(Y<0)return-1;$=Y;continue}if(J==="$"&&Z[$+1]==="("){let Y=BZ(Z,$+1);if(Y<0)return-1;$=Y;continue}$++}return-1}function DZ(Z,z){if(Z[z]!=="<"||Z[z+1]!=="<"||Z[z+2]==="<")return null;let $=z+2,J=Z[$]==="-";if(J)$++;while(Z[$]===" "||Z[$]==="\t")$++;let Y="",X=!1;while($<Z.length&&!/[\s;|&<>()]/.test(Z[$])){let Q=Z[$];if(Q==="'"||Q==='"'){let H=Z.indexOf(Q,$+1);if(H<0)return null;Y+=Z.slice($+1,H),X=!0,$=H+1;continue}if(Q==="\\"){if($+1>=Z.length)return null;Y+=Z[$+1],X=!0,$+=2;continue}Y+=Q,$++}return Y?{delimiter:Y,stripTabs:J,quoted:X,end:$}:null}function tZ(Z,z,$){let J=z+1;for(let Y of $)for(;;){if(J>Z.length)return-1;let X=Z.indexOf(`
17
+ `,J),Q=X===-1?Z.length:X,H=Z.slice(J,Q);if(H.endsWith("\r"))H=H.slice(0,-1);let K=Y.stripTabs?H.length-H.replace(/^\t+/,"").length:0;if(Y.stripTabs)H=H.slice(K);if(H===Y.delimiter){J=Q+1;break}if(H.startsWith(Y.delimiter)&&/^\s*\)/.test(H.slice(Y.delimiter.length))){if(Y===$[$.length-1])return J+K+Y.delimiter.length;return-1}if(X===-1)return-1;J=X+1}return J-1}function BZ(Z,z){let $=Z.length,J=Z[z+1]==="(",Y=0,X=z,Q=[];while(X<$){let H=Z[X];if(H==="\\"){X+=2;continue}if(H==="'"){let K=b2(Z,X);if(K<0)return-1;X=K;continue}if(H==='"'){let K=E2(Z,X);if(K<0)return-1;X=K;continue}if(H==="`"){let K=gZ(Z,X);if(K<0)return-1;X=K;continue}if(!J&&H==="<"&&Z[X+1]==="<"){if(Z[X+2]==="<"){X+=3;continue}let K=DZ(Z,X);if(!K)return-1;Q.push(K),X=K.end;continue}if(H===`
18
+ `&&Q.length>0){let K=tZ(Z,X,Q);if(K<0)return-1;Q=[],X=K;continue}if(!J&&H==="#"&&/[\s;&|(]/.test(Z[X-1])){let K=Z.indexOf(`
19
+ `,X);if(K<0)return-1;X=K;continue}if(H==="(")Y++;else if(H===")"){if(Y--,Y===0)return Q.length>0?-1:X+1}X++}return-1}function f(Z,z={}){let $=z.deep===!0,J=[],Y=[],X=[],Q=new Set,H=[],K=[],B=-1,M=!1,V=!0,G=0,U=Z.length,j=(q)=>{if(B>=0){let F=X.length;if(X.push({text:Z.slice(B,q),start:B,end:q}),M)Q.add(F);B=-1,M=!1}},N=(q)=>{if(j(q),X.length>0)J.push($?{words:X,redirects:Q,heredocs:H}:{words:X,redirects:Q});if(X=[],Q=new Set,$)H=[];M=!1},y=(q)=>b2(Z,q),b=(q)=>gZ(Z,q),k=(q)=>BZ(Z,q),d=(q)=>E2(Z,q);while(G<U){let q=Z[G];if(q===" "||q==="\t"||q==="\r"){j(G),G++;continue}if(q===`
20
+ `){if(N(G),K.length>0){let F=I2(Z,G,K,Y);if(K=[],F<0)V=!1,G=U;else G=F;continue}G++;continue}if(q===";"){N(G),G++;continue}if(q==="&"){N(G),G+=Z[G+1]==="&"?2:1;continue}if(q==="|"){N(G),G+=Z[G+1]==="|"?2:1;continue}if($&&q==="("&&B>=0&&"?*+@!".includes(Z[G-1])){V=!1,G=U;continue}if(q==="("||q===")"){N(G),G++;continue}if(q==="<"&&Z[G+1]==="<"&&Z[G+2]!=="<"){let F=Z.slice(G+2).match(/^-?[ \t]*(['"]?)([A-Za-z_][A-Za-z0-9_]*)\1/);if(!F){V=!1,G=U;continue}if($){let qZ=G+2+F[0].length;if(qZ<U&&!/[\s;&|()<>]/.test(Z[qZ])){V=!1,G=U;continue}j(G),K.push({delimiter:F[2],quoted:F[1]!=="",stripTabs:F[0].startsWith("-"),owner:H}),G=qZ;continue}let R=Z.indexOf(`
21
+ `,G+2+F[0].length);if(R===-1){V=!1,G=U;continue}let m=Z.slice(R+1),p=E4(m,F[2]);if(p===-1){V=!1,G=U;continue}j(G),G=R+1+p+F[2].length;continue}if(q===">"||q==="<"){if(B>=0&&/^\d+$/.test(Z.slice(B,G)))B=-1;if(j(G),M=!0,G++,Z[G]===q||Z[G]==="&"||q===">"&&Z[G]==="|"||q==="<"&&Z[G]===">")G++;continue}if(q==="'"){if(B<0)B=G;let F=y(G);if(F<0)V=!1,G=U;else G=F;continue}if(q==='"'){if(B<0)B=G;let F=d(G),R=F<0||!$?[]:v4(Z,G,F);if(F<0||!R)V=!1,G=U;else Y.push(...R),G=F;continue}if(q==="`"){if(B<0)B=G;let F=b(G);if(F<0)V=!1,G=U;else{let R=Z.slice(G+1,F-1);Y.push($?O0(R,!1):R),G=F}continue}if(q==="$"&&Z[G+1]==="("){if(B<0)B=G;let F=k(G+1);if(F<0)V=!1,G=U;else Y.push(Z.slice(G+2,F-1)),G=F;continue}if(q==="\\"){if(B<0)B=G;if(G+1>=U)V=!1,G=U;else G+=2;continue}if(B<0)B=G;G++}if(N(U),K.length>0&&I2(Z,U,K,Y)<0)V=!1;return{segments:J,trustworthy:V,substitutions:Y}}function E4(Z,z){let $=0;while($<=Z.length){let J=Z.indexOf(z,$);if(J===-1)return-1;let Y=J===0||Z[J-1]===`
22
+ `,X=J+z.length,Q=X===Z.length||Z[X]===`
23
+ `||Z[X]==="\r";if(Y&&Q)return J;$=J+1}return-1}function E(Z){return R2(Z,!1)}function l(Z){let z=0,$=0;while(z<Z.words.length&&$++<32){if(Z.redirects.has(z)){z++;continue}let J=Z.words[z].text,Y=S(J);if(y2.test(Y)&&!Y.startsWith("-")){z++;continue}if(P4.has(Y)){z++;continue}let X=aZ(Y);if(X==="command")for(let H of Z.words.filter((K,B)=>B>z&&!Z.redirects.has(B))){let K=S(H.text);if(K==="--"||!K.startsWith("-"))break;if(/^-[pvV]*[vV][pvV]*$/.test(K))return-1}let Q=D4[X];if(Q){let H=z;z++;while(z<Z.words.length){if(Z.redirects.has(z)){z++;continue}let B=S(Z.words[z].text);if(!B.startsWith("-")||B==="-")break;if(B==="--"){z++;break}if(X==="env"&&(/^-[iv0]*S/.test(B)||/^--split-string(?:=|$)/.test(B)))return H;if(z++,Q.includes(B)||X==="exec"&&/^-[cl]*a$/.test(B)){while(Z.redirects.has(z))z++;z++}}let K=I4[X]??0;while(K>0&&z<Z.words.length){let B=S(Z.words[z].text);if(B.startsWith("-")&&B!=="-")break;z++,K--}continue}return z}return-1}function S4(Z,z){let $=[],J=!1;for(let Y=z+1;Y<Z.words.length;Y++){if(Z.redirects.has(Y))continue;let X=E(Z.words[Y].text);if(!J){if(X==="--"){J=!0;continue}if(X.startsWith("-")&&X!=="-")continue}$.push(Z.words[Y])}return $}function L0(Z){return N4.map((z)=>x.join(Z,...z.split("/")))}function f4(Z,z){if(Z==="~"||Z==="$HOME"||Z==="${HOME}")return z;if(Z.startsWith("~/"))return x.join(z,Z.slice(2));if(Z.startsWith("$HOME/"))return x.join(z,Z.slice(6));if(Z.startsWith("${HOME}/"))return x.join(z,Z.slice(8));return Z}function oZ(Z,z,$){let J=E(Z);if(!J)return null;if(J.includes("`"))return null;if(J==="$HOME"||J==="${HOME}"||J==="$HOME/"||J==="${HOME}/")return $;if(J.replace(/\$\{HOME\}/g,"").replace(/\$HOME/g,"").includes("$"))return null;if(/[*?[\]]/.test(J))return null;if(J.startsWith("~")){let H=f4(J,$);if(H===J)return null;J=H}let Q=(x.isAbsolute(J)?x.normalize(J):x.resolve(z,J)).replace(/\/+$/,"");return Q===""?"/":Q}function JZ(Z,z){return Z===z||Z.startsWith(`${z}${x.sep}`)}function k4(Z,z){let $=`${x.join(z,".hasna","scratchpad","scratch")}${x.sep}`;if(!Z.startsWith($))return!1;let[J,Y]=Z.slice($.length).split(x.sep);if(!J||!/^[a-z0-9][a-z0-9._-]{0,63}$/.test(J)||J.endsWith(".")||!Y)return!1;let X=Y.normalize("NFKC").toLowerCase();return X!=="meta.json"&&X!==".lock"}function x4(Z,z){if(Z===z)return`\`${Z}\` is the home directory itself, which is never deleted or trashed. Delete a specific file or directory inside it instead.`;for(let $ of V2){if(Z!==$&&!JZ($,Z))continue;return $==="/"?`\`${Z}\` is the filesystem root, which is never deleted.`:`\`${Z}\` is the system root \`${$}\` (or an ancestor of it), which is never deleted or trashed.`}for(let $ of F4){let J=x.join(z,$);if($===".hasna"&&k4(Z,z))continue;if(!JZ(Z,J)&&!JZ(J,Z))continue;return`\`${Z}\` is the protected \`~/${$}\` path (or contains it), which is never deleted or trashed. Delete a specific file inside it, and only when you are sure.`}return null}function h4(Z,z,$){let J=L0($);if(J.some((Y)=>JZ(z,Y)))return!0;return Z.some((Y)=>Y!==null&&J.some((X)=>JZ(Y,X)))}var T2=new WeakMap;function w4(Z){let z=T2.get(Z);if(z)return z;let $=Z.words.map((Q)=>S(Q.text)),J=$.findIndex((Q)=>Q==="-exec"||Q==="-execdir"||Q==="-ok"||Q==="-okdir"),Y=-1;Z.words.forEach((Q,H)=>{if(A2.has(E(Q.text)))Y=H});let X={findDelete:$.includes("-delete"),findExecDelete:J>=0&&$.slice(J).some((Q)=>P0.has(aZ(Q))),namesDelete:$.some((Q)=>P0.has(aZ(Q))),lastFlockCommand:Y,textMention:a(d4(Z)),envMention:a(wZ(Z.words.map((Q)=>E(Q.text)))),bodiesMention:a((Z.heredocs??[]).join(`
24
+ `))};return T2.set(Z,X),X}var g4=new Set(["sh","bash","zsh","dash","ksh","ash","mksh"]);function u4(Z,z){if(!g4.has(FZ(Z.words[z].text)))return!1;for(let $=z+1;$<Z.words.length;$++){if(Z.redirects.has($))continue;let J=E(Z.words[$].text);if(J==="--")return $+1>=Z.words.length;if(/^-[A-Za-z]*s/.test(J))return!0;if(/^-[A-Za-z]*c/.test(J))return!1;if(J==="-o"||J==="+o"||J==="-O"||J==="+O"){$++;continue}if(!/^[-+]/.test(J)||J==="-")return J==="-"}return!0}var q0=(Z)=>Z.kind==="rm"||Z.kind==="refuse",l4="This command's command word or wrapper arguments cannot be read before it runs (an expansion such as a variable, substitution, brace or glob pattern, an unknown or unsupported option, a working directory or a non-decimal duration), so this hook cannot tell which word runs, and one of its words could run a delete. Run the delete as a plain `rm -- <path>` command, which is redirected into trash.",m4="This delete's brace pattern names more paths than this hook will check. Run the delete on explicit paths with `rm -- <path> …`, which is redirected into trash.",p4="This delete's brace pattern expands to a path under a protected repository checkout. Deletes there are refused; run them through the owning workflow, and write any other delete out as plain paths.",c4="This command's wrapper arguments can be read as running two different deletes, so no single rewrite is safe. Run the delete as a plain `rm -- <path>` command, which is redirected into trash.";function A0(Z){let z=[];Z.words.forEach((Y,X)=>{if(!Z.redirects.has(X))z.push(X)});let $=z.map((Y)=>{let X=Z.words[Y].text;return{text:S(X),opaque:rZ(X)}}),J=KZ($,q4);if(J===null)return null;return J.index<0?-1:z[J.index]}function C0(Z,z,$,J){let Y=FZ(Z.words[z].text);if(Y==="cd"){let K=Z.words[z+1];if(!K)return{kind:"none"};return{kind:"cd",cwd:oZ(K.text,$,J.home)??J.cwd}}if(Object.hasOwn(T0,Y))return{kind:"refuse",reason:T0[Y]};let X=S2(Z,z,$,J);if(X)return X;if(Y==="rm"){let K=S4(Z,z);if(K.length===0)return{kind:"none"};let B={word:Z.words[z],operands:K},M=L0(J.home),V=(j)=>j!==null&&M.some((N)=>JZ(j,N)),G=[],U=[];for(let j of K){let N=oZ(j.text,$,J.home);if(G.push(N),!j.text.includes("{"))continue;let y=QZ(j.text);if(y===null)return{kind:"refuse",reason:m4};for(let b of y){let k=oZ(b,$,J.home);if(k===null)continue;if(V(k)&&!V(N))return{kind:"refuse",reason:p4};U.push(k)}}if(h4(G,$,J.home))return B.cwdOnly=G.every((j)=>j!==null&&!V(j)),{kind:"rm",hit:B,handoff:!0,protectedReason:null};for(let j of[...G,...U]){if(!j)continue;let N=x4(j,J.home);if(N)return{kind:"rm",hit:B,handoff:!1,protectedReason:N}}return{kind:"rm",hit:B,handoff:!1,protectedReason:null}}if(C4.has(Y)){let K=Z.words.findIndex((M,V)=>V>z&&!E(M.text).startsWith("-")),B=K>=0?FZ(Z.words[K].text):"";if(B==="rm"||Object.hasOwn(T0,B))return{kind:"refuse",reason:`\`${Y} ${B}\` runs the ${Y} applet, whose own \`rm\` is not GNU \`rm\` and cannot be rewritten in place. Run the delete as \`rm -- <path>\`, which is redirected into trash.`};return{kind:"none"}}if(Y==="git"){let K=y0(Z,z);if(K==="rm"||K==="clean"){if(!(K==="rm"?s4(Z,z):f2(Z,z)))return{kind:"refuse",reason:K==="rm"?"`git rm` is refused: without `--cached` it deletes the working-tree file, and its semantics are not `rm`'s. Use `rm -- <path>` (intercepted and redirected into trash) to remove the file, or `git rm --cached -- <path>` to unstage it without deleting.":"`git clean` deletes untracked files irrecoverably and is refused. Remove them explicitly with `rm -- <path>` (intercepted and redirected into trash), or preview with `git clean -n`."}}return{kind:"none"}}let Q=w4(Z);if(Y==="find"){if(Q.findDelete)return{kind:"refuse",reason:"`find -delete` deletes files irrecoverably and is refused. List the paths first (`find … -print`), then remove them explicitly with `rm -- <path>` so the delete is redirected into trash."};if(Q.findExecDelete)return{kind:"refuse",reason:"`find -exec <delete>` is refused: the delete runs through find, not through `rm`, and cannot be redirected into trash. Remove the paths explicitly with `rm -- <path>`."};return{kind:"none"}}if(Y==="xargs"&&Q.namesDelete)return{kind:"refuse",reason:"`xargs rm` takes its targets from stdin, so this hook cannot verify what would be deleted. Pipe the paths into an explicit `rm -- <path> …` instead, which is redirected into trash."};let H=Y==="flock"?Q.lastFlockCommand>z:A2.has(Y);if(_4.has(Y)||H){let K=u4(Z,z)?J.bodiesMention:Q.bodiesMention;if((Y==="env"?Q.envMention:Q.textMention)||K)return{kind:"refuse",reason:`\`${H?"flock":Y}\` runs a command string this hook cannot rewrite in place. Run the delete directly as \`rm -- <path>\` (intercepted and redirected into trash), or as a script that uses \`trash guard\` itself.`}}return{kind:"none"}}function S2(Z,z,$,J,Y={segment:Z,index:z},X=0){let Q=FZ(Z.words[z].text);for(let V of kZ(Z.words.map((G)=>S(G.text)),z,(G)=>Z.redirects.has(G))){if(X>=8)return hZ(Y.segment,Y.index,$,J.home)?{kind:"refuse",reason:i4}:null;let G={words:Z.words.slice(V.start,V.end),redirects:new Set([...Z.redirects].filter((j)=>j>=V.start&&j<V.end).map((j)=>j-V.start))},U=A0(G);for(let j of new Set([l(G),U??-1])){if(j<0)continue;let N=S2(G,j,$,J,Y,X+1);if(N)return N}}let H=Z.words.map((V,G)=>({word:V,at:G})).filter(({at:V})=>!Z.redirects.has(V)),K=H.findIndex(({at:V})=>V===z),B=K<0?null:fZ(H.map(({word:V})=>V.text),K,S);if(B&&!B.literal&&(hZ(Z,z,$,J.home)||hZ(Y.segment,Y.index,$,J.home)))return{kind:"refuse",reason:`\`${Q}\` runs a shell program that is not a plain literal (an expansion, a substitution, ANSI-C \`$'…'\` quoting or several words), so this hook cannot read what it would delete under a protected repository checkout. Write the program out literally, or run it from outside the checkout.`};let M=xZ(Z.words.map((V)=>S(V.text)),z,(V)=>V>=0&&V<Z.words.length&&(Z.redirects.has(V)||rZ(Z.words[V].text)));if(!M||!(hZ(Z,z,$,J.home)||hZ(Y.segment,Y.index,$,J.home)))return null;if(!M.unresolved&&!M.programs.some((V)=>a(V.text)))return null;return{kind:"refuse",reason:`\`${Q}\` runs a program locally (an interpreter's inline program or a command-running option) this hook cannot rewrite, and it could delete a file under a protected repository checkout. Run the delete directly as \`rm -- <path>\` (intercepted and redirected into trash), or run the command from outside the checkout.`}}var i4="This command nests find/xargs launchers too deeply for this hook to read what they run under a protected repository checkout. Run the inner command directly.";function hZ(Z,z,$,J){let Y=L0(J),X=(Q)=>Q!==null&&Y.some((H)=>JZ(Q,H));if(Y.some((Q)=>JZ($,Q)))return!0;for(let Q=z+1;Q<Z.words.length;Q++){if(Z.redirects.has(Q))continue;if(X(oZ(Z.words[Q].text,$,J)))return!0}return!1}function _Z(Z,z){let $={rmHits:[],handoffHits:[],refusals:[],protectedHits:[],trustworthy:!0},J=f(Z,v2);$.trustworthy=J.trustworthy;let Y={cwd:z.cwd,home:z.home,depth:z.depth??0,bodiesMention:a(J.segments.flatMap((K)=>K.heredocs??[]).join(`
25
+ `))};if(!J.trustworthy){let K=NZ(Z);return K===Z?$:{..._Z(K,z),trustworthy:!1}}let X=[],Q=(K,B=$.refusals)=>{if(K.kind==="refuse")B.push({reason:K.reason});else if(K.kind==="rm"&&K.handoff)$.handoffHits.push(K.hit);else if(K.kind==="rm"){if($.rmHits.push(K.hit),K.protectedReason)$.protectedHits.push({reason:K.protectedReason})}},H=Y.cwd;for(let K of J.segments){let B=l(K),M=A0(K),V=B<0?{kind:"none"}:C0(K,B,H,Y);if(V.kind!=="cd")Q(V);let G=(U)=>U!==null&&U>=0&&rZ(K.words[U].text);if(M===null||G(B)||G(M)){if(K.words.some((U,j)=>!K.redirects.has(j)&&(q0(C0(K,j,H,Y))||R4(U.text))))X.push({reason:l4})}else if(M>=0&&M!==B){let U=C0(K,M,H,Y);if(q0(U))if(q0(V))X.push({reason:c4});else Q(U,X)}if(V.kind==="cd")H=V.cwd}if(Y.depth<3)for(let K of J.substitutions){let B=_Z(K,{cwd:H,home:Y.home,depth:Y.depth+1});if(B.rmHits.length>0||B.refusals.length>0||B.handoffHits.length>0||B.protectedHits.length>0||!B.trustworthy&&a(K)){$.refusals.push({reason:"This command runs a delete inside a command substitution `$(…)`, which this hook cannot rewrite. Run the delete as a separate `rm -- <path>` command, which is redirected into trash."});break}}else if(J.substitutions.some((K)=>a(K)))$.refusals.push({reason:"This command nests a delete inside command substitutions deeper than this hook will follow. Run the delete as a separate `rm -- <path>` command."});return $.refusals.push(...X),$}function d4(Z){return Z.words.map((z)=>z.text).join(" ")}function y0(Z,z){let $=z+1;while($<Z.words.length){let J=E(Z.words[$].text);if(!J.startsWith("-"))return J;if($++,O4.has(J))$++}return null}function s4(Z,z){if(Z.words.slice(z+1).map((J)=>E(J.text)).includes("--cached"))return!0;return f2(Z,z)}function f2(Z,z){let $=Z.words.slice(z+1).map((J)=>E(J.text));return $.includes("-n")||$.includes("--dry-run")}function q2(Z){if(/^[A-Za-z0-9_\-./+=:,@%^]+$/.test(Z))return Z;return`'${Z.replace(/'/g,"'\\''")}'`}function n4(Z,z,$,J){let Y=J?["/usr/bin/env","-i",`HOME=${J.home}`,`PATH=${J.path}`,`HASNA_TRASH_AGENT=${J.agent}`,J.runtime,"--config=/dev/null","--no-env-file","--no-macros","--no-install",$,"guard"].map(q2).join(" "):`${q2($)} guard`,X=[...z].sort((H,K)=>K.word.start-H.word.start),Q=Z;for(let H of X)Q=`${Q.slice(0,H.word.start)}${Y}${Q.slice(H.word.end)}`;return Q}function o4(Z,z,$,J,Y){if(!z||z===Z)return!1;if($.length===0)return!1;let X=_Z(z,{cwd:J,home:Y});if(!X.trustworthy)return!1;if(X.rmHits.length>0||X.handoffHits.length>0)return!1;return X.refusals.length===0}function a4(Z,z){let $={};for(let[J,Y]of Object.entries(Z??{}))$[J]=Y;if($.command=z,typeof $.description!=="string"||$.description.trim()==="")$.description=W4;if(typeof $.timeout!=="number"||!Number.isFinite($.timeout)||$.timeout<=0)$.timeout=j4;if(typeof $.run_in_background!=="boolean")$.run_in_background=!1;if("dangerouslyDisableSandbox"in $&&typeof $.dangerouslyDisableSandbox!=="boolean")delete $.dangerouslyDisableSandbox;return $}function r4(Z,z,$,J,Y){if(typeof Z.command!=="string"||Z.command.trim()==="")return!1;if(typeof Z.description!=="string"||Z.description.trim()==="")return!1;if(typeof Z.timeout!=="number"||!Number.isFinite(Z.timeout)||Z.timeout<=0)return!1;if(typeof Z.run_in_background!=="boolean")return!1;if("dangerouslyDisableSandbox"in Z&&typeof Z.dangerouslyDisableSandbox!=="boolean")return!1;return o4(z,Z.command,$,J,Y)}function t4(Z){let z=new Set(["export","set","unset","readonly","declare","typeset","local","alias","unalias","read","readarray","mapfile","getopts","trap","enable","function","env","sudo","doas","stdbuf"]);return f(Z,v2).segments.some((J)=>{let Y=A0(J);return[l(J),...Y===null?[]:[Y]].some((X)=>{if(J.words.slice(0,X<0?J.words.length:X).some((K)=>y2.test(E(K.text))||z.has(FZ(K.text))))return!0;if(X<0)return!1;let H=J.words[X];return z.has(FZ(H.text))||/^\s*\(\s*\)\s*\{/.test(Z.slice(H.end))})})}function i(Z){return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:Z}}}function e4(Z){return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"allow",updatedInput:Z}}}function Z5(Z){try{if(Z.inspectTrash){let z=Z.inspectTrash();return z.ok?{path:z.path,error:null}:{path:null,error:`${z.code}: ${M2[z.code]}`}}return{path:Z.findTrash(),error:null}}catch(z){return{path:null,error:z instanceof Error?z.message:String(z)}}}var $5="[trash-guard] No verified @hasna/trash guard was found on PATH. This deletion is refused. Install the current @hasna/trash package with Bun and run its setup; the operating-system trash utility is not a compatible guard.",C2="[trash-guard] The rewrite of this command did not verify (the delete could not be redirected cleanly), so the command is refused rather than run unredirected. Re-run the delete as a plain `rm -- <path>` command.";function P2(Z,z){if(Z.refusals.length>0)return i(`[trash-guard] ${Z.refusals[0].reason}`);if(Z.protectedHits.length>0)return i(`[trash-guard] ${Z.protectedHits[0].reason}`);if(!Z.trustworthy)return a(z)?i("[trash-guard] This command could not be parsed to the end (unterminated quote, substitution or here-document), so a delete inside it cannot be redirected. Re-run the delete as a plain `rm -- <path>` command."):{continue:!0};if(Z.rmHits.length===0){if(Z.handoffHits.some(($)=>$.cwdOnly))return i("[trash-guard] This delete runs from inside a protected repository checkout but names only paths outside it. Run it from outside the checkout (`cd /tmp && rm -- <path>`), where it is redirected into trash.");return{continue:!0}}if(Z.handoffHits.length>0)return i("[trash-guard] This command mixes a delete under the protected repo-checkout roots (owned by workspace-repos-guard) with a delete outside them, and a partial rewrite would leave one of them unredirected. Re-run them as separate commands, so each delete is handled by the hook that owns it.");return null}function k2(Z,z){if(Z.hook_event_name!=="PreToolUse")return{continue:!0};if(["apply_patch","ApplyPatch","functions.apply_patch"].includes(Z.tool_name??"")){let j=Z.tool_input?.command;if(typeof j!=="string")return i("[trash-guard] Unreadable patch input; deletion safety cannot be checked.");if(/^\s*\*\*\* Delete File:/m.test(j))return i("[trash-guard] Delete File would bypass recoverable deletion. First use `trash put -- <path>` or the trash_put MCP tool, then submit any remaining edits without the deletion block.");return{continue:!0}}if(Z.tool_name!=="Bash")return{continue:!0};if(typeof Z.tool_input?.command!=="string")return i("[trash-guard] The Bash tool call carried no readable `command`, so this hook cannot verify what would run. Refusing a call it cannot verify. Re-run the delete explicitly as `rm -- <path>` so it can be redirected into trash.");let J=WZ(Z);if(!J.trim())return{continue:!0};let Y=()=>_Z(J,{cwd:z.cwd,home:z.home}),X=(j)=>j.rmHits.map((N)=>N.word.start).join(),Q=(j)=>j()||!!HZ(J,j),H=Y(),K=P2(H,J),B=HZ(J,()=>{let j=Y();return{result:j,verdict:P2(j,J)}});if(B){let{result:j,verdict:N}=B;if(N&&!("continue"in N))return N;if(!N&&(!K||("continue"in K))&&X(j)!==X(H))return i(C2)}if(K)return K;let M=Z5(z);if(M.error!==null)return i(`[trash-guard] The guard could not resolve the \`trash\` binary (${M.error}), so this \`rm\` cannot be redirected into a recoverable delete — and an unrecoverable delete is never allowed, so the command is refused rather than run. Fix the environment (PATH, permissions) and re-run the same command.`);if(M.path===null)return i($5);let V=M.path;if(z.execution&&Q(()=>t4(J)))return i("[trash-guard] A deletion combined with shell environment changes cannot use the verified native execution context. Run the deletion as a separate plain rm command.");let G=n4(J,H.rmHits,V,z.execution),U=a4(Z.tool_input,G);if(z.execution)U.hasna_execution="hasna.hooks.execution.v1";if(Q(()=>!r4(U,J,H.rmHits,z.cwd,z.home)))return i(C2);return e4(U)}var h=require("node:fs"),f0=require("node:os"),O=require("node:path");var J5=new Set(["Write","Edit","MultiEdit","NotebookEdit"]),z5=new Set(["apply_patch","ApplyPatch","functions.apply_patch"]),Y5=["hasna","hasnaxyz","hasna-products"],uZ="workspace-repos-guard";function X5(Z){return O.join(Z,".hasna","repos","clones")}function Q5(Z){return O.join(Z,"workspace","repos")}function i2(Z){return[X5(Z),Q5(Z)]}function K5(Z){return O.join(Z,".hasna","hooks","config","workspace-repos-guard-orgs")}var H5=/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/;function R0(Z){let z=process.getuid?.();return z!==void 0&&(Z.uid===0||Z.uid===z)&&(Z.mode&18)===0}function B5(Z){let z=K5(Z),$;try{let Y=h.openSync(z,h.constants.O_RDONLY|h.constants.O_NOFOLLOW);try{let Q=h.fstatSync(Y);if(!Q.isFile()||!R0(Q)||Q.size>4096)return null;$=h.readFileSync(Y,"utf8")}finally{h.closeSync(Y)}let X=O.normalize(Z);for(let Q=O.dirname(z);Q!==X;Q=O.dirname(Q)){let H=h.lstatSync(Q);if(!H.isDirectory()||!R0(H)||Q===O.dirname(Q))return null}if(!R0(h.statSync(X)))return null}catch{return null}let J=$.replace(/#[^\n]*/g,"").split(/[\s,]+/).filter(Boolean);return J.length>0&&J.every((Y)=>H5.test(Y))?new Set(J):null}function M5(Z=process.env,z=f0.homedir()){let $=Z.WORKSPACE_REPOS_GUARD_ORGS;if(typeof $==="string"&&$.trim())return new Set($.split(",").map((J)=>J.trim()).filter(Boolean));return B5(z)??new Set(Y5)}function v0(Z,z,$,J){if(J==="read")return{blocked:!1};let Y=O.relative(z,Z);if(Y===""){if(J==="delete")return{blocked:!0,reason:`[${uZ}] delete of the protected repo-checkout root is forbidden: ${z}`};return{blocked:!0,reason:`[${uZ}] writes directly to the protected repo-checkout root are forbidden: ${z}`}}if(Y.startsWith(`..${O.sep}`)||Y===".."||O.isAbsolute(Y))return{blocked:!1};let X=Y.split(O.sep).filter(Boolean);if(J==="delete")return{blocked:!0,reason:`[${uZ}] delete under the protected repo-checkout root (${z}) is forbidden at any depth: ${Z}`};if(X.length<=1)return{blocked:!0,reason:`[${uZ}] writing would create a top-level entry directly under the protected repo-checkout root (${z}); only GitHub-org folders belong there: ${Z}`};let Q=X[0];if(!$.has(Q))return{blocked:!0,reason:`[${uZ}] '${Q}' is not an allowed GitHub org under the protected repo-checkout root (${z}); allowed: ${[...$].join(", ")}: ${Z}`};return{blocked:!1}}var d2=/\b(?:-o|--output|-O|--output-document|-out)\b/,V5=/\d*[<>]&\s*(?:\d+|-)(?=$|[\s;&|)])/g,G5=/(?:\d+|&)?(?:>>|>\||>&|<>|>)\s*([^\s;&|<>()\x60]*)/g;function s2(Z){return Z.replace(V5," ")}function U5(Z){let z=[],$=null,J=0,Y=0,X=!1,Q=0;for(let H=0;H<Z.length;H++){let K=Z[H];if($==="'"){if(K==="'")$=null;continue}if(K==="\\"){H++;continue}if(K==="("){J++;continue}if(K===")"){if(--J<0)return[Z];continue}if(K==="$"&&Z[H+1]==="{"){Y++,H++;continue}if(K==="}"&&Y>0){Y--;continue}if(K==="`"){X=!X;continue}if($==='"'){if(K==='"')$=null;continue}if(K==="'"||K==='"'){$=K;continue}if(K!=="|"||J>0||Y>0||X||Z[H-1]===">")continue;if(z.push(Z.slice(Q,H)),Z[H+1]==="&")H++;Q=H+1}if($||J!==0||Y!==0||X)return[Z];return z.push(Z.slice(Q)),z}function j5(Z){let z=[],$="",J="",Y=null,X=!1,Q=()=>{if(!X)return;let H=J.replace(/^"?\$\{?HOME\}?"?(?=\/|$)/,""),K=$.startsWith("~")&&!/^~(?:\/|$)/.test(J);z.push({text:K?`./${$}`:$,opaque:/[$\x60*?[]/.test(H)||/[()]/.test(H)||sZ(J)}),$="",J="",X=!1};for(let H=0;H<Z.length;H++){let K=Z[H];if(Y==="'"){if(K==="'")Y=null;else $+=K;J+=K;continue}if(K==="\\"&&H+1<Z.length){let B=Z[H+1];$+=Y==='"'&&!/[$\x60"\\\n]/.test(B)?K+B:Y==='"'&&B===`
26
+ `&&!$Z.on?"":B,J+=K+B,X=!0,H++;continue}if(Y==='"'){if(K==='"')Y=null;else $+=K;J+=K;continue}if(/\s/.test(K)){Q();continue}if(X=!0,J+=K,K==="'"||K==='"')Y=K;else $+=K}if(Y)J+="$";return Q(),z}function b0(Z,z,$){let J=Z[z];return J==="--help"||J==="--version"||$&&(J==="-h"||J==="-V")}var x2={read:0,write:1,delete:2};function eZ(...Z){return Z.reduce((z,$)=>x2[$]>x2[z]?$:z,"read")}var W5=new Set(["status","doctor","list","info","get","pending","station","setup","backup","storage","retrieval","backup-storage","backup-inspect","backup-refresh","help"]),n2=new Set(["put","rm","delete","remove"]),N5=new Set([...n2,"restore","restore-capsule","recover","release","locks","retention","hold","unhold","pin","unpin","retrieve","backup-retrieve"]),o2=new Set(["-delete","-exec","-execdir","-ok","-okdir","-fls","-fprint","-fprint0","-fprintf"]);function k0(Z){let z=null;for(let $=0;$<Z.length;$++){let J=Z[$];if(z==="'"){if(J==="'")z=null;continue}if(J==="\\"){$++;continue}if(J==="$"||J==="`")return!0;if(z==='"'){if(J==='"')z=null;continue}if(J==="'"||J==='"')z=J;else if("*?[{".includes(J))return!0}return z!==null}function x0(Z){let z=Z.trim();if(!z)return"read";if($0(z))return"delete";let $=f(z);if(!$.trustworthy||$.substitutions.length||/\$\{[^}]*[|;()]|[<>]\(/.test(z))return MZ(z);let J=$.segments.flatMap((Y)=>{let X=h2(Y),Q=Y.words.filter((B,M)=>!Y.redirects.has(M)).map((B)=>B.text),H=Q.map(QZ);if(H.every((B,M)=>B!==null&&B.length===1&&B[0]===Q[M]))return[X];if(H.some((B)=>B===null))return[X,MZ(Q.join(" "))];let K=f(H.flatMap((B)=>B??[]).join(" "));return[X,...K.trustworthy?K.segments.map(h2):[MZ(Q.join(" "))]]});return eZ(...J)}function h2(Z){let z=Z.words.map((X,Q)=>({word:X,at:Q})).filter(({at:X})=>!Z.redirects.has(X)),$=l(Z),J=$<0?"read":w2(Z,$),Y=KZ(z.map(({word:X})=>h0(X.text)));if(Y===null)return eZ(J,MZ(z.map(({word:X})=>E(X.text)).join(" ")));if(Y.index<0||z[Y.index].at===$)return J;return eZ(J,w2(Z,z[Y.index].at))}function a2(Z,z,$=0){if(z<0||$>8)return $>8;let J=Z.words.map((B,M)=>({word:B,at:M})).filter(({at:B})=>!Z.redirects.has(B)),Y=J.findIndex(({at:B})=>B===z),X=Y<0?null:fZ(J.map(({word:B})=>B.text),Y,S);if(X){if(!X.literal)return!0;let B=f(X.program);if(B.trustworthy&&B.segments.some((M)=>Z0(M,$+1)))return!0}let Q=Z.words.map((B)=>S(B.text));for(let B of kZ(Q,z,(M)=>Z.redirects.has(M)))if(Z0(r2(Z,B.start,B.end),$+1))return!0;let K=xZ(Q,z,(B)=>B>=0&&B<Z.words.length&&(Z.redirects.has(B)||k0(Z.words[B].text)));if(!K)return!1;if(K.unresolved)return!0;return K.programs.some((B)=>B.kind==="shell"?x0(B.text)!=="read":!F2(B))}function r2(Z,z,$){let J=new Set([...Z.redirects].filter((Y)=>Y>=z&&Y<$).map((Y)=>Y-z));return{words:Z.words.slice(z,$),redirects:J}}function Z0(Z,z=0){return t2(Z).some(($)=>a2(Z,$,z))}function h0(Z){return{text:S(Z),opaque:/[$\x60]/.test(Z)&&!/^(?:[^$\x60"'\\]|\$'(?:[^'\\]|\\.)*')+$/.test(Z)}}function t2(Z){let z=new Set,$=l(Z);if($>=0)z.add($);let J=Z.words.map((X,Q)=>({word:X,at:Q})).filter(({at:X})=>!Z.redirects.has(X)),Y=KZ(J.map(({word:X})=>h0(X.text)));if(Y!==null&&Y.index>=0)z.add(J[Y.index].at);return[...z]}function lZ(Z,z=0){if(z>8)return[];let $=[];for(let J of Z.segments){let Y=J.words.map((H)=>S(H.text)),X=(H)=>H>=0&&H<J.words.length&&(J.redirects.has(H)||k0(J.words[H].text)),Q=J.words.filter((H,K)=>!J.redirects.has(K));for(let H of t2(J)){$.push(...(xZ(Y,H,X)?.writes??[]).map((M)=>M[0]==="/"?M:`./${M}`));let K=fZ(Q.map((M)=>M.text),Q.indexOf(J.words[H]),S),B=K?.literal?f(K.program):null;if(B?.trustworthy)$.push(...lZ(B,z+1));for(let M of kZ(Y,H,(V)=>J.redirects.has(V)))$.push(...lZ({segments:[r2(J,M.start,M.end)]},z+1))}}for(let J of Z.substitutions??[]){let Y=f(J);if(Y.trustworthy)$.push(...lZ(Y,z+1))}return $}function $0(Z,z=0){if(z>4)return!1;let $=f(Z),J=$.trustworthy?Z:NZ(Z);if(J!==Z)return $0(J,z+1);if($.trustworthy&&$.segments.some((X)=>Z0(X)))return!0;return($3(Z)??$.substitutions).some((X)=>$0(X,z+1))}function w2(Z,z){if(a2(Z,z))return"delete";let $=Z.words.filter((X,Q)=>Q>=z&&!Z.redirects.has(Q)),J=$.map((X)=>S(X.text)),Y=J[0].split("/").pop();if(["rm","rmdir","shred"].includes(Y??""))return b0(J,1,!1)?"read":"delete";if(["unlink","rmtree","del"].includes(Y??""))return"delete";if(Y==="trash"){let X=1;while(X<J.length&&J[X].startsWith("-")){let Q=J[X++];if(["--help","-h","--version","-V","--identity"].includes(Q))return"read";if(["--agent","--spool","--files","--info","--config"].includes(Q))X++;else if(!["--json","--local"].includes(Q))return"delete"}if(X===J.length||W5.has(J[X]))return"read";if(N5.has(J[X])&&b0(J,X+1,!0))return"read";if(["restore","restore-capsule"].includes(J[X]))return"write";return"delete"}if(Y==="git"){let X=y0(Z,z);if(X==="clean"||X==="rm")return J[1]===X&&b0(J,2,!0)?"read":"delete";return X==="clone"||X==="init"?"write":"read"}if(Y==="find"&&!$.some((X)=>k0(X.text))&&!J.some((X)=>o2.has(X)))return"read";if(Y==="env"&&a(wZ(J)))return"delete";if(["sh","bash","zsh","dash","ksh","ash","mksh","eval","source",".","su","runuser","env","xargs","find","busybox","toybox"].includes(Y??""))return MZ(J.join(" "));if(["mkdir","mkfile","touch","mv","cp","ln","tee","install","dd","rsync","scp","truncate"].includes(Y??""))return"write";if(Y==="curl"||Y==="wget")return d2.test(J.join(" "))?"write":"read";if(Y==="sed"&&J.slice(1).some((X)=>/^-i|^--in-place(?:=|$)/.test(X)))return"write";if(["python","python3","node","bun"].includes(Y??"")&&J.some((X)=>X==="-c"||X==="-e"))return"write";return"read"}function MZ(Z){let z=Z.replace(/[{},]/g," ");return z===Z?E0(Z):eZ(E0(Z),E0(z))}function E0(Z){let z=Z.trim();if(!z)return"read";if(/(?:^|\s)\\?(?:[^\s;&|<>()]*\/)?(?:rm|rmdir|unlink|shred|trash|rmtree|del)(?:\s|$)/.test(z))return"delete";if(/\bgit\b/.test(z)){if(/\bgit\b[^;&|]*\b(?:clean|rm)\b/.test(z))return"delete";if(/\bgit\b[^;&|]*\b(?:clone|init)\b/.test(z))return"write";return"read"}if(/(?:^|\s)\\?(?:[^\s;&|<>()]*\/)?(?:mkdir|mkfile|touch|mv|cp|ln|tee|install|dd)(?:\s|$)/.test(z))return"write";if(/\b(?:curl|wget)\b/.test(z)){if(d2.test(z))return"write";return"read"}if(/\bsed\b/.test(z)){if(/(?:^|\s)-i\S*(?:\s|$)|--in-place(?:\s|$)/.test(z))return"write"}else if(/\b(?:rsync|scp|truncate)\b/.test(z))return"write";else if(/(?:^|\s)(?:python3?|node|bun)\b[^;&|]*\s+-[ce](?:\s|$)/.test(z))return"write";if(/(?:^|[;&|])\s*echo\b/.test(z)||/>/.test(s2(z)))return"write";return"read"}function mZ(Z,z){let $=Z.trim(),J=$.match(/^(['"])([\s\S]*)\1$/);if(J)$=J[2];if($=$.replace(/^"*\$HOME"*\//,"$HOME/"),$=$.replace(/^"*\$\{HOME\}"*\//,"${HOME}/"),$==="~")return z;if($.startsWith("~/"))return O.join(z,$.slice(2));if($==="$HOME"||$==="${HOME}")return z;if($.startsWith("$HOME/"))return O.join(z,$.slice(6));if($.startsWith("${HOME}/"))return O.join(z,$.slice(8));let Y=$.match(new RegExp(`^"*${S0(z)}"*/`));if(Y)return z+"/"+$.slice(Y[0].length);return Z}function F5(Z){let z=Z.trim();while(z.startsWith("(")||/^\{(?:\s|$)/.test(z))z=z.slice(1).trim();while(z.endsWith(")")||/(?:^|\s)\}$/.test(z))z=z.slice(0,-1).trim();return z}function S0(Z){return Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function g2(Z,z,$){if(Z===void 0)return[$];let J=mZ(Z,$),Y=J.match(/^(['"])(.*)\1$/);if(Y)J=Y[2];if(!J||J==="-"||/[$\x60*?[\]{}~\\'"]/.test(J))return null;return[...new Set(z.map((X)=>O.resolve(X,J)))]}var _5=/(?:^|\s)(\.\.?|[^\s"';&|<>()\x60/]+(?:\/[^\s"';&|<>()\x60]*)?)\s*$/;function D5(Z,z){let $=KZ(z);if(!$||$.index<=0||z[$.index].opaque)return 0;let J=f(Z);if(!J.trustworthy||J.substitutions.length>0||J.segments.length!==1)return 0;let[Y]=J.segments;if(Y.redirects.size>0||Y.words.length!==z.length)return 0;if(Y.words.some((X,Q)=>E(X.text)!==z[Q].text))return 0;return l(Y)===$.index?$.index:0}function I5(Z,z){let $=0;if(Z==="git")$=z.findIndex((Y)=>Y.text==="rm"||Y.text==="clean")+1;let J=!1;return z.slice($).filter((Y)=>{if(!J&&Y.text==="--")return J=!0,!1;if(!J&&Y.text.startsWith("-")&&!Y.opaque)return!1;return J=!0,!0})}var T5=new Set(["--agent","--spool","--files","--info","--config"]),q5=new Set(["--spool","--files","--info","--config"]),C5=new Set(["--json","--local","--help","-h","--version","--identity"]),u2={"--agent":/^[^-]/,"--retention":/^(?:\d+(?:\.\d+)?|never)$/},P5=new Set(["--to"]);function O5(Z){let z=[],$=0;for(;$<Z.length&&Z[$].text.startsWith("-");$++){let X=Z[$];if(X.opaque)return null;if(T5.has(X.text)){let Q=Z[++$];if(!Q||Q.opaque)return null;if(q5.has(X.text))z.push(Q)}else if(!C5.has(X.text))return null}let J=Z[$];if(!J||J.opaque||!n2.has(J.text))return null;let Y=!1;for($++;$<Z.length;$++){let X=Z[$];if(Y||X.opaque||X.text==="-"||!X.text.startsWith("-")){z.push(X);continue}if(X.text==="--"){Y=!0;continue}let Q=X.text.indexOf("="),H=Q<0?X.text:X.text.slice(0,Q);if(P5.has(H)){if(Q>=0)z.push({text:X.text.slice(Q+1),opaque:!1});else if(Z[$+1]&&!Z[$+1].text.startsWith("-"))z.push(Z[++$]);continue}let K=Z[$+1];if(Q<0&&Object.hasOwn(u2,H)&&K&&!K.opaque&&u2[H].test(K.text))$++}return z}function L5(Z){let z=Z.split(`
27
+ `),$=[],J=[],Y=0;while(Y<z.length){let X=Y,Q=z[Y++].replace(/\r$/,""),H=[];for(let K=0;K<Q.length;K++){let B=Q[K],M=J[J.length-1];if(B==="\\"){K++;continue}if(B==="$"&&Q[K+1]==="("&&Q[K+2]==="("){let V=Q.indexOf("))",K+3);if(V<0)return null;K=V+1;continue}if(B==="$"&&Q[K+1]==="("){J.push(0),K++;continue}if(B==="$"&&Q[K+1]==="[")return null;if(B==="$"&&Q[K+1]==="{"){let V=Q.indexOf("}",K+2);if(V<0||/['"\x60$]|<</.test(Q.slice(K+2,V)))return null;K=V;continue}if(B==="`"){let V=Q.indexOf("`",K+1);if(V<0)return null;K=V;continue}if(M==='"'){if(B==='"')J.pop();continue}if(B==="'"){let V=Q.indexOf("'",K+1);if(V<0)return null;K=V;continue}if(B==='"'){J.push('"');continue}if(B==="#"&&(K===0||/[\s;&|()]/.test(Q[K-1])))break;if(B==="("&&Q[K+1]==="("&&(K===0||/[\s;&|(]/.test(Q[K-1]))){let V=Q.indexOf("))",K+2);if(V<0)return null;K=V+1;continue}if(typeof M==="number"&&(B==="("||B===")")){if(B==="(")J[J.length-1]=M+1;else if(M===0)J.pop();else J[J.length-1]=M-1;continue}if(B==="<"&&Q[K+1]==="<"){if(Q[K+2]==="<"){K+=2;continue}let V=DZ(Q,K);if(!V)return null;H.push({marker:V,from:K}),K=V.end-1}}for(let{marker:K,from:B}of H){let M=Y;for(;;){if(Y>=z.length)return null;let V=z[Y++].replace(/\r$/,"");if(K.stripTabs)V=V.replace(/^\t+/,"");if(V===K.delimiter)break}$.push({line:X,from:B,to:K.end,start:M,end:Y-1,quoted:K.quoted})}}return J.length===0?$:null}var A5=new Set(["sh","bash","zsh","dash","ksh","mksh","ash","fish","csh","tcsh","nu","xonsh","elvish","busybox","toybox","ssh","su","runuser","sudo","doas","pkexec","xargs","parallel","expect","script","at","batch","crontab","watch","flock","chroot","nsenter","unshare","docker","podman","kubectl","lxc","python","pypy","node","nodejs","bun","deno","tsx","ts-node","zx","npx","bunx","pnpx","perl","ruby","irb","php","lua","luajit","osascript","pwsh","powershell","Rscript","R","julia","tclsh","wish","awk","gawk","mawk","nawk","sed","make","gmake","gdb","lldb","sqlite3","psql","mysql","sftp","ftp","lftp","vim","vi","nvim","ex","ed","emacs","chmod"]),y5=new Set([".","source","eval","env","alias","hash"]),R5=new Set(["tee","cp","mv","install","ln"]),e2=new Set(["cat","tac","tee","head","tail","wc","cut","tr","nl","rev","fold","fmt","paste","uniq","grep","egrep","fgrep","jq","diff","cmp","comm","iconv","od","xxd","hexdump","base64","base32","md5sum","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","b2sum","cksum","echo","printf","true","false",":","test","[","read","cd","pwd","ls","mkdir","touch","stat","sleep","cp","mv","ln","rm","rmdir","unlink","shred","trash","todos","conversations","mementos","knowledge","files","asks"]),v5=new Set(["add","commit","tag","notes","status","diff","log","show","rev-parse","branch","switch","push","fetch","hash-object","apply"]),b5=new Set(["pr","issue","api","release","gist"]);function E5(Z,z){let $=Z[z];if($==="gh")return b5.has(Z[z+1]??"");if($!=="git")return e2.has($);for(let J=z+1;J<Z.length;J++){let Y=Z[J];if(Y==="-C")J++;else if(Y==="--no-pager"||Y==="-P")continue;else return!Y.startsWith("-")&&v5.has(Y)}return!1}function S5(Z,z){for(let $=z+1;$<Z.length;$++){let J=Z[$];if(J==="\\")$++;else if(J==='"')return $;else if(J==="$"&&Z[$+1]==="("){if($=Z3(Z,$+1),$<0)return-1}else if(J==="`"){if($=Z.indexOf("`",$+1),$<0)return-1}}return-1}function Z3(Z,z){let $=0;for(let J=z;J<Z.length;J++){let Y=Z[J];if(Y==="\\")J++;else if(Y==="'"||Y==="`"){if(J=Z.indexOf(Y,J+1),J<0)return-1}else if(Y==='"'){if(J=S5(Z,J),J<0)return-1}else if(Y==="(")$++;else if(Y===")"&&--$===0)return J}return-1}function $3(Z){let z=[],$=!1;for(let J=0;J<Z.length;J++){let Y=Z[J];if(Y==="\\")J++;else if(Y==="'"&&!$){let X=Z.indexOf("'",J+1);if(X<0)return null;J=X}else if(Y==='"')$=!$;else if(Y==="$"&&Z[J+1]==="("){let X=Z3(Z,J+1);if(X<0)return null;let Q=Z.slice(J+2,X);if(Z[J+2]==="("){if(/\$\(|\x60/.test(Q))return null}else z.push(Q);J=X}else if(Y==="`"){let X=Z.indexOf("`",J+1);if(X<0)return null;z.push(Z.slice(J+1,X)),J=X}}return $?null:z}function f5(Z){if(/[<>]\(/.test(Z))return!0;let z=[],$=[Z];for(let Y=0;$.length>0;Y++){if(Y>64)return!0;let X=$.shift(),Q=f(X),H=$3(X);if(!Q.trustworthy||!H)return!0;z.push(...Q.segments),$.push(...new Set([...Q.substitutions,...H]))}let J=new Set;for(let Y of z){let X=Y.words.map((K)=>E(K.text));for(let K of Y.redirects)J.add(o(X[K]??""));let Q=l(Y);if(Q<0)continue;let H=o(X[Q]);if(R5.has(H)){for(let K of X.slice(Q+1))if(!K.startsWith("-"))J.add(o(K))}if(H==="dd"){for(let K of X)if(K.startsWith("of="))J.add(o(K.slice(3)))}}J.delete("");for(let Y of z){for(let B of Y.words){let M=o(E(B.text));if(A5.has(M)||/^(?:python|pypy|node|perl|ruby|php|lua)[0-9.]+$/.test(M))return!0}let X=l(Y),Q=Y.words.map((B,M)=>({text:E(B.text),at:M})).filter(({at:B})=>!Y.redirects.has(B));if(Q.some(({text:B,at:M})=>(X<0||M<X)&&bZ.test(B)))return!0;if(X<0)continue;let H=Y.words[X].text,K=E(H);if(/[$\x60]/.test(H)||K.includes("/")||y5.has(K)||J.has(K))return!0;if(!E5(Q.filter(({at:B})=>B>=X).map(({text:B})=>B),0))return!0}return!1}function k5(Z){if(!Z.includes("<<"))return null;let z=L5(Z);if(!z||z.length===0)return null;let $=Z.split(`
28
+ `),J=[...$],Y=[];for(let Q of z){let H=$.slice(Q.start,Q.end);if(!Q.quoted&&H.some((K)=>/\$\(|\x60/.test(K)))return null;Y.push(H.join(`
29
+ `));for(let K=Q.start;K<=Q.end;K++)J[K]=""}let X=[...J];for(let Q of[...z].reverse()){let H=X[Q.line];X[Q.line]=H.slice(0,Q.from)+" ".repeat(Q.to-Q.from)+H.slice(Q.to)}return f5(X.join(`
27
30
  `))?null:{outer:J.join(`
28
- `),bodies:Y}}var b5="/";function b0(Z,z,$){if(!Z)return[];let J=S(Z).trustworthy?Z:jZ(Z),Y=v5(Z);return[...J===Z?[]:b0(J,z,$),...Y?[...g2(Y.outer,z,$),...Y.bodies.flatMap((Q)=>b0(Q,z,b5))]:g2(Z,z,$)]}var E5=/(\s*&&\s*|\s*\|\|\s*|;\s*|\n+)/,S5=/^(?:'[^']*'|"[^"$\x60\\]*")$/;function x2(Z,z,$=!1){let J=[],Y=0;for(let H of z)J.push(Y),Y+=H.length;let Q=S(Z);if(!Q.trustworthy||!$&&Q.substitutions.length>0)return null;let X=Q.segments.flatMap((H)=>H.words).filter((H)=>z.some((K,B)=>B%2===1&&J[B]<H.end&&J[B]+K.length>H.start));return X.length>0?{lexed:Q,offsets:J,words:X}:null}function h2(Z,z,$=[]){if(f0(z)!=="read")return!1;let J=u(Z),Y=Z.words.filter((M,V)=>!Z.redirects.has(V)),Q=XZ(Y.map((M)=>k0(M.text)));if(Q===null)return!1;let X=[J<0?1/0:J,Q.index<0?1/0:Z.words.indexOf(Y[Q.index])];if(Z.words.some((M,V)=>V<Math.max(...X)&&!Z.redirects.has(V)&&RZ.test(b(M.text))))return!1;if([J<0?null:Z.words[J].text,Q.index<0?null:Y[Q.index].text].every((M)=>M===null||n2.has(a(b(M)))))return!0;let K=Y.filter((M)=>!$.includes(M)),B=K.map((M)=>b(M.text));return HZ(K.map((M)=>M.text).join(" "))==="read"&&HZ(B.join(" "))==="read"&&!B.some((M)=>c2.has(M))}function f5(Z,z,$,J){let Y=(Q)=>Q.start<J&&Q.end>$;if(!z.words.some(Y))return!1;return z.lexed.segments.filter((Q)=>Q.words.some(Y)).some((Q)=>tZ(Q))}var w2=(Z,z)=>Z.slice(z.words[0].start,z.words[z.words.length-1].end);function k5(Z,z,$,J){let Y=(X)=>X.start<J&&X.end>$,Q=z.words.filter(Y);if(Q.length===0||Q.some((X)=>!S5.test(X.text)))return!1;for(let X of z.lexed.segments.filter((H)=>H.words.some(Y)))if(!h2(X,w2(Z,X),z.words))return!1;for(let X of Q){let H=X.text.slice(1,-1);if(H.includes("<<"))return!1;let K=S(H);if(!K.trustworthy||K.substitutions.length>0)return!1;if(!K.segments.every((B)=>h2(B,w2(H,B))))return!1}return!0}function g2(Z,z,$){if(!Z)return[];let J=l2(z),Y=(U)=>J.some((W)=>U===W||U.startsWith(`${W}${O.sep}`)),Q=Z.split(E5),X=x2(Z,Q),H=X??x2(Z,Q,!0),K=[],B=[$],M=new Set([$]),V=!0,G=[];for(let U=0;U<Q.length;U+=2){let W=U===0?"":Q[U-1].trim();if(W==="||")V=!1;else if(W!=="&&")V=!0;if(W!=="&&"||!V)B=[...M];let N=Q[U],R=(N.match(/^[\s({]*/)?.[0].match(/\(/g)??[]).length,f=(N.match(/[\s)}]*$/)?.[0].match(/\)/g)??[]).length;for(let _=0;_<R;_++)G.push({current:[...B],reachable:new Set(M),certain:V});let k=G5(N),i=X!==null&&k5(Z,X,X.offsets[U],X.offsets[U]+N.length),q=!i&&(H!==null&&f5(Z,H,H.offsets[U],H.offsets[U]+N.length)||eZ(N.trim())),F=k.match(/^cd(?:\s+(?:-[A-Za-z@]+|--))*(?:\s+([^\s;&|<>()\x60]+))?$/),A=F?null:k.match(/(?:^|\s)cd(?:\s+(?:-[A-Za-z]+|--))*\s+([^\s;&|<>()\x60]+)/);if(A){for(let _ of f2(A[1],B,z)??[])M.add(_);V=!1,B=[...M]}let m=v0(z),p=J.map((_)=>v0(_.slice(z.length+1))).join("|"),IZ=new RegExp(`(?:~|\\$HOME"*|\\$\\{HOME\\}"*|${m}"*)/(?:${p})`),$2=new RegExp(`(${IZ.source})([^\\s"';&|<>()\`]*|$)`,"g"),J2=(_)=>{let g=[],c;$2.lastIndex=0;while((c=$2.exec(_))!==null)g.push(O.normalize(lZ(c[0],z)).replace(/\/+$/,""));return g},z2=H===null?0:H.offsets[U],Y2=(_)=>_.start<z2+N.length&&_.end>z2,N3=H!==null&&H.words.some(Y2)?gZ({segments:H.lexed.segments.filter((_)=>_.words.some(Y2))}):[N.trim(),k].flatMap((_)=>{let g=S(_);if(!g.trustworthy)g=S(jZ(_));return g.trustworthy?gZ(g):[]}),H0=H5(k).map((_,g)=>{let c=g===0?[...new Set(N3)]:[],TZ=!1,qZ=m2(_).replace(K5,(M0,VZ)=>{if(!VZ||/[$\x60]/.test(VZ))TZ=!0;if(VZ)c.push(VZ);return" "}),CZ=i?"read":q?"delete":f0(qZ);return{commandPart:qZ,operands:c,op:TZ&&CZ==="read"?"write":CZ}}),F3=H0.some((_)=>_.op==="delete")?"delete":H0.some((_)=>_.op==="write")?"write":"read",B0=B.filter(Y);if(q)for(let _ of B0)K.push({path:_,op:"delete"});for(let _ of H0){let g=!1;for(let l of J2(_.commandPart))g=!0,K.push({path:l,op:F3});for(let l of _.operands){let e=J2(l);for(let n of e)K.push({path:n,op:"write"});if(e.length>0)continue;for(let n of B0)K.push({path:O.normalize(O.resolve(n,lZ(l,z))),op:"write"})}if(g||_.op==="read")continue;let c=B5(_.commandPart),TZ=j5(_.commandPart,c),qZ=a(c[TZ]?.text??""),CZ=c.slice(TZ+1),M0=((qZ==="trash"?I5(CZ):null)??W5(qZ,CZ)).map((l)=>l.opaque?".":l.text),VZ=_.op==="delete"||/(?:^|\s)\\?(?:[^\s;&|<>()]*\/)?(?:mkdir|mkfile|touch|tee|truncate|install|mv)(?:\s|$)/.test(_.commandPart)||/(?:^|\s)sed(?:\s|$)/.test(_.commandPart)&&/(?:^|\s)(?:-i\S*|--in-place\S*)(?:\s|$)/.test(_.commandPart),PZ=[];if(VZ)for(let l of M0.length>0?M0:["."])PZ.push({operand:l,op:_.op});else{let l=_.commandPart.match(U5),e=c.at(-1);if(PZ.push({operand:l?l[1]:!e||e.opaque?".":e.text,op:_.op}),/(?:^|\s)(?:cp|ln|install|mv)(?:\s|$)/.test(_.commandPart))c.forEach((n,Q2)=>{let GZ,V0=n.text.match(/^-[A-Za-z]*?t(.*)$/),mZ=n.text.match(/^(--t[a-z-]*)(?:=(.*))?$/);if(V0&&!n.text.startsWith("--"))GZ=V0[1]?{text:V0[1],opaque:n.opaque}:c[Q2+1];else if(mZ&&"--target-directory".startsWith(mZ[1]))GZ=mZ[2]!==void 0?{text:mZ[2],opaque:n.opaque}:c[Q2+1];if(GZ)PZ.push({operand:GZ.opaque||!GZ.text?".":GZ.text,op:_.op})});if(/(?:^|\s)(?:python3?|node|bun)\b[^;&|]*\s+-[ce](?:\s|$)/.test(_.commandPart))PZ.push({operand:".",op:_.op})}for(let l of B0)for(let{operand:e,op:n}of PZ)K.push({path:O.normalize(O.resolve(l,lZ(e,z))),op:n})}if(F){let _=f2(F[1],B,z);if(_){for(let g of _)M.add(g);if(V)B=_}else V=!1}for(let _=0;_<f&&G.length>0;_++)({current:B,reachable:M,certain:V}=G.pop())}return K}var x5=/^\s*\*\*\*\s+(Add File|Update File|Delete File):\s+(\S+)\s*$/gm;function h5(Z,z){let $=[],J;while((J=x5.exec(Z))!==null){let Y=J[1]==="Delete File"?"delete":"write";$.push({path:O.normalize(O.resolve(z,J[2])),op:Y})}return $}function r2(Z,z={}){let $=[];if(Z.hook_event_name!=="PreToolUse")return{output:{continue:!0},warnings:$};let J=typeof Z.tool_name==="string"?Z.tool_name:"",Y=z.home??E0.homedir(),Q=l2(Y),X=Q5(process.env,Y);if(J==="Bash"){let G=UZ(Z);if(!G)return{output:{continue:!0},warnings:$};let U=typeof Z.cwd==="string"&&Z.cwd?Z.cwd:process.cwd(),W=b0(G,Y,U);for(let N of W)for(let R of Q){let f=y0(N.path,R,X,N.op);if(f.blocked)return{output:{decision:"block",reason:f.reason},warnings:$}}return{output:{continue:!0},warnings:$}}let H=Z.tool_input??{},K=typeof Z.cwd==="string"&&Z.cwd?Z.cwd:process.cwd();if(t4.has(J)){let G=typeof H.patch==="string"?H.patch:"";if(!G)return{output:{continue:!0},warnings:$};let U=h5(G,K);for(let W of U)for(let N of Q){let R=y0(W.path,N,X,W.op);if(R.blocked)return{output:{decision:"block",reason:R.reason},warnings:$}}return{output:{continue:!0},warnings:$}}if(!r4.has(J))return{output:{continue:!0},warnings:$};let B=typeof H.file_path==="string"?H.file_path:typeof H.path==="string"?H.path:typeof H.notebook_path==="string"?H.notebook_path:null;if(!B)return{output:{continue:!0},warnings:$};let M=lZ(B,Y),V=O.isAbsolute(M)?O.normalize(M):O.resolve(K,M);for(let G of Q){let U=y0(V,G,X,"write");if(U.blocked)return{output:{decision:"block",reason:U.reason},warnings:$}}return{output:{continue:!0},warnings:$}}var w5=new Set(["id","node_id","databaseId","fullDatabaseId","number","state","state_reason","stateReason","status","conclusion","bucket","name","login","sha","oid","abbreviatedOid","ref","headRefName","baseRefName","headRefOid","baseRefOid","head_sha","headSha","head_branch","headBranch","merged","mergeable","mergeable_state","mergeStateStatus","draft","isDraft","locked","isLocked","title","displayTitle","display_title","created_at","updated_at","closed_at","merged_at","started_at","completed_at","submitted_at","pushed_at","published_at","createdAt","updatedAt","closedAt","mergedAt","startedAt","completedAt","submittedAt","pushedAt","publishedAt","tag_name","tagName","total_count","totalCount","count","additions","deletions","changes","changed_files","changedFiles","filename","path","event","workflow","workflowName","workflow_id","workflowDatabaseId","run_id","run_number","run_attempt","attempt","check_suite_id","default_branch","defaultBranch","full_name","fullName","nameWithOwner","private","isPrivate","visibility","archived","isArchived","fork","isFork","isRequired","is_required","required","context","type","__typename","role","permission","size","reviewDecision","author_association","authorAssociation","isCrossRepository","maintainerCanModify","maintainer_can_modify","commentsCount","language","digest","size_in_bytes","run_started_at","date","wait_timer","ahead_by","behind_by","total_commits","expired","current_user_can_approve","environment","html_url"]),g5=new Set(["payload","client_payload","inputs","config","metadata","output","properties","custom_properties","variables"]),$3=new Set(["length","utf8bytelength","not","type","any","all","isempty","empty","test","startswith","endswith","contains","inside","has","in","index","rindex","indices","floor","ceil","round","fabs","sqrt","isinfinite","isnan","isnormal","infinite","nan","true","false","null"]),J3=new Set(["tostring","tojson","ascii_downcase","ascii_upcase","ltrimstr","rtrimstr","trim","ltrim","rtrim","sort","unique","reverse","first","last","min","max","add","flatten","join","split","values","nulls","strings","numbers","booleans","arrays","objects","iterables","scalars","sort_by","group_by","unique_by","min_by","max_by","select","limit","to_entries","from_entries"]),l5=new Set(["test","startswith","endswith","contains","inside","has","in","index","rindex","indices","ltrimstr","rtrimstr","join","split","flatten","limit"]),u5=new Set(["@text","@json","@csv","@tsv","@sh","@base64","@uri","@html"]);class w0 extends Error{}var L=()=>{throw new w0};function x0(Z,z){let $=[],J="",Y=z+1;while(Y<Z.length){let Q=Z[Y];if(Q==='"'){if(J)$.push(J);return{end:Y+1,parts:$}}if(Q==="\\"){let X=Z[Y+1];if(X==="("){let H=1,K=Y+2;while(K<Z.length&&H>0){let B=Z[K];if(B==='"'){K=x0(Z,K).end;continue}if(B==="(")H++;else if(B===")")H--;K++}if(H!==0)L();if(J)$.push(J),J="";$.push({src:Z.slice(Y+2,K-1)}),Y=K;continue}if(X===void 0)L();J+=X,Y+=2;continue}J+=Q,Y++}return L()}function z3(Z){let z=[],$=0,J=["?//","|=","+=","-=","*=","/=","%=","//=","==","!=","<=",">=","//","|",",","+","-","*","/","%","<",">","=","(",")","[","]","{","}",":",";","?"];while($<Z.length){let Y=Z[$];if(/\s/.test(Y)){$++;continue}if(Y==="#")L();if(Y==='"'){let K=x0(Z,$);z.push({t:"str",parts:K.parts}),$=K.end;continue}if(Y==="."){if(Z[$+1]===".")L();let K=/^[A-Za-z_][A-Za-z0-9_]*/.exec(Z.slice($+1));if(K){z.push({t:"field",name:K[0]}),$+=1+K[0].length;continue}if(Z[$+1]==='"'){let B=x0(Z,$+1);if(B.parts.some((M)=>typeof M!=="string"))L();z.push({t:"field",name:B.parts.join("")}),$=B.end;continue}z.push({t:"dot"}),$++;continue}if(Y==="$"||Y==="@"){let K=/^[@$][A-Za-z_][A-Za-z0-9_]*/.exec(Z.slice($));if(!K||Y==="$")L();z.push({t:"fmt",name:K[0]}),$+=K[0].length;continue}let Q=/^[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/.exec(Z.slice($));if(Q){z.push({t:"num"}),$+=Q[0].length;continue}let X=/^[A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*/.exec(Z.slice($));if(X){z.push({t:"ident",name:X[0]}),$+=X[0].length;continue}let H=J.find((K)=>Z.startsWith(K,$));if(!H)L();z.push({t:"op",v:H}),$+=H.length}return z}var m5=new Set(["if","then","elif","else","end","as","def","reduce","foreach","try","catch","label","import","include","and","or","__loc__","error","input","inputs","debug","stderr","env","halt","halt_error","input_filename","input_line_number","recurse","paths","leaf_paths","getpath","setpath","delpaths","del","path","splits","sub","gsub","capture","match","scan","keys","keys_unsorted","map_values","with_entries","tostream","fromstream","truncate_stream","walk","tonumber","implode","explode","ascii","fromjson"]);class g0{tokens;at=0;constructor(Z){this.tokens=Z}parse(){if(this.tokens.length===0)L();let Z=this.pipe();if(this.at!==this.tokens.length)L();return Z}peek(){return this.tokens[this.at]}isOp(Z){let z=this.peek();return!!z&&z.t==="op"&&z.v===Z}isIdent(Z){let z=this.peek();return!!z&&z.t==="ident"&&z.name===Z}expectOp(Z){if(!this.isOp(Z))L();this.at++}pipe(){let Z=this.comma();if(this.isIdent("as"))L();if(this.isOp("|"))this.at++,Z={k:"pipe",a:Z,b:this.pipe()};return Z}comma(){let Z=this.alt();while(this.isOp(","))this.at++,Z={k:"comma",a:Z,b:this.alt()};return Z}alt(){let Z=this.or();if(this.isOp("//"))return this.at++,{k:"alt",a:Z,b:this.alt()};return Z}or(){let Z=this.and();while(this.isIdent("or"))this.at++,Z={k:"bool",a:Z,b:this.and()};return Z}and(){let Z=this.cmp();while(this.isIdent("and"))this.at++,Z={k:"bool",a:Z,b:this.cmp()};return Z}cmp(){let Z=this.add();for(let z of["==","!=","<=",">=","<",">"])if(this.isOp(z))return this.at++,{k:"bool",a:Z,b:this.add()};for(let z of["=","|=","+=","-=","*=","/=","%=","//=","?//"])if(this.isOp(z))L();return Z}add(){let Z=this.mul();while(this.isOp("+")||this.isOp("-"))this.at++,Z={k:"arith",a:Z,b:this.mul()};return Z}mul(){let Z=this.unary();while(this.isOp("*")||this.isOp("/")||this.isOp("%"))this.at++,Z={k:"arith",a:Z,b:this.unary()};return Z}unary(){if(this.isOp("-"))return this.at++,{k:"neg",of:this.postfix()};return this.postfix()}objectValue(){let Z=this.unary();if(this.isOp("|"))this.at++,Z={k:"pipe",a:Z,b:this.objectValue()};return Z}postfix(){let Z=this.primary();for(;;){let z=this.peek();if(!z)return Z;if(z.t==="field"){this.at++,Z={k:"field",name:z.name,of:Z};continue}if(z.t==="dot"&&this.tokens[this.at+1]?.t==="op"&&this.tokens[this.at+1].v==="["){this.at++;continue}if(z.t==="op"&&z.v==="?"){this.at++,Z={k:"opt",of:Z};continue}if(z.t==="op"&&z.v==="["){Z=this.bracket(Z);continue}return Z}}bracket(Z){if(this.expectOp("["),this.isOp("]"))return this.at++,{k:"iter",of:Z};if(this.isOp(":")){if(this.at++,!this.isOp("]"))this.pipe();return this.expectOp("]"),{k:"slice",of:Z}}let z=this.pipe();if(this.isOp(":")){if(this.at++,!this.isOp("]"))this.pipe();return this.expectOp("]"),{k:"slice",of:Z}}return this.expectOp("]"),{k:"index",of:Z,key:z}}primary(){let Z=this.peek();if(!Z)return L();switch(this.at++,Z.t){case"dot":return{k:"dot"};case"field":return{k:"field",name:Z.name};case"num":return{k:"lit"};case"str":return this.stringNode(Z.parts);case"fmt":{if(!u5.has(Z.name))L();let z=this.peek();if(z?.t==="str")return this.at++,{k:"fmt",name:Z.name,str:this.stringNode(z.parts)};return{k:"fmt",name:Z.name}}case"ident":{if(m5.has(Z.name))L();if(Z.name==="map"||$3.has(Z.name)||J3.has(Z.name)){let z=[];if(this.isOp("(")){this.at++,z.push(this.pipe());while(this.isOp(";"))this.at++,z.push(this.pipe());this.expectOp(")")}return{k:"call",name:Z.name,args:z}}return L()}case"op":{if(Z.v==="("){let z=this.pipe();return this.expectOp(")"),z}if(Z.v==="["){if(this.isOp("]"))return this.at++,{k:"array"};let z=this.pipe();return this.expectOp("]"),{k:"array",of:z}}if(Z.v==="{")return this.object();return L()}}return L()}stringNode(Z){let z=[];for(let $ of Z){if(typeof $==="string")continue;z.push(new g0(z3($.src)).parse())}return z.length===0?{k:"str",parts:z,text:Z.join("")}:{k:"str",parts:z}}object(){let Z=[];if(this.isOp("}"))return this.at++,{k:"object",entries:Z};for(;;){let z=this.peek();if(!z)L();this.at++;let $;if(z.t==="ident")$=z.name;else if(z.t==="str"){if(z.parts.some((J)=>typeof J!=="string"))L();$=z.parts.join("")}else L();if(this.isOp(":"))this.at++,Z.push({key:"static",value:this.objectValue()});else Z.push({key:"static",value:{k:"field",name:$}});if(this.isOp(",")){this.at++;continue}return this.expectOp("}"),{k:"object",entries:Z}}}}function l0(Z){if(typeof Z==="object"&&"union"in Z)return Z.union.every(l0);return Z==="safe"||typeof Z==="object"&&w5.has(Z.leaf)}var uZ=(...Z)=>Z.every(l0)?"safe":"tainted";function h0(...Z){let z=[];for(let $ of Z)if(typeof $==="object"&&"union"in $)z.push(...$.union);else z.push($);return z.length===1?z[0]:{union:z}}function Z0(Z,z){return typeof Z==="object"&&"union"in Z?h0(...Z.union.map(z)):z(Z)}var $0=(Z)=>typeof Z==="object"&&("leaf"in Z)&&g5.has(Z.leaf),JZ=(Z)=>Z0(Z,(z)=>z==="safe"?"safe":z==="tainted"||$0(z)?"tainted":"unknown");function t2(Z){return Z.k==="lit"||Z.k==="str"&&Z.parts.length===0||Z.k==="call"&&["true","false","null"].includes(Z.name)&&Z.args.length===0}function e2(Z,z,$){return Z0(Z,(J)=>{if(J==="safe"||J==="tainted")return J;if($0(J))return"tainted";if(J==="root"&&$.rootScalars.has(z))return"safe";return{leaf:z}})}function y(Z,z,$){switch(Z.k){case"dot":return z;case"field":return e2(Z.of?y(Z.of,z,$):z,Z.name,$);case"iter":return JZ(y(Z.of,z,$));case"index":{let J=y(Z.of,z,$);if(Z.key.k==="str"&&Z.key.text!==void 0)return e2(J,Z.key.text,$);if(Z.key.k==="lit")return JZ(J);return y(Z.key,z,$),"tainted"}case"slice":return Z0(y(Z.of,z,$),(J)=>J==="root"?"unknown":$0(J)?"tainted":J);case"opt":return y(Z.of,z,$);case"lit":return"safe";case"str":return uZ(...Z.parts.map((J)=>y(J,z,$)));case"fmt":return Z.str?y(Z.str,z,$):z;case"array":return Z.of?uZ(y(Z.of,z,$)):"safe";case"object":return uZ(...Z.entries.map((J)=>y(J.value,z,$)));case"pipe":return y(Z.b,y(Z.a,z,$),$);case"comma":return h0(y(Z.a,z,$),y(Z.b,z,$));case"alt":return h0(y(Z.a,z,$),y(Z.b,z,$));case"bool":return y(Z.a,z,$),y(Z.b,z,$),"safe";case"arith":return uZ(y(Z.a,z,$),y(Z.b,z,$));case"neg":return y(Z.of,z,$);case"call":return p5(Z,z,$)}}var Z3=(Z)=>Z0(Z,(z)=>z==="root"?"unknown":$0(z)?"tainted":z);function p5(Z,z,$){let{name:J,args:Y}=Z;if(l5.has(J)&&J!=="limit"&&!Y.every(t2))L();switch(J){case"map":if(Y.length!==1)L();return uZ(y(Y[0],JZ(z),$));case"select":if(Y.length!==1)L();return y(Y[0],z,$),z;case"limit":if(Y.length!==2||!t2(Y[0]))L();return y(Y[1],z,$);case"first":case"last":if(Y.length>1)L();return Y.length===1?y(Y[0],z,$):JZ(z);case"min":case"max":return JZ(z);case"sort_by":case"group_by":case"unique_by":if(Y.length!==1)L();return y(Y[0],JZ(z),$),Z3(z);case"min_by":case"max_by":if(Y.length!==1)L();return y(Y[0],JZ(z),$),JZ(z);case"any":case"all":case"isempty":for(let Q of Y)y(Q,"unknown",$);return"safe"}if($3.has(J))return"safe";if(J3.has(J))return Z3(z);return L()}function Y3(Z,z={}){if(typeof Z!=="string"||!Z.trim()||Z.length>4096)return!1;try{let $=new g0(z3(Z)).parse();return l0(y($,"root",{rootScalars:z.rootScalars??new Set}))}catch($){if($ instanceof w0)return!1;return!1}}var a0="composite output withheld: signed-link shape; use bounded scalar projections per class disposition 799310",T={refused:!1},I=(Z)=>({refused:!0,rule:Z}),u0=new Set(["additions","assignees","author","baseRefName","baseRefOid","changedFiles","closed","closedAt","createdAt","deletions","files","fullDatabaseId","headRefName","headRefOid","headRepository","headRepositoryOwner","id","isCrossRepository","isDraft","labels","maintainerCanModify","mergeCommit","mergeStateStatus","mergeable","mergedAt","mergedBy","number","potentialMergeCommit","reactionGroups","reviewDecision","reviewRequests","state","title","updatedAt","url"]),m0=new Set(["assignees","author","closed","closedAt","createdAt","id","isPinned","labels","number","reactionGroups","state","stateReason","subIssuesSummary","title","updatedAt","url"]),Q3=new Set(["apiUrl","author","createdAt","databaseId","id","isDraft","isImmutable","isLatest","isPrerelease","name","publishedAt","tagName","tarballUrl","targetCommitish","uploadUrl","url","zipballUrl"]),X3=new Set(["answerChosenAt","answerChosenBy","answered","author","closed","closedAt","createdAt","id","labels","locked","number","reactionGroups","state","stateReason","title","updatedAt","url"]),c5=new Set(["assignees","author","authorAssociation","closedAt","commentsCount","createdAt","id","isDraft","isLocked","isPullRequest","labels","number","repository","state","title","updatedAt","url"]),i5=new Set(["author","committer","id","parents","repository","sha","url"]),d5=new Set(["bucket","completedAt","event","name","startedAt","state","workflow"]);function B3(Z){let z=[];for(let $=0;$<Z.length;$++){let J=Z[$];if(J==="\\"){$++;continue}if(J==="'"){let Y=Z.indexOf("'",$+1);if(Y<0)return!1;$=Y;continue}if(J==='"'){$++;while($<Z.length&&Z[$]!=='"')$+=Z[$]==="\\"?2:1;continue}if(J==="{"){z.push({list:!1});continue}if(z.length===0)continue;if(J===","||J==="."&&Z[$+1]===".")z[z.length-1].list=!0;else if(J==="}"&&z.pop().list)return!0}return!1}function _Z(Z){let z="",$=!1,J=0,Y=(Q)=>Z[Q]==="`"||Z[Q]==="$"&&/[A-Za-z_{(@*#?$!0-9-]/.test(Z[Q+1]??"");while(J<Z.length){let Q=Z[J];if(Q==="\\"){z+=Z[J+1]??"",J+=2;continue}if(Q==="$"&&Z[J+1]==="'"){$=!0,z+=Q,J++;continue}if(Q==="'"){let X=Z.indexOf("'",J+1);if(X<0){$=!0,z+=Z.slice(J+1);break}z+=Z.slice(J+1,X),J=X+1;continue}if(Q==='"'){J++;while(J<Z.length&&Z[J]!=='"'){if(Z[J]==="\\"&&/[$`"\\\n]/.test(Z[J+1]??"")){z+=Z[J+1],J+=2;continue}if(Y(J))$=!0;z+=Z[J],J++}if(J>=Z.length)$=!0;J++;continue}if(Y(J)||Q==="*"||Q==="?"||Q==="[")$=!0;z+=Q,J++}if(!$&&Z.includes("{")&&B3(Z))$=!0;return{value:z,opaque:$,raw:Z}}var BZ=(Z)=>Z.slice(Z.lastIndexOf("/")+1);function i0(Z,z="word"){let $=[],J=!1;for(let Y=0;Y<Z.length;Y++){let Q=Z[Y];if(Q==="\\"){Y++;continue}if(z==="word"&&Q==="'"&&!J){let X=Z.indexOf("'",Y+1);if(X<0)return{bodies:$,complete:!1};Y=X;continue}if(z==="word"&&Q==='"'){J=!J;continue}if(Q==="`"){let X=Y+1;while(X<Z.length&&Z[X]!=="`")X+=Z[X]==="\\"?2:1;if(X>=Z.length)return{bodies:$,complete:!1};$.push(Z.slice(Y+1,X)),Y=X;continue}if(Q==="$"&&Z[Y+1]==="("){let X=KZ(Z,Y+1);if(X<0)return{bodies:$,complete:!1};$.push(Z.slice(Y+2,X-1)),Y=X-1}}return{bodies:$,complete:!0}}function DZ(Z,z){let $=new Set(z.values),J={flags:[],positionals:[]},Y=(Q,X)=>({value:Q,opaque:X.opaque,raw:X.raw});for(let Q=0;Q<Z.length;Q++){let X=Z[Q],H=X.value;if(H==="--"){J.positionals.push(...Z.slice(Q+1));break}if(H.startsWith("--")&&H.length>2){let K=H.indexOf("="),B=K>=0?H.slice(0,K):H;if(K>=0)J.flags.push({name:B,value:Y(H.slice(K+1),X),inline:!0});else if($.has(B)){let M=Z[Q+1];J.flags.push(M?{name:B,value:M}:{name:B,missing:!0}),Q++}else J.flags.push({name:B});continue}if(H.startsWith("-")&&H.length>1){for(let K=1;K<H.length;K++){let B="-"+H[K],M=H.slice(K+1);if(M.startsWith("=")){J.flags.push({name:B,value:Y(M.slice(1),X),inline:!0});break}if(!$.has(B)){J.flags.push({name:B});continue}if(M)J.flags.push({name:B,value:Y(M,X),inline:!0});else{let V=Z[Q+1];J.flags.push(V?{name:B,value:V}:{name:B,missing:!0}),Q++}break}continue}J.positionals.push(X)}return J}function w(Z,...z){let $=!1;for(let J of Z.flags){if(!z.includes(J.name))continue;if(!J.inline){$=!0;continue}let Y=J.value;$=!Y.opaque&&["1","t","T","TRUE","true","True"].includes(Y.value)}return $}var YZ=(Z,...z)=>Z.flags.filter(($)=>z.includes($.name)),s=["-R","--repo","-q","--jq","-t","--template","--json"],MZ={"pr view":{values:s},"issue view":{values:s},"release view":{values:s},"discussion view":{values:[...s,"--after","-L","--limit","--order"]},"pr list":{values:[...s,"--app","-a","--assignee","-A","--author","-B","--base","-H","--head","-l","--label","-L","--limit","-S","--search","-s","--state"]},"issue list":{values:[...s,"--app","-a","--assignee","-A","--author","-l","--label","-L","--limit","--mention","-m","--milestone","-S","--search","-s","--state"]},"discussion list":{values:[...s,"--after","-A","--author","-c","--category","-l","--label","-L","--limit","--order","-S","--search","--sort","-s","--state"]},"release list":{values:[...s,"-L","--limit","-O","--order"]},"pr status":{values:s},"issue status":{values:s},"pr checks":{values:[...s,"-i","--interval"]},"pr diff":{values:["-R","--repo"]},search:{values:[...s,"--app","--assignee","--author","--author-date","--author-email","--author-name","--base","--checks","--closed","--commenter","--committer","--committer-date","--committer-email","--committer-name","--created","--hash","--head","--interactions","--involves","--label","--language","--limit","-L","--match","--mentions","--merged-at","--milestone","--no-assignee","--no-label","--no-milestone","--no-project","--order","--owner","--parent","--project","--reactions","--review","--review-requested","--reviewed-by","--sort","--state","--team-mentions","--tree","--updated","--visibility","--extension","--filename","--size","--forks","--good-first-issue","--help-wanted-issues","--number-topics","--stars","--topic","--followers","--include-forks","--license"]},"project item-list":{values:["--format","-L","--limit","--owner","-q","--jq","-t","--template","--query","--field","--field-id"]},api:{values:["-X","--method","-H","--header","-f","--raw-field","-F","--field","-q","--jq","-t","--template","-p","--preview","--input","--hostname","--cache"]},group:{values:["-R","--repo"]}},s5=new Set(["auth","browse","codespace","cs","gist","org","repo","skill","cache","run","workflow","co","agent-task","alias","attestation","completion","config","copilot","extension","ext","extensions","gpg-key","label","licenses","preview","ruleset","secret","ssh-key","variable","help","version","accessibility","actions","environment","exit-codes","formatting","mintty","reference","telemetry"]),n5=new Set(["pr","issue","release","discussion","search","project","api","status"]),a5=new Set(["create","new","checkout","co","close","comment","edit","lock","merge","ready","reopen","revert","review","unlock","update-branch"]),o5=new Set(["create","new","close","comment","delete","develop","edit","lock","pin","reopen","transfer","unlock","unpin"]),r5=new Set(["create","new","delete","delete-asset","download","edit","upload","verify","verify-asset"]),t5=new Set(["create","new","close","comment","delete","edit","lock","reopen","unlock","answer","unanswer"]);function Q0(Z,z){let $=YZ(Z,"--json"),J=[],Y=!1;for(let Q of $){if(Q.missing){if(z.appendsArgs)Y=!0;continue}if(!Q.value)continue;if(Q.value.opaque)Y=!0;J.push(...Q.value.value.split(",").map((X)=>X.trim()).filter(Boolean))}return{present:$.length>0,opaque:Y,fields:J}}function o0(Z,z){if(w(Z,"--verbose")||YZ(Z,"-t","--template").length>0)return!1;let $=YZ(Z,"-q","--jq");return $.length>0&&$.every((J)=>J.value!==void 0&&!J.value.opaque&&Y3(J.value.value,{rootScalars:z}))}function r0(Z,z,$,J){let Y=Q0(Z,$);if(Y.opaque)return I("unclassifiable");if(Y.fields.every((Q)=>z.has(Q)))return T;if($.debug)return I("debug-traffic");return o0(Z)?T:I(J)}function J0(Z,z,$,J,Y){let Q=DZ(Z,MZ[z]);if(w(Q,"-h","--help"))return T;if(w(Q,"-w","--web"))return J.debug?I("debug-traffic"):T;if(Y&&w(Q,"-c","--comments"))return I("view-comments");if(!Q0(Q,J).present)return I(J.debug?"debug-traffic":"view-human");return r0(Q,$,J,"json-composite")}function zZ(Z,z,$,J){let Y=DZ(Z,MZ[z]);if(w(Y,"-h","--help"))return T;if(J.debug&&(w(Y,"-w","--web")||!Q0(Y,J).present))return I("debug-traffic");if(w(Y,"-w","--web"))return T;return r0(Y,$,J,"json-composite")}function e5(Z,z){let $=DZ(Z,MZ["pr checks"]);if(w($,"-h","--help"))return T;if(z.debug)return I("debug-traffic");if(w($,"-w","--web"))return T;if(!Q0($,z).present)return I("checks-human");return r0($,d5,z,"checks-json")}function Z6(Z){let z=new Set(MZ.group.values);for(let $=0;$<Z.length;$++){let J=Z[$].value;if(J==="--")return{sub:Z[$+1],rest:Z.slice($+2)};if(!J.startsWith("-")||J==="-")return{sub:Z[$],rest:[...Z.slice(0,$),...Z.slice($+1)]};if(z.has(J))$++}return{rest:Z}}function $6(Z,z,$){let{sub:J,rest:Y}=Z6(z);if(!J)return $.appendsArgs?I("unclassifiable"):T;if(J.opaque)return I("unclassifiable");let Q=J.value;if((Z==="pr"?a5:Z==="issue"?o5:Z==="release"?r5:Z==="discussion"?t5:new Set).has(Q))return $.debug?I("debug-traffic"):T;if($.appendsArgs&&!(Z==="project"&&Q!=="item-list"))return I("unclassifiable");switch(Z){case"pr":if(Q==="view")return J0(Y,"pr view",u0,$,!0);if(Q==="list"||Q==="ls")return zZ(Y,"pr list",u0,$);if(Q==="status")return zZ(Y,"pr status",u0,$);if(Q==="checks")return e5(Y,$);if(Q==="diff"){let H=DZ(Y,MZ["pr diff"]);if(w(H,"-h","--help"))return T;if($.debug)return I("debug-traffic");return w(H,"--patch")?I("composite-other"):T}return I("unclassifiable");case"issue":if(Q==="view")return J0(Y,"issue view",m0,$,!0);if(Q==="list"||Q==="ls")return zZ(Y,"issue list",m0,$);if(Q==="status")return zZ(Y,"issue status",m0,$);return I("unclassifiable");case"release":if(Q==="view")return J0(Y,"release view",Q3,$,!1);if(Q==="list"||Q==="ls")return zZ(Y,"release list",Q3,$);return I("unclassifiable");case"discussion":if(Q==="view")return J0(Y,"discussion view",X3,$,!0);if(Q==="list"||Q==="ls")return zZ(Y,"discussion list",X3,$);return I("unclassifiable");case"search":if(Q==="prs"||Q==="issues")return zZ(Y,"search",c5,$);if(Q==="commits")return zZ(Y,"search",i5,$);if(Q==="code"||Q==="repos")return $.debug?I("debug-traffic"):T;return I("unclassifiable");case"project":{if($.debug)return I("debug-traffic");if(Q!=="item-list")return T;let H=DZ(Y,MZ["project item-list"]);if(w(H,"-h","--help"))return T;let K=YZ(H,"--format");if(K.some((B)=>!B.value||B.value.opaque))return I("unclassifiable");if(K.every((B)=>B.value.value!=="json"))return T;return o0(H)?T:I("composite-other")}}return I("unclassifiable")}var M3=new Set(["pulls","issues","commits","check-runs","check-suites","statuses","comments","releases","compare","events","discussions","deployments","milestones"]);function J6(Z){let z=Z.value.trim(),$=/^https?:\/\/([^/]+)(\/.*)?$/i.exec(z);if($){let Q=$[1].toLowerCase(),X=$[2]??"/";if(Q==="api.github.com"||/^api\./.test(Q))z=X;else if(/^\/api\/v3(?:\/|$)/i.test(X))z=X.replace(/^\/api\/v3/i,"");else if(/^\/api\/graphql(?:[/?#]|$)/i.test(X))z="graphql";else return null}z=z.replace(/[?#].*$/,"");let J=[],Y=[];for(let Q of z.split("/")){let X;try{X=decodeURIComponent(Q)}catch{return null}for(let H of X.split("/")){if(H===""||H===".")continue;if(H===".."){J.pop(),Y.pop();continue}J.push(H.toLowerCase()),Y.push(Z.opaque&&/[$`]/.test(H)||/[*?[]/.test(H)||B3(H))}}return{segments:J,opaque:Y}}function z6(Z){let z=J6(Z);if(!z)return{kind:"unclassifiable",segments:[]};let{segments:$,opaque:J}=z,Y=(K)=>({kind:K,segments:$});if($.length===1&&$[0]==="graphql")return Y("graphql");if($.length===0)return Y(Z.opaque?"unclassifiable":"other");if(J[0])return Y("unclassifiable");let Q,X=[];if($[0]==="repos")Q=$.slice(3),X=J.slice(3);else if($[0]==="repositories")Q=$.slice(2),X=J.slice(2);if(Q){if(($[0]==="repos"?J.slice(1,3):J.slice(1,2)).some(Boolean)){let B=J.findIndex(Boolean),M=$.findIndex((V,G)=>G>B&&!J[G]&&Y6.has(V));return Y(M<0?"unclassifiable":K3($.slice(M),J.slice(M)))}return Y(K3(Q,X))}let H=$[0];if(H==="issues")return Y("sensitive");if(H==="user"&&$[1]==="issues")return Y("sensitive");if(H==="orgs"&&$[2]==="issues")return Y("sensitive");if(H==="search")return Y($[1]==="issues"||$[1]==="commits"?"sensitive":$[1]!==void 0&&J[1]?"unclassifiable":"other");if(H==="events"||H==="networks")return Y("sensitive");if((H==="users"||H==="orgs")&&$.slice(2).some((K)=>K==="events"||K==="received_events"||K==="discussions"))return Y("sensitive");if((H==="users"||H==="orgs")&&$[2]==="projectsv2"&&$[4]==="items")return Y("sensitive");if(H==="orgs"&&$[2]==="hooks"&&$[4]==="deliveries"&&$[5]!==void 0||H==="app"&&$[1]==="hook"&&$[2]==="deliveries"&&$[3]!==void 0)return Y("sensitive");if(H==="teams"&&$.includes("discussions"))return Y("sensitive");if(H==="projects"&&$.includes("cards"))return Y("sensitive");if(J.some(Boolean))return Y($.some((K)=>K==="events"||K==="discussions"||K==="issues")?"sensitive":"unclassifiable");return Y("other")}var Y6=new Set([...M3,"branches","git","actions","hooks","zipball","tarball"]);function K3(Z,z){let[$,J]=Z;if($===void 0)return"other";if(z[0])return"unclassifiable";if($==="issues"&&/^\d+$/.test(J??"")&&Z[2]==="labels")return"other";if(M3.has($))return"sensitive";if($==="branches"){if(Z.length===1||Z.slice(1).some((Y)=>Y==="protection")||Z[Z.length-1]==="rename")return"other";return z.slice(1).some(Boolean)?"unclassifiable":"sensitive"}if($==="git")return J===void 0||J==="commits"||J==="tags"?"sensitive":z[1]?"unclassifiable":"other";if($==="actions"){if(J===void 0)return"sensitive";if(z[1])return"unclassifiable";if(J==="runs"||J==="jobs"){if(Z[Z.length-1]==="logs"&&Z.length>=4&&!z.some(Boolean))return"download";return"sensitive"}if(J==="workflows"&&Z[3]==="runs")return"sensitive";if(J==="artifacts"&&Z.length===4)return"download";return"other"}if($==="hooks"&&Z[2]==="deliveries"&&Z[3]!==void 0)return"sensitive";if($==="zipball"||$==="tarball")return"download";return"other"}function Q6(Z,z){if(z[0]!=="repos"||z.length<5)return!1;let $=z.slice(3),J=(Q)=>/^\d+$/.test($[Q]??""),Y=(...Q)=>$.length===Q.length&&Q.every((X,H)=>typeof X==="number"?J(H):$[H]===X);if(Z==="DELETE")return Y("issues","comments",0)||Y("pulls","comments",0)||Y("comments",0)||Y("issues","comments",0,"reactions",0)||Y("pulls","comments",0,"reactions",0)||Y("issues",0,"reactions",0)||Y("issues",0,"labels")||$.length===4&&$[0]==="issues"&&J(1)&&$[2]==="labels"||Y("releases",0)||Y("releases","assets",0)||Y("actions","runs",0)||Y("actions","runs",0,"logs")||Y("deployments",0)||Y("milestones",0)||Y("issues",0,"lock");if(Z==="POST")return $.length===4&&$[0]==="actions"&&$[1]==="runs"&&J(2)&&["rerun","rerun-failed-jobs","cancel","force-cancel","approve"].includes($[3])||Y("actions","jobs",0,"rerun")||Y("issues",0,"labels");if(Z==="PUT")return Y("pulls",0,"merge")||Y("pulls",0,"update-branch")||Y("issues",0,"labels")||Y("issues",0,"lock");if(Z==="GET")return Y("pulls",0,"merge");return!1}function X6(Z){if(Z[0]!=="repos"||Z.length!==5||!/^\d+$/.test(Z[4]))return;if(Z[3]==="pulls")return new Set(["commits","comments","review_comments"]);if(Z[3]==="issues")return new Set(["comments"]);return}var K6=new Set(["body","bodyText","bodyHTML","bodyUrl","bodyResourcePath","comments","reviews","latestReviews","latestOpinionatedReviews","reviewThreads","url","permalink","summary","text","description","message","messageBody","messageHeadline","commitBody","commitHeadline","annotations","rawDetails","note","diff","readme","payload"]),H6=new Set(["checkRuns","checkRun","checkSuites","checkSuite","contexts","statusCheckRollup","annotations","CheckRun","CheckSuite","StatusContext","CheckAnnotation","latestStatus","status","statuses"]);function B6(Z){let z=[],$=0;while($<Z.length){let J=Z[$];if(/[\s,]/.test(J)){$++;continue}if(J==="#"){let X=Z.indexOf(`
29
- `,$);$=X<0?Z.length:X+1;continue}if(Z.startsWith('"""',$)){let X=$+3;for(;;){let H=Z.indexOf('"""',X);if(H<0)return null;if(Z[H-1]==="\\"){X=H+3;continue}$=H+3;break}continue}if(J==='"'){let X=$+1;while(X<Z.length&&Z[X]!=='"'&&Z[X]!==`
30
- `)X+=Z[X]==="\\"?2:1;if(Z[X]!=='"')return null;$=X+1;continue}let Y=/^[_A-Za-z][_0-9A-Za-z]*/.exec(Z.slice($,$+256));if(Y){z.push({kind:"name",text:Y[0]}),$+=Y[0].length;continue}let Q=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(Z.slice($,$+64));if(Q){$+=Q[0].length;continue}if(Z.startsWith("...",$)){z.push({kind:"punct",text:"..."}),$+=3;continue}if("{}()[]:!$@=|&".includes(J)){z.push({kind:"punct",text:J}),$++;continue}return null}return z}function M6(Z){let z=B6(Z);if(!z)return!0;let $=[],J="",Y=0;for(let Q=0;Q<z.length;Q++){let X=z[Q];if(X.kind==="punct"){if(X.text==="(")Y++;else if(X.text===")"){if(Y--,Y<0)return!0}else if(Y===0&&X.text==="{")$.push(J),J="";else if(Y===0&&X.text==="}"){if($.pop()===void 0)return!0;J=""}continue}if(Y>0)continue;let H=z[Q-1];if(H?.kind==="punct"&&(H.text==="@"||H.text==="$"))continue;if(z[Q+1]?.kind==="punct"&&z[Q+1].text===":")continue;if(X.text==="on"&&H?.kind==="punct"&&H.text==="...")continue;if(H?.kind==="name"&&H.text==="on"){J=X.text;continue}if($.length===0){J=X.text;continue}if(K6.has(X.text)||/(?:Url|URL|HTML|Html)$/.test(X.text))return!0;if(X.text==="title"&&$.some((K)=>H6.has(K)))return!0;J=X.text}return Y!==0||$.length!==0}function V6(Z,z){let $=DZ(Z,MZ.api);if(w($,"-h","--help"))return T;let J=$.positionals[0];if(!J)return z.appendsArgs?I("unclassifiable"):T;let Y=z6(J),Q=YZ($,"-X","--method"),X=Q[Q.length-1],H=YZ($,"-f","--raw-field","-F","--field","--input"),K=X?X.value&&!X.value.opaque?X.value.value.toUpperCase():"?":H.length>0?"POST":"GET",B=Q6(K,Y.segments),M=T;if(Y.kind==="unclassifiable")M=I("unclassifiable");else if(Y.kind==="sensitive"&&!B)M=I("api-rest");else if(Y.kind==="graphql")M=G6($);if(z.debug||w($,"--verbose")){if(Y.kind==="download"&&!M.refused)M=I("api-rest");if(M.refused)return z.debug?I("debug-traffic"):M;return T}if(z.appendsArgs&&Y.kind!=="other"&&Y.kind!=="download")return I("unclassifiable");if(!M.refused||w($,"--silent"))return T;if(o0($,X6(Y.segments)))return T;return M}function G6(Z){if(YZ(Z,"--input").length>0)return I("unclassifiable");let z=YZ(Z,"-f","--raw-field","-F","--field"),$=z.filter((J)=>J.value&&/^query=/.test(J.value.value));if($.length===0||z.some((J)=>!J.value))return I("unclassifiable");for(let J of $){let Y=J.value.value.slice(6);if((J.name==="-F"||J.name==="--field")&&Y.startsWith("@")||J.value.opaque)return I("unclassifiable");if(M6(Y))return I("api-graphql")}return T}function Y0(Z,z){let $=0;while($<Z.length&&Z[$].value.startsWith("-")&&!Z[$].opaque){if(["--help","-h","--version"].includes(Z[$].value))return T;$++}if($>=Z.length)return z.appendsArgs?I("unclassifiable"):T;let J=Z[$],Y=Z.slice($+1);if(J.opaque)return I("unclassifiable");switch(J.value){case"pr":case"issue":case"release":case"discussion":case"search":case"project":return $6(J.value,Y,z);case"api":return V6(Y,z);case"status":return Y.length>0&&Y.every((Q)=>Q.value==="-h"||Q.value==="--help")?T:I("composite-other");case"help":case"version":return T;case"cs":case"codespace":{let Q=Y.findIndex((X)=>X.value==="--");if(Y.some((X)=>X.value==="ssh")&&Q>=0&&Q+1<Y.length){let X=r(Y.slice(Q+1).map((H)=>H.value).join(" "),z.depth+1,z.debug);if(X.refused)return X}break}}if(!s5.has(J.value))return I("unclassifiable");if(z.debug)return I("debug-traffic");return T}var X0=new Set(["sh","bash","zsh","dash","ksh","ash","mksh","fish"]),U6=new Set(["su","runuser","script","flock"]),j6=new Set(["secrets","op","unbuffer","caffeinate","chronic","strace","ltrace","firejail","bwrap","nsenter","unshare","chroot","sg","retry","parallel","doppler","aws-vault","dotenv","direnv","faketime","taskset","numactl","cgexec","systemd-run","docker","podman","kubectl","mise","asdf","rtx","devbox","gosu","su-exec","setpriv","pkexec","with-contenv","uv","poetry","pipenv","npx","bunx","pnpm","yarn","nix","nix-shell","infisical","chamber","envchain","dotenvx","teller","vault","chrt","coproc","prlimit","ionice","cpulimit","trickle","proxychains","proxychains4","torsocks","tsocks","catchsegv","valgrind"]),W6=new Map([["bun",["x","exec"]],["npm",["exec","x"]],["deno",["run"]]]),N6=new Set(["-I","-L","-l","-n","-P","-s","-d","-E","-e","-a","--arg-file","--delimiter","--max-args","--max-lines","--max-procs","--max-chars","--replace","--eof","--process-slot-var"]),F6=new Set(["-b","-c","-D","-E","-e","-F","-I","-i","-J","-L","-l","-m","-O","-o","-p","-Q","-R","-S","-W","-w"]),z0=/(?:^|[^A-Za-z0-9_.-])gh(?:$|[^A-Za-z0-9_.-])/,_6=/^([A-Za-z_][A-Za-z0-9_]*)=([\s\S]*)$/,D6=6;function H3(Z,z){let $,J;for(let Y of Z){let Q=_6.exec(Y.value);if(!Q)continue;let X={...Y,value:Q[2]};if(Q[1]==="GH_DEBUG")$=X;else if(Q[1]==="DEBUG")J=X}if($)return $.opaque||!["","0","false","no"].includes($.value);if(J&&(J.opaque||["1","true","yes","api"].includes(J.value)))return!0;return z}function t0(Z){let z=S(Z),$=0;return{segments:z.segments.map((Y)=>{let Q=Y.words[0],X=Z.slice($,Q.start);return $=Y.words[Y.words.length-1].end,{words:Y.words,redirects:Y.redirects,sepBefore:X}}),trustworthy:z.trustworthy}}var V3=(Z)=>/(?:^|[^|])\|&?$/.test(Z.trim());function d0(Z,z){if(!X0.has(Z))return!1;if(e0(z))return!1;for(let $=0;$<z.length;$++){let J=z[$].value;if(J==="--")return $+1>=z.length;if(J==="-"||J==="-s")return!0;if(/^[-+][A-Za-z]*[oO]$/.test(J)){$++;continue}if(!J.startsWith("-")&&!J.startsWith("+"))return!1}return!0}function s0(Z){let{segments:z}=t0(Z.trim());if(z.length!==1)return null;let $=z[0],J=u($);if(J<0)return null;let Y=BZ(_Z($.words[J].text).value),Q=$.words.slice(J+1).filter((X,H)=>!$.redirects.has(H+J+1)).map((X)=>_Z(X.text));if(Y==="echo")return Q.filter((X,H)=>!(H===0&&/^-[neE]+$/.test(X.value))).map((X)=>X.value).join(" ");if(Y==="printf"){let[X,...H]=Q.filter((B)=>B.value!=="--");if(!X)return null;let K=0;return X.value.replace(/\\n/g,`
31
- `).replace(/%s/g,()=>H[K++]?.value??"")+(K<H.length?" "+H.slice(K).map((B)=>B.value).join(" "):"")}if(Y==="cat"){let X=Z.indexOf("<<");if(X<0)return null;let H=FZ(Z,X),K=Z.indexOf(`
32
- `,X);if(!H||K<0)return null;let B=oZ(Z,K,[H]);if(B<0)return null;let M=Z.slice(K+1,B);return M.slice(0,M.lastIndexOf(H.delimiter)).replace(/\n$/,"")}return null}function p0(Z,z,$){for(let J of i0(Z).bodies){let Y=s0(J);if(Y===null)continue;let Q=r(Y,z+1,$.debug);if(Q.refused)return Q}return T}function r(Z,z=0,$=!1){if(typeof Z!=="string"||!Z.trim())return T;if(z>D6)return z0.test(Z)?I("unclassifiable"):T;let{segments:J,trustworthy:Y}=t0(Z);if(!Y)return z0.test(Z)?I("unclassifiable"):T;let Q=$,X=(H)=>r(H,z+1,Q);for(let H of q6(Z)){if(H.runsBody){let K=X(H.body);if(K.refused)return K}if(!H.quoted){let K=i0(H.body,"heredoc");if(!K.complete&&z0.test(H.body))return I("unclassifiable");for(let B of K.bodies){let M=X(B);if(M.refused)return M}}}for(let H=0;H<J.length;H++){let K=J[H];for(let F of K.words){let A=i0(F.text);if(!A.complete&&z0.test(F.text))return I("unclassifiable");for(let m of A.bodies){let p=X(m);if(p.refused)return p}}let B=u(K),M=K.words.map((F,A)=>({word:_Z(F.text),redirect:K.redirects.has(A)})),V=M.slice(0,B<0?M.length:B).map((F)=>F.word),G=B>=0?BZ(M[B].word.value):"";if(B<0||["export","declare","typeset","readonly","local"].includes(G)){if(Q=H3([...V,...M.slice(B+1).map((F)=>F.word)],Q),B<0)continue}let U=H3(V,Q),W=M.slice(B+1).filter((F)=>!F.redirect).map((F)=>F.word),N=M.slice(B+1).filter((F)=>F.redirect).map((F)=>F.word),R=M[B].word,f=BZ(R.value),k={depth:z,appendsArgs:!1,debug:U};if(B>0&&M[B-1].word.value==="function"){let F=W.filter((m)=>!["{","()","(",")"].includes(m.value)),A=n0(F,k);if(A.refused)return A;continue}if(H>0&&V3(K.sepBefore)&&d0(f,W)){let F=J[H-1],A=I6(Z,F),m=A===null?null:s0(A);if(m!==null){let p=r(m,z+1,U);if(p.refused)return p}}let i=J[H+1];if(i&&/<\(\s*$/.test(i.sepBefore)&&(X0.has(f)||f==="source"||f===".")){let F=i.words[0].start-i.sepBefore.length+i.sepBefore.lastIndexOf("("),A=KZ(Z,F),m=A<0?null:s0(Z.slice(F+1,A-1));if(m!==null){let p=r(m,z+1,U);if(p.refused)return p}}let q=G3(f,R,W,N,K.words.slice(0,B+1),k);if(q.refused)return q}return T}function I6(Z,z){let $=z.words[0],J=z.words[z.words.length-1];return $&&J?Z.slice($.start,J.end):null}function T6(Z){let z=BZ(Z.value);return/[$`]/.test(z)||z===""?void 0:z}function G3(Z,z,$,J,Y,Q){let X=Q.depth,H=(K)=>r(K,X+1,Q.debug);if(z.opaque){let K=T6(z);if(K===void 0){let B=$.find((V)=>!V.value.startsWith("-")),M=Y0($,Q);if(!M.refused)return T;return M.rule!=="unclassifiable"||B!==void 0&&!B.opaque&&n5.has(B.value)?M:T}Z=K}if(Z==="gh")return Y0($,Q);if(X0.has(Z)){let K=e0($);if(K){let B=H(K.value);if(B.refused||!K.opaque)return B;return p0(K.raw,X,Q)}for(let B of J){let M=H(B.value);if(M.refused)return M;if(B.opaque){let V=p0(B.raw,X,Q);if(V.refused)return V}}return T}if(U6.has(Z)){let K=$.findIndex((M)=>M.value==="-c"||M.value==="--command"||/^-[A-Za-z]*c$/.test(M.value)),B=K>=0?$[K+1]:void 0;return B?H(B.value):c0($,Q)}if(Z==="eval"||Z==="watch"){let K=$;if(Z==="watch"){let M=0;while(M<$.length&&$[M].value.startsWith("-")){if($[M].value==="--"){M++;break}if(["-n","--interval","-q","--equexit"].includes($[M].value))M++;M++}K=$.slice(M)}let B=H(K.map((M)=>M.value).join(" "));if(B.refused)return B;for(let M of K){let V=p0(M.raw,X,Q);if(V.refused)return V}return T}if(Z==="env")return H(xZ([...Y.map((K)=>_Z(K.text).value),...$.map((K)=>K.value)]));if(Z==="ssh"){let K=0;for(;K<$.length;K++){let V=$[K].value;if(!V.startsWith("-"))break;if(F6.has(V))K++}let B=$.slice(K+1);if(B[0]?.value==="--")B.shift();let M=B.map((V)=>V.value).join(" ");return M?H(M):T}if(Z==="xargs"){let K=0,B=!1;for(;K<$.length;K++){let M=$[K].value;if(M==="--"){K++;break}if(!M.startsWith("-"))break;if(/^-I|^-i|^--replace/.test(M))B=!0;if(N6.has(M))K++}return n0($.slice(K),{depth:X,appendsArgs:!B,debug:Q.debug})}if(Z==="find"){for(let K=0;K<$.length;K++){if(!["-exec","-execdir","-ok","-okdir"].includes($[K].value))continue;let B=K+1;while(B<$.length&&$[B].value!==";"&&$[B].value!=="+")B++;let M=n0($.slice(K+1,B),Q);if(M.refused)return M;K=B}return T}if(j6.has(Z))return c0($,Q);if(W6.get(Z)?.includes($[0]?.value??""))return c0($.slice(1),Q);return T}function n0(Z,z){if(Z.length===0)return T;let $=BZ(Z[0].value);if($==="gh")return Y0(Z.slice(1),z);if(X0.has($)){let J=e0(Z.slice(1));return J?r(J.value,z.depth+1,z.debug):T}return G3($,Z[0],Z.slice(1),[],[],z)}function c0(Z,z){let $=Z.findIndex((J)=>!J.opaque&&BZ(J.value)==="gh"&&(J.value==="gh"||J.value.includes("/")));return $>=0?Y0(Z.slice($+1),z):T}function e0(Z){for(let z=0;z<Z.length;z++){let $=Z[z].value;if($==="--")return;if(!$.startsWith("-")&&!$.startsWith("+"))return;if($==="-c"||/^-[A-Za-z]+$/.test($)&&$.includes("c"))return Z.slice(z+1).find((J)=>!J.value.startsWith("-")||J.value==="-");if(/^[-+][A-Za-z]*[oO]$/.test($))z++}return}function q6(Z){let z=[],$=0;for(;;){let J=Z.indexOf("<<",$);if(J<0)break;if($=J+2,Z[J+2]==="<"||J>0&&Z[J-1]==="<"){$=J+3;continue}let Y=FZ(Z,J);if(!Y)continue;let Q=Z.lastIndexOf(`
33
- `,J)+1,X=Z.indexOf(`
34
- `,J);if(X<0)continue;let H=oZ(Z,X,[Y]),K=H<0?Z.slice(X+1):Z.slice(X+1,H),B=H<0?K:K.slice(0,Math.max(0,K.lastIndexOf(Y.delimiter))).replace(/\n$/,""),M=Z.slice(Q,J)+" HEREDOC_OPERATOR "+Z.slice(Y.end,X);z.push({body:B,runsBody:C6(M),quoted:Y.quoted})}return z}function C6(Z){let{segments:z}=t0(Z),$=z.findIndex((H)=>H.words.some((K)=>K.text==="HEREDOC_OPERATOR"));if($<0)return!1;let J=(H)=>{let K=u(H);if(K<0)return{verb:"",args:[]};let B=H.words.slice(K+1).filter((M)=>M.text!=="HEREDOC_OPERATOR").map((M)=>_Z(M.text));return{verb:BZ(_Z(H.words[K].text).value),args:B}},{verb:Y,args:Q}=J(z[$]);if(Y==="ssh"||d0(Y,Q))return!0;if((Y==="source"||Y===".")&&["/dev/stdin","/dev/fd/0","/proc/self/fd/0"].includes(Q[0]?.value??""))return!0;let X=z[$+1];if(Y==="cat"&&X&&V3(X.sepBefore)){let H=J(X);return H.verb==="ssh"||d0(H.verb,H.args)}return!1}var P6=/(?:^|[^A-Za-z0-9_.-])gh(?:$|[^A-Za-z0-9_.-])/;function U3(){return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:a0}}}var O6=new Set(["Bash","Monitor"]);function j3(Z){if(Z?.hook_event_name!=="PreToolUse"||!O6.has(Z.tool_name??""))return{continue:!0};let z=UZ(Z);if(!z.trim())return{continue:!0};try{return r(z).refused?U3():{continue:!0}}catch{return P6.test(z)?U3():{continue:!0}}}function L6(Z){if(Z!=="trash-guard"&&Z!=="workspace-repos-guard")throw Error("Invalid safety capability")}function W3(Z,z){L6(Z);let $=Z,J=JSON.parse(z);if(!J||Array.isArray(J)||J.hook_event_name!=="PreToolUse"||typeof J.tool_name!=="string"||!J.tool_input||typeof J.tool_input!=="object"||Array.isArray(J.tool_input)||typeof J.cwd!=="string"||!Z2.isAbsolute(J.cwd))throw Error("Invalid safety input");if(J.tool_name==="Bash"&&typeof J.tool_input.command!=="string")throw Error("Invalid shell input");if(J.tool_name==="Monitor"&&J.tool_input.command!==void 0&&typeof J.tool_input.command!=="string")throw Error("Invalid monitor input");let Y=J.hasna_execution;if(Y!==void 0&&(!Y||Object.keys(Y).sort().join()!=="agent,schema"||Y.schema!=="hasna.hooks.execution.v1"||typeof Y.agent!=="string"||!/^[A-Za-z0-9][A-Za-z0-9._:@-]{0,127}$/.test(Y.agent)))throw Error("Invalid execution capability");let Q=Y===void 0?void 0:{runtime:process.execPath,home:K0.homedir(),path:process.env.PATH,agent:Y.agent};if(Q&&(!Z2.isAbsolute(Q.runtime)||!Q.path))throw Error("Invalid bound execution context");if(["apply_patch","ApplyPatch","functions.apply_patch"].includes(J.tool_name)){if(J.tool_input.command!==void 0&&J.tool_input.patch!==void 0&&J.tool_input.command!==J.tool_input.patch)throw Error("Conflicting patch aliases");let N=J.tool_input.command??J.tool_input.patch;if(typeof N!=="string")throw Error("Invalid patch input");J.tool_input={...J.tool_input,command:N,patch:N}}let X=J.tool_name==="Monitor",H=J.tool_name==="Bash"||X&&typeof J.tool_input.command==="string",K=X&&H?{...J,tool_name:"Bash"}:J,B=(N)=>({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:N}}),M=r2(K).output,V=j3(K),G=H&&NZ(K.tool_input.command,{home:K0.homedir(),cwd:J.cwd}).handoffHits.length>0,U=$==="trash-guard"&&(!X||H)?v2(K,{home:K0.homedir(),cwd:J.cwd,findTrash:cZ,inspectTrash:yZ,execution:Q}):{continue:!0};if(X&&U.hookSpecificOutput?.permissionDecision==="allow")U=B("[trash-guard] A deletion inside a Monitor command is refused; run it with the Bash tool, where it is redirected into trash.");let W=M.decision==="block"?B(M.reason):V.hookSpecificOutput?V:G?B("[workspace-repos-guard] Deletion under a protected repository checkout is refused."):U;return JSON.stringify({verdict:"continue"in W?null:W})}var y6=2,A6="0.12.18";function R6(Z,z){return W3(Z,z)}
31
+ `),bodies:Y}}var x5="/";function J0(Z,z,$){if(!Z)return[];let J=f(Z).trustworthy?Z:NZ(Z),Y=k5(Z);return[...J===Z?[]:J0(J,z,$),...Y?[...c2(Y.outer,z,$),...Y.bodies.flatMap((X)=>J0(X,z,x5))]:c2(Z,z,$)]}var h5=/(\s*&&\s*|\s*\|\|\s*|;\s*|\n+)/,w5=/^(?:'[^']*'|"[^"$\x60\\]*")$/;function l2(Z,z,$=!1){let J=[],Y=0;for(let H of z)J.push(Y),Y+=H.length;let X=f(Z);if(!X.trustworthy||!$&&X.substitutions.length>0)return null;let Q=X.segments.flatMap((H)=>H.words).filter((H)=>z.some((K,B)=>B%2===1&&J[B]<H.end&&J[B]+K.length>H.start));return Q.length>0?{lexed:X,offsets:J,words:Q}:null}function m2(Z,z,$=[]){if(x0(z)!=="read")return!1;let J=l(Z),Y=Z.words.filter((M,V)=>!Z.redirects.has(V)),X=KZ(Y.map((M)=>h0(M.text)));if(X===null)return!1;let Q=[J<0?1/0:J,X.index<0?1/0:Z.words.indexOf(Y[X.index])];if(Z.words.some((M,V)=>V<Math.max(...Q)&&!Z.redirects.has(V)&&bZ.test(E(M.text))))return!1;if([J<0?null:Z.words[J].text,X.index<0?null:Y[X.index].text].every((M)=>M===null||e2.has(o(E(M)))))return!0;let K=Y.filter((M)=>!$.includes(M)),B=K.map((M)=>E(M.text));return MZ(K.map((M)=>M.text).join(" "))==="read"&&MZ(B.join(" "))==="read"&&!B.some((M)=>o2.has(M))}function g5(Z,z,$,J){let Y=(X)=>X.start<J&&X.end>$;if(!z.words.some(Y))return!1;return z.lexed.segments.filter((X)=>X.words.some(Y)).some((X)=>Z0(X))}var p2=(Z,z)=>Z.slice(z.words[0].start,z.words[z.words.length-1].end);function u5(Z,z,$,J){let Y=(Q)=>Q.start<J&&Q.end>$,X=z.words.filter(Y);if(X.length===0||X.some((Q)=>!w5.test(Q.text)))return!1;for(let Q of z.lexed.segments.filter((H)=>H.words.some(Y)))if(!m2(Q,p2(Z,Q),z.words))return!1;for(let Q of X){let H=Q.text.slice(1,-1);if(H.includes("<<"))return!1;let K=f(H);if(!K.trustworthy||K.substitutions.length>0)return!1;if(!K.segments.every((B)=>m2(B,p2(H,B))))return!1}return!0}function c2(Z,z,$){if(!Z)return[];let J=i2(z),Y=(U)=>J.some((j)=>U===j||U.startsWith(`${j}${O.sep}`)),X=Z.split(h5),Q=l2(Z,X),H=Q??l2(Z,X,!0),K=[],B=[$],M=new Set([$]),V=!0,G=[];for(let U=0;U<X.length;U+=2){let j=U===0?"":X[U-1].trim();if(j==="||")V=!1;else if(j!=="&&")V=!0;if(j!=="&&"||!V)B=[...M];let N=X[U],y=(N.match(/^[\s({]*/)?.[0].match(/\(/g)??[]).length,b=(N.match(/[\s)}]*$/)?.[0].match(/\)/g)??[]).length;for(let _=0;_<y;_++)G.push({current:[...B],reachable:new Set(M),certain:V});let k=F5(N),d=Q!==null&&u5(Z,Q,Q.offsets[U],Q.offsets[U]+N.length),q=!d&&(H!==null&&g5(Z,H,H.offsets[U],H.offsets[U]+N.length)||$0(N.trim())),F=k.match(/^cd(?:\s+(?:-[A-Za-z@]+|--))*(?:\s+([^\s;&|<>()\x60]+))?$/),R=F?null:k.match(/(?:^|\s)cd(?:\s+(?:-[A-Za-z]+|--))*\s+([^\s;&|<>()\x60]+)/);if(R){for(let _ of g2(R[1],B,z)??[])M.add(_);V=!1,B=[...M]}let m=S0(z),p=J.map((_)=>S0(_.slice(z.length+1))).join("|"),qZ=new RegExp(`(?:~|\\$HOME"*|\\$\\{HOME\\}"*|${m}"*)/(?:${p})`),z2=new RegExp(`(${qZ.source})([^\\s"';&|<>()\`]*|$)`,"g"),Y2=(_)=>{let g=[],c;z2.lastIndex=0;while((c=z2.exec(_))!==null)g.push(O.normalize(mZ(c[0],z)).replace(/\/+$/,""));return g},X2=H===null?0:H.offsets[U],Q2=(_)=>_.start<X2+N.length&&_.end>X2,T3=H!==null&&H.words.some(Q2)?lZ({segments:H.lexed.segments.filter((_)=>_.words.some(Q2))}):[N.trim(),k].flatMap((_)=>{let g=f(_);if(!g.trustworthy)g=f(NZ(_));return g.trustworthy?lZ(g):[]}),V0=U5(k).map((_,g)=>{let c=g===0?[...new Set(T3)]:[],CZ=!1,PZ=s2(_).replace(G5,(U0,UZ)=>{if(!UZ||/[$\x60]/.test(UZ))CZ=!0;if(UZ)c.push(UZ);return" "}),OZ=d?"read":q?"delete":x0(PZ);return{commandPart:PZ,operands:c,op:CZ&&OZ==="read"?"write":OZ}}),q3=V0.some((_)=>_.op==="delete")?"delete":V0.some((_)=>_.op==="write")?"write":"read",G0=B.filter(Y);if(q)for(let _ of G0)K.push({path:_,op:"delete"});for(let _ of V0){let g=!1;for(let u of Y2(_.commandPart))g=!0,K.push({path:u,op:q3});for(let u of _.operands){let e=Y2(u);for(let n of e)K.push({path:n,op:"write"});if(e.length>0)continue;for(let n of G0)K.push({path:O.normalize(O.resolve(n,mZ(u,z))),op:"write"})}if(g||_.op==="read")continue;let c=j5(_.commandPart),CZ=D5(_.commandPart,c),PZ=o(c[CZ]?.text??""),OZ=c.slice(CZ+1),U0=((PZ==="trash"?O5(OZ):null)??I5(PZ,OZ)).map((u)=>u.opaque?".":u.text),UZ=_.op==="delete"||/(?:^|\s)\\?(?:[^\s;&|<>()]*\/)?(?:mkdir|mkfile|touch|tee|truncate|install|mv)(?:\s|$)/.test(_.commandPart)||/(?:^|\s)sed(?:\s|$)/.test(_.commandPart)&&/(?:^|\s)(?:-i\S*|--in-place\S*)(?:\s|$)/.test(_.commandPart),LZ=[];if(UZ)for(let u of U0.length>0?U0:["."])LZ.push({operand:u,op:_.op});else{let u=_.commandPart.match(_5),e=c.at(-1);if(LZ.push({operand:u?u[1]:!e||e.opaque?".":e.text,op:_.op}),/(?:^|\s)(?:cp|ln|install|mv)(?:\s|$)/.test(_.commandPart))c.forEach((n,K2)=>{let jZ,j0=n.text.match(/^-[A-Za-z]*?t(.*)$/),cZ=n.text.match(/^(--t[a-z-]*)(?:=(.*))?$/);if(j0&&!n.text.startsWith("--"))jZ=j0[1]?{text:j0[1],opaque:n.opaque}:c[K2+1];else if(cZ&&"--target-directory".startsWith(cZ[1]))jZ=cZ[2]!==void 0?{text:cZ[2],opaque:n.opaque}:c[K2+1];if(jZ)LZ.push({operand:jZ.opaque||!jZ.text?".":jZ.text,op:_.op})});if(/(?:^|\s)(?:python3?|node|bun)\b[^;&|]*\s+-[ce](?:\s|$)/.test(_.commandPart))LZ.push({operand:".",op:_.op})}for(let u of G0)for(let{operand:e,op:n}of LZ)K.push({path:O.normalize(O.resolve(u,mZ(e,z))),op:n})}if(F){let _=g2(F[1],B,z);if(_){for(let g of _)M.add(g);if(V)B=_}else V=!1}for(let _=0;_<b&&G.length>0;_++)({current:B,reachable:M,certain:V}=G.pop())}return K}var l5=/^\s*\*\*\*\s+(Add File|Update File|Delete File):\s+(\S+)\s*$/gm;function m5(Z,z){let $=[],J;while((J=l5.exec(Z))!==null){let Y=J[1]==="Delete File"?"delete":"write";$.push({path:O.normalize(O.resolve(z,J[2])),op:Y})}return $}function J3(Z,z={}){let $=[];if(Z.hook_event_name!=="PreToolUse")return{output:{continue:!0},warnings:$};let J=typeof Z.tool_name==="string"?Z.tool_name:"",Y=z.home??f0.homedir(),X=i2(Y),Q=M5(process.env,Y);if(J==="Bash"){let G=WZ(Z);if(!G)return{output:{continue:!0},warnings:$};let U=typeof Z.cwd==="string"&&Z.cwd?Z.cwd:process.cwd(),j=J0(G,Y,U);j.unshift(...HZ(G,()=>J0(G,Y,U))??[]);for(let N of j)for(let y of X){let b=v0(N.path,y,Q,N.op);if(b.blocked)return{output:{decision:"block",reason:b.reason},warnings:$}}return{output:{continue:!0},warnings:$}}let H=Z.tool_input??{},K=typeof Z.cwd==="string"&&Z.cwd?Z.cwd:process.cwd();if(z5.has(J)){let G=typeof H.patch==="string"?H.patch:"";if(!G)return{output:{continue:!0},warnings:$};let U=m5(G,K);for(let j of U)for(let N of X){let y=v0(j.path,N,Q,j.op);if(y.blocked)return{output:{decision:"block",reason:y.reason},warnings:$}}return{output:{continue:!0},warnings:$}}if(!J5.has(J))return{output:{continue:!0},warnings:$};let B=typeof H.file_path==="string"?H.file_path:typeof H.path==="string"?H.path:typeof H.notebook_path==="string"?H.notebook_path:null;if(!B)return{output:{continue:!0},warnings:$};let M=mZ(B,Y),V=O.isAbsolute(M)?O.normalize(M):O.resolve(K,M);for(let G of X){let U=v0(V,G,Q,"write");if(U.blocked)return{output:{decision:"block",reason:U.reason},warnings:$}}return{output:{continue:!0},warnings:$}}var p5=new Set(["id","node_id","databaseId","fullDatabaseId","number","state","state_reason","stateReason","status","conclusion","bucket","name","login","sha","oid","abbreviatedOid","ref","headRefName","baseRefName","headRefOid","baseRefOid","head_sha","headSha","head_branch","headBranch","merged","mergeable","mergeable_state","mergeStateStatus","draft","isDraft","locked","isLocked","title","displayTitle","display_title","created_at","updated_at","closed_at","merged_at","started_at","completed_at","submitted_at","pushed_at","published_at","createdAt","updatedAt","closedAt","mergedAt","startedAt","completedAt","submittedAt","pushedAt","publishedAt","tag_name","tagName","total_count","totalCount","count","additions","deletions","changes","changed_files","changedFiles","filename","path","event","workflow","workflowName","workflow_id","workflowDatabaseId","run_id","run_number","run_attempt","attempt","check_suite_id","default_branch","defaultBranch","full_name","fullName","nameWithOwner","private","isPrivate","visibility","archived","isArchived","fork","isFork","isRequired","is_required","required","context","type","__typename","role","permission","size","reviewDecision","author_association","authorAssociation","isCrossRepository","maintainerCanModify","maintainer_can_modify","commentsCount","language","digest","size_in_bytes","run_started_at","date","wait_timer","ahead_by","behind_by","total_commits","expired","current_user_can_approve","environment","html_url"]),c5=new Set(["payload","client_payload","inputs","config","metadata","output","properties","custom_properties","variables"]),Q3=new Set(["length","utf8bytelength","not","type","any","all","isempty","empty","test","startswith","endswith","contains","inside","has","in","index","rindex","indices","floor","ceil","round","fabs","sqrt","isinfinite","isnan","isnormal","infinite","nan","true","false","null"]),K3=new Set(["tostring","tojson","ascii_downcase","ascii_upcase","ltrimstr","rtrimstr","trim","ltrim","rtrim","sort","unique","reverse","first","last","min","max","add","flatten","join","split","values","nulls","strings","numbers","booleans","arrays","objects","iterables","scalars","sort_by","group_by","unique_by","min_by","max_by","select","limit","to_entries","from_entries"]),i5=new Set(["test","startswith","endswith","contains","inside","has","in","index","rindex","indices","ltrimstr","rtrimstr","join","split","flatten","limit"]),d5=new Set(["@text","@json","@csv","@tsv","@sh","@base64","@uri","@html"]);class u0 extends Error{}var L=()=>{throw new u0};function w0(Z,z){let $=[],J="",Y=z+1;while(Y<Z.length){let X=Z[Y];if(X==='"'){if(J)$.push(J);return{end:Y+1,parts:$}}if(X==="\\"){let Q=Z[Y+1];if(Q==="("){let H=1,K=Y+2;while(K<Z.length&&H>0){let B=Z[K];if(B==='"'){K=w0(Z,K).end;continue}if(B==="(")H++;else if(B===")")H--;K++}if(H!==0)L();if(J)$.push(J),J="";$.push({src:Z.slice(Y+2,K-1)}),Y=K;continue}if(Q===void 0)L();J+=Q,Y+=2;continue}J+=X,Y++}return L()}function H3(Z){let z=[],$=0,J=["?//","|=","+=","-=","*=","/=","%=","//=","==","!=","<=",">=","//","|",",","+","-","*","/","%","<",">","=","(",")","[","]","{","}",":",";","?"];while($<Z.length){let Y=Z[$];if(/\s/.test(Y)){$++;continue}if(Y==="#")L();if(Y==='"'){let K=w0(Z,$);z.push({t:"str",parts:K.parts}),$=K.end;continue}if(Y==="."){if(Z[$+1]===".")L();let K=/^[A-Za-z_][A-Za-z0-9_]*/.exec(Z.slice($+1));if(K){z.push({t:"field",name:K[0]}),$+=1+K[0].length;continue}if(Z[$+1]==='"'){let B=w0(Z,$+1);if(B.parts.some((M)=>typeof M!=="string"))L();z.push({t:"field",name:B.parts.join("")}),$=B.end;continue}z.push({t:"dot"}),$++;continue}if(Y==="$"||Y==="@"){let K=/^[@$][A-Za-z_][A-Za-z0-9_]*/.exec(Z.slice($));if(!K||Y==="$")L();z.push({t:"fmt",name:K[0]}),$+=K[0].length;continue}let X=/^[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/.exec(Z.slice($));if(X){z.push({t:"num"}),$+=X[0].length;continue}let Q=/^[A-Za-z_][A-Za-z0-9_]*(?:::[A-Za-z_][A-Za-z0-9_]*)*/.exec(Z.slice($));if(Q){z.push({t:"ident",name:Q[0]}),$+=Q[0].length;continue}let H=J.find((K)=>Z.startsWith(K,$));if(!H)L();z.push({t:"op",v:H}),$+=H.length}return z}var s5=new Set(["if","then","elif","else","end","as","def","reduce","foreach","try","catch","label","import","include","and","or","__loc__","error","input","inputs","debug","stderr","env","halt","halt_error","input_filename","input_line_number","recurse","paths","leaf_paths","getpath","setpath","delpaths","del","path","splits","sub","gsub","capture","match","scan","keys","keys_unsorted","map_values","with_entries","tostream","fromstream","truncate_stream","walk","tonumber","implode","explode","ascii","fromjson"]);class l0{tokens;at=0;constructor(Z){this.tokens=Z}parse(){if(this.tokens.length===0)L();let Z=this.pipe();if(this.at!==this.tokens.length)L();return Z}peek(){return this.tokens[this.at]}isOp(Z){let z=this.peek();return!!z&&z.t==="op"&&z.v===Z}isIdent(Z){let z=this.peek();return!!z&&z.t==="ident"&&z.name===Z}expectOp(Z){if(!this.isOp(Z))L();this.at++}pipe(){let Z=this.comma();if(this.isIdent("as"))L();if(this.isOp("|"))this.at++,Z={k:"pipe",a:Z,b:this.pipe()};return Z}comma(){let Z=this.alt();while(this.isOp(","))this.at++,Z={k:"comma",a:Z,b:this.alt()};return Z}alt(){let Z=this.or();if(this.isOp("//"))return this.at++,{k:"alt",a:Z,b:this.alt()};return Z}or(){let Z=this.and();while(this.isIdent("or"))this.at++,Z={k:"bool",a:Z,b:this.and()};return Z}and(){let Z=this.cmp();while(this.isIdent("and"))this.at++,Z={k:"bool",a:Z,b:this.cmp()};return Z}cmp(){let Z=this.add();for(let z of["==","!=","<=",">=","<",">"])if(this.isOp(z))return this.at++,{k:"bool",a:Z,b:this.add()};for(let z of["=","|=","+=","-=","*=","/=","%=","//=","?//"])if(this.isOp(z))L();return Z}add(){let Z=this.mul();while(this.isOp("+")||this.isOp("-"))this.at++,Z={k:"arith",a:Z,b:this.mul()};return Z}mul(){let Z=this.unary();while(this.isOp("*")||this.isOp("/")||this.isOp("%"))this.at++,Z={k:"arith",a:Z,b:this.unary()};return Z}unary(){if(this.isOp("-"))return this.at++,{k:"neg",of:this.postfix()};return this.postfix()}objectValue(){let Z=this.unary();if(this.isOp("|"))this.at++,Z={k:"pipe",a:Z,b:this.objectValue()};return Z}postfix(){let Z=this.primary();for(;;){let z=this.peek();if(!z)return Z;if(z.t==="field"){this.at++,Z={k:"field",name:z.name,of:Z};continue}if(z.t==="dot"&&this.tokens[this.at+1]?.t==="op"&&this.tokens[this.at+1].v==="["){this.at++;continue}if(z.t==="op"&&z.v==="?"){this.at++,Z={k:"opt",of:Z};continue}if(z.t==="op"&&z.v==="["){Z=this.bracket(Z);continue}return Z}}bracket(Z){if(this.expectOp("["),this.isOp("]"))return this.at++,{k:"iter",of:Z};if(this.isOp(":")){if(this.at++,!this.isOp("]"))this.pipe();return this.expectOp("]"),{k:"slice",of:Z}}let z=this.pipe();if(this.isOp(":")){if(this.at++,!this.isOp("]"))this.pipe();return this.expectOp("]"),{k:"slice",of:Z}}return this.expectOp("]"),{k:"index",of:Z,key:z}}primary(){let Z=this.peek();if(!Z)return L();switch(this.at++,Z.t){case"dot":return{k:"dot"};case"field":return{k:"field",name:Z.name};case"num":return{k:"lit"};case"str":return this.stringNode(Z.parts);case"fmt":{if(!d5.has(Z.name))L();let z=this.peek();if(z?.t==="str")return this.at++,{k:"fmt",name:Z.name,str:this.stringNode(z.parts)};return{k:"fmt",name:Z.name}}case"ident":{if(s5.has(Z.name))L();if(Z.name==="map"||Q3.has(Z.name)||K3.has(Z.name)){let z=[];if(this.isOp("(")){this.at++,z.push(this.pipe());while(this.isOp(";"))this.at++,z.push(this.pipe());this.expectOp(")")}return{k:"call",name:Z.name,args:z}}return L()}case"op":{if(Z.v==="("){let z=this.pipe();return this.expectOp(")"),z}if(Z.v==="["){if(this.isOp("]"))return this.at++,{k:"array"};let z=this.pipe();return this.expectOp("]"),{k:"array",of:z}}if(Z.v==="{")return this.object();return L()}}return L()}stringNode(Z){let z=[];for(let $ of Z){if(typeof $==="string")continue;z.push(new l0(H3($.src)).parse())}return z.length===0?{k:"str",parts:z,text:Z.join("")}:{k:"str",parts:z}}object(){let Z=[];if(this.isOp("}"))return this.at++,{k:"object",entries:Z};for(;;){let z=this.peek();if(!z)L();this.at++;let $;if(z.t==="ident")$=z.name;else if(z.t==="str"){if(z.parts.some((J)=>typeof J!=="string"))L();$=z.parts.join("")}else L();if(this.isOp(":"))this.at++,Z.push({key:"static",value:this.objectValue()});else Z.push({key:"static",value:{k:"field",name:$}});if(this.isOp(",")){this.at++;continue}return this.expectOp("}"),{k:"object",entries:Z}}}}function m0(Z){if(typeof Z==="object"&&"union"in Z)return Z.union.every(m0);return Z==="safe"||typeof Z==="object"&&p5.has(Z.leaf)}var pZ=(...Z)=>Z.every(m0)?"safe":"tainted";function g0(...Z){let z=[];for(let $ of Z)if(typeof $==="object"&&"union"in $)z.push(...$.union);else z.push($);return z.length===1?z[0]:{union:z}}function z0(Z,z){return typeof Z==="object"&&"union"in Z?g0(...Z.union.map(z)):z(Z)}var Y0=(Z)=>typeof Z==="object"&&("leaf"in Z)&&c5.has(Z.leaf),zZ=(Z)=>z0(Z,(z)=>z==="safe"?"safe":z==="tainted"||Y0(z)?"tainted":"unknown");function z3(Z){return Z.k==="lit"||Z.k==="str"&&Z.parts.length===0||Z.k==="call"&&["true","false","null"].includes(Z.name)&&Z.args.length===0}function Y3(Z,z,$){return z0(Z,(J)=>{if(J==="safe"||J==="tainted")return J;if(Y0(J))return"tainted";if(J==="root"&&$.rootScalars.has(z))return"safe";return{leaf:z}})}function A(Z,z,$){switch(Z.k){case"dot":return z;case"field":return Y3(Z.of?A(Z.of,z,$):z,Z.name,$);case"iter":return zZ(A(Z.of,z,$));case"index":{let J=A(Z.of,z,$);if(Z.key.k==="str"&&Z.key.text!==void 0)return Y3(J,Z.key.text,$);if(Z.key.k==="lit")return zZ(J);return A(Z.key,z,$),"tainted"}case"slice":return z0(A(Z.of,z,$),(J)=>J==="root"?"unknown":Y0(J)?"tainted":J);case"opt":return A(Z.of,z,$);case"lit":return"safe";case"str":return pZ(...Z.parts.map((J)=>A(J,z,$)));case"fmt":return Z.str?A(Z.str,z,$):z;case"array":return Z.of?pZ(A(Z.of,z,$)):"safe";case"object":return pZ(...Z.entries.map((J)=>A(J.value,z,$)));case"pipe":return A(Z.b,A(Z.a,z,$),$);case"comma":return g0(A(Z.a,z,$),A(Z.b,z,$));case"alt":return g0(A(Z.a,z,$),A(Z.b,z,$));case"bool":return A(Z.a,z,$),A(Z.b,z,$),"safe";case"arith":return pZ(A(Z.a,z,$),A(Z.b,z,$));case"neg":return A(Z.of,z,$);case"call":return n5(Z,z,$)}}var X3=(Z)=>z0(Z,(z)=>z==="root"?"unknown":Y0(z)?"tainted":z);function n5(Z,z,$){let{name:J,args:Y}=Z;if(i5.has(J)&&J!=="limit"&&!Y.every(z3))L();switch(J){case"map":if(Y.length!==1)L();return pZ(A(Y[0],zZ(z),$));case"select":if(Y.length!==1)L();return A(Y[0],z,$),z;case"limit":if(Y.length!==2||!z3(Y[0]))L();return A(Y[1],z,$);case"first":case"last":if(Y.length>1)L();return Y.length===1?A(Y[0],z,$):zZ(z);case"min":case"max":return zZ(z);case"sort_by":case"group_by":case"unique_by":if(Y.length!==1)L();return A(Y[0],zZ(z),$),X3(z);case"min_by":case"max_by":if(Y.length!==1)L();return A(Y[0],zZ(z),$),zZ(z);case"any":case"all":case"isempty":for(let X of Y)A(X,"unknown",$);return"safe"}if(Q3.has(J))return"safe";if(K3.has(J))return X3(z);return L()}function B3(Z,z={}){if(typeof Z!=="string"||!Z.trim()||Z.length>4096)return!1;try{let $=new l0(H3(Z)).parse();return m0(A($,"root",{rootScalars:z.rootScalars??new Set}))}catch($){if($ instanceof u0)return!1;return!1}}var r0="composite output withheld: signed-link shape; use bounded scalar projections per class disposition 799310",T={refused:!1},I=(Z)=>({refused:!0,rule:Z}),p0=new Set(["additions","assignees","author","baseRefName","baseRefOid","changedFiles","closed","closedAt","createdAt","deletions","files","fullDatabaseId","headRefName","headRefOid","headRepository","headRepositoryOwner","id","isCrossRepository","isDraft","labels","maintainerCanModify","mergeCommit","mergeStateStatus","mergeable","mergedAt","mergedBy","number","potentialMergeCommit","reactionGroups","reviewDecision","reviewRequests","state","title","updatedAt","url"]),c0=new Set(["assignees","author","closed","closedAt","createdAt","id","isPinned","labels","number","reactionGroups","state","stateReason","subIssuesSummary","title","updatedAt","url"]),M3=new Set(["apiUrl","author","createdAt","databaseId","id","isDraft","isImmutable","isLatest","isPrerelease","name","publishedAt","tagName","tarballUrl","targetCommitish","uploadUrl","url","zipballUrl"]),V3=new Set(["answerChosenAt","answerChosenBy","answered","author","closed","closedAt","createdAt","id","labels","locked","number","reactionGroups","state","stateReason","title","updatedAt","url"]),o5=new Set(["assignees","author","authorAssociation","closedAt","commentsCount","createdAt","id","isDraft","isLocked","isPullRequest","labels","number","repository","state","title","updatedAt","url"]),a5=new Set(["author","committer","id","parents","repository","sha","url"]),r5=new Set(["bucket","completedAt","event","name","startedAt","state","workflow"]);function j3(Z){let z=[];for(let $=0;$<Z.length;$++){let J=Z[$];if(J==="\\"){$++;continue}if(J==="'"){let Y=Z.indexOf("'",$+1);if(Y<0)return!1;$=Y;continue}if(J==='"'){$++;while($<Z.length&&Z[$]!=='"')$+=Z[$]==="\\"?2:1;continue}if(J==="{"){z.push({list:!1});continue}if(z.length===0)continue;if(J===","||J==="."&&Z[$+1]===".")z[z.length-1].list=!0;else if(J==="}"&&z.pop().list)return!0}return!1}function IZ(Z){let z="",$=!1,J=0,Y=(X)=>Z[X]==="`"||Z[X]==="$"&&/[A-Za-z_{(@*#?$!0-9-]/.test(Z[X+1]??"");while(J<Z.length){let X=Z[J];if(X==="\\"){z+=Z[J+1]??"",J+=2;continue}if(X==="$"&&Z[J+1]==="'"){$=!0,z+=X,J++;continue}if(X==="'"){let Q=Z.indexOf("'",J+1);if(Q<0){$=!0,z+=Z.slice(J+1);break}z+=Z.slice(J+1,Q),J=Q+1;continue}if(X==='"'){J++;while(J<Z.length&&Z[J]!=='"'){if(Z[J]==="\\"&&/[$`"\\\n]/.test(Z[J+1]??"")){z+=Z[J+1],J+=2;continue}if(Y(J))$=!0;z+=Z[J],J++}if(J>=Z.length)$=!0;J++;continue}if(Y(J)||X==="*"||X==="?"||X==="[")$=!0;z+=X,J++}if(!$&&Z.includes("{")&&j3(Z))$=!0;return{value:z,opaque:$,raw:Z}}var VZ=(Z)=>Z.slice(Z.lastIndexOf("/")+1);function s0(Z,z="word"){let $=[],J=!1;for(let Y=0;Y<Z.length;Y++){let X=Z[Y];if(X==="\\"){Y++;continue}if(z==="word"&&X==="'"&&!J){let Q=Z.indexOf("'",Y+1);if(Q<0)return{bodies:$,complete:!1};Y=Q;continue}if(z==="word"&&X==='"'){J=!J;continue}if(X==="`"){let Q=Y+1;while(Q<Z.length&&Z[Q]!=="`")Q+=Z[Q]==="\\"?2:1;if(Q>=Z.length)return{bodies:$,complete:!1};$.push(Z.slice(Y+1,Q)),Y=Q;continue}if(X==="$"&&Z[Y+1]==="("){let Q=BZ(Z,Y+1);if(Q<0)return{bodies:$,complete:!1};$.push(Z.slice(Y+2,Q-1)),Y=Q-1}}return{bodies:$,complete:!0}}function TZ(Z,z){let $=new Set(z.values),J={flags:[],positionals:[]},Y=(X,Q)=>({value:X,opaque:Q.opaque,raw:Q.raw});for(let X=0;X<Z.length;X++){let Q=Z[X],H=Q.value;if(H==="--"){J.positionals.push(...Z.slice(X+1));break}if(H.startsWith("--")&&H.length>2){let K=H.indexOf("="),B=K>=0?H.slice(0,K):H;if(K>=0)J.flags.push({name:B,value:Y(H.slice(K+1),Q),inline:!0});else if($.has(B)){let M=Z[X+1];J.flags.push(M?{name:B,value:M}:{name:B,missing:!0}),X++}else J.flags.push({name:B});continue}if(H.startsWith("-")&&H.length>1){for(let K=1;K<H.length;K++){let B="-"+H[K],M=H.slice(K+1);if(M.startsWith("=")){J.flags.push({name:B,value:Y(M.slice(1),Q),inline:!0});break}if(!$.has(B)){J.flags.push({name:B});continue}if(M)J.flags.push({name:B,value:Y(M,Q),inline:!0});else{let V=Z[X+1];J.flags.push(V?{name:B,value:V}:{name:B,missing:!0}),X++}break}continue}J.positionals.push(Q)}return J}function w(Z,...z){let $=!1;for(let J of Z.flags){if(!z.includes(J.name))continue;if(!J.inline){$=!0;continue}let Y=J.value;$=!Y.opaque&&["1","t","T","TRUE","true","True"].includes(Y.value)}return $}var XZ=(Z,...z)=>Z.flags.filter(($)=>z.includes($.name)),s=["-R","--repo","-q","--jq","-t","--template","--json"],GZ={"pr view":{values:s},"issue view":{values:s},"release view":{values:s},"discussion view":{values:[...s,"--after","-L","--limit","--order"]},"pr list":{values:[...s,"--app","-a","--assignee","-A","--author","-B","--base","-H","--head","-l","--label","-L","--limit","-S","--search","-s","--state"]},"issue list":{values:[...s,"--app","-a","--assignee","-A","--author","-l","--label","-L","--limit","--mention","-m","--milestone","-S","--search","-s","--state"]},"discussion list":{values:[...s,"--after","-A","--author","-c","--category","-l","--label","-L","--limit","--order","-S","--search","--sort","-s","--state"]},"release list":{values:[...s,"-L","--limit","-O","--order"]},"pr status":{values:s},"issue status":{values:s},"pr checks":{values:[...s,"-i","--interval"]},"pr diff":{values:["-R","--repo"]},search:{values:[...s,"--app","--assignee","--author","--author-date","--author-email","--author-name","--base","--checks","--closed","--commenter","--committer","--committer-date","--committer-email","--committer-name","--created","--hash","--head","--interactions","--involves","--label","--language","--limit","-L","--match","--mentions","--merged-at","--milestone","--no-assignee","--no-label","--no-milestone","--no-project","--order","--owner","--parent","--project","--reactions","--review","--review-requested","--reviewed-by","--sort","--state","--team-mentions","--tree","--updated","--visibility","--extension","--filename","--size","--forks","--good-first-issue","--help-wanted-issues","--number-topics","--stars","--topic","--followers","--include-forks","--license"]},"project item-list":{values:["--format","-L","--limit","--owner","-q","--jq","-t","--template","--query","--field","--field-id"]},api:{values:["-X","--method","-H","--header","-f","--raw-field","-F","--field","-q","--jq","-t","--template","-p","--preview","--input","--hostname","--cache"]},group:{values:["-R","--repo"]}},t5=new Set(["auth","browse","codespace","cs","gist","org","repo","skill","cache","run","workflow","co","agent-task","alias","attestation","completion","config","copilot","extension","ext","extensions","gpg-key","label","licenses","preview","ruleset","secret","ssh-key","variable","help","version","accessibility","actions","environment","exit-codes","formatting","mintty","reference","telemetry"]),e5=new Set(["pr","issue","release","discussion","search","project","api","status"]),Z6=new Set(["create","new","checkout","co","close","comment","edit","lock","merge","ready","reopen","revert","review","unlock","update-branch"]),$6=new Set(["create","new","close","comment","delete","develop","edit","lock","pin","reopen","transfer","unlock","unpin"]),J6=new Set(["create","new","delete","delete-asset","download","edit","upload","verify","verify-asset"]),z6=new Set(["create","new","close","comment","delete","edit","lock","reopen","unlock","answer","unanswer"]);function H0(Z,z){let $=XZ(Z,"--json"),J=[],Y=!1;for(let X of $){if(X.missing){if(z.appendsArgs)Y=!0;continue}if(!X.value)continue;if(X.value.opaque)Y=!0;J.push(...X.value.value.split(",").map((Q)=>Q.trim()).filter(Boolean))}return{present:$.length>0,opaque:Y,fields:J}}function t0(Z,z){if(w(Z,"--verbose")||XZ(Z,"-t","--template").length>0)return!1;let $=XZ(Z,"-q","--jq");return $.length>0&&$.every((J)=>J.value!==void 0&&!J.value.opaque&&B3(J.value.value,{rootScalars:z}))}function e0(Z,z,$,J){let Y=H0(Z,$);if(Y.opaque)return I("unclassifiable");if(Y.fields.every((X)=>z.has(X)))return T;if($.debug)return I("debug-traffic");return t0(Z)?T:I(J)}function X0(Z,z,$,J,Y){let X=TZ(Z,GZ[z]);if(w(X,"-h","--help"))return T;if(w(X,"-w","--web"))return J.debug?I("debug-traffic"):T;if(Y&&w(X,"-c","--comments"))return I("view-comments");if(!H0(X,J).present)return I(J.debug?"debug-traffic":"view-human");return e0(X,$,J,"json-composite")}function YZ(Z,z,$,J){let Y=TZ(Z,GZ[z]);if(w(Y,"-h","--help"))return T;if(J.debug&&(w(Y,"-w","--web")||!H0(Y,J).present))return I("debug-traffic");if(w(Y,"-w","--web"))return T;return e0(Y,$,J,"json-composite")}function Y6(Z,z){let $=TZ(Z,GZ["pr checks"]);if(w($,"-h","--help"))return T;if(z.debug)return I("debug-traffic");if(w($,"-w","--web"))return T;if(!H0($,z).present)return I("checks-human");return e0($,r5,z,"checks-json")}function X6(Z){let z=new Set(GZ.group.values);for(let $=0;$<Z.length;$++){let J=Z[$].value;if(J==="--")return{sub:Z[$+1],rest:Z.slice($+2)};if(!J.startsWith("-")||J==="-")return{sub:Z[$],rest:[...Z.slice(0,$),...Z.slice($+1)]};if(z.has(J))$++}return{rest:Z}}function Q6(Z,z,$){let{sub:J,rest:Y}=X6(z);if(!J)return $.appendsArgs?I("unclassifiable"):T;if(J.opaque)return I("unclassifiable");let X=J.value;if((Z==="pr"?Z6:Z==="issue"?$6:Z==="release"?J6:Z==="discussion"?z6:new Set).has(X))return $.debug?I("debug-traffic"):T;if($.appendsArgs&&!(Z==="project"&&X!=="item-list"))return I("unclassifiable");switch(Z){case"pr":if(X==="view")return X0(Y,"pr view",p0,$,!0);if(X==="list"||X==="ls")return YZ(Y,"pr list",p0,$);if(X==="status")return YZ(Y,"pr status",p0,$);if(X==="checks")return Y6(Y,$);if(X==="diff"){let H=TZ(Y,GZ["pr diff"]);if(w(H,"-h","--help"))return T;if($.debug)return I("debug-traffic");return w(H,"--patch")?I("composite-other"):T}return I("unclassifiable");case"issue":if(X==="view")return X0(Y,"issue view",c0,$,!0);if(X==="list"||X==="ls")return YZ(Y,"issue list",c0,$);if(X==="status")return YZ(Y,"issue status",c0,$);return I("unclassifiable");case"release":if(X==="view")return X0(Y,"release view",M3,$,!1);if(X==="list"||X==="ls")return YZ(Y,"release list",M3,$);return I("unclassifiable");case"discussion":if(X==="view")return X0(Y,"discussion view",V3,$,!0);if(X==="list"||X==="ls")return YZ(Y,"discussion list",V3,$);return I("unclassifiable");case"search":if(X==="prs"||X==="issues")return YZ(Y,"search",o5,$);if(X==="commits")return YZ(Y,"search",a5,$);if(X==="code"||X==="repos")return $.debug?I("debug-traffic"):T;return I("unclassifiable");case"project":{if($.debug)return I("debug-traffic");if(X!=="item-list")return T;let H=TZ(Y,GZ["project item-list"]);if(w(H,"-h","--help"))return T;let K=XZ(H,"--format");if(K.some((B)=>!B.value||B.value.opaque))return I("unclassifiable");if(K.every((B)=>B.value.value!=="json"))return T;return t0(H)?T:I("composite-other")}}return I("unclassifiable")}var W3=new Set(["pulls","issues","commits","check-runs","check-suites","statuses","comments","releases","compare","events","discussions","deployments","milestones"]);function K6(Z){let z=Z.value.trim(),$=/^https?:\/\/([^/]+)(\/.*)?$/i.exec(z);if($){let X=$[1].toLowerCase(),Q=$[2]??"/";if(X==="api.github.com"||/^api\./.test(X))z=Q;else if(/^\/api\/v3(?:\/|$)/i.test(Q))z=Q.replace(/^\/api\/v3/i,"");else if(/^\/api\/graphql(?:[/?#]|$)/i.test(Q))z="graphql";else return null}z=z.replace(/[?#].*$/,"");let J=[],Y=[];for(let X of z.split("/")){let Q;try{Q=decodeURIComponent(X)}catch{return null}for(let H of Q.split("/")){if(H===""||H===".")continue;if(H===".."){J.pop(),Y.pop();continue}J.push(H.toLowerCase()),Y.push(Z.opaque&&/[$`]/.test(H)||/[*?[]/.test(H)||j3(H))}}return{segments:J,opaque:Y}}function H6(Z){let z=K6(Z);if(!z)return{kind:"unclassifiable",segments:[]};let{segments:$,opaque:J}=z,Y=(K)=>({kind:K,segments:$});if($.length===1&&$[0]==="graphql")return Y("graphql");if($.length===0)return Y(Z.opaque?"unclassifiable":"other");if(J[0])return Y("unclassifiable");let X,Q=[];if($[0]==="repos")X=$.slice(3),Q=J.slice(3);else if($[0]==="repositories")X=$.slice(2),Q=J.slice(2);if(X){if(($[0]==="repos"?J.slice(1,3):J.slice(1,2)).some(Boolean)){let B=J.findIndex(Boolean),M=$.findIndex((V,G)=>G>B&&!J[G]&&B6.has(V));return Y(M<0?"unclassifiable":G3($.slice(M),J.slice(M)))}return Y(G3(X,Q))}let H=$[0];if(H==="issues")return Y("sensitive");if(H==="user"&&$[1]==="issues")return Y("sensitive");if(H==="orgs"&&$[2]==="issues")return Y("sensitive");if(H==="search")return Y($[1]==="issues"||$[1]==="commits"?"sensitive":$[1]!==void 0&&J[1]?"unclassifiable":"other");if(H==="events"||H==="networks")return Y("sensitive");if((H==="users"||H==="orgs")&&$.slice(2).some((K)=>K==="events"||K==="received_events"||K==="discussions"))return Y("sensitive");if((H==="users"||H==="orgs")&&$[2]==="projectsv2"&&$[4]==="items")return Y("sensitive");if(H==="orgs"&&$[2]==="hooks"&&$[4]==="deliveries"&&$[5]!==void 0||H==="app"&&$[1]==="hook"&&$[2]==="deliveries"&&$[3]!==void 0)return Y("sensitive");if(H==="teams"&&$.includes("discussions"))return Y("sensitive");if(H==="projects"&&$.includes("cards"))return Y("sensitive");if(J.some(Boolean))return Y($.some((K)=>K==="events"||K==="discussions"||K==="issues")?"sensitive":"unclassifiable");return Y("other")}var B6=new Set([...W3,"branches","git","actions","hooks","zipball","tarball"]);function G3(Z,z){let[$,J]=Z;if($===void 0)return"other";if(z[0])return"unclassifiable";if($==="issues"&&/^\d+$/.test(J??"")&&Z[2]==="labels")return"other";if(W3.has($))return"sensitive";if($==="branches"){if(Z.length===1||Z.slice(1).some((Y)=>Y==="protection")||Z[Z.length-1]==="rename")return"other";return z.slice(1).some(Boolean)?"unclassifiable":"sensitive"}if($==="git")return J===void 0||J==="commits"||J==="tags"?"sensitive":z[1]?"unclassifiable":"other";if($==="actions"){if(J===void 0)return"sensitive";if(z[1])return"unclassifiable";if(J==="runs"||J==="jobs"){if(Z[Z.length-1]==="logs"&&Z.length>=4&&!z.some(Boolean))return"download";return"sensitive"}if(J==="workflows"&&Z[3]==="runs")return"sensitive";if(J==="artifacts"&&Z.length===4)return"download";return"other"}if($==="hooks"&&Z[2]==="deliveries"&&Z[3]!==void 0)return"sensitive";if($==="zipball"||$==="tarball")return"download";return"other"}function M6(Z,z){if(z[0]!=="repos"||z.length<5)return!1;let $=z.slice(3),J=(X)=>/^\d+$/.test($[X]??""),Y=(...X)=>$.length===X.length&&X.every((Q,H)=>typeof Q==="number"?J(H):$[H]===Q);if(Z==="DELETE")return Y("issues","comments",0)||Y("pulls","comments",0)||Y("comments",0)||Y("issues","comments",0,"reactions",0)||Y("pulls","comments",0,"reactions",0)||Y("issues",0,"reactions",0)||Y("issues",0,"labels")||$.length===4&&$[0]==="issues"&&J(1)&&$[2]==="labels"||Y("releases",0)||Y("releases","assets",0)||Y("actions","runs",0)||Y("actions","runs",0,"logs")||Y("deployments",0)||Y("milestones",0)||Y("issues",0,"lock");if(Z==="POST")return $.length===4&&$[0]==="actions"&&$[1]==="runs"&&J(2)&&["rerun","rerun-failed-jobs","cancel","force-cancel","approve"].includes($[3])||Y("actions","jobs",0,"rerun")||Y("issues",0,"labels");if(Z==="PUT")return Y("pulls",0,"merge")||Y("pulls",0,"update-branch")||Y("issues",0,"labels")||Y("issues",0,"lock");if(Z==="GET")return Y("pulls",0,"merge");return!1}function V6(Z){if(Z[0]!=="repos"||Z.length!==5||!/^\d+$/.test(Z[4]))return;if(Z[3]==="pulls")return new Set(["commits","comments","review_comments"]);if(Z[3]==="issues")return new Set(["comments"]);return}var G6=new Set(["body","bodyText","bodyHTML","bodyUrl","bodyResourcePath","comments","reviews","latestReviews","latestOpinionatedReviews","reviewThreads","url","permalink","summary","text","description","message","messageBody","messageHeadline","commitBody","commitHeadline","annotations","rawDetails","note","diff","readme","payload"]),U6=new Set(["checkRuns","checkRun","checkSuites","checkSuite","contexts","statusCheckRollup","annotations","CheckRun","CheckSuite","StatusContext","CheckAnnotation","latestStatus","status","statuses"]);function j6(Z){let z=[],$=0;while($<Z.length){let J=Z[$];if(/[\s,]/.test(J)){$++;continue}if(J==="#"){let Q=Z.indexOf(`
32
+ `,$);$=Q<0?Z.length:Q+1;continue}if(Z.startsWith('"""',$)){let Q=$+3;for(;;){let H=Z.indexOf('"""',Q);if(H<0)return null;if(Z[H-1]==="\\"){Q=H+3;continue}$=H+3;break}continue}if(J==='"'){let Q=$+1;while(Q<Z.length&&Z[Q]!=='"'&&Z[Q]!==`
33
+ `)Q+=Z[Q]==="\\"?2:1;if(Z[Q]!=='"')return null;$=Q+1;continue}let Y=/^[_A-Za-z][_0-9A-Za-z]*/.exec(Z.slice($,$+256));if(Y){z.push({kind:"name",text:Y[0]}),$+=Y[0].length;continue}let X=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/.exec(Z.slice($,$+64));if(X){$+=X[0].length;continue}if(Z.startsWith("...",$)){z.push({kind:"punct",text:"..."}),$+=3;continue}if("{}()[]:!$@=|&".includes(J)){z.push({kind:"punct",text:J}),$++;continue}return null}return z}function W6(Z){let z=j6(Z);if(!z)return!0;let $=[],J="",Y=0;for(let X=0;X<z.length;X++){let Q=z[X];if(Q.kind==="punct"){if(Q.text==="(")Y++;else if(Q.text===")"){if(Y--,Y<0)return!0}else if(Y===0&&Q.text==="{")$.push(J),J="";else if(Y===0&&Q.text==="}"){if($.pop()===void 0)return!0;J=""}continue}if(Y>0)continue;let H=z[X-1];if(H?.kind==="punct"&&(H.text==="@"||H.text==="$"))continue;if(z[X+1]?.kind==="punct"&&z[X+1].text===":")continue;if(Q.text==="on"&&H?.kind==="punct"&&H.text==="...")continue;if(H?.kind==="name"&&H.text==="on"){J=Q.text;continue}if($.length===0){J=Q.text;continue}if(G6.has(Q.text)||/(?:Url|URL|HTML|Html)$/.test(Q.text))return!0;if(Q.text==="title"&&$.some((K)=>U6.has(K)))return!0;J=Q.text}return Y!==0||$.length!==0}function N6(Z,z){let $=TZ(Z,GZ.api);if(w($,"-h","--help"))return T;let J=$.positionals[0];if(!J)return z.appendsArgs?I("unclassifiable"):T;let Y=H6(J),X=XZ($,"-X","--method"),Q=X[X.length-1],H=XZ($,"-f","--raw-field","-F","--field","--input"),K=Q?Q.value&&!Q.value.opaque?Q.value.value.toUpperCase():"?":H.length>0?"POST":"GET",B=M6(K,Y.segments),M=T;if(Y.kind==="unclassifiable")M=I("unclassifiable");else if(Y.kind==="sensitive"&&!B)M=I("api-rest");else if(Y.kind==="graphql")M=F6($);if(z.debug||w($,"--verbose")){if(Y.kind==="download"&&!M.refused)M=I("api-rest");if(M.refused)return z.debug?I("debug-traffic"):M;return T}if(z.appendsArgs&&Y.kind!=="other"&&Y.kind!=="download")return I("unclassifiable");if(!M.refused||w($,"--silent"))return T;if(t0($,V6(Y.segments)))return T;return M}function F6(Z){if(XZ(Z,"--input").length>0)return I("unclassifiable");let z=XZ(Z,"-f","--raw-field","-F","--field"),$=z.filter((J)=>J.value&&/^query=/.test(J.value.value));if($.length===0||z.some((J)=>!J.value))return I("unclassifiable");for(let J of $){let Y=J.value.value.slice(6);if((J.name==="-F"||J.name==="--field")&&Y.startsWith("@")||J.value.opaque)return I("unclassifiable");if(W6(Y))return I("api-graphql")}return T}function K0(Z,z){let $=0;while($<Z.length&&Z[$].value.startsWith("-")&&!Z[$].opaque){if(["--help","-h","--version"].includes(Z[$].value))return T;$++}if($>=Z.length)return z.appendsArgs?I("unclassifiable"):T;let J=Z[$],Y=Z.slice($+1);if(J.opaque)return I("unclassifiable");switch(J.value){case"pr":case"issue":case"release":case"discussion":case"search":case"project":return Q6(J.value,Y,z);case"api":return N6(Y,z);case"status":return Y.length>0&&Y.every((X)=>X.value==="-h"||X.value==="--help")?T:I("composite-other");case"help":case"version":return T;case"cs":case"codespace":{let X=Y.findIndex((Q)=>Q.value==="--");if(Y.some((Q)=>Q.value==="ssh")&&X>=0&&X+1<Y.length){let Q=r(Y.slice(X+1).map((H)=>H.value).join(" "),z.depth+1,z.debug);if(Q.refused)return Q}break}}if(!t5.has(J.value))return I("unclassifiable");if(z.debug)return I("debug-traffic");return T}var B0=new Set(["sh","bash","zsh","dash","ksh","ash","mksh","fish"]),_6=new Set(["su","runuser","script","flock"]),D6=new Set(["secrets","op","unbuffer","caffeinate","chronic","strace","ltrace","firejail","bwrap","nsenter","unshare","chroot","sg","retry","parallel","doppler","aws-vault","dotenv","direnv","faketime","taskset","numactl","cgexec","systemd-run","docker","podman","kubectl","mise","asdf","rtx","devbox","gosu","su-exec","setpriv","pkexec","with-contenv","uv","poetry","pipenv","npx","bunx","pnpm","yarn","nix","nix-shell","infisical","chamber","envchain","dotenvx","teller","vault","chrt","coproc","prlimit","ionice","cpulimit","trickle","proxychains","proxychains4","torsocks","tsocks","catchsegv","valgrind"]),I6=new Map([["bun",["x","exec"]],["npm",["exec","x"]],["deno",["run"]]]),T6=new Set(["-I","-L","-l","-n","-P","-s","-d","-E","-e","-a","--arg-file","--delimiter","--max-args","--max-lines","--max-procs","--max-chars","--replace","--eof","--process-slot-var"]),q6=new Set(["-b","-c","-D","-E","-e","-F","-I","-i","-J","-L","-l","-m","-O","-o","-p","-Q","-R","-S","-W","-w"]),Q0=/(?:^|[^A-Za-z0-9_.-])gh(?:$|[^A-Za-z0-9_.-])/,C6=/^([A-Za-z_][A-Za-z0-9_]*)=([\s\S]*)$/,P6=6;function U3(Z,z){let $,J;for(let Y of Z){let X=C6.exec(Y.value);if(!X)continue;let Q={...Y,value:X[2]};if(X[1]==="GH_DEBUG")$=Q;else if(X[1]==="DEBUG")J=Q}if($)return $.opaque||!["","0","false","no"].includes($.value);if(J&&(J.opaque||["1","true","yes","api"].includes(J.value)))return!0;return z}function Z2(Z){let z=f(Z),$=0;return{segments:z.segments.map((Y)=>{let X=Y.words[0],Q=Z.slice($,X.start);return $=Y.words[Y.words.length-1].end,{words:Y.words,redirects:Y.redirects,sepBefore:Q}}),trustworthy:z.trustworthy}}var N3=(Z)=>/(?:^|[^|])\|&?$/.test(Z.trim());function n0(Z,z){if(!B0.has(Z))return!1;if($2(z))return!1;for(let $=0;$<z.length;$++){let J=z[$].value;if(J==="--")return $+1>=z.length;if(J==="-"||J==="-s")return!0;if(/^[-+][A-Za-z]*[oO]$/.test(J)){$++;continue}if(!J.startsWith("-")&&!J.startsWith("+"))return!1}return!0}function o0(Z){let{segments:z}=Z2(Z.trim());if(z.length!==1)return null;let $=z[0],J=l($);if(J<0)return null;let Y=VZ(IZ($.words[J].text).value),X=$.words.slice(J+1).filter((Q,H)=>!$.redirects.has(H+J+1)).map((Q)=>IZ(Q.text));if(Y==="echo")return X.filter((Q,H)=>!(H===0&&/^-[neE]+$/.test(Q.value))).map((Q)=>Q.value).join(" ");if(Y==="printf"){let[Q,...H]=X.filter((B)=>B.value!=="--");if(!Q)return null;let K=0;return Q.value.replace(/\\n/g,`
34
+ `).replace(/%s/g,()=>H[K++]?.value??"")+(K<H.length?" "+H.slice(K).map((B)=>B.value).join(" "):"")}if(Y==="cat"){let Q=Z.indexOf("<<");if(Q<0)return null;let H=DZ(Z,Q),K=Z.indexOf(`
35
+ `,Q);if(!H||K<0)return null;let B=tZ(Z,K,[H]);if(B<0)return null;let M=Z.slice(K+1,B);return M.slice(0,M.lastIndexOf(H.delimiter)).replace(/\n$/,"")}return null}function i0(Z,z,$){for(let J of s0(Z).bodies){let Y=o0(J);if(Y===null)continue;let X=r(Y,z+1,$.debug);if(X.refused)return X}return T}function r(Z,z=0,$=!1){if(typeof Z!=="string"||!Z.trim())return T;if(z>P6)return Q0.test(Z)?I("unclassifiable"):T;let{segments:J,trustworthy:Y}=Z2(Z);if(!Y)return Q0.test(Z)?I("unclassifiable"):T;let X=$,Q=(H)=>r(H,z+1,X);for(let H of A6(Z)){if(H.runsBody){let K=Q(H.body);if(K.refused)return K}if(!H.quoted){let K=s0(H.body,"heredoc");if(!K.complete&&Q0.test(H.body))return I("unclassifiable");for(let B of K.bodies){let M=Q(B);if(M.refused)return M}}}for(let H=0;H<J.length;H++){let K=J[H];for(let F of K.words){let R=s0(F.text);if(!R.complete&&Q0.test(F.text))return I("unclassifiable");for(let m of R.bodies){let p=Q(m);if(p.refused)return p}}let B=l(K),M=K.words.map((F,R)=>({word:IZ(F.text),redirect:K.redirects.has(R)})),V=M.slice(0,B<0?M.length:B).map((F)=>F.word),G=B>=0?VZ(M[B].word.value):"";if(B<0||["export","declare","typeset","readonly","local"].includes(G)){if(X=U3([...V,...M.slice(B+1).map((F)=>F.word)],X),B<0)continue}let U=U3(V,X),j=M.slice(B+1).filter((F)=>!F.redirect).map((F)=>F.word),N=M.slice(B+1).filter((F)=>F.redirect).map((F)=>F.word),y=M[B].word,b=VZ(y.value),k={depth:z,appendsArgs:!1,debug:U};if(B>0&&M[B-1].word.value==="function"){let F=j.filter((m)=>!["{","()","(",")"].includes(m.value)),R=a0(F,k);if(R.refused)return R;continue}if(H>0&&N3(K.sepBefore)&&n0(b,j)){let F=J[H-1],R=O6(Z,F),m=R===null?null:o0(R);if(m!==null){let p=r(m,z+1,U);if(p.refused)return p}}let d=J[H+1];if(d&&/<\(\s*$/.test(d.sepBefore)&&(B0.has(b)||b==="source"||b===".")){let F=d.words[0].start-d.sepBefore.length+d.sepBefore.lastIndexOf("("),R=BZ(Z,F),m=R<0?null:o0(Z.slice(F+1,R-1));if(m!==null){let p=r(m,z+1,U);if(p.refused)return p}}let q=F3(b,y,j,N,K.words.slice(0,B+1),k);if(q.refused)return q}return T}function O6(Z,z){let $=z.words[0],J=z.words[z.words.length-1];return $&&J?Z.slice($.start,J.end):null}function L6(Z){let z=VZ(Z.value);return/[$`]/.test(z)||z===""?void 0:z}function F3(Z,z,$,J,Y,X){let Q=X.depth,H=(K)=>r(K,Q+1,X.debug);if(z.opaque){let K=L6(z);if(K===void 0){let B=$.find((V)=>!V.value.startsWith("-")),M=K0($,X);if(!M.refused)return T;return M.rule!=="unclassifiable"||B!==void 0&&!B.opaque&&e5.has(B.value)?M:T}Z=K}if(Z==="gh")return K0($,X);if(B0.has(Z)){let K=$2($);if(K){let B=H(K.value);if(B.refused||!K.opaque)return B;return i0(K.raw,Q,X)}for(let B of J){let M=H(B.value);if(M.refused)return M;if(B.opaque){let V=i0(B.raw,Q,X);if(V.refused)return V}}return T}if(_6.has(Z)){let K=$.findIndex((M)=>M.value==="-c"||M.value==="--command"||/^-[A-Za-z]*c$/.test(M.value)),B=K>=0?$[K+1]:void 0;return B?H(B.value):d0($,X)}if(Z==="eval"||Z==="watch"){let K=$;if(Z==="watch"){let M=0;while(M<$.length&&$[M].value.startsWith("-")){if($[M].value==="--"){M++;break}if(["-n","--interval","-q","--equexit"].includes($[M].value))M++;M++}K=$.slice(M)}let B=H(K.map((M)=>M.value).join(" "));if(B.refused)return B;for(let M of K){let V=i0(M.raw,Q,X);if(V.refused)return V}return T}if(Z==="env")return H(wZ([...Y.map((K)=>IZ(K.text).value),...$.map((K)=>K.value)]));if(Z==="ssh"){let K=0;for(;K<$.length;K++){let V=$[K].value;if(!V.startsWith("-"))break;if(q6.has(V))K++}let B=$.slice(K+1);if(B[0]?.value==="--")B.shift();let M=B.map((V)=>V.value).join(" ");return M?H(M):T}if(Z==="xargs"){let K=0,B=!1;for(;K<$.length;K++){let M=$[K].value;if(M==="--"){K++;break}if(!M.startsWith("-"))break;if(/^-I|^-i|^--replace/.test(M))B=!0;if(T6.has(M))K++}return a0($.slice(K),{depth:Q,appendsArgs:!B,debug:X.debug})}if(Z==="find"){for(let K=0;K<$.length;K++){if(!["-exec","-execdir","-ok","-okdir"].includes($[K].value))continue;let B=K+1;while(B<$.length&&$[B].value!==";"&&$[B].value!=="+")B++;let M=a0($.slice(K+1,B),X);if(M.refused)return M;K=B}return T}if(D6.has(Z))return d0($,X);if(I6.get(Z)?.includes($[0]?.value??""))return d0($.slice(1),X);return T}function a0(Z,z){if(Z.length===0)return T;let $=VZ(Z[0].value);if($==="gh")return K0(Z.slice(1),z);if(B0.has($)){let J=$2(Z.slice(1));return J?r(J.value,z.depth+1,z.debug):T}return F3($,Z[0],Z.slice(1),[],[],z)}function d0(Z,z){let $=Z.findIndex((J)=>!J.opaque&&VZ(J.value)==="gh"&&(J.value==="gh"||J.value.includes("/")));return $>=0?K0(Z.slice($+1),z):T}function $2(Z){for(let z=0;z<Z.length;z++){let $=Z[z].value;if($==="--")return;if(!$.startsWith("-")&&!$.startsWith("+"))return;if($==="-c"||/^-[A-Za-z]+$/.test($)&&$.includes("c"))return Z.slice(z+1).find((J)=>!J.value.startsWith("-")||J.value==="-");if(/^[-+][A-Za-z]*[oO]$/.test($))z++}return}function A6(Z){let z=[],$=0;for(;;){let J=Z.indexOf("<<",$);if(J<0)break;if($=J+2,Z[J+2]==="<"||J>0&&Z[J-1]==="<"){$=J+3;continue}let Y=DZ(Z,J);if(!Y)continue;let X=Z.lastIndexOf(`
36
+ `,J)+1,Q=Z.indexOf(`
37
+ `,J);if(Q<0)continue;let H=tZ(Z,Q,[Y]),K=H<0?Z.slice(Q+1):Z.slice(Q+1,H),B=H<0?K:K.slice(0,Math.max(0,K.lastIndexOf(Y.delimiter))).replace(/\n$/,""),M=Z.slice(X,J)+" HEREDOC_OPERATOR "+Z.slice(Y.end,Q);z.push({body:B,runsBody:y6(M),quoted:Y.quoted})}return z}function y6(Z){let{segments:z}=Z2(Z),$=z.findIndex((H)=>H.words.some((K)=>K.text==="HEREDOC_OPERATOR"));if($<0)return!1;let J=(H)=>{let K=l(H);if(K<0)return{verb:"",args:[]};let B=H.words.slice(K+1).filter((M)=>M.text!=="HEREDOC_OPERATOR").map((M)=>IZ(M.text));return{verb:VZ(IZ(H.words[K].text).value),args:B}},{verb:Y,args:X}=J(z[$]);if(Y==="ssh"||n0(Y,X))return!0;if((Y==="source"||Y===".")&&["/dev/stdin","/dev/fd/0","/proc/self/fd/0"].includes(X[0]?.value??""))return!0;let Q=z[$+1];if(Y==="cat"&&Q&&N3(Q.sepBefore)){let H=J(Q);return H.verb==="ssh"||n0(H.verb,H.args)}return!1}var R6=/(?:^|[^A-Za-z0-9_.-])gh(?:$|[^A-Za-z0-9_.-])/;function _3(){return{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:r0}}}var v6=new Set(["Bash","Monitor"]);function D3(Z){if(Z?.hook_event_name!=="PreToolUse"||!v6.has(Z.tool_name??""))return{continue:!0};let z=WZ(Z);if(!z.trim())return{continue:!0};try{return r(z).refused?_3():{continue:!0}}catch{return R6.test(z)?_3():{continue:!0}}}function b6(Z){if(Z!=="trash-guard"&&Z!=="workspace-repos-guard")throw Error("Invalid safety capability")}function I3(Z,z){b6(Z);let $=Z,J=JSON.parse(z);if(!J||Array.isArray(J)||J.hook_event_name!=="PreToolUse"||typeof J.tool_name!=="string"||!J.tool_input||typeof J.tool_input!=="object"||Array.isArray(J.tool_input)||typeof J.cwd!=="string"||!J2.isAbsolute(J.cwd))throw Error("Invalid safety input");if(J.tool_name==="Bash"&&typeof J.tool_input.command!=="string")throw Error("Invalid shell input");if(J.tool_name==="Monitor"&&J.tool_input.command!==void 0&&typeof J.tool_input.command!=="string")throw Error("Invalid monitor input");let Y=J.hasna_execution;if(Y!==void 0&&(!Y||Object.keys(Y).sort().join()!=="agent,schema"||Y.schema!=="hasna.hooks.execution.v1"||typeof Y.agent!=="string"||!/^[A-Za-z0-9][A-Za-z0-9._:@-]{0,127}$/.test(Y.agent)))throw Error("Invalid execution capability");let X=Y===void 0?void 0:{runtime:process.execPath,home:M0.homedir(),path:process.env.PATH,agent:Y.agent};if(X&&(!J2.isAbsolute(X.runtime)||!X.path))throw Error("Invalid bound execution context");if(["apply_patch","ApplyPatch","functions.apply_patch"].includes(J.tool_name)){if(J.tool_input.command!==void 0&&J.tool_input.patch!==void 0&&J.tool_input.command!==J.tool_input.patch)throw Error("Conflicting patch aliases");let b=J.tool_input.command??J.tool_input.patch;if(typeof b!=="string")throw Error("Invalid patch input");J.tool_input={...J.tool_input,command:b,patch:b}}let Q=J.tool_name==="Monitor",H=J.tool_name==="Bash"||Q&&typeof J.tool_input.command==="string",K=Q&&H?{...J,tool_name:"Bash"}:J,B=(b)=>({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:b}}),M=J3(K).output,V=D3(K),G=K.tool_input.command,U=()=>_Z(G,{home:M0.homedir(),cwd:J.cwd}).handoffHits.length>0,j=H&&(U()||!!HZ(G,U)),N=$==="trash-guard"&&(!Q||H)?k2(K,{home:M0.homedir(),cwd:J.cwd,findTrash:dZ,inspectTrash:RZ,execution:X}):{continue:!0};if(Q&&N.hookSpecificOutput?.permissionDecision==="allow")N=B("[trash-guard] A deletion inside a Monitor command is refused; run it with the Bash tool, where it is redirected into trash.");let y=M.decision==="block"?B(M.reason):V.hookSpecificOutput?V:j?B("[workspace-repos-guard] Deletion under a protected repository checkout is refused."):N;return JSON.stringify({verdict:"continue"in y?null:y})}var E6=2,S6="0.12.19";function f6(Z,z){return I3(Z,z)}