cc-safety-net 2.0.7 → 2.0.9

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,101 +1,99 @@
1
1
  // cc-safety-net managed OpenClaw plugin. Do not edit. Reinstall with: npx -y cc-safety-net install --openclaw
2
- // version: 2.0.7
3
- var jM=Object.defineProperty;var RM=($)=>$;function bM($,J){this[$]=RM.bind(null,J)}var U2=($,J)=>{for(var Q in J)jM($,Q,{get:J[Q],enumerable:!0,configurable:!0,set:bM.bind(J,Q)})};var PK={id:"cc-safety-net",name:"CC Safety Net",description:"Block destructive commands and secret-file access before OpenClaw runs a tool."};import{randomBytes as _O}from"node:crypto";import{appendFileSync as DO,mkdirSync as zO}from"node:fs";import{homedir as IO,userInfo as jO}from"node:os";import{isAbsolute as RO,join as SJ}from"node:path";var PM=[/\bgh[pousr]_[A-Za-z0-9]{20,}\b/g,/\bgithub_pat_[A-Za-z0-9_]{20,}\b/g,/\bglpat-[A-Za-z0-9_-]{20,}\b/g,/\bxox[abeprs]-[A-Za-z0-9-]{20,}\b/g,/\bnpm_[A-Za-z0-9_]{20,}\b/g,/\bpypi-[A-Za-z0-9_-]{20,}\b/g,/\b[rs]k_(?:live|test)_[A-Za-z0-9_]{20,}\b/g,/\bsk-[A-Za-z0-9_-]{20,}\b/g,/\bsk_[A-Za-z0-9]{20,}\b/g,/\bgsk_[A-Za-z0-9]{52,}\b/g,/\bxai-[A-Za-z0-9_-]{80,}\b/g,/\bpplx-[A-Za-z0-9_-]{20,}\b/g,/\bbastn_[A-Za-z0-9]{16,}\b/g,/\btgp_v1_[A-Za-z0-9_-]{43,}\b/g,/\bflp_[A-Za-z0-9]{10,}\b/g,/\bwfr_[A-Za-z0-9]{20,}\b/g,/\bfwp?_[A-Za-z0-9_-]{20,}\b/g,/\btp-[A-Za-z0-9_-]{20,}\b/g,/\bpsk-[A-Za-z0-9_-]{8,}-[A-Za-z0-9_-]{8,}\b/g,/\b[a-f0-9]{32}\.[A-Za-z0-9]{16}\b/g];function A0($){let J=$.replace(/\b((?:DATABASE|POSTGRES|POSTGRESQL|MYSQL|MARIADB|REDIS|MONGO(?:DB)?|DB)_DSN|CONNECTION_STRING)=("[^"]*"|'[^']*'|[^\s]+(?:\s+[A-Z_][A-Z0-9_]*=[^\s]+)*)/gi,"$1=<redacted>").replace(/\b((?:DATABASE|POSTGRES|POSTGRESQL|MYSQL|MARIADB|REDIS|MONGO(?:DB)?|DB)_(?:URL|URI|CONNECTION_STRING))=("[^"]*"|'[^']*'|[^\s]+)/gi,"$1=<redacted>").replace(/\b([A-Z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASS|KEY|CREDENTIALS)[A-Z0-9_]*)=("[^"]*"|'[^']*'|[^\s]+)/gi,"$1=<redacted>");return AM(J)}function AM($){let J=$.replace(/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/gi,"<redacted>").replace(/((?:(['"])(?:authorization|cookie|x-api-key|api-key)\2|(?:authorization|cookie|x-api-key|api-key))\s*:\s*)(['"])(?:\\[^\r\n]|(?!\3)[^\\\r\n])*\3/gi,"$1$3<redacted>$3").replace(/(['"]?\s*(?:authorization|cookie|x-api-key|api-key)\s*:(?!\s*(?:"<redacted>"|'<redacted>'))\s*)([^'"\r\n]+)(['"]?)/gi,"$1<redacted>$3").replace(/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/:@]+):([^\s@/]+)@/gi,"$1<redacted>:<redacted>@").replace(/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/@:]+)@/gi,"$1<redacted>@").replace(/(^|[\s?&;|])((?:x-amz-signature|x-goog-signature|sig|signature)=)(?:"[^"\r\n]*"|'[^'\r\n]*'|[^&#\s'"`;|<>()]*)/gi,"$1$2<redacted>").replace(/(^|\s)((?:-u|--user)(?:\s+|=))([^\s:]+):([^\s]+)/g,"$1$2<redacted>:<redacted>");for(let Q of PM)J=J.replace(Q,"<redacted>");return J.replace(/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\b/g,"<redacted>").replace(/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/g,"<redacted>")}import{lstatSync as mK,readdirSync as KO,readFileSync as dK,rmdirSync as BO,statSync as lK,unlinkSync as qO,utimesSync as UO,writeFileSync as GO}from"node:fs";import{dirname as HO,join as r2}from"node:path";var b6=30,_J=1,DJ=365;function P6($){if(typeof $!=="number"||!Number.isInteger($))return 30;if($<1)return 1;return $>365?365:$}import{homedir as dM}from"node:os";import{dirname as p0,isAbsolute as rM,join as c0,relative as iM,resolve as C0,sep as oM}from"node:path";import{closeSync as EM,constants as AK,fstatSync as CM,fsyncSync as lE,lstatSync as EK,mkdirSync as pE,openSync as SM,readdirSync as cE,readFileSync as TM,realpathSync as A6,renameSync as dE,rmdirSync as rE,statSync as wM,unlinkSync as iE,writeFileSync as oE}from"node:fs";import{isAbsolute as CK,join as SK,normalize as vM,parse as fM,relative as zJ,resolve as IJ,sep as jJ}from"node:path";var kM=Symbol("PolicyFilesystemScope"),hM=Symbol("PolicyFilesystemTarget"),yM=AK.O_NOFOLLOW??0;class K1 extends Error{constructor($){super(`Unable to access ${$} filesystem safely.`);this.name="PolicyFilesystemError"}}function l0($,J){return{[kM]:!0,root:IJ($),label:J}}function TK($,J){let Q=vM(J);if(J===""||CK(J)||Q===".."||Q.startsWith(`..${jJ}`))throw new K1($.label);return{[hM]:!0,scope:$,relativePath:Q,path:SK($.root,Q)}}function E0($,J){let Q=zJ($.root,IJ(J));return TK($,Q)}function C6($,J="rules policy"){let Q=IJ($),W=fM(Q).dir;return TK(l0(W,J),zJ(W,Q))}function G2($){try{if(!E6($,!1).exists)return null;let Q=SM($.path,AK.O_RDONLY|yM);try{let W=CM(Q);if(!W.isFile())throw new K1($.scope.label);let X=TM(Q,"utf-8"),Y=EK($.path);if(!Y.isFile()||Y.isSymbolicLink()||W.dev!==Y.dev||W.ino!==Y.ino)throw new K1($.scope.label);return E6($,!1),X}finally{EM(Q)}}catch(J){uM($.scope.label,J)}}function wK($,J){if($.path===J.path)return!0;try{if(!E6($,!1).exists||!E6(J,!1).exists)return!1;return A6($.path)===A6(J.path)}catch(Q){if(Q instanceof K1)throw Q;throw new K1($.scope.label)}}function E6($,J,Q="file"){let W=gM($.scope);if(!W)return{exists:!1};let X=$.relativePath.split(jJ);for(let Y of X.keys()){let K=SK($.scope.root,...X.slice(0,Y+1)),B=vK(K);if(!B){if(Y===X.length-1&&J)return{exists:!1};return{exists:!1}}if(B.isSymbolicLink())throw new K1($.scope.label);if(Y<X.length-1&&!B.isDirectory())throw new K1($.scope.label);if(Y===X.length-1&&(Q==="file"?!B.isFile():!B.isDirectory()))throw new K1($.scope.label);xM(W,A6(K),$.scope.label)}return{exists:!0}}function gM($){if(!vK($.root))return null;if(!wM($.root).isDirectory())throw new K1($.label);return A6($.root)}function xM($,J,Q){let W=zJ($,J);if(W===".."||W.startsWith(`..${jJ}`)||CK(W))throw new K1(Q)}function vK($){try{return EK($)}catch(J){if(mM(J)&&J.code==="ENOENT")return null;throw J}}function uM($,J){if(J instanceof K1)throw J;throw new K1($)}function mM($){return $ instanceof Error&&"code"in $}var q0=/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/,RJ="rulebook.json",bJ=".cc-safety-net/rules";var fK=/^([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)#(.+)$/;var lM=/^[A-Za-z0-9._-]+$/,pM=".cc-safety-net/rules".replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),cM="rulebook.json".replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),kK=new RegExp(`^${pM}/(${q0.source.slice(1,-1)})/${cM}$`);function hK($){return`.cc-safety-net/rules/${$}/rulebook.json`}function n4($){if(T6($))try{return S6($),null}catch(J){return J instanceof Error?J.message:String(J)}return q0.test($)?null:`Local rulebook sources must be bare names matching ${q0}: ${$}`}function S6($){if($.startsWith("github:"))throw Error(`Invalid rulebook source: ${$}`);let J=$.match(fK);if(!J?.[1]||!J[2]||!J[3])throw Error(`Invalid GitHub rulebook source: ${$}`);let[Q,W,...X]=J[3].split("/");if(!Q||!lM.test(Q))throw Error(`GitHub rulebook refs must be a single path segment: ${$}`);if(!W||X.length>0||!q0.test(W))throw Error(`GitHub rulebook sources must be owner/repo#ref/<rulebook-name>: ${$}`);return{owner:J[1],repo:J[2],ref:Q,path:hK(W),name:W}}function T6($){return fK.test($)}var gK="rule.json",w6="policy.json",nM="rule.lock";var xK=".cc-safety-net",sM="rules",yK="cache",aM="CC_SAFETY_NET_HOME",d0="`cc-safety-net rule sync`";function tM($){return C0($??process.cwd(),bJ)}function eM($){return c0(tM($),gK)}function H2($){return $?.userConfigDir??($?.userConfigPath?p0($.userConfigPath):c0($O(),sM))}function $O(){let $=process.env[aM];return $?C0($):c0(dM(),xK)}function JO($){return c0(H2($),gK)}function s4($){return c0(p0($),nM)}function uK($){let J=$.userConfigPath??JO($),Q=$.projectConfigPath??eM($.cwd),W=QO(J,$),X=WO(Q,$);return{userConfigPath:J,projectConfigPath:Q,userLockPath:s4(J),projectLockPath:s4(Q),userScope:W,projectScope:X,userConfigTarget:E0(W,J),projectConfigTarget:E0(X,Q),userLockTarget:E0(W,s4(J)),projectLockTarget:E0(X,s4(Q))}}function QO($,J){let Q=J.userConfigPath?p0(p0(C0(J.userConfigPath))):p0(C0(J.userConfigDir??H2(J)));return l0(Q,"user policy")}function WO($,J){let Q=C0(J.cwd??process.cwd()),W=C0($),X=iM(Q,W);if(X!==".."&&!X.startsWith(`..${oM}`)&&!rM(X))return l0(Q,"project policy");return l0(p0(p0(W)),"project policy")}function PJ($,J){let Q=$.digest.startsWith("sha256:")?$.digest.slice(7):$.digest;return c0(YO(J),"rulebooks",`${XO($)}--${Q.slice(0,12)}`,RJ)}function AJ($,J){let Q=J;return{cacheConfigDir:$,cwd:J.cwd,global:Q.global}}function XO($){return($.kind==="github"&&$.display_ref?`${$.owner}/${$.repo}#${$.display_ref}/${$.name}`:$.spec).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"rulebook"}function YO($){let J=$?.cacheConfigDir??H2($),Q=$;if(Q&&!Q.global&&Q.cwd&&C0(J)===C0(Q.cwd))return c0(C0(Q.cwd),xK,yK);return c0(p0(J),yK)}var CJ=86400000,ZO=".last-prune",LO=/^\d{4}-\d{2}$/,MO=/^((\d{4}-\d{2})-\d{2})-.+\.jsonl$/,pK=($)=>Math.floor($/CJ);function OO($){try{let J=r2(HO(H2($)),w6),Q=JSON.parse(dK(J,"utf-8"));return P6(Q?.audit?.retention_days)}catch{return b6}}function rK($,J=()=>new Date){try{let Q=J().getTime();if(!lK($,{throwIfNoEntry:!1})?.isDirectory())return;let W=r2($,ZO),X=lK(W,{throwIfNoEntry:!1})?.mtimeMs;if(X!==void 0&&pK(X)===pK(Q))return;let Y=Q-OO()*CJ,K=new Date(Q).toISOString().slice(0,7);for(let B of EJ($)){if(B.isDirectory()){NO(r2($,B.name),Y,K);continue}if(B.isFile()&&B.name.endsWith(".jsonl"))FO(r2($,B.name),Y)}GO(W,"",{mode:384}),UO(W,Q/1000,Q/1000)}catch{}}function NO($,J,Q){for(let W of EJ($)){if(!W.isDirectory()||!LO.test(W.name))continue;let X=r2($,W.name);for(let Y of EJ(X)){if(!Y.isFile())continue;let K=MO.exec(Y.name);if(!K||K[2]!==W.name)continue;let B=Date.parse(`${K[1]}T00:00:00.000Z`)+CJ;if(!Number.isFinite(B)||B>=J)continue;iK(r2(X,Y.name))}if(W.name!==Q)cK(X)}cK($)}function FO($,J){try{let Q=mK($);if(Q.mtimeMs>=J)return;let W=dK($,"utf-8").split(`
4
- `).filter((X)=>X.trim()).map(VO);if(W.length===0)return;if(W.some((X)=>X===void 0||X>=J))return;if(mK($).mtimeMs!==Q.mtimeMs)return;iK($)}catch{}}function VO($){try{let J=JSON.parse($).ts,Q=typeof J==="string"?Date.parse(J):Number.NaN;return Number.isFinite(Q)?Q:void 0}catch{return}}function EJ($){try{return KO($,{withFileTypes:!0,encoding:"utf8"})}catch{return[]}}function iK($){try{qO($)}catch{}}function cK($){try{BO($)}catch{}}var bO="2.0.7",PO=1e4,AO=2000,EO=256,CO=32768;function SO($){let J=$.trim();if(!J)return null;let Q=J.replace(/[^A-Za-z0-9_.-]+/g,"_");if(Q=Q.replace(/^[._-]+|[._-]+$/g,"").slice(0,128),!Q||Q==="."||Q==="..")return null;return Q}function TO($){return($??"").replace(/[^A-Za-z0-9]/g,"-").slice(0,180)||"no-cwd"}function TJ($,J,Q,W,X,Y={}){let K=SO($);if(!K)return;let B=Y.homeDir??oK();if(!B)return;let q=wO(B);if(!q)return;try{let U=(Y.now??(()=>new Date))().toISOString(),G=v6(A0(J),PO),H=v6(A0(Q),AO),L=Y.toolName?v6(A0(Y.toolName),EO):void 0,Z=X===null?void 0:v6(A0(X),CO),M=SJ(q,TO(Z?.value??null),U.slice(0,7));zO(M,{recursive:!0,mode:448});let O=SJ(M,`${U.slice(0,10)}-${K}.jsonl`),V={ts:U,id:(Y.createId??(()=>_O(8).toString("hex")))(),v:bO,sessionId:K,decision:Y.decision??"deny",agent:Y.agent,shape:Y.shape,level:Y.level,configFallback:Y.configFallback,toolName:L?.value,command:G.value,segment:H.value,...G.truncated||H.truncated||L?.truncated||Z?.truncated?{truncated:!0}:{},reason:W,ruleId:Y.ruleId,intent:Y.intent,failureStage:Y.failureStage,errorCode:Y.errorCode,cwd:Z?.value??null};DO(O,`${JSON.stringify(V)}
5
- `,{encoding:"utf-8",mode:384}),rK(q,Y.now)}catch{}}function v6($,J){return{value:$.slice(0,J),truncated:$.length>J}}function oK($=process.env.CC_SAFETY_NET_AUDIT_HOME||process.env.HOME){let J=$||IO()||jO().homedir;return J&&RO(J)?J:null}function wO($=oK()){return $?SJ($,".cc-safety-net","logs"):null}function sK($,J,Q,W=!0,X){if(J.decision.kind==="allow"){if(!Q||$.route.kind!=="command")return;let B=nK($);return{decision:"allow",command:B,segment:B,reason:"allowed",cwd:$.context.executionCwd,toolName:$.toolName,level:J.level,...J.configFallback?{configFallback:!0}:{}}}let Y=J.decision.evidence.find((B)=>B.kind==="command"),K=Y?.command??(W?nK($):"");return{decision:"deny",command:K,segment:Y?.segment??K,reason:J.decision.reason,cwd:$.context.executionCwd,toolName:$.toolName,level:J.level,...J.configFallback?{configFallback:!0}:{},ruleId:J.decision.ruleId,intent:J.decision.intent,failureStage:X?.stage,errorCode:X?.errorCode}}function nK($){return"command"in $?$.command??"":""}function aK($,J,Q){if(!$)return;let W;try{W=J()}catch{return}if(typeof W!=="string"||!W.trim())return;TJ(W,$.command,$.segment,$.reason,$.cwd,{homeDir:Q.homeDir,decision:$.decision,agent:Q.agent,shape:Q.shape,level:$.level,configFallback:$.configFallback,toolName:$.toolName,ruleId:$.ruleId,intent:$.intent,failureStage:$.failureStage,errorCode:$.errorCode})}function tK($,J,Q){let W;try{W=J()}catch{return}if(typeof W!=="string"||!W.trim())return;TJ(W,$.command??"",$.segment??$.command??"",$.reason,Q.cwd??null,{homeDir:Q.homeDir,decision:"deny",agent:Q.agent,shape:Q.shape,toolName:Q.toolName??$.toolName,ruleId:$.ruleId,intent:$.intent})}import{realpathSync as uO,statSync as mO}from"node:fs";import{isAbsolute as $B,relative as lO,resolve as pO,sep as cO}from"node:path";import{dirname as vO,isAbsolute as fO,parse as kO,sep as hO}from"node:path";function Z2($,J=process.platform){if(J!=="win32")return!1;return($[0]==="/"||$[0]==="\\")&&($[1]==="/"||$[1]==="\\")}function r0($,J,Q){if(Z2(J))throw Error("Unsupported Windows namespace path");let W=fO(J)?gO(J):"",X=W||$;for(let Y of xO(W?J.slice(W.length):J)){if(Y===""||Y===".")continue;if(Y===".."){X=vO(X);continue}let K=yO(X,Y),B=Q.entryKind(K),q=B==="symlink"?Q.realpath(K):K;if(B==="missing"||q===null)throw Error(`Cannot resolve path component: ${K}`);X=q}return X}function yO($,J){return $.endsWith("/")||$.endsWith("\\")?`${$}${J}`:`${$}${hO}${J}`}function gO($){return kO($).root}function xO($){let J=process.platform==="win32"?/[\\/]+/:/\/+/;return $.split(J)}function f6($,J){if(Z2($))return;let Q=J.flatMap((X)=>eK(X));if(!Q[0])return;let W=eK($B($)?$:pO(Q[0],$))[0];if(!W)return;return Q.some((X)=>JB(W,X))?W:void 0}function eK($){try{let J=uO($);return mO(J).isDirectory()?[J]:[]}catch{return[]}}function JB($,J){let Q=lO(J,$);return Q===""||Q!==".."&&!Q.startsWith(`..${cO}`)&&!$B(Q)}var i0="Command could not be safely analyzed (strict mode). Simplify the command and retry, or ask the user to verify.",S0="Command exceeds maximum recursion depth and cannot be safely analyzed. Flatten the nesting and retry.",QB="CC Safety Net could not validate the command because its structure exceeds safe analysis limits.",k6="CC Safety Net failed closed because command analysis failed unexpectedly. This is not caused by your command. Report it to the user.";function XB($){let{reason:J,command:Q,segment:W,toolName:X}=$,Y=$.maxLen??200,K=$.redact??((q)=>q),B=`BLOCKED by CC Safety Net
2
+ // version: 2.0.9
3
+ var ww=Object.defineProperty;var Ew=(e)=>e;function Rw(e,t){this[e]=Ew.bind(null,t)}var dn=(e,t)=>{for(var n in t)ww(e,n,{get:t[n],enumerable:!0,configurable:!0,set:Rw.bind(t,n)})};var Ah={id:"cc-safety-net",name:"CC Safety Net",description:"Block destructive commands and secret-file access before OpenClaw runs a tool."};import{randomBytes as SE}from"node:crypto";import{appendFileSync as _E,mkdirSync as xE}from"node:fs";import{homedir as CE,userInfo as wE}from"node:os";import{isAbsolute as EE,join as Il}from"node:path";var Pw=[/\bgh[pousr]_[A-Za-z0-9]{20,}\b/g,/\bgithub_pat_[A-Za-z0-9_]{20,}\b/g,/\bglpat-[A-Za-z0-9_-]{20,}\b/g,/\bxox[abeprs]-[A-Za-z0-9-]{20,}\b/g,/\bnpm_[A-Za-z0-9_]{20,}\b/g,/\bpypi-[A-Za-z0-9_-]{20,}\b/g,/\b[rs]k_(?:live|test)_[A-Za-z0-9_]{20,}\b/g,/\bsk-[A-Za-z0-9_-]{20,}\b/g,/\bsk_[A-Za-z0-9]{20,}\b/g,/\bgsk_[A-Za-z0-9]{52,}\b/g,/\bxai-[A-Za-z0-9_-]{80,}\b/g,/\bpplx-[A-Za-z0-9_-]{20,}\b/g,/\bbastn_[A-Za-z0-9]{16,}\b/g,/\btgp_v1_[A-Za-z0-9_-]{43,}\b/g,/\bflp_[A-Za-z0-9]{10,}\b/g,/\bwfr_[A-Za-z0-9]{20,}\b/g,/\bfwp?_[A-Za-z0-9_-]{20,}\b/g,/\btp-[A-Za-z0-9_-]{20,}\b/g,/\bpsk-[A-Za-z0-9_-]{8,}-[A-Za-z0-9_-]{8,}\b/g,/\b[a-f0-9]{32}\.[A-Za-z0-9]{16}\b/g];function kt(e){let t=e.replace(/\b((?:DATABASE|POSTGRES|POSTGRESQL|MYSQL|MARIADB|REDIS|MONGO(?:DB)?|DB)_DSN|CONNECTION_STRING)=("[^"]*"|'[^']*'|[^\s]+(?:\s+[A-Z_][A-Z0-9_]*=[^\s]+)*)/gi,"$1=<redacted>").replace(/\b((?:DATABASE|POSTGRES|POSTGRESQL|MYSQL|MARIADB|REDIS|MONGO(?:DB)?|DB)_(?:URL|URI|CONNECTION_STRING))=("[^"]*"|'[^']*'|[^\s]+)/gi,"$1=<redacted>").replace(/\b([A-Z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASS|KEY|CREDENTIALS)[A-Z0-9_]*)=("[^"]*"|'[^']*'|[^\s]+)/gi,"$1=<redacted>");return kw(t)}function kw(e){let t=e.replace(/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/gi,"<redacted>").replace(/((?:(['"])(?:authorization|cookie|x-api-key|api-key)\2|(?:authorization|cookie|x-api-key|api-key))\s*:\s*)(['"])(?:\\[^\r\n]|(?!\3)[^\\\r\n])*\3/gi,"$1$3<redacted>$3").replace(/(['"]?\s*(?:authorization|cookie|x-api-key|api-key)\s*:(?!\s*(?:"<redacted>"|'<redacted>'))\s*)([^'"\r\n]+)(['"]?)/gi,"$1<redacted>$3").replace(/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/:@]+):([^\s@/]+)@/gi,"$1<redacted>:<redacted>@").replace(/\b([a-z][a-z0-9+.-]*:\/\/)([^\s/@:]+)@/gi,"$1<redacted>@").replace(/(^|[\s?&;|])((?:x-amz-signature|x-goog-signature|sig|signature)=)(?:"[^"\r\n]*"|'[^'\r\n]*'|[^&#\s'"`;|<>()]*)/gi,"$1$2<redacted>").replace(/(^|\s)((?:-u|--user)(?:\s+|=))([^\s:]+):([^\s]+)/g,"$1$2<redacted>:<redacted>");for(let n of Pw)t=t.replace(n,"<redacted>");return t.replace(/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\b/g,"<redacted>").replace(/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/g,"<redacted>")}import{lstatSync as Uh,readdirSync as aE,readFileSync as qh,rmdirSync as cE,statSync as jh,unlinkSync as lE,utimesSync as uE,writeFileSync as dE}from"node:fs";import{dirname as mE,join as qn}from"node:path";var Ai=30,Sl=1,_l=365;function Ti(e){if(typeof e!=="number"||!Number.isInteger(e))return 30;if(e<1)return 1;return e>365?365:e}import{homedir as Hw}from"node:os";import{dirname as Ut,isAbsolute as Vw,join as jt,relative as qw,resolve as Tt,sep as Kw}from"node:path";import{closeSync as Aw,constants as Th,fstatSync as Tw,fsyncSync as IL,lstatSync as Ih,mkdirSync as OL,openSync as Iw,readdirSync as zL,readFileSync as Ow,realpathSync as Ii,renameSync as NL,rmdirSync as DL,statSync as zw,unlinkSync as $L,writeFileSync as LL}from"node:fs";import{isAbsolute as Oh,join as zh,normalize as Nw,parse as Dw,relative as xl,resolve as Cl,sep as wl}from"node:path";var $w=Symbol("PolicyFilesystemScope"),Lw=Symbol("PolicyFilesystemTarget"),Mw=Th.O_NOFOLLOW??0;class ae extends Error{constructor(e){super(`Unable to access ${e} filesystem safely.`);this.name="PolicyFilesystemError"}}function Bt(e,t){return{[$w]:!0,root:Cl(e),label:t}}function Nh(e,t){let n=Nw(t);if(t===""||Oh(t)||n===".."||n.startsWith(`..${wl}`))throw new ae(e.label);return{[Lw]:!0,scope:e,relativePath:n,path:zh(e.root,n)}}function At(e,t){let n=xl(e.root,Cl(t));return Nh(e,n)}function zi(e,t="rules policy"){let n=Cl(e),r=Dw(n).dir;return Nh(Bt(r,t),xl(r,n))}function mn(e){try{if(!Oi(e,!1).exists)return null;let n=Iw(e.path,Th.O_RDONLY|Mw);try{let r=Tw(n);if(!r.isFile())throw new ae(e.scope.label);let o=Ow(n,"utf-8"),i=Ih(e.path);if(!i.isFile()||i.isSymbolicLink()||r.dev!==i.dev||r.ino!==i.ino)throw new ae(e.scope.label);return Oi(e,!1),o}finally{Aw(n)}}catch(t){Gw(e.scope.label,t)}}function Dh(e,t){if(e.path===t.path)return!0;try{if(!Oi(e,!1).exists||!Oi(t,!1).exists)return!1;return Ii(e.path)===Ii(t.path)}catch(n){if(n instanceof ae)throw n;throw new ae(e.scope.label)}}function Oi(e,t,n="file"){let r=Ww(e.scope);if(!r)return{exists:!1};let o=e.relativePath.split(wl);for(let i of o.keys()){let s=zh(e.scope.root,...o.slice(0,i+1)),a=$h(s);if(!a){if(i===o.length-1&&t)return{exists:!1};return{exists:!1}}if(a.isSymbolicLink())throw new ae(e.scope.label);if(i<o.length-1&&!a.isDirectory())throw new ae(e.scope.label);if(i===o.length-1&&(n==="file"?!a.isFile():!a.isDirectory()))throw new ae(e.scope.label);Fw(r,Ii(s),e.scope.label)}return{exists:!0}}function Ww(e){if(!$h(e.root))return null;if(!zw(e.root).isDirectory())throw new ae(e.label);return Ii(e.root)}function Fw(e,t,n){let r=xl(e,t);if(r===".."||r.startsWith(`..${wl}`)||Oh(r))throw new ae(n)}function $h(e){try{return Ih(e)}catch(t){if(Zw(t)&&t.code==="ENOENT")return null;throw t}}function Gw(e,t){if(t instanceof ae)throw t;throw new ae(e)}function Zw(e){return e instanceof Error&&"code"in e}var lt=/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/,El="rulebook.json",Rl=".cc-safety-net/rules";var Lh=/^([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)#(.+)$/;var Bw=/^[A-Za-z0-9._-]+$/,Uw=".cc-safety-net/rules".replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),jw="rulebook.json".replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Mh=new RegExp(`^${Uw}/(${lt.source.slice(1,-1)})/${jw}$`);function Wh(e){return`.cc-safety-net/rules/${e}/rulebook.json`}function Xr(e){if(Di(e))try{return Ni(e),null}catch(t){return t instanceof Error?t.message:String(t)}return lt.test(e)?null:`Local rulebook sources must be bare names matching ${lt}: ${e}`}function Ni(e){if(e.startsWith("github:"))throw Error(`Invalid rulebook source: ${e}`);let t=e.match(Lh);if(!t?.[1]||!t[2]||!t[3])throw Error(`Invalid GitHub rulebook source: ${e}`);let[n,r,...o]=t[3].split("/");if(!n||!Bw.test(n))throw Error(`GitHub rulebook refs must be a single path segment: ${e}`);if(!r||o.length>0||!lt.test(r))throw Error(`GitHub rulebook sources must be owner/repo#ref/<rulebook-name>: ${e}`);return{owner:t[1],repo:t[2],ref:n,path:Wh(r),name:r}}function Di(e){return Lh.test(e)}var Gh="rule.json",$i="policy.json",Yw="rule.lock";var Zh=".cc-safety-net",Jw="rules",Fh="cache",Xw="CC_SAFETY_NET_HOME",Ht="`cc-safety-net rule sync`";function Qw(e){return Tt(e??process.cwd(),Rl)}function eE(e){return jt(Qw(e),Gh)}function fn(e){return e?.userConfigDir??(e?.userConfigPath?Ut(e.userConfigPath):jt(tE(),Jw))}function tE(){let e=process.env[Xw];return e?Tt(e):jt(Hw(),Zh)}function nE(e){return jt(fn(e),Gh)}function Qr(e){return jt(Ut(e),Yw)}function Bh(e){let t=e.userConfigPath??nE(e),n=e.projectConfigPath??eE(e.cwd),r=rE(t,e),o=oE(n,e);return{userConfigPath:t,projectConfigPath:n,userLockPath:Qr(t),projectLockPath:Qr(n),userScope:r,projectScope:o,userConfigTarget:At(r,t),projectConfigTarget:At(o,n),userLockTarget:At(r,Qr(t)),projectLockTarget:At(o,Qr(n))}}function rE(e,t){let n=t.userConfigPath?Ut(Ut(Tt(t.userConfigPath))):Ut(Tt(t.userConfigDir??fn(t)));return Bt(n,"user policy")}function oE(e,t){let n=Tt(t.cwd??process.cwd()),r=Tt(e),o=qw(n,r);if(o!==".."&&!o.startsWith(`..${Kw}`)&&!Vw(o))return Bt(n,"project policy");return Bt(Ut(Ut(r)),"project policy")}function Pl(e,t){let n=e.digest.startsWith("sha256:")?e.digest.slice(7):e.digest;return jt(sE(t),"rulebooks",`${iE(e)}--${n.slice(0,12)}`,El)}function kl(e,t){let n=t;return{cacheConfigDir:e,cwd:t.cwd,global:n.global}}function iE(e){return(e.kind==="github"&&e.display_ref?`${e.owner}/${e.repo}#${e.display_ref}/${e.name}`:e.spec).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"rulebook"}function sE(e){let t=e?.cacheConfigDir??fn(e),n=e;if(n&&!n.global&&n.cwd&&Tt(t)===Tt(n.cwd))return jt(Tt(n.cwd),Zh,Fh);return jt(Ut(t),Fh)}var Tl=86400000,fE=".last-prune",pE=/^\d{4}-\d{2}$/,gE=/^((\d{4}-\d{2})-\d{2})-.+\.jsonl$/,Hh=(e)=>Math.floor(e/Tl);function hE(e){try{let t=qn(mE(fn(e)),$i),n=JSON.parse(qh(t,"utf-8"));return Ti(n?.audit?.retention_days)}catch{return Ai}}function Kh(e,t=()=>new Date){try{let n=t().getTime();if(!jh(e,{throwIfNoEntry:!1})?.isDirectory())return;let r=qn(e,fE),o=jh(r,{throwIfNoEntry:!1})?.mtimeMs;if(o!==void 0&&Hh(o)===Hh(n))return;let i=n-hE()*Tl,s=new Date(n).toISOString().slice(0,7);for(let a of Al(e)){if(a.isDirectory()){yE(qn(e,a.name),i,s);continue}if(a.isFile()&&a.name.endsWith(".jsonl"))bE(qn(e,a.name),i)}dE(r,"",{mode:384}),uE(r,n/1000,n/1000)}catch{}}function yE(e,t,n){for(let r of Al(e)){if(!r.isDirectory()||!pE.test(r.name))continue;let o=qn(e,r.name);for(let i of Al(o)){if(!i.isFile())continue;let s=gE.exec(i.name);if(!s||s[2]!==r.name)continue;let a=Date.parse(`${s[1]}T00:00:00.000Z`)+Tl;if(!Number.isFinite(a)||a>=t)continue;Yh(qn(o,i.name))}if(r.name!==n)Vh(o)}Vh(e)}function bE(e,t){try{let n=Uh(e);if(n.mtimeMs>=t)return;let r=qh(e,"utf-8").split(`
4
+ `).filter((o)=>o.trim()).map(vE);if(r.length===0)return;if(r.some((o)=>o===void 0||o>=t))return;if(Uh(e).mtimeMs!==n.mtimeMs)return;Yh(e)}catch{}}function vE(e){try{let t=JSON.parse(e).ts,n=typeof t==="string"?Date.parse(t):Number.NaN;return Number.isFinite(n)?n:void 0}catch{return}}function Al(e){try{return aE(e,{withFileTypes:!0,encoding:"utf8"})}catch{return[]}}function Yh(e){try{lE(e)}catch{}}function Vh(e){try{cE(e)}catch{}}var RE="2.0.9",PE=1e4,kE=2000,AE=256,TE=32768;function IE(e){let t=e.trim();if(!t)return null;let n=t.replace(/[^A-Za-z0-9_.-]+/g,"_");if(n=n.replace(/^[._-]+|[._-]+$/g,"").slice(0,128),!n||n==="."||n==="..")return null;return n}function OE(e){return(e??"").replace(/[^A-Za-z0-9]/g,"-").slice(0,180)||"no-cwd"}function Ol(e,t,n,r,o,i={}){let s=IE(e);if(!s)return;let a=i.homeDir??Jh();if(!a)return;let c=zE(a);if(!c)return;try{let l=(i.now??(()=>new Date))().toISOString(),u=Li(kt(t),i.failureStage?Number.POSITIVE_INFINITY:PE),d=Li(kt(n),kE),f=i.toolName?Li(kt(i.toolName),AE):void 0,m=o===null?void 0:Li(kt(o),TE),p=Il(c,OE(m?.value??null),l.slice(0,7));xE(p,{recursive:!0,mode:448});let h=Il(p,`${l.slice(0,10)}-${s}.jsonl`),b={ts:l,id:(i.createId??(()=>SE(8).toString("hex")))(),v:RE,sessionId:s,decision:i.decision??"deny",agent:i.agent,shape:i.shape,level:i.level,configFallback:i.configFallback,toolName:f?.value,command:u.value,segment:d.value,...u.truncated||d.truncated||f?.truncated||m?.truncated?{truncated:!0}:{},reason:r,ruleId:i.ruleId,intent:i.intent,failureStage:i.failureStage,errorCode:i.errorCode,cwd:m?.value??null};_E(h,`${JSON.stringify(b)}
5
+ `,{encoding:"utf-8",mode:384}),Kh(c,i.now)}catch{}}function Li(e,t){return{value:e.slice(0,t),truncated:e.length>t}}function Jh(e=process.env.CC_SAFETY_NET_AUDIT_HOME||process.env.HOME){let t=e||CE()||wE().homedir;return t&&EE(t)?t:null}function zE(e=Jh()){return e?Il(e,".cc-safety-net","logs"):null}function Qh(e,t,n,r=!0,o){if(t.decision.kind==="allow"){if(!n||e.route.kind!=="command")return;let a=Xh(e);return{decision:"allow",command:a,segment:a,reason:"allowed",cwd:e.context.executionCwd,toolName:e.toolName,level:t.level,...t.configFallback?{configFallback:!0}:{}}}let i=t.decision.evidence.find((a)=>a.kind==="command"),s=i?.command??(r?Xh(e):"");return{decision:"deny",command:s,segment:i?.segment??s,reason:t.decision.reason,cwd:e.context.executionCwd,toolName:e.toolName,level:t.level,...t.configFallback?{configFallback:!0}:{},ruleId:t.decision.ruleId,intent:t.decision.intent,failureStage:o?.stage,errorCode:o?.errorCode}}function Xh(e){return"command"in e?e.command??"":""}function ey(e,t,n){if(!e)return;let r;try{r=t()}catch{return}if(typeof r!=="string"||!r.trim())return;Ol(r,e.command,e.segment,e.reason,e.cwd,{homeDir:n.homeDir,decision:e.decision,agent:n.agent,shape:n.shape,level:e.level,configFallback:e.configFallback,toolName:e.toolName,ruleId:e.ruleId,intent:e.intent,failureStage:e.failureStage,errorCode:e.errorCode})}function ty(e,t,n){let r;try{r=t()}catch{return}if(typeof r!=="string"||!r.trim())return;Ol(r,e.command??"",e.segment??e.command??"",e.reason,n.cwd??null,{homeDir:n.homeDir,decision:"deny",agent:n.agent,shape:n.shape,toolName:n.toolName??e.toolName,ruleId:e.ruleId,intent:e.intent})}import{realpathSync as GE,statSync as ZE}from"node:fs";import{isAbsolute as ry,relative as BE,resolve as UE,sep as jE}from"node:path";import{dirname as NE,isAbsolute as DE,parse as $E,sep as LE}from"node:path";function pn(e,t=process.platform){if(t!=="win32")return!1;return(e[0]==="/"||e[0]==="\\")&&(e[1]==="/"||e[1]==="\\")}function Vt(e,t,n){if(pn(t))throw Error("Unsupported Windows namespace path");let r=DE(t)?WE(t):"",o=r||e;for(let i of FE(r?t.slice(r.length):t)){if(i===""||i===".")continue;if(i===".."){o=NE(o);continue}let s=ME(o,i),a=n.entryKind(s),c=a==="symlink"?n.realpath(s):s;if(a==="missing"||c===null)throw Error(`Cannot resolve path component: ${s}`);o=c}return o}function ME(e,t){return e.endsWith("/")||e.endsWith("\\")?`${e}${t}`:`${e}${LE}${t}`}function WE(e){return $E(e).root}function FE(e){let t=process.platform==="win32"?/[\\/]+/:/\/+/;return e.split(t)}function Mi(e,t){if(pn(e))return;let n=t.flatMap((o)=>ny(o));if(!n[0])return;let r=ny(ry(e)?e:UE(n[0],e))[0];if(!r)return;return n.some((o)=>oy(r,o))?r:void 0}function ny(e){try{let t=GE(e);return ZE(t).isDirectory()?[t]:[]}catch{return[]}}function oy(e,t){let n=BE(t,e);return n===""||n!==".."&&!n.startsWith(`..${jE}`)&&!ry(n)}var qt="Command could not be safely analyzed (strict mode). Simplify the command and retry, or ask the user to verify.",It="Command exceeds maximum recursion depth and cannot be safely analyzed. Flatten the nesting and retry.",iy="CC Safety Net could not validate the command because its structure exceeds safe analysis limits.",sy="CC Safety Net could not analyze the command because it exceeds safe analysis limits. Simplify or split the command and retry.",Wi="CC Safety Net failed closed because command analysis failed unexpectedly. This is not caused by your command. Report it to the user.";function cy(e){let{reason:t,command:n,segment:r,toolName:o}=e,i=e.maxLen??200,s=e.redact??((c)=>c),a=`BLOCKED by CC Safety Net
6
6
 
7
- Reason: ${K(J)}`;if($.ruleId)B+=`
7
+ Reason: ${s(t)}`;if(e.ruleId)a+=`
8
8
 
9
- Rule: ${$.ruleId}`;if(X)B+=`
9
+ Rule: ${e.ruleId}`;if(o)a+=`
10
10
 
11
- Tool: ${X}`;if(Q){let q=K(Q);B+=`
11
+ Tool: ${o}`;if(n){let c=s(n);a+=`
12
12
 
13
- Command: ${WB(q,Y)}`}if(W&&W!==Q){let q=K(W);B+=`
13
+ Command: ${ay(c,i)}`}if(r&&r!==n){let c=s(r);a+=`
14
14
 
15
- Segment: ${WB(q,Y)}`}if($.configWarning)B+=`
15
+ Segment: ${ay(c,i)}`}if(e.configWarning)a+=`
16
16
 
17
- Config warning: ${K($.configWarning)}`;return B+=`
17
+ Config warning: ${s(e.configWarning)}`;return a+=`
18
18
 
19
- ${dO($.intent??"manual_only")}`,B}function dO($){switch($){case"hard_stop":return"Do not retry this operation or attempt any workaround (other tools, flags, or paths). Report the block to the user and continue with the rest of the task.";case"use_alternative":return"Do not retry the blocked form. Continue the task using the safer alternative described above.";case"scope_down":return"Retry with a narrower, explicit target as described above. Escalate to the user if the broad operation is truly required.";case"manual_only":return"If this operation is truly needed, ask the user for explicit permission and have them run the command manually.";case"stop_and_explain":return"Do not brute-force variants. Simplify or restructure the command so it can be analyzed, or report the block to the user."}}function WB($,J){return $.length>J?`${$.slice(0,J)}...`:$}function YB($,J){if($.decision.kind!=="deny")return;let Q=J.includeEvidence?$.decision.evidence.find((W)=>W.kind==="command"):void 0;return{reason:$.decision.reason,ruleId:$.decision.ruleId,intent:$.decision.intent,command:Q?.command,segment:Q?.segment,toolName:J.toolName,...$.configFallback?{configWarning:$.configFallback.reason}:{}}}function wJ($={}){return{reason:k6,intent:"stop_and_explain",command:$.command,segment:$.segment??$.command,toolName:$.toolName}}function KB($){return XB({...$,redact:A0})}function BB($){return A0($ instanceof Error?$.message:String($))}import{basename as rO,dirname as iO,join as qB}from"node:path";var h6=Object.freeze({maxEnvironmentExpansionDepth:64,maxMissingSuffixComponents:256,maxRealpathAttempts:1024,maxProcessedCandidateBytes:4194304});class S1 extends Error{name="PathCanonicalizationLimitError";constructor(){super("Path canonicalization work limit exceeded.")}}function a4(){return{realpathAttempts:0,processedCandidateBytes:0,resolvedPaths:new Map}}function L2($){return{...a4(),environment:$}}var y6=new Set(["CC_SAFETY_NET_HOME","CLAUDE_CONFIG_DIR","CODEX_HOME","COPILOT_HOME","GEMINI_CLI_HOME","HOME","KIMI_CODE_HOME","KIMI_SHARE_DIR","OPENCODE_CONFIG","OPENCODE_CONFIG_DIR","PI_CODING_AGENT_DIR","ProgramData","TMPDIR","XDG_CONFIG_HOME","XDG_DATA_HOME"]);function g6($,J){return vJ($,0,J)}function vJ($,J,Q){let W="",X=0;while(X<$.length){if($[X]!=="$"){W+=$[X],X++;continue}if($[X+1]==="{"){let K=fJ($,X+2),B=oO($,X,J);if(B===null){if(y6.has(K))throw new S1;W+=$.slice(X);break}let q=$.slice(X,B+1);W+=nO(q,J,Q),X=B+1;continue}let Y=fJ($,X+1);if(!Y){W+="$",X++;continue}W+=kJ(Y,Q)??`$${Y}`,X+=Y.length+1}return W}function oO($,J,Q){let W=1;for(let X=J+2;X<$.length;X++){if($[X]==="\\"){X++;continue}if($[X]==="$"&&$[X+1]==="{"){if(W++,Q+W>h6.maxEnvironmentExpansionDepth)throw new S1;X++;continue}if($[X]!=="}")continue;if(W--,W===0)return X}return null}function nO($,J,Q){let W=$.slice(2,-1),X=fJ(W,0);if(!X)return $;let Y=W.slice(X.length);if(!Y)return kJ(X,Q)??$;let K=[":-",":+",":=",":?","-","+","=","?"].find((U)=>Y.startsWith(U));if(!K){if(y6.has(X))throw new S1;return $}if(!y6.has(X))return $;if(K.endsWith("="))throw new S1;let B=kJ(X,Q),q=K.startsWith(":")?B!==null&&B!=="":B!==null;if(K.endsWith("?")&&!q)throw new S1;if(K.endsWith("-")||K.endsWith("?"))return q?B??"":vJ(Y.slice(K.length),J+1,Q);return q?vJ(Y.slice(K.length),J+1,Q):""}function fJ($,J){if(!/[A-Za-z_]/.test($[J]??""))return"";let Q=J+1;while(/[A-Za-z0-9_]/.test($[Q]??""))Q++;return $.slice(J,Q)}function a($,J,Q=a4()){if(!$)return $;let W=Q.resolvedPaths.get($);if(W!==void 0)return W;let X=[],Y=$;while(!0){if(Q.realpathAttempts++,Q.processedCandidateBytes+=Buffer.byteLength(Y),Q.realpathAttempts>h6.maxRealpathAttempts||Q.processedCandidateBytes>h6.maxProcessedCandidateBytes)throw new S1;let K=J.realpath(Y);if(K!==null){let q=X.length===0?K:qB(K,...X.reverse());return Q.resolvedPaths.set($,q),q}let B=iO(Y);if(B===Y){let q=X.length===0?Y:qB(Y,...X.reverse());return Q.resolvedPaths.set($,q),q}if(X.length>=h6.maxMissingSuffixComponents)throw new S1;X.push(rO(Y)),Y=B}}function kJ($,J){if(!y6.has($))return null;if($==="HOME")return J.env.get("HOME")??J.home;return J.env.get($)??null}function v($){return $.provenance==="command-substitution"?$.raw:$.text}function i2($,J){return $==="posix"?J:p(J.map((Q)=>Q.text))}function x6($,J){return $&&$.provenance!=="unknown"?$.provenance==="literal":!/[$`*?[\]]/.test(J)}function p($){return $.map((J)=>({kind:"word",text:J,raw:J,span:{start:0,end:0},provenance:"unknown",quoted:!1,parts:[]}))}import{existsSync as gJ,lstatSync as WN,readFileSync as p6,realpathSync as $3,statSync as e4}from"node:fs";import{dirname as xJ,isAbsolute as uJ,join as c6,resolve as d6}from"node:path";import{lstatSync as sO,realpathSync as aO}from"node:fs";import{homedir as tO,tmpdir as eO}from"node:os";var m1={realpath:($)=>{try{return aO($)}catch{return null}},entryKind:($)=>{let J=sO($,{throwIfNoEntry:!1});if(!J)return"missing";return J.isSymbolicLink()?"symlink":"present"}};function M2(){return process.env.HOME||tO()}function T0(){return{env:new Map(Object.entries(process.env).flatMap(([$,J])=>J===void 0?[]:[[$,J]])),home:M2(),tmpdir:eO(),paths:m1}}var hJ=["GIT_DIR","GIT_WORK_TREE","GIT_COMMON_DIR","GIT_INDEX_FILE"],$N=new Set(hJ);var UB=new Set(["GIT_CONFIG_GLOBAL","GIT_CONFIG_NOSYSTEM","GIT_CONFIG_SYSTEM","HOME","XDG_CONFIG_HOME"]),u6=new Set(["GIT_SSH_COMMAND","GIT_SSH","GIT_SSH_VARIANT"]),JN=/^([A-Za-z_][A-Za-z0-9_]*)\+=/;function QN($){return $N.has($)}function t4($){return $==="GIT_CONFIG_COUNT"||$==="GIT_CONFIG_PARAMETERS"||/^GIT_CONFIG_(KEY|VALUE)_\d+$/.test($)}function yJ($){return QN($)||UB.has($)||u6.has($)||t4($)}function l1($,J,Q){return Q?.has($)?Q.get($):J.get($)}function m6($,J){let Q=l1("GIT_CONFIG_COUNT",$,J);if(Q===void 0)return{state:"absent"};if(Q==="")return{state:"valid",count:0};if(!/^\d+$/.test(Q))return{state:"invalid"};let W=Number(Q);return Number.isSafeInteger(W)&&W<=1024?{state:"valid",count:W}:{state:"invalid"}}function l6($,J,Q){let X=$.match(JN)?.[1];if(!X||!yJ(X))return null;let Y=$.indexOf("=");return{name:X,value:`${l1(X,J,Q)??""}${$.slice(Y+1)}`}}function GB($){return ZB($,u6)}function HB($){return ZB($,UB)}function ZB($,J){if(!$)return!1;for(let Q of $.keys())if(J.has(Q))return!0;return!1}var U0=new Set(["-c","-C","--git-dir","--work-tree","--namespace","--super-prefix","--config-env"]);function OB($,J){return hJ.some((Q)=>J?.has(Q)||$.has(Q))}function NB($,J){if(!J)return{gitCwd:null,hasExplicitGitContext:!1};let Q;try{Q=$3(d6(J))}catch{return{gitCwd:null,hasExplicitGitContext:!1}}if(!_B(Q))return{gitCwd:null,hasExplicitGitContext:!1};let W=!1,X=1;while(X<$.length){let Y=$[X];if(!Y)break;if(Y==="--")break;if(!Y.startsWith("-"))break;if(Y==="-C"){let K=$[X+1];if(!K)return{gitCwd:null,hasExplicitGitContext:W};let B=MB(Q,K);if(!B)return{gitCwd:null,hasExplicitGitContext:W};Q=B,X+=2;continue}if(Y.startsWith("-C")&&Y.length>2){let K=MB(Q,Y.slice(2));if(!K)return{gitCwd:null,hasExplicitGitContext:W};Q=K,X++;continue}if(Y==="--git-dir"||Y==="--work-tree"){W=!0,X+=2;continue}if(Y.startsWith("--git-dir=")||Y.startsWith("--work-tree=")){W=!0,X++;continue}if(U0.has(Y))X+=2;else if(Y.startsWith("-c")&&Y.length>2)X++;else X++}return{gitCwd:Q,hasExplicitGitContext:W}}function FB($){let J=FN($);if(!J)return!1;try{let Q=WN(J);if(Q.isSymbolicLink()||!Q.isFile())return!1;let W=mJ(J);if(!W?.commonDir)return!1;if(!KN(W.gitDir,J))return!1;return BN(W.gitDir,xJ(J))}catch{return!1}}function mJ($){try{let J=XN($);if(!J)return null;let Q=$3(uJ(J)?J:d6(xJ($),J));if(!e4(Q).isDirectory())return null;return{gitDir:Q,commonDir:YN(Q)}}catch{return null}}function XN($){let J=p6($,"utf-8").split(/\r?\n/,1)[0]?.trim()??"";if(!J.startsWith("gitdir:"))return null;return J.slice(7).trim()||null}function YN($){try{let J=p6(c6($,"commondir"),"utf-8").split(/\r?\n/,1)[0]?.trim();if(!J)return null;let Q=$3(uJ(J)?J:d6($,J));return e4(Q).isDirectory()?Q:null}catch{return null}}function KN($,J){let Q=qN($);return Q===null?!1:VB($,Q,J)}function BN($,J){let Q=UN($);return Q===null?!0:VB($,Q,J)}function qN($){let J=c6($,"gitdir");if(!gJ(J))return null;let Q=p6(J,"utf-8").split(/\r?\n/,1)[0]?.trim()??"";return Q===""?null:Q}function UN($){let J=c6($,"config.worktree");return gJ(J)?MN(J):null}function VB($,J,Q){return HN(GN($,J),Q)}function GN($,J){return uJ(J)?J:d6($,J)}function HN($,J){try{return ZN($,J)}catch{return!1}}function ZN($,J){try{let Q=e4($),W=e4(J);if(Q.ino!==0&&W.ino!==0&&Q.dev===W.dev&&Q.ino===W.ino)return!0}catch{}return LB($)===LB(J)}function LB($){return LN($3.native($))}function LN($){let J=$.replace(/^\\\\\?\\UNC\\/i,"//").replace(/^\\\\\?\\/i,"");if(J=J.replace(/\\/g,"/"),J.length>1&&J.endsWith("/"))J=J.slice(0,-1);return process.platform==="win32"?J.toLowerCase():J}function MN($){let J=p6($,"utf-8"),Q=!1,W=null;for(let X of J.split(/\r?\n/)){let Y=X.trim();if(Y===""||Y.startsWith("#")||Y.startsWith(";"))continue;if(Y.startsWith("[")){Q=/^\[core\]$/i.test(Y);continue}if(!Q)continue;let K=Y.match(/^worktree\s*=\s*(.*)$/i);if(K)W=ON(K[1]??"")}return W}function ON($){let J=$.trim();if(!J.startsWith('"')||!J.endsWith('"'))return J;return NN(J.slice(1,-1))}function NN($){let J="";for(let Q=0;Q<$.length;Q++){let W=$[Q];if(W!=="\\"){J+=W;continue}let X=$[Q+1];if(X===void 0){J+=W;continue}switch(X){case"\\":case'"':J+=X;break;case"n":J+=`
20
- `;break;case"t":J+="\t";break;case"b":J+="\b";break;default:J+=`\\${X}`;break}Q++}return J}function MB($,J){try{let Q=r0($,J,m1);return _B(Q)?Q:null}catch{return null}}function _B($){try{return e4($).isDirectory()}catch{return!1}}function FN($){try{return J3($3($))}catch{return null}}function J3($){let J=$;while(!0){let Q=c6(J,".git");if(gJ(Q))return Q;let W=xJ(J);if(W===J)return null;J=W}}function lJ($,J){return{value:$,work:J}}function j($,J){if($.work)$.work.units=Math.min(Number.MAX_SAFE_INTEGER,$.work.units+1);return $.value[J]}function B1($){return $.value.length}function Q3($,J,Q=1){if($)$.units=Math.min(Number.MAX_SAFE_INTEGER,$.units+J.length*Q)}function T1($,J){Q3($,J)}function O2($){if(!$)return!1;let J=$.charCodeAt(0);return J>=48&&J<=57||J>=65&&J<=90||J===95||J>=97&&J<=122}function e($){if(!$)return!1;let J=$.charCodeAt(0);return J===9||J===10||J===11||J===12||J===13||J===32||J===160||J===65279||J===5760||J>=8192&&J<=8202||J===8232||J===8233||J===8239||J===8287||J===12288}function pJ($){return $===`
21
- `||$==="\r"||$==="\u2028"||$==="\u2029"}function $1($,J,Q){if(J+Q.length>B1($))return!1;for(let W=0;W<Q.length;W++)if(j($,J+W)!==Q[W])return!1;return!0}function w0($,J,Q){return!O2(j($,J-1))&&$1($,J,Q)&&!O2(j($,J+Q.length))}function v0($,J){return O2(j($,J-1))!==O2(j($,J))}function L1($){return $===`
22
- `||$===";"||$==="&"||$==="|"}function o2($){return $==="|"||$===";"}function r6($,J,Q){let W=lJ($,Q);if(J==="rm")return VN(W);if(J==="dd")return DN(W);return bB(W,!0)}function i6($,J,Q){let W=lJ($,Q);if(J==="rm")return zN(W);if(J==="reset-hard")return jB(W,"--ha","rd");if(J==="reset-merge")return jB(W,"--me","rge");if(J==="clean")return bN(W);if(J==="checkout")return AN(W);if(J==="push-force")return EN(W);if(J==="push-refspec")return CN(W);if(J==="push-delete")return SN(W);if(J==="branch")return TN(W);if(J==="tag")return fN(W);if(J==="restore")return kN(W);return bB(W,!1)}function VN($){let J=!1,Q=!1,W=!1,X=-1;for(let Y=0;Y<=B1($);Y++){let K=j($,Y);if(!J){let q=j($,Y+2);if(w0($,Y,"rm")&&e(q)&&q!==`
23
- `)J=!0,Y++;continue}let B=_N($,Y);if(K===`
24
- `||B!==-1){if(J=!1,Q=!1,W=!1,X=-1,B!==-1)Y=B-1;continue}if(K===";"||K==="&"||K==="|"||Y===B1($)){if(X>=0){let q=DB($,X,Y);Q||=q.recursive,W||=q.force}if(Q&&W)return!0;J=!1,Q=!1,W=!1,X=-1;continue}if(e(K)){if(X>=0){if($1($,X,"--")&&Y-X===2)J=!1,Q=!1,W=!1;else{let q=DB($,X,Y);if(Q||=q.recursive,W||=q.force,Q&&W)return!0}X=-1}continue}if(X<0)X=Y}return!1}function _N($,J){if(j($,J)!=="\\"||j($,J-1)==="\\")return-1;if($1($,J,String.raw`\n`))return J+2;if($1($,J,String.raw`\x0a`)||$1($,J,String.raw`\x0A`))return J+5;if($1($,J,String.raw`\u000a`)||$1($,J,String.raw`\u000A`))return J+7;return $1($,J,String.raw`\012`)?J+4:-1}function DB($,J,Q){if(zB($,J,Q,"recursive"))return{recursive:!0,force:!1};if(zB($,J,Q,"force"))return{recursive:!1,force:!0};if(j($,J)!=="-"||j($,J+1)==="-")return{recursive:!1,force:!1};let W=!1,X=!1;for(let Y=J+1;Y<Q;Y++){let K=j($,Y);W||=K==="r"||K==="R",X||=K==="f"||K==="F"}return{recursive:W,force:X}}function zB($,J,Q,W){let X=Q-J-2;if(X<1||X>W.length||!$1($,J,"--"))return!1;for(let Y=0;Y<X;Y++)if(j($,J+Y+2)!==W[Y])return!1;return!0}function DN($){let J=!1;for(let Q=0;Q<B1($);Q++){if(L1(j($,Q))){J=!1;continue}if(w0($,Q,"dd")){J=!0,Q++;continue}if(!J||!w0($,Q,"of")||!$1($,Q,"of=/dev/"))continue;let W=Q+8;if(W<B1($)&&!e(j($,W))&&j($,W)!=="'"&&j($,W)!=='"')return!0}return!1}function zN($){let J=!1,Q=!1,W=!1;for(let X=0;X<=B1($);){let Y=j($,X);if(X===B1($)||L1(Y)){J=!1,Q=!1,W=!1,X++;continue}let K=jN($,X);if(K>=0){if(IN($,K))return!0;let B=K,q=!1;while(e(j($,B)))q||=j($,B)===`
25
- `,B++;if(q)Q=!1,W=!1;J=!0,X=B;continue}if(!J){X++;continue}if($1($,X,"--")&&(X===0||e(j($,X-1)))&&(!j($,X+2)||e(j($,X+2))||L1(j($,X+2)))){J=!1,Q=!1,W=!1,X+=2;continue}if(Q||=$1($,X,"--recursive")&&v0($,X+11)||cJ($,X,"recursive"),W||=$1($,X,"--force")&&v0($,X+7)||cJ($,X,"force"),Q&&W)return!0;X++}return!1}function cJ($,J,Q){if(!$1($,J,"--"))return!1;let W=0;while(W<=Q.length){let X=j($,J+W+2);if(!X||e(X)||L1(X))break;if(X!==Q[W])return!1;W++}return W>0&&v0($,J+W+2)}function IN($,J){let Q=J,W=!1,X=!1;while(Q<B1($)){while(e(j($,Q)))Q++;let Y=Q;while(Q<B1($)&&!e(j($,Q)))Q++;if(j($,Y)!=="-"||Q-Y===2&&$1($,Y,"--"))return!1;let K=IB($,Y,"recursive"),B=IB($,Y,"force");if(W&&B||X&&K)return!0;if(W||=K,X||=B,j($,Y+1)==="-")continue;let q=RN($,Y,Q);if(q.combined||W&&q.forceAtBoundary||X&&q.recursiveAtBoundary)return!0;W||=q.recursive,X||=q.force}return!1}function IB($,J,Q){return $1($,J,`--${Q}`)&&v0($,J+Q.length+2)||cJ($,J,Q)}function jN($,J){if(J>0&&O2(j($,J-1)))return-1;let Q=J;if(j($,Q)==="\\")Q++;if(j($,Q)!=="r")return-1;if(Q++,j($,Q)==="\\")Q++;if(j($,Q)!=="m"||!e(j($,Q+1)))return-1;return Q+1}function RN($,J,Q){let W=!1,X=!1,Y=!1,K=!1,B=!1;if(j($,J)!=="-")return{recursive:W,force:X,recursiveAtBoundary:Y,forceAtBoundary:K,combined:B};let q="";for(let U=J+1;U<Q;U++){let G=j($,U)??"",H=(G==="r"||G==="f")&&v0($,U+1);W||=G==="r",X||=G==="f",Y||=G==="r"&&H,K||=G==="f"&&H,B||=(q==="r"&&G==="f"||q==="f"&&G==="r")&&H,q=G}return{recursive:W,force:X,recursiveAtBoundary:Y,forceAtBoundary:K,combined:B}}function jB($,J,Q){return X3($,"reset",o2,!0,(W)=>j($,W)==="-"&&n2($,W,J,Q)?!0:W)}function bN($){return X3($,"clean",o2,!0,(J)=>{if(j($,J)!=="-")return J;if(n2($,J,"--fo","rce"))return!0;let Q=W3($,J,o2);for(let W=J+1;W<Q;W++)if(j($,W)==="f")return!0;return Q-1})}function o6($,J,Q){if(!w0($,J,"git"))return null;let W=J+3;if(!e(j($,W)))return{commandEnd:-1,next:W};while(e(j($,W)))W++;while(W<B1($)){if(L1(j($,W)))return{commandEnd:-1,next:W};let X=W3($,W,L1);if(w0($,W,Q))return{commandEnd:W+Q.length,next:X};if(j($,W)!=="-")return{commandEnd:-1,next:X};let Y=X-W===2&&$1($,W,"--"),K=PN($,W,X);W=X;while(e(j($,W)))W++;if(Y)return{commandEnd:w0($,W,Q)?W+Q.length:-1,next:W3($,W,L1)};if(!K)continue;if(W>=B1($)||L1(j($,W)))return{commandEnd:-1,next:W};W=W3($,W,L1);while(e(j($,W)))W++}return{commandEnd:-1,next:W}}function PN($,J,Q){for(let W of U0)if(Q-J===W.length&&$1($,J,W))return!0;return!1}function AN($){return RB($,{command:"checkout",longPrefix:"--fo",longOptional:"rce",shortFlag:"f",excludedShortStarts:"bBU"})}function EN($){return X3($,"push",o2,!0,(J)=>{if(j($,J)!=="-")return J;if(j($,J+1)==="f"&&!O2(j($,J+2))&&!$1($,J+2,"-with-lease"))return!0;let Q=PB($,J,"--fo","rce");if(Q>=0&&!$1($,Q,"-with-lease"))return!0;return J})}function CN($){return X3($,"push",L1,!1,(J)=>{if(e(j($,J))&&j($,J+1)==="+"&&J+2<B1($)&&!L1(j($,J+2))&&!e(j($,J+2)))return!0;if(j($,J)===":"&&j($,J+1)==="+")return!0;return J})}function SN($){return X3($,"push",L1,!1,(J)=>{if(j($,J)==="-"&&n2($,J,"--de","lete"))return!0;if(e(j($,J))&&j($,J+1)===":"&&J+2<B1($)&&!e(j($,J+2))&&!L1(j($,J+2)))return!0;return J})}function TN($){let J=!1,Q=!1,W=!1;for(let X=0;X<=B1($);X++){if(X===B1($)||L1(j($,X))){if(Q&&W)return!0;J=!1,Q=!1,W=!1;continue}if(!J){let B=o6($,X,"branch");if(B){J=B.commandEnd>=0,X=Math.max(X,(J?B.commandEnd:B.next)-1);continue}}if(!J||j($,X)!=="-")continue;let Y=W3($,X,L1),K=wN($,X,Y);if(Q||=K.deletion,W||=K.force,Q&&W)return!0;X=Y-1}return!1}function wN($,J,Q){let W=!1,X=!1;for(let Y=J;Y<Q;Y++){if(j($,Y)!=="-")continue;if(n2($,Y,"--de","lete"))W=!0;if(n2($,Y,"--fo","rce"))X=!0;if(j($,Y+1)==="-")continue;let K=Y+1,B=!1,q=!1,U=!1;while(K<Q&&vN(j($,K))){let G=j($,K);B||=G==="d"||G==="D",q||=G==="f",U||=G==="D",K++}if(!v0($,K))continue;W||=B,X||=q||U}return{deletion:W,force:X}}function vN($){if(!$)return!1;let J=$.charCodeAt(0);return J>=65&&J<=90||J>=97&&J<=122}function fN($){return RB($,{command:"tag",longPrefix:"--de",longOptional:"lete",shortFlag:"d",excludedShortStarts:""})}function RB($,J){let Q=[{outerActive:!1,shortActive:!1,hasShortFlag:!1,depth:0,quote:"",escaped:!1}];for(let W=0;W<B1($);W++){let X=j($,W),Y=Q[Q.length-1];if(!Y)return!1;let K=Y.escaped;if(Y.escaped=!K&&Y.quote!=="'"&&X==="\\",!K&&X==="'"&&Y.quote!=='"')Y.quote=Y.quote==="'"?"":"'";if(!K&&X==='"'&&Y.quote!=="'")Y.quote=Y.quote==='"'?"":'"';if(X==="$"&&j($,W+1)==="("&&(Q.length===1||!K&&Y.quote!=="'")){Q.push({outerActive:!1,shortActive:!1,hasShortFlag:!1,depth:1,quote:"",escaped:!1}),W++;continue}if(!K&&!Y.quote&&Q.length>1&&X==="("){Y.depth++;continue}if(!K&&!Y.quote&&Q.length>1&&X===")"){if(Y.depth--,Y.depth===0)Q.pop();continue}if(e(X))Y.shortActive=!1,Y.hasShortFlag=!1;if(!Y.outerActive){let B=o6($,W,J.command);if(B){Y.outerActive=B.commandEnd>=0&&e(j($,B.commandEnd)),Y.shortActive=!1,Y.hasShortFlag=!1,W=Math.max(W,(Y.outerActive?B.commandEnd:B.next)-1);continue}}if(Y.outerActive&&X==="-"){if(n2($,W,J.longPrefix,J.longOptional))return!0;Y.shortActive||=!J.excludedShortStarts.includes(j($,W+1)??"")}if(Y.hasShortFlag||=Y.shortActive&&X===J.shortFlag,Y.hasShortFlag&&v0($,W+1))return!0;if(o2(X))Y.outerActive=!1}return!1}function X3($,J,Q,W,X){let Y=!1;for(let K=0;K<B1($);K++){let B=j($,K),q=Q(B);if(!Y&&!q){let U=o6($,K,J);if(U){Y=U.commandEnd>=0&&(!W||e(j($,U.commandEnd))),K=Math.max(K,(Y?U.commandEnd:U.next)-1);continue}}if(Y){let U=X(K);if(U===!0)return!0;for(let G=K;G<=U;G++)if(Q(j($,G)))Y=!1;K=U}if(q)Y=!1}return!1}function kN($){let J=!1;for(let Q=0;Q<B1($);Q++){if(pJ(j($,Q))){if(J)return!0;J=!1;continue}if(!J){let W=o6($,Q,"restore");if(W){J=W.commandEnd>=0,Q=Math.max(Q,(J?W.commandEnd:W.next)-1);continue}}if(J&&j($,Q)==="-"&&j($,Q+1)==="-"&&($1($,Q+2,"staged")||$1($,Q+2,"help")))J=!1}return J}function bB($,J){let Q=!1;for(let W=0;W<B1($);W++){let X=j($,W),Y=J?pJ(X):L1(X);if(Q&&e(X)&&j($,W+1)==="-"&&w0($,W+2,"delete"))return!0;if(Y){Q=!1;continue}if(w0($,W,"find"))Q=!0,W+=3}return!1}function W3($,J,Q){let W=J;while(W<B1($)&&!e(j($,W))&&!Q(j($,W)))W++;return W}function PB($,J,Q,W){if(!$1($,J,Q))return-1;let X=J+Q.length;for(let Y=0;Y<W.length&&j($,X)===W[Y];Y++)X++;return v0($,X)?X:-1}function n2($,J,Q,W){return PB($,J,Q,W)>=0}var hN=["git.ssh-env","git.alias-config","git.checkout-force","git.checkout-double-dash","git.checkout-ref-path","git.checkout-pathspec-from-file","git.checkout-ambiguous","git.switch-discard-changes","git.switch-force","git.restore-worktree","git.restore-unstaged","git.reset-hard","git.reset-merge","git.clean-force","git.rm-force","git.push-force","git.push-delete","git.push-mirror","git.branch-force-delete","git.rebase-abort","git.merge-abort","git.tag-delete","git.reflog-delete","git.stash-drop","git.stash-clear","git.worktree-remove-force","rm.recursive-force-root-or-home","rm.git-metadata","rm.recursive-force-dynamic-target","rm.recursive-force-home-cwd","rm.recursive-force-cwd-self","rm.recursive-force-outside-cwd","rm.recursive-force-paranoid","powershell.remove-item-root-or-home","powershell.remove-item-recursive-force-root-or-home","powershell.remove-item-git-metadata","powershell.remove-item-recursive-force-dynamic-target","powershell.remove-item-recursive-force-home-cwd","powershell.remove-item-recursive-force-cwd-self","powershell.remove-item-recursive-force-outside-cwd","powershell.remove-item-recursive-force-paranoid","powershell.remove-item-pipeline-dynamic-target","find.delete","find.delete-git-metadata","find.exec-rm-recursive-force","dd.device-write","mkfs.device","shred.target","interpreter.dangerous-command","interpreter.one-liner-paranoid","awk.system-dynamic","xargs.rm-recursive-force-dynamic","xargs.shell-dynamic","parallel.rm-recursive-force-dynamic","parallel.shell-dynamic","parallel.command-stream-dynamic","shell.dynamic-structure","shell.dynamic-executable","raw-text.dangerous-command"],n6=new Set(hN),s6=[{id:"git.ssh-env",category:"Git",label:"Git SSH environment override",description:"Blocks Git network operations with SSH environment overrides.",example:'GIT_SSH_COMMAND="./ssh-wrapper" git push',intent:"manual_only"},{id:"git.alias-config",category:"Git",label:"Git command-line alias",description:"Blocks command-line Git aliases that cannot be safely resolved.",example:"git -c alias.wipe='!rm -rf /' wipe",intent:"manual_only"},{id:"git.checkout-force",category:"Git",label:"Git checkout force",description:"Blocks forced checkout operations that discard local changes.",example:"git checkout --force main",intent:"use_alternative"},{id:"git.checkout-double-dash",category:"Git",label:"Git checkout path restore",description:"Blocks checkout path restores after --.",example:"git checkout -- src/app.ts",intent:"use_alternative"},{id:"git.checkout-ref-path",category:"Git",label:"Git checkout ref and path",description:"Blocks checkout forms that mix a ref and path restore.",example:"git checkout HEAD -- src/app.ts",intent:"use_alternative"},{id:"git.checkout-pathspec-from-file",category:"Git",label:"Git checkout pathspec file",description:"Blocks checkout pathspec loading from a file.",example:"git checkout --pathspec-from-file=paths.txt",intent:"use_alternative"},{id:"git.checkout-ambiguous",category:"Git",label:"Git checkout ambiguous targets",description:"Blocks ambiguous checkout arguments that may restore paths.",example:"git checkout main src/app.ts",intent:"use_alternative"},{id:"git.switch-discard-changes",category:"Git",label:"Git switch discard changes",description:"Blocks branch switches that explicitly discard local changes.",example:"git switch --discard-changes main",intent:"use_alternative"},{id:"git.switch-force",category:"Git",label:"Git switch force",description:"Blocks forced branch switches.",example:"git switch --force main",intent:"use_alternative"},{id:"git.restore-worktree",category:"Git",label:"Git restore worktree",description:"Blocks worktree restore operations.",example:"git restore --worktree src/app.ts",intent:"use_alternative"},{id:"git.restore-unstaged",category:"Git",label:"Git restore unstaged",description:"Blocks unstaged restore operations.",example:"git restore src/app.ts",intent:"use_alternative"},{id:"git.reset-hard",category:"Git",label:"Git reset hard",description:"Blocks hard resets.",example:"git reset --hard",intent:"use_alternative"},{id:"git.reset-merge",category:"Git",label:"Git reset merge",description:"Blocks merge resets.",example:"git reset --merge",intent:"use_alternative"},{id:"git.clean-force",category:"Git",label:"Git clean force",description:"Blocks forced clean operations.",example:"git clean -fd",intent:"use_alternative"},{id:"git.rm-force",category:"Git",label:"Git rm force",description:"Blocks forced removal of tracked files from the working tree.",example:"git rm -rf .",intent:"use_alternative"},{id:"git.push-force",category:"Git",label:"Git push force",description:"Blocks force pushes.",example:"git push --force origin main",intent:"use_alternative"},{id:"git.push-delete",category:"Git",label:"Git push delete",description:"Blocks remote ref deletion through push.",example:"git push --delete origin old-branch",intent:"manual_only"},{id:"git.push-mirror",category:"Git",label:"Git push mirror",description:"Blocks mirror pushes that can force-update or delete remote refs.",example:"git push --mirror origin",intent:"manual_only"},{id:"git.branch-force-delete",category:"Git",label:"Git branch force delete",description:"Blocks forced branch deletion.",example:"git branch -D old-branch",intent:"use_alternative"},{id:"git.rebase-abort",category:"Git",label:"Git rebase abort",description:"Blocks rebase abort operations.",example:"git rebase --abort",intent:"use_alternative"},{id:"git.merge-abort",category:"Git",label:"Git merge abort",description:"Blocks merge abort operations.",example:"git merge --abort",intent:"use_alternative"},{id:"git.tag-delete",category:"Git",label:"Git tag delete",description:"Blocks tag deletion.",example:"git tag --delete v1.0.0",intent:"manual_only"},{id:"git.reflog-delete",category:"Git",label:"Git reflog delete",description:"Blocks reflog deletion.",example:"git reflog delete HEAD@{1}",intent:"manual_only"},{id:"git.stash-drop",category:"Git",label:"Git stash drop",description:"Blocks dropping stash entries.",example:"git stash drop stash@{0}",intent:"use_alternative"},{id:"git.stash-clear",category:"Git",label:"Git stash clear",description:"Blocks clearing all stash entries.",example:"git stash clear",intent:"manual_only"},{id:"git.worktree-remove-force",category:"Git",label:"Git worktree force remove",description:"Blocks forced worktree removal.",example:"git worktree remove --force ../feature",intent:"use_alternative"},{id:"rm.recursive-force-root-or-home",category:"Filesystem",label:"rm -rf root or home",description:"Blocks recursive forced removal of root or home paths.",example:"rm -rf /",intent:"hard_stop",catastrophic:!0},{id:"rm.git-metadata",category:"Filesystem",label:"rm Git metadata",description:"Blocks removal of protected Git metadata and hooks.",example:"rm -rf .git",intent:"hard_stop",catastrophic:!0},{id:"rm.recursive-force-dynamic-target",category:"Filesystem",label:"rm -rf dynamic target",description:"Blocks recursive forced removal with dynamic targets in strict mode.",example:'rm -rf "$target"',intent:"scope_down",activationCapability:"fail_closed"},{id:"rm.recursive-force-home-cwd",category:"Filesystem",label:"rm -rf from home cwd",description:"Blocks recursive forced removal while working in home.",example:'cd "$HOME" && rm -rf build',intent:"scope_down"},{id:"rm.recursive-force-cwd-self",category:"Filesystem",label:"rm -rf current directory",description:"Blocks recursive forced removal of the current directory.",example:"rm -rf .",intent:"scope_down"},{id:"rm.recursive-force-outside-cwd",category:"Filesystem",label:"rm -rf outside cwd",description:"Blocks recursive forced removal outside the original cwd.",example:"rm -rf ../outside",intent:"scope_down"},{id:"rm.recursive-force-paranoid",category:"Filesystem",label:"rm -rf paranoid mode",description:"Blocks non-temp recursive forced removal when paranoid rm is enabled.",example:"rm -rf ./cache",intent:"scope_down",activationCapability:"paranoid_rm"},{id:"powershell.remove-item-root-or-home",category:"PowerShell",label:"Remove-Item root or home",description:"Blocks PowerShell Remove-Item targeting root or home paths.",example:"Remove-Item C:\\",intent:"hard_stop",catastrophic:!0},{id:"powershell.remove-item-recursive-force-root-or-home",category:"PowerShell",label:"Remove-Item recursive force root or home",description:"Blocks recursive forced PowerShell removal of root or home paths.",example:"Remove-Item C:\\ -Recurse -Force",intent:"hard_stop",catastrophic:!0},{id:"powershell.remove-item-git-metadata",category:"PowerShell",label:"Remove-Item Git metadata",description:"Blocks PowerShell removal of protected Git metadata and hooks.",example:"Remove-Item .git -Recurse -Force",intent:"hard_stop",catastrophic:!0},{id:"powershell.remove-item-recursive-force-dynamic-target",category:"PowerShell",label:"Remove-Item recursive force dynamic target",description:"Blocks recursive forced PowerShell removal with dynamic targets in strict mode.",example:"Remove-Item $target -Recurse -Force",intent:"scope_down",activationCapability:"fail_closed"},{id:"powershell.remove-item-recursive-force-home-cwd",category:"PowerShell",label:"Remove-Item recursive force from home cwd",description:"Blocks recursive forced PowerShell removal while working in home.",example:"Set-Location $HOME; Remove-Item ./build -Recurse -Force",intent:"scope_down"},{id:"powershell.remove-item-recursive-force-cwd-self",category:"PowerShell",label:"Remove-Item recursive force current directory",description:"Blocks recursive forced PowerShell removal of the current directory.",example:"Remove-Item . -Recurse -Force",intent:"scope_down"},{id:"powershell.remove-item-recursive-force-outside-cwd",category:"PowerShell",label:"Remove-Item recursive force outside cwd",description:"Blocks recursive forced PowerShell removal outside the original cwd.",example:"Remove-Item ../outside -Recurse -Force",intent:"scope_down"},{id:"powershell.remove-item-recursive-force-paranoid",category:"PowerShell",label:"Remove-Item recursive force paranoid mode",description:"Blocks non-temp recursive forced PowerShell removal when paranoid rm is enabled.",example:"Remove-Item ./cache -Recurse -Force",intent:"scope_down",activationCapability:"paranoid_rm"},{id:"powershell.remove-item-pipeline-dynamic-target",category:"PowerShell",label:"Remove-Item pipeline dynamic target",description:"Blocks PowerShell Remove-Item with unverifiable pipeline input in strict mode.",example:"Get-ChildItem . -Recurse | Remove-Item -Force",intent:"scope_down",activationCapability:"fail_closed"},{id:"find.delete",category:"Filesystem",label:"find delete",description:"Blocks unsafe find -delete operations.",example:"find . -delete",intent:"scope_down"},{id:"find.delete-git-metadata",category:"Filesystem",label:"find delete Git metadata",description:"Blocks find -delete operations selecting protected Git metadata and hooks.",example:"find .git -delete",intent:"hard_stop",catastrophic:!0},{id:"find.exec-rm-recursive-force",category:"Filesystem",label:"find exec rm -rf",description:"Blocks find -exec rm -rf operations.",example:"find . -exec rm -rf {} +",intent:"scope_down"},{id:"dd.device-write",category:"Filesystem",label:"dd device write",description:"Blocks dd writing to a /dev device.",example:"dd if=/dev/zero of=/dev/sda",intent:"manual_only"},{id:"mkfs.device",category:"Filesystem",label:"mkfs device format",description:"Blocks mkfs formatting a /dev device.",example:"mkfs.ext4 /dev/sda1",intent:"manual_only"},{id:"shred.target",category:"Filesystem",label:"shred target",description:"Blocks shred against any target, including shred --help and shred --version.",example:"shred -u secret.txt",intent:"use_alternative"},{id:"interpreter.dangerous-command",category:"Execution",label:"Interpreter dangerous command",description:"Blocks interpreter one-liners containing dangerous commands.",example:`python -c "import os; os.system('rm -rf /')"`,intent:"use_alternative"},{id:"interpreter.one-liner-paranoid",category:"Execution",label:"Interpreter one-liner paranoid mode",description:"Blocks interpreter one-liners when paranoid interpreters is enabled.",example:'python -c "print(1)"',intent:"use_alternative",activationCapability:"paranoid_interpreters"},{id:"awk.system-dynamic",category:"Execution",label:"Awk dynamic system call",description:"Blocks awk system calls that cannot be safely analyzed.",example:"awk '{ system($0) }'",intent:"stop_and_explain"},{id:"xargs.rm-recursive-force-dynamic",category:"Execution",label:"xargs dynamic rm -rf",description:"Blocks xargs rm -rf with dynamic input.",example:"printf / | xargs rm -rf",intent:"scope_down"},{id:"xargs.shell-dynamic",category:"Execution",label:"xargs dynamic shell",description:"Blocks xargs shell execution with dynamic input.",example:"xargs r$(printf m) -rf",intent:"scope_down"},{id:"parallel.rm-recursive-force-dynamic",category:"Execution",label:"parallel dynamic rm -rf",description:"Blocks parallel rm -rf with dynamic input.",example:"printf / | parallel rm -rf",intent:"scope_down"},{id:"parallel.shell-dynamic",category:"Execution",label:"parallel dynamic shell",description:"Blocks parallel shell execution with dynamic input.",example:"parallel r$(printf m) -rf ::: child",intent:"scope_down"},{id:"parallel.command-stream-dynamic",category:"Execution",label:"parallel dynamic command stream",description:"Blocks parallel command streams from dynamic input.",example:"parallel --dry-run",intent:"scope_down"},{id:"shell.dynamic-structure",category:"Execution",label:"Dynamic command structure",description:"Blocks guarded subcommands and options assembled from substitution output in strict mode.",example:"git reset $(printf --hard)",intent:"stop_and_explain",activationCapability:"fail_closed"},{id:"shell.dynamic-executable",category:"Execution",label:"Dynamic executable name",description:"Blocks executable names assembled from command substitution output in strict mode.",example:"$(printf r)m -rf /",intent:"manual_only",activationCapability:"fail_closed"},{id:"raw-text.dangerous-command",category:"Execution",label:"Raw text dangerous command",description:"Blocks dangerous commands detected in raw command text.",example:"git reset --hard 'unterminated",intent:"stop_and_explain"}],yN=new Map(s6.map(($)=>[$.id,$.intent])),AB=new Set(s6.filter(($)=>$.catastrophic).map(($)=>$.id));function D($,J){return{id:$,reason:J,intent:yN.get($)??"manual_only"}}function k($,J){if(!$)return null;if(AB.has($.id))return $;if(J?.destructiveCommandProtectionEnabled===!1)return null;let Q=J?.effectiveDestructiveCommandRules?.[$.id];if(Q)return Q.enabled?$:null;return J?.destructiveCommandRuleOverrides[$.id]==="off"?null:$}function q1($,J,Q){if(AB.has(J))return!0;if($?.destructiveCommandProtectionEnabled===!1)return!1;let W=$?.effectiveDestructiveCommandRules?.[J];if(W)return W.enabled;let X=$?.destructiveCommandRuleOverrides[J];return X?X==="on":Q}function EB($,J){return Object.freeze(Object.fromEntries(s6.map((Q)=>{let W=Q.activationCapability?J[Q.activationCapability]:void 0,X=W?.enabled??!0,Y=$.destructiveCommandRuleOverrides[Q.id],K=Q.catastrophic?{enabled:!0,inheritedEnabled:!0,changesInherited:!1,source:"catastrophic",...Y?{override:Y}:{}}:$.destructiveCommandProtectionEnabled?Y?{enabled:Y==="on",inheritedEnabled:X,changesInherited:Y==="on"!==X,source:"rule_override",...Q.activationCapability?{activationCapability:Q.activationCapability}:{},override:Y}:{enabled:X,inheritedEnabled:X,changesInherited:!1,source:W?.source??"built_in_default",...Q.activationCapability?{activationCapability:Q.activationCapability}:{}}:{enabled:!1,inheritedEnabled:X,changesInherited:!1,source:"master_disabled",...Q.activationCapability?{activationCapability:Q.activationCapability}:{},...Y?{override:Y}:{}};return[Q.id,Object.freeze(K)]})))}function CB($,J){return Object.freeze({...$,effectiveDestructiveCommandRules:EB($,J)})}function Y3($,J){Q3(J,$,2);let Q=$.toLowerCase(),W=Q.trimStart(),X=W.startsWith("echo ")||W.startsWith("rg "),Y=[{scan:"rm",label:"rm -rf"},{scan:"reset-hard",label:"git reset --hard"},{scan:"reset-merge",label:"git reset --merge"},{scan:"clean",label:"git clean -f"},{scan:"checkout",label:"git checkout --force"},{scan:"push-force",label:"git push --force"},{scan:"push-refspec",label:"git push --force"},{scan:"push-delete",label:"git push delete"},{scan:"branch",label:"git branch -D",caseSensitive:!0},{scan:"tag",label:"git tag -d"},{regex:/\bgit\s+stash\s+(drop|clear)\b/,label:"git stash drop/clear"},{regex:/\bgit\s+checkout\s+--\s/,label:"git checkout --"},{scan:"restore",label:"git restore without --staged"},{scan:"find",label:"find -delete",skipForEchoRg:!0},{regex:/\bdd\b[^\n|;&]*\bof=\/dev\/\S/,label:"dd of=/dev/",skipForEchoRg:!0},{regex:/\bmkfs(?:\.[a-z0-9_-]+)?\s+\/dev\/\S/,label:"mkfs /dev/",skipForEchoRg:!0},{regex:/\bshred\b\s+\S/,label:"shred",skipForEchoRg:!0}];for(let K of Y){if(K.skipForEchoRg&&X)continue;let B=K.caseSensitive?$:Q;if(K.regex)T1(J,B);if((K.regex?.test(B)??!1)||K.scan&&i6(B,K.scan,J))return D("raw-text.dangerous-command",`Unparseable command text contains a destructive pattern (${K.label}). Rewrite as a plain, parseable command so it can be analyzed.`)}return null}var gN=/^[A-Za-z_][A-Za-z0-9_]*=/;function TB($,J,Q){let W=$.words[0];if(!J||!W||$.words.length!==1||$.dialect!=="posix")return!1;if(!W.quoted||W.provenance!=="literal")return!1;let X=/^([A-Za-z_][A-Za-z0-9_]*)=/.exec(W.text)?.[1];if(!X)return!1;Q3(Q,J.source,2);let Y={anchored:new RegExp(`^\\$\\{?${X}(?![A-Za-z0-9_])`),loose:new RegExp(`\\$\\{?${X}(?![A-Za-z0-9_])`)};return wB(J.nodes,W,Y)}function wB($,J,Q){return $.every((W)=>{if(W.kind==="connector")return!0;if(W.kind==="group"||W.kind==="function")return wB(W.body.nodes,J,Q);if(W.kind==="unknown")return!Q.loose.test(W.source);return xN(W,J,Q)})}function xN($,J,Q){if($.nested.some((X)=>Q.loose.test(X.source)))return!1;let W=$.words.findIndex((X)=>!gN.test(X.text));return $.words.every((X,Y)=>X===J||SB(X.raw,Q.anchored,Y!==W))&&$.redirections.every((X)=>(!X.heredoc||X.heredoc.quotedDelimiter||!Q.loose.test(X.heredoc.body))&&(!X.target||SB(X.target.raw,Q.anchored,!0)))}function SB($,J,Q){let W=!1,X=!1;for(let Y=0;Y<$.length;Y++){let K=$[Y];if(K==="\\"&&!W){Y++;continue}if(!X&&K==="'"){W=!W;continue}if(!W&&K==='"'){X=!X;continue}if(W||K!=="$")continue;if(!J.test($.slice(Y)))continue;if(!X||!Q)return!1}return!0}var vB=Object.freeze({maxDerivedTokens:16384}),fB="Command analysis exceeds CC Safety Net's derived-command work limit. Reduce nested or embedded command complexity and retry.",kB="env -S split-string expansion exceeds the 16,384-token analysis limit and cannot be verified safely. Expand the command explicitly.";class p1 extends Error{constructor(){super("Command analysis exceeds CC Safety Net's derived-command work limit. Reduce nested or embedded command complexity and retry.");this.name="DerivedCommandWorkLimitError"}}class N2 extends Error{constructor(){super("env -S split-string expansion exceeds the 16,384-token analysis limit and cannot be verified safely. Expand the command explicitly.");this.name="EnvSplitStringExpansionError"}}function a6(){return{derivedTokens:0}}function G0($,J){if(!Number.isSafeInteger($.derivedTokens)||$.derivedTokens<0||$.derivedTokens>vB.maxDerivedTokens||!Number.isSafeInteger(J)||J<0||J>vB.maxDerivedTokens-$.derivedTokens)throw new p1;$.derivedTokens+=J}import{isAbsolute as uN,resolve as hB}from"node:path";var yB=64;function K3($,J,Q){let W=uN($)?hB($):J?hB(J,$):void 0;if(!W)return;try{return a(W,Q)}catch{return W}}function gB($){return!["/dev","/proc","/sys"].some((J)=>$===J||$.startsWith(`${J}/`))}function r($){return l($).toLowerCase()}function l($){return $.split(/[\\/]/).pop()?.replace(/\.exe$/i,"")??$}var t6=10,s2=20,F2=/^[a-zA-Z][a-zA-Z0-9_-]*$/,a2=256,U1=new Set(["bash","sh","zsh","ksh","dash","fish","csh","tcsh"]),xB=new Set(["python","python3","python2","node","ruby","perl"]),uB=/^python(?:[23](?:\.\d+)*)?$/,e6=new Set(["echo","printf","cat","head","tail","less","more","grep","rg","ag","ack","sed","awk","cut","tr","sort","uniq","wc","tee","man","help","info","type","which","whereis","whatis","apropos","file","stat","ls","ll","dir","tree","pwd","date","cal","uptime","whoami","id","groups","hostname","uname","env","printenv","set","export","alias","history","jobs","fg","bg","test","true","false","read","return","exit","break","continue","shift","wait","trap","basename","dirname","realpath","readlink","md5sum","sha256sum","base64","xxd","od","hexdump","strings","diff","cmp","comm","join","paste","column","fmt","fold","nl","pr","expand","unexpand","rev","tac","shuf","seq","yes","sleep","logger","write","wall","mesg","notify-send"]);var V2="Interpreter code contains a dangerous command. Run the underlying command directly so it can be analyzed, or use the safer alternative for that command.",t2="Interpreter one-liners are blocked by the active safety policy. Write the code to a script file and run it, or run the equivalent shell command directly.",$9=new Map([["python",new Set(["-c"])],["node",new Set(["-e","--eval"])],["ruby",new Set(["-e"])],["perl",new Set(["-e","-E"])]]),mN=new Set(["-p","--print"]),lN=new Map([["python",new Set(["c"])],["node",new Set(["e"])],["ruby",new Set(["e"])],["perl",new Set(["e","E"])]]),pN=new Map([["python",new Set(["W","X"])],["node",new Set(["C","r"])],["ruby",new Set(["C","E","F","I","r"])],["perl",new Set(["F","I","M","m"])]]),cN=new Map([["ruby",new Set(["0","K","W","x"])],["perl",new Set(["0","C","D","V","d","i","l","x"])]]),dN=new Map([["python",new Set(["m"])]]),rN=new Map([["node",new Set(["--allow-fs-read","--allow-fs-write","--conditions","--cpu-prof-dir","--cpu-prof-interval","--cpu-prof-name","--debug-port","--diagnostic-dir","--disable-proto","--disable-warning","--dns-result-order","--env-file","--env-file-if-exists","--experimental-package-map","--experimental-test-isolation","--experimental-test-tag-filter","--heap-prof-dir","--heap-prof-interval","--heap-prof-name","--heapsnapshot-near-heap-limit","--heapsnapshot-signal","--icu-data-dir","--input-type","--inspect-port","--inspect-publish-uid","--localstorage-file","--max-http-header-size","--max-old-space-size-percentage","--network-family-autoselection-attempt-timeout","--openssl-config","--redirect-warnings","--report-dir","--report-directory","--report-filename","--report-signal","--secure-heap","--secure-heap-min","--test-concurrency","--test-coverage-branches","--test-coverage-exclude","--test-coverage-functions","--test-coverage-include","--test-coverage-lines","--test-global-setup","--test-isolation","--test-name-pattern","--test-random-seed","--test-reporter","--test-reporter-destination","--test-rerun-failures","--test-shard","--test-skip-pattern","--test-timeout","--title","--tls-cipher-list","--tls-keylog","--trace-event-categories","--trace-event-file-pattern","--trace-require-module","--unhandled-rejections","--use-largepages","--v8-pool-size","--watch-kill-signal"])],["python",new Set(["--check-hash-based-pycs"])],["ruby",new Set(["--backtrace-limit","--crash-report","--disable","--enable","--encoding","--external-encoding","--internal-encoding","--parser"])]]),iN=new Set(["always","default","never"]),oN=new Set(["--backtrace-limit","--crash-report","--disable","--enable"]),nN=/\\\r?\n/g,sN=new Map([["python",[{selector:"-c",kind:"inline-code",valueForm:"attached-or-separate"},{selector:"-m",kind:"module-file",valueForm:"attached-or-separate"}]],["node",[{selector:"-e",kind:"inline-code",valueForm:"separate-only"},{selector:"--eval",kind:"inline-code",valueForm:"equals-or-separate"},{selector:"-p",kind:"inline-code",valueForm:"separate-only"},{selector:"--print",kind:"inline-code",valueForm:"separate-only"},{selector:"-r",kind:"module-file",valueForm:"separate-only"},{selector:"--require",kind:"module-file",valueForm:"equals-or-separate"},{selector:"--import",kind:"module-file",valueForm:"equals-or-separate"},{selector:"--loader",kind:"module-file",valueForm:"equals-or-separate"},{selector:"--experimental-loader",kind:"module-file",valueForm:"equals-or-separate"}]],["ruby",[{selector:"-e",kind:"inline-code",valueForm:"attached-or-separate"},{selector:"-r",kind:"module-file",valueForm:"attached-or-separate"}]],["perl",[{selector:"-e",kind:"inline-code",valueForm:"attached-or-separate"},{selector:"-E",kind:"inline-code",valueForm:"attached-or-separate"},{selector:"-M",kind:"module-file",valueForm:"attached-only"},{selector:"-m",kind:"module-file",valueForm:"attached-only"}]]]);function J9($){return W9($).code}function Q9($){return W9($).sources}function lB($){return sN.get(Y9($))??[]}function W9($){let J=Y9($[0]??"");if(!$9.has(J))return{code:null,sources:[],optionsOpen:!1};let Q=[],W=[],X=!0;for(let Y=1;Y<$.length;Y++){let K=$[Y];if(K===void 0)break;if(K==="--")return s1(J,Q,W,X,$[Y+1]===void 0?void 0:Y+1,$[Y+1]);if(K===""||K==="-"||!K.startsWith("-"))return s1(J,Q,W,X,Y,K);if(J==="node"&&mN.has(K)){let H=$[Y+1];if(H===void 0)return s1(J,Q,W,X);if(H.startsWith("-"))continue;Q.push({tokenIndex:Y+1,value:H}),W.push({tokenIndex:Y+1,kind:"inline-code",value:H}),Y++;continue}if(tN(J,K)){let H=$[Y+1];if(H===void 0)return s1(J,Q,W,X);if(Q.push({tokenIndex:Y+1,value:H}),W.push({tokenIndex:Y+1,kind:"inline-code",value:H}),J==="python")return s1(J,Q,W,X);Y++;continue}let B=/^--eval=(.*)$/s.exec(K);if(eN(J)&&B){let H=B[1]??"";Q.push({tokenIndex:Y,value:H}),W.push({tokenIndex:Y,kind:"inline-code",value:H});continue}if(J==="node"){let H=aN(K);if(H){if(H.attached){if(X&&=H.value!=="",H.value!=="")W.push({tokenIndex:Y,kind:"module-file",value:H.value});continue}let L=$[Y+1];if(L===void 0||L.startsWith("-"))return X=!1,s1(J,Q,W,X);W.push({tokenIndex:Y+1,kind:"module-file",value:L}),Y++;continue}}if(J==="python"&&K.startsWith("--check-hash-based-pycs=")||J==="node"&&(K==="--conditions="||K==="--diagnostic-dir="||K==="--title=")||J==="ruby"&&(K==="--disable="||K==="--enable="))return s1(J,Q,W,X);if(rN.get(J)?.has(K)){let H=$[Y+1];if(H===void 0||H.startsWith("-")&&!(J==="ruby"&&oN.has(K))||J==="python"&&!iN.has(H))return s1(J,Q,W,X);Y++;continue}if(K.startsWith("--"))continue;let q,U=!1;for(let H=1;H<K.length;H++){let L=K[H];if(L===void 0)break;if(dN.get(J)?.has(L)){let Z=K.slice(H+1),M=Z||$[Y+1];if(M!==void 0)W.push({tokenIndex:Z?Y:Y+1,kind:"module-file",value:M});return s1(J,Q,W,X)}if(lN.get(J)?.has(L)){q=K.slice(H+1)||$[Y+1],U=H+1===K.length;break}if(J==="node"&&L==="r"){if(K==="-r"){let Z=$[Y+1];if(X&&=Z!==void 0&&!Z.startsWith("-"),X&&Z!==void 0)W.push({tokenIndex:Y+1,kind:"module-file",value:Z});Y++}else X=!1;break}if(J==="ruby"&&L==="r"){let Z=K.slice(H+1),M=Z||$[Y+1];if(X&&=M!==void 0,M!==void 0)W.push({tokenIndex:Z?Y:Y+1,kind:"module-file",value:M});if(!Z)Y++;break}if(J==="perl"&&(L==="M"||L==="m")){let Z=K.slice(H+1);if(Z)W.push({tokenIndex:Y,kind:"module-file",value:Z});else if(X=!1,H+1===K.length)Y++;break}if(pN.get(J)?.has(L)){if(H+1===K.length)Y++;break}if(cN.get(J)?.has(L)&&H+1<K.length)break}if(q===void 0)continue;let G=U?Y+1:Y;if(Q.push({tokenIndex:G,value:q}),W.push({tokenIndex:G,kind:"inline-code",value:q}),J==="python")return s1(J,Q,W,X);if(U)Y++}return s1(J,Q,W,X,void 0,void 0,!0)}function s1($,J,Q,W,X,Y,K=!1){let B=$==="node"?J.slice(-1):J,q=new Set(B.map((G)=>G.tokenIndex)),U=Q.filter((G)=>G.kind!=="inline-code"||q.has(G.tokenIndex));if(W&&J.length===0&&X!==void 0&&Y!==void 0)U.push({tokenIndex:X,kind:"main-script",value:Y});return{code:($==="node"?B[0]?.value:B.map((G)=>G.value).join(`
26
- `))||null,sources:W?U:[],optionsOpen:W&&K}}function aN($){for(let J of["--import","--loader","--experimental-loader","--require"]){if($===J)return{attached:!1,value:""};if($.startsWith(`${J}=`))return{attached:!0,value:$.slice(J.length+1)}}return}function w1($){return $9.has(Y9($))}function X9($,J){return Y9($)==="node"&&/^\s*console\.(?:log|info|warn|error)\(\s*(?:"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*')\s*\)\s*;?\s*$/.test(J)}function Y9($){let J=l($).toLowerCase();return uB.test(J)?"python":J}function tN($,J){return $9.get($)?.has(J)??!1}function eN($){return $9.get($)?.has("--eval")??!1}function e2($,J){let Q=QF($,J);if(!mB(Q,J))return!1;T1(J,Q);let W=JF(Q);if(mB(W,J))return!0;return T1(J,W),$F.test(W)}var $F=/`|%x|\b(?:system|exec|spawn|popen|subprocess|child_process|open3|eval|fork|qx)/i;function JF($){let J=[],Q=0,W=0;while(W<$.length){let X=$[W];if(X!=="'"&&X!=='"'){W++;continue}let Y=$.startsWith(X.repeat(3),W)?X.repeat(3):X,K=W+Y.length;while(K<$.length&&!$.startsWith(Y,K))K+=$[K]==="\\"?2:1;if(K>=$.length)break;J.push($.slice(Q,W)," "),W=K+Y.length,Q=W}return J.push($.slice(Q)),J.join("")}function mB($,J){if(r6($,"rm",J))return!0;for(let W of[/\bgit[^\S\n]+checkout[^\S\n]+--[^\S\n]/,/\bgit[^\S\n]+stash[^\S\n]+(drop|clear)\b/])if(T1(J,$),W.test($))return!0;if(r6($,"dd",J))return!0;for(let W of[/\bmkfs(?:\.[A-Za-z0-9_-]+)?\s+\/dev\/[^\s'"]+/,/\bshred\b\s+/])if(T1(J,$),W.test($))return!0;if(r6($,"find",J))return!0;let Q=$.split(/[\n\r\u2028\u2029]/);return["reset-hard","reset-merge","clean","checkout","push-force","push-refspec","push-delete","branch","tag","restore"].some((W)=>{return T1(J,$),Q.some((X)=>i6(X,W))})}function QF($,J){return T1(J,$),$.replace(nN,"")}var h=Object.freeze({maxChildAnalyses:1024,maxDerivedTokens:16384,maxDerivedBytes:1048576,maxPlaceholderReplacements:16384}),pB="Parallel command expands beyond CC Safety Net's analysis limits. Reduce the template or explicit argument list and retry.";class B9 extends Error{constructor(){super("Parallel command expands beyond CC Safety Net's analysis limits. Reduce the template or explicit argument list and retry.");this.name="ParallelAnalysisLimitError"}}function cB(){return{childAnalyses:0,derivedTokens:0,derivedBytes:0,placeholderReplacements:0}}function v1($,J){let Q=J.childAnalyses??0,W=J.derivedTokens??0,X=J.derivedBytes??0,Y=J.placeholderReplacements??0;if(K9($.childAnalyses,Q,h.maxChildAnalyses)||K9($.derivedTokens,W,h.maxDerivedTokens)||K9($.derivedBytes,X,h.maxDerivedBytes)||K9($.placeholderReplacements,Y,h.maxPlaceholderReplacements))throw new B9;$.childAnalyses+=Q,$.derivedTokens+=W,$.derivedBytes+=X,$.placeholderReplacements+=Y}function K9($,J,Q){return!Number.isSafeInteger($)||$<0||$>Q||!Number.isSafeInteger(J)||J<0||J>Q-$}import{isAbsolute as bQ,normalize as L_,parse as M_,posix as BU,resolve as Y4,sep as RQ}from"node:path";import{isAbsolute as WF,join as dB,normalize as oB,parse as XF,sep as rB}from"node:path";var YF=["/tmp","/var/tmp","/private/tmp","/private/var/tmp"],KF=`
27
- `;function B3($,J){if(H0($,J))return!0;if(!$.has("TMPDIR"))return!1;return!dJ($.get("TMPDIR")??"",J)}function f0($,J){if($.has("TMPDIR"))return dJ($.get("TMPDIR")??"",J);let Q=rJ($,J);if(Q===void 0)return!0;return dJ(Q,J)}function rJ($,J){return aB($,J,"TMPDIR")}function dJ($,J){if(!$)return!1;if(qF($))return!1;return iJ($,J)}function H0($,J){let Q=aB($,J,"IFS");return Q!==void 0&&Q!==""&&Q!==KF}function iJ($,J){let Q=q9($,J.paths);return Q!==null&&sB(J).some((W)=>GF(Q,W))}function nB($,J){let Q=q9($,J.paths);return Q!==null&&sB(J).includes(Q)}var iB=new WeakMap;function sB($){let J=iB.get($);if(J)return J;let Q=BF($);return iB.set($,Q),Q}function BF($){let J=YF.map((W)=>q9(W,$.paths)??oB(W)),Q=q9($.tmpdir,$.paths);if(!Q)return J;if(process.platform==="win32")return[...J,Q];if(process.platform==="darwin"&&UF(Q))return[...J,Q];return J}function qF($){return/[\s$`*?[]/.test($)||/\{[^{}]*(?:,|\.\.)[^{}]*\}/.test($)||/[+@!]\([^)]*\)/.test($)}function aB($,J,Q){return $.has(Q)?$.get(Q):J.env.get(Q)}function UF($){return/^\/(?:private\/)?var\/folders\/[^/]{2}\/[^/]+\/T$/.test($)}function q9($,J){try{let Q=oB($);if(!WF(Q))return Q;let W=XF(Q).root,X=Q.slice(W.length).split(/[\\/]+/).filter(Boolean),Y=W;for(let K=0;K<X.length;K++){let B=dB(Y,X[K]??"");if(J.entryKind(B)==="missing")return dB(B,...X.slice(K+1));let q=J.realpath(B);if(q===null)return null;Y=q}return Y}catch{return null}}function GF($,J){if($===J)return!0;let Q=J.endsWith(rB)?J:`${J}${rB}`;return $.startsWith(Q)}import{statSync as eV}from"node:fs";import{isAbsolute as tq,join as $_,relative as eq}from"node:path";import{isAbsolute as tB,parse as HF}from"node:path";var Jq=/^[A-Za-z_][A-Za-z0-9_]*=/,ZF=/^\$\{([A-Za-z_][A-Za-z0-9_]*)\}/,Qq=131072,LF=16384;function t1($){if(!Jq.test($))return null;let J=$.indexOf("=");return{name:$.slice(0,J),value:$.slice(J+1)}}function U9($){let J=new Map,Q=0;while(Q<$.length){let W=$[Q];if(!W)break;let X=t1(v(W));if(!X)break;J.set(X.name,X.value),Q++}return{words:$.slice(Q),envAssignments:J}}function Wq($){let J=$.toLowerCase();return $.includes("=")||J==="sudo"||J==="env"||J==="command"||J==="builtin"}function _2($,J,Q,W){if(!Wq($4($)))return{words:$,envAssignments:new Map,cwd:Q,rewritten:!1};let X=new Set($),Y=$,K=new Map,B=new Map(W??[]),q=Q;for(let G=0;G<s2;G++){let H=$q(Y),L=U9(Y);for(let[M,O]of L.envAssignments)K.set(M,O),B.set(M,O);if(Y=L.words,Y.length===0)break;while(Y.length>0&&$4(Y).includes("=")&&!MF(Y)){let M=OF($4(Y),B,J.env)??l6($4(Y),J.env,B);if(M)K.set(M.name,M.value),B.set(M.name,M.value);Y=Y.slice(1)}if(Y.length===0)break;let Z=$4(Y).toLowerCase();if(Z!=="sudo"&&Z!=="env"&&Z!=="command"&&Z!=="builtin")break;if(Z==="sudo"){let M=FF(Y,J.paths,q);if(Y=M.words,M.cwd!==void 0)q=M.cwd}if(Z==="env"){let M=DF(Y,q,B,J);if(M.unverifiableEnvSplit)return{words:Y,envAssignments:K,cwd:q,unverifiableEnvSplit:!0,rewritten:eB(Y,X)};if(Y=M.words,M.cwd!==void 0)q=M.cwd;for(let[O,V]of M.envAssignments)K.set(O,V),B.set(O,V)}if(Z==="command")Y=PF(Y);if(Z==="builtin")Y=Y.slice(a1(Y,1)==="--"?2:1);if($q(Y)===H)break}let U=U9(Y);for(let[G,H]of U.envAssignments)K.set(G,H),B.set(G,H);return{words:U.words,envAssignments:K,cwd:q,rewritten:eB(U.words,X)}}function eB($,J){return $.some((Q)=>!J.has(Q))}function $q($){return $.map(v).join(" ")}function $4($){let J=$[0];return J?v(J):""}function a1($,J){let Q=$[J];return Q?v(Q):void 0}function MF($){return Jq.test($4($))}function OF($,J,Q){if(!$.startsWith("TMPDIR+="))return null;return{name:"TMPDIR",value:`${J.get("TMPDIR")??Q.get("TMPDIR")??""}${$.slice(8)}`}}var NF=new Set(["-u","-g","-C","-D","-h","-p","-r","-t","-T","-U"]);function FF($,J,Q){let W=1,X=Q;while(W<$.length){let Y=a1($,W);if(!Y)break;if(Y==="--")return{words:$.slice(W+1),cwd:X};if(!Y.startsWith("-"))break;if(Y==="-D"||Y==="--chdir"){let K=a1($,W+1);X=K?q3(X,K,J):null,W+=2;continue}if(Y.startsWith("--chdir=")){X=q3(X,Y.slice(8),J),W++;continue}if(Y.startsWith("-D")&&Y.length>2){X=q3(X,Y.slice(2),J),W++;continue}if(Y==="-i"||Y==="--login"){X=null,W++;continue}if(NF.has(Y)){W+=2;continue}W++}return{words:$.slice(W),cwd:X}}var VF=new Set(["-i","-0","--null"]),_F=new Set(["-u","--unset","-C","--chdir","-S","--split-string","-P"]);function DF($,J,Q,W){let X=new Map,Y=J,K=$,B=new Set,q=1;while(q<K.length){let U=a1(K,q);if(!U)break;if(U==="--")return{words:K.slice(q+1),envAssignments:X,cwd:Y};if(U==="-i"||U==="--ignore-environment"||U==="-"){X.clear();for(let H of Q.keys())X.set(H,"");X.set("TMPDIR",""),q++;continue}if(VF.has(U)){q++;continue}if(U==="-u"||U==="--unset"){let H=a1(K,q+1);if(H!==void 0)B.add(H),X.set(H,"");q+=2;continue}if(U.startsWith("-u")&&U.length>2&&!U.startsWith("-u=")){let H=U.slice(2);B.add(H),X.set(H,""),q++;continue}if(U.startsWith("--unset=")){let H=U.slice(8);B.add(H),X.set(H,""),q++;continue}let G=U==="-S"||U==="--split-string"?{value:a1(K,q+1),consumed:2}:U.startsWith("-S")&&U.length>2?{value:U.slice(2),consumed:1}:U.startsWith("--split-string=")?{value:U.slice(15),consumed:1}:null;if(G){let H=zF(K,q,G.value,G.consumed,Q,B,Y,W.env);if(H.done)return H.result;K=H.expanded,Y=H.currentCwd,q=H.nextIndex;continue}if(_F.has(U)){if(U==="-C"||U==="--chdir"){let H=a1(K,q+1);Y=H?q3(Y,H,W.paths):null}q+=2;continue}if(U.startsWith("-u=")){q++;continue}if(U.startsWith("-C")&&U.length>2||U.startsWith("--chdir=")){let H=U.startsWith("--chdir=")?U.slice(8):U.startsWith("-C=")?U.slice(3):U.slice(2);Y=q3(Y,H,W.paths),q++;continue}if(U.startsWith("-P")){q++;continue}if(U.startsWith("-")){q++;continue}if(!t1(U))break;while(q<K.length){let H=t1(a1(K,q)??"");if(!H)break;X.set(H.name,H.value),q++}if(a1(K,q)==="--")q++;return{words:K.slice(q),envAssignments:X,cwd:Y}}return{words:K.slice(q),envAssignments:X,cwd:Y}}function zF($,J,Q,W,X,Y,K,B){let q=Q!==void 0?IF(Q,X,Y,B):{tokens:null,unverifiableEnvSplit:!1};if(q.unverifiableEnvSplit)return{done:!0,result:{words:$,envAssignments:new Map,cwd:K,unverifiableEnvSplit:!0}};if(!q.tokens)return{done:!1,expanded:$,currentCwd:null,nextIndex:J+W};return{done:!1,expanded:[...$.slice(0,J),...p(q.tokens),...$.slice(J+W)],currentCwd:K,nextIndex:J}}function IF($,J,Q,W){if($.length>Qq)return{tokens:null,unverifiableEnvSplit:!0};let X=jF($,(Y)=>{if(Q.has(Y))return"";if(J.has(Y))return J.get(Y)??"";return W.get(Y)??""});return{tokens:X.tokens,unverifiableEnvSplit:X.limited}}function jF($,J){let Q=[],W=[],X=0,Y=!1,K=!1,B=!1,q=!1,U=(H)=>{if(X+H.length>Qq)return q=!0,!1;return W.push(H),X+=H.length,Y=!0,!0},G=()=>{if(!Y)return!0;if(Q.length>=LF)return q=!0,!1;return Q.push(W.join("")),W=[],Y=!1,!0};for(let H=0;H<$.length;H++){let L=$[H]??"";if(L==="'"&&!B){K=!K,Y=!0;continue}if(L==='"'&&!K){B=!B,Y=!0;continue}if(!K&&!B&&bF(L)){if(!G())return{tokens:null,limited:q};continue}if(!K&&!B&&L==="#"&&!Y)break;if(L==="$"&&!K){let O=$.slice(H).match(ZF);if(!O?.[1]||!U(J(O[1])))return{tokens:null,limited:q};H+=O[0].length-1;continue}if(L!=="\\"){if(!U(L))return{tokens:null,limited:q};continue}let Z=$[H+1];if(Z===void 0)return{tokens:null,limited:q};if(K&&Z!=="'"&&Z!=="\\"){if(!U("\\"))return{tokens:null,limited:q};continue}if(Z==="c"){if(B)return{tokens:null,limited:q};break}if(Z==="_"&&!K&&!B){if(!G())return{tokens:null,limited:q};H++;continue}let M=RF(Z);if(M===void 0||!U(M))return{tokens:null,limited:q};H++}if(K||B||!G())return{tokens:null,limited:q};return{tokens:Q,limited:!1}}function RF($){if($==="f")return"\f";if($==="n")return`
28
- `;if($==="r")return"\r";if($==="t")return"\t";if($==="v")return"\v";if($==="_")return" ";if($==="#"||$==="$"||$==='"'||$==="'")return $;if($==="\\")return"\\";return}function bF($){return $===" "||$==="\t"||$===`
29
- `||$==="\r"||$==="\f"||$==="\v"}function q3($,J,Q){if(J==="")return null;if(!$&&!tB(J))return null;let W=tB(J)?HF(J).root:Q.realpath($??"/");if(W===null)return null;try{return r0(W,J,Q)}catch{return null}}function PF($){if(a1($,1)==="-v")return[...p(["type"]),...$.slice(2)];let J=1;while(J<$.length){let Q=a1($,J);if(!Q)break;if(Q==="-p"||Q==="-v"||Q==="-V"){J++;continue}if(Q==="--")return $.slice(J+1);if(Q.startsWith("-")&&!Q.startsWith("--")&&Q.length>1){if(!/^[pvV]+$/.test(Q.slice(1)))break;J++;continue}break}return $.slice(J)}function c1($,J,Q){return oJ($,J,Q).tokens}function oJ($,J,Q,W){if(!Wq($[0]??""))return{tokens:[...$],envAssignments:new Map,cwd:Q};let X=_2(p($),J,Q,W);return{tokens:X.words.map(v),envAssignments:X.envAssignments,cwd:X.cwd,unverifiableEnvSplit:X.unverifiableEnvSplit}}import{isAbsolute as oV,normalize as nV,resolve as sq}from"node:path";function G9(){return[]}function H9(){return[]}function Z9(){return{words:[],redirections:[],nested:[],start:-1,end:-1,reset(){this.words=[],this.redirections=[],this.nested=[],this.start=-1,this.end=-1}}}function AF($){return Object.freeze({...$,span:Object.freeze($.span),words:Object.freeze($.words),redirections:Object.freeze($.redirections.map((J)=>Object.freeze({...J,span:Object.freeze(J.span),...J.heredoc?{heredoc:Object.freeze({...J.heredoc,bodySpan:Object.freeze(J.heredoc.bodySpan),terminatorSpan:Object.freeze(J.heredoc.terminatorSpan)})}:{}}))),nested:Object.freeze($.nested.map((J)=>j1(J)))})}function L9($,J,Q){$.push(Q),J.reset()}function EF($,J,Q,W,X){if(W<=Q)return;$.push({raw:J.slice(Q,W),span:{start:Q,end:W},provenance:X})}function M9($){let J=[];return{parts:J,push:(Q,W,X)=>EF(J,$,Q,W,X)}}function nJ($){let J=$.parts??[{raw:$.raw,span:$.span,provenance:$.provenance}];return Object.freeze({kind:"word",...$,span:Object.freeze($.span),parts:Object.freeze(J.map((Q)=>Object.freeze({...Q,span:Object.freeze(Q.span)})))})}function J4($,J,Q,W,X,Y,K){return nJ({text:W,raw:$.slice(J,Q),span:{start:J,end:Q},provenance:X,quoted:Y,...K?{parts:K}:{}})}function j1($){return Object.freeze({...$,span:Object.freeze($.span),issues:Object.freeze($.issues.map((J)=>Object.freeze({...J,span:Object.freeze(J.span)}))),nodes:Object.freeze($.nodes.map((J)=>{if(J.kind==="command")return AF(J);if(J.kind==="group"||J.kind==="function")return Object.freeze({...J,span:Object.freeze(J.span),body:j1(J.body)});return Object.freeze({...J,span:Object.freeze(J.span)})}))})}function sJ($,J,Q){if(J>=Q||Yq($[J]??""))return null;let W="",X=!1,Y=!1,K=J;while(K<Q&&!Yq($[K]??"")){let B=$[K]??"";if(B==="'"){X=!0;let q=Xq($,K+1,Q,"'");W+=q.text,Y||=!q.closed,K=q.next;continue}if(B==='"'){X=!0;let q=Xq($,K+1,Q,'"');W+=q.text,Y||=!q.closed,K=q.next;continue}if(B==="\\"){X=!0;let q=$[K+1];if(!q||q===`
30
- `||q==="\r"){Y=!0;break}W+=q,K+=2;continue}if(B==="`"||$.startsWith("$(",K)||$.startsWith("${",K)||$.startsWith("<(",K)||$.startsWith(">(",K))Y=!0;W+=B,K++}return{delimiter:W,quoted:X,next:K,span:{start:J,end:K},ambiguous:Y}}function aJ($,J,Q,W){let X=[],Y=J;for(let K of W){let B=Y,q=!1;while(Y<Q){let U=CF($,Y,Q);if((K.stripTabs?U.text.replace(/^\t+/,""):U.text)===K.delimiter){K.attach({body:K.stripTabs?SF($.slice(B,Y)):$.slice(B,Y),delimiter:K.delimiter,quotedDelimiter:K.quotedDelimiter,stripTabs:K.stripTabs,bodySpan:{start:B,end:Y},terminatorSpan:{start:Y,end:U.contentEnd}}),Y=U.next,q=!0;break}if(U.next<=Y)break;Y=U.next}if(q)continue;return X.push({code:"unterminated-heredoc",message:`heredoc delimiter ${K.delimiter} was not found`,span:K.declarationSpan}),{next:Q,issues:X,terminated:!1}}return{next:Y,issues:X,terminated:!0}}function Xq($,J,Q,W){let X="",Y=J;while(Y<Q&&$[Y]!==`
31
- `&&$[Y]!=="\r"){let K=$[Y]??"";if(K===W)return{text:X,next:Y+1,closed:!0};if(W==='"'&&K==="\\"&&$[Y+1]){let B=$[Y+1]??"";X+=["$","`",'"',"\\"].includes(B)?B:`\\${B}`,Y+=2;continue}X+=K,Y++}return{text:X,next:Y,closed:!1}}function Yq($){return/[\s;&|<>)]/u.test($)||$==="`"}function CF($,J,Q){let W=J;while(W<Q&&$[W]!==`
32
- `&&$[W]!=="\r")W++;let X=W>=Q?Q:$[W]==="\r"&&$[W+1]===`
33
- `?W+2:W+1;return{text:$.slice(J,W),contentEnd:W,next:X}}function SF($){return $.replace(/(^|\r\n?|\n)\t+/g,"$1")}var Gq=new Set(["&&","||","|","|&"]);function Hq($,J,Q){let W={start:0,end:$.length};if($.length>Q.maxInputLength)return j1({kind:"program",dialect:J,source:$,span:W,status:"limited",issues:[{code:"input-limit",message:`command exceeds ${Q.maxInputLength} UTF-16 code units`,span:W}],nodes:[]});let X=F9($,0,$.length,J,Q,{used:0,max:Q.maxWords},0);return j1({kind:"program",dialect:J,source:$,span:W,status:D9(X.issues,X.limited),issues:X.issues,nodes:X.nodes})}function F9($,J,Q,W,X,Y,K,B){let q=G9(),U=H9(),G=Z9(),H=[],L=()=>{if(G.words.length===0&&G.redirections.length===0)return;let M={start:G.start,end:G.end},O=G.words.map((V)=>V.text);L9(q,G,{kind:"command",dialect:W,source:$.slice(M.start,M.end),span:M,words:G.words,redirections:G.redirections,nested:G.nested,dynamicExecutable:G.words[0]?.provenance==="command-substitution",displayText:U.length>0&&q.length===0?$.slice(J,Q):O.join(" ")})},Z=J;while(Z<Q){let M=$[Z];if(!M)break;if(B&&M===B)return L(),Uq(q,U),{nodes:q,issues:U,next:Z+1,closed:!0,limited:!1,pendingHeredocs:H};if(_9(M)){if(M===`
34
- `||M==="\r"){L();let E=M==="\r"&&$[Z+1]===`
35
- `?Z+2:Z+1,_=q.at(-1);if(_?.kind!=="connector"||!Gq.has(_.operator))q.push(Object.freeze({kind:"connector",operator:$.slice(Z,E),span:Object.freeze({start:Z,end:E})}));if(H.length>0){let R=aJ($,E,Q,H.splice(0));U.push(...R.issues),Z=R.next;continue}Z=E;continue}Z++;continue}if(M==="#"){while(Z<Q&&$[Z]!==`
36
- `&&$[Z]!=="\r")Z++;continue}let O=G.start===-1?nF($,Z,Q):void 0;if(O){if(eJ(q,U,Z),K>=X.maxDepth)return Q4(q,U,Z,"depth-limit",X.maxDepth);if(!tJ(Y))return Q4(q,U,Z,"word-limit",X.maxWords);let E=F9($,O.braceIndex+1,Q,W,X,Y,K+1,"}"),_=E.next,R={start:O.braceIndex+1,end:E.closed?_-1:_},P=Kq($,W,R,E);if(q.push({kind:"function",name:O.name,span:{start:Z,end:_},body:P}),U.push(...E.issues),E.pendingHeredocs.length>0||G3(E.nodes))U.push({code:"unsupported-heredoc-context",message:"heredocs attached inside function bodies are not supported safely",span:{start:Z,end:_}});if(H.push(...E.pendingHeredocs),E.limited)return N9(q,U,E.next);if(!E.closed)U.push({code:"unclosed-function-body",message:"function body is not closed",span:{start:O.braceIndex,end:_}});Z=_;continue}let V=V9($,Z);if(V){if(L(),!_q(q.at(-1)))U.push({code:"unexpected-connector",message:`connector ${V} has no preceding command`,span:{start:Z,end:Z+V.length}});q.push(Object.freeze({kind:"connector",operator:V,span:Object.freeze({start:Z,end:Z+V.length})})),Z+=V.length;continue}if(M===")"){L(),U.push({code:"unexpected-closing-delimiter",message:"closing parenthesis has no matching opening parenthesis",span:{start:Z,end:Z+1}}),q.push({kind:"unknown",source:M,span:{start:Z,end:Z+1}}),Z++;continue}if((M==="("||M==="{"&&yF($,Z,Q))&&G.start===-1){if(eJ(q,U,Z),K>=X.maxDepth)return Q4(q,U,Z,"depth-limit",X.maxDepth);let E=M==="("?")":"}",_=F9($,Z+1,Q,W,X,Y,K+1,E),R=_.next,P={start:Z+1,end:_.closed?R-1:R},C=Kq($,W,P,_);if(q.push({kind:"group",style:M==="("?"subshell":"brace",span:{start:Z,end:R},body:C}),U.push(..._.issues),_.pendingHeredocs.length>0||G3(_.nodes))U.push({code:"unsupported-heredoc-context",message:"heredocs attached inside command groups are not supported safely",span:{start:Z,end:R}});if(H.push(..._.pendingHeredocs),_.limited)return N9(q,U,_.next);if(!_.closed)U.push({code:M==="("?"unclosed-subshell":"unclosed-brace-group",message:`${M} group is not closed`,span:{start:Z,end:R}});Z=R;continue}let F=(M==="<"||M===">")&&$[Z+1]!=="("?vF($,Z):null;if(F){let E=G.words.at(-1),_=E&&E.span.end===Z&&/^[0-9]+$/.test(E.raw)?Number(E.raw):void 0;if(_!==void 0)G.words.pop();let R=_===void 0?Z:E?.span.start??Z;G.start=G.start===-1?Z:G.start;let P=Z+F.length;while(P<Q&&/[ \t]/.test($[P]??""))P++;let C=$[P],S=P>Z+F.length&&C==="#",g=!C||_9(C)||!!V9($,P)||C===B||C===")"||S||(C==="<"||C===">")&&$[P+1]!=="(",x=F==="<<"||F==="<<-"?sJ($,P,Q):void 0,d=x?{word:J4($,P,x.next,x.delimiter,"literal",x.quoted),nested:[],issues:[],next:x.next,limited:!1}:!g?$Q($,P,Q,W,X,Y,K):void 0;if(d){if(U.push(...d.issues),d.limited)return N9(q,U,d.next);if(!tJ(Y))return Q4(q,U,d.next,"word-limit",X.maxWords)}let V1=d?.next??Z+F.length,T={kind:"redirection",operator:F,span:{start:R,end:V1},..._===void 0?{}:{fd:_},...d?{target:d.word}:{}};if(G.redirections.push(T),F==="<<"||F==="<<-")if(!x)U.push({code:"missing-heredoc-delimiter",message:"heredoc redirection requires a delimiter word",span:{start:Z,end:Z+F.length}});else{if(x.ambiguous||x.delimiter.length===0)U.push({code:"ambiguous-heredoc-delimiter",message:"heredoc delimiter cannot be determined safely",span:x.span});H.push({delimiter:x.delimiter,quotedDelimiter:x.quoted,stripTabs:F==="<<-",declarationSpan:{start:R,end:V1},attach:(m)=>{T.heredoc=m}})}else if(!d)U.push({code:"missing-redirection-target",message:`redirection ${F} requires a target word`,span:{start:Z,end:Z+F.length}});if(d)G.nested.push(...d.nested);G.end=V1,Z=V1;continue}if(G.start===-1)eJ(q,U,Z);let b=$Q($,Z,Q,W,X,Y,K);if(U.push(...b.issues),b.limited)return N9(q,U,b.next);let I=uF(G.words)?dF($,b.word,Y.max-Y.used,X.maxDepth,X.maxInputLength):void 0;if(I?.limitCode)return Q4(q,U,b.next,I.limitCode,I.limitCode==="word-limit"?X.maxWords:I.limitCode==="depth-limit"?X.maxDepth:X.maxInputLength);let A=I?.words??[b.word];for(let E of A){if(!tJ(Y))return Q4(q,U,b.next,"word-limit",X.maxWords);G.words.push(E)}G.start=G.start===-1?Z:G.start,G.end=b.next,G.nested.push(...b.nested),Z=b.next>Z?b.next:Z+1}return L(),Uq(q,U),U.push(...sF(H)),{nodes:q,issues:U,next:Z,closed:B===void 0,limited:!1,pendingHeredocs:[]}}function Kq($,J,Q,W){return{kind:"program",dialect:J,source:$.slice(Q.start,Q.end),span:Q,status:D9(W.issues,W.limited),issues:W.issues,nodes:W.nodes}}function $Q($,J,Q,W,X,Y,K){let B="",q=J,U=!1,G="literal",H=[],L=[],Z=!1;while(q<Q){let M=$[q],O=(M==="<"||M===">")&&$[q+1]==="(";if(!M||_9(M)||(M===";"||M==="|"||M==="&")&&V9($,q)||(M==="<"||M===">")&&!O)break;if(M===")")break;if(M==="'"){U=!0;let F=$.indexOf("'",q+1);if(F===-1||F>=Q){B+=$.slice(q+1,Q),L.push({code:"unclosed-single-quote",message:"single-quoted word is not closed",span:{start:q,end:Q}}),q=Q;break}B+=$.slice(q+1,F),q=F+1;continue}if(M==='"'){U=!0;let F=TF($,q,Q,W,X,Y,K);if(B+=F.text,H.push(...F.nested),L.push(...F.issues),Z||=F.limited,G=U3(G,F.provenance),q=F.next,Z)break;continue}if($.startsWith("$'",q)){U=!0;let F=fF($,q+2,Q);if(B+=F.text,L.push(...F.issues),!F.closed)L.push({code:"unclosed-ansi-c-quote",message:"ANSI-C quoted word is not closed",span:{start:q,end:Q}});q=F.next;continue}if(M==="\\"){let F=$[q+1];if(!F){L.push({code:"trailing-escape",message:"escape has no following character",span:{start:q,end:q+1}}),q++;break}if(F===`
37
- `){q+=2;continue}B+=F,q+=2;continue}let V=M==="$"||M==="<"||M===">"||M==="`"?JQ($,q,Q,W,X,Y,K):null;if(V){let F=Zq(V,H,L);if(Z||=F.limited,G=U3(G,F.provenance),q=F.next,Z)break;continue}if(M==="$"){let F=Oq($,q,Q,B,G);B=F.text,G=F.provenance,q=F.next;continue}if(M==="*"||M==="?"||M==="[")G=U3(G,"glob");B+=M,q++}return{word:J4($,J,q,B,G,U,G==="literal"?void 0:hF($,J,q)),nested:H,issues:L,next:q,limited:Z}}function TF($,J,Q,W,X,Y,K){let B="",q="literal",U=[],G=[],H=!1,L=J+1;while(L<Q){let Z=$[L];if(Z==='"')return{text:B,provenance:q,nested:U,issues:G,next:L+1,limited:H};if(Z==="\\"&&$[L+1]){let O=$[L+1]??"";if(O===`
38
- `){L+=2;continue}if(O==="\r"&&$[L+2]===`
39
- `){L+=3;continue}B+=["$","`",'"',"\\"].includes(O)?O:`\\${O}`,L+=2;continue}if($.startsWith("$((",L)){let O=QQ($,L+3,Q,"))"),V=O===-1?Q:O+2;if(B+=$.slice(L,V),O===-1)G.push({code:"unclosed-arithmetic",message:"$(( substitution is not closed",span:{start:L,end:V}});L=V;continue}let M=JQ($,L,Q,W,X,Y,K);if(M){let O=Zq(M,U,G);if(L=O.next,H||=O.limited,q=U3(q,O.provenance),H)return{text:B,provenance:q,nested:U,issues:G,next:L,limited:H};continue}if(Z==="$"){let O=Oq($,L,Q,B,q);B=O.text,q=O.provenance,L=O.next;continue}B+=Z??"",L++}return G.push({code:"unclosed-double-quote",message:"double-quoted word is not closed",span:{start:J,end:Q}}),{text:B,provenance:q,nested:U,issues:G,next:Q,limited:H}}function JQ($,J,Q,W,X,Y,K){let B=$.startsWith("$((",J),q=$.startsWith("$(",J)&&!B,U=($.startsWith("<(",J)||$.startsWith(">(",J))&&!0,G=$[J]==="`";if(!B&&!q&&!U&&!G)return null;let H=B?3:G?1:2,L=B?"))":G?"`":")",Z=QQ($,J+H,Q,L),M=Z===-1?Q:Z,O=Z===-1?Q:Z+L.length;if(K>=X.maxDepth)return{program:oF($,J+H,M,W,"depth-limit"),next:O,provenance:B?"arithmetic":"command-substitution"};if(B){let I=[],A=[],E=!1,_=J+H;while(_<M){let R=JQ($,_,M,W,X,Y,K+1);if(!R){_++;continue}if(I.push(...R.program.nodes),A.push(...R.program.issues),E||=R.program.status==="limited",_=R.next,E)break}if(Z===-1)A.push({code:"unclosed-arithmetic",message:"$(( substitution is not closed",span:{start:J,end:O}});return{program:j1({kind:"program",dialect:W,source:$.slice(J+H,M),span:{start:J+H,end:M},status:D9(A,E),issues:A,nodes:I}),next:O,provenance:"arithmetic"}}let V=F9($,J+H,M,W,X,Y,K+1),F=Z===-1?[{code:B?"unclosed-arithmetic":"unclosed-command-substitution",message:`${$.slice(J,J+H)} substitution is not closed`,span:{start:J,end:O}}]:[],b=(G||U)&&G3(V.nodes)?[{code:"unsupported-heredoc-context",message:"heredocs are supported only in ordinary commands and $(...) substitutions",span:{start:J,end:O}}]:[];return{program:j1({kind:"program",dialect:W,source:$.slice(J+H,M),span:{start:J+H,end:M},status:D9([...V.issues,...F,...b],V.limited),issues:[...V.issues,...F,...b],nodes:V.nodes}),next:O,provenance:B?"arithmetic":"command-substitution"}}function Zq($,J,Q){return J.push($.program),Q.push(...$.program.issues),{provenance:$.provenance,next:$.next,limited:$.program.status==="limited"}}function QQ($,J,Q,W){if(W==="`"){for(let B=J;B<Q;B++)if($[B]==="\\")B++;else if($[B]==="`")return B;return-1}let X=1,Y={single:!1,double:!1},K=[];for(let B=J;B<Q;B++){let q=$[B];if((q===`
40
- `||q==="\r")&&K.length>0){let G=q==="\r"&&$[B+1]===`
41
- `?B+2:B+1,H=aJ($,G,Q,K.splice(0));if(!H.terminated)return-1;B=H.next-1;continue}let U=Lq($,B,J,Q,Y);if(U!==null){B=U;continue}if(!Y.double&&$.startsWith("$((",B)){let G=wF($,B+3,Q);if(G===-1)return-1;B=G+1;continue}if(W===")"&&!Y.double&&q==="<"&&$[B+1]==="<"&&$[B+2]!=="<"){let G=$[B+2]==="-",H=B+(G?3:2);while(H<Q&&/[ \t]/.test($[H]??""))H++;let L=sJ($,H,Q);if(L){K.push({delimiter:L.delimiter,quotedDelimiter:L.quoted,stripTabs:G,declarationSpan:{start:B,end:L.next},attach:()=>{return}}),B=L.next-1;continue}}if($.startsWith("$(",B)&&!$.startsWith("$((",B)){X++,B++;continue}if(q==="("&&!Y.double)X++;if(q===")"&&!Y.double){if(X--,X===0)return W==="))"&&$[B+1]!==")"?-1:B}}return-1}function wF($,J,Q){let W=1,X={single:!1,double:!1};for(let Y=J;Y<Q;Y++){let K=$[Y],B=Lq($,Y,J,Q,X);if(B!==null){Y=B;continue}if($.startsWith("$(",Y)&&!$.startsWith("$((",Y)){W++,Y++;continue}if(K==="("&&!X.double)W++;if(K!==")"||X.double)continue;if(W--,W===0)return $[Y+1]===")"?Y:-1}return-1}function Lq($,J,Q,W,X){let Y=$[J];if(Y==="\\"&&!X.single)return J+1;if(!X.double&&Y==="'")X.single=!X.single;if(!X.single&&Y==='"')X.double=!X.double;if(X.single)return J;if(X.double||Y!=="#"||!aF($,J,Q))return null;let K=J;while(K+1<W&&$[K+1]!==`
42
- `&&$[K+1]!=="\r")K++;return K}function V9($,J){let Q=$[J];if(Q===";")return";";if(Q==="&")return $[J+1]==="&"?"&&":"&";if(Q==="|")return $[J+1]==="|"?"||":$[J+1]==="&"?"|&":"|";return null}function vF($,J){let Q=$[J];if(Q===">"){if($[J+1]===">")return">>";if($[J+1]==="&")return">&";return $[J+1]==="|"?">|":">"}if(Q!=="<")return null;if($.startsWith("<<<",J))return"<<<";if($.startsWith("<<-",J))return"<<-";if($[J+1]==="<")return"<<";if($[J+1]==="&")return"<&";if($[J+1]===">")return"<>";return"<"}function _9($){let J=$.charCodeAt(0);if(J===32||J>=9&&J<=13)return!0;if(J<128)return!1;return/\s/u.test($)}function Mq($,J,Q){if($[J+1]==="{"){let X=$.indexOf("}",J+2);return X===-1||X>=Q?Q:X+1}let W=J+1;while(W<Q&&/[A-Za-z0-9_?@#$!*-]/.test($[W]??""))W++;return W===J+1?J+1:W}function fF($,J,Q){let W="",X=[],Y=J;while(Y<Q){let K=$[Y];if(K==="'")return{text:W,next:Y+1,closed:!0,issues:X};if(K!=="\\"){W+=K??"",Y++;continue}let B=kF($,Y+1,Q);if(W+=B.text,B.invalidCodePoint!==void 0)X.push({code:"invalid-ansi-c-code-point",message:`ANSI-C escape is not a valid Unicode scalar value: ${B.invalidCodePoint}`,span:{start:Y,end:B.next}});Y=B.next}return{text:W,next:Q,closed:!1,issues:X}}function kF($,J,Q){let W=$[J];if(!W||J>=Q)return{text:"\\",next:J};let X=new Map([["a","\x07"],["b","\b"],["e","\x1B"],["E","\x1B"],["f","\f"],["n",`
43
- `],["r","\r"],["t","\t"],["v","\v"],["\\","\\"],["'","'"],['"','"']]);if(X.has(W))return{text:X.get(W)??W,next:J+1};if(W==="x")return O9($,J+1,Q,16,2,J+1);if(W==="u")return O9($,J+1,Q,16,4,J+1);if(W==="U")return O9($,J+1,Q,16,8,J+1);if(/[0-7]/.test(W))return O9($,J,Q,8,3,J+1);return{text:W,next:J+1}}function O9($,J,Q,W,X,Y){let K=W===16?/[0-9a-fA-F]/:/[0-7]/,B="",q=J;while(q<Q&&B.length<X&&K.test($[q]??""))B+=$[q],q++;if(!B)return{text:$[Y-1]??"",next:Y};let U=Number.parseInt(B,W);return U>1114111||U>=55296&&U<=57343?{text:"�",next:q,invalidCodePoint:U}:{text:String.fromCodePoint(U),next:q}}function D9($,J=!1){if(J)return"limited";if($.some((Q)=>Q.code==="invalid-ansi-c-code-point"||Q.code==="missing-heredoc-delimiter"||Q.code==="ambiguous-heredoc-delimiter"||Q.code==="unterminated-heredoc"||Q.code==="unsupported-heredoc-context"))return"invalid";return $.length>0?"partial":"complete"}function Oq($,J,Q,W,X){let Y=Mq($,J,Q);return{text:W+$.slice(J,Y),provenance:U3(X,"variable"),next:Y}}function hF($,J,Q){let W=M9($),X=J,Y=!1,K=!1,B=J;while(B<Q){let q=$[B];if(q==="\\"&&!Y){B+=2;continue}if(!K&&q==="'"){Y=!Y,B++;continue}if(!Y&&q==='"'){K=!K,B++;continue}if(Y){B++;continue}let U=$.startsWith("$((",B),G=$.startsWith("$(",B)&&!U,H=!K&&($.startsWith("<(",B)||$.startsWith(">(",B)),L=q==="`";if(U||G||H||L){let Z=U?3:L?1:2,M=U?"))":L?"`":")",O=QQ($,B+Z,Q,M),V=O===-1?Q:O+M.length;W.push(X,B,"literal"),W.push(B,V,U?"arithmetic":"command-substitution"),B=V,X=V;continue}if(q==="$"){let Z=Mq($,B,Q);if(Z>B+1){W.push(X,B,"literal"),W.push(B,Z,"variable"),B=Z,X=Z;continue}}if(!K&&(q==="*"||q==="?"||q==="[")){W.push(X,B,"literal"),W.push(B,B+1,"glob"),B++,X=B;continue}B++}return W.push(X,Q,"literal"),W.parts}function U3($,J){if(J==="command-substitution"||$==="command-substitution")return"command-substitution";if(J==="arithmetic"||$==="arithmetic")return"arithmetic";if(J==="variable"||$==="variable")return"variable";if(J==="glob"||$==="glob")return"glob";return $}function yF($,J,Q){return J+1>=Q||_9($[J+1]??"")||V9($,J+1)!==null}var gF=new Set(["-u","--unset","-C","--chdir","-S","--split-string","-P"]),xF=new Set(["-u","-g","-C","-D","-h","-p","-r","-t","-T","-U"]);function uF($){let J=0;while(J<=$.length){while(/^[A-Za-z_][A-Za-z0-9_]*=/.test($[J]?.text??""))J++;if(J===$.length)return!0;let Q=mF($,J);if(Q===void 0||Q===null)return!1;J=Q}return!1}function mF($,J){let Q=$[J]?.text.toLowerCase();if(Q==="command")return lF($,J);if(Q==="env")return pF($,J);if(Q==="sudo")return cF($,J);return}function lF($,J){if($[J+1]?.text==="-v")return null;for(let Q=J+1;Q<$.length;Q++){let W=$[Q]?.text??"";if(W==="--")return Q+1;if(W==="-p"||W==="-v"||W==="-V"||/^-[pvV]+$/.test(W))continue;return Q}return $.length}function pF($,J){for(let Q=J+1;Q<$.length;Q++){let W=$[Q]?.text??"";if(W==="--")return Q+1;if(gF.has(W)){if($[Q+1]===void 0)return null;Q++;continue}if(W.startsWith("-u=")||W.startsWith("--unset=")||W.startsWith("-C")&&W.length>2||W.startsWith("--chdir=")||W.startsWith("-S")&&W.length>2||W.startsWith("--split-string=")||W.startsWith("-P"))continue;if(W.startsWith("-")||/^[A-Za-z_][A-Za-z0-9_]*=/.test(W))continue;return Q}return $.length}function cF($,J){for(let Q=J+1;Q<$.length;Q++){let W=$[Q]?.text??"";if(W==="--")return Q+1;if(xF.has(W)){if($[Q+1]===void 0)return null;Q++;continue}if(W.startsWith("-"))continue;return Q}return $.length}function Nq($,J,Q,W){if($.provenance!=="literal"||!$.raw.includes("{"))return;let X=[$.raw],Y=$.raw.length,K=0;while(!0){let q=X.findIndex((M)=>qq(M));if(q===-1)break;if(++K>Q)return{limited:!0};let U=X[q]??"",G=qq(U);if(!G||G.kind==="range")return{limited:!0};let H=G.start+U.length-G.end,L=G.alternatives.reduce((M,O)=>M+H+O.length,0);if(Y-U.length+L>W||X.length-1+G.alternatives.length>J)return{limited:!0};let Z=Fq(U,G);X.splice(q,1,...Z),Y+=L-U.length}if(K===0)return;let B=X.map((q)=>iF(q,Q));if(B.some((q)=>q===null))return{limited:!0};return{words:[...new Set(B.filter((q)=>q!==null&&q!==""))]}}function dF($,J,Q,W,X){if(J.provenance!=="literal"||J.quoted||J.raw!==J.text||!J.raw.includes("{"))return;let Y=[J.text],K=J.text.length,B=0;while(!0){let U=Y.findIndex((V)=>Bq(V));if(U===-1)break;if(++B>W)return{limitCode:"depth-limit"};let G=Y[U]??"",H=Bq(G);if(!H)break;let L=H.start+G.length-H.end,Z=H.alternatives.filter((V)=>L+V.length>0),M=Z.reduce((V,F)=>V+L+F.length,0);if(K-G.length+M>X)return{limitCode:"brace-expansion-limit"};if(Y.length-1+Z.length>Q)return{limitCode:"word-limit"};let O=Fq(G,{...H,alternatives:Z});Y.splice(U,1,...O),K+=M-G.length}let q=Y.filter((U)=>U.length>0);if(B===0)return;return{words:q.map((U)=>J4($,J.span.start,J.span.end,U,"literal",!1))}}function Bq($){let J=[],Q;for(let W=0;W<$.length;W++){let X=$[W];if(X==="{"){J.push({start:W,commas:[]});continue}if(X===","&&J.length>0){J.at(-1)?.commas.push(W);continue}if(X!=="}"||J.length===0)continue;let Y=J.pop();if(!Y||Y.commas.length===0)continue;if(!Q||Y.start<Q.start)Q={start:Y.start,end:W+1,commas:Y.commas}}if(!Q)return;return{start:Q.start,end:Q.end,alternatives:Vq($,Q)}}function qq($){let J=[],Q,W=null,X=!1;for(let Y=0;Y<$.length;Y++){let K=$[Y];if(X){X=!1;continue}if(K==="\\"&&W!=="'"){X=!0;continue}if(K===W){W=null;continue}if(W===null&&(K==="'"||K==='"')){W=K;continue}if(W!==null)continue;if(K==="{"){J.push({start:Y,commas:[]});continue}if(K===","&&J.length>0){J.at(-1)?.commas.push(Y);continue}if(K!=="}"||J.length===0)continue;let B=J.pop();if(!B)continue;let q=B.commas.length>0?{kind:"alternatives",start:B.start,end:Y+1,commas:B.commas}:rF($.slice(B.start+1,Y))?{kind:"range",start:B.start,end:Y+1}:void 0;if(q&&(!Q||q.start<Q.start))Q=q}if(!Q||Q.kind==="range")return Q;return{kind:Q.kind,start:Q.start,end:Q.end,alternatives:Vq($,Q)}}function Fq($,J){return J.alternatives.map((Q)=>`${$.slice(0,J.start)}${Q}${$.slice(J.end)}`)}function Vq($,J){let Q=[J.start,...J.commas,J.end-1];return Q.slice(0,-1).map((W,X)=>$.slice(W+1,Q[X+1]))}function rF($){return/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test($)||/^[A-Za-z]\.\.[A-Za-z](?:\.\.-?\d+)?$/.test($)}function iF($,J){let Q=`x${$}`,W=$Q(Q,0,Q.length,"posix",{maxInputLength:Q.length,maxWords:1,maxDepth:J},{used:0,max:1},0);if(W.limited||W.issues.length>0||W.next!==Q.length||W.word.provenance!=="literal")return null;return W.word.text.slice(1)}function oF($,J,Q,W,X){return j1({kind:"program",dialect:W,source:$.slice(J,Q),span:{start:J,end:Q},status:"limited",issues:[{code:X,message:"command structure exceeds parser limit",span:{start:J,end:Q}}],nodes:[]})}function Q4($,J,Q,W,X){return{nodes:$,issues:[...J,{code:W,message:`command structure exceeds parser limit ${X}`,span:{start:Q,end:Q}}],next:Q,closed:!1,limited:!0,pendingHeredocs:[]}}function N9($,J,Q){return{nodes:$,issues:J,next:Q,closed:!1,limited:!0,pendingHeredocs:[]}}function tJ($){return $.used++,$.used<=$.max}function nF($,J,Q){let W=/^([A-Za-z_][A-Za-z0-9_]*)[ \t]*\([ \t]*\)[ \t]*\{/.exec($.slice(J,Q)),X=W?.[1];if(!W||!X)return;return{name:X,braceIndex:J+W[0].lastIndexOf("{")}}function G3($){return $.some((J)=>{if(J.kind==="command")return J.redirections.some((Q)=>Q.heredoc)||J.nested.some((Q)=>G3(Q.nodes));return(J.kind==="group"||J.kind==="function")&&G3(J.body.nodes)})}function sF($){return $.map((J)=>({code:"unterminated-heredoc",message:`heredoc delimiter ${J.delimiter} was not found`,span:J.declarationSpan}))}function _q($){return $?.kind==="command"||$?.kind==="group"||$?.kind==="function"}function Uq($,J){let Q=$.at(-1);if(Q?.kind!=="connector"||!Gq.has(Q.operator))return;J.push({code:"missing-command-after-connector",message:`connector ${Q.operator} requires a following command`,span:Q.span})}function eJ($,J,Q){if(!_q($.at(-1)))return;J.push({code:"missing-command-connector",message:"adjacent commands require a connector",span:{start:Q,end:Q+1}})}function aF($,J,Q){return J===Q||/[\s;&|()]/u.test($[J-1]??"")}var Dq=new Set(["remove-item","ri","del","erase","rd","rmdir"]),zq=["-rec","-for","-path","-literalpath","-whatif"],z9={maxInputLength:131072,maxWords:16384,maxDepth:64};function Iq($){let J=$.toLowerCase().replaceAll("`","");if(![...Dq].some((W)=>J.includes(W))&&!(J.includes("rm")&&zq.some((W)=>J.includes(W)))&&!J.includes("<#"))return!1;let Q=JV($);return Q.invalidComment||Q.commands.some(tF)}function tF($){let J=$[0]==="&"||$[0]==="."?1:0,Q=$[J]?.toLowerCase();if(Q&&Dq.has(Q))return!0;if(Q!=="rm")return!1;return $.slice(J+1).some((W)=>{let X=W.toLowerCase().split(":",1)[0]??"";return zq.some((Y)=>X.startsWith(Y))})}function jq($,J){let Q={start:0,end:$.length};if($.length>J.maxInputLength)return j1({kind:"program",dialect:"powershell",source:$,span:Q,status:"limited",issues:[{code:"input-limit",message:`command exceeds ${J.maxInputLength} UTF-16 code units`,span:Q}],nodes:[]});let W=BQ($,0,$.length,J,0);return j1({kind:"program",dialect:"powershell",source:$,span:Q,status:QV(W.issues,W.limited),issues:W.issues,nodes:W.nodes})}function BQ($,J,Q,W,X,Y=!1){let K=G9(),B=H9(),q=Z9(),U=0,G=!1,H=()=>{if(q.words.length===0&&q.redirections.length===0)return;let Z={start:q.start,end:q.end};L9(K,q,{kind:"command",dialect:"powershell",source:$.slice(Z.start,Z.end),span:Z,words:q.words,redirections:q.redirections,nested:q.nested,dynamicExecutable:q.words[0]?.provenance!=="literal",displayText:q.words.map((M)=>M.text).join(" ")})},L=J;while(L<Q){let Z=$[L];if(!Z)break;if(Y&&Z==="}")return H(),{nodes:K,issues:B,next:L+1,closed:!0,words:U,limited:G};let M=Pq($,L,Q,W.maxDepth);if(M){if(M.issue)B.push(M.issue);if(M.limited)return H(),{nodes:K,issues:B,next:M.next,closed:!1,words:U,limited:!0};L=M.next;continue}if(/\s/.test(Z)){if(Z==="\r"||Z===`
44
- `){H();let F=Z==="\r"&&$[L+1]===`
45
- `?L+2:L+1;K.push(WQ($,L,F)),L=F;continue}L++;continue}let O=qQ($,L);if(O){H(),K.push(WQ($,L,L+O.length)),L+=O.length;continue}if(Z==="{"){if(H(),X>=W.maxDepth)return B.push(bq(L,W.maxDepth)),{nodes:K,issues:B,next:Q,closed:!1,words:U,limited:!0};let F=BQ($,L+1,Q,W,X+1,!0),b=F.closed?F.next-1:F.next,I=j1({kind:"program",dialect:"powershell",source:$.slice(L+1,b),span:{start:L+1,end:b},status:F.limited?"limited":F.issues.length>0?"partial":"complete",issues:F.issues,nodes:F.nodes});if(K.push(Object.freeze({kind:"group",style:"brace",span:Object.freeze({start:L,end:F.next}),body:I})),B.push(...F.issues),!F.closed)B.push({code:"unclosed-script-block",message:"PowerShell script block is not closed",span:{start:L,end:F.next}});U+=F.words,G||=F.limited,L=F.next;continue}if(Z==="}"){H(),K.push(WQ($,L,L+1)),L++;continue}if(Z===">"||Z==="<"){q.start=q.start===-1?L:q.start;let F=$[L+1]===Z?L+2:L+1,b=F;while(/[ \t]/.test($[b]??""))b++;let I=b<Q?XQ($,b,Q,W,X):void 0,A=I?.next??F;if(q.redirections.push(Object.freeze({kind:"redirection",operator:$.slice(L,F),span:Object.freeze({start:L,end:A}),...I?{target:I.word}:{}})),I)B.push(...I.issues),q.nested.push(...I.nested),U+=I.words,G||=I.limited;q.end=A,L=A;continue}if(Z===","){q.start=q.start===-1?L:q.start,q.words.push(nJ({text:",",raw:",",span:{start:L,end:L+1},provenance:"literal",quoted:!1})),q.end=++L;continue}let V=XQ($,L,Q,W,X);if(q.start=q.start===-1?L:q.start,q.end=V.next,q.words.push(V.word),B.push(...V.issues),q.nested.push(...V.nested),U+=1+V.words,G||=V.limited,U>W.maxWords)return B.push({code:"word-limit",message:`command exceeds ${W.maxWords} words`,span:{start:L,end:V.next}}),H(),{nodes:K,issues:B,next:V.next,closed:!1,words:U,limited:!0};L=V.next>L?V.next:L+1}return H(),{nodes:K,issues:B,next:L,closed:!Y,words:U,limited:G}}function XQ($,J,Q,W,X){let Y="",K="literal",B=!1,q=[],U=[],G=0,H=!1,L=(M)=>{let O=eF($,M,Q,W,X);return Y+=$.slice(M,O.next),U.push(O.program),q.push(...O.program.issues),G+=YQ(O.program),H||=O.program.status==="limited",K="command-substitution",O.next},Z=J;while(Z<Q){let M=$[Z];if(!M||/\s/.test(M)||qQ($,Z)||M===">"||M==="<"||M==="#")break;if(M===",")break;if(M==="`"){let O=$[Z+1];if(!O){q.push({code:"trailing-escape",message:"PowerShell escape has no following character",span:{start:Z,end:Z+1}}),Z++;break}Y+=O,Z+=2;continue}if($.startsWith("$(",Z)){Z=L(Z);continue}if(M==="'"){B=!0,Z++;let O=!1;while(Z<$.length){if($[Z]==="'"&&$[Z+1]==="'"){Y+="'",Z+=2;continue}if($[Z]==="'"){O=!0,Z++;break}Y+=$[Z]??"",Z++}if(!O)q.push({code:"unclosed-single-quote",message:"single-quoted word is not closed",span:{start:J,end:$.length}});continue}if(M==='"'){B=!0;let O=Z++,V=!1;while(Z<Q){let F=$[Z];if(F==="`"&&$[Z+1]){Y+=$[Z+1],Z+=2;continue}if(F==='"'){V=!0,Z++;break}if($.startsWith("$(",Z)){Z=L(Z);continue}if(F==="$")K=$[Z+1]==="("?"command-substitution":"variable";Y+=F??"",Z++}if(!V)q.push({code:"unclosed-double-quote",message:"double-quoted word is not closed",span:{start:O,end:$.length}});continue}if(M==="$")K=$[Z+1]==="("?"command-substitution":"variable";if(M==="@"&&Z===J)K="variable";Y+=M,Z++}return{word:J4($,J,Z,Y,K,B,K==="literal"?void 0:$V($,J,Z)),next:Z,issues:q,nested:U,words:G,limited:H}}function eF($,J,Q,W,X){let Y=Rq($,J+2,Q),K=Y===-1?Q:Y,B=Y===-1?Q:Y+1;if(X>=W.maxDepth)return{program:j1({kind:"program",dialect:"powershell",source:$.slice(J+2,K),span:{start:J+2,end:K},status:"limited",issues:[bq(J,W.maxDepth)],nodes:[]}),next:B};let q=BQ($,J+2,K,W,X+1),U=Y===-1?[{code:"unclosed-command-subexpression",message:"PowerShell command subexpression is not closed",span:{start:J,end:B}}]:[];return{program:j1({kind:"program",dialect:"powershell",source:$.slice(J+2,K),span:{start:J+2,end:K},status:q.limited?"limited":q.issues.length+U.length>0?"partial":"complete",issues:[...q.issues,...U],nodes:q.nodes}),next:B}}function Rq($,J,Q){let W=1,X=!1,Y=!1;for(let K=J;K<Q;K++){let B=$[K];if(B==="`"){K++;continue}if(!Y&&B==="'"){if(X&&$[K+1]==="'"){K++;continue}X=!X;continue}if(!X&&B==='"'){Y=!Y;continue}if(X)continue;if($.startsWith("$(",K)){W++,K++;continue}if(!Y&&B==="(")W++;if(B!==")")continue;if(W--,W===0)return K}return-1}function YQ($){let J=0;for(let Q of $.nodes){if(Q.kind==="group")J+=YQ(Q.body);if(Q.kind==="command"){J+=Q.words.length;for(let W of Q.nested)J+=YQ(W)}}return J}function $V($,J,Q){let W=M9($),X=J,Y=!1,K=J;while(K<Q){let B=$[K];if(B==="`"){K+=2;continue}if(B==="'"){if(Y&&$[K+1]==="'"){K+=2;continue}Y=!Y,K++;continue}if(Y){K++;continue}if($.startsWith("$(",K)){let q=Rq($,K+2,Q),U=q===-1?Q:q+1;W.push(X,K,"literal"),W.push(K,U,"command-substitution"),K=U,X=U;continue}if(B==="$"||B==="@"&&K===J){let q=K+1;if($[q]==="{"){let U=$.indexOf("}",q+1);q=U===-1||U>=Q?Q:U+1}else while(q<Q&&/[A-Za-z0-9_:?]/.test($[q]??""))q++;W.push(X,K,"literal"),W.push(K,q,"variable"),K=q,X=q;continue}K++}return W.push(X,Q,"literal"),W.parts}function bq($,J){return{code:"depth-limit",message:`command structure exceeds parser limit ${J}`,span:{start:$,end:$}}}function JV($){let J=[],Q=[],W=0,X=0,Y=!1,K=()=>{if(Q.length>0)J.push(Q);Q=[]};while(W<$.length&&W<131072&&X<16384){let B=$[W];if(B==="\r"||B===`
46
- `){K(),W+=B==="\r"&&$[W+1]===`
47
- `?2:1;continue}if(/\s/.test(B??"")){W++;continue}let q=Pq($,W,Math.min($.length,z9.maxInputLength),z9.maxDepth);if(q){Y||=!!q.issue||q.limited,W=q.next;continue}let U=qQ($,W);if(U){K(),W+=U.length;continue}if(B==="{"||B==="}"){K(),W++;continue}let G=XQ($,W,Math.min($.length,z9.maxInputLength),z9,0);if(G.word.text)Q.push(G.word.text);for(let H of G.nested)J.push(...KQ(H));X++,W=G.next>W?G.next:W+1}return K(),{commands:J,invalidComment:Y}}function KQ($){return $.nodes.flatMap((J)=>{if(J.kind==="group")return KQ(J.body);if(J.kind!=="command")return[];return[J.words.map((Q)=>Q.text),...J.nested.flatMap(KQ)]})}function qQ($,J){for(let Q of["&&","||",";","|"])if($.startsWith(Q,J))return Q;return null}function Pq($,J,Q,W){if($[J]==="#"&&$[J+1]!==">"){let K=J+1;while(K<Q&&$[K]!=="\r"&&$[K]!==`
48
- `)K++;return{next:K,limited:!1}}if(!$.startsWith("<#",J))return null;let X=1,Y=J+2;while(Y<Q){if($.startsWith("<#",Y)){if(X++,X>W)return{next:Q,issue:{code:"comment-depth-limit",message:`PowerShell block comment exceeds nesting limit ${W}`,span:{start:J,end:Y+2}},limited:!0};Y+=2;continue}if($.startsWith("#>",Y)){if(X--,Y+=2,X===0)return{next:Y,limited:!1};continue}Y++}return{next:Q,issue:{code:"unclosed-block-comment",message:"PowerShell block comment is not closed",span:{start:J,end:Q}},limited:!1}}function QV($,J){if(J)return"limited";if($.some((Q)=>Q.code==="unclosed-block-comment"))return"invalid";return $.length>0?"partial":"complete"}function WQ($,J,Q){return Object.freeze({kind:"connector",operator:$.slice(J,Q),span:Object.freeze({start:J,end:Q})})}var D2=Object.freeze({maxInputLength:131072,maxWords:16384,maxDepth:64});function e1($,J="auto",Q=D2){if(J==="powershell"||J==="auto"&&Iq($.slice(0,Q.maxInputLength)))return jq($,Q);return Hq($,"posix",Q)}function UQ($,J){if($!=="powershell")return J[0]?.provenance==="command-substitution";let Q=J[0]?.text==="&"||J[0]?.text==="."?1:0,W=J[Q]?.provenance;return W!==void 0&&W!=="literal"}var WV=/^[A-Za-z_][A-Za-z0-9_]*=/;function I9($,J){return $?.provenance==="literal"&&!$.quoted&&$.raw===J&&$.text===J}function j9($){let J=I9($.words[0],"time")?1:0,Q=J===1&&I9($.words[J],"-p")?J+1:J,W=J===1&&I9($.words[Q],"--")?Q+1:Q,X=I9($.words[W],"!")?W+1:W,Y=$.words.slice(X).find((K)=>!WV.test(K.text));return Y?.provenance==="literal"?Y.text:void 0}function H3($,J){if(J.escaped)return J.escaped=!1,!0;if($==="\\"&&!J.inSingle)return J.escaped=!0,!0;if($==="'"&&!J.inDouble)return J.inSingle=!J.inSingle,!0;if($==='"'&&!J.inSingle)return J.inDouble=!J.inDouble,!0;return!1}function W4($){let J={inSingle:!1,inDouble:!1,escaped:!1};for(let Q of XV($))H3(Q,J);return J.inSingle||J.inDouble}function XV($){let J="",Q={inSingle:!1,inDouble:!1,escaped:!1},W=!1,X=!0;for(let Y=0;Y<$.length;Y++){let K=$[Y];if(!K)break;if(W){if(K===`
49
- `||K==="\r")J+=K,W=!1,Q.escaped=!1;continue}if(K==="#"&&!Q.inSingle&&!Q.inDouble&&X){W=!0;continue}if(J+=K,!Q.inSingle&&!Q.inDouble&&!Q.escaped)X=/[\s;&|()<>]/.test(K);H3(K,Q)}return J}var YV=new Set(["&&","||","|&","|","&",";"]),KV=new Set(["<<","<<<",">|"]),BV=/[*@#?$!_-]/,GQ=Object.freeze([]),qV=Object.freeze([]),UV=256;function Tq($,J){let Q=J.status==="complete"?new Set(ZQ(J)):new Set,W=[...Q].reduce((K,B)=>K.slice(0,B.start)+" ".repeat(B.end-B.start)+K.slice(B.end),$);if(W4(W))return R9("unclosed-quote",W,GQ);let X={invalid:!1,limited:!1,expansions:0,assignmentFallbacks:[]},Y=Z3(J,{source:W,suppressed:Q,flags:X,depth:0,functions:new Map});if(X.limited)return R9("structural-limit",W,GQ);if(X.invalid)return R9("invalid",W,GQ);return R9("complete",W,Y,X.assignmentFallbacks)}function R9($,J,Q,W=qV){return Object.freeze({status:$,source:J,entries:Object.freeze(Q),assignmentFallbacks:Object.freeze(W)})}function Z3($,J){return $.nodes.flatMap((Q,W)=>GV(Q,$,W,J)).sort((Q,W)=>Q.start-W.start).flatMap((Q)=>[...Q.entries])}function GV($,J,Q,W){if($.kind==="connector")return[{start:$.span.start,entries:[$0(OV($.operator))]}];if($.kind==="unknown")return[{start:$.span.start,entries:[$0($.source)]}];if($.kind==="function")return W.functions.set($.name,$.body),[];if($.kind==="group"){let Y=$.style!=="subshell",K=W.source[$.span.end-1]===(Y?"}":")"),B=Y?W:{...W,functions:new Map(W.functions)};return[{start:$.span.start,entries:[Y?b9("{"):$0("("),...Z3($.body,B),...K?[Y?b9("}"):$0(")")]:[]]}]}let X=FV($,W.functions);if(X){if(W.depth>=D2.maxDepth||++W.flags.expansions>UV)return W.flags.limited=!0,[];return[{start:$.span.start,entries:[...Aq($,W),b9(";"),...Z3(X,{...W,depth:W.depth+1}),b9(";")]},...Eq($,J,Q,W)]}return[{start:$.span.start,entries:Aq($,W)},...Eq($,J,Q,W)]}function Aq($,J){return[...$.words.map((Q)=>({start:Q.span.start,entries:vq(Q,$,J,!1)})),...$.redirections.map((Q)=>({start:Q.span.start,entries:HV(Q,$,J)}))].sort((Q,W)=>Q.start-W.start).flatMap((Q)=>Q.entries)}function HV($,J,Q){let W=$.operator==="<<-"?"<<":$.operator,X=$.target?vq($.target,J,Q,!0):[],Y=X[0],K=Y?.kind==="word"?Y.text:void 0;return[...$.fd===void 0?[]:[LQ(String($.fd))],Object.freeze({kind:"redirection",operator:W,role:NV(W),targetOrder:KV.has(W)?"legacy-segment":"immediate",...K===void 0?{}:{target:K}}),...K===void 0?X:X.slice(1)]}function Eq($,J,Q,W){let X=$.redirections.filter((Y)=>Y.operator==="<<"||Y.operator==="<<-");return[...X.flatMap((Y)=>{let K=Y.heredoc;if(!K)return[];let B=[LQ(K.delimiter),.../[\r\n]/.test(W.source[K.terminatorSpan.end]??"")?[$0(";")]:[]];if(W.suppressed.has(K.bodySpan))return[{start:K.bodySpan.start,entries:B}];return[{start:K.bodySpan.start,entries:[...wq(W.source.slice(K.bodySpan.start,K.bodySpan.end),W),...B]}]}),...X.some((Y)=>!Y.heredoc&&Y.target)?ZV(J,Q,W):[]]}function ZV($,J,Q){let W=$.nodes.slice(J+1).find((X)=>X.kind==="connector");if(!W||W.span.end>=$.span.end)return[];return[{start:W.span.end,entries:wq(Q.source.slice(W.span.end,$.span.end),Q)}]}function wq($,J){if(J.depth>=D2.maxDepth)return J.flags.limited=!0,[];let Q=e1($,"posix");if(Q.status==="limited")return J.flags.limited=!0,[];let W={invalid:!1,limited:!1,expansions:J.flags.expansions,assignmentFallbacks:J.flags.assignmentFallbacks},X=Z3(Q,{source:$,suppressed:new Set,flags:W,depth:J.depth+1,functions:new Map});return J.flags.limited||=W.limited,J.flags.expansions=W.expansions,X}function vq($,J,Q,W){let X=[],Y={single:!1,double:!1},K="",B=!1,q=()=>{if(B&&!W)X.push($0("glob"));else if(K!==""||$.quoted&&X.length===0)X.push(LQ(K));K="",B=!1};for(let U of $.parts){if(U.provenance!=="command-substitution"&&U.provenance!=="arithmetic"){for(let Z of HQ(U.raw,Y,Q.flags)){if(typeof Z==="string"){q(),X.push($0(Z));continue}K+=Z.text,B||=Z.glob}continue}if(Y.double){let Z=Q.source.slice(U.span.start,U.span.end);K+=HQ(Z,{single:!1,double:!0},Q.flags).map((M)=>typeof M==="string"?M:M.text).join("");continue}let G=J.nested.find((Z)=>Z.span.start>=U.span.start&&Z.span.end<=U.span.end),H=G?Z3(G,Q):[];if(U.raw.startsWith("`")){K+="${}",q(),X.push(...H);continue}if(U.raw.startsWith("<(")||U.raw.startsWith(">(")){q(),X.push(U.raw.startsWith("<(")?$0("<("):Object.freeze({kind:"redirection",operator:">",role:"file-write",targetOrder:"immediate"}),...H,...U.raw.endsWith(")")?[$0(")")]:[]);continue}let L=U.raw.startsWith("$((")?2:1;K+="${}",q(),X.push(...Array.from({length:L},()=>$0("(")),...H,...U.raw.endsWith(")".repeat(L))?Array.from({length:L},()=>$0(")")):[])}return q(),X}function HQ($,J,Q){let W=[],X="",Y=!1,K=0;while(K<$.length){let B=$[K]??"";if(!J.single&&!J.double&&(B==="("||B===")")){W.push({text:X,glob:Y},B),X="",Y=!1,K++;continue}if(J.single){if(B==="'")J.single=!1;else X+=B;K++;continue}if(J.double){if(B==='"'){J.double=!1,K++;continue}if(B==="\\"){let q=$[K+1]??"";X+=['"',"\\","$"].includes(q)?q:`\\${q}`,K+=2;continue}if(B==="$"){let q=Cq($,K,J,Q);X+=q.text,K=q.next;continue}X+=B,K++;continue}if(B==="'"||B==='"'){J.single=B==="'",J.double=B==='"',K++;continue}if(B==="\\"){let q=$[K+1]??"";Y||=q==="*"||q==="?",X+=q,K+=2;continue}if(B==="$"){let q=Cq($,K,J,Q);X+=q.text,K=q.next;continue}Y||=B==="*"||B==="?",X+=B,K++}return[...W,{text:X,glob:Y}]}function Cq($,J,Q,W){let X=$[J+1];if(X==="{"){let K=MV($,J+2);if(K===-1)return W.invalid=!0,{text:"",next:$.length};let B=$.slice(J,K+1);return LV(B,Q,W),{text:B,next:K+1}}if(X!==void 0&&BV.test(X))return{text:`\${${X}}`,next:J+2};let Y=/^\w*/.exec($.slice(J+1))?.[0]??"";return{text:`\${${Y}}`,next:J+1+Y.length}}function LV($,J,Q){let W=$.slice(2,-1),X=/^[A-Za-z_][A-Za-z0-9_]*/.exec(W)?.[0];if(!X)return;let Y=W.slice(X.length),K=[":=","="].find((q)=>Y.startsWith(q));if(!K)return;let B=HQ(Y.slice(K.length),{...J},Q);Q.assignmentFallbacks.push(...B.flatMap((q)=>typeof q==="string"||!q.text?[]:[q.text]))}function MV($,J){let Q=1,W=J;while(Q>0&&W<$.length){if($[W]==="{"&&$[W-1]==="$")Q++;else if($[W]==="}")Q--;W++}return Q===0?W-1:-1}function OV($){return/^[\r\n]+$/.test($)?";":$}function $0($){return Object.freeze({kind:"operator",operator:$,boundary:YV.has($)})}function b9($){return Object.freeze({kind:"operator",operator:$,boundary:!0})}function LQ($){return Object.freeze({kind:"word",text:$})}function NV($){if($==="<<"||$==="<<<")return"here-data";if($==="<"||$==="<&")return"file-read";return"file-write"}function ZQ($){return $.nodes.flatMap((J,Q)=>{if(J.kind==="group"||J.kind==="function")return ZQ(J.body);if(J.kind!=="command")return[];let W=J.nested.flatMap((K)=>ZQ(K)),X=$.nodes[Q+1];if(X?.kind==="connector"&&(X.operator==="|"||X.operator==="|&")||!_V(J))return W;return[...W,...J.redirections.flatMap((K)=>K.heredoc?.quotedDelimiter?[K.heredoc.bodySpan]:[])]})}function FV($,J){let Q=j9($);return Q===void 0?void 0:J.get(Q)}function o0($,J){return $!==void 0&&$.provenance==="literal"&&!$.quoted&&$.raw===$.text&&$.text===J}function VV($){if(o0($.words[0],"git"))return o0($.words[1],"commit");if(!o0($.words[0],"gh")||!o0($.words[2],"create"))return!1;return o0($.words[1],"pr")||o0($.words[1],"issue")}function _V($){return(o0($.words[0],"cat")||o0($.words[0],"tee")||VV($))&&!$.words.some(Sq)&&!$.redirections.some((Q)=>Sq(Q.target))}function Sq($){return $?.parts.some((J)=>J.provenance==="command-substitution"&&J.raw.startsWith(">("))??!1}import{types as DV}from"node:util";var zV=new Set(["find","findbyname","glob","grep","grepsearch","listdir","listpermissions","ls","read","readfile","readurlcontent","searchweb","view","viewfile"]),IV=new Set(["command","diff","input","patch","patchtext"]),fq=new TextEncoder,jV=new TextDecoder,RV=/\s/,bV=64;class k0 extends Error{name="ToolInputLimitError";constructor(){super("tool input traversal limit exceeded")}}var L3=Object.freeze({maxDepth:64,maxNodes:1e4,maxKeys:1e4,maxStringBytes:1048576,maxAggregateStringBytes:4194304});function PV($){return $.replace(/[-_\s]/g,"").toLowerCase()}function A9($){return zV.has(PV($))}function X4($){if(!$||typeof $!=="object")return;pq($);let J=Object.getOwnPropertyDescriptor($,"command");if(!J){if("command"in $)Z0();return}if(J.get||J.set)Z0();let Q=J.value;return typeof Q==="string"&&Q!==""?Q:void 0}function FQ($,J){return xq($,J,{nodes:0,keys:0,stringBytes:0,ancestors:new Set},1)}function xq($,J,Q,W){let X=lq($,Q,W);if(!X)return[];let Y=X.entries.flatMap(([K,B])=>{let q=xq(B,J,Q,W+1);return typeof B==="string"&&J.has(uq(K))?[B]:q});return Q.ancestors.delete(X.object),Y}function uq($){return $.replace(/-/g,"_").toLowerCase()}function VQ($){return mq($,!0,{nodes:0,keys:0,stringBytes:0,ancestors:new Set},1).flatMap(EV)}function mq($,J,Q,W){let X=lq($,Q,W);if(typeof $==="string")return J?[$]:[];if(!X)return[];let Y=X.entries.flatMap(([K,B])=>mq(B,X.array?J:IV.has(uq(K)),Q,W+1));return Q.ancestors.delete(X.object),Y}function AV($,J,Q){if(J.nodes++,$!==null&&typeof $==="object"&&Q>L3.maxDepth||J.nodes>L3.maxNodes)Z0();if(typeof $!=="string")return;let W=Buffer.byteLength($);if(J.stringBytes+=W,W>L3.maxStringBytes||J.stringBytes>L3.maxAggregateStringBytes)Z0()}function lq($,J,Q){if(AV($,J,Q),!$||typeof $!=="object")return null;let W=pq($);if(J.ancestors.has($))Z0();let X=Reflect.ownKeys($);if(J.keys+=X.length,J.keys>L3.maxKeys)Z0();let Y=X.flatMap((K)=>{let B=Object.getOwnPropertyDescriptor($,K);if(!B||B.get||B.set)Z0();return typeof K==="string"&&B.enumerable?[[K,B.value]]:[]});return J.ancestors.add($),{object:$,array:W,entries:Y}}function pq($){if(DV.isProxy($))Z0();let J=Array.isArray($),Q=Object.getPrototypeOf($);if(J&&Q!==Array.prototype||!J&&Q!==Object.prototype&&Q!==null)Z0();return J}function Z0(){throw new k0}function EV($){let J=[],Q=$.split(/\r?\n/),W=!1,X=!1,Y=null,K=null,B=()=>{X=!1,Y=null,K=null};for(let q=0;q<Q.length;q++){let U=Q[q]??"";if(U==="*** Begin Patch"){W=!0,B();continue}if(U==="*** End Patch"){W=!1,B();continue}if(U.startsWith("@@")){let G=CV(U);if(X=!0,Y=G?.oldLines??null,K=G?.newLines??null,Y===0&&K===0)B();continue}if(X&&Y!==null&&K!==null){let G=U.startsWith(" ")||U.startsWith("-")?1:0,H=U.startsWith(" ")||U.startsWith("+")?1:0;if(Y=Math.max(0,Y-G),K=Math.max(0,K-H),Y===0&&K===0)B();continue}if(U.startsWith("*** ")){B(),J.push(...MQ(U));continue}if(X)continue;if(U.startsWith("diff --git ")){J.push(...MQ(U));continue}if(U.startsWith("--- ")){let G=Q[q+1]??"";if(!G.startsWith("+++ "))continue;J.push(...NQ(P9(U.slice(4),!0),P9(G.slice(4),!0))),q++;continue}if(!W)J.push(...MQ(U))}return J}function CV($){let J=/^@@ -\d+(?:,(\d+))? \+\d+(?:,(\d+))? @@/.exec($);if(!J)return null;return{oldLines:Number(J[1]??1),newLines:Number(J[2]??1)}}function MQ($){let J=/^\*\*\* (?:Add|Update|Delete) File: (.+)$/.exec($);if(J?.[1])return gq(J[1]);let Q=/^\*\*\* Move to: (.+)$/.exec($);if(Q?.[1])return gq(Q[1]);if($.startsWith("diff --git "))return SV($.slice(11));let W=/^--- (.+)$/.exec($);if(W?.[1])return yq(W[1]);let X=/^\+\+\+ (.+)$/.exec($);if(X?.[1])return yq(X[1]);let Y=/^(?:rename|copy) (?:from|to) (.+)$/.exec($);if(Y?.[1])return yV(Y[1]);return[]}function SV($){let J=TV($);if(J.length===2&&J[0]&&J[1])return NQ(J[0],J[1]);let Q=wV($);return Q?NQ($.slice(Q.oldStart,Q.oldEnd),$.slice(Q.newStart,Q.newEnd)):[]}function TV($){let J=[],Q=0;while(Q<$.length&&J.length<2){while(z2($[Q]))Q++;if(Q>=$.length)break;let W=$[Q]==='"'||$[Q]==="'"?$[Q]:void 0;if(!W){let Y=Q;while(Q<$.length&&!z2($[Q]))Q++;J.push($.slice(Y,Q));continue}let X=cq($,Q,W);if(!X)return[];J.push(X.value),Q=X.end}while(z2($[Q]))Q++;return Q===$.length?J:[]}function wV($){let J=0;while(J<$.length&&z2($[J]))J++;let Q=$.length;while(Q>J&&z2($[Q-1]))Q--;let W=0,X=J;while(X<Q){if(!z2($[X])){X++;continue}let Y=X;while(X<Q&&z2($[X]))X++;if(Y===J||X===Q)continue;if(W++,W>bV)Z0();if(vV($,J,Y,X,Q))return{oldStart:J,oldEnd:Y,newStart:X,newEnd:Q}}return null}function vV($,J,Q,W,X){if(OQ($,J,Q,W,X))return!0;let Y=kq($,"/",J,Q),K=kq($,"/",W,X);if(Y<=J||K<=W)return!1;if(OQ($,J,Y,W,K))return!1;return OQ($,Y+1,Q,K+1,X)}function OQ($,J,Q,W,X){if(Q-J!==X-W)return!1;for(let Y=0;Y<Q-J;Y++)if($[J+Y]!==$[W+Y])return!1;return!0}function kq($,J,Q,W){for(let X=Q;X<W;X++)if($[X]===J)return X;return-1}function z2($){return $!==void 0&&RV.test($)}function cq($,J,Q){let W=[],X=J+1;while(X<$.length){let Y=$[X]??"";if(Y===Q)return{value:jV.decode(Uint8Array.from(W)),end:X+1};if(Y!=="\\"||Q==="'"){W.push(...fq.encode(Y)),X++;continue}let K=$.slice(X+1),B=/^[0-7]{1,3}/.exec(K)?.[0];if(B){W.push(Number.parseInt(B,8)),X+=B.length+1;continue}W.push(...fq.encode(fV(K[0]??""))),X+=2}return null}function fV($){return{a:"\x07",b:"\b",f:"\f",n:`
50
- `,r:"\r",t:"\t",v:"\v"}[$]??$}function kV($){return M3(gV($))}function NQ($,J){if($==="/dev/null")return hq(J);if(J==="/dev/null")return hq($);if($.startsWith("a/")&&J.startsWith("b/"))return[$.slice(2),J.slice(2)].flatMap(M3);let Q=hV($,J)??($===J?dq($):null);return[$,J,...Q?[Q]:[]].flatMap(M3)}function hq($){let J=dq($);return[$,...J?[J]:[]].flatMap(M3)}function dq($){let J=$.indexOf("/");return J>0&&J<$.length-1?$.slice(J+1):null}function hV($,J){let Q=$.indexOf("/"),W=J.indexOf("/");if(Q<1||W<1)return null;if($.slice(0,Q)===J.slice(0,W))return null;let X=$.slice(Q+1);return X===J.slice(W+1)?X:null}function yq($){return kV(P9($,!0))}function yV($){return M3(P9($,!1))}function P9($,J){let Q=$.trim(),W=Q[0]==='"'||Q[0]==="'"?Q[0]:void 0;if(W){let X=cq(Q,0,W);if(X&&(J||Q.slice(X.end).trim()===""))return X.value}return J?Q.split("\t",1)[0]?.trim()??"":Q}function gV($){return $.startsWith("a/")||$.startsWith("b/")?$.slice(2):$}function M3($){return $===""||$==="/dev/null"?[]:[$]}function gq($){let J=$.split("\t",1)[0]?.trim().replace(/^['"]|['"]$/g,"")??"";return J===""||J==="/dev/null"?[]:[J]}var rq=new Set(["absolutepath","directorypath","directory_path","file","file_path","filepath","include","notebook_path","path","searchdirectory","search_directory","searchpath","targetfile","target_file"]),iq=new Set([...rq,"glob"]),xV=new Set([...iq,"pattern"]),uV=[],oq={parseCommand:e1,projectShellSyntax:Tq};class n0 extends Error{name="StructuralShellSyntaxLimitError";constructor(){super("Structural command analysis limit exceeded.")}}function E9($,J={}){let Q=mV({...oq,...J}),W=X4($.input),X=[];if(($.route.kind==="command"||$.route.kind==="unknown")&&W)X.push({usage:"input-candidate",source:W});if($.route.kind==="command"&&"command"in $&&$.command)X.push({usage:"declared-command",source:$.command});let Y=X.reduce((K,B)=>{let q=K.findIndex((H)=>H.source===B.source);if(q!==-1){let H=K[q];if(!H)return K;return K[q]={...H,usages:[...H.usages,B.usage]},K}let U=$.route.kind==="command"?$.route.shell:"posix",G=Q.getCommandProgram(B.source,U);return K.push({usages:[B.usage],source:B.source,program:G,views:_Q(G),uncertainties:G.issues,shell:Q.getShellSyntax(B.source,G)}),K},[]);return{invocation:{toolName:$.toolName,route:$.route,context:$.context},commands:Y,paths:lV($),store:Q}}function f1($,J){return $.commands.find((Q)=>Q.usages.includes(J))}function L0($){if(!$.includes("$"))return $;return g6($,T0())}function mV($={}){let J={...oq,...$},Q=new Map,W=new Map,X=new WeakMap,Y=(B,q)=>{let U=`${q}\x00${B}`,G=W.get(U);if(G)return G;let H=J.parseCommand(B,q);return W.set(U,H),H};return{getShellSyntax:(B,q)=>{if(q&&q.source!==B)throw TypeError("Shell syntax source does not match command program source.");let U=q??Y(B,"posix");if(U.status==="limited"){let L=X.get(U);if(L)return L;let Z={status:"structural-limit",source:B,entries:uV,assignmentFallbacks:[]};return X.set(U,Z),Z}let G=Q.get(B);if(G)return G;let H=J.projectShellSyntax(B,U);return Q.set(B,H),H},getCommandProgram:Y}}function _Q($){return $.nodes.flatMap((J)=>{if(J.kind==="group")return _Q(J.body);if(J.kind!=="command")return[];return[...J.nested.flatMap((Q)=>_Q(Q)),J]})}function lV($){let J=$.route.kind==="grep"?iq:$.route.kind==="glob"?xV:rq;return[...FQ($.input,J),...$.route.kind==="patch"?VQ($.input):[]]}function R1($,J){let Q=new Set,W=!1;for(let X of $){if(X==="--"){W=!0;continue}if(W)continue;if(X.startsWith("-")&&!X.startsWith("--")&&X.length>1)for(let Y=1;Y<X.length;Y++){let K=X[Y];if(!K||!/[a-zA-Z]/.test(K))break;let B=`-${K}`;if(Q.add(B),J?.shortOptsWithValue?.has(B))break}}return Q}var pV=new Map([["bash",new Set(["O","o"])],["dash",new Set(["o"])],["ksh",new Set(["o"])],["sh",new Set(["o"])],["zsh",new Set(["o"])]]),cV=new Map([["zsh",new Set(["o"])]]),dV=new Map([["bash",new Set(["--init-file","--rcfile"])]]);function nq($,J){for(let Q=0;Q<J.length;Q++){let W=J[Q];if(W===void 0||W==="--"||W==="-"||W[0]!=="-"&&W[0]!=="+")return null;if(W.startsWith("--")){let K=dV.get($);if(iV(W,K))continue;if(!K?.has(W))continue;if(J[Q+1]===void 0)return null;Q++;continue}let X=rV($,W);if(X.commandSelected)return J[Q+X.followingValues+1]??null;let Y=J[Q+1];if($==="ksh"&&(W==="-o"||W==="+o")&&Y!==void 0&&Y[0]!=="-"&&Y[0]!=="+")Q++;Q+=X.followingValues}return null}function rV($,J){let Q=pV.get($),W=cV.get($),X=!1,Y=0;for(let K=1;K<J.length;K++){let B=J[K];if(B===void 0)break;if(J[0]==="-"&&B==="c")X=!0;if($==="ksh"&&B==="o"){if(K+1<J.length){let q=J.slice(K+1);if(!X&&J[0]==="-"&&q==="c")continue;if(!X&&J[0]==="-"&&q[0]==="-"&&q.endsWith("c"))X=!0;break}if(X)Y++;continue}if(!Q?.has(B))continue;if(W?.has(B)&&K+1<J.length)break;Y++}return{commandSelected:X,followingValues:Y}}function iV($,J){return J!==void 0&&[...J].some((Q)=>$.startsWith(`${Q}=`))}var sV=new Set(["-S","--suffix"]);function C9($,J,Q,W){if($.status==="structural-limit")throw new n0;if($.status!=="complete")return W.findMalformedTarget($.source);let X={cwd:J,variables:new Map},Y=[];for(let K of $.entries){if(K.kind==="operator"){if(!K.boundary)continue;let B=W.findSegmentTarget(Y,X);if(B)return B;X=aV(Y,X,Q,W.normalizeCwd),Y=[];continue}if(K.kind==="redirection"){if(K.role==="file-write"&&K.target&&W.isRedirectionTarget(k1(K.target,X.variables),X))return K.target;continue}Y.push(K.text)}return W.findSegmentTarget(Y,X)}function k1($,J){return $.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)(:?[-+])([^}]*)\}/g,(Q,W,X,Y)=>{let K=J.get(W);if(K===void 0)return Q;let B=X.startsWith(":")?K!=="":!0;if(X.endsWith("-"))return B?K:k1(Y,J);return B?k1(Y,J):""}).replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g,(Q,W)=>J.get(W)??Q).replace(/\$([A-Za-z_][A-Za-z0-9_]*)/g,(Q,W)=>J.get(W)??Q)}function O3($){return $.length>0&&$.every((J)=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(J))}function O1($,J,Q){let W=Q.environment.home,X=g6($.trim(),Q.environment).replace(/\\/g,"/");if(!X)return"";let Y=X==="~"?W:X.startsWith("~/")?sq(W,X.slice(2)):X;return a(nV(oV(Y)?Y:sq(J,Y)),Q.environment.paths,Q).replace(/\\/g,"/")}function S9($){let J=[],Q=null,W=!1;for(let X=0;X<$.length;X++){let Y=$[X];if(Y===void 0)break;if(!W&&Y==="--"){W=!0;continue}if(!W&&(Y==="-t"||Y==="--target-directory")){Q=$[++X]??null;continue}if(!W&&Y.startsWith("--target-directory=")){Q=Y.slice(19);continue}if(!W&&Y.startsWith("-t")&&Y.length>2){Q=Y.slice(2);continue}if(!W&&sV.has(Y)){X++;continue}if(!W&&(Y.startsWith("--suffix=")||Y.startsWith("--backup=")))continue;if(!W&&Y.startsWith("-"))continue;J.push(Y)}return Q?{sources:J,destination:Q}:{sources:J.slice(0,-1),destination:J.at(-1)??null}}function aV($,J,Q,W){let X=O3($)?new Map([...J.variables,...tV($,J.variables)]):J.variables,Y=c1([...$],Q.environment),K=l(Y[0]??"").toLowerCase()==="cd"?Y[1]:void 0;return{cwd:!K||K==="-"?J.cwd:W(k1(K,X),J.cwd,Q),variables:X}}function tV($,J){return $.flatMap((Q)=>{let W=/^([A-Za-z_][A-Za-z0-9_]*)(.*)$/.exec(Q),X=W?.[2]?.startsWith("=")?W[2].slice(1):void 0;return W?.[1]!==void 0&&X!==void 0?[[W[1],k1(X,J)]]:[]})}var d1="Git metadata and hooks are protected. Ask the user before modifying them.";function $U($,J=zQ($.invocation.context.executionCwd)){let Q=L2(T0()),W=$.invocation.context.executionCwd;if(!J)return null;if($.invocation.route.kind==="patch"||$.invocation.route.kind==="path"||$.invocation.route.kind==="unknown"){if(A9($.invocation.toolName))return null;let K=$.paths.find((B)=>X_(B,W,J,Q));return K?{target:K}:null}if($.invocation.route.kind!=="command")return null;let X=f1($,"input-candidate");if(!X)return null;let Y=C9(X.shell,W,Q,{findSegmentTarget:(K,B)=>K_(K,B,J,Q),isRedirectionTarget:(K,B)=>Y_(K,B.cwd,J,Q),findMalformedTarget:()=>null,normalizeCwd:O1});return Y?{target:Y}:null}function zQ($,J=L2(T0())){if(typeof $!=="string"||!$)return null;let Q=J3(O1($,$,J));if(!Q)return null;try{let W=O1(Q,$,J),X=eV(Q),Y=X.isFile()?W:null,K=X.isFile()?mJ(Q):null,B=(X.isDirectory()?[W]:[K?.gitDir,K?.commonDir]).flatMap((U)=>U?[M0(O1(U,$,J))]:[]),q=[...new Set(X.isDirectory()?[M0(Q.replace(/\\/g,"/")),...B]:B)];return Object.freeze({entry:M0(W),markerFile:Y?M0(Y):null,directories:Object.freeze(q),hooksDirectories:Object.freeze([...new Set(q.flatMap((U)=>{let G=M0($_(U,"hooks"));return[G,M0(O1(G,$,J))]}))])})}catch{return null}}function I2($,J,Q,W,X,Y=!1){if(!Q)return!1;let K=M0(O1($,J,X)),B=K.replace(/(\/\.?\*+)+$/,"");if(B!==K&&B!==""){if(DQ(B,Q))return!0;let q=Y||K.slice(B.length).includes("/."),U=(G)=>q?T9(G,B):J_(G,B);if(Q.markerFile&&U(Q.markerFile))return!0;return W&&aq(Q).some(U)}if(DQ(K,Q))return!0;return W&&aq(Q).some((q)=>T9(q,K))}function J_($,J){let Q=eq(J,$);if(Q===""||Q.startsWith("..")||tq(Q))return!1;return!Q.split(/[\\/]/)[0]?.startsWith(".")}function Q_($,J,Q,W){return I2($,J,Q,!0,W)}function W_($,J,Q,W){if(!Q)return!1;return DQ(M0(O1($,J,W)),Q)}function X_($,J,Q,W){if(!Q)return!1;return JU($,J,Q,W,Q.entry)}function Y_($,J,Q,W){if(!Q)return!1;return JU($,J,Q,W,Q.markerFile)}function JU($,J,Q,W,X){let Y=M0(O1($,J,W));return Y===X||WU(Y,Q)}function QU($,J,Q,W){if(!Q)return!1;return Q.hooksDirectories.some((X)=>$.some((Y)=>T9(X,M0(O1(Y,J,W)))))}function DQ($,J){return $===J.entry||J.directories.includes($)||WU($,J)}function WU($,J){return J.hooksDirectories.some((Q)=>T9($,Q))}function aq($){return[$.entry,...$.directories,...$.hooksDirectories]}function T9($,J){let Q=eq(J,$);return Q===""||!/^\.\.(?:[\\/]|$)/.test(Q)&&!tq(Q)}function M0($){return process.platform==="win32"?$.toLowerCase():$}function K_($,J,Q,W){if(O3($))return null;let X=c1([...$],W.environment);if(l(X[0]??"").toLowerCase()!=="mv")return null;let Y=S9(X.slice(1)),K=Y.sources.find((B)=>Q_(k1(B,J.variables),J.cwd,Q,W));if(K)return K;return Y.destination&&W_(k1(Y.destination,J.variables),J.cwd,Q,W)?Y.destination:null}import{isAbsolute as IQ,join as B_,normalize as q_,sep as w9}from"node:path";var XU=process.platform==="win32",U_=/[*?]/;function N3($,J){if($==="~")return J;if($.startsWith("~/"))return`${J}${$.slice(1)}`;return $}function f9($,J){if(typeof $!=="string"||$.trim()==="")return"must be a non-empty path string";let Q=N3($.trim(),J);if(!IQ(Q))return"must be an absolute path or start with ~/";return F3(Q,J)}function k9($,J){let Q=YU($,J);if(Q===null)return"must be a non-empty path string";if(!IQ(Q))return null;if(F3(Q,J)===null)return null;return"cannot be the home directory or a path above it (this would block every command the agent runs)"}var G_="cannot cover the home directory or a path above it (this would disable secret protection everywhere)",H_="cannot cover the guard's own configuration";function YU($,J){if(typeof $!=="string"||$.trim()==="")return null;return N3($.trim().replace(/^\$(?:\{HOME\}|HOME(?=\/|$))/,"~"),J)}function h9($,J){let Q=YU($,J);if(Q===null)return"must be a non-empty path string";if(U_.test(Q))return"cannot contain glob characters (* or ?); list the exact file or directory";if(!IQ(Q))return null;if(F3(Q,J)!==null)return G_;return Z_(Q,J)?H_:null}function Z_($,J){let Q=v9($),W=v9(B_(J,".cc-safety-net"));return Q===W||Q.startsWith(`${W}${w9}`)}function F3($,J){let Q=v9($),W=v9(J);if(Q===W)return"cannot be the home directory";let X=Q.endsWith(w9)?Q:`${Q}${w9}`;if(W.startsWith(X))return"cannot contain the home directory";return null}function v9($){let J=q_($);if(XU)J=J.replace(/\//g,"\\").toLowerCase();if(J.length>(XU?3:1)&&J.endsWith(w9))J=J.slice(0,-1);return J}var O_=process.platform==="win32",KU=64,N_=16384;function V3($){let J=Nq($,KU,KU,N_);return{expandedTargets:J&&"words"in J?J.words:void 0,unsafeBraceExpansion:J!==void 0&&"limited"in J,targetIsLiteral:J===void 0&&$.provenance==="literal"&&($.quoted||$.raw!==$.text),tmpdirWordSplittingProtected:F_($)}}function F_($){let J=$.parts.filter((Q)=>Q.provenance==="variable"&&/\$(?:TMPDIR(?![A-Za-z0-9_])|\{TMPDIR\})/.test(Q.raw));return J.length>0&&J.every((Q)=>V_($.raw,Q.span.start-$.span.start))}function V_($,J){let Q=null,W=!1;for(let X=0;X<J;X++){let Y=$[X];if(W){W=!1;continue}if(Y==="\\"&&Q!=="'"){W=!0;continue}if(Q===Y){Q=null;continue}if(Q===null&&(Y==="'"||Y==='"'))Q=Y}return Q==='"'}function j2($){let J=$.environment.home,Q=$.environment.paths,W=L2($.environment);return{anchoredCwd:$.originalCwd??$.cwd??null,resolvedCwd:$.cwd??null,strict:$.strict??!1,paranoid:$.paranoid??!1,trustTmpdirVar:$.allowTmpdirVar??!0,posixShell:$.posixShell??!1,tmpdirWordSplittingUnsafe:$.tmpdirWordSplittingUnsafe??!1,trustedTmpdirValue:$.trustedTmpdirValue??$.allowTmpdirVar??!0,environment:$.environment,allowRoots:j_($.allowPaths,J,Q,W),protectedGitMetadata:$.protectedGitMetadata,pathCanonicalizationContext:W}}function J0($,J,Q={}){let W=Q.targetIsLiteral??!1;if(!W&&J.tmpdirWordSplittingUnsafe&&!Q.tmpdirWordSplittingProtected&&b_($))return{kind:"outside_anchored_cwd"};let X=!W&&GU($,J.posixShell);if(Z2($))return{kind:"outside_anchored_cwd"};if(PQ($,W))return{kind:"root_or_home_target"};if(__($,J,W))return{kind:"root_or_home_target"};if(J.resolvedCwd&&I2($,J.resolvedCwd,J.protectedGitMetadata,!0,J.pathCanonicalizationContext,!J.posixShell))return{kind:"git_metadata_target"};if(D_($,J.trustTmpdirVar,J.posixShell,X,W,Q.tmpdirWordSplittingProtected??!1,J.trustedTmpdirValue,J.environment))return{kind:"temp_target"};if(X)return{kind:"dynamic_target"};if(R_($,J,W))return{kind:"temp_target"};let Y=J.anchoredCwd;if(Y){if(!Q.skipHomeCwd&&C_(Y,J.environment.home,J.environment.paths,J.pathCanonicalizationContext))return{kind:"home_cwd_target"};if(!Q.skipCwdSelf&&S_($,J.resolvedCwd??Y,J.environment.paths,J.pathCanonicalizationContext))return{kind:"cwd_self_target"};if(T_($,Y,J.resolvedCwd??Y,X,W,J.environment.paths,J.pathCanonicalizationContext))return{kind:"within_anchored_cwd"}}return{kind:"outside_anchored_cwd"}}function qU($,J,Q={}){let{containmentTarget:W,...X}=Q;if(J0($,J,X).kind!=="temp_target")return!1;let Y=$.trim();if(I_(Y))return!1;if(nB(Y,J.environment))return!1;return![J.anchoredCwd,J.resolvedCwd].some((K)=>w_(W??Y,K,J.environment.paths,J.pathCanonicalizationContext))}function PQ($,J=!1){let Q=$.trim(),W=BU.normalize(Q),X=Q.replace(/\\/g,"/"),Y=W==="/"?W:W.replace(/\/+$/,"");if(Y==="/"||Y.startsWith("/")&&Y.slice(1).split("/").every((K)=>/^\*+$/.test(K)))return!0;if(/^[A-Za-z]:\/+\*?$/.test(X)||/^\/\/[^/]+\/+[^/]+(?:\/+\*?)?$/.test(X))return!0;if(!J&&(W==="~"||W==="~/"||W==="~/*"))return!0;if(!J&&(W==="$HOME"||W==="$HOME/"||W==="$HOME/*"))return!0;if(!J&&(W==="${HOME}"||W==="${HOME}/"||W==="${HOME}/*"))return!0;return!1}function __($,J,Q){let W=$.trim(),X=Q?W:W==="*"?".":W.endsWith("/*")?W.slice(0,-2):W;if(!X)return!1;try{let Y=bQ(X)?X:J.resolvedCwd?Y4(J.resolvedCwd,X):null;if(!Y)return!1;let K=b1(a(Y,J.environment.paths,J.pathCanonicalizationContext));if(K===M_(K).root)return!0;return K===b1(a(J.environment.home,J.environment.paths,J.pathCanonicalizationContext))}catch{return!1}}function b1($){let J=L_($);if(O_){if(J=J.replace(/\//g,"\\").toLowerCase(),J.length>3&&J.endsWith("\\"))J=J.slice(0,-1);return J}if(J.length>1&&J.endsWith("/"))J=J.slice(0,-1);return J}function D_($,J,Q,W,X,Y,K,B){let q=$.trim();if(UU(q))return!1;if(!W&&iJ(q,B))return!0;return(J||Y&&K)&&Q&&!X&&z_(q,Q)}function z_($,J){return["$TMPDIR","${TMPDIR}"].some((Q)=>{if($===Q)return!0;if(!$.startsWith(`${Q}/`))return!1;return!GU($.slice(Q.length+1),J)})}function I_($){let J=/^(?:\$TMPDIR|\$\{TMPDIR\})(?:\/(.*))?$/.exec($);if(!J)return!1;return BU.normalize(`/${J[1]??""}`)==="/"}function UU($){return $.split(/[\\/]+/).includes("..")}function j_($,J,Q,W){if(!$?.length)return[];return $.flatMap((X)=>{let Y=N3(X.trim(),J);if(!bQ(Y))return[];try{let K=a(Y,Q,W);if(F3(K,a(J,Q,W)))return[];return[b1(K)]}catch{return[]}})}function R_($,J,Q){if(J.allowRoots.length===0)return!1;let W=$.trim();if(UU(W))return!1;let X=Q?W:N3(W,J.environment.home),Y=J.resolvedCwd??J.anchoredCwd,K=bQ(X)?X:Y?Y4(Y,X):null;if(!K)return!1;try{let B=b1(a(K,J.environment.paths,J.pathCanonicalizationContext));return J.allowRoots.some((q)=>B===q||B.startsWith(q.endsWith(RQ)?q:`${q}${RQ}`))}catch{return!1}}function b_($){return/\$(?:TMPDIR(?![A-Za-z0-9_])|\{TMPDIR\})/.test($)}function GU($,J=!1){return $.includes("$")||$.includes("`")||P_($)||J&&A_($)}function P_($){let J=!1;for(let Q of $){if(J){J=!1;continue}if(Q==="\\"){J=!0;continue}if(Q==="*"||Q==="?"||Q==="[")return!0}return!1}function A_($){let J=!1;for(let Q=0;Q<$.length;Q++){let W=$[Q];if(J){J=!1;continue}if(W==="\\"){J=!0;continue}if(W==="{"&&E_($,Q)||(W==="+"||W==="@"||W==="!")&&$[Q+1]==="(")return!0}return!1}function E_($,J){let Q=$.indexOf("}",J+1);if(Q===-1)return!1;let W=$.slice(J+1,Q);return W.includes(",")||W.includes("..")}function C_($,J,Q,W){try{return b1(a($,Q,W))===b1(a(J,Q,W))}catch{try{return b1($)===b1(J)}catch{return!1}}}function S_($,J,Q,W){if($==="."||$==="./"||$===".\\")return!0;try{return b1(a(Y4(J,$),Q,W))===b1(a(J,Q,W))}catch{try{return b1(Y4(J,$))===b1(J)}catch{return!1}}}function T_($,J,Q,W,X,Y,K){let B=Q??J;if(!X&&($.startsWith("~")||$.startsWith("$HOME")||$.startsWith("${HOME}")))return!1;if(W)return!1;if($.startsWith("/")||/^[A-Za-z]:[\\/]/.test($))try{return jQ($,J,Y,K)}catch{return!1}if($.startsWith("./")||$.startsWith(".\\")||!$.includes("/")&&!$.includes("\\"))try{return jQ(Y4(B,$),J,Y,K)}catch{return!1}if($.startsWith("../"))return!1;try{return jQ(Y4(B,$),J,Y,K)}catch{return!1}}function jQ($,J,Q,W){try{return HU(a($,Q,W),a(J,Q,W))}catch{return!1}}function w_($,J,Q,W){if(!J)return!1;try{return HU(a(J,Q,W),a($,Q,W))}catch{return!0}}function HU($,J){let Q=b1($),W=b1(J);return Q.startsWith(`${W}${RQ}`)||Q===W}var v_=new Set(["remove-item","ri","del","erase","rd","rm","rmdir"]),ZU="PowerShell Remove-Item -Recurse -Force outside cwd is blocked. Retry deleting only explicit paths inside the current directory; escalate for anything outside it.",f_="PowerShell Remove-Item -Recurse -Force for non-temporary paths is blocked by the active safety policy. Retry deleting only explicit paths inside the current directory; escalate for anything outside it.",LU="PowerShell Remove-Item target contains variables or pipeline input that cannot be verified safely. Use literal paths within cwd.",MU="PowerShell Remove-Item targeting root or home directory is extremely dangerous and always blocked.",k_="PowerShell Remove-Item -Recurse -Force in home directory is dangerous. Change to a project directory first.",h_="PowerShell Remove-Item receives pipeline input that cannot be verified safely. Use explicit literal paths within cwd.";function OU($,J,Q,W=j2({...Q,allowPaths:Q.policy?.destructiveCommandAllowPaths})){return y_($.words.map((X)=>({kind:"word",text:X.text,dynamic:X.provenance!=="literal"})),J,W,Q.policy)}function y_($,J,Q,W){let X=$.filter((q)=>q.kind==="word"),Y=x_(X),K=X[Y];if(!K||!v_.has(o_(K.text)))return null;let B=g_(X.slice(Y+1));if(B.whatIfProtected)return null;if(q1(W,"powershell.remove-item-pipeline-dynamic-target",Q.strict)&&J&&(B.targets.length===0||B.recursive))return D("powershell.remove-item-pipeline-dynamic-target",h_);for(let q of B.targets)if(!Z2(q.text)&&PQ(EQ(q.text)))return D(B.recursive&&B.force?"powershell.remove-item-recursive-force-root-or-home":"powershell.remove-item-root-or-home",MU);for(let q of B.targets)if(Q.resolvedCwd&&I2(EQ(q.text),Q.resolvedCwd,Q.protectedGitMetadata,B.recursive,Q.pathCanonicalizationContext,!0))return D("powershell.remove-item-git-metadata",d1);if(!B.recursive||!B.force)return null;if(q1(W,"powershell.remove-item-recursive-force-dynamic-target",Q.strict)&&(B.hasDynamicTarget||B.targets.length===0))return D("powershell.remove-item-recursive-force-dynamic-target",LU);for(let q of B.targets){let U=n_(J0(EQ(q.text),Q),Q,W);if(U)return U}return null}function g_($){let J=[],Q=!1,W=!1,X=!1,Y=!1,K=!1;for(let B=0;B<$.length;B++){let q=$[B];if(!q||q.kind!=="word")continue;if(u_(q))continue;if(K){J.push(AQ(q)),Y=Y||q.dynamic;continue}if(q.text==="--"){K=!0;continue}let U=l_(q.text);if(!U){J.push(AQ(q)),Y=Y||q.dynamic;continue}if(p_(U.name)){let G=U.value?m_(U.value,q):$[++B];if(G?.kind==="word")J.push(AQ(G)),Y=Y||G.dynamic;else Y=!0;continue}if(c_(U.name)){Q=!0;continue}if(d_(U.name)){W=!0;continue}if(r_(U.name))X=i_(U.value)}return{targets:J,recursive:Q,force:W,whatIfProtected:X,hasDynamicTarget:Y}}function x_($){let J=$[0];if(J?.kind==="word"&&J.text==="&"||J?.text===".")return $.length>1?1:0;return 0}function AQ($){return{text:$.kind==="word"?$.text:"",dynamic:$.kind==="word"&&$.dynamic}}function u_($){return $.kind==="word"&&$.text===","}function EQ($){let J=$.replace(/\\/g,"/"),Q=/^\$env:(?:userprofile|home)(?=$|\/)/i.exec(J);return Q?`$HOME${J.slice(Q[0].length)}`:J}function m_($,J){return{kind:"word",text:$,dynamic:J.kind==="word"&&(J.dynamic||$.includes("$"))}}function l_($){if(!$.startsWith("-")||$==="-")return null;let J=$.slice(1),Q=J.indexOf(":");if(Q===-1)return{name:J.toLowerCase()};return{name:J.slice(0,Q).toLowerCase(),value:J.slice(Q+1)}}function p_($){return"path".startsWith($)||"literalpath".startsWith($)}function c_($){return"recurse".startsWith($)}function d_($){return $.length>=2&&"force".startsWith($)}function r_($){return $==="wi"||"whatif".startsWith($)}function i_($){if($===void 0||$==="")return!0;let J=$.toLowerCase();return J==="$true"||J==="true"}function o_($){return $.toLowerCase()}function n_($,J,Q){switch($.kind){case"root_or_home_target":return D("powershell.remove-item-recursive-force-root-or-home",MU);case"git_metadata_target":return D("powershell.remove-item-git-metadata",d1);case"temp_target":return null;case"dynamic_target":if(!q1(Q,"powershell.remove-item-recursive-force-dynamic-target",J.strict))return null;return D("powershell.remove-item-recursive-force-dynamic-target",LU);case"home_cwd_target":return D("powershell.remove-item-recursive-force-home-cwd",k_);case"cwd_self_target":return D("powershell.remove-item-recursive-force-cwd-self",ZU);case"within_anchored_cwd":if(!q1(Q,"powershell.remove-item-recursive-force-paranoid",J.paranoid))return null;return D("powershell.remove-item-recursive-force-paranoid",f_);case"outside_anchored_cwd":return D("powershell.remove-item-recursive-force-outside-cwd",ZU)}}import{normalize as e9}from"node:path";var h1=new Set(["awk","gawk","nawk","mawk"]),s_=new Set(["-e","--source"]),a_=new Set(["-F","-v","--assign","--field-separator"]),NU=new Set(["-f","--file"]),t_=new Set(["print","printf","return"]),FU=[{selector:"-e",kind:"inline-code",valueForm:"attached-or-separate"},{selector:"--source",kind:"inline-code",valueForm:"equals-or-separate"},{selector:"-f",kind:"program-file",valueForm:"attached-or-separate"},{selector:"--file",kind:"program-file",valueForm:"equals-or-separate"}],e_="Detected awk system(), pipe, or getline command with dynamic command that cannot be safely analyzed. Use a literal command or process the data without system(), pipes, or getline.";function x9($,J,Q){let W=!1;for(let X of $D($)){let Y=JD(X,Q);if(!Y)continue;for(let K of Y.commands){let B=J(K);if(B)return B;if(K.includes("{}")||/[$`]/.test(K))W=!0}W||=Y.dynamic}return W?D("awk.system-dynamic",e_):null}function SQ($){let J=[],Q=!1,W=!1,X=!0,Y=!0;for(let K=1;K<$.length;K++){let B=$[K];if(B===void 0)break;if(X&&B==="--"){X=!1;continue}if(X&&s_.has(B)){Q=!0;let q=$[K+1];if(q!==void 0)J.push({tokenIndex:K+1,kind:"inline-code",value:q});else Y=!1;K++;continue}if(X&&B.startsWith("--source=")){Q=!0,J.push({tokenIndex:K,kind:"inline-code",value:B.slice(9)});continue}if(X&&B.startsWith("-e")&&B.length>2){Q=!0,J.push({tokenIndex:K,kind:"inline-code",value:B.slice(2)});continue}if(X&&(a_.has(B)||NU.has(B))){if(NU.has(B)){W=!0;let q=$[K+1];if(q!==void 0)J.push({tokenIndex:K+1,kind:"program-file",value:q});else Y=!1}else if($[K+1]===void 0)Y=!1;K++;continue}if(X&&(B.startsWith("-F")||B.startsWith("-v")&&B.slice(2).includes("=")))continue;if(X&&B.startsWith("-f")&&B.length>2){W=!0,J.push({tokenIndex:K,kind:"program-file",value:B.slice(2)});continue}if(X&&(B.startsWith("--assign=")||B.startsWith("--field-separator=")))continue;if(X&&B.startsWith("--file=")){W=!0,J.push({tokenIndex:K,kind:"program-file",value:B.slice(7)});continue}if(X&&B.startsWith("-")&&B!=="-")continue;if(X=!1,!Q&&!W)J.push({tokenIndex:K,kind:"main-program",value:B});return{sources:J,optionsOpen:!1}}return{sources:Y?J:[],optionsOpen:X&&Y}}function D3($){return SQ($).sources}function $D($){return D3($).filter((J)=>J.kind!=="program-file").map((J)=>J.value)}function JD($,J){T1(J,$);let Q=$.includes("system")?TQ($,J):null,W=QD($,J);if(!Q&&!W)return null;return{dynamic:!!Q?.dynamic||!!W?.dynamic,commands:[...Q?.commands??[],...W?.commands??[]]}}function TQ($,J){T1(J,$);let Q=[],W=!1,X=!1,Y=0;while(Y<$.length){let K=$[Y];if(K==='"'||K==="'"){Y=g9($,Y,K)?.endIndex??Y+1;continue}if(K==="#"){Y=VU($,Y+1);continue}if(K==="/"&&_U($,Y)){Y=DU($,Y+1)??Y+1;continue}if(!$.startsWith("system",Y)){Y++;continue}let B=Y;if(Y+=6,_3($[B-1])||_3($[Y]))continue;let q=y9($,Y);if($[q]!=="(")continue;q=y9($,q+1);let U=$[q];if(U!=='"'&&U!=="'"){W=!0,X=!0;continue}let G=g9($,q,U);if(!G){W=!0,X=!0;continue}if(q=y9($,G.endIndex),W=!0,$[q]!==")"){X=!0,Y=G.endIndex;continue}Q.push(G.value),Y=q+1}if(!W)return null;return{dynamic:X,commands:Q}}function QD($,J){T1(J,$);let Q=[],W=!1,X=!1,Y=0,K=0,B=null,q=null,U=0;while(Y<$.length){let G=$[Y];if(!G)break;if(G==='"'||G==="'"){let Z=g9($,Y,G);if(Z&&U===K)q={...Z,startIndex:Y};U=Z?.endIndex??Y+1,Y=Z?.endIndex??Y+1;continue}if(G==="#"){Y=VU($,Y+1),K=Y,B=null,q=null,U=Y;continue}if(G==="/"&&_U($,Y)){let Z=DU($,Y+1);U=Z??Y+1,Y=Z??Y+1;continue}if(`;
51
- {}`.includes(G)){Y++,K=Y,B=null,q=null,U=Y;continue}if(B===null&&(CQ($,Y,"print")||CQ($,Y,"printf")))B=Y;if(G!=="|"||$[Y-1]==="|"||$[Y+1]==="|"){if(!/\s/.test(G))U=Y+1;Y++;continue}let H=$[Y+1]==="&"?Y+2:Y+1,L=y9($,H);if(CQ($,L,"getline")){X=!0;let Z=YD(K,q,U);if(Z===null)W=!0;else Q.push(Z);U=H,Y=H;continue}if(BD(K,B)){X=!0;let Z=XD($,L);if(!Z){W=!0,U=H,Y=H;continue}if(!WD($,Z.endIndex)){W=!0,U=Z.endIndex,Y=Z.endIndex;continue}Q.push(Z.value),U=Z.endIndex,Y=Z.endIndex;continue}U=H,Y++}if(!X)return null;return{dynamic:W,commands:Q}}function _3($){return!!$&&/[A-Za-z0-9_]/.test($)}function y9($,J){let Q=J;while(/\s/.test($[Q]??""))Q++;return Q}function WD($,J){let Q=J;while(/[\t\f\v\r ]/.test($[Q]??""))Q++;let W=$[Q];return!W||`;
52
- }#`.includes(W)}function g9($,J,Q){let W="",X=!1;for(let Y=J+1;Y<$.length;Y++){let K=$[Y];if(!K)break;if(X){let B=KD($,Y);if(!B)return null;W+=B.value,Y=B.endIndex,X=!1;continue}if(K==="\\"){X=!0;continue}if(K===Q)return{value:W,endIndex:Y+1};W+=K}return null}function XD($,J){let Q=$[J];if(Q!=='"'&&Q!=="'")return null;return g9($,J,Q)}function YD($,J,Q){if(!J)return null;return J.startIndex>=$&&J.endIndex===Q?J.value:null}function KD($,J){let Q=$[J];if(!Q)return null;if(Q==="x"){let X=$.slice(J+1,J+3);if(!/^[0-9A-Fa-f]{2}$/.test(X))return null;return{value:String.fromCharCode(Number.parseInt(X,16)),endIndex:J+2}}if(/[0-7]/.test(Q)){let X=/^[0-7]{1,3}/.exec($.slice(J));if(!X)return null;return{value:String.fromCharCode(Number.parseInt(X[0],8)),endIndex:J+X[0].length-1}}return{value:{a:"\x07",b:"\b",f:"\f",n:`
53
- `,r:"\r",t:"\t",v:"\v"}[Q]??Q,endIndex:J}}function CQ($,J,Q){return $.startsWith(Q,J)&&!_3($[J-1])&&!_3($[J+Q.length])}function BD($,J){return J!==null&&J>=$}function VU($,J){let Q=$.indexOf(`
54
- `,J);return Q===-1?$.length:Q+1}function _U($,J){let Q=qD($,J);if(Q===-1)return!0;if("{([,;!~=".includes($[Q]??""))return!0;let W=Q;while(_3($[W-1]))W--;return t_.has($.slice(W,Q+1))}function qD($,J){for(let Q=J-1;Q>=0;Q--)if(!/\s/.test($[Q]??""))return Q;return-1}function DU($,J){let Q=!1;for(let W=J;W<$.length;W++){let X=$[W];if(!X)break;if(Q){Q=!1;continue}if(X==="\\"){Q=!0;continue}if(X==="/")return W+1}return null}var zU=new Set(["rm","find","xargs","parallel"]),UD=new Set(["sudo","env","command","builtin"]),GD=new Set(["git","busybox",...zU,...U1,...xB,...h1]);function u9($,J){let Q=$[0];if(!Q||!J.transparentWrappers.includes(l(Q)))return null;let W=l(Q),X=$[1]==="--"?2:1,Y=HD($,X,W,J),K=Y[0];if(K===void 0)return null;return{wrapper:W,tokens:[...$.slice(K)],childIndex:K,alternativeChildIndices:Y.slice(1)}}function HD($,J,Q,W){let X=$[1]==="--",Y=[];for(let K=J;K<$.length;K++){let B=$[K];if(!B)continue;if(l(B)!==Q&&ZD(B,W))Y.push(K);else if(e6.has(r(B)))break;if(X)break}return Y}function ZD($,J){let Q=l($),W=r($);return W==="git"||Q==="busybox"||R2($)||zU.has(Q)||J.transparentWrappers.includes(Q)||U1.has(W)||$==="$SHELL"||w1(W)||h1.has(W)||J.rules.some((X)=>X.command===Q)}function R2($){return UD.has($.toLowerCase())}function IU($){let J=r($);return GD.has(J)||w1(J)}function Q0($,J){let Q=J.policy??{rules:[],transparentWrappers:[]};return wQ([...$],J.environment,J.cwd,J.cwd,new Map,new Map(J.envAssignments??[]),Q,{iterations:0},!1)}function*wQ($,J,Q,W,X,Y,K,B,q){let U=oJ($,J,Q,Y);if(U.unverifiableEnvSplit)throw new N2;for(let[Z,M]of U.envAssignments)Y.set(Z,M),X.set(Z,M);let{tokens:G,cwd:H}=U;if(R2(G[0]??""))throw new p1;let L=u9(G,K);if(L){for(let Z of[L.childIndex,...L.alternativeChildIndices])jU(B),yield*wQ(Z===L.childIndex?L.tokens:[...G.slice(Z)],J,H,W,new Map(X),new Map(Y),K,B,!0);return}if(MD(G)){jU(B),yield*wQ([...G.slice(1)],J,H,W,X,Y,K,B,q);return}yield LD(G,H,W,X,Y,q)}function LD($,J,Q,W,X,Y){return{tokens:$,cwd:J===null?void 0:J??Q,wrapperCwd:J,wrapperEnvAssignments:W,envAssignments:X,head:l($[0]??"").toLowerCase(),wrappedByTransparent:Y}}function jU($){if($.iterations>=s2)throw new p1;$.iterations++}function MD($){return l($[0]??"").toLowerCase()==="busybox"&&$.length>1}function vQ($,J){let Q=[],W=J;while(W<$.length){let X=$[W];if(X===void 0||X===":::")break;Q.push(X),W++}return{markerIndex:W<$.length&&$[W]===":::"?W:-1,templateTokens:Q}}function W0($){let J=!1,Q=!1;for(let W of $){if(W==="--")break;if(W==="-r"||W==="-R"||fQ(W,"recursive"))J=!0;else if(W==="-f"||fQ(W,"force"))Q=!0;else if(W.startsWith("-")&&!W.startsWith("--")){if(W.includes("r")||W.includes("R"))J=!0;if(W.includes("f"))Q=!0}}return J&&Q}function RU($){let J=$.indexOf("--");return $.slice(1,J===-1?void 0:J).some((Q)=>fQ(Q,"recursive")||/^-[A-Za-z]+$/.test(Q)&&/[rR]/.test(Q.slice(1)))}function fQ($,J){return $.length>2&&$.startsWith("--")&&J.startsWith($.slice(2))}var OD="find -delete permanently removes files. Use -print first to preview.",ND="find -exec rm -rf is dangerous. Use explicit file list instead.",FD=new Set(["-exec","-execdir","-ok","-okdir"]),VD=new Map([...["-Bmin","-Bnewer","-Btime","-amin","-anewer","-atime","-cmin","-cnewer","-context","-ctime","-f","-flags","-fprint","-fprint0","-fls","-fstype","-gid","-group","-ilname","-iname","-inum","-ipath","-iwholename","-iregex","-links","-lname","-maxdepth","-mindepth","-mmin","-mnewer","-mtime","-name","-newer","-newerXY","-newermt","-path","-perm","-printf","-regex","-samefile","-size","-type","-uid","-used","-user","-wholename","-xattrname","-xtype"].map(($)=>[$,1]),["-fprintf",2]]);function m9($,J){let Q=$.map(v),W=_D($,Q,J);if(W)return W;if(p9(Q,1)&&!zD($,Q,J)){let K=k(D("find.delete",OD),J.policy);if(K)return K}let X=J.derivedCommandWorkBudget??a6(),Y=0;while(Y<Q.length){let K=Q[Y],B=s0(K??"");if(B>0){Y+=B+1;continue}if(!h0(K)){Y++;continue}G0(X,Q.length-Y-1);let q=z3(Q,Y);Y=q.nextIndex;let U=jD(q.tokens,J.environment);if(U){let Z=k(U,J.policy);if(Z)return Z}let G=K==="-execdir"||K==="-okdir",H=J.analyzeTokens?J.analyzeTokens(q.tokens,G?null:J.cwd):J.analyzeNested?J.analyzeNested(q.tokens.join(" "),{effectiveCwd:G?void 0:J.cwd,envAssignments:J.envAssignments}):null,L=H?.id.startsWith("custom.")?H:k(H,J.policy);if(L)return L}return null}function _D($,J,Q){if(!p9(J,1)&&!kQ(J,Q.environment))return null;let X=l9($)??p(["."]),Y=j2({...Q,allowPaths:Q.policy?.destructiveCommandAllowPaths,posixShell:!0});for(let K of X){let B=V3(K);for(let q of B.expandedTargets??[v(K)]){let U=J0(q,Y,{targetIsLiteral:B.expandedTargets!==void 0||B.targetIsLiteral,tmpdirWordSplittingProtected:B.tmpdirWordSplittingProtected});if(U.kind==="root_or_home_target")return D("rm.recursive-force-root-or-home","rm -rf targeting root or home directory is extremely dangerous and always blocked.");if(U.kind==="git_metadata_target")return D("find.delete-git-metadata",d1)}}if(DD(J)&&Y.resolvedCwd&&QU(X.map(v),Y.resolvedCwd,Y.protectedGitMetadata,Y.pathCanonicalizationContext))return D("find.delete-git-metadata",d1);return null}function kQ($,J){let Q=0;while(Q<$.length){if(!h0($[Q])){Q++;continue}let W=z3($,Q),X=c1([...W.tokens],J),Y=l(X[0]??"").toLowerCase();if((Y==="rm"||Y==="rmdir")&&X.some((K)=>K.includes("{}")))return!0;Q=W.nextIndex}return!1}function DD($){return $.some((J,Q)=>{if(!["-name","-iname"].includes(J))return!1;return $[Q+1]?.toLowerCase()==="hooks"})}function zD($,J,Q){if(J.includes("-L")||J.includes("-f")||J.includes("-follow"))return!1;let W=l9($);if(!W)return!1;let X=Q.envAssignments??new Map,Y=rJ(X,Q.environment),K=Q.trustedTmpdirValue??f0(X,Q.environment),B=Q.allowTmpdirVar??!B3(X,Q.environment),q=j2({environment:Q.environment,protectedGitMetadata:Q.protectedGitMetadata,cwd:Q.cwd,originalCwd:Q.originalCwd,strict:Q.strict,allowTmpdirVar:B&&K&&Boolean(Y),allowPaths:Q.policy?.destructiveCommandAllowPaths,posixShell:!0,tmpdirWordSplittingUnsafe:Q.tmpdirWordSplittingUnsafe??H0(X,Q.environment),trustedTmpdirValue:K});return W.every((U)=>{let G=V3(U);if(G.unsafeBraceExpansion)return!1;return(G.expandedTargets??[v(U)]).every((H)=>qU(H,q,{containmentTarget:ID(H,Y),targetIsLiteral:G.expandedTargets!==void 0||G.targetIsLiteral,tmpdirWordSplittingProtected:G.tmpdirWordSplittingProtected}))})}function ID($,J){if(!J)return $;return $.replace(/^(?:\$TMPDIR|\$\{TMPDIR\})/,()=>J)}function l9($){let J=(X)=>{let Y=$[X];return Y?v(Y):void 0},Q=1;while(J(Q)==="-H"||J(Q)==="-P")Q++;if(J(Q)==="--")Q++;let W=[];while(Q<$.length){let X=J(Q),Y=$[Q];if(!X||!Y||X.startsWith("-")||["!","(",")"].includes(X))break;W.push(Y),Q++}return W.length>0?W:null}function jD($,J){let Q=c1([...$],J);if(Q.length===0)return null;let W=l(Q[0]??"");if(W==="busybox"&&Q.length>1)Q=Q.slice(1),W=l(Q[0]??"");if(W==="rm"&&W0(Q))return D("find.exec-rm-recursive-force",ND);return null}function z3($,J){let Q=J+1;while(Q<$.length&&$[Q]!==";"&&!($[Q]==="+"&&$[Q-1]==="{}"))Q++;return{tokens:$.slice(J+1,Q),nextIndex:Math.min(Q+1,$.length)}}function p9($,J){let Q=J;while(Q<$.length){let W=$[Q];if(!W){Q++;continue}if(h0(W)){Q=z3($,Q).nextIndex;continue}let X=s0(W);if(X>0){Q+=X+1;continue}if(W==="-delete")return!0;Q++}return!1}function s0($){return VD.get($)??(/^-newer[A-Za-z]{2}$/.test($)?1:0)}function h0($){return $!==void 0&&FD.has($)}function I3($){let J=e1($,"posix");if(J.status!=="complete"||J.nodes.length!==1)return null;let Q=J.nodes[0];if(Q?.kind!=="command")return null;if(Q.redirections.length>0||Q.nested.length>0)return null;if(Q.words.some((W)=>W.provenance==="command-substitution"))return null;return Q.words.map((W)=>W.text)}var RD=5,hQ="Git aliases supplied through command-line or environment config can hide or execute commands. Run git without Git alias overrides, or ask the user to run it manually.";function _1($){let J=$.indexOf("--");if(J===-1)return{index:-1,before:$,after:[]};return{index:J,before:$.slice(0,J),after:$.slice(J+1)}}function PU($,J,Q){let W=EU($,J,Q),X=bD(W.entries);if(X.size===0)return{blockedReason:W.blockedReason,expanded:!1,tokens:$};let Y=$,K=!1;for(let B=0;B<RD;B++){let{subcommand:q,rest:U}=X0(Y),G=q?.toLowerCase();if(!G||!X.has(G))return{blockedReason:W.blockedReason,expanded:K,tokens:Y};let H=X.get(G),L=SD(H);if(L===null||L.length===0)return{blockedReason:hQ,expanded:!0,tokens:Y};Y=["git",...L,...U],K=!0}return{blockedReason:hQ,expanded:!0,tokens:Y}}function AU($,J,Q){return EU($,J,Q).entries.some((W)=>W.key.toLowerCase()==="core.sshcommand")}function X0($){if($.length===0)return{subcommand:null,rest:[]};let J=$[0];if((J?l(J).toLowerCase():null)!=="git")return{subcommand:null,rest:[]};let W=1;while(W<$.length){let X=$[W];if(!X)break;if(X==="--"){let Y=$[W+1];if(Y&&!Y.startsWith("-"))return{subcommand:Y,rest:$.slice(W+2)};return{subcommand:null,rest:$.slice(W+1)}}if(X.startsWith("-"))if(U0.has(X))W+=2;else if(X.startsWith("-c")&&X.length>2)W++;else if(X.startsWith("-C")&&X.length>2)W++;else W++;else return{subcommand:X,rest:$.slice(W+1)}}return{subcommand:null,rest:[]}}function bD($){let J=new Map;for(let Q of $){let W=Q.key.toLowerCase();if(!W.startsWith("alias."))continue;let X=W.slice(6);if(X!=="")J.set(X,Q.value)}return J}function EU($,J,Q){if($.length===0)return{blockedReason:null,entries:[]};let W=$[0];if((W?l(W).toLowerCase():null)!=="git")return{blockedReason:null,entries:[]};let Y=AD(J,Q);return{blockedReason:Y.blockedReason,entries:[...Y.entries,...PD($,J,Q)]}}function PD($,J,Q){let W=[],X=1;while(X<$.length){let Y=$[X];if(!Y||Y==="--"||!Y.startsWith("-"))return W;if(Y==="-c"){let K=yQ($[X+1]);if(K)W.push(K);X+=2;continue}if(Y.startsWith("-c")&&Y.length>2){let K=yQ(Y.slice(2));if(K)W.push(K);X++;continue}if(Y==="--config-env"){let K=bU($[X+1],J,Q);if(K)W.push(K);X+=2;continue}if(Y.startsWith("--config-env=")){let K=bU(Y.slice(13),J,Q);if(K)W.push(K);X++;continue}if(U0.has(Y)){X+=2;continue}X++}return W}function AD($,J){let Q=ED($,J),W=CD($,J);return{blockedReason:Q===null||W===null?hQ:null,entries:[...Q??[],...W??[]]}}function ED($,J){let Q=l1("GIT_CONFIG_PARAMETERS",$,J);if(Q===void 0)return[];let W=[],X=I3(Q);if(!X)return null;for(let Y of X){let K=yQ(Y);if(!K)return null;W.push(K)}return W}function CD($,J){let Q=m6($,J);if(Q.state==="absent")return[];if(Q.state==="invalid")return null;let W=[];for(let X=0;X<Q.count;X++){let Y=l1(`GIT_CONFIG_KEY_${X}`,$,J)?.trim(),K=l1(`GIT_CONFIG_VALUE_${X}`,$,J);if(!Y||K===void 0)return null;W.push({key:Y,value:K})}return W}function yQ($){if(!$)return null;let J=$.indexOf("=");return{key:(J===-1?$:$.slice(0,J)).trim(),value:J===-1?void 0:$.slice(J+1)}}function bU($,J,Q){let W=$?.indexOf("=")??-1;if(!$||W===-1)return null;return{key:$.slice(0,W).trim(),value:l1($.slice(W+1),J,Q)}}function SD($){let J=$?.trimStart();if(!J||J.startsWith("!"))return null;return I3(J)}var TD="git checkout -- discards uncommitted changes permanently. Use 'git stash' first.",wD="git checkout --force discards uncommitted changes. Use 'git stash' first.",vD="git checkout <ref> -- <path> overwrites working tree with ref version. Use 'git stash' first.",fD="git checkout --pathspec-from-file can overwrite multiple files. Use 'git stash' first.",kD="git checkout with multiple positional args may overwrite files. Use 'git switch' for branches or 'git restore' for files.",hD="git switch --discard-changes discards uncommitted changes. Use 'git stash' first.",yD="git switch --force discards uncommitted changes. Use 'git stash' first.",gD="git restore discards uncommitted changes. Use 'git stash' first, or use --staged to only unstage.",xD="git restore --worktree explicitly discards working tree changes. Use 'git stash' first.",uD="git reset --hard destroys all uncommitted changes permanently. Use 'git stash' first.",mD="git reset --merge can lose uncommitted changes. Use 'git stash' first.",lD="git clean -f removes untracked files permanently. Use 'git clean -n' to preview first.",pD="git rm --force removes tracked files from the working tree. Use 'git rm --cached' to keep the files, or 'git rm --dry-run' to preview first.",cD="git push --force destroys remote history. Use --force-with-lease for safer force push.",dD="git push deletes remote refs. Ask the user to run it manually if deletion is intended.",rD="git push --mirror can force-update and delete remote refs. Ask the user to run it manually if mirror push is intended.",iD="git branch -D force-deletes without merge check. Use -d for safe delete.",oD="git rebase --abort discards rebase conflict resolutions. Use 'git status' first.",nD="git merge --abort discards merge conflict resolutions. Use 'git status' first.",sD="git tag -d permanently deletes tags. Ask the user to run it manually if deletion is intended.",aD="git reflog delete removes recovery history. Ask the user to run it manually if deletion is intended.",tD="git stash drop permanently deletes stashed changes. Consider 'git stash list' first.",eD="git stash clear deletes ALL stashed changes permanently. Use 'git stash list' to review; ask the user to run it manually if intended.",$z="git worktree remove --force can delete uncommitted changes. Remove --force flag.",CU=new Set(["-b","-B","--orphan","--conflict","--inter-hunk-context","--pathspec-from-file","--unified"]),SU=new Set(["--recurse-submodules","--track","-t"]),gQ=new Set(["-b","-B","-U"]),xQ=new Set(["-c","-C"]),Jz=new Set(["--source","--conflict","--unified","--inter-hunk-context"]),Qz=new Set(["-q","--quiet","--no-quiet","-f","--force","--no-force","-d","--detach","--no-detach","-m","--merge","--no-merge","-p","--patch","--no-patch","--guess","--no-guess","--overlay","--no-overlay","--ours","--theirs","--ignore-skip-worktree-bits","--no-ignore-skip-worktree-bits","--no-track","--overwrite-ignore","--no-overwrite-ignore","--ignore-other-worktrees","--no-ignore-other-worktrees","--progress","--no-progress","--pathspec-file-nul","--no-pathspec-file-nul","--no-recurse-submodules"]);function c($,J){let Q=$.split("=",1)[0]??$;return Q.length>=4&&J.startsWith(Q)&&Q.startsWith("--")&&Q.slice(2).length>=2}var c9=new Set(["branch","checkout","clean","merge","push","rebase","reflog","reset","restore","rm","stash","switch","tag","worktree"]);function wU($){let{subcommand:J,rest:Q}=X0($);if(!J)return null;switch(J.toLowerCase()){case"checkout":return a0(Wz(Q));case"switch":return a0(Xz(Q));case"restore":return a0(Kz(Q));case"reset":return qz(Q);case"clean":return a0(Gz(Q));case"rm":return a0(Hz(Q));case"push":return b2(Zz(Q));case"branch":return b2(Oz(Q));case"stash":return b2(Dz(Q));case"worktree":return b2(zz(Q));case"rebase":return a0(Nz(Q));case"merge":return a0(Fz(Q));case"tag":return b2(Vz(Q));case"reflog":return b2(_z(Q));default:return null}}function a0($){return $?{...$,localDiscard:!0}:null}function b2($){return $?{...$,localDiscard:!1}:null}function Wz($){let{index:J,before:Q}=_1($),W=R1(Q,{shortOptsWithValue:gQ});if(Q.some((Y)=>c(Y,"--force"))||W.has("-f"))return D("git.checkout-force",wD);for(let Y of $){if(Y==="-b"||Y==="-B"||Y==="--orphan")return null;if(c(Y,"--pathspec-from-file"))return D("git.checkout-pathspec-from-file",fD)}if(J!==-1){if(Q.some((K)=>!K.startsWith("-")))return D("git.checkout-ref-path",vD);return D("git.checkout-double-dash",TD)}if(Yz($).length>=2)return D("git.checkout-ambiguous",kD);return null}function Xz($){let{before:J}=_1($);if(J.some((W)=>c(W,"--discard-changes")))return D("git.switch-discard-changes",hD);let Q=R1(J,{shortOptsWithValue:xQ});if(J.some((W)=>c(W,"--force"))||Q.has("-f"))return D("git.switch-force",yD);return null}function Yz($){let J=[],Q=0;while(Q<$.length){let W=$[Q];if(!W)break;if(W==="--")break;if(W.startsWith("-"))if(CU.has(W))Q+=2;else if(W.startsWith("--")&&W.includes("="))Q++;else if(SU.has(W)){let X=$[Q+1];if(X&&!X.startsWith("-")&&(W==="--recurse-submodules"||W==="--track"||W==="-t"))if((W==="--recurse-submodules"?["checkout","on-demand"]:["direct","inherit"]).includes(X))Q+=2;else Q++;else Q++}else if(W.startsWith("--")&&!Qz.has(W)&&!CU.has(W)&&!SU.has(W))Q++;else Q++;else J.push(W),Q++}return J}function Kz($){let J=Bz($);if(J.isTerminal||!J.hasPathspec&&!J.hasPatch||!J.hasWorktree)return null;return J.hasExplicitLocation?D("git.restore-worktree",xD):D("git.restore-unstaged",gD)}function Bz($){let J=!1,Q=!1,W=!0,X=!1,Y=(K)=>{if(!X)W=!1,X=!0;if(K!==void 0)W=K};for(let K=0;K<$.length;K++){let B=$[K];if(B===void 0)break;if(B==="--"){J||=K+1<$.length;break}if(B==="--pathspec-from-file"){J=!0,K++;continue}if(B.startsWith("--pathspec-from-file=")){J=!0;continue}if(B==="-h"||B==="--help"||B==="--version")return{hasPathspec:J,hasPatch:Q,hasWorktree:W,hasExplicitLocation:X,isTerminal:!0};if(B==="--staged"){Y();continue}if(B==="--no-staged"){Y();continue}if(B==="--worktree"){Y(!0);continue}if(B==="--no-worktree"){Y(!1);continue}if(B==="--patch"){Q=!0;continue}if(B==="--no-patch"){Q=!1;continue}if(Jz.has(B)){K++;continue}if(B.startsWith("--"))continue;if(B==="-"){J=!0;continue}if(!B.startsWith("-")){J=!0;continue}for(let q=1;q<B.length;q++){let U=B.charAt(q);if(U==="h")return{hasPathspec:J,hasPatch:Q,hasWorktree:W,hasExplicitLocation:X,isTerminal:!0};if(U==="S"){Y();continue}if(U==="W"){Y(!0);continue}if(U==="p"){Q=!0;continue}if(U==="s"||U==="U"){if(q===B.length-1)K++;break}}}return{hasPathspec:J,hasPatch:Q,hasWorktree:W,hasExplicitLocation:X,isTerminal:!1}}function qz($){let J=null;for(let Q of $){if(c(Q,"--hard")){J=D("git.reset-hard",uD);break}if(c(Q,"--merge")){J=D("git.reset-merge",mD);break}}if(!J)return null;return Uz($)?b2(J):a0(J)}function Uz($){for(let J of $){if(J==="--")return!1;if(!J.startsWith("-"))return!0}return!1}function Gz($){for(let Q of $)if(Q==="-n"||c(Q,"--dry-run"))return null;let J=R1($.filter((Q)=>Q!=="--"));if($.some((Q)=>c(Q,"--force"))||J.has("-f"))return D("git.clean-force",lD);return null}function Hz($){let J=!1,Q=!1,W=!1;for(let X of _1($).before){if(c(X,"--no-force")){J=!1;continue}if(c(X,"--force")){J=!0;continue}if(c(X,"--no-cached")){Q=!1;continue}if(c(X,"--cached")){Q=!0;continue}if(c(X,"--no-dry-run")){W=!1;continue}if(c(X,"--dry-run")){W=!0;continue}let Y=R1([X]);J||=Y.has("-f"),W||=Y.has("-n")}return J&&!Q&&!W?D("git.rm-force",pD):null}function Zz($){let{before:J,after:Q}=_1($),W=R1(J);if(J.some((K)=>c(K,"--mirror")))return D("git.push-mirror",rD);if(J.some((K)=>c(K,"--force"))||W.has("-f")||TU(J,Q).some(Lz))return D("git.push-force",cD);if(J.some((K)=>c(K,"--delete"))||W.has("-d")||TU(J,Q).some(Mz))return D("git.push-delete",dD);return null}function TU($,J){return[...$.filter((Q)=>Q!==""&&!Q.startsWith("-")),...J]}function Lz($){return $.startsWith("+")||$.includes(":+")}function Mz($){return $.length>1&&$.startsWith(":")}function Oz($){let{before:J}=_1($),Q=R1(J),W=Q.has("-D")||Q.has("-d")||J.some((Y)=>c(Y,"--delete")),X=Q.has("-D")||Q.has("-f")||J.some((Y)=>c(Y,"--force"));if(W&&X)return D("git.branch-force-delete",iD);return null}function Nz($){let{before:J}=_1($);return J.some((Q)=>c(Q,"--abort"))?D("git.rebase-abort",oD):null}function Fz($){let{before:J}=_1($);return J.some((Q)=>c(Q,"--abort"))?D("git.merge-abort",nD):null}function Vz($){let{before:J}=_1($);return R1(J).has("-d")||J.some((W)=>c(W,"--delete"))?D("git.tag-delete",sD):null}function _z($){return $[0]==="delete"?D("git.reflog-delete",aD):null}function Dz($){for(let J of $){if(J==="drop")return D("git.stash-drop",tD);if(J==="clear")return D("git.stash-clear",eD)}return null}function zz($){let{before:J}=_1($);if(!J.includes("remove"))return null;let W=R1(J);if(J.some((X)=>c(X,"--force"))||W.has("-f"))return D("git.worktree-remove-force",$z);return null}import{execFileSync as Iz}from"node:child_process";import{existsSync as mQ,readFileSync as lQ}from"node:fs";import{dirname as jz,isAbsolute as kU,join as uQ,resolve as hU}from"node:path";var Rz=["/usr/bin/git","/usr/local/bin/git","/opt/homebrew/bin/git","C:\\Program Files\\Git\\cmd\\git.exe","C:\\Program Files\\Git\\bin\\git.exe"];function yU($,J,Q,W){let X=bz($,J,Q);if(X!==null)return X;let Y=Pz(J,Q);if(Y!==null)return Y;if(HB(Q))return!0;return Az(W)}function bz($,J,Q){let W=null,X=1;while(X<$.length){let Y=$[X];if(!Y||Y==="--")return W;if(!Y.startsWith("-"))return W;if(Y==="-c"){let K=vU($[X+1]);if(K!==null)W=K;X+=2;continue}if(Y.startsWith("-c")&&Y.length>2){let K=vU(Y.slice(2));if(K!==null)W=K;X++;continue}if(Y==="--config-env"){let K=fU($[X+1],J,Q);if(K!==null)W=K;X+=2;continue}if(Y.startsWith("--config-env=")){let K=fU(Y.slice(13),J,Q);if(K!==null)W=K;X++;continue}if(U0.has(Y))X+=2;else X++}return W}function Pz($,J){if(l1("GIT_CONFIG_PARAMETERS",$,J)!==void 0)return!0;let Q=m6($,J);if(Q.state==="absent")return null;if(Q.state==="invalid")return!0;let W=null;for(let X=0;X<Q.count;X++){let Y=l1(`GIT_CONFIG_KEY_${X}`,$,J),K=l1(`GIT_CONFIG_VALUE_${X}`,$,J);if(!Y?.trim()||K===void 0)return!0;let B=Y.trim().toLowerCase();if(pQ(B))return!0;if(B!=="submodule.recurse")continue;W=j3(K)}return W}function Az($,J=Cz()){let Q=Ez($);if(Q===null||Q)return!0;if(J===null)return!0;try{let W=Iz(J,["config","--get","submodule.recurse"],{cwd:$,encoding:"utf8",env:Sz(process.env),stdio:["ignore","pipe","ignore"]}).trim();return j3(W)}catch(W){return!Tz(W)}}function Ez($){let J=wz($);if(J===null)return null;for(let Q of J){if(!mQ(Q))continue;if(kz(Q))return!0}return!1}function Cz(){for(let $ of Rz)if(mQ($))return $;return null}function Sz($){let J={...$};for(let Q of Object.keys(J))if(t4(Q))delete J[Q];return J}function Tz($){return typeof $==="object"&&$!==null&&"status"in $&&$.status===1}function wz($){let J=J3($);if(J===null)return null;let Q=vz(J);if(Q===null)return null;let W=fz(Q);if(W===null)return null;return[uQ(W,"config"),uQ(Q,"config.worktree")]}function vz($){try{let Q=lQ($,"utf-8").split(/\r?\n/,1)[0]?.trim()??"";if(!Q.startsWith("gitdir:"))return $;let W=Q.slice(7).trim();if(W==="")return null;return kU(W)?W:hU(jz($),W)}catch{return null}}function fz($){let J=uQ($,"commondir");if(!mQ(J))return $;try{let Q=lQ(J,"utf-8").split(/\r?\n/,1)[0]?.trim()??"";if(Q==="")return null;return kU(Q)?Q:hU($,Q)}catch{return null}}function kz($){let J;try{J=lQ($,"utf-8")}catch{return!0}let Q="",W=!1;for(let X of J.split(/\r?\n/)){let Y=X.trim();if(Y===""||Y.startsWith("#")||Y.startsWith(";"))continue;let K=Y.match(/^\[([^\]]+)\]$/);if(K){Q=K[1]?.trim().toLowerCase()??"";continue}let B=Y.indexOf("="),q=(B===-1?Y:Y.slice(0,B)).trim().toLowerCase(),U=B===-1?"true":Y.slice(B+1).trim();if(hz(Q)&&q==="path")return!0;if(Q==="submodule"&&q==="recurse")W=j3(U)}return W}function hz($){return $==="include"||$.startsWith("includeif ")}function vU($){if(!$)return null;let J=$.indexOf("="),Q=(J===-1?$:$.slice(0,J)).toLowerCase();if(pQ(Q))return!0;if(Q!=="submodule.recurse")return null;let W=J===-1?"true":$.slice(J+1).toLowerCase();return j3(W)}function j3($){let J=$.toLowerCase();return J!=="false"&&J!=="no"&&J!=="off"&&J!=="0"}function fU($,J,Q){let W=$?.indexOf("=")??-1;if(!$||W===-1)return null;let X=$.slice(0,W).toLowerCase();if(pQ(X))return!0;if(X!=="submodule.recurse")return null;let Y=l1($.slice(W+1),J,Q);return Y===void 0||j3(Y)}function pQ($){return $==="include.path"||$.startsWith("includeif.")&&$.endsWith(".path")}function gU($,J,Q){if(!J.localDiscard||!Q.worktreeMode||OB(Q.env,Q.envAssignments))return null;let W=NB($,Q.cwd);if(!W.gitCwd||W.hasExplicitGitContext)return null;if(!FB(W.gitCwd))return null;if(yz($,Q,W.gitCwd))return null;return{originalReason:J.reason,gitCwd:W.gitCwd}}function yz($,J,Q){let{subcommand:W,rest:X}=X0($),Y=W?.toLowerCase();if(J.dynamicArguments||gz(X)||yU($,J.env,J.envAssignments,Q)||mz(X)||xz(Y,X))return!0;return Y==="clean"&&lz(X)>1}function gz($){return $.some((J)=>/[$*?[]/.test(J))}function xz($,J){if($==="checkout"){let{before:Q}=_1(J),W=R1(Q,{shortOptsWithValue:gQ}),X=Q.some((K)=>c(K,"--force"))||W.has("-f"),Y=W.has("-B")||Q.some((K)=>K==="-B"||K.startsWith("-B"));return X&&Y}if($==="switch"){let{before:Q}=_1(J),W=R1(Q,{shortOptsWithValue:xQ}),X=Q.some((K)=>c(K,"--force"))||Q.some((K)=>c(K,"--discard-changes"))||W.has("-f"),Y=Q.some((K)=>K==="-C"||K.startsWith("-C")||uz(K))||W.has("-C");return X&&Y}return!1}function uz($){let J=$.split("=",1)[0]??$;return J==="--force-create"||J.length>=9&&"--force-create".startsWith(J)}function mz($){return $.some((J)=>J.startsWith("--recurse-sub"))}function lz($){let J=0;for(let Q of $){if(Q==="--force"){J++;continue}if(Q.startsWith("-")&&!Q.startsWith("--")){for(let W of Q.slice(1))if(W==="f")J++}}return J}var pz="Git SSH environment overrides can execute arbitrary commands during network operations. Run git without GIT_SSH/GIT_SSH_COMMAND overrides, or ask the user to run it manually.",cz=new Set(["clone","fetch","pull","push","ls-remote","submodule"]);function K4($,J){return xU($.map(v),J)}function xU($,J,Q){let W=PU($,J.env,J.envAssignments),X=J.policy?.destructiveCommandRuleOverrides["git.alias-config"]==="off";if(W.blockedReason&&!X)return D("git.alias-config",W.blockedReason);let Y=W.tokens;if((GB(J.envAssignments)||AU($,J.env,J.envAssignments))&&dz(Y))return D("git.ssh-env",pz);let K=wU(Y);if(!K)return null;if(W.expanded||W.blockedReason)return K;let B=gU($,K,J);if(!B)return K;return Q?.(B),null}function uU($,J){let Q=null;return{match:xU($.map(v),J,(X)=>{Q=X}),relaxation:Q}}function dz($){let{subcommand:J,rest:Q}=X0($),W=J?.toLowerCase();if(!W)return!1;if(cz.has(W))return!0;if(W==="archive")return _1(Q).before.some((X)=>c(X,"--remote"));return W==="remote"&&rz(Q)}function rz($){return $.find((J)=>!iz(J))?.toLowerCase()==="update"}function iz($){return $==="-v"||c($,"--verbose")||c($,"--no-verbose")}import{isAbsolute as gI}from"node:path";var mU="rm -rf outside cwd is blocked. Retry deleting only explicit paths inside the current directory; escalate for anything outside it.",oz="rm -rf for non-temporary paths is blocked by the active safety policy. Retry deleting only explicit paths inside the current directory; escalate for anything outside it.",nz="rm -rf target contains shell variables that cannot be verified safely. Use literal paths within cwd, /tmp, /var/tmp, or $TMPDIR.",pU="rm -rf targeting root or home directory is extremely dangerous and always blocked.",sz="rm -rf in home directory is dangerous. Change to a project directory first.";function B4($,J){let Q=j2({...J,allowPaths:J.policy?.destructiveCommandAllowPaths,posixShell:!0}),W=$.map(v),X=W0(W),Y=RU(W),K=tz($);for(let B of K){let q=V3(B.word);if(X&&q.unsafeBraceExpansion){let U=k(lU({kind:"outside_anchored_cwd"},Q,J.policy),J.policy);if(U)return U;continue}for(let U of q.expandedTargets??[B.text]){let G={targetIsLiteral:q.expandedTargets!==void 0||q.targetIsLiteral,tmpdirWordSplittingProtected:q.tmpdirWordSplittingProtected};if(!Y&&Q.resolvedCwd&&I2(U,Q.resolvedCwd,Q.protectedGitMetadata,Y,Q.pathCanonicalizationContext))return D("rm.git-metadata",d1);if(Y&&!X){let H=J0(U,Q,G);if(H.kind==="root_or_home_target")return D("rm.recursive-force-root-or-home",pU);if(H.kind==="git_metadata_target")return D("rm.git-metadata",d1);continue}if(!X)continue;for(let H of az(U,Q,G)){let L=lU(H,Q,J.policy),Z=k(L,J.policy);if(Z)return Z}}}return null}function az($,J,Q){let W=J0($,J,Q);if(W.kind==="cwd_self_target")return[W,J0($,J,{...Q,skipCwdSelf:!0})];if(W.kind!=="home_cwd_target")return[W];let X=J0($,J,{...Q,skipHomeCwd:!0});if(X.kind!=="cwd_self_target")return[W,X];return[W,X,J0($,J,{...Q,skipHomeCwd:!0,skipCwdSelf:!0})]}function tz($){let J=[],Q=!1;for(let W of $.slice(1)){let X=v(W);if(!X)continue;if(X==="--"){Q=!0;continue}if(Q){J.push({text:X,word:W});continue}if(!X.startsWith("-"))J.push({text:X,word:W})}return J}function lU($,J,Q){switch($.kind){case"root_or_home_target":return D("rm.recursive-force-root-or-home",pU);case"git_metadata_target":return D("rm.git-metadata",d1);case"temp_target":return null;case"dynamic_target":if(!q1(Q,"rm.recursive-force-dynamic-target",J.strict))return null;return D("rm.recursive-force-dynamic-target",nz);case"home_cwd_target":return D("rm.recursive-force-home-cwd",sz);case"cwd_self_target":return D("rm.recursive-force-cwd-self",mU);case"within_anchored_cwd":if(q1(Q,"rm.recursive-force-paranoid",J.paranoid))return D("rm.recursive-force-paranoid",oz);return null;case"outside_anchored_cwd":return D("rm.recursive-force-outside-cwd",mU)}}var ez={bash:["O","o"],dash:["o"],ksh:["o"],sh:["o"],zsh:["o"]},dU=new Set(["--init-file","--rcfile"]),$I=["--init-file","--rcfile"],JI=new Map([["bash","BASH_ENV"],["dash","ENV"],["ksh","ENV"],["sh","ENV"]]);function O0($){for(let J=1;J<$.length;J++){let Q=$[J];if(!Q)continue;if(Q==="-c")return cU($,J,!0);if(Q.startsWith("-")&&Q.includes("c")&&!Q.startsWith("--")){let W=cU($,J,!1);if(W!==null)return W}}return null}function r1($){let J=l($[0]??"").toLowerCase();if(J==="zsh"||J==="ksh")return N0($).syntaxCheck;let Q=!1;for(let W of $.slice(1)){if(W==="--")return Q;if(W.startsWith("+")&&!W.startsWith("++")){if(W.slice(1).includes("n"))Q=!1;continue}if(!W.startsWith("-")||W.startsWith("--"))return Q;let X=W.slice(1);if(X.includes("n"))Q=!0;if(X.includes("c"))return Q}return Q}function cU($,J,Q){if($[J+1]==="--")return $[J+2]||null;let W=$[J+1];if(!W||!Q&&W.startsWith("-"))return null;return W}function rU($){let J=l($[0]??"").toLowerCase(),Q=QI($,J),W=JI.get(J)??null,X=Q.argvSource?.kind!=="absent";return{argvSource:J==="bash"?Q.argvSource:null,argvSourceApplies:J==="bash"&&Q.interactive&&Q.argvSource?.kind==="literal",envName:W,envSourceApplies:X&&(W==="BASH_ENV"?!Q.interactive:W==="ENV"&&Q.interactive)}}function QI($,J){let Q=N0($),W=Q.commandIndex??Q.scriptIndex??$.length,X=[],Y=!1,K=!0;for(let B=1;B<W;B++){let q=$[B];if(q===void 0||q==="--"||q==="-"||q[0]!=="-"&&q[0]!=="+")break;if(q.startsWith("--")){if(J==="bash"&&K?$I.find((L)=>q===L):void 0){let L=$[B+1];X.push(L===void 0?{kind:"absent"}:{kind:"literal",value:L}),B++;continue}let H=q.split("=",1)[0]??q;if(J==="bash"&&dU.has(H)&&!q.includes("="))B++;continue}if(J==="bash")K=!1;let U=iU(J,q,$[B+1],"startup");if(U.interactive)Y=q[0]==="-";B+=U.followingValues}return{argvSource:X.at(-1)??null,interactive:Y}}function iU($,J,Q,W){let X=!1,Y=0,K=!1,B=!1,q=!1;for(let U=1;U<J.length;U++){let G=J[U];if(G===void 0)break;if($==="ksh"&&G==="o"&&U+1<J.length){if(W==="argv"){let H=J.slice(U+1);if(J[0]==="-"&&(H==="c"||H[0]==="-"&&H.endsWith("c")))K=!0}break}if($==="ksh"&&G==="o"&&U+1===J.length&&(Q?.startsWith("-")||Q?.startsWith("+")))break;if($==="zsh"&&G==="o"&&U+1<J.length)break;if(W==="startup"&&G==="i")X=J[0]==="-";if(W==="argv"&&J[0]==="-"&&G==="c")K=!0;if(W==="argv"&&G==="n")q=J[0]==="-";if(W==="argv"&&G==="s")B=J[0]==="-";if(!ez[$]?.includes(G))continue;if(U+1===J.length)Y++;break}return{interactive:X,followingValues:Y,commandSelected:K,stdinMode:B,syntaxCheck:q}}function N0($){let J=l($[0]??"").toLowerCase(),Q=!1,W=!1,X=!1;for(let Y=1;Y<$.length;Y++){let K=$[Y];if(K===void 0)break;if(K==="--"){let q=Q&&$[Y+1]!==void 0?Y+1:null;return{command:q===null?null:$[q]??null,commandIndex:q,scriptIndex:!Q&&!W&&$[Y+1]!==void 0?Y+1:null,readsStdinAsCommands:!Q&&(W||$[Y+1]===void 0),syntaxCheck:X}}if(K==="-"||K[0]!=="-"&&K[0]!=="+")return{command:Q?K:null,commandIndex:Q?Y:null,scriptIndex:!Q&&!W&&K!=="-"?Y:null,readsStdinAsCommands:!Q&&(W||K==="-"),syntaxCheck:X};if(K.startsWith("--")){let q=K.split("=",1)[0]??K;if(J==="bash"&&dU.has(q)&&!K.includes("="))Y++;continue}let B=iU(J,K,$[Y+1],"argv");if(B.commandSelected)Q=!0;if(B.syntaxCheck)X=!0;if(B.stdinMode)W=!0;Y+=B.followingValues}return{command:null,commandIndex:null,scriptIndex:null,readsStdinAsCommands:!Q,syntaxCheck:X}}var t0={kind:"none"},P2={kind:"dynamic"},WI=new Set(["<","<<","<<-","<<<","<&","<>"]),nU=/\$(?:([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)|\{!?([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*))/g,XI=/^(?:[0-9]+|[@*])$/,YI=D2.maxWords,KI=D2.maxInputLength;function sU($){if(!$||l(r($.words[0]?.text??""))!=="printf")return;if($.words.some((X)=>X.provenance!=="literal"))return;let J=$.words.slice($.words[1]?.text==="--"?2:1),Q=J[0]?.text;if(Q===void 0)return"";let W=J.slice(1).map((X)=>X.text);if(Q==="%s")return W.join("");if(Q==="%s\\n"||Q===`%s
55
- `)return`${W.join(`
19
+ ${HE(e.intent??"manual_only")}`,a}function HE(e){switch(e){case"hard_stop":return"Do not retry this operation or attempt any workaround (other tools, flags, or paths). Report the block to the user and continue with the rest of the task.";case"use_alternative":return"Do not retry the blocked form. Continue the task using the safer alternative described above.";case"scope_down":return"Retry with a narrower, explicit target as described above. Escalate to the user if the broad operation is truly required.";case"manual_only":return"If this operation is truly needed, ask the user for explicit permission and have them run the command manually.";case"stop_and_explain":return"Do not brute-force variants. Simplify or restructure the command so it can be analyzed, or report the block to the user."}}function ay(e,t){return e.length>t?`${e.slice(0,t)}...`:e}function ly(e,t){if(e.decision.kind!=="deny")return;let n=t.includeEvidence?e.decision.evidence.find((r)=>r.kind==="command"):void 0;return{reason:e.decision.reason,ruleId:e.decision.ruleId,intent:e.decision.intent,command:n?.command,segment:n?.segment,toolName:t.toolName,...e.configFallback?{configWarning:e.configFallback.reason}:{}}}function zl(e={}){return{reason:Wi,intent:"stop_and_explain",command:e.command,segment:e.segment??e.command,toolName:e.toolName}}function uy(e){return cy({...e,redact:kt})}function dy(e){return kt(e instanceof Error?e.message:String(e))}import{basename as VE,dirname as qE,join as my}from"node:path";var Kn=Object.freeze({maxEnvironmentExpansionDepth:64,maxMissingSuffixComponents:256,maxRealpathAttempts:16384,maxProcessedCandidateBytes:4194304});class he extends Error{name="PathCanonicalizationLimitError";constructor(){super("Path canonicalization work limit exceeded.")}}function eo(){return{realpathAttempts:0,processedCandidateBytes:0,resolvedPaths:new Map}}function gn(e){return{...eo(),environment:e}}var Fi=new Set(["CC_SAFETY_NET_HOME","CLAUDE_CONFIG_DIR","CODEX_HOME","COPILOT_HOME","GEMINI_CLI_HOME","HOME","KIMI_CODE_HOME","KIMI_SHARE_DIR","OPENCODE_CONFIG","OPENCODE_CONFIG_DIR","PI_CODING_AGENT_DIR","ProgramData","TMPDIR","XDG_CONFIG_HOME","XDG_DATA_HOME"]);function Gi(e,t){return Nl(e,0,t)}function Nl(e,t,n){let r="",o=0;while(o<e.length){if(e[o]!=="$"){r+=e[o],o++;continue}if(e[o+1]==="{"){let s=Dl(e,o+2),a=KE(e,o,t);if(a===null){if(Fi.has(s))throw new he;r+=e.slice(o);break}let c=e.slice(o,a+1);r+=YE(c,t,n),o=a+1;continue}let i=Dl(e,o+1);if(!i){r+="$",o++;continue}r+=$l(i,n)??`$${i}`,o+=i.length+1}return r}function KE(e,t,n){let r=1;for(let o=t+2;o<e.length;o++){if(e[o]==="\\"){o++;continue}if(e[o]==="$"&&e[o+1]==="{"){if(r++,n+r>Kn.maxEnvironmentExpansionDepth)throw new he;o++;continue}if(e[o]!=="}")continue;if(r--,r===0)return o}return null}function YE(e,t,n){let r=e.slice(2,-1),o=Dl(r,0);if(!o)return e;let i=r.slice(o.length);if(!i)return $l(o,n)??e;let s=[":-",":+",":=",":?","-","+","=","?"].find((l)=>i.startsWith(l));if(!s){if(Fi.has(o))throw new he;return e}if(!Fi.has(o))return e;if(s.endsWith("="))throw new he;let a=$l(o,n),c=s.startsWith(":")?a!==null&&a!=="":a!==null;if(s.endsWith("?")&&!c)throw new he;if(s.endsWith("-")||s.endsWith("?"))return c?a??"":Nl(i.slice(s.length),t+1,n);return c?Nl(i.slice(s.length),t+1,n):""}function Dl(e,t){if(!/[A-Za-z_]/.test(e[t]??""))return"";let n=t+1;while(/[A-Za-z0-9_]/.test(e[n]??""))n++;return e.slice(t,n)}function Y(e,t,n=eo()){if(!e)return e;let r=n.resolvedPaths.get(e);if(r!==void 0)return r;let o=[],i=e;while(!0){if(n.realpathAttempts++,n.processedCandidateBytes+=Buffer.byteLength(i),n.realpathAttempts>Kn.maxRealpathAttempts||n.processedCandidateBytes>Kn.maxProcessedCandidateBytes)throw new he;let s=t.realpath(i);if(s!==null){let c=o.length===0?s:my(s,...o.reverse());return n.resolvedPaths.set(e,c),c}let a=qE(i);if(a===i){let c=o.length===0?i:my(i,...o.reverse());return n.resolvedPaths.set(e,c),c}if(o.length>=Kn.maxMissingSuffixComponents)throw new he;o.push(VE(i)),i=a}}function fy(e,t,n){let r=n.resolvedPaths.get(e);if(r!==void 0)return r;if(n.realpathAttempts++,n.processedCandidateBytes+=Buffer.byteLength(e),n.realpathAttempts>Kn.maxRealpathAttempts||n.processedCandidateBytes>Kn.maxProcessedCandidateBytes)throw new he;let o=t.realpath(e);if(o!==null)n.resolvedPaths.set(e,o);return o}function $l(e,t){if(!Fi.has(e))return null;if(e==="HOME")return t.env.get("HOME")??t.home;return t.env.get(e)??null}function N(e){return e.provenance==="command-substitution"?e.raw:e.text}function Yn(e,t){return e==="posix"?t:j(t.map((n)=>n.text))}function Zi(e,t){return e&&e.provenance!=="unknown"?e.provenance==="literal":!/[$`*?[\]]/.test(t)}function j(e){return e.map((t)=>({kind:"word",text:t,raw:t,span:{start:0,end:0},provenance:"unknown",quoted:!1,parts:[]}))}import{existsSync as Fl,lstatSync as rR,readFileSync as Hi,realpathSync as ro,statSync as no}from"node:fs";import{dirname as Gl,isAbsolute as Zl,join as Vi,resolve as qi}from"node:path";import{lstatSync as JE,realpathSync as XE}from"node:fs";import{homedir as QE,tmpdir as eR}from"node:os";var Be={realpath:(e)=>{try{return XE(e)}catch{return null}},entryKind:(e)=>{let t=JE(e,{throwIfNoEntry:!1});if(!t)return"missing";return t.isSymbolicLink()?"symlink":"present"}};function hn(){return process.env.HOME||QE()}function Ot(){return{env:new Map(Object.entries(process.env).flatMap(([e,t])=>t===void 0?[]:[[e,t]])),home:hn(),tmpdir:eR(),paths:Be}}var Ll=["GIT_DIR","GIT_WORK_TREE","GIT_COMMON_DIR","GIT_INDEX_FILE"],tR=new Set(Ll);var py=new Set(["GIT_CONFIG_GLOBAL","GIT_CONFIG_NOSYSTEM","GIT_CONFIG_SYSTEM","HOME","XDG_CONFIG_HOME"]),Bi=new Set(["GIT_SSH_COMMAND","GIT_SSH","GIT_SSH_VARIANT"]),nR=/^([A-Za-z_][A-Za-z0-9_]*)\+=/;function Ml(e){return tR.has(e)}function to(e){return e==="GIT_CONFIG_COUNT"||e==="GIT_CONFIG_PARAMETERS"||/^GIT_CONFIG_(KEY|VALUE)_\d+$/.test(e)}function Wl(e){return Ml(e)||py.has(e)||Bi.has(e)||to(e)}function Ue(e,t,n){return n?.has(e)?n.get(e):t.get(e)}function Ui(e,t){let n=Ue("GIT_CONFIG_COUNT",e,t);if(n===void 0)return{state:"absent"};if(n==="")return{state:"valid",count:0};if(!/^\d+$/.test(n))return{state:"invalid"};let r=Number(n);return Number.isSafeInteger(r)&&r<=1024?{state:"valid",count:r}:{state:"invalid"}}function ji(e,t,n){let o=e.match(nR)?.[1];if(!o||!Wl(o))return null;let i=e.indexOf("=");return{name:o,value:`${Ue(o,t,n)??""}${e.slice(i+1)}`}}function gy(e){return yy(e,Bi)}function hy(e){return yy(e,py)}function yy(e,t){if(!e)return!1;for(let n of e.keys())if(t.has(n))return!0;return!1}var ut=new Set(["-c","-C","--git-dir","--work-tree","--namespace","--super-prefix","--config-env"]);function Sy(e,t){return Ll.some((n)=>t?.has(n)||e.has(n))}function _y(e,t){if(!t)return{gitCwd:null,hasExplicitGitContext:!1};let n;try{n=ro(qi(t))}catch{return{gitCwd:null,hasExplicitGitContext:!1}}if(!wy(n))return{gitCwd:null,hasExplicitGitContext:!1};let r=!1,o=1;while(o<e.length){let i=e[o];if(!i)break;if(i==="--")break;if(!i.startsWith("-"))break;if(i==="-C"){let s=e[o+1];if(!s)return{gitCwd:null,hasExplicitGitContext:r};let a=vy(n,s);if(!a)return{gitCwd:null,hasExplicitGitContext:r};n=a,o+=2;continue}if(i.startsWith("-C")&&i.length>2){let s=vy(n,i.slice(2));if(!s)return{gitCwd:null,hasExplicitGitContext:r};n=s,o++;continue}if(i==="--git-dir"||i==="--work-tree"){r=!0,o+=2;continue}if(i.startsWith("--git-dir=")||i.startsWith("--work-tree=")){r=!0,o++;continue}if(ut.has(i))o+=2;else if(i.startsWith("-c")&&i.length>2)o++;else o++}return{gitCwd:n,hasExplicitGitContext:r}}function xy(e){let t=yR(e);if(!t)return!1;try{let n=rR(t);if(n.isSymbolicLink()||!n.isFile())return!1;let r=Bl(t);if(!r?.commonDir)return!1;if(!sR(r.gitDir,t))return!1;return aR(r.gitDir,Gl(t))}catch{return!1}}function Bl(e){try{let t=oR(e);if(!t)return null;let n=ro(Zl(t)?t:qi(Gl(e),t));if(!no(n).isDirectory())return null;return{gitDir:n,commonDir:iR(n)}}catch{return null}}function oR(e){let t=Hi(e,"utf-8").split(/\r?\n/,1)[0]?.trim()??"";if(!t.startsWith("gitdir:"))return null;return t.slice(7).trim()||null}function iR(e){try{let t=Hi(Vi(e,"commondir"),"utf-8").split(/\r?\n/,1)[0]?.trim();if(!t)return null;let n=ro(Zl(t)?t:qi(e,t));return no(n).isDirectory()?n:null}catch{return null}}function sR(e,t){let n=cR(e);return n===null?!1:Cy(e,n,t)}function aR(e,t){let n=lR(e);return n===null?!0:Cy(e,n,t)}function cR(e){let t=Vi(e,"gitdir");if(!Fl(t))return null;let n=Hi(t,"utf-8").split(/\r?\n/,1)[0]?.trim()??"";return n===""?null:n}function lR(e){let t=Vi(e,"config.worktree");return Fl(t)?pR(t):null}function Cy(e,t,n){return dR(uR(e,t),n)}function uR(e,t){return Zl(t)?t:qi(e,t)}function dR(e,t){try{return mR(e,t)}catch{return!1}}function mR(e,t){try{let n=no(e),r=no(t);if(n.ino!==0&&r.ino!==0&&n.dev===r.dev&&n.ino===r.ino)return!0}catch{}return by(e)===by(t)}function by(e){return fR(ro.native(e))}function fR(e){let t=e.replace(/^\\\\\?\\UNC\\/i,"//").replace(/^\\\\\?\\/i,"");if(t=t.replace(/\\/g,"/"),t.length>1&&t.endsWith("/"))t=t.slice(0,-1);return process.platform==="win32"?t.toLowerCase():t}function pR(e){let t=Hi(e,"utf-8"),n=!1,r=null;for(let o of t.split(/\r?\n/)){let i=o.trim();if(i===""||i.startsWith("#")||i.startsWith(";"))continue;if(i.startsWith("[")){n=/^\[core\]$/i.test(i);continue}if(!n)continue;let s=i.match(/^worktree\s*=\s*(.*)$/i);if(s)r=gR(s[1]??"")}return r}function gR(e){let t=e.trim();if(!t.startsWith('"')||!t.endsWith('"'))return t;return hR(t.slice(1,-1))}function hR(e){let t="";for(let n=0;n<e.length;n++){let r=e[n];if(r!=="\\"){t+=r;continue}let o=e[n+1];if(o===void 0){t+=r;continue}switch(o){case"\\":case'"':t+=o;break;case"n":t+=`
20
+ `;break;case"t":t+="\t";break;case"b":t+="\b";break;default:t+=`\\${o}`;break}n++}return t}function vy(e,t){try{let n=Vt(e,t,Be);return wy(n)?n:null}catch{return null}}function wy(e){try{return no(e).isDirectory()}catch{return!1}}function yR(e){try{return oo(ro(e))}catch{return null}}function oo(e){let t=e;while(!0){let n=Vi(t,".git");if(Fl(n))return n;let r=Gl(t);if(r===t)return null;t=r}}function Ul(e,t){return{value:e,work:t}}function C(e,t){if(e.work)e.work.units=Math.min(Number.MAX_SAFE_INTEGER,e.work.units+1);return e.value[t]}function ce(e){return e.value.length}function io(e,t,n=1){if(e)e.units=Math.min(Number.MAX_SAFE_INTEGER,e.units+t.length*n)}function Te(e,t){io(e,t)}function yn(e){if(!e)return!1;let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t===95||t>=97&&t<=122}function ee(e){if(!e)return!1;let t=e.charCodeAt(0);return t===9||t===10||t===11||t===12||t===13||t===32||t===160||t===65279||t===5760||t>=8192&&t<=8202||t===8232||t===8233||t===8239||t===8287||t===12288}function jl(e){return e===`
21
+ `||e==="\r"||e==="\u2028"||e==="\u2029"}function te(e,t,n){if(t+n.length>ce(e))return!1;for(let r=0;r<n.length;r++)if(C(e,t+r)!==n[r])return!1;return!0}function zt(e,t,n){return!yn(C(e,t-1))&&te(e,t,n)&&!yn(C(e,t+n.length))}function Nt(e,t){return yn(C(e,t-1))!==yn(C(e,t))}function fe(e){return e===`
22
+ `||e===";"||e==="&"||e==="|"}function Jn(e){return e==="|"||e===";"}function Ki(e,t,n){let r=Ul(e,n);if(t==="rm")return bR(r);if(t==="dd")return SR(r);return Ty(r,!0)}function Yi(e,t,n){let r=Ul(e,n);if(t==="rm")return _R(r);if(t==="reset-hard")return ky(r,"--ha","rd");if(t==="reset-merge")return ky(r,"--me","rge");if(t==="clean")return ER(r);if(t==="checkout")return PR(r);if(t==="push-force")return kR(r);if(t==="push-refspec")return AR(r);if(t==="push-delete")return TR(r);if(t==="branch")return IR(r);if(t==="tag")return NR(r);if(t==="restore")return DR(r);return Ty(r,!1)}function bR(e){let t=!1,n=!1,r=!1,o=-1;for(let i=0;i<=ce(e);i++){let s=C(e,i);if(!t){let c=C(e,i+2);if(zt(e,i,"rm")&&ee(c)&&c!==`
23
+ `)t=!0,i++;continue}let a=vR(e,i);if(s===`
24
+ `||a!==-1){if(t=!1,n=!1,r=!1,o=-1,a!==-1)i=a-1;continue}if(s===";"||s==="&"||s==="|"||i===ce(e)){if(o>=0){let c=Ey(e,o,i);n||=c.recursive,r||=c.force}if(n&&r)return!0;t=!1,n=!1,r=!1,o=-1;continue}if(ee(s)){if(o>=0){if(te(e,o,"--")&&i-o===2)t=!1,n=!1,r=!1;else{let c=Ey(e,o,i);if(n||=c.recursive,r||=c.force,n&&r)return!0}o=-1}continue}if(o<0)o=i}return!1}function vR(e,t){if(C(e,t)!=="\\"||C(e,t-1)==="\\")return-1;if(te(e,t,String.raw`\n`))return t+2;if(te(e,t,String.raw`\x0a`)||te(e,t,String.raw`\x0A`))return t+5;if(te(e,t,String.raw`\u000a`)||te(e,t,String.raw`\u000A`))return t+7;return te(e,t,String.raw`\012`)?t+4:-1}function Ey(e,t,n){if(Ry(e,t,n,"recursive"))return{recursive:!0,force:!1};if(Ry(e,t,n,"force"))return{recursive:!1,force:!0};if(C(e,t)!=="-"||C(e,t+1)==="-")return{recursive:!1,force:!1};let r=!1,o=!1;for(let i=t+1;i<n;i++){let s=C(e,i);r||=s==="r"||s==="R",o||=s==="f"||s==="F"}return{recursive:r,force:o}}function Ry(e,t,n,r){let o=n-t-2;if(o<1||o>r.length||!te(e,t,"--"))return!1;for(let i=0;i<o;i++)if(C(e,t+i+2)!==r[i])return!1;return!0}function SR(e){let t=!1;for(let n=0;n<ce(e);n++){if(fe(C(e,n))){t=!1;continue}if(zt(e,n,"dd")){t=!0,n++;continue}if(!t||!zt(e,n,"of")||!te(e,n,"of=/dev/"))continue;let r=n+8;if(r<ce(e)&&!ee(C(e,r))&&C(e,r)!=="'"&&C(e,r)!=='"')return!0}return!1}function _R(e){let t=!1,n=!1,r=!1;for(let o=0;o<=ce(e);){let i=C(e,o);if(o===ce(e)||fe(i)){t=!1,n=!1,r=!1,o++;continue}let s=CR(e,o);if(s>=0){if(xR(e,s))return!0;let a=s,c=!1;while(ee(C(e,a)))c||=C(e,a)===`
25
+ `,a++;if(c)n=!1,r=!1;t=!0,o=a;continue}if(!t){o++;continue}if(te(e,o,"--")&&(o===0||ee(C(e,o-1)))&&(!C(e,o+2)||ee(C(e,o+2))||fe(C(e,o+2)))){t=!1,n=!1,r=!1,o+=2;continue}if(n||=te(e,o,"--recursive")&&Nt(e,o+11)||Hl(e,o,"recursive"),r||=te(e,o,"--force")&&Nt(e,o+7)||Hl(e,o,"force"),n&&r)return!0;o++}return!1}function Hl(e,t,n){if(!te(e,t,"--"))return!1;let r=0;while(r<=n.length){let o=C(e,t+r+2);if(!o||ee(o)||fe(o))break;if(o!==n[r])return!1;r++}return r>0&&Nt(e,t+r+2)}function xR(e,t){let n=t,r=!1,o=!1;while(n<ce(e)){while(ee(C(e,n)))n++;let i=n;while(n<ce(e)&&!ee(C(e,n)))n++;if(C(e,i)!=="-"||n-i===2&&te(e,i,"--"))return!1;let s=Py(e,i,"recursive"),a=Py(e,i,"force");if(r&&a||o&&s)return!0;if(r||=s,o||=a,C(e,i+1)==="-")continue;let c=wR(e,i,n);if(c.combined||r&&c.forceAtBoundary||o&&c.recursiveAtBoundary)return!0;r||=c.recursive,o||=c.force}return!1}function Py(e,t,n){return te(e,t,`--${n}`)&&Nt(e,t+n.length+2)||Hl(e,t,n)}function CR(e,t){if(t>0&&yn(C(e,t-1)))return-1;let n=t;if(C(e,n)==="\\")n++;if(C(e,n)!=="r")return-1;if(n++,C(e,n)==="\\")n++;if(C(e,n)!=="m"||!ee(C(e,n+1)))return-1;return n+1}function wR(e,t,n){let r=!1,o=!1,i=!1,s=!1,a=!1;if(C(e,t)!=="-")return{recursive:r,force:o,recursiveAtBoundary:i,forceAtBoundary:s,combined:a};let c="";for(let l=t+1;l<n;l++){let u=C(e,l)??"",d=(u==="r"||u==="f")&&Nt(e,l+1);r||=u==="r",o||=u==="f",i||=u==="r"&&d,s||=u==="f"&&d,a||=(c==="r"&&u==="f"||c==="f"&&u==="r")&&d,c=u}return{recursive:r,force:o,recursiveAtBoundary:i,forceAtBoundary:s,combined:a}}function ky(e,t,n){return ao(e,"reset",Jn,!0,(r)=>C(e,r)==="-"&&Xn(e,r,t,n)?!0:r)}function ER(e){return ao(e,"clean",Jn,!0,(t)=>{if(C(e,t)!=="-")return t;if(Xn(e,t,"--fo","rce"))return!0;let n=so(e,t,Jn);for(let r=t+1;r<n;r++)if(C(e,r)==="f")return!0;return n-1})}function Ji(e,t,n){if(!zt(e,t,"git"))return null;let r=t+3;if(!ee(C(e,r)))return{commandEnd:-1,next:r};while(ee(C(e,r)))r++;while(r<ce(e)){if(fe(C(e,r)))return{commandEnd:-1,next:r};let o=so(e,r,fe);if(zt(e,r,n))return{commandEnd:r+n.length,next:o};if(C(e,r)!=="-")return{commandEnd:-1,next:o};let i=o-r===2&&te(e,r,"--"),s=RR(e,r,o);r=o;while(ee(C(e,r)))r++;if(i)return{commandEnd:zt(e,r,n)?r+n.length:-1,next:so(e,r,fe)};if(!s)continue;if(r>=ce(e)||fe(C(e,r)))return{commandEnd:-1,next:r};r=so(e,r,fe);while(ee(C(e,r)))r++}return{commandEnd:-1,next:r}}function RR(e,t,n){for(let r of ut)if(n-t===r.length&&te(e,t,r))return!0;return!1}function PR(e){return Ay(e,{command:"checkout",longPrefix:"--fo",longOptional:"rce",shortFlag:"f",excludedShortStarts:"bBU"})}function kR(e){return ao(e,"push",Jn,!0,(t)=>{if(C(e,t)!=="-")return t;if(C(e,t+1)==="f"&&!yn(C(e,t+2))&&!te(e,t+2,"-with-lease"))return!0;let n=Iy(e,t,"--fo","rce");if(n>=0&&!te(e,n,"-with-lease"))return!0;return t})}function AR(e){return ao(e,"push",fe,!1,(t)=>{if(ee(C(e,t))&&C(e,t+1)==="+"&&t+2<ce(e)&&!fe(C(e,t+2))&&!ee(C(e,t+2)))return!0;if(C(e,t)===":"&&C(e,t+1)==="+")return!0;return t})}function TR(e){return ao(e,"push",fe,!1,(t)=>{if(C(e,t)==="-"&&Xn(e,t,"--de","lete"))return!0;if(ee(C(e,t))&&C(e,t+1)===":"&&t+2<ce(e)&&!ee(C(e,t+2))&&!fe(C(e,t+2)))return!0;return t})}function IR(e){let t=!1,n=!1,r=!1;for(let o=0;o<=ce(e);o++){if(o===ce(e)||fe(C(e,o))){if(n&&r)return!0;t=!1,n=!1,r=!1;continue}if(!t){let a=Ji(e,o,"branch");if(a){t=a.commandEnd>=0,o=Math.max(o,(t?a.commandEnd:a.next)-1);continue}}if(!t||C(e,o)!=="-")continue;let i=so(e,o,fe),s=OR(e,o,i);if(n||=s.deletion,r||=s.force,n&&r)return!0;o=i-1}return!1}function OR(e,t,n){let r=!1,o=!1;for(let i=t;i<n;i++){if(C(e,i)!=="-")continue;if(Xn(e,i,"--de","lete"))r=!0;if(Xn(e,i,"--fo","rce"))o=!0;if(C(e,i+1)==="-")continue;let s=i+1,a=!1,c=!1,l=!1;while(s<n&&zR(C(e,s))){let u=C(e,s);a||=u==="d"||u==="D",c||=u==="f",l||=u==="D",s++}if(!Nt(e,s))continue;r||=a,o||=c||l}return{deletion:r,force:o}}function zR(e){if(!e)return!1;let t=e.charCodeAt(0);return t>=65&&t<=90||t>=97&&t<=122}function NR(e){return Ay(e,{command:"tag",longPrefix:"--de",longOptional:"lete",shortFlag:"d",excludedShortStarts:""})}function Ay(e,t){let n=[{outerActive:!1,shortActive:!1,hasShortFlag:!1,depth:0,quote:"",escaped:!1}];for(let r=0;r<ce(e);r++){let o=C(e,r),i=n[n.length-1];if(!i)return!1;let s=i.escaped;if(i.escaped=!s&&i.quote!=="'"&&o==="\\",!s&&o==="'"&&i.quote!=='"')i.quote=i.quote==="'"?"":"'";if(!s&&o==='"'&&i.quote!=="'")i.quote=i.quote==='"'?"":'"';if(o==="$"&&C(e,r+1)==="("&&(n.length===1||!s&&i.quote!=="'")){n.push({outerActive:!1,shortActive:!1,hasShortFlag:!1,depth:1,quote:"",escaped:!1}),r++;continue}if(!s&&!i.quote&&n.length>1&&o==="("){i.depth++;continue}if(!s&&!i.quote&&n.length>1&&o===")"){if(i.depth--,i.depth===0)n.pop();continue}if(ee(o))i.shortActive=!1,i.hasShortFlag=!1;if(!i.outerActive){let a=Ji(e,r,t.command);if(a){i.outerActive=a.commandEnd>=0&&ee(C(e,a.commandEnd)),i.shortActive=!1,i.hasShortFlag=!1,r=Math.max(r,(i.outerActive?a.commandEnd:a.next)-1);continue}}if(i.outerActive&&o==="-"){if(Xn(e,r,t.longPrefix,t.longOptional))return!0;i.shortActive||=!t.excludedShortStarts.includes(C(e,r+1)??"")}if(i.hasShortFlag||=i.shortActive&&o===t.shortFlag,i.hasShortFlag&&Nt(e,r+1))return!0;if(Jn(o))i.outerActive=!1}return!1}function ao(e,t,n,r,o){let i=!1;for(let s=0;s<ce(e);s++){let a=C(e,s),c=n(a);if(!i&&!c){let l=Ji(e,s,t);if(l){i=l.commandEnd>=0&&(!r||ee(C(e,l.commandEnd))),s=Math.max(s,(i?l.commandEnd:l.next)-1);continue}}if(i){let l=o(s);if(l===!0)return!0;for(let u=s;u<=l;u++)if(n(C(e,u)))i=!1;s=l}if(c)i=!1}return!1}function DR(e){let t=!1;for(let n=0;n<ce(e);n++){if(jl(C(e,n))){if(t)return!0;t=!1;continue}if(!t){let r=Ji(e,n,"restore");if(r){t=r.commandEnd>=0,n=Math.max(n,(t?r.commandEnd:r.next)-1);continue}}if(t&&C(e,n)==="-"&&C(e,n+1)==="-"&&(te(e,n+2,"staged")||te(e,n+2,"help")))t=!1}return t}function Ty(e,t){let n=!1;for(let r=0;r<ce(e);r++){let o=C(e,r),i=t?jl(o):fe(o);if(n&&ee(o)&&C(e,r+1)==="-"&&zt(e,r+2,"delete"))return!0;if(i){n=!1;continue}if(zt(e,r,"find"))n=!0,r+=3}return!1}function so(e,t,n){let r=t;while(r<ce(e)&&!ee(C(e,r))&&!n(C(e,r)))r++;return r}function Iy(e,t,n,r){if(!te(e,t,n))return-1;let o=t+n.length;for(let i=0;i<r.length&&C(e,o)===r[i];i++)o++;return Nt(e,o)?o:-1}function Xn(e,t,n,r){return Iy(e,t,n,r)>=0}var $R=["git.ssh-env","git.alias-config","git.checkout-force","git.checkout-double-dash","git.checkout-ref-path","git.checkout-pathspec-from-file","git.checkout-ambiguous","git.switch-discard-changes","git.switch-force","git.restore-worktree","git.restore-unstaged","git.reset-hard","git.reset-merge","git.clean-force","git.rm-force","git.push-force","git.push-delete","git.push-mirror","git.branch-force-delete","git.rebase-abort","git.merge-abort","git.tag-delete","git.reflog-delete","git.stash-drop","git.stash-clear","git.worktree-remove-force","rm.recursive-force-root-or-home","rm.git-metadata","rm.recursive-force-dynamic-target","rm.recursive-force-home-cwd","rm.recursive-force-cwd-self","rm.recursive-force-outside-cwd","rm.recursive-force-paranoid","powershell.remove-item-root-or-home","powershell.remove-item-recursive-force-root-or-home","powershell.remove-item-git-metadata","powershell.remove-item-recursive-force-dynamic-target","powershell.remove-item-recursive-force-home-cwd","powershell.remove-item-recursive-force-cwd-self","powershell.remove-item-recursive-force-outside-cwd","powershell.remove-item-recursive-force-paranoid","powershell.remove-item-pipeline-dynamic-target","find.delete","find.delete-git-metadata","find.exec-rm-recursive-force","dd.device-write","mkfs.device","shred.target","interpreter.dangerous-command","interpreter.one-liner-paranoid","awk.system-dynamic","xargs.rm-recursive-force-dynamic","xargs.shell-dynamic","parallel.rm-recursive-force-dynamic","parallel.shell-dynamic","parallel.command-stream-dynamic","shell.dynamic-structure","shell.dynamic-executable","raw-text.dangerous-command"],Xi=new Set($R),Qi=[{id:"git.ssh-env",category:"Git",label:"Git SSH environment override",description:"Blocks Git network operations with SSH environment overrides.",example:'GIT_SSH_COMMAND="./ssh-wrapper" git push',intent:"manual_only"},{id:"git.alias-config",category:"Git",label:"Git command-line alias",description:"Blocks command-line Git aliases that cannot be safely resolved.",example:"git -c alias.wipe='!rm -rf /' wipe",intent:"manual_only"},{id:"git.checkout-force",category:"Git",label:"Git checkout force",description:"Blocks forced checkout operations that discard local changes.",example:"git checkout --force main",intent:"use_alternative"},{id:"git.checkout-double-dash",category:"Git",label:"Git checkout path restore",description:"Blocks checkout path restores after --.",example:"git checkout -- src/app.ts",intent:"use_alternative"},{id:"git.checkout-ref-path",category:"Git",label:"Git checkout ref and path",description:"Blocks checkout forms that mix a ref and path restore.",example:"git checkout HEAD -- src/app.ts",intent:"use_alternative"},{id:"git.checkout-pathspec-from-file",category:"Git",label:"Git checkout pathspec file",description:"Blocks checkout pathspec loading from a file.",example:"git checkout --pathspec-from-file=paths.txt",intent:"use_alternative"},{id:"git.checkout-ambiguous",category:"Git",label:"Git checkout ambiguous targets",description:"Blocks ambiguous checkout arguments that may restore paths.",example:"git checkout main src/app.ts",intent:"use_alternative"},{id:"git.switch-discard-changes",category:"Git",label:"Git switch discard changes",description:"Blocks branch switches that explicitly discard local changes.",example:"git switch --discard-changes main",intent:"use_alternative"},{id:"git.switch-force",category:"Git",label:"Git switch force",description:"Blocks forced branch switches.",example:"git switch --force main",intent:"use_alternative"},{id:"git.restore-worktree",category:"Git",label:"Git restore worktree",description:"Blocks worktree restore operations.",example:"git restore --worktree src/app.ts",intent:"use_alternative"},{id:"git.restore-unstaged",category:"Git",label:"Git restore unstaged",description:"Blocks unstaged restore operations.",example:"git restore src/app.ts",intent:"use_alternative"},{id:"git.reset-hard",category:"Git",label:"Git reset hard",description:"Blocks hard resets.",example:"git reset --hard",intent:"use_alternative"},{id:"git.reset-merge",category:"Git",label:"Git reset merge",description:"Blocks merge resets.",example:"git reset --merge",intent:"use_alternative"},{id:"git.clean-force",category:"Git",label:"Git clean force",description:"Blocks forced clean operations.",example:"git clean -fd",intent:"use_alternative"},{id:"git.rm-force",category:"Git",label:"Git rm force",description:"Blocks forced removal of tracked files from the working tree.",example:"git rm -rf .",intent:"use_alternative"},{id:"git.push-force",category:"Git",label:"Git push force",description:"Blocks force pushes.",example:"git push --force origin main",intent:"use_alternative"},{id:"git.push-delete",category:"Git",label:"Git push delete",description:"Blocks remote ref deletion through push.",example:"git push --delete origin old-branch",intent:"manual_only"},{id:"git.push-mirror",category:"Git",label:"Git push mirror",description:"Blocks mirror pushes that can force-update or delete remote refs.",example:"git push --mirror origin",intent:"manual_only"},{id:"git.branch-force-delete",category:"Git",label:"Git branch force delete",description:"Blocks forced branch deletion.",example:"git branch -D old-branch",intent:"use_alternative"},{id:"git.rebase-abort",category:"Git",label:"Git rebase abort",description:"Blocks rebase abort operations.",example:"git rebase --abort",intent:"use_alternative"},{id:"git.merge-abort",category:"Git",label:"Git merge abort",description:"Blocks merge abort operations.",example:"git merge --abort",intent:"use_alternative"},{id:"git.tag-delete",category:"Git",label:"Git tag delete",description:"Blocks tag deletion.",example:"git tag --delete v1.0.0",intent:"manual_only"},{id:"git.reflog-delete",category:"Git",label:"Git reflog delete",description:"Blocks reflog deletion.",example:"git reflog delete HEAD@{1}",intent:"manual_only"},{id:"git.stash-drop",category:"Git",label:"Git stash drop",description:"Blocks dropping stash entries.",example:"git stash drop stash@{0}",intent:"use_alternative"},{id:"git.stash-clear",category:"Git",label:"Git stash clear",description:"Blocks clearing all stash entries.",example:"git stash clear",intent:"manual_only"},{id:"git.worktree-remove-force",category:"Git",label:"Git worktree force remove",description:"Blocks forced worktree removal.",example:"git worktree remove --force ../feature",intent:"use_alternative"},{id:"rm.recursive-force-root-or-home",category:"Filesystem",label:"rm -rf root or home",description:"Blocks recursive forced removal of root or home paths.",example:"rm -rf /",intent:"hard_stop",catastrophic:!0},{id:"rm.git-metadata",category:"Filesystem",label:"rm Git metadata",description:"Blocks removal of protected Git metadata and hooks.",example:"rm -rf .git",intent:"hard_stop",catastrophic:!0},{id:"rm.recursive-force-dynamic-target",category:"Filesystem",label:"rm -rf dynamic target",description:"Blocks recursive forced removal with dynamic targets in strict mode.",example:'rm -rf "$target"',intent:"scope_down",activationCapability:"fail_closed"},{id:"rm.recursive-force-home-cwd",category:"Filesystem",label:"rm -rf from home cwd",description:"Blocks recursive forced removal while working in home.",example:'cd "$HOME" && rm -rf build',intent:"scope_down"},{id:"rm.recursive-force-cwd-self",category:"Filesystem",label:"rm -rf current directory",description:"Blocks recursive forced removal of the current directory.",example:"rm -rf .",intent:"scope_down"},{id:"rm.recursive-force-outside-cwd",category:"Filesystem",label:"rm -rf outside cwd",description:"Blocks recursive forced removal outside the original cwd.",example:"rm -rf ../outside",intent:"scope_down"},{id:"rm.recursive-force-paranoid",category:"Filesystem",label:"rm -rf paranoid mode",description:"Blocks non-temp recursive forced removal when paranoid rm is enabled.",example:"rm -rf ./cache",intent:"scope_down",activationCapability:"paranoid_rm"},{id:"powershell.remove-item-root-or-home",category:"PowerShell",label:"Remove-Item root or home",description:"Blocks PowerShell Remove-Item targeting root or home paths.",example:"Remove-Item C:\\",intent:"hard_stop",catastrophic:!0},{id:"powershell.remove-item-recursive-force-root-or-home",category:"PowerShell",label:"Remove-Item recursive force root or home",description:"Blocks recursive forced PowerShell removal of root or home paths.",example:"Remove-Item C:\\ -Recurse -Force",intent:"hard_stop",catastrophic:!0},{id:"powershell.remove-item-git-metadata",category:"PowerShell",label:"Remove-Item Git metadata",description:"Blocks PowerShell removal of protected Git metadata and hooks.",example:"Remove-Item .git -Recurse -Force",intent:"hard_stop",catastrophic:!0},{id:"powershell.remove-item-recursive-force-dynamic-target",category:"PowerShell",label:"Remove-Item recursive force dynamic target",description:"Blocks recursive forced PowerShell removal with dynamic targets in strict mode.",example:"Remove-Item $target -Recurse -Force",intent:"scope_down",activationCapability:"fail_closed"},{id:"powershell.remove-item-recursive-force-home-cwd",category:"PowerShell",label:"Remove-Item recursive force from home cwd",description:"Blocks recursive forced PowerShell removal while working in home.",example:"Set-Location $HOME; Remove-Item ./build -Recurse -Force",intent:"scope_down"},{id:"powershell.remove-item-recursive-force-cwd-self",category:"PowerShell",label:"Remove-Item recursive force current directory",description:"Blocks recursive forced PowerShell removal of the current directory.",example:"Remove-Item . -Recurse -Force",intent:"scope_down"},{id:"powershell.remove-item-recursive-force-outside-cwd",category:"PowerShell",label:"Remove-Item recursive force outside cwd",description:"Blocks recursive forced PowerShell removal outside the original cwd.",example:"Remove-Item ../outside -Recurse -Force",intent:"scope_down"},{id:"powershell.remove-item-recursive-force-paranoid",category:"PowerShell",label:"Remove-Item recursive force paranoid mode",description:"Blocks non-temp recursive forced PowerShell removal when paranoid rm is enabled.",example:"Remove-Item ./cache -Recurse -Force",intent:"scope_down",activationCapability:"paranoid_rm"},{id:"powershell.remove-item-pipeline-dynamic-target",category:"PowerShell",label:"Remove-Item pipeline dynamic target",description:"Blocks PowerShell Remove-Item with unverifiable pipeline input in strict mode.",example:"Get-ChildItem . -Recurse | Remove-Item -Force",intent:"scope_down",activationCapability:"fail_closed"},{id:"find.delete",category:"Filesystem",label:"find delete",description:"Blocks unsafe find -delete operations.",example:"find . -delete",intent:"scope_down"},{id:"find.delete-git-metadata",category:"Filesystem",label:"find delete Git metadata",description:"Blocks find -delete operations selecting protected Git metadata and hooks.",example:"find .git -delete",intent:"hard_stop",catastrophic:!0},{id:"find.exec-rm-recursive-force",category:"Filesystem",label:"find exec rm -rf",description:"Blocks find -exec rm -rf operations.",example:"find . -exec rm -rf {} +",intent:"scope_down"},{id:"dd.device-write",category:"Filesystem",label:"dd device write",description:"Blocks dd writing to a /dev device.",example:"dd if=/dev/zero of=/dev/sda",intent:"manual_only"},{id:"mkfs.device",category:"Filesystem",label:"mkfs device format",description:"Blocks mkfs formatting a /dev device.",example:"mkfs.ext4 /dev/sda1",intent:"manual_only"},{id:"shred.target",category:"Filesystem",label:"shred target",description:"Blocks shred against any target, including shred --help and shred --version.",example:"shred -u secret.txt",intent:"use_alternative"},{id:"interpreter.dangerous-command",category:"Execution",label:"Interpreter dangerous command",description:"Blocks interpreter one-liners containing dangerous commands.",example:`python -c "import os; os.system('rm -rf /')"`,intent:"use_alternative"},{id:"interpreter.one-liner-paranoid",category:"Execution",label:"Interpreter one-liner paranoid mode",description:"Blocks interpreter one-liners when paranoid interpreters is enabled.",example:'python -c "print(1)"',intent:"use_alternative",activationCapability:"paranoid_interpreters"},{id:"awk.system-dynamic",category:"Execution",label:"Awk dynamic system call",description:"Blocks awk system calls that cannot be safely analyzed.",example:"awk '{ system($0) }'",intent:"stop_and_explain"},{id:"xargs.rm-recursive-force-dynamic",category:"Execution",label:"xargs dynamic rm -rf",description:"Blocks xargs rm -rf with dynamic input.",example:"printf / | xargs rm -rf",intent:"scope_down"},{id:"xargs.shell-dynamic",category:"Execution",label:"xargs dynamic shell",description:"Blocks xargs shell execution with dynamic input.",example:"xargs r$(printf m) -rf",intent:"scope_down"},{id:"parallel.rm-recursive-force-dynamic",category:"Execution",label:"parallel dynamic rm -rf",description:"Blocks parallel rm -rf with dynamic input.",example:"printf / | parallel rm -rf",intent:"scope_down"},{id:"parallel.shell-dynamic",category:"Execution",label:"parallel dynamic shell",description:"Blocks parallel shell execution with dynamic input.",example:"parallel r$(printf m) -rf ::: child",intent:"scope_down"},{id:"parallel.command-stream-dynamic",category:"Execution",label:"parallel dynamic command stream",description:"Blocks parallel command streams from dynamic input.",example:"parallel --dry-run",intent:"scope_down"},{id:"shell.dynamic-structure",category:"Execution",label:"Dynamic command structure",description:"Blocks guarded subcommands and options assembled from substitution output in strict mode.",example:"git reset $(printf --hard)",intent:"stop_and_explain",activationCapability:"fail_closed"},{id:"shell.dynamic-executable",category:"Execution",label:"Dynamic executable name",description:"Blocks executable names assembled from command substitution output in strict mode.",example:"$(printf r)m -rf /",intent:"manual_only",activationCapability:"fail_closed"},{id:"raw-text.dangerous-command",category:"Execution",label:"Raw text dangerous command",description:"Blocks dangerous commands detected in raw command text.",example:"git reset --hard 'unterminated",intent:"stop_and_explain"}],LR=new Map(Qi.map((e)=>[e.id,e.intent])),Oy=new Set(Qi.filter((e)=>e.catastrophic).map((e)=>e.id));function S(e,t){return{id:e,reason:t,intent:LR.get(e)??"manual_only"}}function O(e,t){if(!e)return null;if(Oy.has(e.id))return e;if(t?.destructiveCommandProtectionEnabled===!1)return null;let n=t?.effectiveDestructiveCommandRules[e.id];return n&&!n.enabled?null:e}function ue(e,t,n){if(Oy.has(t))return!0;if(e?.destructiveCommandProtectionEnabled===!1)return!1;return e?.effectiveDestructiveCommandRules[t]?.enabled??n}function zy(e,t){return Object.freeze(Object.fromEntries(Qi.map((n)=>{let r=n.activationCapability?t[n.activationCapability]:void 0,o=r?.enabled??!0,i=e.destructiveCommandRuleOverrides[n.id],s=n.catastrophic?{enabled:!0,inheritedEnabled:!0,changesInherited:!1,source:"catastrophic",...i?{override:i}:{}}:e.destructiveCommandProtectionEnabled?i?{enabled:i==="on",inheritedEnabled:o,changesInherited:i==="on"!==o,source:"rule_override",...n.activationCapability?{activationCapability:n.activationCapability}:{},override:i}:{enabled:o,inheritedEnabled:o,changesInherited:!1,source:r?.source??"built_in_default",...n.activationCapability?{activationCapability:n.activationCapability}:{}}:{enabled:!1,inheritedEnabled:o,changesInherited:!1,source:"master_disabled",...n.activationCapability?{activationCapability:n.activationCapability}:{},...i?{override:i}:{}};return[n.id,Object.freeze(s)]})))}function Ny(e,t){return Object.freeze({...e,effectiveDestructiveCommandRules:zy(e,t)})}function Dt(e,t){io(t,e,2);let n=e.toLowerCase(),r=n.trimStart(),o=r.startsWith("echo ")||r.startsWith("rg "),i=[{scan:"rm",label:"rm -rf"},{scan:"reset-hard",label:"git reset --hard"},{scan:"reset-merge",label:"git reset --merge"},{scan:"clean",label:"git clean -f"},{scan:"checkout",label:"git checkout --force"},{scan:"push-force",label:"git push --force"},{scan:"push-refspec",label:"git push --force"},{scan:"push-delete",label:"git push delete"},{scan:"branch",label:"git branch -D",caseSensitive:!0},{scan:"tag",label:"git tag -d"},{regex:/\bgit\s+stash\s+(drop|clear)\b/,label:"git stash drop/clear"},{regex:/\bgit\s+checkout\s+--\s/,label:"git checkout --"},{scan:"restore",label:"git restore without --staged"},{scan:"find",label:"find -delete",skipForEchoRg:!0},{regex:/\bdd\b[^\n|;&]*\bof=\/dev\/\S/,label:"dd of=/dev/",skipForEchoRg:!0},{regex:/\bmkfs(?:\.[a-z0-9_-]+)?\s+\/dev\/\S/,label:"mkfs /dev/",skipForEchoRg:!0},{regex:/\bshred\b\s+\S/,label:"shred",skipForEchoRg:!0}];for(let s of i){if(s.skipForEchoRg&&o)continue;let a=s.caseSensitive?e:n;if(s.regex)Te(t,a);if((s.regex?.test(a)??!1)||s.scan&&Yi(a,s.scan,t))return S("raw-text.dangerous-command",`Unparseable command text contains a destructive pattern (${s.label}). Rewrite as a plain, parseable command so it can be analyzed.`)}return null}var MR=/^[A-Za-z_][A-Za-z0-9_]*=/;function $y(e,t,n){let r=e.words[0];if(!t||!r||e.words.length!==1||e.dialect!=="posix")return!1;if(!r.quoted||r.provenance!=="literal")return!1;let o=/^([A-Za-z_][A-Za-z0-9_]*)=/.exec(r.text)?.[1];if(!o)return!1;io(n,t.source,2);let i={anchored:new RegExp(`^\\$\\{?${o}(?![A-Za-z0-9_])`),loose:new RegExp(`\\$\\{?${o}(?![A-Za-z0-9_])`)};return Ly(t.nodes,r,i)}function Ly(e,t,n){return e.every((r)=>{if(r.kind==="connector")return!0;if(r.kind==="group"||r.kind==="function")return Ly(r.body.nodes,t,n);if(r.kind==="unknown")return!n.loose.test(r.source);return WR(r,t,n)})}function WR(e,t,n){if(e.nested.some((o)=>n.loose.test(o.source)))return!1;let r=e.words.findIndex((o)=>!MR.test(o.text));return e.words.every((o,i)=>o===t||Dy(o.raw,n.anchored,i!==r))&&e.redirections.every((o)=>(!o.heredoc||o.heredoc.quotedDelimiter||!n.loose.test(o.heredoc.body))&&(!o.target||Dy(o.target.raw,n.anchored,!0)))}function Dy(e,t,n){let r=!1,o=!1;for(let i=0;i<e.length;i++){let s=e[i];if(s==="\\"&&!r){i++;continue}if(!o&&s==="'"){r=!r;continue}if(!r&&s==='"'){o=!o;continue}if(r||s!=="$")continue;if(!t.test(e.slice(i)))continue;if(!o||!n)return!1}return!0}var My=Object.freeze({maxDerivedTokens:16384}),Wy="Command analysis exceeds CC Safety Net's derived-command work limit. Reduce nested or embedded command complexity and retry.";class Ie extends Error{constructor(){super("Command analysis exceeds CC Safety Net's derived-command work limit. Reduce nested or embedded command complexity and retry.");this.name="DerivedCommandWorkLimitError"}}function es(){return{derivedTokens:0}}function Je(e,t){if(!Number.isSafeInteger(e.derivedTokens)||e.derivedTokens<0||e.derivedTokens>My.maxDerivedTokens||!Number.isSafeInteger(t)||t<0||t>My.maxDerivedTokens-e.derivedTokens)throw new Ie;e.derivedTokens+=t}import{isAbsolute as FR,resolve as Fy}from"node:path";var Gy=64;function co(e,t,n){let r=FR(e)?Fy(e):t?Fy(t,e):void 0;if(!r)return;try{return Y(r,n)}catch{return r}}function Zy(e){return!["/dev","/proc","/sys"].some((t)=>e===t||e.startsWith(`${t}/`))}function H(e){return G(e).toLowerCase()}function G(e){return e.split(/[\\/]/).pop()?.replace(/\.exe$/i,"")??e}var ts=10,Qn=20,bn=/^[a-zA-Z][a-zA-Z0-9_-]*$/,er=256,de=new Set(["bash","sh","zsh","ksh","dash","fish","csh","tcsh"]),By=new Set(["python","python3","python2","node","ruby","perl"]),Uy=/^python(?:[23](?:\.\d+)*)?$/,ns=new Set(["echo","printf","cat","head","tail","less","more","grep","rg","ag","ack","sed","awk","cut","tr","sort","uniq","wc","tee","man","help","info","type","which","whereis","whatis","apropos","file","stat","ls","ll","dir","tree","pwd","date","cal","uptime","whoami","id","groups","hostname","uname","env","printenv","set","export","alias","history","jobs","fg","bg","test","true","false","read","return","exit","break","continue","shift","wait","trap","basename","dirname","realpath","readlink","md5sum","sha256sum","base64","xxd","od","hexdump","strings","diff","cmp","comm","join","paste","column","fmt","fold","nl","pr","expand","unexpand","rev","tac","shuf","seq","yes","sleep","logger","write","wall","mesg","notify-send"]);var vn="Interpreter code contains a dangerous command. Run the underlying command directly so it can be analyzed, or use the safer alternative for that command.",tr="Interpreter one-liners are blocked by the active safety policy. Write the code to a script file and run it, or run the equivalent shell command directly.",rs=new Map([["python",new Set(["-c"])],["node",new Set(["-e","--eval"])],["ruby",new Set(["-e"])],["perl",new Set(["-e","-E"])]]),GR=new Set(["-p","--print"]),ZR=new Map([["python",new Set(["c"])],["node",new Set(["e"])],["ruby",new Set(["e"])],["perl",new Set(["e","E"])]]),BR=new Map([["python",new Set(["W","X"])],["node",new Set(["C","r"])],["ruby",new Set(["C","E","F","I","r"])],["perl",new Set(["F","I","M","m"])]]),UR=new Map([["ruby",new Set(["0","K","W","x"])],["perl",new Set(["0","C","D","V","d","i","l","x"])]]),jR=new Map([["python",new Set(["m"])]]),HR=new Map([["node",new Set(["--allow-fs-read","--allow-fs-write","--conditions","--cpu-prof-dir","--cpu-prof-interval","--cpu-prof-name","--debug-port","--diagnostic-dir","--disable-proto","--disable-warning","--dns-result-order","--env-file","--env-file-if-exists","--experimental-package-map","--experimental-test-isolation","--experimental-test-tag-filter","--heap-prof-dir","--heap-prof-interval","--heap-prof-name","--heapsnapshot-near-heap-limit","--heapsnapshot-signal","--icu-data-dir","--input-type","--inspect-port","--inspect-publish-uid","--localstorage-file","--max-http-header-size","--max-old-space-size-percentage","--network-family-autoselection-attempt-timeout","--openssl-config","--redirect-warnings","--report-dir","--report-directory","--report-filename","--report-signal","--secure-heap","--secure-heap-min","--test-concurrency","--test-coverage-branches","--test-coverage-exclude","--test-coverage-functions","--test-coverage-include","--test-coverage-lines","--test-global-setup","--test-isolation","--test-name-pattern","--test-random-seed","--test-reporter","--test-reporter-destination","--test-rerun-failures","--test-shard","--test-skip-pattern","--test-timeout","--title","--tls-cipher-list","--tls-keylog","--trace-event-categories","--trace-event-file-pattern","--trace-require-module","--unhandled-rejections","--use-largepages","--v8-pool-size","--watch-kill-signal"])],["python",new Set(["--check-hash-based-pycs"])],["ruby",new Set(["--backtrace-limit","--crash-report","--disable","--enable","--encoding","--external-encoding","--internal-encoding","--parser"])]]),VR=new Set(["always","default","never"]),qR=new Set(["--backtrace-limit","--crash-report","--disable","--enable"]),KR=/\\\r?\n/g,YR=new Map([["python",[{selector:"-c",kind:"inline-code",valueForm:"attached-or-separate"},{selector:"-m",kind:"module-file",valueForm:"attached-or-separate"}]],["node",[{selector:"-e",kind:"inline-code",valueForm:"separate-only"},{selector:"--eval",kind:"inline-code",valueForm:"equals-or-separate"},{selector:"-p",kind:"inline-code",valueForm:"separate-only"},{selector:"--print",kind:"inline-code",valueForm:"separate-only"},{selector:"-r",kind:"module-file",valueForm:"separate-only"},{selector:"--require",kind:"module-file",valueForm:"equals-or-separate"},{selector:"--import",kind:"module-file",valueForm:"equals-or-separate"},{selector:"--loader",kind:"module-file",valueForm:"equals-or-separate"},{selector:"--experimental-loader",kind:"module-file",valueForm:"equals-or-separate"}]],["ruby",[{selector:"-e",kind:"inline-code",valueForm:"attached-or-separate"},{selector:"-r",kind:"module-file",valueForm:"attached-or-separate"}]],["perl",[{selector:"-e",kind:"inline-code",valueForm:"attached-or-separate"},{selector:"-E",kind:"inline-code",valueForm:"attached-or-separate"},{selector:"-M",kind:"module-file",valueForm:"attached-only"},{selector:"-m",kind:"module-file",valueForm:"attached-only"}]]]);function os(e){return ss(e).code}function is(e){return ss(e).sources}function Hy(e){return YR.get(cs(e))??[]}function ss(e){let t=cs(e[0]??"");if(!rs.has(t))return{code:null,sources:[],optionsOpen:!1};let n=[],r=[],o=!0;for(let i=1;i<e.length;i++){let s=e[i];if(s===void 0)break;if(s==="--")return Xe(t,n,r,o,e[i+1]===void 0?void 0:i+1,e[i+1]);if(s===""||s==="-"||!s.startsWith("-"))return Xe(t,n,r,o,i,s);if(t==="node"&&GR.has(s)){let d=e[i+1];if(d===void 0)return Xe(t,n,r,o);if(d.startsWith("-"))continue;n.push({tokenIndex:i+1,value:d}),r.push({tokenIndex:i+1,kind:"inline-code",value:d}),i++;continue}if(XR(t,s)){let d=e[i+1];if(d===void 0)return Xe(t,n,r,o);if(n.push({tokenIndex:i+1,value:d}),r.push({tokenIndex:i+1,kind:"inline-code",value:d}),t==="python")return Xe(t,n,r,o);i++;continue}let a=/^--eval=(.*)$/s.exec(s);if(QR(t)&&a){let d=a[1]??"";n.push({tokenIndex:i,value:d}),r.push({tokenIndex:i,kind:"inline-code",value:d});continue}if(t==="node"){let d=JR(s);if(d){if(d.attached){if(o&&=d.value!=="",d.value!=="")r.push({tokenIndex:i,kind:"module-file",value:d.value});continue}let f=e[i+1];if(f===void 0||f.startsWith("-"))return o=!1,Xe(t,n,r,o);r.push({tokenIndex:i+1,kind:"module-file",value:f}),i++;continue}}if(t==="python"&&s.startsWith("--check-hash-based-pycs=")||t==="node"&&(s==="--conditions="||s==="--diagnostic-dir="||s==="--title=")||t==="ruby"&&(s==="--disable="||s==="--enable="))return Xe(t,n,r,o);if(HR.get(t)?.has(s)){let d=e[i+1];if(d===void 0||d.startsWith("-")&&!(t==="ruby"&&qR.has(s))||t==="python"&&!VR.has(d))return Xe(t,n,r,o);i++;continue}if(s.startsWith("--"))continue;let c,l=!1;for(let d=1;d<s.length;d++){let f=s[d];if(f===void 0)break;if(jR.get(t)?.has(f)){let m=s.slice(d+1),p=m||e[i+1];if(p!==void 0)r.push({tokenIndex:m?i:i+1,kind:"module-file",value:p});return Xe(t,n,r,o)}if(ZR.get(t)?.has(f)){c=s.slice(d+1)||e[i+1],l=d+1===s.length;break}if(t==="node"&&f==="r"){if(s==="-r"){let m=e[i+1];if(o&&=m!==void 0&&!m.startsWith("-"),o&&m!==void 0)r.push({tokenIndex:i+1,kind:"module-file",value:m});i++}else o=!1;break}if(t==="ruby"&&f==="r"){let m=s.slice(d+1),p=m||e[i+1];if(o&&=p!==void 0,p!==void 0)r.push({tokenIndex:m?i:i+1,kind:"module-file",value:p});if(!m)i++;break}if(t==="perl"&&(f==="M"||f==="m")){let m=s.slice(d+1);if(m)r.push({tokenIndex:i,kind:"module-file",value:m});else if(o=!1,d+1===s.length)i++;break}if(BR.get(t)?.has(f)){if(d+1===s.length)i++;break}if(UR.get(t)?.has(f)&&d+1<s.length)break}if(c===void 0)continue;let u=l?i+1:i;if(n.push({tokenIndex:u,value:c}),r.push({tokenIndex:u,kind:"inline-code",value:c}),t==="python")return Xe(t,n,r,o);if(l)i++}return Xe(t,n,r,o,void 0,void 0,!0)}function Xe(e,t,n,r,o,i,s=!1){let a=e==="node"?t.slice(-1):t,c=new Set(a.map((u)=>u.tokenIndex)),l=n.filter((u)=>u.kind!=="inline-code"||c.has(u.tokenIndex));if(r&&t.length===0&&o!==void 0&&i!==void 0)l.push({tokenIndex:o,kind:"main-script",value:i});return{code:(e==="node"?a[0]?.value:a.map((u)=>u.value).join(`
26
+ `))||null,sources:r?l:[],optionsOpen:r&&s}}function JR(e){for(let t of["--import","--loader","--experimental-loader","--require"]){if(e===t)return{attached:!1,value:""};if(e.startsWith(`${t}=`))return{attached:!0,value:e.slice(t.length+1)}}return}function Oe(e){return rs.has(cs(e))}function as(e,t){return cs(e)==="node"&&/^\s*console\.(?:log|info|warn|error)\(\s*(?:"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*')\s*\)\s*;?\s*$/.test(t)}function cs(e){let t=G(e).toLowerCase();return Uy.test(t)?"python":t}function XR(e,t){return rs.get(e)?.has(t)??!1}function QR(e){return rs.get(e)?.has("--eval")??!1}function nr(e,t){let n=nP(e,t);if(!jy(n,t))return!1;Te(t,n);let r=tP(n);if(jy(r,t))return!0;return Te(t,r),eP.test(r)}var eP=/`|%x|\b(?:system|exec|spawn|popen|subprocess|child_process|open3|eval|fork|qx)/i;function tP(e){let t=[],n=0,r=0;while(r<e.length){let o=e[r];if(o!=="'"&&o!=='"'){r++;continue}let i=e.startsWith(o.repeat(3),r)?o.repeat(3):o,s=r+i.length;while(s<e.length&&!e.startsWith(i,s))s+=e[s]==="\\"?2:1;if(s>=e.length)break;t.push(e.slice(n,r)," "),r=s+i.length,n=r}return t.push(e.slice(n)),t.join("")}function jy(e,t){if(Ki(e,"rm",t))return!0;for(let r of[/\bgit[^\S\n]+checkout[^\S\n]+--[^\S\n]/,/\bgit[^\S\n]+stash[^\S\n]+(drop|clear)\b/])if(Te(t,e),r.test(e))return!0;if(Ki(e,"dd",t))return!0;for(let r of[/\bmkfs(?:\.[A-Za-z0-9_-]+)?\s+\/dev\/[^\s'"]+/,/\bshred\b\s+/])if(Te(t,e),r.test(e))return!0;if(Ki(e,"find",t))return!0;let n=e.split(/[\n\r\u2028\u2029]/);return["reset-hard","reset-merge","clean","checkout","push-force","push-refspec","push-delete","branch","tag","restore"].some((r)=>(Te(t,e),n.some((o)=>Yi(o,r))))}function nP(e,t){return Te(t,e),e.replace(KR,"")}var V=Object.freeze({maxChildAnalyses:1024,maxDerivedTokens:16384,maxDerivedBytes:1048576,maxPlaceholderReplacements:16384}),Vy="Parallel command expands beyond CC Safety Net's analysis limits. Reduce the template or explicit argument list and retry.";class us extends Error{constructor(){super("Parallel command expands beyond CC Safety Net's analysis limits. Reduce the template or explicit argument list and retry.");this.name="ParallelAnalysisLimitError"}}function qy(){return{childAnalyses:0,derivedTokens:0,derivedBytes:0,placeholderReplacements:0}}function ze(e,t){let n=t.childAnalyses??0,r=t.derivedTokens??0,o=t.derivedBytes??0,i=t.placeholderReplacements??0;if(ls(e.childAnalyses,n,V.maxChildAnalyses)||ls(e.derivedTokens,r,V.maxDerivedTokens)||ls(e.derivedBytes,o,V.maxDerivedBytes)||ls(e.placeholderReplacements,i,V.maxPlaceholderReplacements))throw new us;e.childAnalyses+=n,e.derivedTokens+=r,e.derivedBytes+=o,e.placeholderReplacements+=i}function ls(e,t,n){return!Number.isSafeInteger(e)||e<0||e>n||!Number.isSafeInteger(t)||t<0||t>n-e}import{isAbsolute as wu,normalize as uA,parse as dA,posix as dv,resolve as cr,sep as Cu}from"node:path";import{isAbsolute as rP,join as Ky,normalize as Xy,parse as oP,sep as Yy}from"node:path";var iP=["/tmp","/var/tmp","/private/tmp","/private/var/tmp"],sP=`
27
+ `;function lo(e,t){if(dt(e,t))return!0;if(!e.has("TMPDIR"))return!1;return!Vl(e.get("TMPDIR")??"",t)}function $t(e,t){if(e.has("TMPDIR"))return Vl(e.get("TMPDIR")??"",t);let n=ql(e,t);if(n===void 0)return!0;return Vl(n,t)}function ql(e,t){return tb(e,t,"TMPDIR")}function Vl(e,t){if(!e)return!1;if(cP(e))return!1;return Kl(e,t)}function dt(e,t){let n=tb(e,t,"IFS");return n!==void 0&&n!==""&&n!==sP}function Kl(e,t){let n=ds(e,t.paths);return n!==null&&eb(t).some((r)=>uP(n,r))}function Qy(e,t){let n=ds(e,t.paths);return n!==null&&eb(t).includes(n)}var Jy=new WeakMap;function eb(e){let t=Jy.get(e);if(t)return t;let n=aP(e);return Jy.set(e,n),n}function aP(e){let t=iP.map((r)=>ds(r,e.paths)??Xy(r)),n=ds(e.tmpdir,e.paths);if(!n)return t;if(process.platform==="win32")return[...t,n];if(process.platform==="darwin"&&lP(n))return[...t,n];return t}function cP(e){return/[\s$`*?[]/.test(e)||/\{[^{}]*(?:,|\.\.)[^{}]*\}/.test(e)||/[+@!]\([^)]*\)/.test(e)}function tb(e,t,n){return e.has(n)?e.get(n):t.env.get(n)}function lP(e){return/^\/(?:private\/)?var\/folders\/[^/]{2}\/[^/]+\/T$/.test(e)}function ds(e,t){try{let n=Xy(e);if(!rP(n))return n;let r=oP(n).root,o=n.slice(r.length).split(/[\\/]+/).filter(Boolean),i=r;for(let s=0;s<o.length;s++){let a=Ky(i,o[s]??"");if(t.entryKind(a)==="missing")return Ky(a,...o.slice(s+1));let c=t.realpath(a);if(c===null)return null;i=c}return i}catch{return null}}function uP(e,t){if(e===t)return!0;let n=t.endsWith(Yy)?t:`${t}${Yy}`;return e.startsWith(n)}import{statSync as Yk}from"node:fs";import{isAbsolute as nv,join as Jk,relative as rv}from"node:path";import{isAbsolute as nb,parse as dP}from"node:path";var ob=/^[A-Za-z_][A-Za-z0-9_]*=/;function je(e){if(!ob.test(e))return null;let t=e.indexOf("=");return{name:e.slice(0,t),value:e.slice(t+1)}}function ms(e){let t=new Map,n=0;while(n<e.length){let r=e[n];if(!r)break;let o=je(N(r));if(!o)break;t.set(o.name,o.value),n++}return{words:e.slice(n),envAssignments:t}}function ib(e){let t=e.toLowerCase();return e.includes("=")||t==="sudo"||t==="env"||t==="command"||t==="builtin"}function Sn(e,t,n,r){if(!ib(rr(e)))return{words:e,envAssignments:new Map,cwd:n,rewritten:!1};let o=new Set(e),i=e,s=new Map,a=new Map(r??[]),c=[],l=n;for(let d=0;d<Qn;d++){let f=rb(i),m=ms(i);for(let[h,b]of m.envAssignments)s.set(h,b),a.set(h,b);if(i=m.words,i.length===0)break;while(i.length>0&&rr(i).includes("=")&&!fP(i)){let h=pP(rr(i),a,t.env)??ji(rr(i),t.env,a);if(h)s.set(h.name,h.value),a.set(h.name,h.value);i=i.slice(1)}if(i.length===0)break;let p=rr(i).toLowerCase();if(p!=="sudo"&&p!=="env"&&p!=="command"&&p!=="builtin")break;if(p==="sudo"){let h=hP(i,t.paths,l);if(i=h.words,h.cwd!==void 0)l=h.cwd}if(p==="env"){let h=vP(i,l,a,t);if(c.push(...h.envSplitValues??[]),i=h.words,h.cwd!==void 0)l=h.cwd;for(let[b,y]of h.envAssignments)s.set(b,y),a.set(b,y)}if(p==="command")i=SP(i);if(p==="builtin")i=i.slice(Qe(i,1)==="--"?2:1);if(rb(i)===f)break}let u=ms(i);for(let[d,f]of u.envAssignments)s.set(d,f),a.set(d,f);return{words:u.words,envAssignments:s,cwd:l,envSplitValues:c.length>0?c:void 0,rewritten:mP(u.words,o)}}function mP(e,t){return e.some((n)=>!t.has(n))}function rb(e){return e.map(N).join(" ")}function rr(e){let t=e[0];return t?N(t):""}function Qe(e,t){let n=e[t];return n?N(n):void 0}function fP(e){return ob.test(rr(e))}function pP(e,t,n){if(!e.startsWith("TMPDIR+="))return null;return{name:"TMPDIR",value:`${t.get("TMPDIR")??n.get("TMPDIR")??""}${e.slice(8)}`}}var gP=new Set(["-u","-g","-C","-D","-h","-p","-r","-t","-T","-U"]);function hP(e,t,n){let r=1,o=n;while(r<e.length){let i=Qe(e,r);if(!i)break;if(i==="--")return{words:e.slice(r+1),cwd:o};if(!i.startsWith("-"))break;if(i==="-D"||i==="--chdir"){let s=Qe(e,r+1);o=s?uo(o,s,t):null,r+=2;continue}if(i.startsWith("--chdir=")){o=uo(o,i.slice(8),t),r++;continue}if(i.startsWith("-D")&&i.length>2){o=uo(o,i.slice(2),t),r++;continue}if(i==="-i"||i==="--login"){o=null,r++;continue}if(gP.has(i)){r+=2;continue}r++}return{words:e.slice(r),cwd:o}}var yP=new Set(["-i","-0","--null"]),bP=new Set(["-u","--unset","-C","--chdir","-P"]);function vP(e,t,n,r){let o=new Map,i=[],s=t,a=1,c=(l)=>({words:e.slice(l),envAssignments:o,cwd:s,envSplitValues:i.length>0?i:void 0});while(a<e.length){let l=Qe(e,a);if(!l)break;if(l==="--")return c(a+1);if(l==="-i"||l==="--ignore-environment"||l==="-"){o.clear();for(let d of n.keys())o.set(d,"");o.set("TMPDIR",""),a++;continue}if(yP.has(l)){a++;continue}if(l==="-u"||l==="--unset"){let d=Qe(e,a+1);if(d!==void 0)o.set(d,"");a+=2;continue}if(l.startsWith("-u")&&l.length>2&&!l.startsWith("-u=")){o.set(l.slice(2),""),a++;continue}if(l.startsWith("--unset=")){o.set(l.slice(8),""),a++;continue}let u=l==="-S"||l==="--split-string"?{value:Qe(e,a+1),consumed:2}:l.startsWith("-S")&&l.length>2?{value:l.slice(2),consumed:1}:l.startsWith("--split-string=")?{value:l.slice(15),consumed:1}:null;if(u){if(u.value!==void 0)i.push(u.value);return s=null,c(a+u.consumed)}if(bP.has(l)){if(l==="-C"||l==="--chdir"){let d=Qe(e,a+1);s=d?uo(s,d,r.paths):null}a+=2;continue}if(l.startsWith("-u=")){a++;continue}if(l.startsWith("-C")&&l.length>2||l.startsWith("--chdir=")){let d=l.startsWith("--chdir=")?l.slice(8):l.startsWith("-C=")?l.slice(3):l.slice(2);s=uo(s,d,r.paths),a++;continue}if(l.startsWith("-P")){a++;continue}if(l.startsWith("-")){a++;continue}if(!je(l))break;while(a<e.length){let d=je(Qe(e,a)??"");if(!d)break;o.set(d.name,d.value),a++}if(Qe(e,a)==="--")a++;return c(a)}return c(a)}function uo(e,t,n){if(t==="")return null;if(!e&&!nb(t))return null;let r=nb(t)?dP(t).root:n.realpath(e??"/");if(r===null)return null;try{return Vt(r,t,n)}catch{return null}}function SP(e){if(Qe(e,1)==="-v")return[...j(["type"]),...e.slice(2)];let t=1;while(t<e.length){let n=Qe(e,t);if(!n)break;if(n==="-p"||n==="-v"||n==="-V"){t++;continue}if(n==="--")return e.slice(t+1);if(n.startsWith("-")&&!n.startsWith("--")&&n.length>1){if(!/^[pvV]+$/.test(n.slice(1)))break;t++;continue}break}return e.slice(t)}var _P=/['"\\$`{}#]/;function fs(e,t){if(e.some((r)=>_P.test(r)))return null;let n=[...e.flatMap((r)=>r.split(/\s+/).filter((o)=>o.length>0)),...t];return n.length<=64?n:null}function or(e,t,n){return ps(e,t,n).tokens}function xP(e){let t=[],n="",r=0;while(r<e.length){let o=e.charAt(r);if(o==='"'||o==="'"){let i=e.indexOf(o,r+1);if(i===-1)return e.split(/\s+/).map((s)=>s.replace(/["']/g,"")).filter((s)=>s.length>0);n+=e.slice(r+1,i),r=i+1;continue}if(/\s/.test(o)){if(n.length>0)t.push(n);n="",r++;continue}n+=o,r++}if(n.length>0)t.push(n);return t}function Kt(e,t,n,r=0){let o=ps(e,t,n),i=(o.envSplitValues??[]).flatMap(xP);if(i.length===0)return o.tokens;let s=[...i,...o.tokens];if(r>=8)return s;return Kt(s,t,n,r+1)}function ps(e,t,n,r){if(!ib(e[0]??""))return{tokens:[...e],envAssignments:new Map,cwd:n};let o=Sn(j(e),t,n,r);return{tokens:o.words.map(N),envAssignments:o.envAssignments,cwd:o.cwd,envSplitValues:o.envSplitValues}}import{basename as Uk,isAbsolute as jk,normalize as Hk,resolve as Xb}from"node:path";function gs(){return[]}function hs(){return[]}function ys(){return{words:[],redirections:[],nested:[],start:-1,end:-1,reset(){this.words=[],this.redirections=[],this.nested=[],this.start=-1,this.end=-1}}}function CP(e){return Object.freeze({...e,span:Object.freeze(e.span),words:Object.freeze(e.words),redirections:Object.freeze(e.redirections.map((t)=>Object.freeze({...t,span:Object.freeze(t.span),...t.heredoc?{heredoc:Object.freeze({...t.heredoc,bodySpan:Object.freeze(t.heredoc.bodySpan),terminatorSpan:Object.freeze(t.heredoc.terminatorSpan)})}:{}}))),nested:Object.freeze(e.nested.map((t)=>Ce(t)))})}function bs(e,t,n){e.push(n),t.reset()}function wP(e,t,n,r,o){if(r<=n)return;e.push({raw:t.slice(n,r),span:{start:n,end:r},provenance:o})}function vs(e){let t=[];return{parts:t,push:(n,r,o)=>wP(t,e,n,r,o)}}function Yl(e){let t=e.parts??[{raw:e.raw,span:e.span,provenance:e.provenance}];return Object.freeze({kind:"word",...e,span:Object.freeze(e.span),parts:Object.freeze(t.map((n)=>Object.freeze({...n,span:Object.freeze(n.span)})))})}function ir(e,t,n,r,o,i,s){return Yl({text:r,raw:e.slice(t,n),span:{start:t,end:n},provenance:o,quoted:i,...s?{parts:s}:{}})}function Ce(e){return Object.freeze({...e,span:Object.freeze(e.span),issues:Object.freeze(e.issues.map((t)=>Object.freeze({...t,span:Object.freeze(t.span)}))),nodes:Object.freeze(e.nodes.map((t)=>{if(t.kind==="command")return CP(t);if(t.kind==="group"||t.kind==="function")return Object.freeze({...t,span:Object.freeze(t.span),body:Ce(t.body)});return Object.freeze({...t,span:Object.freeze(t.span)})}))})}function Jl(e,t,n){if(t>=n||ab(e[t]??""))return null;let r="",o=!1,i=!1,s=t;while(s<n&&!ab(e[s]??"")){let a=e[s]??"";if(a==="'"){o=!0;let c=sb(e,s+1,n,"'");r+=c.text,i||=!c.closed,s=c.next;continue}if(a==='"'){o=!0;let c=sb(e,s+1,n,'"');r+=c.text,i||=!c.closed,s=c.next;continue}if(a==="\\"){o=!0;let c=e[s+1];if(!c||c===`
28
+ `||c==="\r"){i=!0;break}r+=c,s+=2;continue}if(a==="`"||e.startsWith("$(",s)||e.startsWith("${",s)||e.startsWith("<(",s)||e.startsWith(">(",s))i=!0;r+=a,s++}return{delimiter:r,quoted:o,next:s,span:{start:t,end:s},ambiguous:i}}function Xl(e,t,n,r){let o=[],i=t;for(let s of r){let a=i,c=!1;while(i<n){let l=EP(e,i,n);if((s.stripTabs?l.text.replace(/^\t+/,""):l.text)===s.delimiter){s.attach({body:s.stripTabs?RP(e.slice(a,i)):e.slice(a,i),delimiter:s.delimiter,quotedDelimiter:s.quotedDelimiter,bodySpan:{start:a,end:i},terminatorSpan:{start:i,end:l.contentEnd}}),i=l.next,c=!0;break}if(l.next<=i)break;i=l.next}if(c)continue;return o.push({code:"unterminated-heredoc",message:`heredoc delimiter ${s.delimiter} was not found`,span:s.declarationSpan}),{next:n,issues:o,terminated:!1}}return{next:i,issues:o,terminated:!0}}function sb(e,t,n,r){let o="",i=t;while(i<n&&e[i]!==`
29
+ `&&e[i]!=="\r"){let s=e[i]??"";if(s===r)return{text:o,next:i+1,closed:!0};if(r==='"'&&s==="\\"&&e[i+1]){let a=e[i+1]??"";o+=["$","`",'"',"\\"].includes(a)?a:`\\${a}`,i+=2;continue}o+=s,i++}return{text:o,next:i,closed:!1}}function ab(e){return/[\s;&|<>)]/u.test(e)||e==="`"}function EP(e,t,n){let r=t;while(r<n&&e[r]!==`
30
+ `&&e[r]!=="\r")r++;let o=r>=n?n:e[r]==="\r"&&e[r+1]===`
31
+ `?r+2:r+1;return{text:e.slice(t,r),contentEnd:r,next:o}}function RP(e){return e.replace(/(^|\r\n?|\n)\t+/g,"$1")}var mb=new Set(["&&","||","|","|&"]);function fb(e,t,n){let r={start:0,end:e.length};if(e.length>n.maxInputLength)return Ce({kind:"program",dialect:t,source:e,span:r,status:"limited",issues:[{code:"input-limit",message:`command exceeds ${n.maxInputLength} UTF-16 code units`,span:r}],nodes:[]});let o=xs(e,0,e.length,t,n,{used:0,max:n.maxWords},0);return Ce({kind:"program",dialect:t,source:e,span:r,status:Es(o.issues,o.limited),issues:o.issues,nodes:o.nodes})}function xs(e,t,n,r,o,i,s,a){let c=gs(),l=hs(),u=ys(),d=[],f=()=>{if(u.words.length===0&&u.redirections.length===0)return;let p={start:u.start,end:u.end},h=u.words.map((b)=>b.text);bs(c,u,{kind:"command",dialect:r,source:e.slice(p.start,p.end),span:p,words:u.words,redirections:u.redirections,nested:u.nested,displayText:l.length>0&&c.length===0?e.slice(t,n):h.join(" ")})},m=t;while(m<n){let p=e[m];if(!p)break;if(a&&p===a)return f(),db(c,l),{nodes:c,issues:l,next:m+1,closed:!0,limited:!1,pendingHeredocs:d};if(ws(p)){if(p===`
32
+ `||p==="\r"){f();let P=p==="\r"&&e[m+1]===`
33
+ `?m+2:m+1,x=c.at(-1);if(x?.kind!=="connector"||!mb.has(x.operator))c.push(Object.freeze({kind:"connector",operator:e.slice(m,P),span:Object.freeze({start:m,end:P})}));if(d.length>0){let v=Xl(e,P,n,d.splice(0));l.push(...v.issues),m=v.next;continue}m=P;continue}m++;continue}if(p==="#"){while(m<n&&e[m]!==`
34
+ `&&e[m]!=="\r")m++;continue}let h=u.start===-1?jP(e,m,n):void 0;if(h){if(eu(c,l,m),s>=o.maxDepth)return sr(c,l,m,"depth-limit",o.maxDepth);if(!Ql(i))return sr(c,l,m,"word-limit",o.maxWords);let P=xs(e,h.braceIndex+1,n,r,o,i,s+1,"}"),x=P.next,v={start:h.braceIndex+1,end:P.closed?x-1:x},T=cb(e,r,v,P);if(c.push({kind:"function",name:h.name,span:{start:m,end:x},body:T}),l.push(...P.issues),P.pendingHeredocs.length>0||fo(P.nodes))l.push({code:"unsupported-heredoc-context",message:"heredocs attached inside function bodies are not supported safely",span:{start:m,end:x}});if(d.push(...P.pendingHeredocs),P.limited)return _s(c,l,P.next);if(!P.closed)l.push({code:"unclosed-function-body",message:"function body is not closed",span:{start:h.braceIndex,end:x}});m=x;continue}let b=Cs(e,m);if(b){if(f(),!_b(c.at(-1)))l.push({code:"unexpected-connector",message:`connector ${b} has no preceding command`,span:{start:m,end:m+b.length}});c.push(Object.freeze({kind:"connector",operator:b,span:Object.freeze({start:m,end:m+b.length})})),m+=b.length;continue}if(p===")"){f(),l.push({code:"unexpected-closing-delimiter",message:"closing parenthesis has no matching opening parenthesis",span:{start:m,end:m+1}}),c.push({kind:"unknown",source:p,span:{start:m,end:m+1}}),m++;continue}if((p==="("||p==="{"&&zP(e,m,n))&&u.start===-1){if(eu(c,l,m),s>=o.maxDepth)return sr(c,l,m,"depth-limit",o.maxDepth);let P=p==="("?")":"}",x=xs(e,m+1,n,r,o,i,s+1,P),v=x.next,T={start:m+1,end:x.closed?v-1:v},k=cb(e,r,T,x);if(c.push({kind:"group",style:p==="("?"subshell":"brace",span:{start:m,end:v},body:k}),l.push(...x.issues),x.pendingHeredocs.length>0||fo(x.nodes))l.push({code:"unsupported-heredoc-context",message:"heredocs attached inside command groups are not supported safely",span:{start:m,end:v}});if(d.push(...x.pendingHeredocs),x.limited)return _s(c,l,x.next);if(!x.closed)l.push({code:p==="("?"unclosed-subshell":"unclosed-brace-group",message:`${p} group is not closed`,span:{start:m,end:v}});m=v;continue}let y=(p==="<"||p===">")&&e[m+1]!=="("?AP(e,m):null;if(y){let P=u.words.at(-1),x=P&&P.span.end===m&&/^[0-9]+$/.test(P.raw)?Number(P.raw):void 0;if(x!==void 0)u.words.pop();let v=x===void 0?m:P?.span.start??m;u.start=u.start===-1?m:u.start;let T=m+y.length;while(T<n&&/[ \t]/.test(e[T]??""))T++;let k=e[T],z=T>m+y.length&&k==="#",L=!k||ws(k)||!!Cs(e,T)||k===a||k===")"||z||(k==="<"||k===">")&&e[T+1]!=="(",W=y==="<<"||y==="<<-"?Jl(e,T,n):void 0,U=W?{word:ir(e,T,W.next,W.delimiter,"literal",W.quoted),nested:[],issues:[],next:W.next,limited:!1}:!L?tu(e,T,n,r,o,i,s):void 0;if(U){if(l.push(...U.issues),U.limited)return _s(c,l,U.next);if(!Ql(i))return sr(c,l,U.next,"word-limit",o.maxWords)}let ge=U?.next??m+y.length,Ze={kind:"redirection",operator:y,span:{start:v,end:ge},...x===void 0?{}:{fd:x},...U?{target:U.word}:{}};if(u.redirections.push(Ze),y==="<<"||y==="<<-")if(!W)l.push({code:"missing-heredoc-delimiter",message:"heredoc redirection requires a delimiter word",span:{start:m,end:m+y.length}});else{if(W.ambiguous||W.delimiter.length===0)l.push({code:"ambiguous-heredoc-delimiter",message:"heredoc delimiter cannot be determined safely",span:W.span});d.push({delimiter:W.delimiter,quotedDelimiter:W.quoted,stripTabs:y==="<<-",declarationSpan:{start:v,end:ge},attach:(A)=>{Ze.heredoc=A}})}else if(!U)l.push({code:"missing-redirection-target",message:`redirection ${y} requires a target word`,span:{start:m,end:m+y.length}});if(U)u.nested.push(...U.nested);u.end=ge,m=ge;continue}if(u.start===-1)eu(c,l,m);let E=tu(e,m,n,r,o,i,s);if(l.push(...E.issues),E.limited)return _s(c,l,E.next);let w=$P(u.words)?GP(e,E.word,i.max-i.used,o.maxDepth,o.maxInputLength):void 0;if(w?.limitCode)return sr(c,l,E.next,w.limitCode,w.limitCode==="word-limit"?o.maxWords:w.limitCode==="depth-limit"?o.maxDepth:o.maxInputLength);let R=w?.words??[E.word];for(let P of R){if(!Ql(i))return sr(c,l,E.next,"word-limit",o.maxWords);u.words.push(P)}u.start=u.start===-1?m:u.start,u.end=E.next,u.nested.push(...E.nested),m=E.next>m?E.next:m+1}return f(),db(c,l),l.push(...HP(d)),{nodes:c,issues:l,next:m,closed:a===void 0,limited:!1,pendingHeredocs:[]}}function cb(e,t,n,r){return{kind:"program",dialect:t,source:e.slice(n.start,n.end),span:n,status:Es(r.issues,r.limited),issues:r.issues,nodes:r.nodes}}function tu(e,t,n,r,o,i,s){let a="",c=t,l=!1,u="literal",d=[],f=[],m=!1;while(c<n){let p=e[c],h=(p==="<"||p===">")&&e[c+1]==="(";if(!p||ws(p)||(p===";"||p==="|"||p==="&")&&Cs(e,c)||(p==="<"||p===">")&&!h)break;if(p===")")break;if(p==="'"){l=!0;let y=e.indexOf("'",c+1);if(y===-1||y>=n){a+=e.slice(c+1,n),f.push({code:"unclosed-single-quote",message:"single-quoted word is not closed",span:{start:c,end:n}}),c=n;break}a+=e.slice(c+1,y),c=y+1;continue}if(p==='"'){l=!0;let y=PP(e,c,n,r,o,i,s);if(a+=y.text,d.push(...y.nested),f.push(...y.issues),m||=y.limited,u=mo(u,y.provenance),c=y.next,m)break;continue}if(e.startsWith("$'",c)){l=!0;let y=TP(e,c+2,n);if(a+=y.text,f.push(...y.issues),!y.closed)f.push({code:"unclosed-ansi-c-quote",message:"ANSI-C quoted word is not closed",span:{start:c,end:n}});c=y.next;continue}if(p==="\\"){let y=e[c+1];if(!y){f.push({code:"trailing-escape",message:"escape has no following character",span:{start:c,end:c+1}}),c++;break}if(y===`
35
+ `){c+=2;continue}a+=y,c+=2;continue}let b=p==="$"||p==="<"||p===">"||p==="`"?nu(e,c,n,r,o,i,s):null;if(b){let y=pb(b,d,f);if(m||=y.limited,u=mo(u,y.provenance),c=y.next,m)break;continue}if(p==="$"){let y=yb(e,c,n,a,u);a=y.text,u=y.provenance,c=y.next;continue}if(p==="*"||p==="?"||p==="[")u=mo(u,"glob");a+=p,c++}return{word:ir(e,t,c,a,u,l,u==="literal"?void 0:OP(e,t,c)),nested:d,issues:f,next:c,limited:m}}function PP(e,t,n,r,o,i,s){let a="",c="literal",l=[],u=[],d=!1,f=t+1;while(f<n){let m=e[f];if(m==='"')return{text:a,provenance:c,nested:l,issues:u,next:f+1,limited:d};if(m==="\\"&&e[f+1]){let h=e[f+1]??"";if(h===`
36
+ `){f+=2;continue}if(h==="\r"&&e[f+2]===`
37
+ `){f+=3;continue}a+=["$","`",'"',"\\"].includes(h)?h:`\\${h}`,f+=2;continue}if(e.startsWith("$((",f)){let h=ru(e,f+3,n,"))"),b=h===-1?n:h+2;if(a+=e.slice(f,b),h===-1)u.push({code:"unclosed-arithmetic",message:"$(( substitution is not closed",span:{start:f,end:b}});f=b;continue}let p=nu(e,f,n,r,o,i,s);if(p){let h=pb(p,l,u);if(f=h.next,d||=h.limited,c=mo(c,h.provenance),d)return{text:a,provenance:c,nested:l,issues:u,next:f,limited:d};continue}if(m==="$"){let h=yb(e,f,n,a,c);a=h.text,c=h.provenance,f=h.next;continue}a+=m??"",f++}return u.push({code:"unclosed-double-quote",message:"double-quoted word is not closed",span:{start:t,end:n}}),{text:a,provenance:c,nested:l,issues:u,next:n,limited:d}}function nu(e,t,n,r,o,i,s){let a=e.startsWith("$((",t),c=e.startsWith("$(",t)&&!a,l=(e.startsWith("<(",t)||e.startsWith(">(",t))&&!0,u=e[t]==="`";if(!a&&!c&&!l&&!u)return null;let d=a?3:u?1:2,f=a?"))":u?"`":")",m=ru(e,t+d,n,f),p=m===-1?n:m,h=m===-1?n:m+f.length;if(s>=o.maxDepth)return{program:UP(e,t+d,p,r,"depth-limit"),next:h,provenance:a?"arithmetic":"command-substitution"};if(a){let w=[],R=[],P=!1,x=t+d;while(x<p){let v=nu(e,x,p,r,o,i,s+1);if(!v){x++;continue}if(w.push(...v.program.nodes),R.push(...v.program.issues),P||=v.program.status==="limited",x=v.next,P)break}if(m===-1)R.push({code:"unclosed-arithmetic",message:"$(( substitution is not closed",span:{start:t,end:h}});return{program:Ce({kind:"program",dialect:r,source:e.slice(t+d,p),span:{start:t+d,end:p},status:Es(R,P),issues:R,nodes:w}),next:h,provenance:"arithmetic"}}let b=xs(e,t+d,p,r,o,i,s+1),y=m===-1?[{code:a?"unclosed-arithmetic":"unclosed-command-substitution",message:`${e.slice(t,t+d)} substitution is not closed`,span:{start:t,end:h}}]:[],E=(u||l)&&fo(b.nodes)?[{code:"unsupported-heredoc-context",message:"heredocs are supported only in ordinary commands and $(...) substitutions",span:{start:t,end:h}}]:[];return{program:Ce({kind:"program",dialect:r,source:e.slice(t+d,p),span:{start:t+d,end:p},status:Es([...b.issues,...y,...E],b.limited),issues:[...b.issues,...y,...E],nodes:b.nodes}),next:h,provenance:a?"arithmetic":"command-substitution"}}function pb(e,t,n){return t.push(e.program),n.push(...e.program.issues),{provenance:e.provenance,next:e.next,limited:e.program.status==="limited"}}function ru(e,t,n,r){if(r==="`"){for(let a=t;a<n;a++)if(e[a]==="\\")a++;else if(e[a]==="`")return a;return-1}let o=1,i={single:!1,double:!1},s=[];for(let a=t;a<n;a++){let c=e[a];if((c===`
38
+ `||c==="\r")&&s.length>0){let u=c==="\r"&&e[a+1]===`
39
+ `?a+2:a+1,d=Xl(e,u,n,s.splice(0));if(!d.terminated)return-1;a=d.next-1;continue}let l=gb(e,a,t,n,i);if(l!==null){a=l;continue}if(!i.double&&e.startsWith("$((",a)){let u=kP(e,a+3,n);if(u===-1)return-1;a=u+1;continue}if(r===")"&&!i.double&&c==="<"&&e[a+1]==="<"&&e[a+2]!=="<"){let u=e[a+2]==="-",d=a+(u?3:2);while(d<n&&/[ \t]/.test(e[d]??""))d++;let f=Jl(e,d,n);if(f){s.push({delimiter:f.delimiter,quotedDelimiter:f.quoted,stripTabs:u,declarationSpan:{start:a,end:f.next},attach:()=>{return}}),a=f.next-1;continue}}if(e.startsWith("$(",a)&&!e.startsWith("$((",a)){o++,a++;continue}if(c==="("&&!i.double)o++;if(c===")"&&!i.double){if(o--,o===0)return r==="))"&&e[a+1]!==")"?-1:a}}return-1}function kP(e,t,n){let r=1,o={single:!1,double:!1};for(let i=t;i<n;i++){let s=e[i],a=gb(e,i,t,n,o);if(a!==null){i=a;continue}if(e.startsWith("$(",i)&&!e.startsWith("$((",i)){r++,i++;continue}if(s==="("&&!o.double)r++;if(s!==")"||o.double)continue;if(r--,r===0)return e[i+1]===")"?i:-1}return-1}function gb(e,t,n,r,o){let i=e[t];if(i==="\\"&&!o.single)return t+1;if(!o.double&&i==="'")o.single=!o.single;if(!o.single&&i==='"')o.double=!o.double;if(o.single)return t;if(o.double||i!=="#"||!VP(e,t,n))return null;let s=t;while(s+1<r&&e[s+1]!==`
40
+ `&&e[s+1]!=="\r")s++;return s}function Cs(e,t){let n=e[t];if(n===";")return";";if(n==="&")return e[t+1]==="&"?"&&":"&";if(n==="|")return e[t+1]==="|"?"||":e[t+1]==="&"?"|&":"|";return null}function AP(e,t){let n=e[t];if(n===">"){if(e[t+1]===">")return">>";if(e[t+1]==="&")return">&";return e[t+1]==="|"?">|":">"}if(n!=="<")return null;if(e.startsWith("<<<",t))return"<<<";if(e.startsWith("<<-",t))return"<<-";if(e[t+1]==="<")return"<<";if(e[t+1]==="&")return"<&";if(e[t+1]===">")return"<>";return"<"}function ws(e){let t=e.charCodeAt(0);if(t===32||t>=9&&t<=13)return!0;if(t<128)return!1;return/\s/u.test(e)}function hb(e,t,n){if(e[t+1]==="{"){let o=e.indexOf("}",t+2);return o===-1||o>=n?n:o+1}let r=t+1;while(r<n&&/[A-Za-z0-9_?@#$!*-]/.test(e[r]??""))r++;return r===t+1?t+1:r}function TP(e,t,n){let r="",o=[],i=t;while(i<n){let s=e[i];if(s==="'")return{text:r,next:i+1,closed:!0,issues:o};if(s!=="\\"){r+=s??"",i++;continue}let a=IP(e,i+1,n);if(r+=a.text,a.invalidCodePoint!==void 0)o.push({code:"invalid-ansi-c-code-point",message:`ANSI-C escape is not a valid Unicode scalar value: ${a.invalidCodePoint}`,span:{start:i,end:a.next}});i=a.next}return{text:r,next:n,closed:!1,issues:o}}function IP(e,t,n){let r=e[t];if(!r||t>=n)return{text:"\\",next:t};let o=new Map([["a","\x07"],["b","\b"],["e","\x1B"],["E","\x1B"],["f","\f"],["n",`
41
+ `],["r","\r"],["t","\t"],["v","\v"],["\\","\\"],["'","'"],['"','"']]);if(o.has(r))return{text:o.get(r)??r,next:t+1};if(r==="x")return Ss(e,t+1,n,16,2,t+1);if(r==="u")return Ss(e,t+1,n,16,4,t+1);if(r==="U")return Ss(e,t+1,n,16,8,t+1);if(/[0-7]/.test(r))return Ss(e,t,n,8,3,t+1);return{text:r,next:t+1}}function Ss(e,t,n,r,o,i){let s=r===16?/[0-9a-fA-F]/:/[0-7]/,a="",c=t;while(c<n&&a.length<o&&s.test(e[c]??""))a+=e[c],c++;if(!a)return{text:e[i-1]??"",next:i};let l=Number.parseInt(a,r);return l>1114111||l>=55296&&l<=57343?{text:"�",next:c,invalidCodePoint:l}:{text:String.fromCodePoint(l),next:c}}function Es(e,t=!1){if(t)return"limited";if(e.some((n)=>n.code==="invalid-ansi-c-code-point"||n.code==="missing-heredoc-delimiter"||n.code==="ambiguous-heredoc-delimiter"||n.code==="unterminated-heredoc"||n.code==="unsupported-heredoc-context"))return"invalid";return e.length>0?"partial":"complete"}function yb(e,t,n,r,o){let i=hb(e,t,n);return{text:r+e.slice(t,i),provenance:mo(o,"variable"),next:i}}function OP(e,t,n){let r=vs(e),o=t,i=!1,s=!1,a=t;while(a<n){let c=e[a];if(c==="\\"&&!i){a+=2;continue}if(!s&&c==="'"){i=!i,a++;continue}if(!i&&c==='"'){s=!s,a++;continue}if(i){a++;continue}let l=e.startsWith("$((",a),u=e.startsWith("$(",a)&&!l,d=!s&&(e.startsWith("<(",a)||e.startsWith(">(",a)),f=c==="`";if(l||u||d||f){let m=l?3:f?1:2,p=l?"))":f?"`":")",h=ru(e,a+m,n,p),b=h===-1?n:h+p.length;r.push(o,a,"literal"),r.push(a,b,l?"arithmetic":"command-substitution"),a=b,o=b;continue}if(c==="$"){let m=hb(e,a,n);if(m>a+1){r.push(o,a,"literal"),r.push(a,m,"variable"),a=m,o=m;continue}}if(!s&&(c==="*"||c==="?"||c==="[")){r.push(o,a,"literal"),r.push(a,a+1,"glob"),a++,o=a;continue}a++}return r.push(o,n,"literal"),r.parts}function mo(e,t){if(t==="command-substitution"||e==="command-substitution")return"command-substitution";if(t==="arithmetic"||e==="arithmetic")return"arithmetic";if(t==="variable"||e==="variable")return"variable";if(t==="glob"||e==="glob")return"glob";return e}function zP(e,t,n){return t+1>=n||ws(e[t+1]??"")||Cs(e,t+1)!==null}var NP=new Set(["-u","--unset","-C","--chdir","-S","--split-string","-P"]),DP=new Set(["-u","-g","-C","-D","-h","-p","-r","-t","-T","-U"]);function $P(e){let t=0;while(t<=e.length){while(/^[A-Za-z_][A-Za-z0-9_]*=/.test(e[t]?.text??""))t++;if(t===e.length)return!0;let n=LP(e,t);if(n===void 0||n===null)return!1;t=n}return!1}function LP(e,t){let n=e[t]?.text.toLowerCase();if(n==="command")return MP(e,t);if(n==="env")return WP(e,t);if(n==="sudo")return FP(e,t);return}function MP(e,t){if(e[t+1]?.text==="-v")return null;for(let n=t+1;n<e.length;n++){let r=e[n]?.text??"";if(r==="--")return n+1;if(r==="-p"||r==="-v"||r==="-V"||/^-[pvV]+$/.test(r))continue;return n}return e.length}function WP(e,t){for(let n=t+1;n<e.length;n++){let r=e[n]?.text??"";if(r==="--")return n+1;if(NP.has(r)){if(e[n+1]===void 0)return null;n++;continue}if(r.startsWith("-u=")||r.startsWith("--unset=")||r.startsWith("-C")&&r.length>2||r.startsWith("--chdir=")||r.startsWith("-S")&&r.length>2||r.startsWith("--split-string=")||r.startsWith("-P"))continue;if(r.startsWith("-")||/^[A-Za-z_][A-Za-z0-9_]*=/.test(r))continue;return n}return e.length}function FP(e,t){for(let n=t+1;n<e.length;n++){let r=e[n]?.text??"";if(r==="--")return n+1;if(DP.has(r)){if(e[n+1]===void 0)return null;n++;continue}if(r.startsWith("-"))continue;return n}return e.length}function bb(e,t,n,r){if(e.provenance!=="literal"||!e.raw.includes("{"))return;let o=[e.raw],i=e.raw.length,s=0;while(!0){let c=o.findIndex((p)=>ub(p));if(c===-1)break;if(++s>n)return{limited:!0};let l=o[c]??"",u=ub(l);if(!u||u.kind==="range")return{limited:!0};let d=u.start+l.length-u.end,f=u.alternatives.reduce((p,h)=>p+d+h.length,0);if(i-l.length+f>r||o.length-1+u.alternatives.length>t)return{limited:!0};let m=vb(l,u);o.splice(c,1,...m),i+=f-l.length}if(s===0)return;let a=o.map((c)=>BP(c,n));if(a.some((c)=>c===null))return{limited:!0};return{words:[...new Set(a.filter((c)=>c!==null&&c!==""))]}}function GP(e,t,n,r,o){if(t.provenance!=="literal"||t.quoted||t.raw!==t.text||!t.raw.includes("{"))return;let i=[t.text],s=t.text.length,a=0;while(!0){let l=i.findIndex((b)=>lb(b));if(l===-1)break;if(++a>r)return{limitCode:"depth-limit"};let u=i[l]??"",d=lb(u);if(!d)break;let f=d.start+u.length-d.end,m=d.alternatives.filter((b)=>f+b.length>0),p=m.reduce((b,y)=>b+f+y.length,0);if(s-u.length+p>o)return{limitCode:"brace-expansion-limit"};if(i.length-1+m.length>n)return{limitCode:"word-limit"};let h=vb(u,{...d,alternatives:m});i.splice(l,1,...h),s+=p-u.length}let c=i.filter((l)=>l.length>0);if(a===0)return;return{words:c.map((l)=>ir(e,t.span.start,t.span.end,l,"literal",!1))}}function lb(e){let t=[],n;for(let r=0;r<e.length;r++){let o=e[r];if(o==="{"){t.push({start:r,commas:[]});continue}if(o===","&&t.length>0){t.at(-1)?.commas.push(r);continue}if(o!=="}"||t.length===0)continue;let i=t.pop();if(!i||i.commas.length===0)continue;if(!n||i.start<n.start)n={start:i.start,end:r+1,commas:i.commas}}if(!n)return;return{start:n.start,end:n.end,alternatives:Sb(e,n)}}function ub(e){let t=[],n,r=null,o=!1;for(let i=0;i<e.length;i++){let s=e[i];if(o){o=!1;continue}if(s==="\\"&&r!=="'"){o=!0;continue}if(s===r){r=null;continue}if(r===null&&(s==="'"||s==='"')){r=s;continue}if(r!==null)continue;if(s==="{"){t.push({start:i,commas:[]});continue}if(s===","&&t.length>0){t.at(-1)?.commas.push(i);continue}if(s!=="}"||t.length===0)continue;let a=t.pop();if(!a)continue;let c=a.commas.length>0?{kind:"alternatives",start:a.start,end:i+1,commas:a.commas}:ZP(e.slice(a.start+1,i))?{kind:"range",start:a.start,end:i+1}:void 0;if(c&&(!n||c.start<n.start))n=c}if(!n||n.kind==="range")return n;return{kind:n.kind,start:n.start,end:n.end,alternatives:Sb(e,n)}}function vb(e,t){return t.alternatives.map((n)=>`${e.slice(0,t.start)}${n}${e.slice(t.end)}`)}function Sb(e,t){let n=[t.start,...t.commas,t.end-1];return n.slice(0,-1).map((r,o)=>e.slice(r+1,n[o+1]))}function ZP(e){return/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(e)||/^[A-Za-z]\.\.[A-Za-z](?:\.\.-?\d+)?$/.test(e)}function BP(e,t){let n=`x${e}`,r=tu(n,0,n.length,"posix",{maxInputLength:n.length,maxWords:1,maxDepth:t},{used:0,max:1},0);if(r.limited||r.issues.length>0||r.next!==n.length||r.word.provenance!=="literal")return null;return r.word.text.slice(1)}function UP(e,t,n,r,o){return Ce({kind:"program",dialect:r,source:e.slice(t,n),span:{start:t,end:n},status:"limited",issues:[{code:o,message:"command structure exceeds parser limit",span:{start:t,end:n}}],nodes:[]})}function sr(e,t,n,r,o){return{nodes:e,issues:[...t,{code:r,message:`command structure exceeds parser limit ${o}`,span:{start:n,end:n}}],next:n,closed:!1,limited:!0,pendingHeredocs:[]}}function _s(e,t,n){return{nodes:e,issues:t,next:n,closed:!1,limited:!0,pendingHeredocs:[]}}function Ql(e){return e.used++,e.used<=e.max}function jP(e,t,n){let r=/^([A-Za-z_][A-Za-z0-9_]*)[ \t]*\([ \t]*\)[ \t]*\{/.exec(e.slice(t,n)),o=r?.[1];if(!r||!o)return;return{name:o,braceIndex:t+r[0].lastIndexOf("{")}}function fo(e){return e.some((t)=>{if(t.kind==="command")return t.redirections.some((n)=>n.heredoc)||t.nested.some((n)=>fo(n.nodes));return(t.kind==="group"||t.kind==="function")&&fo(t.body.nodes)})}function HP(e){return e.map((t)=>({code:"unterminated-heredoc",message:`heredoc delimiter ${t.delimiter} was not found`,span:t.declarationSpan}))}function _b(e){return e?.kind==="command"||e?.kind==="group"||e?.kind==="function"}function db(e,t){let n=e.at(-1);if(n?.kind!=="connector"||!mb.has(n.operator))return;t.push({code:"missing-command-after-connector",message:`connector ${n.operator} requires a following command`,span:n.span})}function eu(e,t,n){if(!_b(e.at(-1)))return;t.push({code:"missing-command-connector",message:"adjacent commands require a connector",span:{start:n,end:n+1}})}function VP(e,t,n){return t===n||/[\s;&|()]/u.test(e[t-1]??"")}var xb=new Set(["remove-item","ri","del","erase","rd","rmdir"]),Cb=["-rec","-for","-path","-literalpath","-whatif"],Rs={maxInputLength:131072,maxWords:16384,maxDepth:64};function wb(e){let t=e.toLowerCase().replaceAll("`","");if(![...xb].some((r)=>t.includes(r))&&!(t.includes("rm")&&Cb.some((r)=>t.includes(r)))&&!t.includes("<#"))return!1;let n=JP(e);return n.invalidComment||n.commands.some(qP)}function qP(e){let t=e[0]==="&"||e[0]==="."?1:0,n=e[t]?.toLowerCase();if(n&&xb.has(n))return!0;if(n!=="rm")return!1;return e.slice(t+1).some((r)=>{let o=r.toLowerCase().split(":",1)[0]??"";return Cb.some((i)=>o.startsWith(i))})}function Eb(e,t){let n={start:0,end:e.length};if(e.length>t.maxInputLength)return Ce({kind:"program",dialect:"powershell",source:e,span:n,status:"limited",issues:[{code:"input-limit",message:`command exceeds ${t.maxInputLength} UTF-16 code units`,span:n}],nodes:[]});let r=cu(e,0,e.length,t,0);return Ce({kind:"program",dialect:"powershell",source:e,span:n,status:XP(r.issues,r.limited),issues:r.issues,nodes:r.nodes})}function cu(e,t,n,r,o,i=!1){let s=gs(),a=hs(),c=ys(),l=0,u=!1,d=()=>{if(c.words.length===0&&c.redirections.length===0)return;let m={start:c.start,end:c.end};bs(s,c,{kind:"command",dialect:"powershell",source:e.slice(m.start,m.end),span:m,words:c.words,redirections:c.redirections,nested:c.nested,displayText:c.words.map((p)=>p.text).join(" ")})},f=t;while(f<n){let m=e[f];if(!m)break;if(i&&m==="}")return d(),{nodes:s,issues:a,next:f+1,closed:!0,words:l,limited:u};let p=kb(e,f,n,r.maxDepth);if(p){if(p.issue)a.push(p.issue);if(p.limited)return d(),{nodes:s,issues:a,next:p.next,closed:!1,words:l,limited:!0};f=p.next;continue}if(/\s/.test(m)){if(m==="\r"||m===`
42
+ `){d();let y=m==="\r"&&e[f+1]===`
43
+ `?f+2:f+1;s.push(ou(e,f,y)),f=y;continue}f++;continue}let h=lu(e,f);if(h){d(),s.push(ou(e,f,f+h.length)),f+=h.length;continue}if(m==="{"){if(d(),o>=r.maxDepth)return a.push(Pb(f,r.maxDepth)),{nodes:s,issues:a,next:n,closed:!1,words:l,limited:!0};let y=cu(e,f+1,n,r,o+1,!0),E=y.closed?y.next-1:y.next,w=Ce({kind:"program",dialect:"powershell",source:e.slice(f+1,E),span:{start:f+1,end:E},status:y.limited?"limited":y.issues.length>0?"partial":"complete",issues:y.issues,nodes:y.nodes});if(s.push(Object.freeze({kind:"group",style:"brace",span:Object.freeze({start:f,end:y.next}),body:w})),a.push(...y.issues),!y.closed)a.push({code:"unclosed-script-block",message:"PowerShell script block is not closed",span:{start:f,end:y.next}});l+=y.words,u||=y.limited,f=y.next;continue}if(m==="}"){d(),s.push(ou(e,f,f+1)),f++;continue}if(m===">"||m==="<"){c.start=c.start===-1?f:c.start;let y=e[f+1]===m?f+2:f+1,E=y;while(/[ \t]/.test(e[E]??""))E++;let w=E<n?iu(e,E,n,r,o):void 0,R=w?.next??y;if(c.redirections.push(Object.freeze({kind:"redirection",operator:e.slice(f,y),span:Object.freeze({start:f,end:R}),...w?{target:w.word}:{}})),w)a.push(...w.issues),c.nested.push(...w.nested),l+=w.words,u||=w.limited;c.end=R,f=R;continue}if(m===","){c.start=c.start===-1?f:c.start,c.words.push(Yl({text:",",raw:",",span:{start:f,end:f+1},provenance:"literal",quoted:!1})),c.end=++f;continue}let b=iu(e,f,n,r,o);if(c.start=c.start===-1?f:c.start,c.end=b.next,c.words.push(b.word),a.push(...b.issues),c.nested.push(...b.nested),l+=1+b.words,u||=b.limited,l>r.maxWords)return a.push({code:"word-limit",message:`command exceeds ${r.maxWords} words`,span:{start:f,end:b.next}}),d(),{nodes:s,issues:a,next:b.next,closed:!1,words:l,limited:!0};f=b.next>f?b.next:f+1}return d(),{nodes:s,issues:a,next:f,closed:!i,words:l,limited:u}}function iu(e,t,n,r,o){let i="",s="literal",a=!1,c=[],l=[],u=0,d=!1,f=(p)=>{let h=KP(e,p,n,r,o);return i+=e.slice(p,h.next),l.push(h.program),c.push(...h.program.issues),u+=su(h.program),d||=h.program.status==="limited",s="command-substitution",h.next},m=t;while(m<n){let p=e[m];if(!p||/\s/.test(p)||lu(e,m)||p===">"||p==="<"||p==="#")break;if(p===",")break;if(p==="`"){let h=e[m+1];if(!h){c.push({code:"trailing-escape",message:"PowerShell escape has no following character",span:{start:m,end:m+1}}),m++;break}i+=h,m+=2;continue}if(e.startsWith("$(",m)){m=f(m);continue}if(p==="'"){a=!0,m++;let h=!1;while(m<e.length){if(e[m]==="'"&&e[m+1]==="'"){i+="'",m+=2;continue}if(e[m]==="'"){h=!0,m++;break}i+=e[m]??"",m++}if(!h)c.push({code:"unclosed-single-quote",message:"single-quoted word is not closed",span:{start:t,end:e.length}});continue}if(p==='"'){a=!0;let h=m++,b=!1;while(m<n){let y=e[m];if(y==="`"&&e[m+1]){i+=e[m+1],m+=2;continue}if(y==='"'){b=!0,m++;break}if(e.startsWith("$(",m)){m=f(m);continue}if(y==="$")s=e[m+1]==="("?"command-substitution":"variable";i+=y??"",m++}if(!b)c.push({code:"unclosed-double-quote",message:"double-quoted word is not closed",span:{start:h,end:e.length}});continue}if(p==="$")s=e[m+1]==="("?"command-substitution":"variable";if(p==="@"&&m===t)s="variable";i+=p,m++}return{word:ir(e,t,m,i,s,a,s==="literal"?void 0:YP(e,t,m)),next:m,issues:c,nested:l,words:u,limited:d}}function KP(e,t,n,r,o){let i=Rb(e,t+2,n),s=i===-1?n:i,a=i===-1?n:i+1;if(o>=r.maxDepth)return{program:Ce({kind:"program",dialect:"powershell",source:e.slice(t+2,s),span:{start:t+2,end:s},status:"limited",issues:[Pb(t,r.maxDepth)],nodes:[]}),next:a};let c=cu(e,t+2,s,r,o+1),l=i===-1?[{code:"unclosed-command-subexpression",message:"PowerShell command subexpression is not closed",span:{start:t,end:a}}]:[];return{program:Ce({kind:"program",dialect:"powershell",source:e.slice(t+2,s),span:{start:t+2,end:s},status:c.limited?"limited":c.issues.length+l.length>0?"partial":"complete",issues:[...c.issues,...l],nodes:c.nodes}),next:a}}function Rb(e,t,n){let r=1,o=!1,i=!1;for(let s=t;s<n;s++){let a=e[s];if(a==="`"){s++;continue}if(!i&&a==="'"){if(o&&e[s+1]==="'"){s++;continue}o=!o;continue}if(!o&&a==='"'){i=!i;continue}if(o)continue;if(e.startsWith("$(",s)){r++,s++;continue}if(!i&&a==="(")r++;if(a!==")")continue;if(r--,r===0)return s}return-1}function su(e){let t=0;for(let n of e.nodes){if(n.kind==="group")t+=su(n.body);if(n.kind==="command"){t+=n.words.length;for(let r of n.nested)t+=su(r)}}return t}function YP(e,t,n){let r=vs(e),o=t,i=!1,s=t;while(s<n){let a=e[s];if(a==="`"){s+=2;continue}if(a==="'"){if(i&&e[s+1]==="'"){s+=2;continue}i=!i,s++;continue}if(i){s++;continue}if(e.startsWith("$(",s)){let c=Rb(e,s+2,n),l=c===-1?n:c+1;r.push(o,s,"literal"),r.push(s,l,"command-substitution"),s=l,o=l;continue}if(a==="$"||a==="@"&&s===t){let c=s+1;if(e[c]==="{"){let l=e.indexOf("}",c+1);c=l===-1||l>=n?n:l+1}else while(c<n&&/[A-Za-z0-9_:?]/.test(e[c]??""))c++;r.push(o,s,"literal"),r.push(s,c,"variable"),s=c,o=c;continue}s++}return r.push(o,n,"literal"),r.parts}function Pb(e,t){return{code:"depth-limit",message:`command structure exceeds parser limit ${t}`,span:{start:e,end:e}}}function JP(e){let t=[],n=[],r=0,o=0,i=!1,s=()=>{if(n.length>0)t.push(n);n=[]};while(r<e.length&&r<131072&&o<16384){let a=e[r];if(a==="\r"||a===`
44
+ `){s(),r+=a==="\r"&&e[r+1]===`
45
+ `?2:1;continue}if(/\s/.test(a??"")){r++;continue}let c=kb(e,r,Math.min(e.length,Rs.maxInputLength),Rs.maxDepth);if(c){i||=!!c.issue||c.limited,r=c.next;continue}let l=lu(e,r);if(l){s(),r+=l.length;continue}if(a==="{"||a==="}"){s(),r++;continue}let u=iu(e,r,Math.min(e.length,Rs.maxInputLength),Rs,0);if(u.word.text)n.push(u.word.text);for(let d of u.nested)t.push(...au(d));o++,r=u.next>r?u.next:r+1}return s(),{commands:t,invalidComment:i}}function au(e){return e.nodes.flatMap((t)=>{if(t.kind==="group")return au(t.body);if(t.kind!=="command")return[];return[t.words.map((n)=>n.text),...t.nested.flatMap(au)]})}function lu(e,t){for(let n of["&&","||",";","|"])if(e.startsWith(n,t))return n;return null}function kb(e,t,n,r){if(e[t]==="#"&&e[t+1]!==">"){let s=t+1;while(s<n&&e[s]!=="\r"&&e[s]!==`
46
+ `)s++;return{next:s,limited:!1}}if(!e.startsWith("<#",t))return null;let o=1,i=t+2;while(i<n){if(e.startsWith("<#",i)){if(o++,o>r)return{next:n,issue:{code:"comment-depth-limit",message:`PowerShell block comment exceeds nesting limit ${r}`,span:{start:t,end:i+2}},limited:!0};i+=2;continue}if(e.startsWith("#>",i)){if(o--,i+=2,o===0)return{next:i,limited:!1};continue}i++}return{next:n,issue:{code:"unclosed-block-comment",message:"PowerShell block comment is not closed",span:{start:t,end:n}},limited:!1}}function XP(e,t){if(t)return"limited";if(e.some((n)=>n.code==="unclosed-block-comment"))return"invalid";return e.length>0?"partial":"complete"}function ou(e,t,n){return Object.freeze({kind:"connector",operator:e.slice(t,n),span:Object.freeze({start:t,end:n})})}var _n=Object.freeze({maxInputLength:131072,maxWords:16384,maxDepth:64});function et(e,t="auto",n=_n){if(t==="powershell"||t==="auto"&&wb(e.slice(0,n.maxInputLength)))return Eb(e,n);return fb(e,"posix",n)}function po(e,t){if(e!=="powershell")return t[0]?.provenance==="command-substitution";let n=t[0]?.text==="&"||t[0]?.text==="."?1:0,r=t[n]?.provenance;return r!==void 0&&r!=="literal"}var QP=/^[A-Za-z_][A-Za-z0-9_]*=/;function Ps(e,t){return e?.provenance==="literal"&&!e.quoted&&e.raw===t&&e.text===t}function ks(e){let t=Ps(e.words[0],"time")?1:0,n=t===1&&Ps(e.words[t],"-p")?t+1:t,r=t===1&&Ps(e.words[n],"--")?n+1:n,o=Ps(e.words[r],"!")?r+1:r,i=e.words.slice(o).find((s)=>!QP.test(s.text));return i?.provenance==="literal"?i.text:void 0}function go(e,t){if(t.escaped)return t.escaped=!1,!0;if(e==="\\"&&!t.inSingle)return t.escaped=!0,!0;if(e==="'"&&!t.inDouble)return t.inSingle=!t.inSingle,!0;if(e==='"'&&!t.inSingle)return t.inDouble=!t.inDouble,!0;return!1}function ar(e){let t={inSingle:!1,inDouble:!1,escaped:!1};for(let n of ek(e))go(n,t);return t.inSingle||t.inDouble}function ek(e){let t="",n={inSingle:!1,inDouble:!1,escaped:!1},r=!1,o=!0;for(let i=0;i<e.length;i++){let s=e[i];if(!s)break;if(r){if(s===`
47
+ `||s==="\r")t+=s,r=!1,n.escaped=!1;continue}if(s==="#"&&!n.inSingle&&!n.inDouble&&o){r=!0;continue}if(t+=s,!n.inSingle&&!n.inDouble&&!n.escaped)o=/[\s;&|()<>]/.test(s);go(s,n)}return t}var tk=new Set(["&&","||","|&","|","&",";"]),nk=new Set(["<<","<<<",">|"]),rk=/[*@#?$!_-]/,uu=Object.freeze([]),ok=Object.freeze([]),ik=256;function zb(e,t){let n=t.status==="complete"?new Set(mu(t)):new Set,r=[...n].reduce((s,a)=>s.slice(0,a.start)+" ".repeat(a.end-a.start)+s.slice(a.end),e);if(ar(r))return As("unclosed-quote",r,uu);let o={invalid:!1,limited:!1,expansions:0,assignmentFallbacks:[]},i=ho(t,{source:r,suppressed:n,flags:o,depth:0,functions:new Map});if(o.limited)return As("structural-limit",r,uu);if(o.invalid)return As("invalid",r,uu);return As("complete",r,i,o.assignmentFallbacks)}function As(e,t,n,r=ok){return Object.freeze({status:e,source:t,entries:Object.freeze(n),assignmentFallbacks:Object.freeze(r)})}function ho(e,t){return e.nodes.flatMap((n,r)=>sk(n,e,r,t)).sort((n,r)=>n.start-r.start).flatMap((n)=>[...n.entries])}function sk(e,t,n,r){if(e.kind==="connector")return[{start:e.span.start,entries:[tt(dk(e.operator))]}];if(e.kind==="unknown")return[{start:e.span.start,entries:[tt(e.source)]}];if(e.kind==="function")return r.functions.set(e.name,e.body),[];if(e.kind==="group"){let i=e.style!=="subshell",s=r.source[e.span.end-1]===(i?"}":")"),a=i?r:{...r,functions:new Map(r.functions)};return[{start:e.span.start,entries:[i?Ts("{"):tt("("),...ho(e.body,a),...s?[i?Ts("}"):tt(")")]:[]]}]}let o=fk(e,r.functions);if(o){if(r.depth>=_n.maxDepth||++r.flags.expansions>ik)return r.flags.limited=!0,[];return[{start:e.span.start,entries:[...Ab(e,r),Ts(";"),...ho(o,{...r,depth:r.depth+1}),Ts(";")]},...Tb(e,t,n,r)]}return[{start:e.span.start,entries:Ab(e,r)},...Tb(e,t,n,r)]}function Ab(e,t){return[...e.words.map((n)=>({start:n.span.start,entries:Db(n,e,t,!1)})),...e.redirections.map((n)=>({start:n.span.start,entries:ak(n,e,t)}))].sort((n,r)=>n.start-r.start).flatMap((n)=>n.entries)}function ak(e,t,n){let r=e.operator==="<<-"?"<<":e.operator,o=e.target?Db(e.target,t,n,!0):[],i=o[0],s=i?.kind==="word"?i.text:void 0;return[...e.fd===void 0?[]:[fu(String(e.fd))],Object.freeze({kind:"redirection",operator:r,role:mk(r),targetOrder:nk.has(r)?"legacy-segment":"immediate",...s===void 0?{}:{target:s}}),...s===void 0?o:o.slice(1)]}function Tb(e,t,n,r){let o=e.redirections.filter((i)=>i.operator==="<<"||i.operator==="<<-");return[...o.flatMap((i)=>{let s=i.heredoc;if(!s)return[];let a=[fu(s.delimiter),.../[\r\n]/.test(r.source[s.terminatorSpan.end]??"")?[tt(";")]:[]];if(r.suppressed.has(s.bodySpan))return[{start:s.bodySpan.start,entries:a}];return[{start:s.bodySpan.start,entries:[...Nb(r.source.slice(s.bodySpan.start,s.bodySpan.end),r),...a]}]}),...o.some((i)=>!i.heredoc&&i.target)?ck(t,n,r):[]]}function ck(e,t,n){let r=e.nodes.slice(t+1).find((o)=>o.kind==="connector");if(!r||r.span.end>=e.span.end)return[];return[{start:r.span.end,entries:Nb(n.source.slice(r.span.end,e.span.end),n)}]}function Nb(e,t){if(t.depth>=_n.maxDepth)return t.flags.limited=!0,[];let n=et(e,"posix");if(n.status==="limited")return t.flags.limited=!0,[];let r={invalid:!1,limited:!1,expansions:t.flags.expansions,assignmentFallbacks:t.flags.assignmentFallbacks},o=ho(n,{source:e,suppressed:new Set,flags:r,depth:t.depth+1,functions:new Map});return t.flags.limited||=r.limited,t.flags.expansions=r.expansions,o}function Db(e,t,n,r){let o=[],i={single:!1,double:!1},s="",a=!1,c=()=>{if(a&&!r)o.push(tt("glob"));else if(s!==""||e.quoted&&o.length===0)o.push(fu(s));s="",a=!1};for(let l of e.parts){if(l.provenance!=="command-substitution"&&l.provenance!=="arithmetic"){for(let m of du(l.raw,i,n.flags)){if(typeof m==="string"){c(),o.push(tt(m));continue}s+=m.text,a||=m.glob}continue}if(i.double){let m=n.source.slice(l.span.start,l.span.end);s+=du(m,{single:!1,double:!0},n.flags).map((p)=>typeof p==="string"?p:p.text).join("");continue}let u=t.nested.find((m)=>m.span.start>=l.span.start&&m.span.end<=l.span.end),d=u?ho(u,n):[];if(l.raw.startsWith("`")){s+="${}",c(),o.push(...d);continue}if(l.raw.startsWith("<(")||l.raw.startsWith(">(")){c(),o.push(l.raw.startsWith("<(")?tt("<("):Object.freeze({kind:"redirection",operator:">",role:"file-write",targetOrder:"immediate"}),...d,...l.raw.endsWith(")")?[tt(")")]:[]);continue}let f=l.raw.startsWith("$((")?2:1;s+="${}",c(),o.push(...Array.from({length:f},()=>tt("(")),...d,...l.raw.endsWith(")".repeat(f))?Array.from({length:f},()=>tt(")")):[])}return c(),o}function du(e,t,n){let r=[],o="",i=!1,s=0;while(s<e.length){let a=e[s]??"";if(!t.single&&!t.double&&(a==="("||a===")")){r.push({text:o,glob:i},a),o="",i=!1,s++;continue}if(t.single){if(a==="'")t.single=!1;else o+=a;s++;continue}if(t.double){if(a==='"'){t.double=!1,s++;continue}if(a==="\\"){let c=e[s+1]??"";o+=['"',"\\","$"].includes(c)?c:`\\${c}`,s+=2;continue}if(a==="$"){let c=Ib(e,s,t,n);o+=c.text,s=c.next;continue}o+=a,s++;continue}if(a==="'"||a==='"'){t.single=a==="'",t.double=a==='"',s++;continue}if(a==="\\"){let c=e[s+1]??"";i||=c==="*"||c==="?",o+=c,s+=2;continue}if(a==="$"){let c=Ib(e,s,t,n);o+=c.text,s=c.next;continue}i||=a==="*"||a==="?",o+=a,s++}return[...r,{text:o,glob:i}]}function Ib(e,t,n,r){let o=e[t+1];if(o==="{"){let s=uk(e,t+2);if(s===-1)return r.invalid=!0,{text:"",next:e.length};let a=e.slice(t,s+1);return lk(a,n,r),{text:a,next:s+1}}if(o!==void 0&&rk.test(o))return{text:`\${${o}}`,next:t+2};let i=/^\w*/.exec(e.slice(t+1))?.[0]??"";return{text:`\${${i}}`,next:t+1+i.length}}function lk(e,t,n){let r=e.slice(2,-1),o=/^[A-Za-z_][A-Za-z0-9_]*/.exec(r)?.[0];if(!o)return;let i=r.slice(o.length),s=[":=","="].find((c)=>i.startsWith(c));if(!s)return;let a=du(i.slice(s.length),{...t},n);n.assignmentFallbacks.push(...a.flatMap((c)=>typeof c==="string"||!c.text?[]:[c.text]))}function uk(e,t){let n=1,r=t;while(n>0&&r<e.length){if(e[r]==="{"&&e[r-1]==="$")n++;else if(e[r]==="}")n--;r++}return n===0?r-1:-1}function dk(e){return/^[\r\n]+$/.test(e)?";":e}function tt(e){return Object.freeze({kind:"operator",operator:e,boundary:tk.has(e)})}function Ts(e){return Object.freeze({kind:"operator",operator:e,boundary:!0})}function fu(e){return Object.freeze({kind:"word",text:e})}function mk(e){if(e==="<<"||e==="<<<")return"here-data";if(e==="<"||e==="<&")return"file-read";return"file-write"}function mu(e){return e.nodes.flatMap((t,n)=>{if(t.kind==="group"||t.kind==="function")return mu(t.body);if(t.kind!=="command")return[];let r=t.nested.flatMap((s)=>mu(s)),o=e.nodes[n+1];if(o?.kind==="connector"&&(o.operator==="|"||o.operator==="|&")||!gk(t))return r;return[...r,...t.redirections.flatMap((s)=>s.heredoc?.quotedDelimiter?[s.heredoc.bodySpan]:[])]})}function fk(e,t){let n=ks(e);return n===void 0?void 0:t.get(n)}function Yt(e,t){return e!==void 0&&e.provenance==="literal"&&!e.quoted&&e.raw===e.text&&e.text===t}function pk(e){if(Yt(e.words[0],"git"))return Yt(e.words[1],"commit");if(!Yt(e.words[0],"gh")||!Yt(e.words[2],"create"))return!1;return Yt(e.words[1],"pr")||Yt(e.words[1],"issue")}function gk(e){return(Yt(e.words[0],"cat")||Yt(e.words[0],"tee")||pk(e))&&!e.words.some(Ob)&&!e.redirections.some((n)=>Ob(n.target))}function Ob(e){return e?.parts.some((t)=>t.provenance==="command-substitution"&&t.raw.startsWith(">("))??!1}import{types as hk}from"node:util";var yk=new Set(["find","findbyname","glob","grep","grepsearch","listdir","listpermissions","ls","read","readfile","readurlcontent","searchweb","view","viewfile"]),bk=new Set(["command","diff","input","patch","patchtext"]),$b=new TextEncoder,vk=new TextDecoder,Sk=/\s/,_k=64;class Lt extends Error{name="ToolInputLimitError";constructor(){super("tool input traversal limit exceeded")}}var yo=Object.freeze({maxDepth:64,maxNodes:1e4,maxKeys:1e4,maxStringBytes:1048576,maxAggregateStringBytes:4194304});function xk(e){return e.replace(/[-_\s]/g,"").toLowerCase()}function Os(e){return yk.has(xk(e))}function vo(e){if(!e||typeof e!=="object")return;jb(e);let t=Object.getOwnPropertyDescriptor(e,"command");if(!t){if("command"in e)mt();return}if(t.get||t.set)mt();let n=t.value;return typeof n==="string"&&n!==""?n:void 0}function yu(e,t){return Gb(e,t,{nodes:0,keys:0,stringBytes:0,ancestors:new Set},1)}function Gb(e,t,n,r){let o=Ub(e,n,r);if(!o)return[];let i=o.entries.flatMap(([s,a])=>{let c=Gb(a,t,n,r+1);return typeof a==="string"&&t.has(Zb(s))?[a]:c});return n.ancestors.delete(o.object),i}function Zb(e){return e.replace(/-/g,"_").toLowerCase()}function bu(e){return Bb(e,!0,{nodes:0,keys:0,stringBytes:0,ancestors:new Set},1).flatMap(wk)}function Bb(e,t,n,r){let o=Ub(e,n,r);if(typeof e==="string")return t?[e]:[];if(!o)return[];let i=o.entries.flatMap(([s,a])=>Bb(a,o.array?t:bk.has(Zb(s)),n,r+1));return n.ancestors.delete(o.object),i}function Ck(e,t,n){if(t.nodes++,e!==null&&typeof e==="object"&&n>yo.maxDepth||t.nodes>yo.maxNodes)mt();if(typeof e!=="string")return;let r=Buffer.byteLength(e);if(t.stringBytes+=r,r>yo.maxStringBytes||t.stringBytes>yo.maxAggregateStringBytes)mt()}function Ub(e,t,n){if(Ck(e,t,n),!e||typeof e!=="object")return null;let r=jb(e);if(t.ancestors.has(e))mt();let o=Reflect.ownKeys(e);if(t.keys+=o.length,t.keys>yo.maxKeys)mt();let i=o.flatMap((s)=>{let a=Object.getOwnPropertyDescriptor(e,s);if(!a||a.get||a.set)mt();return typeof s==="string"&&a.enumerable?[[s,a.value]]:[]});return t.ancestors.add(e),{object:e,array:r,entries:i}}function jb(e){if(hk.isProxy(e))mt();let t=Array.isArray(e),n=Object.getPrototypeOf(e);if(t&&n!==Array.prototype||!t&&n!==Object.prototype&&n!==null)mt();return t}function mt(){throw new Lt}function wk(e){let t=[],n=e.split(/\r?\n/),r=!1,o=!1,i=null,s=null,a=()=>{o=!1,i=null,s=null};for(let c=0;c<n.length;c++){let l=n[c]??"";if(l==="*** Begin Patch"){r=!0,a();continue}if(l==="*** End Patch"){r=!1,a();continue}if(l.startsWith("@@")){let u=Ek(l);if(o=!0,i=u?.oldLines??null,s=u?.newLines??null,i===0&&s===0)a();continue}if(o&&i!==null&&s!==null){let u=l.startsWith(" ")||l.startsWith("-")?1:0,d=l.startsWith(" ")||l.startsWith("+")?1:0;if(i=Math.max(0,i-u),s=Math.max(0,s-d),i===0&&s===0)a();continue}if(l.startsWith("*** ")){a(),t.push(...pu(l));continue}if(o)continue;if(l.startsWith("diff --git ")){t.push(...pu(l));continue}if(l.startsWith("--- ")){let u=n[c+1]??"";if(!u.startsWith("+++ "))continue;t.push(...hu(Is(l.slice(4),!0),Is(u.slice(4),!0))),c++;continue}if(!r)t.push(...pu(l))}return t}function Ek(e){let t=/^@@ -\d+(?:,(\d+))? \+\d+(?:,(\d+))? @@/.exec(e);if(!t)return null;return{oldLines:Number(t[1]??1),newLines:Number(t[2]??1)}}function pu(e){let t=/^\*\*\* (?:Add|Update|Delete) File: (.+)$/.exec(e);if(t?.[1])return Fb(t[1]);let n=/^\*\*\* Move to: (.+)$/.exec(e);if(n?.[1])return Fb(n[1]);if(e.startsWith("diff --git "))return Rk(e.slice(11));let r=/^--- (.+)$/.exec(e);if(r?.[1])return Wb(r[1]);let o=/^\+\+\+ (.+)$/.exec(e);if(o?.[1])return Wb(o[1]);let i=/^(?:rename|copy) (?:from|to) (.+)$/.exec(e);if(i?.[1])return zk(i[1]);return[]}function Rk(e){let t=Pk(e);if(t.length===2&&t[0]&&t[1])return hu(t[0],t[1]);let n=kk(e);return n?hu(e.slice(n.oldStart,n.oldEnd),e.slice(n.newStart,n.newEnd)):[]}function Pk(e){let t=[],n=0;while(n<e.length&&t.length<2){while(xn(e[n]))n++;if(n>=e.length)break;let r=e[n]==='"'||e[n]==="'"?e[n]:void 0;if(!r){let i=n;while(n<e.length&&!xn(e[n]))n++;t.push(e.slice(i,n));continue}let o=Hb(e,n,r);if(!o)return[];t.push(o.value),n=o.end}while(xn(e[n]))n++;return n===e.length?t:[]}function kk(e){let t=0;while(t<e.length&&xn(e[t]))t++;let n=e.length;while(n>t&&xn(e[n-1]))n--;let r=0,o=t;while(o<n){if(!xn(e[o])){o++;continue}let i=o;while(o<n&&xn(e[o]))o++;if(i===t||o===n)continue;if(r++,r>_k)mt();if(Ak(e,t,i,o,n))return{oldStart:t,oldEnd:i,newStart:o,newEnd:n}}return null}function Ak(e,t,n,r,o){if(gu(e,t,n,r,o))return!0;let i=Lb(e,"/",t,n),s=Lb(e,"/",r,o);if(i<=t||s<=r)return!1;if(gu(e,t,i,r,s))return!1;return gu(e,i+1,n,s+1,o)}function gu(e,t,n,r,o){if(n-t!==o-r)return!1;for(let i=0;i<n-t;i++)if(e[t+i]!==e[r+i])return!1;return!0}function Lb(e,t,n,r){for(let o=n;o<r;o++)if(e[o]===t)return o;return-1}function xn(e){return e!==void 0&&Sk.test(e)}function Hb(e,t,n){let r=[],o=t+1;while(o<e.length){let i=e[o]??"";if(i===n)return{value:vk.decode(Uint8Array.from(r)),end:o+1};if(i!=="\\"||n==="'"){r.push(...$b.encode(i)),o++;continue}let s=e.slice(o+1),a=/^[0-7]{1,3}/.exec(s)?.[0];if(a){r.push(Number.parseInt(a,8)),o+=a.length+1;continue}r.push(...$b.encode(Tk(s[0]??""))),o+=2}return null}function Tk(e){return{a:"\x07",b:"\b",f:"\f",n:`
48
+ `,r:"\r",t:"\t",v:"\v"}[e]??e}function Ik(e){return bo(Nk(e))}function hu(e,t){if(e==="/dev/null")return Mb(t);if(t==="/dev/null")return Mb(e);if(e.startsWith("a/")&&t.startsWith("b/"))return[e.slice(2),t.slice(2)].flatMap(bo);let n=Ok(e,t)??(e===t?Vb(e):null);return[e,t,...n?[n]:[]].flatMap(bo)}function Mb(e){let t=Vb(e);return[e,...t?[t]:[]].flatMap(bo)}function Vb(e){let t=e.indexOf("/");return t>0&&t<e.length-1?e.slice(t+1):null}function Ok(e,t){let n=e.indexOf("/"),r=t.indexOf("/");if(n<1||r<1)return null;if(e.slice(0,n)===t.slice(0,r))return null;let o=e.slice(n+1);return o===t.slice(r+1)?o:null}function Wb(e){return Ik(Is(e,!0))}function zk(e){return bo(Is(e,!1))}function Is(e,t){let n=e.trim(),r=n[0]==='"'||n[0]==="'"?n[0]:void 0;if(r){let o=Hb(n,0,r);if(o&&(t||n.slice(o.end).trim()===""))return o.value}return t?n.split("\t",1)[0]?.trim()??"":n}function Nk(e){return e.startsWith("a/")||e.startsWith("b/")?e.slice(2):e}function bo(e){return e===""||e==="/dev/null"?[]:[e]}function Fb(e){let t=e.split("\t",1)[0]?.trim().replace(/^['"]|['"]$/g,"")??"";return t===""||t==="/dev/null"?[]:[t]}var qb=new Set(["absolutepath","directorypath","directory_path","file","file_path","filepath","include","notebook_path","path","searchdirectory","search_directory","searchpath","targetfile","target_file"]),Kb=new Set([...qb,"glob"]),Dk=new Set([...Kb,"pattern"]),$k=[],Yb={parseCommand:et,projectShellSyntax:zb};class ft extends Error{name="StructuralShellSyntaxLimitError";constructor(){super("Structural command analysis limit exceeded.")}}function zs(e,t={}){let n=Lk({...Yb,...t}),r=vo(e.input),o=[];if((e.route.kind==="command"||e.route.kind==="unknown")&&r)o.push({usage:"input-candidate",source:r});if(e.route.kind==="command"&&"command"in e&&e.command)o.push({usage:"declared-command",source:e.command});let i=o.reduce((s,a)=>{let c=s.findIndex((d)=>d.source===a.source);if(c!==-1){let d=s[c];if(!d)return s;return s[c]={...d,usages:[...d.usages,a.usage]},s}let l=e.route.kind==="command"?e.route.shell:"posix",u=n.getCommandProgram(a.source,l);return s.push({usages:[a.usage],source:a.source,program:u,shell:n.getShellSyntax(a.source,u)}),s},[]);return{invocation:{toolName:e.toolName,route:e.route,context:e.context},commands:i,paths:Mk(e),store:n}}function Ne(e,t){return e.commands.find((n)=>n.usages.includes(t))}function pt(e){if(!e.includes("$"))return e;return Gi(e,Ot())}function Lk(e={}){let t={...Yb,...e},n=new Map,r=new Map,o=new WeakMap,i=(a,c)=>{let l=`${c}\x00${a}`,u=r.get(l);if(u)return u;let d=t.parseCommand(a,c);return r.set(l,d),d};return{getShellSyntax:(a,c)=>{if(c&&c.source!==a)throw TypeError("Shell syntax source does not match command program source.");let l=c??i(a,"posix");if(l.status==="limited"){let f=o.get(l);if(f)return f;let m={status:"structural-limit",source:a,entries:$k,assignmentFallbacks:[]};return o.set(l,m),m}let u=n.get(a);if(u)return u;let d=t.projectShellSyntax(a,l);return n.set(a,d),d},getCommandProgram:i}}function Mk(e){let t=e.route.kind==="grep"?Kb:e.route.kind==="glob"?Dk:qb;return[...yu(e.input,t),...e.route.kind==="patch"?bu(e.input):[]]}function we(e,t){let n=new Set,r=!1;for(let o of e){if(o==="--"){r=!0;continue}if(r)continue;if(o.startsWith("-")&&!o.startsWith("--")&&o.length>1)for(let i=1;i<o.length;i++){let s=o[i];if(!s||!/[a-zA-Z]/.test(s))break;let a=`-${s}`;if(n.add(a),t?.shortOptsWithValue?.has(a))break}}return n}var Wk=new Map([["bash",new Set(["O","o"])],["dash",new Set(["o"])],["ksh",new Set(["o"])],["sh",new Set(["o"])],["zsh",new Set(["o"])]]),Fk=new Map([["zsh",new Set(["o"])]]),Gk=new Map([["bash",new Set(["--init-file","--rcfile"])]]);function Jb(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r===void 0||r==="--"||r==="-"||r[0]!=="-"&&r[0]!=="+")return null;if(r.startsWith("--")){let s=Gk.get(e);if(Bk(r,s))continue;if(!s?.has(r))continue;if(t[n+1]===void 0)return null;n++;continue}let o=Zk(e,r);if(o.commandSelected)return t[n+o.followingValues+1]??null;let i=t[n+1];if(e==="ksh"&&(r==="-o"||r==="+o")&&i!==void 0&&i[0]!=="-"&&i[0]!=="+")n++;n+=o.followingValues}return null}function Zk(e,t){let n=Wk.get(e),r=Fk.get(e),o=!1,i=0;for(let s=1;s<t.length;s++){let a=t[s];if(a===void 0)break;if(t[0]==="-"&&a==="c")o=!0;if(e==="ksh"&&a==="o"){if(s+1<t.length){let c=t.slice(s+1);if(!o&&t[0]==="-"&&c==="c")continue;if(!o&&t[0]==="-"&&c[0]==="-"&&c.endsWith("c"))o=!0;break}if(o)i++;continue}if(!n?.has(a))continue;if(r?.has(a)&&s+1<t.length)break;i++}return{commandSelected:o,followingValues:i}}function Bk(e,t){return t!==void 0&&[...t].some((n)=>e.startsWith(`${n}=`))}var Vk=new Set(["-S","--suffix"]);function Ns(e,t,n,r){if(e.status==="structural-limit")throw new ft;if(e.status!=="complete")return r.findMalformedTarget(e.source);let o={cwd:t,variables:new Map},i=[];for(let s of e.entries){if(s.kind==="operator"){if(!s.boundary)continue;let a=r.findSegmentTarget(i,o);if(a)return a;o=qk(i,o,n,r.normalizeCwd),i=[];continue}if(s.kind==="redirection"){if(s.role==="file-write"&&s.target&&r.isRedirectionTarget(De(s.target,o.variables),o))return s.target;continue}i.push(s.text)}return r.findSegmentTarget(i,o)}function De(e,t){return e.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)(:?[-+])([^}]*)\}/g,(n,r,o,i)=>{let s=t.get(r);if(s===void 0)return n;let a=o.startsWith(":")?s!=="":!0;if(o.endsWith("-"))return a?s:De(i,t);return a?De(i,t):""}).replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g,(n,r)=>t.get(r)??n).replace(/\$([A-Za-z_][A-Za-z0-9_]*)/g,(n,r)=>t.get(r)??n)}function So(e){return e.length>0&&e.every((t)=>/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(t))}function Qb(e,t,n){let r=n.environment.home,o=Gi(e.trim(),n.environment).replace(/\\/g,"/");if(!o)return"";let i=o==="~"?r:o.startsWith("~/")?Xb(r,o.slice(2)):o;return Hk(jk(i)?i:Xb(t,i))}function ve(e,t,n){let r=Qb(e,t,n);if(!r)return"";return Y(r,n.environment.paths,n).replace(/\\/g,"/")}function ev(e,t,n,r){let o=Qb(e,t,n);if(!o)return null;if(r(Uk(o)))return Y(o,n.environment.paths,n).replace(/\\/g,"/");let i=fy(o,n.environment.paths,n);return i===null?null:i.replace(/\\/g,"/")}function Ds(e){let t=[],n=null,r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(i===void 0)break;if(!r&&i==="--"){r=!0;continue}if(!r&&(i==="-t"||i==="--target-directory")){n=e[++o]??null;continue}if(!r&&i.startsWith("--target-directory=")){n=i.slice(19);continue}if(!r&&i.startsWith("-t")&&i.length>2){n=i.slice(2);continue}if(!r&&Vk.has(i)){o++;continue}if(!r&&(i.startsWith("--suffix=")||i.startsWith("--backup=")))continue;if(!r&&i.startsWith("-"))continue;t.push(i)}return n?{sources:t,destination:n}:{sources:t.slice(0,-1),destination:t.at(-1)??null}}function qk(e,t,n,r){let o=So(e)?new Map([...t.variables,...Kk(e,t.variables)]):t.variables,i=or([...e],n.environment),s=G(i[0]??"").toLowerCase()==="cd"?i[1]:void 0;return{cwd:!s||s==="-"?t.cwd:r(De(s,o),t.cwd,n),variables:o}}function Kk(e,t){return e.flatMap((n)=>{let r=/^([A-Za-z_][A-Za-z0-9_]*)(.*)$/.exec(n),o=r?.[2]?.startsWith("=")?r[2].slice(1):void 0;return r?.[1]!==void 0&&o!==void 0?[[r[1],De(o,t)]]:[]})}var He="Git metadata and hooks are protected. Ask the user before modifying them.";function ov(e,t=Su(e.invocation.context.executionCwd)){let n=gn(Ot()),r=e.invocation.context.executionCwd;if(!t)return null;if(e.invocation.route.kind==="patch"||e.invocation.route.kind==="path"||e.invocation.route.kind==="unknown"){if(Os(e.invocation.toolName))return null;let s=e.paths.find((a)=>tA(a,r,t,n));return s?{target:s}:null}if(e.invocation.route.kind!=="command")return null;let o=Ne(e,"input-candidate");if(!o)return null;let i=Ns(o.shell,r,n,{findSegmentTarget:(s,a)=>rA(s,a,t,n),isRedirectionTarget:(s,a)=>nA(s,a.cwd,t,n),findMalformedTarget:()=>null,normalizeCwd:ve});return i?{target:i}:null}function Su(e,t=gn(Ot())){if(typeof e!=="string"||!e)return null;let n=oo(ve(e,e,t));if(!n)return null;try{let r=ve(n,e,t),o=Yk(n),i=o.isFile()?r:null,s=o.isFile()?Bl(n):null,a=(o.isDirectory()?[r]:[s?.gitDir,s?.commonDir]).flatMap((l)=>l?[gt(ve(l,e,t))]:[]),c=[...new Set(o.isDirectory()?[gt(n.replace(/\\/g,"/")),...a]:a)];return Object.freeze({entry:gt(r),markerFile:i?gt(i):null,directories:Object.freeze(c),hooksDirectories:Object.freeze([...new Set(c.flatMap((l)=>{let u=gt(Jk(l,"hooks"));return[u,gt(ve(u,e,t))]}))])})}catch{return null}}function Cn(e,t,n,r,o,i=!1){if(!n)return!1;let s=gt(ve(e,t,o)),a=s.replace(/(\/\.?\*+)+$/,"");if(a!==s&&a!==""){if(vu(a,n))return!0;let c=i||s.slice(a.length).includes("/."),l=(u)=>c?$s(u,a):Xk(u,a);if(n.markerFile&&l(n.markerFile))return!0;return r&&tv(n).some(l)}if(vu(s,n))return!0;return r&&tv(n).some((c)=>$s(c,s))}function Xk(e,t){let n=rv(t,e);if(n===""||n.startsWith("..")||nv(n))return!1;return!n.split(/[\\/]/)[0]?.startsWith(".")}function Qk(e,t,n,r){return Cn(e,t,n,!0,r)}function eA(e,t,n,r){if(!n)return!1;return vu(gt(ve(e,t,r)),n)}function tA(e,t,n,r){if(!n)return!1;return iv(e,t,n,r,n.entry)}function nA(e,t,n,r){if(!n)return!1;return iv(e,t,n,r,n.markerFile)}function iv(e,t,n,r,o){let i=gt(ve(e,t,r));return i===o||av(i,n)}function sv(e,t,n,r){if(!n)return!1;return n.hooksDirectories.some((o)=>e.some((i)=>$s(o,gt(ve(i,t,r)))))}function vu(e,t){return e===t.entry||t.directories.includes(e)||av(e,t)}function av(e,t){return t.hooksDirectories.some((n)=>$s(e,n))}function tv(e){return[e.entry,...e.directories,...e.hooksDirectories]}function $s(e,t){let n=rv(t,e);return n===""||!/^\.\.(?:[\\/]|$)/.test(n)&&!nv(n)}function gt(e){return process.platform==="win32"?e.toLowerCase():e}function rA(e,t,n,r){if(So(e))return null;let o=Kt([...e],r.environment);if(G(o[0]??"").toLowerCase()!=="mv")return null;let i=Ds(o.slice(1)),s=i.sources.find((a)=>Qk(De(a,t.variables),t.cwd,n,r));if(s)return s;return i.destination&&eA(De(i.destination,t.variables),t.cwd,n,r)?i.destination:null}import{isAbsolute as _u,join as oA,normalize as iA,sep as Ls}from"node:path";var cv=process.platform==="win32",sA=/[*?]/;function _o(e,t){if(e==="~")return t;if(e.startsWith("~/"))return`${t}${e.slice(1)}`;return e}function Ws(e,t){if(typeof e!=="string"||e.trim()==="")return"must be a non-empty path string";let n=_o(e.trim(),t);if(!_u(n))return"must be an absolute path or start with ~/";return xo(n,t)}function Fs(e,t){let n=lv(e,t);if(n===null)return"must be a non-empty path string";if(!_u(n))return null;if(xo(n,t)===null)return null;return"cannot be the home directory or a path above it (this would block every command the agent runs)"}var aA="cannot cover the home directory or a path above it (this would disable secret protection everywhere)",cA="cannot cover the guard's own configuration";function lv(e,t){if(typeof e!=="string"||e.trim()==="")return null;return _o(e.trim().replace(/^\$(?:\{HOME\}|HOME(?=\/|$))/,"~"),t)}function Gs(e,t){let n=lv(e,t);if(n===null)return"must be a non-empty path string";if(sA.test(n))return"cannot contain glob characters (* or ?); list the exact file or directory";if(!_u(n))return null;if(xo(n,t)!==null)return aA;return lA(n,t)?cA:null}function lA(e,t){let n=Ms(e),r=Ms(oA(t,".cc-safety-net"));return n===r||n.startsWith(`${r}${Ls}`)}function xo(e,t){let n=Ms(e),r=Ms(t);if(n===r)return"cannot be the home directory";let o=n.endsWith(Ls)?n:`${n}${Ls}`;if(r.startsWith(o))return"cannot contain the home directory";return null}function Ms(e){let t=iA(e);if(cv)t=t.replace(/\//g,"\\").toLowerCase();if(t.length>(cv?3:1)&&t.endsWith(Ls))t=t.slice(0,-1);return t}var mA=process.platform==="win32",uv=64,fA=16384;function Co(e){let t=bb(e,uv,uv,fA);return{expandedTargets:t&&"words"in t?t.words:void 0,unsafeBraceExpansion:t!==void 0&&"limited"in t,targetIsLiteral:t===void 0&&e.provenance==="literal"&&(e.quoted||e.raw!==e.text),tmpdirWordSplittingProtected:pA(e)}}function pA(e){let t=e.parts.filter((n)=>n.provenance==="variable"&&/\$(?:TMPDIR(?![A-Za-z0-9_])|\{TMPDIR\})/.test(n.raw));return t.length>0&&t.every((n)=>gA(e.raw,n.span.start-e.span.start))}function gA(e,t){let n=null,r=!1;for(let o=0;o<t;o++){let i=e[o];if(r){r=!1;continue}if(i==="\\"&&n!=="'"){r=!0;continue}if(n===i){n=null;continue}if(n===null&&(i==="'"||i==='"'))n=i}return n==='"'}function wn(e){let t=e.environment.home,n=e.environment.paths,r=gn(e.environment);return{anchoredCwd:e.originalCwd??e.cwd??null,resolvedCwd:e.cwd??null,strict:e.strict??!1,paranoid:e.paranoid??!1,trustTmpdirVar:e.allowTmpdirVar??!0,posixShell:e.posixShell??!1,tmpdirWordSplittingUnsafe:e.tmpdirWordSplittingUnsafe??!1,trustedTmpdirValue:e.trustedTmpdirValue??e.allowTmpdirVar??!0,environment:e.environment,allowRoots:SA(e.allowPaths,t,n,r),protectedGitMetadata:e.protectedGitMetadata,pathCanonicalizationContext:r}}function nt(e,t,n={}){let r=n.targetIsLiteral??!1;if(!r&&t.tmpdirWordSplittingUnsafe&&!n.tmpdirWordSplittingProtected&&xA(e))return{kind:"outside_anchored_cwd"};let o=!r&&pv(e,t.posixShell);if(pn(e))return{kind:"outside_anchored_cwd"};if(Eu(e,r))return{kind:"root_or_home_target"};if(hA(e,t,r))return{kind:"root_or_home_target"};if(t.resolvedCwd&&Cn(e,t.resolvedCwd,t.protectedGitMetadata,!0,t.pathCanonicalizationContext,!t.posixShell))return{kind:"git_metadata_target"};if(yA(e,t.trustTmpdirVar,t.posixShell,o,r,n.tmpdirWordSplittingProtected??!1,t.trustedTmpdirValue,t.environment))return{kind:"temp_target"};if(o)return{kind:"dynamic_target"};if(_A(e,t,r))return{kind:"temp_target"};let i=t.anchoredCwd;if(i){if(!n.skipHomeCwd&&RA(i,t.environment.home,t.environment.paths,t.pathCanonicalizationContext))return{kind:"home_cwd_target"};if(!n.skipCwdSelf&&PA(e,t.resolvedCwd??i,t.environment.paths,t.pathCanonicalizationContext))return{kind:"cwd_self_target"};if(kA(e,i,t.resolvedCwd??i,o,r,t.environment.paths,t.pathCanonicalizationContext))return{kind:"within_anchored_cwd"}}return{kind:"outside_anchored_cwd"}}function mv(e,t,n={}){let{containmentTarget:r,...o}=n;if(nt(e,t,o).kind!=="temp_target")return!1;let i=e.trim();if(vA(i))return!1;if(Qy(i,t.environment))return!1;return![t.anchoredCwd,t.resolvedCwd].some((s)=>AA(r??i,s,t.environment.paths,t.pathCanonicalizationContext))}function Eu(e,t=!1){let n=e.trim(),r=dv.normalize(n),o=n.replace(/\\/g,"/"),i=r==="/"?r:r.replace(/\/+$/,"");if(i==="/"||i.startsWith("/")&&i.slice(1).split("/").every((s)=>/^\*+$/.test(s)))return!0;if(/^[A-Za-z]:\/+\*?$/.test(o)||/^\/\/[^/]+\/+[^/]+(?:\/+\*?)?$/.test(o))return!0;if(!t&&(r==="~"||r==="~/"||r==="~/*"))return!0;if(!t&&(r==="$HOME"||r==="$HOME/"||r==="$HOME/*"))return!0;if(!t&&(r==="${HOME}"||r==="${HOME}/"||r==="${HOME}/*"))return!0;return!1}function hA(e,t,n){let r=e.trim(),o=n?r:r==="*"?".":r.endsWith("/*")?r.slice(0,-2):r;if(!o)return!1;try{let i=wu(o)?o:t.resolvedCwd?cr(t.resolvedCwd,o):null;if(!i)return!1;let s=Ee(Y(i,t.environment.paths,t.pathCanonicalizationContext));if(s===dA(s).root)return!0;return s===Ee(Y(t.environment.home,t.environment.paths,t.pathCanonicalizationContext))}catch{return!1}}function Ee(e){let t=uA(e);if(mA){if(t=t.replace(/\//g,"\\").toLowerCase(),t.length>3&&t.endsWith("\\"))t=t.slice(0,-1);return t}if(t.length>1&&t.endsWith("/"))t=t.slice(0,-1);return t}function yA(e,t,n,r,o,i,s,a){let c=e.trim();if(fv(c))return!1;if(!r&&Kl(c,a))return!0;return(t||i&&s)&&n&&!o&&bA(c,n)}function bA(e,t){return["$TMPDIR","${TMPDIR}"].some((n)=>{if(e===n)return!0;if(!e.startsWith(`${n}/`))return!1;return!pv(e.slice(n.length+1),t)})}function vA(e){let t=/^(?:\$TMPDIR|\$\{TMPDIR\})(?:\/(.*))?$/.exec(e);if(!t)return!1;return dv.normalize(`/${t[1]??""}`)==="/"}function fv(e){return e.split(/[\\/]+/).includes("..")}function SA(e,t,n,r){if(!e?.length)return[];return e.flatMap((o)=>{let i=_o(o.trim(),t);if(!wu(i))return[];try{let s=Y(i,n,r);if(xo(s,Y(t,n,r)))return[];return[Ee(s)]}catch{return[]}})}function _A(e,t,n){if(t.allowRoots.length===0)return!1;let r=e.trim();if(fv(r))return!1;let o=n?r:_o(r,t.environment.home),i=t.resolvedCwd??t.anchoredCwd,s=wu(o)?o:i?cr(i,o):null;if(!s)return!1;try{let a=Ee(Y(s,t.environment.paths,t.pathCanonicalizationContext));return t.allowRoots.some((c)=>a===c||a.startsWith(c.endsWith(Cu)?c:`${c}${Cu}`))}catch{return!1}}function xA(e){return/\$(?:TMPDIR(?![A-Za-z0-9_])|\{TMPDIR\})/.test(e)}function pv(e,t=!1){return e.includes("$")||e.includes("`")||CA(e)||t&&wA(e)}function CA(e){let t=!1;for(let n of e){if(t){t=!1;continue}if(n==="\\"){t=!0;continue}if(n==="*"||n==="?"||n==="[")return!0}return!1}function wA(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];if(t){t=!1;continue}if(r==="\\"){t=!0;continue}if(r==="{"&&EA(e,n)||(r==="+"||r==="@"||r==="!")&&e[n+1]==="(")return!0}return!1}function EA(e,t){let n=e.indexOf("}",t+1);if(n===-1)return!1;let r=e.slice(t+1,n);return r.includes(",")||r.includes("..")}function RA(e,t,n,r){try{return Ee(Y(e,n,r))===Ee(Y(t,n,r))}catch{try{return Ee(e)===Ee(t)}catch{return!1}}}function PA(e,t,n,r){if(e==="."||e==="./"||e===".\\")return!0;try{return Ee(Y(cr(t,e),n,r))===Ee(Y(t,n,r))}catch{try{return Ee(cr(t,e))===Ee(t)}catch{return!1}}}function kA(e,t,n,r,o,i,s){let a=n??t;if(!o&&(e.startsWith("~")||e.startsWith("$HOME")||e.startsWith("${HOME}")))return!1;if(r)return!1;if(e.startsWith("/")||/^[A-Za-z]:[\\/]/.test(e))try{return xu(e,t,i,s)}catch{return!1}if(e.startsWith("./")||e.startsWith(".\\")||!e.includes("/")&&!e.includes("\\"))try{return xu(cr(a,e),t,i,s)}catch{return!1}if(e.startsWith("../"))return!1;try{return xu(cr(a,e),t,i,s)}catch{return!1}}function xu(e,t,n,r){try{return gv(Y(e,n,r),Y(t,n,r))}catch{return!1}}function AA(e,t,n,r){if(!t)return!1;try{return gv(Y(t,n,r),Y(e,n,r))}catch{return!0}}function gv(e,t){let n=Ee(e),r=Ee(t);return n.startsWith(`${r}${Cu}`)||n===r}var TA=new Set(["remove-item","ri","del","erase","rd","rm","rmdir"]),hv="PowerShell Remove-Item -Recurse -Force outside cwd is blocked. Retry deleting only explicit paths inside the current directory; escalate for anything outside it.",IA="PowerShell Remove-Item -Recurse -Force for non-temporary paths is blocked by the active safety policy. Retry deleting only explicit paths inside the current directory; escalate for anything outside it.",yv="PowerShell Remove-Item target contains variables or pipeline input that cannot be verified safely. Use literal paths within cwd.",bv="PowerShell Remove-Item targeting root or home directory is extremely dangerous and always blocked.",OA="PowerShell Remove-Item -Recurse -Force in home directory is dangerous. Change to a project directory first.",zA="PowerShell Remove-Item receives pipeline input that cannot be verified safely. Use explicit literal paths within cwd.";function vv(e,t,n,r=wn({...n,allowPaths:n.policy?.destructiveCommandAllowPaths})){return NA(e.words.map((o)=>({kind:"word",text:o.text,dynamic:o.provenance!=="literal"})),t,r,n.policy)}function NA(e,t,n,r){let o=e.filter((c)=>c.kind==="word"),i=$A(o),s=o[i];if(!s||!TA.has(jA(s.text)))return null;let a=DA(o.slice(i+1));if(a.whatIfProtected)return null;if(ue(r,"powershell.remove-item-pipeline-dynamic-target",n.strict)&&t&&(a.targets.length===0||a.recursive))return S("powershell.remove-item-pipeline-dynamic-target",zA);for(let c of a.targets)if(!pn(c.text)&&Eu(Pu(c.text)))return S(a.recursive&&a.force?"powershell.remove-item-recursive-force-root-or-home":"powershell.remove-item-root-or-home",bv);for(let c of a.targets)if(n.resolvedCwd&&Cn(Pu(c.text),n.resolvedCwd,n.protectedGitMetadata,a.recursive,n.pathCanonicalizationContext,!0))return S("powershell.remove-item-git-metadata",He);if(!a.recursive||!a.force)return null;if(ue(r,"powershell.remove-item-recursive-force-dynamic-target",n.strict)&&(a.hasDynamicTarget||a.targets.length===0))return S("powershell.remove-item-recursive-force-dynamic-target",yv);for(let c of a.targets){let l=HA(nt(Pu(c.text),n),n,r);if(l)return l}return null}function DA(e){let t=[],n=!1,r=!1,o=!1,i=!1,s=!1;for(let a=0;a<e.length;a++){let c=e[a];if(!c||c.kind!=="word")continue;if(LA(c))continue;if(s){t.push(Ru(c)),i=i||c.dynamic;continue}if(c.text==="--"){s=!0;continue}let l=WA(c.text);if(!l){t.push(Ru(c)),i=i||c.dynamic;continue}if(FA(l.name)){let u=l.value?MA(l.value,c):e[++a];if(u?.kind==="word")t.push(Ru(u)),i=i||u.dynamic;else i=!0;continue}if(GA(l.name)){n=!0;continue}if(ZA(l.name)){r=!0;continue}if(BA(l.name))o=UA(l.value)}return{targets:t,recursive:n,force:r,whatIfProtected:o,hasDynamicTarget:i}}function $A(e){let t=e[0];if(t?.kind==="word"&&t.text==="&"||t?.text===".")return e.length>1?1:0;return 0}function Ru(e){return{text:e.kind==="word"?e.text:"",dynamic:e.kind==="word"&&e.dynamic}}function LA(e){return e.kind==="word"&&e.text===","}function Pu(e){let t=e.replace(/\\/g,"/"),n=/^\$env:(?:userprofile|home)(?=$|\/)/i.exec(t);return n?`$HOME${t.slice(n[0].length)}`:t}function MA(e,t){return{kind:"word",text:e,dynamic:t.kind==="word"&&(t.dynamic||e.includes("$"))}}function WA(e){if(!e.startsWith("-")||e==="-")return null;let t=e.slice(1),n=t.indexOf(":");if(n===-1)return{name:t.toLowerCase()};return{name:t.slice(0,n).toLowerCase(),value:t.slice(n+1)}}function FA(e){return"path".startsWith(e)||"literalpath".startsWith(e)}function GA(e){return"recurse".startsWith(e)}function ZA(e){return e.length>=2&&"force".startsWith(e)}function BA(e){return e==="wi"||"whatif".startsWith(e)}function UA(e){if(e===void 0||e==="")return!0;let t=e.toLowerCase();return t==="$true"||t==="true"}function jA(e){return e.toLowerCase()}function HA(e,t,n){switch(e.kind){case"root_or_home_target":return S("powershell.remove-item-recursive-force-root-or-home",bv);case"git_metadata_target":return S("powershell.remove-item-git-metadata",He);case"temp_target":return null;case"dynamic_target":if(!ue(n,"powershell.remove-item-recursive-force-dynamic-target",t.strict))return null;return S("powershell.remove-item-recursive-force-dynamic-target",yv);case"home_cwd_target":return S("powershell.remove-item-recursive-force-home-cwd",OA);case"cwd_self_target":return S("powershell.remove-item-recursive-force-cwd-self",hv);case"within_anchored_cwd":if(!ue(n,"powershell.remove-item-recursive-force-paranoid",t.paranoid))return null;return S("powershell.remove-item-recursive-force-paranoid",IA);case"outside_anchored_cwd":return S("powershell.remove-item-recursive-force-outside-cwd",hv)}}import{normalize as ra}from"node:path";var $e=new Set(["awk","gawk","nawk","mawk"]),VA=new Set(["-e","--source"]),qA=new Set(["-F","-v","--assign","--field-separator"]),Sv=new Set(["-f","--file"]),KA=new Set(["print","printf","return"]),_v=[{selector:"-e",kind:"inline-code",valueForm:"attached-or-separate"},{selector:"--source",kind:"inline-code",valueForm:"equals-or-separate"},{selector:"-f",kind:"program-file",valueForm:"attached-or-separate"},{selector:"--file",kind:"program-file",valueForm:"equals-or-separate"}],YA="Detected awk system(), pipe, or getline command with dynamic command that cannot be safely analyzed. Use a literal command or process the data without system(), pipes, or getline.";function Us(e,t,n){let r=!1;for(let o of JA(e)){let i=XA(o,n);if(!i)continue;for(let s of i.commands){let a=t(s);if(a)return a;if(s.includes("{}")||/[$`]/.test(s))r=!0}r||=i.dynamic}return r?S("awk.system-dynamic",YA):null}function Au(e){let t=[],n=!1,r=!1,o=!0,i=!0;for(let s=1;s<e.length;s++){let a=e[s];if(a===void 0)break;if(o&&a==="--"){o=!1;continue}if(o&&VA.has(a)){n=!0;let c=e[s+1];if(c!==void 0)t.push({tokenIndex:s+1,kind:"inline-code",value:c});else i=!1;s++;continue}if(o&&a.startsWith("--source=")){n=!0,t.push({tokenIndex:s,kind:"inline-code",value:a.slice(9)});continue}if(o&&a.startsWith("-e")&&a.length>2){n=!0,t.push({tokenIndex:s,kind:"inline-code",value:a.slice(2)});continue}if(o&&(qA.has(a)||Sv.has(a))){if(Sv.has(a)){r=!0;let c=e[s+1];if(c!==void 0)t.push({tokenIndex:s+1,kind:"program-file",value:c});else i=!1}else if(e[s+1]===void 0)i=!1;s++;continue}if(o&&(a.startsWith("-F")||a.startsWith("-v")&&a.slice(2).includes("=")))continue;if(o&&a.startsWith("-f")&&a.length>2){r=!0,t.push({tokenIndex:s,kind:"program-file",value:a.slice(2)});continue}if(o&&(a.startsWith("--assign=")||a.startsWith("--field-separator=")))continue;if(o&&a.startsWith("--file=")){r=!0,t.push({tokenIndex:s,kind:"program-file",value:a.slice(7)});continue}if(o&&a.startsWith("-")&&a!=="-")continue;if(o=!1,!n&&!r)t.push({tokenIndex:s,kind:"main-program",value:a});return{sources:t,optionsOpen:!1}}return{sources:i?t:[],optionsOpen:o&&i}}function Eo(e){return Au(e).sources}function JA(e){return Eo(e).filter((t)=>t.kind!=="program-file").map((t)=>t.value)}function XA(e,t){Te(t,e);let n=e.includes("system")?Tu(e,t):null,r=QA(e,t);if(!n&&!r)return null;return{dynamic:!!n?.dynamic||!!r?.dynamic,commands:[...n?.commands??[],...r?.commands??[]]}}function Tu(e,t){Te(t,e);let n=[],r=!1,o=!1,i=0;while(i<e.length){let s=e[i];if(s==='"'||s==="'"){i=Bs(e,i,s)?.endIndex??i+1;continue}if(s==="#"){i=xv(e,i+1);continue}if(s==="/"&&Cv(e,i)){i=wv(e,i+1)??i+1;continue}if(!e.startsWith("system",i)){i++;continue}let a=i;if(i+=6,wo(e[a-1])||wo(e[i]))continue;let c=Zs(e,i);if(e[c]!=="(")continue;c=Zs(e,c+1);let l=e[c];if(l!=='"'&&l!=="'"){r=!0,o=!0;continue}let u=Bs(e,c,l);if(!u){r=!0,o=!0;continue}if(c=Zs(e,u.endIndex),r=!0,e[c]!==")"){o=!0,i=u.endIndex;continue}n.push(u.value),i=c+1}if(!r)return null;return{dynamic:o,commands:n}}function QA(e,t){Te(t,e);let n=[],r=!1,o=!1,i=0,s=0,a=null,c=null,l=0;while(i<e.length){let u=e[i];if(!u)break;if(u==='"'||u==="'"){let m=Bs(e,i,u);if(m&&l===s)c={...m,startIndex:i};l=m?.endIndex??i+1,i=m?.endIndex??i+1;continue}if(u==="#"){i=xv(e,i+1),s=i,a=null,c=null,l=i;continue}if(u==="/"&&Cv(e,i)){let m=wv(e,i+1);l=m??i+1,i=m??i+1;continue}if(`;
49
+ {}`.includes(u)){i++,s=i,a=null,c=null,l=i;continue}if(a===null&&(ku(e,i,"print")||ku(e,i,"printf")))a=i;if(u!=="|"||e[i-1]==="|"||e[i+1]==="|"){if(!/\s/.test(u))l=i+1;i++;continue}let d=e[i+1]==="&"?i+2:i+1,f=Zs(e,d);if(ku(e,f,"getline")){o=!0;let m=nT(s,c,l);if(m===null)r=!0;else n.push(m);l=d,i=d;continue}if(oT(s,a)){o=!0;let m=tT(e,f);if(!m){r=!0,l=d,i=d;continue}if(!eT(e,m.endIndex)){r=!0,l=m.endIndex,i=m.endIndex;continue}n.push(m.value),l=m.endIndex,i=m.endIndex;continue}l=d,i++}if(!o)return null;return{dynamic:r,commands:n}}function wo(e){return!!e&&/[A-Za-z0-9_]/.test(e)}function Zs(e,t){let n=t;while(/\s/.test(e[n]??""))n++;return n}function eT(e,t){let n=t;while(/[\t\f\v\r ]/.test(e[n]??""))n++;let r=e[n];return!r||`;
50
+ }#`.includes(r)}function Bs(e,t,n){let r="",o=!1;for(let i=t+1;i<e.length;i++){let s=e[i];if(!s)break;if(o){let a=rT(e,i);if(!a)return null;r+=a.value,i=a.endIndex,o=!1;continue}if(s==="\\"){o=!0;continue}if(s===n)return{value:r,endIndex:i+1};r+=s}return null}function tT(e,t){let n=e[t];if(n!=='"'&&n!=="'")return null;return Bs(e,t,n)}function nT(e,t,n){if(!t)return null;return t.startIndex>=e&&t.endIndex===n?t.value:null}function rT(e,t){let n=e[t];if(!n)return null;if(n==="x"){let o=e.slice(t+1,t+3);if(!/^[0-9A-Fa-f]{2}$/.test(o))return null;return{value:String.fromCharCode(Number.parseInt(o,16)),endIndex:t+2}}if(/[0-7]/.test(n)){let o=/^[0-7]{1,3}/.exec(e.slice(t));if(!o)return null;return{value:String.fromCharCode(Number.parseInt(o[0],8)),endIndex:t+o[0].length-1}}return{value:{a:"\x07",b:"\b",f:"\f",n:`
51
+ `,r:"\r",t:"\t",v:"\v"}[n]??n,endIndex:t}}function ku(e,t,n){return e.startsWith(n,t)&&!wo(e[t-1])&&!wo(e[t+n.length])}function oT(e,t){return t!==null&&t>=e}function xv(e,t){let n=e.indexOf(`
52
+ `,t);return n===-1?e.length:n+1}function Cv(e,t){let n=iT(e,t);if(n===-1)return!0;if("{([,;!~=".includes(e[n]??""))return!0;let r=n;while(wo(e[r-1]))r--;return KA.has(e.slice(r,n+1))}function iT(e,t){for(let n=t-1;n>=0;n--)if(!/\s/.test(e[n]??""))return n;return-1}function wv(e,t){let n=!1;for(let r=t;r<e.length;r++){let o=e[r];if(!o)break;if(n){n=!1;continue}if(o==="\\"){n=!0;continue}if(o==="/")return r+1}return null}var Ev=new Set(["rm","find","xargs","parallel"]),sT=new Set(["sudo","env","command","builtin"]),aT=new Set(["git","busybox",...Ev,...de,...By,...$e]);function js(e,t){let n=e[0];if(!n||!t.transparentWrappers.includes(G(n)))return null;let r=G(n),o=e[1]==="--"?2:1,i=cT(e,o,r,t),s=i[0];if(s===void 0)return null;return{wrapper:r,tokens:[...e.slice(s)],childIndex:s,alternativeChildIndices:i.slice(1)}}function cT(e,t,n,r){let o=e[1]==="--",i=[];for(let s=t;s<e.length;s++){let a=e[s];if(!a)continue;if(G(a)!==n&&lT(a,r))i.push(s);else if(ns.has(H(a)))break;if(o)break}return i}function lT(e,t){let n=G(e),r=H(e);return r==="git"||n==="busybox"||En(e)||Ev.has(n)||t.transparentWrappers.includes(n)||de.has(r)||e==="$SHELL"||Oe(r)||$e.has(r)||t.rules.some((o)=>o.command===n)}function En(e){return sT.has(e.toLowerCase())}function Rv(e){let t=H(e);return aT.has(t)||Oe(t)}function rt(e,t){let n=t.policy??{rules:[],transparentWrappers:[]};return Hs([...e],t.environment,t.cwd,t.cwd,new Map,new Map(t.envAssignments??[]),n,{iterations:0},!1)}function*Hs(e,t,n,r,o,i,s,a,c){let l=ps(e,t,n,i);for(let[m,p]of l.envAssignments)i.set(m,p),o.set(m,p);let{tokens:u,cwd:d}=l;if(l.envSplitValues){let m=fs(l.envSplitValues,u);if(!m)throw new Ie;Iu(a),yield*Hs(m,t,d,r,o,i,s,a,c);return}if(En(u[0]??""))throw new Ie;let f=js(u,s);if(f){for(let m of[f.childIndex,...f.alternativeChildIndices])Iu(a),yield*Hs(m===f.childIndex?f.tokens:[...u.slice(m)],t,d,r,new Map(o),new Map(i),s,a,!0);return}if(dT(u)){Iu(a),yield*Hs([...u.slice(1)],t,d,r,o,i,s,a,c);return}yield uT(u,d,r,o,i,c)}function uT(e,t,n,r,o,i){return{tokens:e,cwd:t===null?void 0:t??n,wrapperCwd:t,wrapperEnvAssignments:r,envAssignments:o,head:G(e[0]??"").toLowerCase(),wrappedByTransparent:i}}function Iu(e){if(e.iterations>=Qn)throw new Ie;e.iterations++}function dT(e){return G(e[0]??"").toLowerCase()==="busybox"&&e.length>1}function Ou(e,t){let n=[],r=t;while(r<e.length){let o=e[r];if(o===void 0||o===":::")break;n.push(o),r++}return{markerIndex:r<e.length&&e[r]===":::"?r:-1,templateTokens:n}}function ot(e){let t=!1,n=!1;for(let r of e){if(r==="--")break;if(r==="-r"||r==="-R"||zu(r,"recursive"))t=!0;else if(r==="-f"||zu(r,"force"))n=!0;else if(r.startsWith("-")&&!r.startsWith("--")){if(r.includes("r")||r.includes("R"))t=!0;if(r.includes("f"))n=!0}}return t&&n}function Pv(e){let t=e.indexOf("--");return e.slice(1,t===-1?void 0:t).some((n)=>zu(n,"recursive")||/^-[A-Za-z]+$/.test(n)&&/[rR]/.test(n.slice(1)))}function zu(e,t){return e.length>2&&e.startsWith("--")&&t.startsWith(e.slice(2))}var mT="find -delete permanently removes files. Use -print first to preview.",fT="find -exec rm -rf is dangerous. Use explicit file list instead.",pT=new Set(["-exec","-execdir","-ok","-okdir"]),gT=new Map([...["-Bmin","-Bnewer","-Btime","-amin","-anewer","-atime","-cmin","-cnewer","-context","-ctime","-f","-flags","-fprint","-fprint0","-fls","-fstype","-gid","-group","-ilname","-iname","-inum","-ipath","-iwholename","-iregex","-links","-lname","-maxdepth","-mindepth","-mmin","-mnewer","-mtime","-name","-newer","-newerXY","-newermt","-path","-perm","-printf","-regex","-samefile","-size","-type","-uid","-used","-user","-wholename","-xattrname","-xtype"].map((e)=>[e,1]),["-fprintf",2]]);function Vs(e,t){let n=e.map(N),r=hT(e,n,t);if(r)return r;if(Ks(n,1)&&!bT(e,n,t)){let s=O(S("find.delete",mT),t.policy);if(s)return s}let o=t.derivedCommandWorkBudget??es(),i=0;while(i<n.length){let s=n[i],a=Jt(s??"");if(a>0){i+=a+1;continue}if(!Mt(s)){i++;continue}Je(o,n.length-i-1);let c=Ro(n,i);i=c.nextIndex;let l=ST(c.tokens,t.environment);if(l){let m=O(l,t.policy);if(m)return m}let u=s==="-execdir"||s==="-okdir",d=t.analyzeTokens?t.analyzeTokens(c.tokens,u?null:t.cwd):t.analyzeNested?t.analyzeNested(c.tokens.join(" "),{effectiveCwd:u?void 0:t.cwd,envAssignments:t.envAssignments}):null,f=d?.id.startsWith("custom.")?d:O(d,t.policy);if(f)return f}return null}function hT(e,t,n){if(!Ks(t,1)&&!Nu(t,n.environment))return null;let o=qs(e)??j(["."]),i=wn({...n,allowPaths:n.policy?.destructiveCommandAllowPaths,posixShell:!0});for(let s of o){let a=Co(s);for(let c of a.expandedTargets??[N(s)]){let l=nt(c,i,{targetIsLiteral:a.expandedTargets!==void 0||a.targetIsLiteral,tmpdirWordSplittingProtected:a.tmpdirWordSplittingProtected});if(l.kind==="root_or_home_target")return S("rm.recursive-force-root-or-home","rm -rf targeting root or home directory is extremely dangerous and always blocked.");if(l.kind==="git_metadata_target")return S("find.delete-git-metadata",He)}}if(yT(t)&&i.resolvedCwd&&sv(o.map(N),i.resolvedCwd,i.protectedGitMetadata,i.pathCanonicalizationContext))return S("find.delete-git-metadata",He);return null}function Nu(e,t){let n=0;while(n<e.length){if(!Mt(e[n])){n++;continue}let r=Ro(e,n),o=Kt([...r.tokens],t),i=G(o[0]??"").toLowerCase();if((i==="rm"||i==="rmdir")&&o.some((s)=>s.includes("{}")))return!0;n=r.nextIndex}return!1}function yT(e){return e.some((t,n)=>{if(!["-name","-iname"].includes(t))return!1;return e[n+1]?.toLowerCase()==="hooks"})}function bT(e,t,n){if(t.includes("-L")||t.includes("-f")||t.includes("-follow"))return!1;let r=qs(e);if(!r)return!1;let o=n.envAssignments??new Map,i=ql(o,n.environment),s=n.trustedTmpdirValue??$t(o,n.environment),a=n.allowTmpdirVar??!lo(o,n.environment),c=wn({environment:n.environment,protectedGitMetadata:n.protectedGitMetadata,cwd:n.cwd,originalCwd:n.originalCwd,strict:n.strict,allowTmpdirVar:a&&s&&Boolean(i),allowPaths:n.policy?.destructiveCommandAllowPaths,posixShell:!0,tmpdirWordSplittingUnsafe:n.tmpdirWordSplittingUnsafe??dt(o,n.environment),trustedTmpdirValue:s});return r.every((l)=>{let u=Co(l);if(u.unsafeBraceExpansion)return!1;return(u.expandedTargets??[N(l)]).every((d)=>mv(d,c,{containmentTarget:vT(d,i),targetIsLiteral:u.expandedTargets!==void 0||u.targetIsLiteral,tmpdirWordSplittingProtected:u.tmpdirWordSplittingProtected}))})}function vT(e,t){if(!t)return e;return e.replace(/^(?:\$TMPDIR|\$\{TMPDIR\})/,()=>t)}function qs(e){let t=(o)=>{let i=e[o];return i?N(i):void 0},n=1;while(t(n)==="-H"||t(n)==="-P")n++;if(t(n)==="--")n++;let r=[];while(n<e.length){let o=t(n),i=e[n];if(!o||!i||o.startsWith("-")||["!","(",")"].includes(o))break;r.push(i),n++}return r.length>0?r:null}function ST(e,t){let n=or([...e],t);if(n.length===0)return null;let r=G(n[0]??"");if(r==="busybox"&&n.length>1)n=n.slice(1),r=G(n[0]??"");if(r==="rm"&&ot(n))return S("find.exec-rm-recursive-force",fT);return null}function Ro(e,t){let n=t+1;while(n<e.length&&e[n]!==";"&&!(e[n]==="+"&&e[n-1]==="{}"))n++;return{tokens:e.slice(t+1,n),nextIndex:Math.min(n+1,e.length)}}function Ks(e,t){let n=t;while(n<e.length){let r=e[n];if(!r){n++;continue}if(Mt(r)){n=Ro(e,n).nextIndex;continue}let o=Jt(r);if(o>0){n+=o+1;continue}if(r==="-delete")return!0;n++}return!1}function Jt(e){return gT.get(e)??(/^-newer[A-Za-z]{2}$/.test(e)?1:0)}function Mt(e){return e!==void 0&&pT.has(e)}function Po(e){let t=et(e,"posix");if(t.status!=="complete"||t.nodes.length!==1)return null;let n=t.nodes[0];if(n?.kind!=="command")return null;if(n.redirections.length>0||n.nested.length>0)return null;if(n.words.some((r)=>r.provenance==="command-substitution"))return null;return n.words.map((r)=>r.text)}var _T=5,Du="Git aliases supplied through command-line or environment config can hide or execute commands. Run git without Git alias overrides, or ask the user to run it manually.";function Se(e){let t=e.indexOf("--");if(t===-1)return{index:-1,before:e,after:[]};return{index:t,before:e.slice(0,t),after:e.slice(t+1)}}function Av(e,t,n){let r=Iv(e,t,n),o=xT(r.entries);if(o.size===0)return{blockedReason:r.blockedReason,expanded:!1,tokens:e};let i=e,s=!1;for(let a=0;a<_T;a++){let{subcommand:c,rest:l}=it(i),u=c?.toLowerCase();if(!u||!o.has(u))return{blockedReason:r.blockedReason,expanded:s,tokens:i};let d=o.get(u),f=PT(d);if(f===null||f.length===0)return{blockedReason:Du,expanded:!0,tokens:i};i=["git",...f,...l],s=!0}return{blockedReason:Du,expanded:!0,tokens:i}}function Tv(e,t,n){return Iv(e,t,n).entries.some((r)=>r.key.toLowerCase()==="core.sshcommand")}function it(e){if(e.length===0)return{subcommand:null,rest:[]};let t=e[0];if((t?G(t).toLowerCase():null)!=="git")return{subcommand:null,rest:[]};let r=1;while(r<e.length){let o=e[r];if(!o)break;if(o==="--"){let i=e[r+1];if(i&&!i.startsWith("-"))return{subcommand:i,rest:e.slice(r+2)};return{subcommand:null,rest:e.slice(r+1)}}if(o.startsWith("-"))if(ut.has(o))r+=2;else if(o.startsWith("-c")&&o.length>2)r++;else if(o.startsWith("-C")&&o.length>2)r++;else r++;else return{subcommand:o,rest:e.slice(r+1)}}return{subcommand:null,rest:[]}}function xT(e){let t=new Map;for(let n of e){let r=n.key.toLowerCase();if(!r.startsWith("alias."))continue;let o=r.slice(6);if(o!=="")t.set(o,n.value)}return t}function Iv(e,t,n){if(e.length===0)return{blockedReason:null,entries:[]};let r=e[0];if((r?G(r).toLowerCase():null)!=="git")return{blockedReason:null,entries:[]};let i=wT(t,n);return{blockedReason:i.blockedReason,entries:[...i.entries,...CT(e,t,n)]}}function CT(e,t,n){let r=[],o=1;while(o<e.length){let i=e[o];if(!i||i==="--"||!i.startsWith("-"))return r;if(i==="-c"){let s=$u(e[o+1]);if(s)r.push(s);o+=2;continue}if(i.startsWith("-c")&&i.length>2){let s=$u(i.slice(2));if(s)r.push(s);o++;continue}if(i==="--config-env"){let s=kv(e[o+1],t,n);if(s)r.push(s);o+=2;continue}if(i.startsWith("--config-env=")){let s=kv(i.slice(13),t,n);if(s)r.push(s);o++;continue}if(ut.has(i)){o+=2;continue}o++}return r}function wT(e,t){let n=ET(e,t),r=RT(e,t);return{blockedReason:n===null||r===null?Du:null,entries:[...n??[],...r??[]]}}function ET(e,t){let n=Ue("GIT_CONFIG_PARAMETERS",e,t);if(n===void 0)return[];let r=[],o=Po(n);if(!o)return null;for(let i of o){let s=$u(i);if(!s)return null;r.push(s)}return r}function RT(e,t){let n=Ui(e,t);if(n.state==="absent")return[];if(n.state==="invalid")return null;let r=[];for(let o=0;o<n.count;o++){let i=Ue(`GIT_CONFIG_KEY_${o}`,e,t)?.trim(),s=Ue(`GIT_CONFIG_VALUE_${o}`,e,t);if(!i||s===void 0)return null;r.push({key:i,value:s})}return r}function $u(e){if(!e)return null;let t=e.indexOf("=");return{key:(t===-1?e:e.slice(0,t)).trim(),value:t===-1?void 0:e.slice(t+1)}}function kv(e,t,n){let r=e?.indexOf("=")??-1;if(!e||r===-1)return null;return{key:e.slice(0,r).trim(),value:Ue(e.slice(r+1),t,n)}}function PT(e){let t=e?.trimStart();if(!t||t.startsWith("!"))return null;return Po(t)}var kT="git checkout -- discards uncommitted changes permanently. Use 'git stash' first.",AT="git checkout --force discards uncommitted changes. Use 'git stash' first.",TT="git checkout <ref> -- <path> overwrites working tree with ref version. Use 'git stash' first.",IT="git checkout --pathspec-from-file can overwrite multiple files. Use 'git stash' first.",OT="git checkout with multiple positional args may overwrite files. Use 'git switch' for branches or 'git restore' for files.",zT="git switch --discard-changes discards uncommitted changes. Use 'git stash' first.",NT="git switch --force discards uncommitted changes. Use 'git stash' first.",DT="git restore discards uncommitted changes. Use 'git stash' first, or use --staged to only unstage.",$T="git restore --worktree explicitly discards working tree changes. Use 'git stash' first.",LT="git reset --hard destroys all uncommitted changes permanently. Use 'git stash' first.",MT="git reset --merge can lose uncommitted changes. Use 'git stash' first.",WT="git clean -f removes untracked files permanently. Use 'git clean -n' to preview first.",FT="git rm --force removes tracked files from the working tree. Use 'git rm --cached' to keep the files, or 'git rm --dry-run' to preview first.",GT="git push --force destroys remote history. Use --force-with-lease for safer force push.",ZT="git push deletes remote refs. Ask the user to run it manually if deletion is intended.",BT="git push --mirror can force-update and delete remote refs. Ask the user to run it manually if mirror push is intended.",UT="git branch -D force-deletes without merge check. Use -d for safe delete.",jT="git rebase --abort discards rebase conflict resolutions. Use 'git status' first.",HT="git merge --abort discards merge conflict resolutions. Use 'git status' first.",VT="git tag -d permanently deletes tags. Ask the user to run it manually if deletion is intended.",qT="git reflog delete removes recovery history. Ask the user to run it manually if deletion is intended.",KT="git stash drop permanently deletes stashed changes. Consider 'git stash list' first.",YT="git stash clear deletes ALL stashed changes permanently. Use 'git stash list' to review; ask the user to run it manually if intended.",JT="git worktree remove --force can delete uncommitted changes. Remove --force flag.",Ov=new Set(["-b","-B","--orphan","--conflict","--inter-hunk-context","--pathspec-from-file","--unified"]),zv=new Set(["--recurse-submodules","--track","-t"]),Lu=new Set(["-b","-B","-U"]),Mu=new Set(["-c","-C"]),XT=new Set(["--source","--conflict","--unified","--inter-hunk-context"]),QT=new Set(["-q","--quiet","--no-quiet","-f","--force","--no-force","-d","--detach","--no-detach","-m","--merge","--no-merge","-p","--patch","--no-patch","--guess","--no-guess","--overlay","--no-overlay","--ours","--theirs","--ignore-skip-worktree-bits","--no-ignore-skip-worktree-bits","--no-track","--overwrite-ignore","--no-overwrite-ignore","--ignore-other-worktrees","--no-ignore-other-worktrees","--progress","--no-progress","--pathspec-file-nul","--no-pathspec-file-nul","--no-recurse-submodules"]);function B(e,t){let n=e.split("=",1)[0]??e;return n.length>=4&&t.startsWith(n)&&n.startsWith("--")&&n.slice(2).length>=2}var lr=new Set(["branch","checkout","clean","merge","push","rebase","reflog","reset","restore","rm","stash","switch","tag","worktree"]);function Dv(e){let{subcommand:t,rest:n}=it(e);if(!t)return null;switch(t.toLowerCase()){case"checkout":return Xt(eI(n));case"switch":return Xt(tI(n));case"restore":return Xt(rI(n));case"reset":return iI(n);case"clean":return Xt(aI(n));case"rm":return Xt(cI(n));case"push":return Rn(lI(n));case"branch":return Rn(mI(n));case"stash":return Rn(yI(n));case"worktree":return Rn(bI(n));case"rebase":return Xt(fI(n));case"merge":return Xt(pI(n));case"tag":return Rn(gI(n));case"reflog":return Rn(hI(n));default:return null}}function Xt(e){return e?{...e,localDiscard:!0}:null}function Rn(e){return e?{...e,localDiscard:!1}:null}function eI(e){let{index:t,before:n}=Se(e),r=we(n,{shortOptsWithValue:Lu});if(n.some((i)=>B(i,"--force"))||r.has("-f"))return S("git.checkout-force",AT);for(let i of e){if(i==="-b"||i==="-B"||i==="--orphan")return null;if(B(i,"--pathspec-from-file"))return S("git.checkout-pathspec-from-file",IT)}if(t!==-1){if(n.some((s)=>!s.startsWith("-")))return S("git.checkout-ref-path",TT);return S("git.checkout-double-dash",kT)}if(nI(e).length>=2)return S("git.checkout-ambiguous",OT);return null}function tI(e){let{before:t}=Se(e);if(t.some((r)=>B(r,"--discard-changes")))return S("git.switch-discard-changes",zT);let n=we(t,{shortOptsWithValue:Mu});if(t.some((r)=>B(r,"--force"))||n.has("-f"))return S("git.switch-force",NT);return null}function nI(e){let t=[],n=0;while(n<e.length){let r=e[n];if(!r)break;if(r==="--")break;if(r.startsWith("-"))if(Ov.has(r))n+=2;else if(r.startsWith("--")&&r.includes("="))n++;else if(zv.has(r)){let o=e[n+1];if(o&&!o.startsWith("-")&&(r==="--recurse-submodules"||r==="--track"||r==="-t"))if((r==="--recurse-submodules"?["checkout","on-demand"]:["direct","inherit"]).includes(o))n+=2;else n++;else n++}else if(r.startsWith("--")&&!QT.has(r)&&!Ov.has(r)&&!zv.has(r))n++;else n++;else t.push(r),n++}return t}function rI(e){let t=oI(e);if(t.isTerminal||!t.hasPathspec&&!t.hasPatch||!t.hasWorktree)return null;return t.hasExplicitLocation?S("git.restore-worktree",$T):S("git.restore-unstaged",DT)}function oI(e){let t=!1,n=!1,r=!0,o=!1,i=(s)=>{if(!o)r=!1,o=!0;if(s!==void 0)r=s};for(let s=0;s<e.length;s++){let a=e[s];if(a===void 0)break;if(a==="--"){t||=s+1<e.length;break}if(a==="--pathspec-from-file"){t=!0,s++;continue}if(a.startsWith("--pathspec-from-file=")){t=!0;continue}if(a==="-h"||a==="--help"||a==="--version")return{hasPathspec:t,hasPatch:n,hasWorktree:r,hasExplicitLocation:o,isTerminal:!0};if(a==="--staged"){i();continue}if(a==="--no-staged"){i();continue}if(a==="--worktree"){i(!0);continue}if(a==="--no-worktree"){i(!1);continue}if(a==="--patch"){n=!0;continue}if(a==="--no-patch"){n=!1;continue}if(XT.has(a)){s++;continue}if(a.startsWith("--"))continue;if(a==="-"){t=!0;continue}if(!a.startsWith("-")){t=!0;continue}for(let c=1;c<a.length;c++){let l=a.charAt(c);if(l==="h")return{hasPathspec:t,hasPatch:n,hasWorktree:r,hasExplicitLocation:o,isTerminal:!0};if(l==="S"){i();continue}if(l==="W"){i(!0);continue}if(l==="p"){n=!0;continue}if(l==="s"||l==="U"){if(c===a.length-1)s++;break}}}return{hasPathspec:t,hasPatch:n,hasWorktree:r,hasExplicitLocation:o,isTerminal:!1}}function iI(e){let t=null;for(let n of e){if(B(n,"--hard")){t=S("git.reset-hard",LT);break}if(B(n,"--merge")){t=S("git.reset-merge",MT);break}}if(!t)return null;return sI(e)?Rn(t):Xt(t)}function sI(e){for(let t of e){if(t==="--")return!1;if(!t.startsWith("-"))return!0}return!1}function aI(e){for(let n of e)if(n==="-n"||B(n,"--dry-run"))return null;let t=we(e.filter((n)=>n!=="--"));if(e.some((n)=>B(n,"--force"))||t.has("-f"))return S("git.clean-force",WT);return null}function cI(e){let t=!1,n=!1,r=!1;for(let o of Se(e).before){if(B(o,"--no-force")){t=!1;continue}if(B(o,"--force")){t=!0;continue}if(B(o,"--no-cached")){n=!1;continue}if(B(o,"--cached")){n=!0;continue}if(B(o,"--no-dry-run")){r=!1;continue}if(B(o,"--dry-run")){r=!0;continue}let i=we([o]);t||=i.has("-f"),r||=i.has("-n")}return t&&!n&&!r?S("git.rm-force",FT):null}function lI(e){let{before:t,after:n}=Se(e),r=we(t);if(t.some((s)=>B(s,"--mirror")))return S("git.push-mirror",BT);if(t.some((s)=>B(s,"--force"))||r.has("-f")||Nv(t,n).some(uI))return S("git.push-force",GT);if(t.some((s)=>B(s,"--delete"))||r.has("-d")||Nv(t,n).some(dI))return S("git.push-delete",ZT);return null}function Nv(e,t){return[...e.filter((n)=>n!==""&&!n.startsWith("-")),...t]}function uI(e){return e.startsWith("+")||e.includes(":+")}function dI(e){return e.length>1&&e.startsWith(":")}function mI(e){let{before:t}=Se(e),n=we(t),r=n.has("-D")||n.has("-d")||t.some((i)=>B(i,"--delete")),o=n.has("-D")||n.has("-f")||t.some((i)=>B(i,"--force"));if(r&&o)return S("git.branch-force-delete",UT);return null}function fI(e){let{before:t}=Se(e);return t.some((n)=>B(n,"--abort"))?S("git.rebase-abort",jT):null}function pI(e){let{before:t}=Se(e);return t.some((n)=>B(n,"--abort"))?S("git.merge-abort",HT):null}function gI(e){let{before:t}=Se(e);return we(t).has("-d")||t.some((r)=>B(r,"--delete"))?S("git.tag-delete",VT):null}function hI(e){return e[0]==="delete"?S("git.reflog-delete",qT):null}function yI(e){for(let t of e){if(t==="drop")return S("git.stash-drop",KT);if(t==="clear")return S("git.stash-clear",YT)}return null}function bI(e){let{before:t}=Se(e);if(!t.includes("remove"))return null;let r=we(t);if(t.some((o)=>B(o,"--force"))||r.has("-f"))return S("git.worktree-remove-force",JT);return null}import{execFileSync as vI}from"node:child_process";import{existsSync as Fu,readFileSync as Gu}from"node:fs";import{dirname as SI,isAbsolute as Mv,join as Wu,resolve as Wv}from"node:path";var _I=["/usr/bin/git","/usr/local/bin/git","/opt/homebrew/bin/git","C:\\Program Files\\Git\\cmd\\git.exe","C:\\Program Files\\Git\\bin\\git.exe"];function Fv(e,t,n,r){let o=xI(e,t,n);if(o!==null)return o;let i=CI(t,n);if(i!==null)return i;if(hy(n))return!0;return wI(r)}function xI(e,t,n){let r=null,o=1;while(o<e.length){let i=e[o];if(!i||i==="--")return r;if(!i.startsWith("-"))return r;if(i==="-c"){let s=$v(e[o+1]);if(s!==null)r=s;o+=2;continue}if(i.startsWith("-c")&&i.length>2){let s=$v(i.slice(2));if(s!==null)r=s;o++;continue}if(i==="--config-env"){let s=Lv(e[o+1],t,n);if(s!==null)r=s;o+=2;continue}if(i.startsWith("--config-env=")){let s=Lv(i.slice(13),t,n);if(s!==null)r=s;o++;continue}if(ut.has(i))o+=2;else o++}return r}function CI(e,t){if(Ue("GIT_CONFIG_PARAMETERS",e,t)!==void 0)return!0;let n=Ui(e,t);if(n.state==="absent")return null;if(n.state==="invalid")return!0;let r=null;for(let o=0;o<n.count;o++){let i=Ue(`GIT_CONFIG_KEY_${o}`,e,t),s=Ue(`GIT_CONFIG_VALUE_${o}`,e,t);if(!i?.trim()||s===void 0)return!0;let a=i.trim().toLowerCase();if(Zu(a))return!0;if(a!=="submodule.recurse")continue;r=ko(s)}return r}function wI(e,t=RI()){let n=EI(e);if(n===null||n)return!0;if(t===null)return!0;try{let r=vI(t,["config","--get","submodule.recurse"],{cwd:e,encoding:"utf8",env:PI(process.env),stdio:["ignore","pipe","ignore"]}).trim();return ko(r)}catch(r){return!kI(r)}}function EI(e){let t=AI(e);if(t===null)return null;for(let n of t){if(!Fu(n))continue;if(OI(n))return!0}return!1}function RI(){for(let e of _I)if(Fu(e))return e;return null}function PI(e){let t={...e};for(let n of Object.keys(t))if(to(n))delete t[n];return t}function kI(e){return typeof e==="object"&&e!==null&&"status"in e&&e.status===1}function AI(e){let t=oo(e);if(t===null)return null;let n=TI(t);if(n===null)return null;let r=II(n);if(r===null)return null;return[Wu(r,"config"),Wu(n,"config.worktree")]}function TI(e){try{let n=Gu(e,"utf-8").split(/\r?\n/,1)[0]?.trim()??"";if(!n.startsWith("gitdir:"))return e;let r=n.slice(7).trim();if(r==="")return null;return Mv(r)?r:Wv(SI(e),r)}catch{return null}}function II(e){let t=Wu(e,"commondir");if(!Fu(t))return e;try{let n=Gu(t,"utf-8").split(/\r?\n/,1)[0]?.trim()??"";if(n==="")return null;return Mv(n)?n:Wv(e,n)}catch{return null}}function OI(e){let t;try{t=Gu(e,"utf-8")}catch{return!0}let n="",r=!1;for(let o of t.split(/\r?\n/)){let i=o.trim();if(i===""||i.startsWith("#")||i.startsWith(";"))continue;let s=i.match(/^\[([^\]]+)\]$/);if(s){n=s[1]?.trim().toLowerCase()??"";continue}let a=i.indexOf("="),c=(a===-1?i:i.slice(0,a)).trim().toLowerCase(),l=a===-1?"true":i.slice(a+1).trim();if(zI(n)&&c==="path")return!0;if(n==="submodule"&&c==="recurse")r=ko(l)}return r}function zI(e){return e==="include"||e.startsWith("includeif ")}function $v(e){if(!e)return null;let t=e.indexOf("="),n=(t===-1?e:e.slice(0,t)).toLowerCase();if(Zu(n))return!0;if(n!=="submodule.recurse")return null;let r=t===-1?"true":e.slice(t+1).toLowerCase();return ko(r)}function ko(e){let t=e.toLowerCase();return t!=="false"&&t!=="no"&&t!=="off"&&t!=="0"}function Lv(e,t,n){let r=e?.indexOf("=")??-1;if(!e||r===-1)return null;let o=e.slice(0,r).toLowerCase();if(Zu(o))return!0;if(o!=="submodule.recurse")return null;let i=Ue(e.slice(r+1),t,n);return i===void 0||ko(i)}function Zu(e){return e==="include.path"||e.startsWith("includeif.")&&e.endsWith(".path")}function Gv(e,t,n){if(!t.localDiscard||!n.worktreeMode||Sy(n.env,n.envAssignments))return null;let r=_y(e,n.cwd);if(!r.gitCwd||r.hasExplicitGitContext)return null;if(!xy(r.gitCwd))return null;if(NI(e,n,r.gitCwd))return null;return{originalReason:t.reason,gitCwd:r.gitCwd}}function NI(e,t,n){let{subcommand:r,rest:o}=it(e),i=r?.toLowerCase();if(t.dynamicArguments||DI(o)||Fv(e,t.env,t.envAssignments,n)||MI(o)||$I(i,o))return!0;return i==="clean"&&WI(o)>1}function DI(e){return e.some((t)=>/[$*?[]/.test(t))}function $I(e,t){if(e==="checkout"){let{before:n}=Se(t),r=we(n,{shortOptsWithValue:Lu}),o=n.some((s)=>B(s,"--force"))||r.has("-f"),i=r.has("-B")||n.some((s)=>s==="-B"||s.startsWith("-B"));return o&&i}if(e==="switch"){let{before:n}=Se(t),r=we(n,{shortOptsWithValue:Mu}),o=n.some((s)=>B(s,"--force"))||n.some((s)=>B(s,"--discard-changes"))||r.has("-f"),i=n.some((s)=>s==="-C"||s.startsWith("-C")||LI(s))||r.has("-C");return o&&i}return!1}function LI(e){let t=e.split("=",1)[0]??e;return t==="--force-create"||t.length>=9&&"--force-create".startsWith(t)}function MI(e){return e.some((t)=>t.startsWith("--recurse-sub"))}function WI(e){let t=0;for(let n of e){if(n==="--force"){t++;continue}if(n.startsWith("-")&&!n.startsWith("--")){for(let r of n.slice(1))if(r==="f")t++}}return t}var FI="Git SSH environment overrides can execute arbitrary commands during network operations. Run git without GIT_SSH/GIT_SSH_COMMAND overrides, or ask the user to run it manually.",GI=new Set(["clone","fetch","pull","push","ls-remote","submodule"]);function ur(e,t){return Zv(e.map(N),t)}function Zv(e,t,n){let r=Av(e,t.env,t.envAssignments),o=r.blockedReason?O(S("git.alias-config",r.blockedReason),t.policy):null;if(o)return o;let i=r.tokens;if((gy(t.envAssignments)||Tv(e,t.env,t.envAssignments))&&ZI(i))return S("git.ssh-env",FI);let s=Dv(i);if(!s)return null;if(r.expanded||r.blockedReason)return s;let a=Gv(e,s,t);if(!a)return s;return n?.(a),null}function Bv(e,t){let n=null;return{match:Zv(e.map(N),t,(o)=>{n=o}),relaxation:n}}function ZI(e){let{subcommand:t,rest:n}=it(e),r=t?.toLowerCase();if(!r)return!1;if(GI.has(r))return!0;if(r==="archive")return Se(n).before.some((o)=>B(o,"--remote"));return r==="remote"&&BI(n)}function BI(e){return e.find((t)=>!UI(t))?.toLowerCase()==="update"}function UI(e){return e==="-v"||B(e,"--verbose")||B(e,"--no-verbose")}import{isAbsolute as NO}from"node:path";var Uv="rm -rf outside cwd is blocked. Retry deleting only explicit paths inside the current directory; escalate for anything outside it.",jI="rm -rf for non-temporary paths is blocked by the active safety policy. Retry deleting only explicit paths inside the current directory; escalate for anything outside it.",HI="rm -rf target contains shell variables that cannot be verified safely. Use literal paths within cwd, /tmp, /var/tmp, or $TMPDIR.",Hv="rm -rf targeting root or home directory is extremely dangerous and always blocked.",VI="rm -rf in home directory is dangerous. Change to a project directory first.";function dr(e,t){let n=wn({...t,allowPaths:t.policy?.destructiveCommandAllowPaths,posixShell:!0}),r=e.map(N),o=ot(r),i=Pv(r),s=KI(e);for(let a of s){let c=Co(a.word);if(o&&c.unsafeBraceExpansion){let l=O(jv({kind:"outside_anchored_cwd"},n,t.policy),t.policy);if(l)return l;continue}for(let l of c.expandedTargets??[a.text]){let u={targetIsLiteral:c.expandedTargets!==void 0||c.targetIsLiteral,tmpdirWordSplittingProtected:c.tmpdirWordSplittingProtected};if(!i&&n.resolvedCwd&&Cn(l,n.resolvedCwd,n.protectedGitMetadata,i,n.pathCanonicalizationContext))return S("rm.git-metadata",He);if(i&&!o){let d=nt(l,n,u);if(d.kind==="root_or_home_target")return S("rm.recursive-force-root-or-home",Hv);if(d.kind==="git_metadata_target")return S("rm.git-metadata",He);continue}if(!o)continue;for(let d of qI(l,n,u)){let f=jv(d,n,t.policy),m=O(f,t.policy);if(m)return m}}}return null}function qI(e,t,n){let r=nt(e,t,n);if(r.kind==="cwd_self_target")return[r,nt(e,t,{...n,skipCwdSelf:!0})];if(r.kind!=="home_cwd_target")return[r];let o=nt(e,t,{...n,skipHomeCwd:!0});if(o.kind!=="cwd_self_target")return[r,o];return[r,o,nt(e,t,{...n,skipHomeCwd:!0,skipCwdSelf:!0})]}function KI(e){let t=[],n=!1;for(let r of e.slice(1)){let o=N(r);if(!o)continue;if(o==="--"){n=!0;continue}if(n){t.push({text:o,word:r});continue}if(!o.startsWith("-"))t.push({text:o,word:r})}return t}function jv(e,t,n){switch(e.kind){case"root_or_home_target":return S("rm.recursive-force-root-or-home",Hv);case"git_metadata_target":return S("rm.git-metadata",He);case"temp_target":return null;case"dynamic_target":if(!ue(n,"rm.recursive-force-dynamic-target",t.strict))return null;return S("rm.recursive-force-dynamic-target",HI);case"home_cwd_target":return S("rm.recursive-force-home-cwd",VI);case"cwd_self_target":return S("rm.recursive-force-cwd-self",Uv);case"within_anchored_cwd":if(ue(n,"rm.recursive-force-paranoid",t.paranoid))return S("rm.recursive-force-paranoid",jI);return null;case"outside_anchored_cwd":return S("rm.recursive-force-outside-cwd",Uv)}}var YI={bash:["O","o"],dash:["o"],ksh:["o"],sh:["o"],zsh:["o"]},qv=new Set(["--init-file","--rcfile"]),JI=["--init-file","--rcfile"],XI=new Map([["bash","BASH_ENV"],["dash","ENV"],["ksh","ENV"],["sh","ENV"]]);function ht(e){for(let t=1;t<e.length;t++){let n=e[t];if(!n)continue;if(n==="-c")return Vv(e,t,!0);if(n.startsWith("-")&&n.includes("c")&&!n.startsWith("--")){let r=Vv(e,t,!1);if(r!==null)return r}}return null}function Ve(e){let t=G(e[0]??"").toLowerCase();if(t==="zsh"||t==="ksh")return yt(e).syntaxCheck;let n=!1;for(let r of e.slice(1)){if(r==="--")return n;if(r.startsWith("+")&&!r.startsWith("++")){if(r.slice(1).includes("n"))n=!1;continue}if(!r.startsWith("-")||r.startsWith("--"))return n;let o=r.slice(1);if(o.includes("n"))n=!0;if(o.includes("c"))return n}return n}function Vv(e,t,n){if(e[t+1]==="--")return e[t+2]||null;let r=e[t+1];if(!r||!n&&r.startsWith("-"))return null;return r}function Kv(e){let t=G(e[0]??"").toLowerCase(),n=QI(e,t),r=XI.get(t)??null,o=n.argvSource?.kind!=="absent";return{argvSource:t==="bash"?n.argvSource:null,argvSourceApplies:t==="bash"&&n.interactive&&n.argvSource?.kind==="literal",envName:r,envSourceApplies:o&&(r==="BASH_ENV"?!n.interactive:r==="ENV"&&n.interactive)}}function QI(e,t){let n=yt(e),r=n.commandIndex??n.scriptIndex??e.length,o=[],i=!1,s=!0;for(let a=1;a<r;a++){let c=e[a];if(c===void 0||c==="--"||c==="-"||c[0]!=="-"&&c[0]!=="+")break;if(c.startsWith("--")){if(t==="bash"&&s?JI.find((f)=>c===f):void 0){let f=e[a+1];o.push(f===void 0?{kind:"absent"}:{kind:"literal",value:f}),a++;continue}let d=c.split("=",1)[0]??c;if(t==="bash"&&qv.has(d)&&!c.includes("="))a++;continue}if(t==="bash")s=!1;let l=Yv(t,c,e[a+1],"startup");if(l.interactive)i=c[0]==="-";a+=l.followingValues}return{argvSource:o.at(-1)??null,interactive:i}}function Yv(e,t,n,r){let o=!1,i=0,s=!1,a=!1,c=!1;for(let l=1;l<t.length;l++){let u=t[l];if(u===void 0)break;if(e==="ksh"&&u==="o"&&l+1<t.length){if(r==="argv"){let d=t.slice(l+1);if(t[0]==="-"&&(d==="c"||d[0]==="-"&&d.endsWith("c")))s=!0}break}if(e==="ksh"&&u==="o"&&l+1===t.length&&(n?.startsWith("-")||n?.startsWith("+")))break;if(e==="zsh"&&u==="o"&&l+1<t.length)break;if(r==="startup"&&u==="i")o=t[0]==="-";if(r==="argv"&&t[0]==="-"&&u==="c")s=!0;if(r==="argv"&&u==="n")c=t[0]==="-";if(r==="argv"&&u==="s")a=t[0]==="-";if(!YI[e]?.includes(u))continue;if(l+1===t.length)i++;break}return{interactive:o,followingValues:i,commandSelected:s,stdinMode:a,syntaxCheck:c}}function yt(e){let t=G(e[0]??"").toLowerCase(),n=!1,r=!1,o=!1;for(let i=1;i<e.length;i++){let s=e[i];if(s===void 0)break;if(s==="--"){let c=n&&e[i+1]!==void 0?i+1:null;return{command:c===null?null:e[c]??null,commandIndex:c,scriptIndex:!n&&!r&&e[i+1]!==void 0?i+1:null,readsStdinAsCommands:!n&&(r||e[i+1]===void 0),syntaxCheck:o}}if(s==="-"||s[0]!=="-"&&s[0]!=="+")return{command:n?s:null,commandIndex:n?i:null,scriptIndex:!n&&!r&&s!=="-"?i:null,readsStdinAsCommands:!n&&(r||s==="-"),syntaxCheck:o};if(s.startsWith("--")){let c=s.split("=",1)[0]??s;if(t==="bash"&&qv.has(c)&&!s.includes("="))i++;continue}let a=Yv(t,s,e[i+1],"argv");if(a.commandSelected)n=!0;if(a.syntaxCheck)o=!0;if(a.stdinMode)r=!0;i+=a.followingValues}return{command:null,commandIndex:null,scriptIndex:null,readsStdinAsCommands:!n,syntaxCheck:o}}var Qt={kind:"none"},Pn={kind:"dynamic"},eO=new Set(["<","<<","<<-","<<<","<&","<>"]),Xv=/\$(?:([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)|\{!?([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*))/g,tO=/^(?:[0-9]+|[@*])$/,nO=_n.maxWords,rO=_n.maxInputLength;function Qv(e){if(!e||G(H(e.words[0]?.text??""))!=="printf")return;if(e.words.some((o)=>o.provenance!=="literal"))return;let t=e.words.slice(e.words[1]?.text==="--"?2:1),n=t[0]?.text;if(n===void 0)return"";let r=t.slice(1).map((o)=>o.text);if(n==="%s")return r.join("");if(n==="%s\\n"||n===`%s
53
+ `)return`${r.join(`
56
54
  `)}
57
- `;if(Q.includes("%")||/\\(?![\\nrt])/.test(Q))return;return Q.replaceAll("\\n",`
58
- `).replaceAll("\\r","\r").replaceAll("\\t","\t").replaceAll("\\\\","\\")}function q4($){let J=R3($[1])==="--"?2:1;if($.length<=J)return t0;let Q=$.slice(J);if(!Q.every(r9))return P2;return{kind:"literal",source:Q.map(v).join(" ")}}function aU($){let J=R3($[1])==="--"?2:1,Q=$[J],W=R3(Q);if(Q===void 0||$.length<=J+1||W==="-"||W===""||W==="-l"||W==="-p")return t0;if(!r9(Q))return P2;return{kind:"literal",source:W}}function d9($,J){let Q=qI($);if(Q===-1)return t0;let W=UI(J);if(!W)return t0;let X=[],Y=W.command?.length??0;for(let K of W.references){let B=HI(K,$,Q,W.ifs);if(!B)return P2;if(Y+=B.reduce((q,U)=>q+U.length+3,0),X.length+B.length>YI||Y>KI)return P2;X.push(...B)}if(W.command==="eval")return{kind:"literal",source:X.join(" ")};if(X.length===0||/\s/.test(X[0]??""))return{kind:"literal",source:""};return{kind:"literal",source:[W.command,W.command&&W.optionTerminator?"--":null,...X.map(LI)].filter((K)=>K!==null).join(" ")}}function tU($,J,Q,W){if(!N0($.map(v)).readsStdinAsCommands)return t0;let X=J.filter((Y)=>(Y.fd===void 0||Y.fd===0)&&WI.has(Y.operator)).at(-1);if(X){if(X.operator==="<<"||X.operator==="<<-")return t0;if(X.operator!=="<<<"||X.target?.provenance!=="literal")return P2;return{kind:"literal",source:X.target.text}}if(!Q)return t0;return W===void 0?P2:{kind:"literal",source:W}}function F0($){let J=N0($.map(v)).scriptIndex;if(J===null)return t0;let Q=$[J],W=R3(Q);return x6(Q,W)?{kind:"literal",source:W}:P2}var BI=new Set(["curl","wget","fetch","aria2c","http","https","xh","xhs","nc","ncat","netcat"]);function iQ($){if($.words.length!==2||$.redirections.length!==0||$.nested.length!==1)return!1;let J=$.words[0],Q=$.words[1];if(!J||J.provenance!=="literal"||J.quoted||J.raw!==J.text||!Q)return!1;if(!(J.text==="eval"&&Q.quoted&&Q.parts.length===3&&Q.parts[0]?.raw==='"'&&Q.parts[1]?.provenance==="command-substitution"&&Q.parts[1].raw.startsWith("$(")&&Q.parts[2]?.raw==='"'||(J.text==="source"||J.text===".")&&!Q.quoted&&Q.parts.length===1&&Q.parts[0]?.provenance==="command-substitution"&&Q.parts[0].raw.startsWith("<(")))return!1;let X=$.nested[0];if(X?.status!=="complete"||X.nodes.length!==1)return!1;let Y=X.nodes[0];if(Y?.kind!=="command"||Y.redirections.length!==0||Y.nested.length!==0||Y.words.some((q)=>q.provenance!=="literal"||q.parts.some((U)=>U.provenance!=="literal")))return!1;let K=Y.words[0]?.text;if(K===void 0||t1(K)!==null)return!1;let B=l(r(K));return!BI.has(B)&&!U1.has(B)&&!R2(B)}function qI($){return N0($.map(v)).commandIndex??-1}function UI($){let J=/^IFS=(?:'([^']*)'|"([^"]*)"|([^;\s]*))\s*;\s*(.+)$/.exec($.trim()),Q=J?.[4]??$.trim(),W=/^(\.|bash|command|dash|exec|eval|ksh|sh|source|zsh)(?:\s+(--))?\s+(.+)$/.exec(Q),X=(W?.[3]??Q).split(/\s+/).map(GI);if(X.length===0||X.some((Y)=>Y===null))return null;return{command:W?.[1]??null,optionTerminator:W?.[2]!==void 0,references:X.filter((Y)=>!!Y),ifs:J?J[1]??J[2]??J[3]??"":`
59
- `}}function GI($){let J=/^"\$(?:([0-9]+|[@*])|\{([0-9]+|[@*])\})"$/.exec($),Q=/^\$(?:([0-9]+|[@*])|\{([0-9]+|[@*])\})$/.exec($),W=J??Q;if(!W)return null;let X=W[1]??W[2];return{parameter:X==="@"||X==="*"?X:Number(X),quoted:J!==null}}function HI($,J,Q,W){let X=J.slice(Q+2);if($.parameter==="@")return $.quoted?cQ(X):ZI(X,W);if($.parameter==="*"){let B=cQ(X);if(!B)return;let q=B.join(W[0]??"");return $.quoted?[q]:dQ(q,W)}let Y=J[Q+1+$.parameter];if(Y&&!r9(Y))return;let K=R3(Y);return $.quoted?[K]:dQ(K,W)}function cQ($){return $.every(r9)?$.map(v):void 0}function ZI($,J){let Q=cQ($);if(!Q)return;let W=Q.map((X)=>dQ(X,J));return W.some((X)=>X===void 0)?void 0:W.flatMap((X)=>X??[])}function dQ($,J){if(["*","?","[","]"].some((Q)=>$.includes(Q)))return;if(J==="")return $===""?[]:[$];if(J===`
60
- `)return $.trim().split(/\s+/).filter(Boolean);if(J.length!==1)return;return J===" "||J==="\t"||J===`
61
- `?$.trim().split(/\s+/).filter(Boolean):$.split(J).filter(Boolean)}function r9($){if(!$)return!0;return $.provenance==="unknown"?!/[$`]/.test(v($)):$.provenance==="literal"}function R3($){return $?v($):""}function LI($){return`'${$.replaceAll("'",`'"'"'`)}'`}function oQ($,J){return rQ(e1($,"posix"),J)}function U4($){return oQ($,new Set(Array.from($.matchAll(nU)).flatMap((J)=>{let Q=J[1]??J[2];return Q===void 0?[]:[Q]})))}function rQ($,J){if($.status==="invalid"||$.status==="limited")return!1;let Q=new Set(J);for(let W of $.nodes){if(W.kind==="group"){if(rQ(W.body,Q))return!0;continue}if(W.kind!=="command")continue;if(W.nested.some((X)=>rQ(X,Q))||eU(W.words,Q))return!0;VI(W,Q)}return!1}function eU($,J){let Q=$.findIndex((K)=>t1(K.text)===null);if(Q===-1)return!1;let W=$[Q];if(!W)return!1;if(b3(W,J))return!0;let X=r(W.text);if(X==="source"||X==="."){let K=$[Q+1]?.text==="--"?Q+2:Q+1;return oU($[K],J)}if(U1.has(X)){let K=$.slice(Q),B=N0(K.map((U)=>U.text)),q=B.commandIndex??B.scriptIndex;return!B.syntaxCheck&&q!==null&&oU(K[q],J)}let Y=MI($,Q,J);if(Y===null)return!1;if(Y===-1)return!0;return eU($.slice(Y),J)}function MI($,J,Q){let W=r($[J]?.text??"");if(W==="command")return OI($,J+1);if(W==="exec")return NI($,J+1);if(W==="env")return FI($,J+1,Q);return null}function OI($,J){for(let Q=J;Q<$.length;Q++){let W=$[Q]?.text??"";if(W==="--")return $[Q+1]?Q+1:null;if(/^-[p]*[vV][pvV]*$/.test(W))return null;if(/^-p+$/.test(W))continue;return Q}return null}function NI($,J){for(let Q=J;Q<$.length;Q++){let W=$[Q]?.text??"";if(W==="--")return $[Q+1]?Q+1:null;if(W==="-a"){Q++;continue}if(/^-a.+/.test(W)||/^-[cl]+$/.test(W))continue;return Q}return null}function FI($,J,Q){for(let W=J;W<$.length;W++){let X=$[W],Y=X?.text??"";if(Y==="--")return $[W+1]?W+1:null;if(Y==="-S"||Y==="--split-string")return b3($[W+1],Q)?-1:W+2;if(Y.startsWith("-S")||Y.startsWith("--split-string="))return b3(X,Q)?-1:W+1;if(Y==="-u"||Y==="--unset"||Y==="-C"||Y==="--chdir"||Y==="-P"){W++;continue}if(Y==="-i"||Y==="-0"||Y==="--null"||Y.startsWith("-u=")||Y.startsWith("--unset=")||Y.startsWith("-C")||Y.startsWith("--chdir=")||Y.startsWith("-P"))continue;if(Y.startsWith("-"))continue;if(t1(Y))continue;return W}return null}function VI($,J){if(!$.words.every((Q)=>t1(Q.text)!==null))return;for(let Q of $.words){let W=t1(Q.text);if(!W)continue;if(b3(Q,J))J.add(W.name)}}function b3($,J){if(!$)return!1;return $.parts.filter((Q)=>Q.provenance==="variable").some((Q)=>Array.from(Q.raw.matchAll(nU)).some((W)=>{let X=W[1]??W[2];return X!==void 0&&(XI.test(X)||J.has(X))}))}function oU($,J){return!!$&&($.parts.some((Q)=>Q.provenance!=="literal"&&Q.provenance!=="variable")||b3($,J))}var _I=new Set(["-c","-C","--git-dir","--work-tree","--namespace","--config-env"]),DI=new Set(["-c","-H","-l","--config","--context","--host","--log-level","--tlscacert","--tlscert","--tlskey"]),zI=new Set;function $G($){if($==="git")return _I;if($==="docker")return DI;return zI}function M1($,J){if($.length===0||J.length===0)return null;let Q=r($[0]??""),W=R1($);for(let X of J){if(!II(Q,X.command))continue;if(!jI(Q,$,X.subcommand))continue;if(bI($,new Set(X.block_args),W))return{id:`custom.${X.name}`,reason:`[${X.name}] ${X.reason}`,intent:X.intent??"manual_only"}}return null}function II($,J){return $===r(J)}function jI($,J,Q){if(!Q)return!0;return JG(J,1,Q,$G($))}function JG($,J,Q,W){let X=!1;for(let Y=J;Y<$.length;Y++){let K=$[Y];if(!K)continue;if(X){X=!1;continue}if(K==="--"){let B=$[Y+1];if(B&&!B.startsWith("-"))return B===Q;return!1}if(W.has(K)){X=!0;continue}if(K.startsWith("-")){if(!K.includes("=")&&RI($,Y,Q,W))return!0;continue}return K===Q}return!1}function RI($,J,Q,W){let X=$[J+1];if(!X||X.startsWith("-"))return!1;return JG($,J+2,Q,W)}function bI($,J,Q){for(let W of $)if(J.has(W))return!0;for(let W of Q)if(J.has(W))return!0;return!1}function e0($,J,Q={}){if($.length===0)return null;let W=$[0];if(!W)return null;let X=r(W);if(X==="eval"){let Y=q4(p($));if(Y.kind==="dynamic")return G4(Q,J);if(Y.kind==="literal"&&J.analyzeNested){let K=J.analyzeNested(Y.source,{effectiveCwd:J.cwd,envAssignments:J.envAssignments});if(K)return K}return V0(Q,J)}if(U1.has(X)){if(r1($))return null;let Y=O0($);if(Y){if(Q.dynamicSourceInput??Q.dynamicInput){let q=G4(Q,J);if(q)return q}if(U4(Y)){let q=G4(Q,J);if(q)return q}if(!J.analyzeNested)return null;let B=J.analyzeNested(Y,{effectiveCwd:J.cwd,envAssignments:J.envAssignments});if(B)return B;return null}let K=F0(p($));if(K.kind==="dynamic")return G4(Q,J);if(K.kind==="literal"){if(Q.dynamicSourceInput)return G4(Q,J);return null}if(Q.dynamicSourceInput??Q.dynamicInput)return G4(Q,J);return null}if(h1.has(X))return k(x9($,(Y)=>J.analyzeNested?J.analyzeNested(Y,{effectiveCwd:J.cwd,envAssignments:J.envAssignments}):null),J.policy)??M1($,J.policy?.rules??[])??V0(Q,J);if(w1(X)){let Y=J9($);if(!Y)return V0(Q,J);if(q1(J.policy,"interpreter.one-liner-paranoid",!!J.paranoidInterpreters)){let B=k(D("interpreter.one-liner-paranoid",t2),J.policy);if(B)return B}if(X9(X,Y))return V0(Q,J);let K=J.analyzeNested?.(Y,{effectiveCwd:J.cwd,envAssignments:J.envAssignments});if(K&&K.id!=="raw-text.dangerous-command"&&(K.reason!==i0||W4(Y)))return K;if(e2(Y,J.scanWork))return k(D("interpreter.dangerous-command",V2),J.policy)??V0(Q,J);return V0(Q,J)}if(X==="rm"||X==="rmdir"){let Y=X==="rm"&&(W0($)||Q.dynamicRmInput);return k(B4(p($),{environment:J.environment,cwd:J.cwd,originalCwd:J.originalCwd,strict:J.strict,paranoid:J.paranoidRm,allowTmpdirVar:J.allowTmpdirVar,tmpdirWordSplittingUnsafe:H0(J.envAssignments,J.environment),trustedTmpdirValue:f0(J.envAssignments,J.environment),protectedGitMetadata:J.protectedGitMetadata,policy:J.policy}),J.policy)??(Y&&Q.dynamicRmInput?V0(Q,J):null)??(Y?PI(Q,J):null)}if(X==="find")return m9(p($),{...J,derivedCommandWorkBudget:J.derivedCommandWorkBudget,analyzeTokens:(Y,K)=>e0(Y,{...J,cwd:K??void 0,derivedCommandWorkBudget:J.derivedCommandWorkBudget},Q)})??M1($,J.policy?.rules??[])??V0(Q,J);if(X==="git")return k(K4(p($),{env:J.environment.env,cwd:J.cwd,envAssignments:J.envAssignments,policy:J.policy,worktreeMode:Q.dynamicInput?!1:J.worktreeMode}),J.policy)??M1($,J.policy?.rules??[])??V0(Q,J);return M1($,J.policy?.rules??[])??V0(Q,J)}function G4($,J){return $.shellDynamicMatch?k($.shellDynamicMatch,J.policy):null}function V0($,J){return $.dynamicSourceInput&&$.dynamicSourceMatch?k($.dynamicSourceMatch,J.policy):null}function PI($,J){return $.dynamicInput&&$.rmDynamicMatch?k($.rmDynamicMatch,J.policy):null}var nQ="xargs rm -rf with dynamic input is dangerous. Use explicit file list instead.",sQ="xargs dynamic input can supply arbitrary executable command source. Use an explicit child command and arguments instead.",AI="__CC_SAFETY_NET_XARGS_INPUT__",i9="__CC_SAFETY_NET_XARGS_INTERPRETER_INPUT__",o9="rm",EI=/(?:^|[;&|]\s*|\b(?:eval|source)\s+|\b(?:ba|da|z|k)?sh\s+-c\s+)\s*["']?\$(?:([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)|\{!?([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)(?:[^}]*)\})/g,CI=/(?:^|[;&|]\s*)\s*eval\b((?:\\.|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^\\'";&|\r\n])*)/g,SI=/\$(?:([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)|\{!?([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)(?:[^}]*)\})/g,TI=/^(?:[0-9]+|[@*])$/,wI=new Set(["branch","checkout","clean","push","reset","restore","switch","tag"]);function XG($,J){let Q=$.map(v),{childStart:W,replacementToken:X}=A2(Q),Y=Q.slice(W),K=D("xargs.shell-dynamic",sQ);if(fI(Y,X,J)&&k(K,J.policy))return k(K,J.policy);for(let B of Q0(Y,J)){let q=B.tokens,U=X!==null&&q[0]!==Y[0]&&(q[0]?.includes(X)??!1)?k(K,J.policy):null;if(U)return U;let G=qG(q,X,B.wrapperEnvAssignments),H=B.head==="rm"&&X!==null&&KG(q,X),L=e0(q,{...J,cwd:B.cwd,envAssignments:B.envAssignments},{dynamicInput:G,dynamicSourceInput:H||YG(q,B.head,X,B.wrapperEnvAssignments,G,J.scanWork,J.environment),dynamicRmInput:H,shellDynamicMatch:K,dynamicSourceMatch:K,rmDynamicMatch:D("xargs.rm-recursive-force-dynamic",nQ)});if(L)return L;let Z=vI(q,X,J.policy?.rules??[]);if(Z)return Z;if(B.head==="git"){let O=X===null?[...q,AI]:q,V=X!==null&&(q.some((b)=>b.includes(X))||Array.from(B.envAssignments.values()).some((b)=>b.includes(X))),F=e0(O,{...J,cwd:B.cwd,envAssignments:B.envAssignments,worktreeMode:X===null||V?!1:J.worktreeMode});if(F)return F}let M=M1(q,J.policy?.rules??[]);if(M)return M}return null}function vI($,J,Q){if(Q.length===0)return null;if(J===null){for(let X of Q){let Y=M1([...$,...X.subcommand?[X.subcommand]:[],...X.block_args],Q);if(Y)return Y}return null}let W=new Set(Q.flatMap((X)=>[X.subcommand,...X.block_args].flatMap((Y)=>Y?$.flatMap((K)=>aQ(K,J,Y)):[])));for(let X of W){let Y=M1($.map((K)=>K.replaceAll(J,X)),Q);if(Y)return Y}return null}function aQ($,J,Q){let W=$.indexOf(J);if(W===-1||$.indexOf(J,W+J.length)!==-1)return[];let X=$.slice(0,W),Y=$.slice(W+J.length);return Q.startsWith(X)&&Q.endsWith(Y)?[Q.slice(X.length,Q.length-Y.length)]:[]}function YG($,J,Q,W,X,Y,K){if(U1.has(J)){if(r1($))return!1;if(Q!==null&&kI($,Q))return!0;let B=O0($);if(!B){let q=F0(p($));if(q.kind==="literal")return Q!==null&&q.source.includes(Q);return q.kind==="none"&&X}if(Q!==null&&B.includes(Q))return!0;if(Y3(B,Y))return!0;return hI(B,Q,W)}if(w1(J))return QG($,Q,W9,lB(J));if(h1.has(J))return QG($,Q,SQ,FU);if(J==="eval"){let B=q4(p($));if(B.kind==="dynamic")return!0;if(Q!==null)return B.kind==="literal"&&B.source.includes(Q);return X}if(J==="find")return yI($,Q,Y,K);if(J==="git"){let B=X0($);return Q===null?B.subcommand===null:(B.subcommand?.includes(Q)??!1)||B.subcommand!==null&&wI.has(B.subcommand.toLowerCase())&&BG(B.rest,Q).some((q)=>q.includes(Q))}return!1}function QG($,J,Q,W){let X=Q($);if(J===null)return X.optionsOpen||Q([...$,i9]).sources.some((q)=>q.value===i9);if(X.sources.some((q)=>q.value.includes(J)))return!0;let Y=new Set(X.sources.map((q)=>`${q.tokenIndex}\x00${q.kind}\x00${q.value}`)),K=W.flatMap((q)=>[q.selector,...q.valueForm==="attached-only"||q.valueForm==="attached-or-separate"?[`${q.selector}${i9}`]:[],...q.valueForm==="equals-or-separate"?[`${q.selector}=${i9}`]:[]]),B=new Set(K.flatMap((q)=>$.flatMap((U)=>aQ(U,J,q))));return Array.from(B).some((q)=>Q($.map((U)=>U.replaceAll(J,q))).sources.some((U)=>!Y.has(`${U.tokenIndex}\x00${U.kind}\x00${U.value}`)))}function fI($,J,Q){if($.length===0||($[0]??"").toLowerCase()==="command")return!1;let W=new Set(Array.from(Q0($,Q),(Y)=>Y.head)),X=J===null?[...$,o9]:$.map((Y,K)=>K===0?Y:Y.replaceAll(J,o9));return Array.from(Q0(X,Q)).some((Y)=>Y.head===o9&&!W.has(o9))}function KG($,J){return BG($.slice(1),J).some((Q)=>Q.includes(J)&&(Q.startsWith("-")||Q.startsWith(J)))}function BG($,J){let Q=$.findIndex((W)=>W==="--"&&!W.includes(J));return Q===-1?$:$.slice(0,Q)}function qG($,J,Q){if(J===null)return!0;return $.some((W)=>W.includes(J))||Array.from(Q.values()).some((W)=>W.includes(J))}function kI($,J){let Q=N0($);if(Q.commandIndex!==null&&($[Q.commandIndex]??"").includes(J)||Q.scriptIndex!==null&&($[Q.scriptIndex]??"").includes(J))return!0;return["-c","-nc","-cn",`--${J}`,J].some((X)=>$.some((Y,K)=>{if(K===0||!Y.includes(J))return!1;return aQ(Y,J,X).some((q)=>{let U=$.map((H,L)=>L===K?H.replaceAll(J,q):H),G=N0(U);if(G.commandIndex===null&&G.scriptIndex===null)return!1;if(Q.commandIndex===null&&G.commandIndex!==null)return!0;if(Q.scriptIndex===null&&G.scriptIndex!==null)return!0;if(G.commandIndex!==null&&(U[G.commandIndex]??"").includes(q))return!0;return G.scriptIndex!==null&&(U[G.scriptIndex]??"").includes(q)})}))}function hI($,J,Q){let W=new Set(J===null?[]:Array.from(Q).filter(([,X])=>X.includes(J)).map(([X])=>X));for(let X of $.matchAll(EI))if(WG(X,W))return!0;for(let X of $.matchAll(CI))for(let Y of(X[1]??"").matchAll(SI))if(WG(Y,W))return!0;return oQ($,W)}function WG($,J){let Q=$[1]??$[2];return Q!==void 0&&(TI.test(Q)||J.has(Q))}function yI($,J,Q,W){if(J===null)return!0;let X=!1,Y=0;for(let K=1;K<$.length;K++){let B=$[K]??"";if(!X&&!B.startsWith("-")&&B!=="!"&&B!=="("){if(B.indexOf(J)===0)return!0;continue}if(X=!0,Y>0){Y--;continue}if(h0(B)){let U=z3($,K);K=U.nextIndex-1;for(let G of Q0(U.tokens,{environment:W,cwd:void 0})){let H=qG(G.tokens,J,G.wrapperEnvAssignments);if(G.head==="rm"&&KG(G.tokens,J)||YG(G.tokens,G.head,J,G.wrapperEnvAssignments,H,Q,W))return!0}continue}let q=s0(B);if(q>0){if(Y=q,B.includes(J))return!0;continue}if(B.includes(J))return!0}return!1}function A2($){let J=new Set(["-L","-n","-P","-s","-a","-E","-R","-S","-e","-d","-J","--max-args","--max-procs","--max-chars","--arg-file","--eof","--delimiter","--max-lines","--process-slot-var"]),Q=null,W=1;while(W<$.length){let X=$[W];if(!X)break;if(X==="--")return{childStart:W+1,replacementToken:Q};if(X.startsWith("-")){if(X==="-I"){Q=$[W+1]??"{}",W+=2;continue}if(X.startsWith("-I")&&X.length>2){Q=X.slice(2),W++;continue}if(X==="--replace"){Q="{}",W++;continue}if(X.startsWith("--replace=")){let Y=X.slice(10);Q=Y===""?"{}":Y,W++;continue}if(X==="-J"){Q=$[W+1]??"{}",W+=2;continue}if(J.has(X))W+=2;else W++}else return{childStart:W,replacementToken:Q}}return{childStart:$.length,replacementToken:Q}}var P3="parallel rm -rf with dynamic input is dangerous. Use explicit file list instead.",A3="parallel with shell -c can execute arbitrary commands from dynamic input. Run the inner command directly on an explicit file list instead.",xI="parallel without a command reads executable commands from dynamic input. Use an explicit command template or ::: arguments instead.",uI="parallel command construction cannot be verified safely. Use the default ::: separator, literal arguments, and built-in replacement strings.",mI=/\{[^{}\s]*\}/,FG=/\{\}|\{-?\d+\}/g,lI=["e","f","source","file","-e","-f","--source","--file"],pI=["c","e","eval","m","r","Mmodule","import","require","-c","-e","-m","-r","--eval","--import","--require"],cI=new Set(["-L","-d","-n","--delay","--delimiter","--header","--joblog","--jl","--max-args","--max-lines","--nice","--results","--result","--res","--tagstring","--timeout"]),dI=new Set(["--arg-file","--colsep","--rpl","--arg-sep","--arg-file-sep"]),UG=new Set(["-S","--sshlogin","--slf","--sshloginfile"]),rI=new Set(["--workdir","--wd"]),GG="__CC_SAFETY_NET_PARALLEL_SOURCE__",iI=new TextEncoder,s9=h.maxDerivedBytes+4*h.maxPlaceholderReplacements;function D1($,J){for(let Q of $){let W=J(Q);if(W)return W}return null}function VG($,J){let Q=$.map(v);if((J.envAssignments?.has("PARALLEL")?J.envAssignments.get("PARALLEL"):J.environment.env.get("PARALLEL"))?.trim()){let O=C2(J);if(O)return O}if(Q.length===2&&(Q[1]==="--version"||Q[1]==="--help"))return null;let X=SG(Q),{template:Y,jobs:K,runsRemotely:B,envNames:q,readsCommandsFromInput:U,unsupported:G,workdir:H,dryRun:L}=X;if(G){let O=C2(J);if(O)return O}if(U){let O=Jj(J);if(O)return O}if(H!==void 0&&B){let O=C2(J);if(O)return O}let Z=Kj(H,J.cwd,J.environment.paths);if(Z===null){let O=C2(J);if(O)return O}let M=B?{...J,cwd:void 0,originalCwd:void 0}:Z===null||Z===void 0||Z===J.cwd?J:{...J,cwd:Z};if(L){let O=[...Q0(Y,M)];if((O.length===0?$7(q,J.envAssignments,new Map).values:O.flatMap((F)=>$7(q,J.envAssignments,F.envAssignments).values)).some(W7)){let F=C2(J);if(F)return F}return null}if(Y.length===0){if(q.length>0||K.some((F)=>F.length!==1)){let F=C2(J);if(F)return F}let O=K.map((F)=>F[0]??"");v1(J.budget,eQ(O));let V=PG(M.envAssignments,M.cwd,B);return D1(O,(F)=>J.analyzeNested(F,V))}return D1(Q0(Y,M),(O)=>oI(O,X,J,M))}function oI($,J,Q,W){let{jobs:X,templateHasPlaceholder:Y,runsRemotely:K,usesStdin:B,envNames:q}=J,U=$.tokens,G={...W,cwd:$.cwd,envAssignments:$.envAssignments},H=$7(q,Q.envAssignments,$.envAssignments);if(H.entries.some((F)=>EG(F.value))){let F=C2(Q);if(F)return F}let L=H.entries.some((F)=>F.hasPlaceholder),Z=Y||L,M=B&&Z,O=PG($.envAssignments,$.wrapperCwd,K||M);if(U1.has($.head)){let F=()=>{if(!Y||X.length===0)return null;return v1(Q.budget,n9(U,X,"generic")),D1(X,(A)=>e0(U.map((E)=>_0(E,A)),G))};if(r1(U))return F();let b=O0(U);if(b){if(CG(b)){let P=E2(Q);if(P)return P;if(X.length===0)return null;return v1(Q.budget,OG(b,X)),D1(X,(C)=>Q.analyzeNested(_0(b,C),O))}if(t(b)){if(X.length>0)return v1(Q.budget,OG(b,X)),D1(X,(S)=>Q.analyzeNested(_0(b,S),O));v1(Q.budget,LG(b));let P=I3(b);if(P?.[0]&&r(P[0])==="rm"&&W0(P)){let S=ZG(Q);if(S)return S}let C=P?e0(P,G,{dynamicInput:B,shellDynamicMatch:D("parallel.shell-dynamic",A3),rmDynamicMatch:D("parallel.rm-recursive-force-dynamic",P3)}):null;if(C)return C;return Q.analyzeNested(b,O)}let A=!L&&(!Y||X.length>0)?(X.length>0?X:[void 0]).map((P)=>d9(p(P===void 0?U:Y?U.map((C)=>_0(C,P)):[...U,...P]),b)):[];if(A.some((P)=>P.kind==="dynamic")){let P=E2(Q);if(P)return P}let E=A.flatMap((P)=>P.kind==="literal"?[P.source]:[]);if(E.length>0)return v1(Q.budget,eQ(E)),D1(E,(P)=>Q.analyzeNested(P,O));v1(Q.budget,Wj(LG(b),Qj(H.entries,X)));let _=U4(b);if(_&&H.entries.length>0){let P=NG(H,X,W,K);if(P)return P}if(_){let P=E2(Q);if(P)return P}let R=Q.analyzeNested(b,O);if(R)return R;if(!_){let P=NG(H,X,W,K);if(P)return P}if(Z)return E2(Q);return null}let I=F0(p(U));if(I.kind==="dynamic"||I.kind==="literal"&&t(I.source))return E2(Q)??F();if(I.kind==="literal")return F();if(X.length>0){let A=E2(Q);if(A)return A;let E=F();if(E)return E;if(Y)return null;let _=X.flatMap((R)=>R[0]===void 0?[]:[R[0]]);return v1(Q.budget,eQ(_)),D1(_,(R)=>Q.analyzeNested(R,O))}if(Z||B)return E2(Q)??F();return null}if($.head==="rm"&&W0(U)){if(Y&&X.length>0)return v1(Q.budget,n9(U,X,"rm")),D1(X,(b)=>tQ(U.map((I)=>J7(I,b)),$.cwd,W));if(X.length>0)return v1(Q.budget,MG(U,X)),D1(X,(b)=>tQ([...U,...b],$.cwd,W));let F=tQ(U.flatMap((b,I)=>{if(I===0||!t(b))return[b];return b.startsWith("-")?[J7(b,[""])]:[]}),$.cwd,W);if(F)return F;return ZG(Q)}v1(Q.budget,Y&&X.length>0?n9(U,X,"generic"):X.length>0?MG(U,X):IG(U));let V=X.length>0?X:[void 0];return D1(V,(F)=>{let b=F===void 0?U:Y?U.map((S)=>_0(S,F)):[...U,...F],I=D("parallel.shell-dynamic",A3),A=B&&$.head==="find"?$j(b,W):null,E=DG(b,B,Q.policy?.rules??[],Q.budget)??A?.customResult??null,_=r($.head),R=B&&(_==="rm"&&Q7(b)||_==="xargs"&&zG(b)||A?.rmOptions===!0),P=B&&(R||A?.executedSource===!0||A===null&&_G(b,_)),C=e0(b,{...G,worktreeMode:K||B||Z?!1:Q.worktreeMode},{dynamicInput:B||Z,dynamicRmInput:R,dynamicSourceInput:E!==null||P,shellDynamicMatch:I,dynamicSourceMatch:I,rmDynamicMatch:D("parallel.rm-recursive-force-dynamic",P3)});if(P){let S=k(I,Q.policy);if(S)return S}return C??E??M1(b,Q.policy?.rules??[])})}function _G($,J){if(t($[0]??""))return!0;if(J==="eval"||J==="source"||J===".")return!0;if(J==="parallel"||J==="xargs")return!0;if(U1.has(J))return aI($);if(J==="git")return nI($);if(J==="find")return!0;if(h1.has(J))return HG($,lI,D3);if(w1(J))return HG($,pI,Q9);return!1}function Q7($){let J=$.indexOf("--"),Q=$.slice(1,J===-1?void 0:J);if(!$.some(t))return J===-1;return Q.some((X)=>t(X)&&(X.startsWith("-")||CG(X)))}function nI($){if(sI($))return!0;let J=X0($);if(J.subcommand===null||t(J.subcommand))return!0;if(!c9.has(J.subcommand.toLowerCase()))return!1;let Q=J.rest.indexOf("--"),W=J.rest.slice(0,Q===-1?void 0:Q);if(!$.some(t))return Q===-1;return W.some(t)}function sI($){for(let J=1;J<$.length;J++){let Q=$[J];if(!Q||Q==="--"||!Q.startsWith("-"))return!1;if(Q==="-c"||Q==="--config-env"){if(t($[J+1]??""))return!0;J++;continue}if(Q.startsWith("-c")&&Q.length>2||Q.startsWith("--config-env=")){if(t(Q))return!0;continue}if(t(Q))return!0}return!1}function aI($){if(r1($))return!1;let J=O0($);if(J!==null)return t(J);let Q=F0(p($));if(Q.kind==="literal")return t(Q.source);if(Q.kind==="dynamic")return!0;return!$.some(t)}function HG($,J,Q){let W=Q($);if(W.some((Y)=>t(Y.value)))return!0;if(!$.some(t))return Q([...$,GG]).some((Y)=>Y.value===GG);let X=new Set(W.map((Y)=>`${Y.tokenIndex}\x00${Y.kind}\x00${Y.value}`));return J.some((Y)=>Q($.map((K)=>_0(K,[Y]))).some((K)=>!X.has(`${K.tokenIndex}\x00${K.kind}\x00${K.value}`)))}function DG($,J,Q,W){if(!J||Q.length===0)return null;let X=Q.filter((K)=>r(K.command)===r($[0]??""));if(X.length===0)return null;let Y=$.some(t);if(v1(W,tI($,X,Y)),!Y)return D1(X,(K)=>M1([...$,...K.subcommand?[K.subcommand]:[],...K.block_args],[K]));return D1(X,(K)=>{let B=new Set([K.subcommand,...K.block_args].flatMap((q)=>q?eI($,q):[]));return D1(B,(q)=>M1($.map((U)=>_0(U,[q])),[K]))})}function tI($,J,Q){let W=Q?P1(G1(J.map((X)=>X.block_args.length+(X.subcommand?1:0)),h.maxChildAnalyses),2*Math.max($.length,1),h.maxChildAnalyses):J.length;return{childAnalyses:W,derivedTokens:P1(W,$.length,h.maxDerivedTokens)}}function eI($,J){return $.flatMap((Q)=>{let W=[...Q.matchAll(/\{[^{}\s]*\}/g)];if(W.length!==1)return[];let X=W[0];if(!X||X.index===void 0)return[];let Y=Q.slice(0,X.index),K=Q.slice(X.index+X[0].length);if(!J.startsWith(Y)||!J.endsWith(K))return[J];let B=J.slice(Y.length,J.length-K.length);return B!==J?[J,B]:[J]})}function $j($,J){let Q={customResult:null,executedSource:!$.some(t),rmOptions:!1},W=!1,X=0,Y=null,K=()=>{if(!Y?.some(t))return;for(let B of Q0(Y,J))Q.executedSource||=_G(B.tokens,B.head),Q.rmOptions||=B.head==="rm"&&Q7(B.tokens)||B.head==="xargs"&&zG(B.tokens),Q.customResult??=DG(B.tokens,!0,J.policy?.rules??[],J.budget)};for(let B of $.slice(1)){if(!W&&!B.startsWith("-")&&B!=="!"&&B!=="("){Q.executedSource||=t(B);continue}if(W=!0,Y){if(B===";"||B==="+"){K(),Y=null;continue}Y.push(B);continue}if(X>0){X--;continue}if(h0(B)){Y=[],Q.executedSource||=t(B);continue}let q=s0(B);if(q>0){X=q,Q.executedSource||=t(B);continue}Q.executedSource||=t(B)}return K(),Q}function zG($){let J=$.slice(A2($).childStart);return r(J[0]??"")==="rm"&&Q7(J)}function a9($,J){return(Q)=>k(D($,J),Q.policy)}var E2=a9("parallel.shell-dynamic",A3),Jj=a9("parallel.command-stream-dynamic",xI),C2=a9("parallel.command-stream-dynamic",uI),ZG=a9("parallel.rm-recursive-force-dynamic",P3);function tQ($,J,Q){return k(B4(p($),{environment:Q.environment,cwd:J,originalCwd:Q.originalCwd,strict:Q.strict,paranoid:Q.paranoidRm,allowTmpdirVar:Q.allowTmpdirVar,tmpdirWordSplittingUnsafe:H0(Q.envAssignments??new Map,Q.environment),trustedTmpdirValue:f0(Q.envAssignments??new Map,Q.environment),protectedGitMetadata:Q.protectedGitMetadata,policy:Q.policy}),Q.policy)}function eQ($){return{childAnalyses:$.length,derivedTokens:$.length,derivedBytes:Z4($)}}function LG($){return IG([$])}function IG($){return{childAnalyses:1,derivedTokens:$.length,derivedBytes:Z4($)}}function MG($,J){if(J.length>h.maxChildAnalyses)return{childAnalyses:J.length};return{childAnalyses:J.length,derivedTokens:G1(J.map((Q)=>$.length+Q.length),h.maxDerivedTokens),derivedBytes:G1([P1(Z4($),J.length,h.maxDerivedBytes),G1(J.map((Q)=>Z4(Q)),h.maxDerivedBytes)],h.maxDerivedBytes)}}function OG($,J){return n9([$],J,"generic")}function n9($,J,Q){if(J.length>h.maxChildAnalyses)return{childAnalyses:J.length};let W=P1($.length,J.length,h.maxDerivedTokens);if(W>h.maxDerivedTokens)return{childAnalyses:J.length,derivedTokens:W};let X=bG($.map((q)=>RG(q,Q))),Y=P1(X.occurrences,J.length,h.maxPlaceholderReplacements);if(Y>h.maxPlaceholderReplacements)return{childAnalyses:J.length,derivedTokens:W,placeholderReplacements:Y};if(jG(X,J,Y))return{childAnalyses:J.length,derivedTokens:W,derivedBytes:h.maxDerivedBytes+1,placeholderReplacements:Y};let K=Q==="generic"?_0:J7,B=G1(J.map((q)=>Z4($.map((U)=>K(U,q)))),h.maxDerivedBytes);return{childAnalyses:J.length,derivedTokens:W,derivedBytes:B,placeholderReplacements:Y}}function jG($,J,Q){let W=h.maxDerivedBytes+4*Q;return G1([P1($.fixedBytes,J.length,W),P1($.occurrences,G1(J.map((X)=>X.reduce((Y,K)=>Math.max(Y,H4(K)),0)),W),W)],W)>W}function Qj($,J){let Q=$.filter((G)=>G.hasPlaceholder),W=Math.max(J.length,1),X=G1(Q.map((G)=>G.frequency),h.maxChildAnalyses),Y=P1(X,W,h.maxChildAnalyses),K=P1(X,W,h.maxDerivedTokens);if(Y>h.maxChildAnalyses||K>h.maxDerivedTokens)return{childAnalyses:Y,derivedTokens:K};if(J.length===0)return{childAnalyses:Y,derivedTokens:K,derivedBytes:G1(Q.map((G)=>P1(H4(G.value),G.frequency,h.maxDerivedBytes)),h.maxDerivedBytes)};let B=bG(Q.map((G)=>Xj(RG(G.value,"generic"),G.frequency))),q=P1(B.occurrences,W,h.maxPlaceholderReplacements);if(q>h.maxPlaceholderReplacements)return{childAnalyses:Y,placeholderReplacements:q};if(jG(B,J,q))return{childAnalyses:Y,derivedTokens:K,derivedBytes:h.maxDerivedBytes+1,placeholderReplacements:q};let U=G1(Q.map((G)=>P1(Z4(J.map((H)=>_0(G.value,H))),G.frequency,h.maxDerivedBytes)),h.maxDerivedBytes);return{childAnalyses:Y,derivedTokens:K,derivedBytes:U,placeholderReplacements:q}}function Wj($,J){return{childAnalyses:G1([$.childAnalyses??0,J.childAnalyses??0],h.maxChildAnalyses),derivedTokens:G1([$.derivedTokens??0,J.derivedTokens??0],h.maxDerivedTokens),derivedBytes:G1([$.derivedBytes??0,J.derivedBytes??0],h.maxDerivedBytes),placeholderReplacements:G1([$.placeholderReplacements??0,J.placeholderReplacements??0],h.maxPlaceholderReplacements)}}function RG($,J){let Q=J==="generic"?$.matchAll(/\{[^{}\s]*\}/g):$.matchAll(FG),W=0,X=0,Y=0;for(let K of Q){if(W>=h.maxPlaceholderReplacements)return{occurrences:h.maxPlaceholderReplacements+1,fixedBytes:0};X=G1([X,H4($.slice(Y,K.index))],s9),W++,Y=K.index+K[0].length}return{occurrences:W,fixedBytes:W===0?H4($):G1([X,H4($.slice(Y))],s9)}}function Xj($,J){return{occurrences:P1($.occurrences,J,h.maxPlaceholderReplacements),fixedBytes:P1($.fixedBytes,J,s9)}}function bG($){return{occurrences:G1($.map((J)=>J.occurrences),h.maxPlaceholderReplacements),fixedBytes:G1($.map((J)=>J.fixedBytes),s9)}}function Z4($,J=h.maxDerivedBytes){return G1($.map(H4),J)}function H4($){return iI.encode($).byteLength}function G1($,J){let Q=0;for(let W of $){if(!Number.isSafeInteger(W)||W<0||W>J-Q)return J+1;Q+=W}return Q}function P1($,J,Q){if(!Number.isSafeInteger($)||!Number.isSafeInteger(J)||$<0||J<0||$!==0&&J>Math.floor(Q/$))return Q+1;return $*J}function $7($,J,Q){let W=[];for(let X of $){let Y=Q.get(X)??J?.get(X);if(Y!==void 0)W.push(Y)}return W.push(...Q.values()),Yj(W)}function Yj($){let J=new Map;for(let W of $)J.set(W,(J.get(W)??0)+1);let Q=[...J].map(([W,X])=>({value:W,frequency:X,hasPlaceholder:t(W)}));return{values:$,entries:Q,byValue:new Map(Q.map((W)=>[W.value,W]))}}function NG($,J,Q,W){return D1($.values,(X)=>{if(!$.byValue.get(X)?.hasPlaceholder)return null;let Y=J.length>0?J:[void 0];return D1(Y,(K)=>{let B=K===void 0?X:_0(X,K);return Q.analyzeNested(B,{envAssignments:Q.envAssignments,effectiveCwd:W?null:Q.cwd})})})}function PG($,J,Q){let W={};if($)W.envAssignments=$;if(Q)return W.effectiveCwd=null,W.worktreeMode=!1,W;if(J!==void 0)W.effectiveCwd=J;return Object.keys(W).length>0?W:void 0}function _0($,J){return $.replace(/\{[^{}\s]*\}/g,(Q)=>AG(Q,J))}function J7($,J){return $.replace(FG,(Q)=>AG(Q,J))}function AG($,J){let Q=/^\{(-?\d+)[^{}\s]*\}$/.exec($)?.[1];if(Q===void 0)return J[0]??"";let W=Number(Q),X=W>0?W-1:J.length+W;return J[X]??""}function t($){return mI.test($)}function EG($){if(W7($))return!0;for(let J of $.matchAll(/\{[^{}\s]*\}/g))if(!/^(?:\{\}|\{-?\d+\})$/.test(J[0]))return!0;return!1}function W7($){let J=$.indexOf("{=");return J!==-1&&$.indexOf("=}",J+2)!==-1}function CG($){return/^\{[^{}\s]*\}$/.test($)}function SG($){let J=1,Q=[],W=$.length,X=-1,Y=!1,K=!1,B=!1,q,U=$.some((O)=>O==="::::"||O==="::::+"||O===":::+"),G=[];while(J<$.length){let O=$[J];if(O===void 0)break;if(O===":::"){X=J;break}if(O==="--"){let A=vQ($,J+1);Q.push(...A.templateTokens),W=J+1,X=A.markerIndex;break}if(!O.startsWith("-")){let A=vQ($,J);Q.push(...A.templateTokens),W=J,X=A.markerIndex;break}let V=$[J+1],F=O.indexOf("="),b=F===-1?O:O.slice(0,F),I=F===-1?void 0:O.slice(F+1);if(O==="--dry-run"){B=!0,J++;continue}if(O==="-I"||O.startsWith("-I")&&O.length>2){U||=(O==="-I"?V:O.slice(2))!=="{}",J+=O==="-I"?2:1;continue}if(O==="--replace"||O==="-i"){U=!0,J+=2;continue}if(b==="--replace"||O.startsWith("-i")&&O.length>2){let A=b==="--replace"?I:O.slice(2);U||=A!==""&&A!=="{}",J++;continue}if(O==="-a"||dI.has(b)){U=!0,J+=I===void 0?2:1;continue}if(O==="--pipe"||O==="--pipepart"){K=!0,J++;continue}if(b==="--env"){G.push(...qj(I??V)),J+=I===void 0?2:1;continue}if(UG.has(b)||O.startsWith("-S")&&O.length>2){Y=!0,J+=UG.has(O)?2:1;continue}if(rI.has(b)){let A=I??V;if(A===void 0||A===":::"||A==="--"){U=!0,J++;continue}q=A,U||=I!==void 0&&A==="",J+=I===void 0?2:1;continue}if(O.startsWith("-j")&&O.length>2&&/^\d+$/.test(O.slice(2))){J++;continue}if(O.startsWith("--")&&I!==void 0){J++;continue}if(cI.has(O)){if(V===void 0||V===":::"||V==="--"){U=!0,J++;continue}J+=2;continue}J+=O==="-j"||O==="--jobs"?2:1}U||=Q.some(B?W7:EG);let H=[];if(X!==-1){let O=[];for(let V=X+1;V<$.length;V++){let F=$[V];if(F===":::"){H.push(O),O=[];continue}if(F!==void 0)O.push(F)}H.push(O)}let L=Bj(H),Z=Q.some(t),M=Q.length===0&&X===-1;return{template:Q,jobs:L,childStart:W,templateHasPlaceholder:Z,runsRemotely:Y,usesStdin:K||X===-1,envNames:G,readsCommandsFromInput:M,unsupported:U,workdir:q,dryRun:B}}function Kj($,J,Q){if($===void 0)return;if($==="..."||/[{}$`*?~[]/.test($))return null;if(!J&&!gI($))return null;try{return r0(J??$,$,Q)}catch{return null}}function Bj($){if($.length===0||$.some((Q)=>Q.length===0))return[];let J=[[]];for(let Q of $){if(Q.length===1){let X=Q[0];if(X===void 0)return[];for(let Y of J)Y.push(X);continue}let W=[];for(let X of J)for(let Y of Q)if(W.push([...X,Y]),W.length>h.maxChildAnalyses)return W;J=W}return J}function qj($){return($??"").split(",").map((J)=>J.trim()).filter(Boolean)}function TG($){return SG($).childStart}var Uj="dynamic command name contains shell substitution output and cannot be verified safely. Use a literal executable name.",t9="shell substitution output can change guarded command structure and cannot be verified safely. Use literal subcommands and options.";function Y7($){return $?.parts.some((J)=>J.provenance==="command-substitution")??!1}function X7($){return $?.parts.some((J)=>J.provenance==="literal"&&J.raw.replace(/^["']/,"").startsWith("-"))??!1}function vG($,J,Q,W,X=!1,Y){let B=(UQ($,J)||W&&$!=="powershell"&&J[0]?.provenance==="variable")&&q1(Y,"shell.dynamic-executable",X)?D("shell.dynamic-executable",Uj):null;return k(B,Y)??fG($,J,Q,X,Y)}function fG($,J,Q,W,X){if(J.length<2)return null;let Y=J.flatMap((B,q)=>Y7(B)?[q]:[]);if(Y.length===0)return null;let K=r(J[0]?.text??"");if(K==="git"){let B=i2($,J),q=Hj(B);if(q1(X,"shell.dynamic-structure",W)&&Y.some((H)=>H<=q))return k(D("shell.dynamic-structure",t9),X);if(k(K4(B,{env:Q.env}),X))return null;let U=J[q]?.text.toLowerCase(),G=B.findIndex((H,L)=>L>q&&v(H)==="--");if(q1(X,"shell.dynamic-structure",W)&&U&&c9.has(U)&&Y.some((H)=>H>q&&(G===-1||H<G)))return k(D("shell.dynamic-structure",t9),X);return null}if(K==="find")return q1(X,"shell.dynamic-structure",W)&&Zj(J)?k(D("shell.dynamic-structure",t9),X):null;if(K==="rm"){let B=J.findIndex((U,G)=>G>0&&v(U)==="--"),q=W0(J.map(v));return q1(X,"shell.dynamic-structure",W)&&Y.some((U)=>(B===-1||U<B)&&(U<J.length-1||!q))?k(D("shell.dynamic-structure",t9),X):null}if(K==="xargs")return wG($,J.slice(A2(J.map(v)).childStart),"xargs",Q,W,X);if(K==="parallel")return wG($,J.slice(TG(J.map(v))),"parallel",Q,W,X);return null}function wG($,J,Q,W,X,Y){if(J.length===0)return null;let K=Gj(J,W);if(UQ($,K)){let q=k(D(`${Q}.shell-dynamic`,Q==="xargs"?sQ:A3),Y);if(q)return q}let B=fG($,K,W,X,Y);if(B)return B;if(K[0]?.text==="rm"&&K.slice(1).some((q)=>Y7(q)&&X7(q)))return k(D(`${Q}.rm-recursive-force-dynamic`,Q==="xargs"?nQ:P3),Y);return null}function Gj($,J){let Q=_2($,J),W=Q.rewritten?p(Q.words.map(v)):Q.words,X=W[0];return X&&v(X)==="busybox"?W.slice(1):W}function Hj($){let J=1;while(J<$.length){let Q=$[J],W=Q?v(Q):"";if(U0.has(W)){J+=2;continue}if(W.startsWith("-")){J++;continue}return J}return J}function Zj($){let J=!1,Q=0,W=!1,X=!1;for(let Y=1;Y<$.length;Y++){let K=$[Y];if(!K)continue;let B=Y7(K);if(Q>0){Q--;continue}if(X){if(K.text===";"||K.text==="+"){X=!1,J=!0,W=!1;continue}if(B&&(W||X7(K)))return!0;W=!1;continue}if(!J&&!K.text.startsWith("-")){if(B&&(Y>1||X7(K)))return!0;continue}if(J=!0,B)return!0;let q=s0(K.text);if(q>0){Q=q;continue}if(h0(K.text))X=!0,W=!0}return!1}function K7($,J){return $.some((Q)=>{if(Q.value==="-"&&(Q.kind==="main-script"||Q.kind==="program-file"))return!0;return!x6(J[Q.tokenIndex],Q.value)})}var Lj="dd writing to a /dev device can destroy a disk or partition. Run device writes manually after confirming the target.",Mj="mkfs formatting a /dev device erases everything on it. Run the format manually after confirming the target.",Oj="shred permanently destroys the given target. Use rm for ordinary deletes, or run shred manually.";function kG($,J){let Q=J.slice(1);if($==="dd"&&Q.some((W)=>/^of=\/dev\/.+/.test(W)))return D("dd.device-write",Lj);if(($==="mkfs"||$.startsWith("mkfs."))&&Q.some((W)=>W.startsWith("/dev/")))return D("mkfs.device",Mj);if($==="shred"&&Q.length>0)return D("shred.target",Oj);return null}var yG=[{heads:new Set(["rm","rmdir"]),analyze:($)=>B4($.words,{environment:$.options.environment,cwd:$.cwd,originalCwd:$.originalCwd,strict:$.options.strict,paranoid:$.options.paranoidRm,allowTmpdirVar:$.allowTmpdirVar,tmpdirWordSplittingUnsafe:H0($.envAssignments,$.options.environment),trustedTmpdirValue:f0($.envAssignments,$.options.environment),protectedGitMetadata:$.options.protectedGitMetadata,policy:$.options.policy})},{heads:new Set(["git"]),analyze:($)=>K4($.words,B7($))},{heads:new Set(["find"]),analyze:($)=>m9($.words,{environment:$.options.environment,cwd:$.cwd,originalCwd:$.originalCwd,strict:$.options.strict,allowTmpdirVar:$.allowTmpdirVar,tmpdirWordSplittingUnsafe:H0($.envAssignments,$.options.environment),trustedTmpdirValue:f0($.envAssignments,$.options.environment),protectedGitMetadata:$.options.protectedGitMetadata,derivedCommandWorkBudget:$.options.derivedCommandWorkBudget,envAssignments:$.envAssignments,policy:$.options.policy,analyzeTokens:$.analyzeChildTokens,analyzeNested:(J,Q)=>S2($.options.analyzeNested(J,Q))})},{heads:new Set(["xargs"]),analyze:($)=>XG($.words,{...hG($),analyzeNested:(J,Q)=>S2($.options.analyzeNested(J,Q))})},{heads:new Set(["parallel"]),analyze:($)=>VG($.words,{...hG($),budget:$.options.parallelBudget,analyzeNested:(J,Q)=>S2($.options.analyzeNested(J,Q))})}];function hG($){return{environment:$.options.environment,cwd:$.cwd,originalCwd:$.originalCwd,strict:$.options.strict,paranoidRm:$.options.paranoidRm,paranoidInterpreters:$.options.paranoidInterpreters,allowTmpdirVar:$.allowTmpdirVar,protectedGitMetadata:$.options.protectedGitMetadata,derivedCommandWorkBudget:$.options.derivedCommandWorkBudget,envAssignments:$.envAssignments,worktreeMode:$.options.worktreeMode,policy:$.options.policy,scanWork:$.options.scanWork}}function S2($){return $?{id:$.ruleId??"",reason:$.reason,intent:$.intent??"manual_only"}:null}function B7($){return{env:$.options.environment.env,cwd:$.cwd,dynamicArguments:$.dynamicArguments,envAssignments:$.envAssignments,policy:$.options.policy,worktreeMode:$.options.worktreeMode}}var mG="shell execution source cannot be verified safely. Use a literal command string or ask the user to run it manually.";function lG($){return yG.find((J)=>J.heads.has($))?.analyze}function E3($,J,Q){let W=Q.trace;if($.length===0)return null;let X=Q.commandView?.dialect??"posix",Y=(T)=>T.map((m)=>X==="posix"?v(m):m.text),K=Q.effectiveCwd===null,B=K?void 0:Q.effectiveCwd??Q.cwd,q=K?void 0:Q.cwd,U=U9($);if(U.envAssignments.size>0)W?.recordSegment({type:"env-strip",input:Y($),envVars:[...U.envAssignments.keys()],output:Y(U.words)});let G=_2(U.words,Q.environment,B,new Map([...Q.envAssignments??[],...U.envAssignments]));if(G.unverifiableEnvSplit)throw new N2;let H=G.rewritten?p(Y(G.words)):i2(X,G.words),L=Y(H),Z={...Q,wrapperNormalizationBudget:Q.wrapperNormalizationBudget??{iterations:0}};if(W&&U.words.length>H.length){let T=Y(U.words);W.recordSegment({type:"leading-tokens-stripped",input:T,removed:T.slice(0,T.length-H.length),output:L})}let M=new Map([...Q.envAssignments??[],...U.envAssignments,...G.envAssignments]),O=L[0];if(!O)return null;if(R2(O))throw new p1;let V=r(O),F=G.cwd===null?void 0:G.cwd??B,b=G.cwd===null?void 0:q,I=G.cwd===void 0?Q.effectiveCwd:G.cwd,A=!B3(M,Q.environment),E=vG(X,G.words,Q.environment,J===0,Q.strict,Q.policy);if(E)return W?.recordSegment({type:"rule-check",rule:"analyzer/segment.ts:analyzeDynamicCommandStructure",matched:!0,reason:E.reason}),y0(E);let _=u9(L,Q.policy);if(_){for(let T of[_.childIndex,..._.alternativeChildIndices]){gG(Z.wrapperNormalizationBudget);let m=H.slice(T);W?.recordSegment({type:"transparent-wrapper",wrapper:_.wrapper,output:Y(m)});let X1=E3(m,J,{...Z,effectiveCwd:I,envAssignments:M});if(X1)return X1}return null}let R=V==="eval"?q4(H):V==="trap"?aU(H):void 0;if(R?.kind==="dynamic"&&(Q.strict||!Q.commandView||!iQ(Q.commandView)))return i1(W);if(R?.kind==="literal"){W?.recordSegment({type:"recurse",reason:V==="eval"?"shell-eval":"shell-trap",innerCommand:R.source,depth:J+1});let T=Q.analyzeNested(R.source,{effectiveCwd:I,envAssignments:M,functionDefinitions:Q.functionDefinitions});if(T)return T}if(cG(O,V)){if(r1(L))return null;let T=Nj(L,M,I,Q,W,J);if(T)return T;let m=O0(L);if(m){let d2=d9(H,m);if(d2.kind==="dynamic")return i1(W);let VJ=d2.kind==="literal"?d2.source:m,RK=Fj(VJ);W?.recordSegment({type:"shell-wrapper",wrapper:V,innerCommand:RK}),W?.recordSegment({type:"recurse",reason:"shell-wrapper",innerCommand:RK,depth:J+1});let bK=Q.analyzeNested(VJ,{effectiveCwd:I,envAssignments:M});if(bK)return bK;return U4(VJ)?i1(W):null}let X1=F0(H);if(X1.kind==="dynamic")return i1(W);if(X1.kind==="literal")return J$(X1.source,I,M,Q,W,J);let Z1=tU(H,Q.commandView?.redirections??[],Q.hasPipelineInput??!1,Q.literalShellInput);if(Z1.kind==="dynamic")return i1(W);if(Z1.kind==="literal")return W?.recordSegment({type:"recurse",reason:"shell-stdin",innerCommand:Z1.source,depth:J+1}),Q.analyzeNested(Z1.source,{effectiveCwd:I,envAssignments:M})}if(V==="source"||V==="."){let T=L[1]==="-p"?2:null;if(T!==null){let d2=Q.commandView?H[T]:void 0;if(!d2)return null;if(d2.provenance!=="literal")return i1(W)}let m=T===null?1:3,X1=L[m]==="--"?m+1:m,Z1=Q.commandView?H[X1]:void 0;if(!Z1)return null;if(Z1.provenance==="literal")return J$(Z1.text,I,M,Q,W,J);if(Q.strict||!Q.commandView||!iQ(Q.commandView))return i1(W)}if(h1.has(V)){if(Q.strict&&K7(D3(L),H))return i1(W);let T=x9(L,(X1)=>S2(Q.analyzeNested(X1,{effectiveCwd:I,envAssignments:M}))),m=k(T,Q.policy);if(m)return W?.recordSegment({type:"rule-check",rule:"awk:analyzeAwkSystemCallMatch",matched:!0,reason:m.reason}),y0(m)}if(w1(V)){if(Q.strict&&K7(Q9(L),H))return i1(W);let T=J9(L);if(T){let m=q1(Q.policy,"interpreter.one-liner-paranoid",!!Q.paranoidInterpreters);if(W?.recordSegment({type:"interpreter",interpreter:V,codeArg:T,paranoidBlocked:m}),m){let Z1=k(D("interpreter.one-liner-paranoid",t2),Q.policy);if(Z1)return y0(Z1)}if(X9(V,T))return null;W?.recordSegment({type:"recurse",reason:"interpreter",innerCommand:T,depth:J+1});let X1=Q.analyzeNested(T,{effectiveCwd:I,envAssignments:M});if(X1&&X1.ruleId!=="raw-text.dangerous-command"&&(X1.reason!==i0||W4(T)))return X1;if(e2(T,Q.scanWork)){let Z1=k(D("interpreter.dangerous-command",V2),Q.policy);if(Z1)return W?.recordSegment({type:"dangerous-text",token:T,matched:!0,reason:V2}),y0(Z1)}W=void 0}}if(V==="busybox"&&L.length>1)return gG(Z.wrapperNormalizationBudget),W?.recordSegment({type:"busybox",subcommand:L[1]??"unknown"}),W?.recordSegment({type:"recurse",reason:"busybox",innerCommand:L.slice(1).join(" "),depth:J+1}),E3(H.slice(1),J,{...Z,effectiveCwd:I,envAssignments:M});let P=k(kG(V,L),Q.policy);if(P)return W?.recordSegment({type:"rule-check",rule:"analyzer/device.ts:analyzeDeviceCommandMatch",matched:!0,reason:P.reason}),y0(P);let C=W===Z.trace?Z:{...Z,trace:W},S={words:H,head:V,cwd:F,originalCwd:b,envAssignments:M,allowTmpdirVar:A,dynamicArguments:G.words.some((T)=>T.provenance==="command-substitution"),depth:J,effectiveCwd:I,options:C,analyzeChildTokens:(T,m)=>S2(E3(p(T),J+1,{...C,commandView:void 0,effectiveCwd:m,envAssignments:M}))??M1(T,C.policy.rules)},g=lG(V);if(V==="rm"||V==="xargs"||V==="parallel")W?.recordSegment({type:"tmpdir-check",tmpdirValue:M.has("TMPDIR")||Q.environment.env.has("TMPDIR")?"<redacted>":null,isOverriddenToNonTemp:!A,allowTmpdirVar:A});let x=W&&V==="git"?uU(S.words,B7(S)):void 0,d=xG(x?x.match:g?.(S)??null,Q.policy);if(W)Vj(S,d,x?.relaxation??null);if(d)return y0(d);let V1=g!==void 0;if(!V1)if(!e6.has(V)){let T=W?[]:void 0;for(let m=1;m<L.length;m++){let X1=L[m];if(!X1)continue;T?.push(X1);let Z1=xG(_j(S,L,m),Q.policy);if(Z1)return W?.recordSegment({type:"fallback-scan",tokensScanned:T??[],embeddedCommandFound:r(X1)}),y0(Z1)}W?.recordSegment({type:"fallback-scan",tokensScanned:T??[]})}else W?.recordSegment({type:"fallback-scan",tokensScanned:[]});else W?.recordSegment({type:"fallback-scan",tokensScanned:[]});if(J===0||!V1){let T=M1(L,Q.policy.rules);if(W?.recordSegment({type:"custom-rules-check",rulesChecked:Q.policy.rules.length>0,matched:!!T,reason:T?.reason}),T)return y0(T)}else W?.recordSegment({type:"custom-rules-check",rulesChecked:!1,matched:!1});return null}function Nj($,J,Q,W,X,Y){let K=rU($);if(K.argvSource?.kind==="absent")return i1(X);if(K.argvSourceApplies&&K.argvSource){let q=J$(K.argvSource.value,Q,J,W,X,Y,!0);if(q)return q}if(!K.envSourceApplies||!K.envName)return null;let B=J.get(K.envName);if(!B)return null;return J$(B,Q,J,W,X,Y,!0)}function J$($,J,Q,W,X,Y,K=!1){if(K&&/[$`*?[\]]/.test($))return i1(X);let B=K3($,J,W.environment.paths),q=B?W.literalHeredocFiles?.get(B):void 0;if(q===void 0)return K?i1(X):null;return G0(W.derivedCommandWorkBudget,1),X?.recordSegment({type:"recurse",reason:"heredoc-file",innerCommand:q,depth:Y+1}),W.analyzeNested(q,{effectiveCwd:J,envAssignments:Q})}function Fj($){let J=$[0];return $.length>=2&&(J==='"'||J==="'")&&$.at(-1)===J?$.slice(1,-1):$}function Vj($,J,Q){let W={git:"git:analyzeGitMatch",rm:"analyzer/rm.ts:analyzeRmMatch",find:"analyzer/find.ts:analyzeFindMatch",xargs:"analyzer/xargs.ts:analyzeXargs",parallel:"analyzer/parallel.ts:analyzeParallel"}[$.head];if(!W)return;if($.options.trace?.recordSegment({type:"rule-check",rule:W,matched:!!J||!!Q,reason:J?.reason??Q?.originalReason}),Q)$.options.trace?.recordSegment({type:"worktree-relaxation",originalReason:Q.originalReason,gitCwd:Q.gitCwd})}function gG($){if($.iterations>=s2)throw new p1;$.iterations++}function y0($){return{reason:$.reason,ruleId:$.id||void 0,intent:$.intent}}function i1($){return $?.recordSegment({type:"error",message:mG}),y0(pG())}function pG(){return{id:"",reason:mG,intent:"stop_and_explain"}}function cG($,J){return U1.has(J)||$==="$SHELL"||$==="${SHELL}"||U1.has(l(J))}function _j($,J,Q){let W=Q0(J.slice(Q),{environment:$.options.environment,cwd:$.cwd,envAssignments:$.envAssignments,policy:$.options.policy});for(let X of W){let Y=Dj($,Q,X);if(Y)return Y}return null}function Dj($,J,Q){let W=Q.tokens[0];if(!W)return null;let X=r(W);if(cG(W,X)){G0($.options.derivedCommandWorkBudget,$.words.length-J);let q=Q.tokens;if(r1(q))return null;let U=O0(q);if(!U){if(F0(p(q)).kind==="dynamic")return pG();return $$($,Q)}let G=$.options.analyzeNested(U,{effectiveCwd:Q.wrapperCwd===void 0?$.effectiveCwd:Q.wrapperCwd,envAssignments:Q.envAssignments});return G?S2(G):$$($,Q)}let Y=lG(X);if(!Y||X==="xargs"||X==="parallel"){if(Q.wrappedByTransparent&&$.options.policy.rules.length>0)G0($.options.derivedCommandWorkBudget,$.words.length-J);return $$($,Q)}G0($.options.derivedCommandWorkBudget,$.words.length-J);let K=[X,...Q.tokens.slice(1)],B={...$,words:p(K),head:X,cwd:Q.cwd,originalCwd:Q.wrapperCwd===null?void 0:$.originalCwd,envAssignments:Q.envAssignments,allowTmpdirVar:!B3(Q.envAssignments,$.options.environment),effectiveCwd:Q.wrapperCwd===void 0?$.effectiveCwd:Q.wrapperCwd,options:X==="git"?{...$.options,worktreeMode:!1}:$.options};return Y(B)??$$($,Q)}function $$($,J){return J.wrappedByTransparent?M1(J.tokens,$.options.policy.rules):null}function xG($,J){return $?.id.startsWith("custom.")?$:k($,J)}var zj=/^\s*(?:\$\(\s*)?[({]*\s*(?:command\s+|builtin\s+)?(?:cd|pushd|popd)(?:\s|$)/,Ij=new Set(["cd","chdir","pop-location","popd","push-location","pushd","set-location","sl"]);function jj($,J){let Q=iG($,J);if(Q.length===0)return!1;let W=Q[rG(Q)];if(W==="cd"||W==="pushd"||W==="popd")return!0;return zj.test($.join(" "))}function dG($,J,Q,W){if($.dialect==="powershell"){let B=Rj($.words,W);if(B.kind==="none")return;if(!J||B.kind==="unknown")return null;return uG(Ej(B.target),J,Q.paths)}let X=$.words.map(v);if(!jj(X,Q))return;if(!J)return null;let Y=iG(X,Q,J),K=rG(Y);if(K===-1||Y[K]!=="cd")return null;return uG(Y[K+1],J,Q.paths)}function uG($,J,Q){if(!$||$==="-"||$.includes("$")||$.includes("`"))return null;try{return Cj(r0(J,$,Q),J,Q)?J:null}catch{return null}}function Rj($,J){let Q=bj($[0])?1:0,W=$[Q];if(!Pj(W,Q===1))return{kind:"none"};let X=W.text.toLowerCase(),Y=X.split(/[\\/]/).pop()??X;if(!Ij.has(Y))return{kind:"none"};if(X!==Y||Y==="pop-location"||Y==="popd")return{kind:"unknown"};return Aj($.slice(Q+1),J)}function bj($){return $?.provenance==="literal"&&!$.quoted&&$.raw===$.text&&($.text==="&"||$.text===".")}function Pj($,J){return $?.provenance==="literal"&&(J||!$.quoted&&$.raw===$.text)}function Aj($,J){let Q;for(let W of $){if(W.provenance!=="literal"||Q!==void 0)return{kind:"unknown"};Q=W.text}if(Q!==void 0)return{kind:"target",target:Q};return J===void 0?{kind:"unknown"}:{kind:"target",target:J}}function Ej($){return $.includes("::")?void 0:$.replaceAll("\\","/")}function rG($){let J=0;if($[0]==="builtin"&&$.length>1)J=1;if($[J]!=="time")return J;let Q=J+1;while($[Q]?.startsWith("-"))Q++;return Q}function iG($,J,Q){let W=Sj($);return c1([...W],J,Q)}function Cj($,J,Q){let W=Q.realpath($),X=Q.realpath(J);if(W===null||X===null)return e9($)===e9(J);return e9(W)===e9(X)}function Sj($){let J=0;while(J<$.length){let Q=$[J];if(Q==="{"||Q==="("||Q==="$(")J++;else break}return $.slice(J)}var C3="TMPDIR",S3="IFS",Tj=/^([A-Za-z_][A-Za-z0-9_]*)\+=/,q7=/^[A-Za-z_][A-Za-z0-9_]*$/;function nG($,J){let Q=hj($,J);return{env:$,effectiveEnvAssignments:Q,shellAssignments:new Map,exportedNames:yj($,Q),allexport:!1,keywordExport:!1}}function sG($){return{env:$.env,effectiveEnvAssignments:$.effectiveEnvAssignments?new Map($.effectiveEnvAssignments):void 0,shellAssignments:new Map($.shellAssignments),exportedNames:new Set($.exportedNames),allexport:$.allexport,keywordExport:$.keywordExport}}function U7($,J){let Q=wj($,J);if(!Q)return;let{command:W,commandIndex:X,leadingAssignments:Y,prefixAssignmentsPersist:K}=Q;if(W===null){for(let q of Y.values())oG(J,q);return}if(K)for(let q of Y.values())J.shellAssignments.set(q.name,q.value),J.exportedNames.add(q.name),$2(J,q);if(W==="set"){let q=cj($,X);if(q.allexport!==null)J.allexport=q.allexport;if(q.keywordExport!==null)J.keywordExport=q.keywordExport;return}if(W==="unset"){let q=mj($,X);if(q===null)return;for(let U of $.slice(q))uj(J,U);return}if(W!=="export"&&W!=="typeset"&&W!=="declare"&&W!=="readonly")return;for(let q of Y.values())oG(J,q);if(W==="export"){let q=lj($,X);if(q===null)return;for(let U of $.slice(q))gj(J,U);return}let B=pj($,X);if(B===null)return;for(let q of $.slice(B.operandsStart))xj(J,q,B.exports,W==="readonly"?Y:void 0)}function aG($,J){if(!J.keywordExport)return J.effectiveEnvAssignments;let Q=null,W=X$(J);for(let X of $){let Y=W$(X,W,J.env);if(!Y)continue;Q??=new Map(J.effectiveEnvAssignments??[]),Q.set(Y.name,Y.value),W.set(Y.name,Y.value)}return Q??J.effectiveEnvAssignments}function wj($,J){let Q=new Map,W=0;while(W<$.length){let B=$[W];if(!B)return null;let q=W$(B,X$(J,Q),J.env);if(!q)break;Q.set(q.name,q),W++}if(W>=$.length)return{command:null,commandIndex:W,leadingAssignments:Q,prefixAssignmentsPersist:!1};let X=W,Y=W,K=$[Y]??null;while(K==="builtin"||K==="command"||K==="time"){if(K==="builtin"){if(Y++,$[Y]==="--")Y++;K=$[Y]??null;continue}if(K==="command"){let q=vj($,Y);if(!q)return null;Y=q.commandIndex,K=q.command;continue}let B=fj($,Y);if(!B)return null;Y=B.commandIndex,K=B.command}if(K===null)return null;return{command:K,commandIndex:Y,leadingAssignments:Q,prefixAssignmentsPersist:Y===X&&(K==="unset"||K==="set"||K==="export"||K==="readonly")}}function vj($,J){return tG($,J,(Q)=>{if(Q==="-p")return"skip";return Q==="-v"||Q==="-V"?"abort":"stop"})}function fj($,J){return tG($,J,(Q)=>Q.startsWith("-")?"skip":"stop")}function tG($,J,Q){let W=J+1;while(W<$.length){let Y=$[W];if(!Y)return null;if(Y==="--"){W++;break}let K=Q(Y);if(K==="abort")return null;if(K==="skip"){W++;continue}break}let X=$[W];return X?{command:X,commandIndex:W}:null}function W$($,J,Q){return t1($)??kj($,J,Q)}function kj($,J,Q){let W=l6($,Q,J);if(W)return W;let X=$.match(Tj)?.[1];if(!X)return null;let Y=$.indexOf("=");return{name:X,value:`${J.has(X)?J.get(X):Q.get(X)??""}${$.slice(Y+1)}`}}function Q$($){return $===C3||$===S3||yJ($)}function X$($,J){return new Map([...$.effectiveEnvAssignments??[],...$.shellAssignments,...[...J?.values()??[]].map((Q)=>[Q.name,Q.value])])}function hj($,J){let Q=[...u6,C3,S3].map((W)=>{let X=$.get(W);return X===void 0?null:[W,X]}).filter((W)=>W!==null);if(Q.length===0)return J;return new Map([...Q,...J??[]])}function yj($,J){let Q=new Set;for(let W of $.keys())if(Q$(W))Q.add(W);for(let W of J?.keys()??[])if(Q$(W))Q.add(W);return Q}function oG($,J){if($.shellAssignments.set(J.name,J.value),J.name===C3||J.name===S3||$.allexport||$.exportedNames.has(J.name))$2($,J)}function $2($,J){let Q=new Map($.effectiveEnvAssignments??[]);Q.set(J.name,J.value),$.effectiveEnvAssignments=Q}function gj($,J){let Q=W$(J,X$($),$.env);if(Q){$.shellAssignments.set(Q.name,Q.value),$.exportedNames.add(Q.name),$2($,Q);return}if(q7.test(J))eG($,J)}function xj($,J,Q,W){let X=W$(J,X$($),$.env);if(X){if($.shellAssignments.set(X.name,X.value),Q)$.exportedNames.add(X.name),$2($,X);else if(X.name===C3||X.name===S3||$.allexport||$.exportedNames.has(X.name))$2($,X);return}let Y=W?.get(J);if(Y){$.exportedNames.add(J),$2($,Y);return}if(Q&&q7.test(J))eG($,J)}function eG($,J){$.exportedNames.add(J),$2($,{name:J,value:$.shellAssignments.get(J)??$.effectiveEnvAssignments?.get(J)??$.env.get(J)??""})}function uj($,J){if(!Q$(J)&&!q7.test(J))return;if($.shellAssignments.set(J,""),$.exportedNames.delete(J),!Q$(J)||J===C3||J===S3||t4(J)){$2($,{name:J,value:""});return}if(!$.effectiveEnvAssignments?.has(J))return;let Q=new Map($.effectiveEnvAssignments);Q.delete(J),$.effectiveEnvAssignments=Q.size===0?void 0:Q}function mj($,J){return $H($,J,(Q)=>Q==="-v")}function lj($,J){return $H($,J,(Q)=>Q==="-p")}function $H($,J,Q){let W=J+1;while(W<$.length){let X=$[W];if(!X)return null;if(X==="--")return W+1;if(Q(X)){W++;continue}if(X.startsWith("-"))return null;return W}return W}function pj($,J){let Q=J+1,W=!1;while(Q<$.length){let X=$[Q];if(!X)return null;if(X==="--")return{operandsStart:Q+1,exports:W};if(X.startsWith("-")){if(X.slice(1).includes("x"))W=!0;Q++;continue}if(X.startsWith("+")){if(X.slice(1).includes("x"))W=!1;Q++;continue}return{operandsStart:Q,exports:W}}return{operandsStart:Q,exports:W}}function cj($,J){let Q={allexport:null,keywordExport:null},W=J+1;while(W<$.length){let X=$[W];if(!X)return Q;if(X==="--")return Q;if(X==="-o"||X==="+o"){if($[W+1]==="allexport")Q.allexport=X==="-o";if($[W+1]==="keyword")Q.keywordExport=X==="-o";W+=2;continue}if(X.startsWith("-")&&X.length>1){let Y=X.slice(1);if(Y.includes("a"))Q.allexport=!0;if(Y.includes("k"))Q.keywordExport=!0;W++;continue}if(X.startsWith("+")&&X.length>1){let Y=X.slice(1);if(Y.includes("a"))Q.allexport=!1;if(Y.includes("k"))Q.keywordExport=!1;W++;continue}return Q}return Q}var dj="Unquoted heredoc input is not supported safely. Quote the delimiter or ask the user to verify.",T2="This heredoc form or stdin consumer is not supported safely. Use a quoted heredoc with a supported consumer (cat, tee, git apply, git commit, gh pr create, gh issue create), or ask the user to verify.",rj=64;function M7($,J,Q,W){let X=Q.derivedCommandWorkBudget===void 0,Y=Q.parallelBudget===void 0;try{return ij($,J,{...Q,derivedCommandWorkBudget:Q.derivedCommandWorkBudget??a6(),parallelBudget:Q.parallelBudget??cB()},W)}catch(K){let B=K instanceof N2?kB:K instanceof p1&&X?fB:K instanceof B9&&Y?pB:void 0;if(!B)throw K;if(Q.trace?.currentSegmentIndex!==void 0)Q.trace.recordSegment({type:"error",message:B});else Q.trace?.recordGlobal({type:"error",message:B});return{reason:B,segment:$,intent:"stop_and_explain"}}}function ij($,J,Q,W){if(J>=t6)return Q.trace?.recordSegment({type:"error",message:S0}),{reason:S0,segment:$,intent:"stop_and_explain"};let X=W??Q.factStore?.getCommandProgram($,Q.shell??"auto")??e1($,Q.shell);if(X.status==="limited")return Q.trace?.recordSegment({type:"error",message:S0}),{reason:S0,segment:$,intent:"stop_and_explain"};if(X.status==="invalid"){let U=X.issues.find((G)=>G.code.includes("heredoc"));if(U){if(!Q.strict)return L7($,Q);let G=`Unsupported heredoc syntax: ${U.message}`;return Q.trace?.recordGlobal({type:"error",message:G}),{reason:G,segment:$,intent:"stop_and_explain"}}return KH($,Q),{reason:i0,segment:$,intent:"stop_and_explain"}}if(Q.strict&&X.status==="partial")return KH($,Q),{reason:i0,segment:$,intent:"stop_and_explain"};if(X.issues.some((U)=>U.code.includes("quote"))&&!Q.analyzePartialProgram)return L7($,Q);let K=Q.cwd,B=Q.effectiveCwd!==void 0?Q.effectiveCwd:Q.cwd,q=nG(Q.environment.env,Q.envAssignments);return B$(X,J,{...Q,rootProgram:X},K,[{effectiveCwd:B,shellGitContextState:q,literalHeredocFiles:new Map(Q.literalHeredocFiles),functionDefinitions:new Map(Q.functionDefinitions)}]).result}function B$($,J,Q,W,X){let Y=[...X],K,B;for(let[q,U]of $.nodes.entries()){if(U.kind==="connector"){B=U.operator;continue}let G=$.nodes[q+1],H=G?.kind==="connector"?G.operator:void 0,L=oj($,q,U,B,H),Z=B==="&&"||B==="||",M=Z?K:void 0,O=B==="&&"?M?.success??Y:B==="||"?M?.failure??Y:Y,V=B==="||"?M?.success??[]:[],F=B==="&&"?M?.failure??[]:[],b=Z||L4(H);if(U.kind==="function"){let C=O.flatMap((g)=>{let x=T3(g);return x.functionDefinitions.set(U.name,U.body),G7(g,[x],L,H==="&",L4(H))}),S=H7(C,[],V,F,B,H);Y=S.states,K=S.conditionalStates,B=void 0;continue}if(U.kind==="group"){let C=[],S=[];for(let x of O){let d=B$(U.body,J,Q,W,[T3(x)]);if(d.result)return d;if(C.push(...G7(x,d.states,L,H==="&",L4(H))),b)S.push(x,...L?d.states.map((V1)=>Y$(x,V1)):d.states)}let g=H7(C,S,V,F,B,H);Y=g.states,K=g.conditionalStates,B=void 0;continue}if(U.kind!=="command")continue;let I=Q.trace?.flattenNested?Q.trace.currentSegmentIndex:Q.trace?.allocateSegment(),A=$.nodes[q-2],E=q$(B)&&A?.kind==="command"?sU(A)??sj(A):void 0,_=[],R=[];for(let C of O){let S=aj(U,J,Q,W,[T3(C)]);if(S.result)return{result:S.result,states:Y};let g=$.dialect==="powershell"?S.states:S.states.map((x)=>Y$(C,x));for(let x of g){let d=T3(x),V1=$R(U,J,Q.trace?{...Q,trace:BH(Q.trace,I)}:Q,W,d,q$(B),E);if(V1)return{result:V1,states:Y};let T=LR(U,d.functionDefinitions);if(T)G0(Q.derivedCommandWorkBudget,U$(T));let m=T?J+1>=t6?Z7(U.displayText,Q,[d]):B$(T,J+1,Q,W,[d]):{result:null,states:[d]};if(m.result)return m;if(_.push(...G7(C,m.states,L,H==="&",L4(H))),b)R.push(C),R.push(...m.states.map((X1)=>L?Y$(C,X1):X1))}}let P=H7(_,R,V,F,B,H);Y=P.states,K=P.conditionalStates,B=void 0}return{result:null,states:Y}}function oj($,J,Q,W,X){if(Q.kind==="group"&&Q.style==="subshell")return!0;if($.dialect==="posix"&&(q$(W)||q$(X)))return!0;if(X==="&")return!0;return $.dialect==="powershell"&&Q.kind==="group"&&Q.style==="brace"&&nj($,J)}function G7($,J,Q,W,X){let Y=Q?J.map((B)=>Y$($,B)):[...J],K=X?Y.flatMap((B)=>w3($.literalHeredocFiles,B.literalHeredocFiles)?[B]:[{...B,literalHeredocFiles:new Map($.literalHeredocFiles)},B]):Y;return W?[$,...K]:K}function Y$($,J){return{...$,literalHeredocFiles:new Map(J.literalHeredocFiles)}}function nj($,J){let Q=[...$.nodes.slice(0,J)].reverse().find((X)=>X.kind==="command"||X.kind==="connector");if(!Q||Q.kind!=="command")return!0;let W=Q.words[0]?.text.toLowerCase();if(W==="&"||W===".")return!1;if(W==="write-output"||W==="function"||W==="start-job")return!0;if(tj(Q))return!0;return Q.source.replaceAll(/\s/g,"").toLowerCase()==="if($false)"}function q$($){return $==="|"||$==="|&"}function sj($){if($?.dialect!=="powershell")return;if($.words.length===1&&$.words[0]?.quoted&&$.words[0].provenance==="literal")return $.words[0].text;if($.words[0]?.text.toLowerCase()==="write-output"&&$.words.length===2&&$.words[1]?.provenance==="literal")return $.words[1].text;return}function L4($){return $==="&&"||$==="||"}function H7($,J,Q,W,X,Y){let K={success:K$([...Q,...$]),failure:K$([...W,...J])},B=L4(Y)?K:void 0;return{states:L4(X)||B?K$([...K.success,...K.failure]):K.success,conditionalStates:B}}function BH($,J,Q=$.flattenNested){return{currentSegmentIndex:J,flattenNested:Q,allocateSegment:$.allocateSegment,getNextSegmentIndex:$.getNextSegmentIndex,recordGlobal:$.recordGlobal,recordSegment:(W,X=J)=>$.recordSegment(W,X)}}function aj($,J,Q,W,X){let Y=$.nested.map((K)=>({program:K,depth:J}));if($.dialect==="powershell"){let K=ej($);if(K){if(J+1>=t6)return Z7(K,Q,X);let B=e1(K,"powershell");if(B.status==="limited")return Z7(K,Q,X);if(B.status!=="complete")return JH(Y,Q,W,X);G0(Q.derivedCommandWorkBudget,U$(B)),Y.push({program:B,depth:J+1})}}return JH(Y,Q,W,X)}function tj($){let J=$.words[0];return J?.provenance==="variable"&&$.words.at(-1)?.text==="="?J.text.toLowerCase():void 0}function JH($,J,Q,W){let X=[...W];for(let Y of $){let K=[];for(let B of X){let q=B$(Y.program,Y.depth,J,Q,[T3(B)]);if(q.result)return q;K.push(...q.states)}X=K$(K)}return{result:null,states:X}}function ej($){let J=$.words[0]?.provenance==="literal"&&!$.words[0].quoted&&$.words[0].raw===$.words[0].text&&($.words[0].text==="&"||$.words[0].text==="."),Q=J?1:0,W=$.words[Q];if(W?.provenance!=="literal"||!J&&(W.quoted||W.raw!==W.text)||!["iex","invoke-expression"].includes(W.text.toLowerCase()))return;let X=$.words.slice(Q+1),Y=X[0]&&!X[0].quoted&&X[0].raw===X[0].text&&["-c","-command"].includes(X[0].text.toLowerCase())?1:0,K=X[Y];return X.length===Y+1&&K?.quoted&&K.provenance==="literal"?K.text:void 0}function U$($){return $.nodes.reduce((J,Q)=>J+(Q.kind==="command"?Q.words.length+Q.nested.reduce((W,X)=>W+U$(X),0):Q.kind==="group"||Q.kind==="function"?U$(Q.body):0),0)}function Z7($,J,Q){return J.trace?.recordSegment({type:"error",message:S0}),{result:{reason:S0,segment:$,intent:"stop_and_explain"},states:[...Q]}}function $R($,J,Q,W,X,Y,K){let B=BR($);if(B&&Q.strict)return Q.trace?.recordSegment({type:"error",message:B}),{reason:B,segment:$.source,intent:"stop_and_explain"};qH($,X,"before-consumer",Q.environment.paths);let q=i2($.dialect,$.words).map(v),U=$.displayText,G=aG(q,X.shellGitContextState);if($.dialect==="powershell"){let Z=k(OU($,Y,NR(Q,X.effectiveCwd)),Q.policy);if(Q.trace?.recordSegment({type:"rule-check",rule:"analyzer/powershell/remove-item.ts:analyzePowerShellCommandViewMatch",matched:!!Z,reason:Z?.reason}),Z)return OR(U,Z)}if(q.length===1&&q[0]?.includes(" ")&&!$.dynamicExecutable){let Z=k(Y3(q[0],Q.scanWork),Q.policy),M=Z!==null&&!Q.strict&&TB($,Q.rootProgram,Q.scanWork);if(Z&&!M)return Q.trace?.recordSegment({type:"dangerous-text",token:q[0],matched:!0,reason:Z.reason}),{reason:Z.reason,segment:U,ruleId:Z.id,intent:Z.intent};Q.trace?.recordSegment({type:"dangerous-text",token:q[0],matched:!1});let O=QH($,B,X,G,K,Q);if(O)return O;return U7(q,X.shellGitContextState),null}let H=E3($.words,J,{...Q,commandView:$,cwd:W,effectiveCwd:X.effectiveCwd,envAssignments:G,literalHeredocFiles:X.literalHeredocFiles,functionDefinitions:X.functionDefinitions,hasPipelineInput:Y,literalShellInput:K,analyzeNested:(Z,M)=>{let O=M&&Object.hasOwn(M,"effectiveCwd")?M.effectiveCwd:X.effectiveCwd,V=M7(Z,J+1,{...Q,derivedCommandWorkBudget:Q.derivedCommandWorkBudget,effectiveCwd:O,envAssignments:M?.envAssignments??G,literalHeredocFiles:X.literalHeredocFiles,functionDefinitions:M?.functionDefinitions,worktreeMode:M?.worktreeMode??Q.worktreeMode,trace:Q.trace?BH(Q.trace,Q.trace.currentSegmentIndex,!0):void 0});return V?{reason:V.reason,ruleId:V.ruleId,intent:V.intent}:null}});if(H)return{...H,segment:U};let L=QH($,B,X,G,K,Q);if(L)return L;return U7(q,X.shellGitContextState),null}function QH($,J,Q,W,X,Y){let K=qR($,J,Q,W??new Map,Y);if(K)return K;return qH($,Q,"after-consumer",Y.environment.paths),Q.literalHeredocFiles.clear(),WR($,J,Q,Y.environment.paths),HR($,Q,X,Y.environment,Y.trace),null}var JR=new Set([">>","<>"]);function qH($,J,Q,W){for(let Y of $.redirections){if(!(Q==="before-consumer"?QR(Y):JR.has(Y.operator)))continue;WH(Y.target,J,W)}if(Q!=="before-consumer"||!y1($.words[0],"tee"))return;let X=UH($.words.slice(1));if(!X)return;for(let Y of X.operands)WH(Y,J,W)}function QR($){if($.operator===">"||$.operator===">|")return!0;return $.operator===">&"&&$.fd===void 0&&$.target?.provenance==="literal"&&!/^(?:[0-9]+|-)$/.test($.target.text)}function WH($,J,Q){let W=$?.provenance==="literal"?K3($.text,J.effectiveCwd,Q):void 0;if(!W)return;J.literalHeredocFiles.delete(W)}function WR($,J,Q,W){if(J)return;let X=$.redirections.find((Y)=>Y.operator==="<<"||Y.operator==="<<-")?.heredoc;if(!X?.quotedDelimiter)return;for(let Y of XR($)){let K=K3(Y.text,Q.effectiveCwd,W);if(!K||!gB(K))continue;if(!Q.literalHeredocFiles.has(K)&&Q.literalHeredocFiles.size>=yB)throw new p1;Q.literalHeredocFiles.set(K,X.body)}}function XR($){let J=KR($.redirections)?.target,Q=XH(J)?[J]:[];if(y1($.words[0],"cat"))return YR($.words)?Q:[];if(!y1($.words[0],"tee"))return[];let W=UH($.words.slice(1));if(!W||W.append||W.hasUnsupportedOptions||!W.operands.every(XH))return[];return[...W.operands,...Q]}function YR($){let J=!1;for(let Q of $.slice(1)){if(J||Q.provenance!=="literal")return!1;if(Q.text==="--"){J=!0;continue}if(!/^-u+$/.test(Q.text))return!1}return!0}function KR($){let J=$.findLast((Q)=>(Q.fd??([">",">|",">>",">&"].includes(Q.operator)?1:0))===1);return J?.operator===">"||J?.operator===">|"?J:void 0}function UH($){let J=[],Q=!0,W=!1,X=!1;for(let Y of $){if(Y.provenance!=="literal")return;if(Q&&y1(Y,"--")){Q=!1;continue}if(Q&&!Y.quoted&&Y.raw===Y.text&&/^-[^-]/.test(Y.text)){W||=Y.text.slice(1).includes("a"),X||=[...Y.text.slice(1)].some((K)=>K!=="a"&&K!=="i");continue}if(Q&&!Y.quoted&&Y.raw===Y.text&&Y.text.startsWith("--")){W||=Y.text==="--append",X||=Y.text!=="--append"&&Y.text!=="--ignore-interrupts";continue}J.push(Y)}return{operands:J,append:W,hasUnsupportedOptions:X}}function XH($){if(!$||$.provenance!=="literal"||$.text.length===0)return!1;if($.quoted||$.raw!==$.text)return!0;return!$.raw.startsWith("~")&&!/[{}]/.test($.raw)}function y1($,J){return $?.text===J&&$.raw===J&&$.provenance==="literal"&&!$.quoted}function BR($){let J=$.redirections.filter((K)=>K.operator==="<<"||K.operator==="<<-");if(J.length===0)return;if(J.length!==1)return T2;let Q=J[0];if(!Q?.heredoc)return T2;if(!Q.heredoc.quotedDelimiter)return dj;if(Q.fd!==void 0&&Q.fd!==0)return T2;if($.redirections.some((K)=>K!==Q&&["<","<<","<<-","<<<","<&","<>"].includes(K.operator)))return T2;let W=$.redirections.some((K)=>K!==Q&&YH(K.target));if(y1($.words[0],"cat"))return W?T2:void 0;if(y1($.words[0],"tee"))return W||$.words.slice(1).some(YH)?T2:void 0;let X=$.words[0],Y=$.words[1];if(y1(X,"git")&&(y1(Y,"apply")||y1(Y,"commit")))return;if(y1(X,"gh")&&(y1(Y,"pr")||y1(Y,"issue"))&&y1($.words[2],"create"))return;return T2}function YH($){return $?.parts.some((J)=>J.provenance==="command-substitution"&&J.raw.startsWith(">("))??!1}function qR($,J,Q,W,X){if(!J)return null;let Y=$.redirections.filter((U)=>U.operator==="<<"||U.operator==="<<-"),K=Y.flatMap((U)=>U.heredoc?[U.heredoc.body]:[]);if(GR($,Y,Q,W,X))return null;let B=UR($,Y,X);if(B!==void 0)return B?{reason:B.reason,segment:$.displayText,ruleId:B.id,intent:B.intent}:null;let q=L7(K.length===Y.length?K.join(`
62
- `):$.source,X);return q?{...q,segment:$.displayText}:null}function UR($,J,Q){let W=J.length===1?J[0]:void 0;if(!W?.heredoc?.quotedDelimiter||W.fd!==void 0&&W.fd!==0)return;let X=$.words[0];if(X?.provenance!=="literal"||!w1(X.text))return;if(!$.words.slice(1).every((U)=>U.provenance==="literal"&&U.text.startsWith("-")))return;let K=W.heredoc.body,B=q1(Q.policy,"interpreter.one-liner-paranoid",!!Q.paranoidInterpreters);if(Q.trace?.recordSegment({type:"interpreter",interpreter:X.text,codeArg:K,paranoidBlocked:B}),B){let U=k(D("interpreter.one-liner-paranoid",t2),Q.policy);if(U)return U}if(!e2(K,Q.scanWork))return null;let q=k(D("interpreter.dangerous-command",V2),Q.policy);if(!q)return null;return Q.trace?.recordSegment({type:"dangerous-text",token:K,matched:!0,reason:q.reason}),q}function GR($,J,Q,W,X){let Y=J.length===1?J[0]:void 0;if(!Y?.heredoc?.quotedDelimiter||Y.fd!==void 0&&Y.fd!==0)return!1;let K=_2($.words,X.environment,Q.effectiveCwd,W),B=K.words.map(v),q=r(B[0]??"");if(K.unverifiableEnvSplit||!U1.has(q)&&!U1.has(l(q)))return!1;return r1(B)}function HR($,J,Q,W,X){let Y=dG($,J.effectiveCwd,W,Q);if(Y===null)X?.recordSegment({type:"cwd-change",segment:$.words.map(v).join(" "),effectiveCwdNowUnknown:!0});if(Y!==void 0)J.effectiveCwd=Y}function T3($){return{effectiveCwd:$.effectiveCwd,shellGitContextState:sG($.shellGitContextState),literalHeredocFiles:new Map($.literalHeredocFiles),functionDefinitions:new Map($.functionDefinitions)}}function K$($){let J=[];for(let Q of $){if(!J.some((W)=>ZR(W,Q)))J.push(Q);if(J.length>rj)throw new p1}return J}function ZR($,J){return $.effectiveCwd===J.effectiveCwd&&w3($.literalHeredocFiles,J.literalHeredocFiles)&&w3($.functionDefinitions,J.functionDefinitions)&&w3($.shellGitContextState.effectiveEnvAssignments,J.shellGitContextState.effectiveEnvAssignments)&&w3($.shellGitContextState.shellAssignments,J.shellGitContextState.shellAssignments)&&MR($.shellGitContextState.exportedNames,J.shellGitContextState.exportedNames)&&$.shellGitContextState.allexport===J.shellGitContextState.allexport&&$.shellGitContextState.keywordExport===J.shellGitContextState.keywordExport}function w3($,J){if($===J)return!0;if(!$||!J||$.size!==J.size)return!1;return[...$].every(([Q,W])=>J.get(Q)===W&&J.has(Q))}function LR($,J){let Q=j9($);return Q===void 0?void 0:J.get(Q)}function MR($,J){return $.size===J.size&&[...$].every((Q)=>J.has(Q))}function OR($,J){if(!J)return null;return{reason:J.reason,segment:$,ruleId:J.id,intent:J.intent}}function NR($,J=$.effectiveCwd){let Q=J===null;return{environment:$.environment,cwd:Q?void 0:J??$.cwd,originalCwd:Q?void 0:$.cwd,strict:$.strict,paranoid:$.paranoidRm,allowTmpdirVar:$.allowTmpdirVar,protectedGitMetadata:$.protectedGitMetadata,policy:$.policy}}function L7($,J){let Q=k(Y3($,J.scanWork),J.policy),W=J.trace?.currentSegmentIndex??J.trace?.allocateSegment(),X={type:"dangerous-text",token:$,matched:!!Q,reason:Q?.reason};if(J.trace?.recordSegment(X,W),!Q&&/^(?:cd|pushd)\s/.test($))J.trace?.recordSegment({type:"cwd-change",segment:$,effectiveCwdNowUnknown:!0},W);return Q?{reason:Q.reason,segment:$,ruleId:Q.id,intent:Q.intent}:null}function KH($,J){let Q={type:"strict-unparseable",rawCommand:$,reason:i0};if(J.trace?.currentSegmentIndex===void 0)J.trace?.recordGlobal(Q);else J.trace.recordSegment(Q)}var H1={level:{name:"CC_SAFETY_NET_LEVEL"},strict:{name:"CC_SAFETY_NET_STRICT",legacyName:"SAFETY_NET_STRICT"},paranoid:{name:"CC_SAFETY_NET_PARANOID",legacyName:"SAFETY_NET_PARANOID"},paranoidRm:{name:"CC_SAFETY_NET_PARANOID_RM",legacyName:"SAFETY_NET_PARANOID_RM"},paranoidInterpreters:{name:"CC_SAFETY_NET_PARANOID_INTERPRETERS",legacyName:"SAFETY_NET_PARANOID_INTERPRETERS"},worktree:{name:"CC_SAFETY_NET_WORKTREE",legacyName:"SAFETY_NET_WORKTREE"},debug:{name:"CC_SAFETY_NET_DEBUG"},auditScope:{name:"CC_SAFETY_NET_AUDIT_SCOPE"}},G$=["standard","strict","paranoid"];function FR($){return{failClosed:$==="strict"||$==="paranoid",paranoidRm:$==="paranoid",paranoidInterpreters:$==="paranoid"}}function VR($,J){if(!J)return $;return G$.indexOf(J)>G$.indexOf($)?J:$}function _R(){let $=_7(H1.level);if($===void 0||$==="")return;if(G$.includes($))return $;console.error(`CC Safety Net: ignored invalid ${H1.level.name}=${JSON.stringify($.slice(0,40))}. Use ${G$.join(", ")}.`);return}function DR($){if($===void 0||$==="all")return"all";if($==="blocked")return"blocked";return"invalid"}function N7(){return DR(_7(H1.auditScope))==="all"}function F7($){if($.failClosed&&$.paranoidRm&&$.paranoidInterpreters)return"paranoid";if($.failClosed&&!$.paranoidRm&&!$.paranoidInterpreters)return"strict";if(!$.failClosed&&!$.paranoidRm&&!$.paranoidInterpreters)return"standard";return"custom"}function V7($={}){let J=$.safety?.level??"standard",Q=_R(),W=VR(J,Q),X=FR(W),Y={failClosed:W===J?"preset":"environment",paranoidRm:W===J?"preset":"environment",paranoidInterpreters:W===J?"preset":"environment"},K={failClosed:[`policy safety.level=${J}`],paranoidRm:[`policy safety.level=${J}`],paranoidInterpreters:[`policy safety.level=${J}`]};if(W!==J)K.failClosed.push(`env ${H1.level.name}=${Q}`),K.paranoidRm.push(`env ${H1.level.name}=${Q}`),K.paranoidInterpreters.push(`env ${H1.level.name}=${Q}`);if($.safety?.overrides?.failClosed!==void 0)X.failClosed=$.safety.overrides.failClosed,Y.failClosed="capability_override",K.failClosed.push("policy safety.overrides.fail_closed");if($.safety?.overrides?.paranoidRm!==void 0)X.paranoidRm=$.safety.overrides.paranoidRm,Y.paranoidRm="capability_override",K.paranoidRm.push("policy safety.overrides.paranoid_rm");if($.safety?.overrides?.paranoidInterpreters!==void 0)X.paranoidInterpreters=$.safety.overrides.paranoidInterpreters,Y.paranoidInterpreters="capability_override",K.paranoidInterpreters.push("policy safety.overrides.paranoid_interpreters");if(J2(H1.strict))X.failClosed=!0,Y.failClosed="environment",K.failClosed.push(`env ${H1.strict.name}`);if(J2(H1.paranoid))X.paranoidRm=!0,X.paranoidInterpreters=!0,Y.paranoidRm="environment",Y.paranoidInterpreters="environment",K.paranoidRm.push(`env ${H1.paranoid.name}`),K.paranoidInterpreters.push(`env ${H1.paranoid.name}`);if(J2(H1.paranoidRm))X.paranoidRm=!0,Y.paranoidRm="environment",K.paranoidRm.push(`env ${H1.paranoidRm.name}`);if(J2(H1.paranoidInterpreters))X.paranoidInterpreters=!0,Y.paranoidInterpreters="environment",K.paranoidInterpreters.push(`env ${H1.paranoidInterpreters.name}`);let B=!!$.worktreeMode||J2(H1.worktree);return{strict:X.failClosed,paranoidRm:X.paranoidRm,paranoidInterpreters:X.paranoidInterpreters,worktreeMode:B,effectiveLevel:F7(X),capabilities:{fail_closed:{enabled:X.failClosed,source:Y.failClosed,sources:K.failClosed},paranoid_rm:{enabled:X.paranoidRm,source:Y.paranoidRm,sources:K.paranoidRm},paranoid_interpreters:{enabled:X.paranoidInterpreters,source:Y.paranoidInterpreters,sources:K.paranoidInterpreters}}}}function J2($){let J=typeof $==="string"?O7($):_7($);return J==="1"||J?.toLowerCase()==="true"}function O7($){return Object.hasOwn(process.env,$)?process.env[$]:void 0}function _7($){let J=O7($.name);if(J!==void 0)return J;if($.legacyName)return O7($.legacyName);return}function GH($){let J=$.effectiveCapabilities,Q=$.strict??J.fail_closed.enabled,W=$.paranoidRm??J.paranoid_rm.enabled,X=$.paranoidInterpreters??J.paranoid_interpreters.enabled,Y={fail_closed:D7(J.fail_closed,$.strict,"strict"),paranoid_rm:D7(J.paranoid_rm,$.paranoidRm,"paranoidRm"),paranoid_interpreters:D7(J.paranoid_interpreters,$.paranoidInterpreters,"paranoidInterpreters")};return{policy:CB($.policySnapshot.policy,Y),effectiveCapabilities:Y,effectiveLevel:F7({failClosed:Q,paranoidRm:W,paranoidInterpreters:X}),strict:Q,paranoidRm:W,paranoidInterpreters:X,worktreeMode:$.worktreeMode??!1}}function D7($,J,Q){if(J===void 0||J===$.enabled)return $;return{enabled:J,source:"capability_override",sources:[...$.sources,`analysis options.${Q}`]}}function HH($,J,Q,W){let X=M7($,0,{...J,...GH(J),factStore:W},Q);if(!X)return null;return{kind:"deny",reason:X.reason,intent:X.intent??"manual_only",...X.ruleId?{ruleId:X.ruleId}:{},evidence:[{kind:"command",command:$,segment:X.segment}]}}import{dirname as LK}from"node:path";function H$($,J,Q,W,X){if(Q.kind!=="command")return{toolName:$,input:J,route:Q,context:W};return{toolName:$,input:J,route:Q,context:W,command:X}}import{chmodSync as mh,existsSync as AP,mkdirSync as lh,readFileSync as EP}from"node:fs";import{dirname as CP,join as SP}from"node:path";import{createRequire as MP}from"node:module";var WK={};U2(WK,{z:()=>UJ,xor:()=>hZ,xid:()=>YZ,void:()=>SZ,uuidv7:()=>aH,uuidv6:()=>sH,uuidv4:()=>nH,uuid:()=>oH,util:()=>w,url:()=>tH,uppercase:()=>P4,unknown:()=>x2,union:()=>$J,undefined:()=>EZ,ulid:()=>XZ,uint64:()=>PZ,uint32:()=>jZ,tuple:()=>AY,trim:()=>w4,treeifyError:()=>V$,transform:()=>QJ,toUpperCase:()=>f4,toLowerCase:()=>v4,toJSONSchema:()=>a3,templateLiteral:()=>nZ,symbol:()=>AZ,superRefine:()=>$K,success:()=>rZ,stringbool:()=>WL,stringFormat:()=>NZ,string:()=>v8,strictObject:()=>fZ,startsWith:()=>E4,slugify:()=>k4,size:()=>h2,setErrorMap:()=>BL,set:()=>mZ,safeParseAsync:()=>R8,safeParse:()=>j8,safeEncodeAsync:()=>T8,safeEncode:()=>C8,safeDecodeAsync:()=>w8,safeDecode:()=>S8,registry:()=>o3,regexes:()=>x1,regex:()=>R4,refine:()=>eY,record:()=>EY,readonly:()=>iY,property:()=>N8,promise:()=>sZ,prettifyError:()=>_$,preprocess:()=>YL,prefault:()=>uY,positive:()=>Z8,pipe:()=>K6,partialRecord:()=>gZ,parseAsync:()=>I8,parse:()=>z8,overwrite:()=>Y0,optional:()=>X6,object:()=>vZ,number:()=>HY,nullish:()=>dZ,nullable:()=>Y6,null:()=>NY,normalize:()=>T4,nonpositive:()=>M8,nonoptional:()=>mY,nonnegative:()=>O8,never:()=>e8,negative:()=>L8,nativeEnum:()=>lZ,nanoid:()=>JZ,nan:()=>iZ,multipleOf:()=>K2,minSize:()=>j0,minLength:()=>x0,mime:()=>S4,meta:()=>JL,maxSize:()=>B2,maxLength:()=>y2,map:()=>uZ,mac:()=>qZ,lte:()=>u1,lt:()=>z0,lowercase:()=>b4,looseRecord:()=>xZ,looseObject:()=>kZ,locales:()=>i3,literal:()=>pZ,length:()=>g2,lazy:()=>sY,ksuid:()=>KZ,keyof:()=>wZ,jwt:()=>OZ,json:()=>XL,iso:()=>Q6,ipv6:()=>UZ,ipv4:()=>BZ,intersection:()=>bY,int64:()=>bZ,int32:()=>IZ,int:()=>f8,instanceof:()=>QL,includes:()=>A4,httpUrl:()=>eH,hostname:()=>FZ,hex:()=>VZ,hash:()=>_Z,guid:()=>iH,gte:()=>z1,gt:()=>I0,globalRegistry:()=>C1,getErrorMap:()=>qL,function:()=>aZ,fromJSONSchema:()=>QK,formatError:()=>V4,float64:()=>zZ,float32:()=>DZ,flattenError:()=>F4,file:()=>cZ,exactOptional:()=>kY,enum:()=>JJ,endsWith:()=>C4,encodeAsync:()=>A8,encode:()=>b8,emoji:()=>$Z,email:()=>rH,e164:()=>MZ,discriminatedUnion:()=>yZ,describe:()=>$L,default:()=>UP,decodeAsync:()=>E8,decode:()=>P8,date:()=>TZ,custom:()=>eZ,cuid2:()=>WZ,cuid:()=>QZ,core:()=>R0,config:()=>Y1,coerce:()=>qJ,codec:()=>oZ,clone:()=>N1,cidrv6:()=>HZ,cidrv4:()=>GZ,check:()=>tZ,catch:()=>cY,boolean:()=>ZY,bigint:()=>RZ,base64url:()=>LZ,base64:()=>ZZ,array:()=>U6,any:()=>CZ,_function:()=>aZ,_default:()=>gY,_ZodString:()=>k8,ZodXor:()=>IY,ZodXID:()=>l8,ZodVoid:()=>DY,ZodUnknown:()=>VY,ZodUnion:()=>H6,ZodUndefined:()=>MY,ZodUUID:()=>b0,ZodURL:()=>B6,ZodULID:()=>m8,ZodType:()=>y,ZodTuple:()=>PY,ZodTransform:()=>vY,ZodTemplateLiteral:()=>oY,ZodSymbol:()=>LY,ZodSuccess:()=>lY,ZodStringFormat:()=>o,ZodString:()=>l4,ZodSet:()=>SY,ZodRecord:()=>Z6,ZodRealError:()=>I1,ZodReadonly:()=>rY,ZodPromise:()=>aY,ZodPrefault:()=>xY,ZodPipe:()=>YJ,ZodOptional:()=>WJ,ZodObject:()=>G6,ZodNumberFormat:()=>u2,ZodNumber:()=>c4,ZodNullable:()=>hY,ZodNull:()=>OY,ZodNonOptional:()=>XJ,ZodNever:()=>_Y,ZodNanoID:()=>g8,ZodNaN:()=>dY,ZodMap:()=>CY,ZodMAC:()=>GY,ZodLiteral:()=>TY,ZodLazy:()=>nY,ZodKSUID:()=>p8,ZodJWT:()=>a8,ZodIssueCode:()=>KL,ZodIntersection:()=>RY,ZodISOTime:()=>$6,ZodISODuration:()=>J6,ZodISODateTime:()=>t3,ZodISODate:()=>e3,ZodIPv6:()=>d8,ZodIPv4:()=>c8,ZodGUID:()=>W6,ZodFunction:()=>tY,ZodFirstPartyTypeKind:()=>BJ,ZodFile:()=>wY,ZodExactOptional:()=>fY,ZodError:()=>dH,ZodEnum:()=>m4,ZodEmoji:()=>y8,ZodEmail:()=>h8,ZodE164:()=>s8,ZodDiscriminatedUnion:()=>jY,ZodDefault:()=>yY,ZodDate:()=>q6,ZodCustomStringFormat:()=>p4,ZodCustom:()=>L6,ZodCodec:()=>KJ,ZodCatch:()=>pY,ZodCUID2:()=>u8,ZodCUID:()=>x8,ZodCIDRv6:()=>i8,ZodCIDRv4:()=>r8,ZodBoolean:()=>d4,ZodBigIntFormat:()=>t8,ZodBigInt:()=>r4,ZodBase64URL:()=>n8,ZodBase64:()=>o8,ZodArray:()=>zY,ZodAny:()=>FY,TimePrecision:()=>H8,NEVER:()=>Z$,$output:()=>p$,$input:()=>c$,$brand:()=>L$});var UJ={};U2(UJ,{xor:()=>hZ,xid:()=>YZ,void:()=>SZ,uuidv7:()=>aH,uuidv6:()=>sH,uuidv4:()=>nH,uuid:()=>oH,util:()=>w,url:()=>tH,uppercase:()=>P4,unknown:()=>x2,union:()=>$J,undefined:()=>EZ,ulid:()=>XZ,uint64:()=>PZ,uint32:()=>jZ,tuple:()=>AY,trim:()=>w4,treeifyError:()=>V$,transform:()=>QJ,toUpperCase:()=>f4,toLowerCase:()=>v4,toJSONSchema:()=>a3,templateLiteral:()=>nZ,symbol:()=>AZ,superRefine:()=>$K,success:()=>rZ,stringbool:()=>WL,stringFormat:()=>NZ,string:()=>v8,strictObject:()=>fZ,startsWith:()=>E4,slugify:()=>k4,size:()=>h2,setErrorMap:()=>BL,set:()=>mZ,safeParseAsync:()=>R8,safeParse:()=>j8,safeEncodeAsync:()=>T8,safeEncode:()=>C8,safeDecodeAsync:()=>w8,safeDecode:()=>S8,registry:()=>o3,regexes:()=>x1,regex:()=>R4,refine:()=>eY,record:()=>EY,readonly:()=>iY,property:()=>N8,promise:()=>sZ,prettifyError:()=>_$,preprocess:()=>YL,prefault:()=>uY,positive:()=>Z8,pipe:()=>K6,partialRecord:()=>gZ,parseAsync:()=>I8,parse:()=>z8,overwrite:()=>Y0,optional:()=>X6,object:()=>vZ,number:()=>HY,nullish:()=>dZ,nullable:()=>Y6,null:()=>NY,normalize:()=>T4,nonpositive:()=>M8,nonoptional:()=>mY,nonnegative:()=>O8,never:()=>e8,negative:()=>L8,nativeEnum:()=>lZ,nanoid:()=>JZ,nan:()=>iZ,multipleOf:()=>K2,minSize:()=>j0,minLength:()=>x0,mime:()=>S4,meta:()=>JL,maxSize:()=>B2,maxLength:()=>y2,map:()=>uZ,mac:()=>qZ,lte:()=>u1,lt:()=>z0,lowercase:()=>b4,looseRecord:()=>xZ,looseObject:()=>kZ,locales:()=>i3,literal:()=>pZ,length:()=>g2,lazy:()=>sY,ksuid:()=>KZ,keyof:()=>wZ,jwt:()=>OZ,json:()=>XL,iso:()=>Q6,ipv6:()=>UZ,ipv4:()=>BZ,intersection:()=>bY,int64:()=>bZ,int32:()=>IZ,int:()=>f8,instanceof:()=>QL,includes:()=>A4,httpUrl:()=>eH,hostname:()=>FZ,hex:()=>VZ,hash:()=>_Z,guid:()=>iH,gte:()=>z1,gt:()=>I0,globalRegistry:()=>C1,getErrorMap:()=>qL,function:()=>aZ,fromJSONSchema:()=>QK,formatError:()=>V4,float64:()=>zZ,float32:()=>DZ,flattenError:()=>F4,file:()=>cZ,exactOptional:()=>kY,enum:()=>JJ,endsWith:()=>C4,encodeAsync:()=>A8,encode:()=>b8,emoji:()=>$Z,email:()=>rH,e164:()=>MZ,discriminatedUnion:()=>yZ,describe:()=>$L,decodeAsync:()=>E8,decode:()=>P8,date:()=>TZ,custom:()=>eZ,cuid2:()=>WZ,cuid:()=>QZ,core:()=>R0,config:()=>Y1,coerce:()=>qJ,codec:()=>oZ,clone:()=>N1,cidrv6:()=>HZ,cidrv4:()=>GZ,check:()=>tZ,catch:()=>cY,boolean:()=>ZY,bigint:()=>RZ,base64url:()=>LZ,base64:()=>ZZ,array:()=>U6,any:()=>CZ,_function:()=>aZ,_default:()=>gY,_ZodString:()=>k8,ZodXor:()=>IY,ZodXID:()=>l8,ZodVoid:()=>DY,ZodUnknown:()=>VY,ZodUnion:()=>H6,ZodUndefined:()=>MY,ZodUUID:()=>b0,ZodURL:()=>B6,ZodULID:()=>m8,ZodType:()=>y,ZodTuple:()=>PY,ZodTransform:()=>vY,ZodTemplateLiteral:()=>oY,ZodSymbol:()=>LY,ZodSuccess:()=>lY,ZodStringFormat:()=>o,ZodString:()=>l4,ZodSet:()=>SY,ZodRecord:()=>Z6,ZodRealError:()=>I1,ZodReadonly:()=>rY,ZodPromise:()=>aY,ZodPrefault:()=>xY,ZodPipe:()=>YJ,ZodOptional:()=>WJ,ZodObject:()=>G6,ZodNumberFormat:()=>u2,ZodNumber:()=>c4,ZodNullable:()=>hY,ZodNull:()=>OY,ZodNonOptional:()=>XJ,ZodNever:()=>_Y,ZodNanoID:()=>g8,ZodNaN:()=>dY,ZodMap:()=>CY,ZodMAC:()=>GY,ZodLiteral:()=>TY,ZodLazy:()=>nY,ZodKSUID:()=>p8,ZodJWT:()=>a8,ZodIssueCode:()=>KL,ZodIntersection:()=>RY,ZodISOTime:()=>$6,ZodISODuration:()=>J6,ZodISODateTime:()=>t3,ZodISODate:()=>e3,ZodIPv6:()=>d8,ZodIPv4:()=>c8,ZodGUID:()=>W6,ZodFunction:()=>tY,ZodFirstPartyTypeKind:()=>BJ,ZodFile:()=>wY,ZodExactOptional:()=>fY,ZodError:()=>dH,ZodEnum:()=>m4,ZodEmoji:()=>y8,ZodEmail:()=>h8,ZodE164:()=>s8,ZodDiscriminatedUnion:()=>jY,ZodDefault:()=>yY,ZodDate:()=>q6,ZodCustomStringFormat:()=>p4,ZodCustom:()=>L6,ZodCodec:()=>KJ,ZodCatch:()=>pY,ZodCUID2:()=>u8,ZodCUID:()=>x8,ZodCIDRv6:()=>i8,ZodCIDRv4:()=>r8,ZodBoolean:()=>d4,ZodBigIntFormat:()=>t8,ZodBigInt:()=>r4,ZodBase64URL:()=>n8,ZodBase64:()=>o8,ZodArray:()=>zY,ZodAny:()=>FY,TimePrecision:()=>H8,NEVER:()=>Z$,$output:()=>p$,$input:()=>c$,$brand:()=>L$});var R0={};U2(R0,{version:()=>bW,util:()=>w,treeifyError:()=>V$,toJSONSchema:()=>a3,toDotPath:()=>FH,safeParseAsync:()=>w7,safeParse:()=>T7,safeEncodeAsync:()=>eR,safeEncode:()=>aR,safeDecodeAsync:()=>$b,safeDecode:()=>tR,registry:()=>o3,regexes:()=>x1,process:()=>s,prettifyError:()=>_$,parseAsync:()=>z$,parse:()=>D$,meta:()=>_5,locales:()=>i3,isValidJWT:()=>hH,isValidBase64URL:()=>kH,isValidBase64:()=>iW,initializeContext:()=>g4,globalRegistry:()=>C1,globalConfig:()=>v3,formatError:()=>V4,flattenError:()=>F4,finalize:()=>u4,extractDefs:()=>x4,encodeAsync:()=>nR,encode:()=>iR,describe:()=>V5,decodeAsync:()=>sR,decode:()=>oR,createToJSONSchemaMethod:()=>z5,createStandardJSONSchemaMethod:()=>F8,config:()=>Y1,clone:()=>N1,_xor:()=>Tb,_xid:()=>J8,_void:()=>U5,_uuidv7:()=>n$,_uuidv6:()=>o$,_uuidv4:()=>i$,_uuid:()=>r$,_url:()=>s3,_uppercase:()=>P4,_unknown:()=>B5,_union:()=>Sb,_undefined:()=>X5,_ulid:()=>$8,_uint64:()=>Q5,_uint32:()=>sX,_tuple:()=>fb,_trim:()=>w4,_transform:()=>mb,_toUpperCase:()=>f4,_toLowerCase:()=>v4,_templateLiteral:()=>sb,_symbol:()=>W5,_superRefine:()=>F5,_success:()=>rb,_stringbool:()=>D5,_stringFormat:()=>h4,_string:()=>yX,_startsWith:()=>E4,_slugify:()=>k4,_size:()=>h2,_set:()=>yb,_safeParseAsync:()=>I4,_safeParse:()=>z4,_safeEncodeAsync:()=>E$,_safeEncode:()=>P$,_safeDecodeAsync:()=>C$,_safeDecode:()=>A$,_regex:()=>R4,_refine:()=>N5,_record:()=>kb,_readonly:()=>nb,_property:()=>N8,_promise:()=>tb,_positive:()=>Z8,_pipe:()=>ob,_parseAsync:()=>D4,_parse:()=>_4,_overwrite:()=>Y0,_optional:()=>lb,_number:()=>cX,_nullable:()=>pb,_null:()=>Y5,_normalize:()=>T4,_nonpositive:()=>M8,_nonoptional:()=>db,_nonnegative:()=>O8,_never:()=>q5,_negative:()=>L8,_nativeEnum:()=>xb,_nanoid:()=>a$,_nan:()=>Z5,_multipleOf:()=>K2,_minSize:()=>j0,_minLength:()=>x0,_min:()=>z1,_mime:()=>S4,_maxSize:()=>B2,_maxLength:()=>y2,_max:()=>u1,_map:()=>hb,_mac:()=>xX,_lte:()=>u1,_lt:()=>z0,_lowercase:()=>b4,_literal:()=>ub,_length:()=>g2,_lazy:()=>ab,_ksuid:()=>Q8,_jwt:()=>G8,_isoTime:()=>lX,_isoDuration:()=>pX,_isoDateTime:()=>uX,_isoDate:()=>mX,_ipv6:()=>X8,_ipv4:()=>W8,_intersection:()=>vb,_int64:()=>J5,_int32:()=>nX,_int:()=>rX,_includes:()=>A4,_guid:()=>n3,_gte:()=>z1,_gt:()=>I0,_float64:()=>oX,_float32:()=>iX,_file:()=>M5,_enum:()=>gb,_endsWith:()=>C4,_encodeAsync:()=>R$,_encode:()=>I$,_emoji:()=>s$,_email:()=>d$,_e164:()=>U8,_discriminatedUnion:()=>wb,_default:()=>cb,_decodeAsync:()=>b$,_decode:()=>j$,_date:()=>G5,_custom:()=>O5,_cuid2:()=>e$,_cuid:()=>t$,_coercedString:()=>gX,_coercedNumber:()=>dX,_coercedDate:()=>H5,_coercedBoolean:()=>tX,_coercedBigint:()=>$5,_cidrv6:()=>K8,_cidrv4:()=>Y8,_check:()=>mH,_catch:()=>ib,_boolean:()=>aX,_bigint:()=>eX,_base64url:()=>q8,_base64:()=>B8,_array:()=>L5,_any:()=>K5,TimePrecision:()=>H8,NEVER:()=>Z$,JSONSchemaGenerator:()=>YY,JSONSchema:()=>lH,Doc:()=>v$,$output:()=>p$,$input:()=>c$,$constructor:()=>N,$brand:()=>L$,$ZodXor:()=>HX,$ZodXID:()=>hW,$ZodVoid:()=>BX,$ZodUnknown:()=>YX,$ZodUnion:()=>d3,$ZodUndefined:()=>QX,$ZodUUID:()=>EW,$ZodURL:()=>SW,$ZodULID:()=>kW,$ZodType:()=>f,$ZodTuple:()=>m$,$ZodTransform:()=>DX,$ZodTemplateLiteral:()=>TX,$ZodSymbol:()=>JX,$ZodSuccess:()=>PX,$ZodStringFormat:()=>i,$ZodString:()=>k2,$ZodSet:()=>NX,$ZodRegistry:()=>hX,$ZodRecord:()=>MX,$ZodRealError:()=>E1,$ZodReadonly:()=>SX,$ZodPromise:()=>vX,$ZodPrefault:()=>RX,$ZodPipe:()=>CX,$ZodOptional:()=>l$,$ZodObjectJIT:()=>GX,$ZodObject:()=>xH,$ZodNumberFormat:()=>eW,$ZodNumber:()=>x$,$ZodNullable:()=>IX,$ZodNull:()=>WX,$ZodNonOptional:()=>bX,$ZodNever:()=>KX,$ZodNanoID:()=>wW,$ZodNaN:()=>EX,$ZodMap:()=>OX,$ZodMAC:()=>cW,$ZodLiteral:()=>VX,$ZodLazy:()=>fX,$ZodKSUID:()=>yW,$ZodJWT:()=>aW,$ZodIntersection:()=>LX,$ZodISOTime:()=>uW,$ZodISODuration:()=>mW,$ZodISODateTime:()=>gW,$ZodISODate:()=>xW,$ZodIPv6:()=>pW,$ZodIPv4:()=>lW,$ZodGUID:()=>AW,$ZodFunction:()=>wX,$ZodFile:()=>_X,$ZodExactOptional:()=>zX,$ZodError:()=>u3,$ZodEnum:()=>FX,$ZodEncodeError:()=>w2,$ZodEmoji:()=>TW,$ZodEmail:()=>CW,$ZodE164:()=>sW,$ZodDiscriminatedUnion:()=>ZX,$ZodDefault:()=>jX,$ZodDate:()=>qX,$ZodCustomStringFormat:()=>tW,$ZodCustom:()=>kX,$ZodCodec:()=>r3,$ZodCheckUpperCase:()=>VW,$ZodCheckStringFormat:()=>j4,$ZodCheckStartsWith:()=>DW,$ZodCheckSizeEquals:()=>ZW,$ZodCheckRegex:()=>NW,$ZodCheckProperty:()=>IW,$ZodCheckOverwrite:()=>RW,$ZodCheckNumberFormat:()=>qW,$ZodCheckMultipleOf:()=>BW,$ZodCheckMinSize:()=>HW,$ZodCheckMinLength:()=>MW,$ZodCheckMimeType:()=>jW,$ZodCheckMaxSize:()=>GW,$ZodCheckMaxLength:()=>LW,$ZodCheckLowerCase:()=>FW,$ZodCheckLessThan:()=>T$,$ZodCheckLengthEquals:()=>OW,$ZodCheckIncludes:()=>_W,$ZodCheckGreaterThan:()=>w$,$ZodCheckEndsWith:()=>zW,$ZodCheckBigIntFormat:()=>UW,$ZodCheck:()=>n,$ZodCatch:()=>AX,$ZodCUID2:()=>fW,$ZodCUID:()=>vW,$ZodCIDRv6:()=>rW,$ZodCIDRv4:()=>dW,$ZodBoolean:()=>c3,$ZodBigIntFormat:()=>$X,$ZodBigInt:()=>u$,$ZodBase64URL:()=>nW,$ZodBase64:()=>oW,$ZodAsyncError:()=>D0,$ZodArray:()=>UX,$ZodAny:()=>XX});var Z$=Object.freeze({status:"aborted"});function N($,J,Q){function W(B,q){if(!B._zod)Object.defineProperty(B,"_zod",{value:{def:q,constr:K,traits:new Set},enumerable:!1});if(B._zod.traits.has($))return;B._zod.traits.add($),J(B,q);let U=K.prototype,G=Object.keys(U);for(let H=0;H<G.length;H++){let L=G[H];if(!(L in B))B[L]=U[L].bind(B)}}let X=Q?.Parent??Object;class Y extends X{}Object.defineProperty(Y,"name",{value:$});function K(B){var q;let U=Q?.Parent?new Y:this;W(U,B),(q=U._zod).deferred??(q.deferred=[]);for(let G of U._zod.deferred)G();return U}return Object.defineProperty(K,"init",{value:W}),Object.defineProperty(K,Symbol.hasInstance,{value:(B)=>{if(Q?.Parent&&B instanceof Q.Parent)return!0;return B?._zod?.traits?.has($)}}),Object.defineProperty(K,"name",{value:$}),K}var L$=Symbol("zod_brand");class D0 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class w2 extends Error{constructor($){super(`Encountered unidirectional transform during encode: ${$}`);this.name="ZodEncodeError"}}var v3={};function Y1($){if($)Object.assign(v3,$);return v3}var w={};U2(w,{unwrapMessage:()=>f3,uint8ArrayToHex:()=>dR,uint8ArrayToBase64url:()=>pR,uint8ArrayToBase64:()=>MH,stringifyPrimitive:()=>F$,slugify:()=>j7,shallowClone:()=>b7,safeExtend:()=>yR,required:()=>uR,randomString:()=>SR,propertyKeyTypes:()=>y3,promiseAllObject:()=>CR,primitiveTypes:()=>P7,prefixIssues:()=>g1,pick:()=>fR,partial:()=>xR,parsedType:()=>S7,optionalKeys:()=>A7,omit:()=>kR,objectClone:()=>PR,numKeys:()=>TR,nullish:()=>Q2,normalizeParams:()=>z,mergeDefs:()=>g0,merge:()=>gR,jsonStringifyReplacer:()=>M4,joinValues:()=>M$,issue:()=>N4,isPlainObject:()=>X2,isObject:()=>v2,hexToUint8Array:()=>cR,getSizableOrigin:()=>g3,getParsedType:()=>wR,getLengthableOrigin:()=>x3,getEnumValues:()=>k3,getElementAtPath:()=>ER,floatSafeRemainder:()=>I7,finalizeIssue:()=>A1,extend:()=>hR,escapeRegex:()=>o1,esc:()=>O$,defineLazy:()=>u,createTransparentProxy:()=>vR,cloneDef:()=>AR,clone:()=>N1,cleanRegex:()=>h3,cleanEnum:()=>mR,captureStackTrace:()=>N$,cached:()=>O4,base64urlToUint8Array:()=>lR,base64ToUint8Array:()=>LH,assignProp:()=>W2,assertNotEqual:()=>IR,assertNever:()=>RR,assertIs:()=>jR,assertEqual:()=>zR,assert:()=>bR,allowsEval:()=>R7,aborted:()=>Y2,NUMBER_FORMAT_RANGES:()=>E7,Class:()=>OH,BIGINT_FORMAT_RANGES:()=>C7});function zR($){return $}function IR($){return $}function jR($){}function RR($){throw Error("Unexpected value in exhaustive check")}function bR($){}function k3($){let J=Object.values($).filter((W)=>typeof W==="number");return Object.entries($).filter(([W,X])=>J.indexOf(+W)===-1).map(([W,X])=>X)}function M$($,J="|"){return $.map((Q)=>F$(Q)).join(J)}function M4($,J){if(typeof J==="bigint")return J.toString();return J}function O4($){return{get value(){{let Q=$();return Object.defineProperty(this,"value",{value:Q}),Q}throw Error("cached value already set")}}}function Q2($){return $===null||$===void 0}function h3($){let J=$.startsWith("^")?1:0,Q=$.endsWith("$")?$.length-1:$.length;return $.slice(J,Q)}function I7($,J){let Q=($.toString().split(".")[1]||"").length,W=J.toString(),X=(W.split(".")[1]||"").length;if(X===0&&/\d?e-\d?/.test(W)){let q=W.match(/\d?e-(\d?)/);if(q?.[1])X=Number.parseInt(q[1])}let Y=Q>X?Q:X,K=Number.parseInt($.toFixed(Y).replace(".","")),B=Number.parseInt(J.toFixed(Y).replace(".",""));return K%B/10**Y}var ZH=Symbol("evaluating");function u($,J,Q){let W=void 0;Object.defineProperty($,J,{get(){if(W===ZH)return;if(W===void 0)W=ZH,W=Q();return W},set(X){Object.defineProperty($,J,{value:X})},configurable:!0})}function PR($){return Object.create(Object.getPrototypeOf($),Object.getOwnPropertyDescriptors($))}function W2($,J,Q){Object.defineProperty($,J,{value:Q,writable:!0,enumerable:!0,configurable:!0})}function g0(...$){let J={};for(let Q of $){let W=Object.getOwnPropertyDescriptors(Q);Object.assign(J,W)}return Object.defineProperties({},J)}function AR($){return g0($._zod.def)}function ER($,J){if(!J)return $;return J.reduce((Q,W)=>Q?.[W],$)}function CR($){let J=Object.keys($),Q=J.map((W)=>$[W]);return Promise.all(Q).then((W)=>{let X={};for(let Y=0;Y<J.length;Y++)X[J[Y]]=W[Y];return X})}function SR($=10){let Q="";for(let W=0;W<$;W++)Q+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return Q}function O$($){return JSON.stringify($)}function j7($){return $.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var N$="captureStackTrace"in Error?Error.captureStackTrace:(...$)=>{};function v2($){return typeof $==="object"&&$!==null&&!Array.isArray($)}var R7=O4(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch($){return!1}});function X2($){if(v2($)===!1)return!1;let J=$.constructor;if(J===void 0)return!0;if(typeof J!=="function")return!0;let Q=J.prototype;if(v2(Q)===!1)return!1;if(Object.prototype.hasOwnProperty.call(Q,"isPrototypeOf")===!1)return!1;return!0}function b7($){if(X2($))return{...$};if(Array.isArray($))return[...$];return $}function TR($){let J=0;for(let Q in $)if(Object.prototype.hasOwnProperty.call($,Q))J++;return J}var wR=($)=>{let J=typeof $;switch(J){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN($)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray($))return"array";if($===null)return"null";if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return"promise";if(typeof Map<"u"&&$ instanceof Map)return"map";if(typeof Set<"u"&&$ instanceof Set)return"set";if(typeof Date<"u"&&$ instanceof Date)return"date";if(typeof File<"u"&&$ instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${J}`)}},y3=new Set(["string","number","symbol"]),P7=new Set(["string","number","bigint","boolean","symbol","undefined"]);function o1($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function N1($,J,Q){let W=new $._zod.constr(J??$._zod.def);if(!J||Q?.parent)W._zod.parent=$;return W}function z($){let J=$;if(!J)return{};if(typeof J==="string")return{error:()=>J};if(J?.message!==void 0){if(J?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");J.error=J.message}if(delete J.message,typeof J.error==="string")return{...J,error:()=>J.error};return J}function vR($){let J;return new Proxy({},{get(Q,W,X){return J??(J=$()),Reflect.get(J,W,X)},set(Q,W,X,Y){return J??(J=$()),Reflect.set(J,W,X,Y)},has(Q,W){return J??(J=$()),Reflect.has(J,W)},deleteProperty(Q,W){return J??(J=$()),Reflect.deleteProperty(J,W)},ownKeys(Q){return J??(J=$()),Reflect.ownKeys(J)},getOwnPropertyDescriptor(Q,W){return J??(J=$()),Reflect.getOwnPropertyDescriptor(J,W)},defineProperty(Q,W,X){return J??(J=$()),Reflect.defineProperty(J,W,X)}})}function F$($){if(typeof $==="bigint")return $.toString()+"n";if(typeof $==="string")return`"${$}"`;return`${$}`}function A7($){return Object.keys($).filter((J)=>{return $[J]._zod.optin==="optional"&&$[J]._zod.optout==="optional"})}var E7={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},C7={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function fR($,J){let Q=$._zod.def,W=Q.checks;if(W&&W.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let Y=g0($._zod.def,{get shape(){let K={};for(let B in J){if(!(B in Q.shape))throw Error(`Unrecognized key: "${B}"`);if(!J[B])continue;K[B]=Q.shape[B]}return W2(this,"shape",K),K},checks:[]});return N1($,Y)}function kR($,J){let Q=$._zod.def,W=Q.checks;if(W&&W.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let Y=g0($._zod.def,{get shape(){let K={...$._zod.def.shape};for(let B in J){if(!(B in Q.shape))throw Error(`Unrecognized key: "${B}"`);if(!J[B])continue;delete K[B]}return W2(this,"shape",K),K},checks:[]});return N1($,Y)}function hR($,J){if(!X2(J))throw Error("Invalid input to extend: expected a plain object");let Q=$._zod.def.checks;if(Q&&Q.length>0){let Y=$._zod.def.shape;for(let K in J)if(Object.getOwnPropertyDescriptor(Y,K)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let X=g0($._zod.def,{get shape(){let Y={...$._zod.def.shape,...J};return W2(this,"shape",Y),Y}});return N1($,X)}function yR($,J){if(!X2(J))throw Error("Invalid input to safeExtend: expected a plain object");let Q=g0($._zod.def,{get shape(){let W={...$._zod.def.shape,...J};return W2(this,"shape",W),W}});return N1($,Q)}function gR($,J){let Q=g0($._zod.def,{get shape(){let W={...$._zod.def.shape,...J._zod.def.shape};return W2(this,"shape",W),W},get catchall(){return J._zod.def.catchall},checks:[]});return N1($,Q)}function xR($,J,Q){let X=J._zod.def.checks;if(X&&X.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let K=g0(J._zod.def,{get shape(){let B=J._zod.def.shape,q={...B};if(Q)for(let U in Q){if(!(U in B))throw Error(`Unrecognized key: "${U}"`);if(!Q[U])continue;q[U]=$?new $({type:"optional",innerType:B[U]}):B[U]}else for(let U in B)q[U]=$?new $({type:"optional",innerType:B[U]}):B[U];return W2(this,"shape",q),q},checks:[]});return N1(J,K)}function uR($,J,Q){let W=g0(J._zod.def,{get shape(){let X=J._zod.def.shape,Y={...X};if(Q)for(let K in Q){if(!(K in Y))throw Error(`Unrecognized key: "${K}"`);if(!Q[K])continue;Y[K]=new $({type:"nonoptional",innerType:X[K]})}else for(let K in X)Y[K]=new $({type:"nonoptional",innerType:X[K]});return W2(this,"shape",Y),Y}});return N1(J,W)}function Y2($,J=0){if($.aborted===!0)return!0;for(let Q=J;Q<$.issues.length;Q++)if($.issues[Q]?.continue!==!0)return!0;return!1}function g1($,J){return J.map((Q)=>{var W;return(W=Q).path??(W.path=[]),Q.path.unshift($),Q})}function f3($){return typeof $==="string"?$:$?.message}function A1($,J,Q){let W={...$,path:$.path??[]};if(!$.message){let X=f3($.inst?._zod.def?.error?.($))??f3(J?.error?.($))??f3(Q.customError?.($))??f3(Q.localeError?.($))??"Invalid input";W.message=X}if(delete W.inst,delete W.continue,!J?.reportInput)delete W.input;return W}function g3($){if($ instanceof Set)return"set";if($ instanceof Map)return"map";if($ instanceof File)return"file";return"unknown"}function x3($){if(Array.isArray($))return"array";if(typeof $==="string")return"string";return"unknown"}function S7($){let J=typeof $;switch(J){case"number":return Number.isNaN($)?"nan":"number";case"object":{if($===null)return"null";if(Array.isArray($))return"array";let Q=$;if(Q&&Object.getPrototypeOf(Q)!==Object.prototype&&"constructor"in Q&&Q.constructor)return Q.constructor.name}}return J}function N4(...$){let[J,Q,W]=$;if(typeof J==="string")return{message:J,code:"custom",input:Q,inst:W};return{...J}}function mR($){return Object.entries($).filter(([J,Q])=>{return Number.isNaN(Number.parseInt(J,10))}).map((J)=>J[1])}function LH($){let J=atob($),Q=new Uint8Array(J.length);for(let W=0;W<J.length;W++)Q[W]=J.charCodeAt(W);return Q}function MH($){let J="";for(let Q=0;Q<$.length;Q++)J+=String.fromCharCode($[Q]);return btoa(J)}function lR($){let J=$.replace(/-/g,"+").replace(/_/g,"/"),Q="=".repeat((4-J.length%4)%4);return LH(J+Q)}function pR($){return MH($).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function cR($){let J=$.replace(/^0x/,"");if(J.length%2!==0)throw Error("Invalid hex string length");let Q=new Uint8Array(J.length/2);for(let W=0;W<J.length;W+=2)Q[W/2]=Number.parseInt(J.slice(W,W+2),16);return Q}function dR($){return Array.from($).map((J)=>J.toString(16).padStart(2,"0")).join("")}class OH{constructor(...$){}}var NH=($,J)=>{$.name="$ZodError",Object.defineProperty($,"_zod",{value:$._zod,enumerable:!1}),Object.defineProperty($,"issues",{value:J,enumerable:!1}),$.message=JSON.stringify(J,M4,2),Object.defineProperty($,"toString",{value:()=>$.message,enumerable:!1})},u3=N("$ZodError",NH),E1=N("$ZodError",NH,{Parent:Error});function F4($,J=(Q)=>Q.message){let Q={},W=[];for(let X of $.issues)if(X.path.length>0)Q[X.path[0]]=Q[X.path[0]]||[],Q[X.path[0]].push(J(X));else W.push(J(X));return{formErrors:W,fieldErrors:Q}}function V4($,J=(Q)=>Q.message){let Q={_errors:[]},W=(X)=>{for(let Y of X.issues)if(Y.code==="invalid_union"&&Y.errors.length)Y.errors.map((K)=>W({issues:K}));else if(Y.code==="invalid_key")W({issues:Y.issues});else if(Y.code==="invalid_element")W({issues:Y.issues});else if(Y.path.length===0)Q._errors.push(J(Y));else{let K=Q,B=0;while(B<Y.path.length){let q=Y.path[B];if(B!==Y.path.length-1)K[q]=K[q]||{_errors:[]};else K[q]=K[q]||{_errors:[]},K[q]._errors.push(J(Y));K=K[q],B++}}};return W($),Q}function V$($,J=(Q)=>Q.message){let Q={errors:[]},W=(X,Y=[])=>{var K,B;for(let q of X.issues)if(q.code==="invalid_union"&&q.errors.length)q.errors.map((U)=>W({issues:U},q.path));else if(q.code==="invalid_key")W({issues:q.issues},q.path);else if(q.code==="invalid_element")W({issues:q.issues},q.path);else{let U=[...Y,...q.path];if(U.length===0){Q.errors.push(J(q));continue}let G=Q,H=0;while(H<U.length){let L=U[H],Z=H===U.length-1;if(typeof L==="string")G.properties??(G.properties={}),(K=G.properties)[L]??(K[L]={errors:[]}),G=G.properties[L];else G.items??(G.items=[]),(B=G.items)[L]??(B[L]={errors:[]}),G=G.items[L];if(Z)G.errors.push(J(q));H++}}};return W($),Q}function FH($){let J=[],Q=$.map((W)=>typeof W==="object"?W.key:W);for(let W of Q)if(typeof W==="number")J.push(`[${W}]`);else if(typeof W==="symbol")J.push(`[${JSON.stringify(String(W))}]`);else if(/[^\w$]/.test(W))J.push(`[${JSON.stringify(W)}]`);else{if(J.length)J.push(".");J.push(W)}return J.join("")}function _$($){let J=[],Q=[...$.issues].sort((W,X)=>(W.path??[]).length-(X.path??[]).length);for(let W of Q)if(J.push(`✖ ${W.message}`),W.path?.length)J.push(` → at ${FH(W.path)}`);return J.join(`
63
- `)}var _4=($)=>(J,Q,W,X)=>{let Y=W?Object.assign(W,{async:!1}):{async:!1},K=J._zod.run({value:Q,issues:[]},Y);if(K instanceof Promise)throw new D0;if(K.issues.length){let B=new(X?.Err??$)(K.issues.map((q)=>A1(q,Y,Y1())));throw N$(B,X?.callee),B}return K.value},D$=_4(E1),D4=($)=>async(J,Q,W,X)=>{let Y=W?Object.assign(W,{async:!0}):{async:!0},K=J._zod.run({value:Q,issues:[]},Y);if(K instanceof Promise)K=await K;if(K.issues.length){let B=new(X?.Err??$)(K.issues.map((q)=>A1(q,Y,Y1())));throw N$(B,X?.callee),B}return K.value},z$=D4(E1),z4=($)=>(J,Q,W)=>{let X=W?{...W,async:!1}:{async:!1},Y=J._zod.run({value:Q,issues:[]},X);if(Y instanceof Promise)throw new D0;return Y.issues.length?{success:!1,error:new($??u3)(Y.issues.map((K)=>A1(K,X,Y1())))}:{success:!0,data:Y.value}},T7=z4(E1),I4=($)=>async(J,Q,W)=>{let X=W?Object.assign(W,{async:!0}):{async:!0},Y=J._zod.run({value:Q,issues:[]},X);if(Y instanceof Promise)Y=await Y;return Y.issues.length?{success:!1,error:new $(Y.issues.map((K)=>A1(K,X,Y1())))}:{success:!0,data:Y.value}},w7=I4(E1),I$=($)=>(J,Q,W)=>{let X=W?Object.assign(W,{direction:"backward"}):{direction:"backward"};return _4($)(J,Q,X)},iR=I$(E1),j$=($)=>(J,Q,W)=>{return _4($)(J,Q,W)},oR=j$(E1),R$=($)=>async(J,Q,W)=>{let X=W?Object.assign(W,{direction:"backward"}):{direction:"backward"};return D4($)(J,Q,X)},nR=R$(E1),b$=($)=>async(J,Q,W)=>{return D4($)(J,Q,W)},sR=b$(E1),P$=($)=>(J,Q,W)=>{let X=W?Object.assign(W,{direction:"backward"}):{direction:"backward"};return z4($)(J,Q,X)},aR=P$(E1),A$=($)=>(J,Q,W)=>{return z4($)(J,Q,W)},tR=A$(E1),E$=($)=>async(J,Q,W)=>{let X=W?Object.assign(W,{direction:"backward"}):{direction:"backward"};return I4($)(J,Q,X)},eR=E$(E1),C$=($)=>async(J,Q,W)=>{return I4($)(J,Q,W)},$b=C$(E1);var x1={};U2(x1,{xid:()=>h7,uuid7:()=>Xb,uuid6:()=>Wb,uuid4:()=>Qb,uuid:()=>f2,uppercase:()=>KW,unicodeEmail:()=>VH,undefined:()=>XW,ulid:()=>k7,time:()=>a7,string:()=>e7,sha512_hex:()=>bb,sha512_base64url:()=>Ab,sha512_base64:()=>Pb,sha384_hex:()=>Ib,sha384_base64url:()=>Rb,sha384_base64:()=>jb,sha256_hex:()=>_b,sha256_base64url:()=>zb,sha256_base64:()=>Db,sha1_hex:()=>Nb,sha1_base64url:()=>Vb,sha1_base64:()=>Fb,rfc5322Email:()=>Kb,number:()=>m3,null:()=>WW,nanoid:()=>g7,md5_hex:()=>Lb,md5_base64url:()=>Ob,md5_base64:()=>Mb,mac:()=>d7,lowercase:()=>YW,ksuid:()=>y7,ipv6:()=>c7,ipv4:()=>p7,integer:()=>JW,idnEmail:()=>Bb,html5Email:()=>Yb,hostname:()=>Gb,hex:()=>Zb,guid:()=>u7,extendedDuration:()=>Jb,emoji:()=>l7,email:()=>m7,e164:()=>n7,duration:()=>x7,domain:()=>Hb,datetime:()=>t7,date:()=>s7,cuid2:()=>f7,cuid:()=>v7,cidrv6:()=>i7,cidrv4:()=>r7,browserEmail:()=>qb,boolean:()=>QW,bigint:()=>$W,base64url:()=>S$,base64:()=>o7});var v7=/^[cC][^\s-]{8,}$/,f7=/^[0-9a-z]+$/,k7=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,h7=/^[0-9a-vA-V]{20}$/,y7=/^[A-Za-z0-9]{27}$/,g7=/^[a-zA-Z0-9_-]{21}$/,x7=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Jb=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,u7=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,f2=($)=>{if(!$)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${$}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)},Qb=f2(4),Wb=f2(6),Xb=f2(7),m7=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Yb=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Kb=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,VH=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Bb=VH,qb=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Ub="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function l7(){return new RegExp(Ub,"u")}var p7=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,c7=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,d7=($)=>{let J=o1($??":");return new RegExp(`^(?:[0-9A-F]{2}${J}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${J}){5}[0-9a-f]{2}$`)},r7=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,i7=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,o7=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,S$=/^[A-Za-z0-9_-]*$/,Gb=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Hb=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,n7=/^\+[1-9]\d{6,14}$/,_H="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",s7=new RegExp(`^${_H}$`);function DH($){return typeof $.precision==="number"?$.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":$.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${$.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function a7($){return new RegExp(`^${DH($)}$`)}function t7($){let J=DH({precision:$.precision}),Q=["Z"];if($.local)Q.push("");if($.offset)Q.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let W=`${J}(?:${Q.join("|")})`;return new RegExp(`^${_H}T(?:${W})$`)}var e7=($)=>{let J=$?`[\\s\\S]{${$?.minimum??0},${$?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${J}$`)},$W=/^-?\d+n?$/,JW=/^-?\d+$/,m3=/^-?\d+(?:\.\d+)?$/,QW=/^(?:true|false)$/i,WW=/^null$/i;var XW=/^undefined$/i;var YW=/^[^A-Z]*$/,KW=/^[^a-z]*$/,Zb=/^[0-9a-fA-F]*$/;function l3($,J){return new RegExp(`^[A-Za-z0-9+/]{${$}}${J}$`)}function p3($){return new RegExp(`^[A-Za-z0-9_-]{${$}}$`)}var Lb=/^[0-9a-fA-F]{32}$/,Mb=l3(22,"=="),Ob=p3(22),Nb=/^[0-9a-fA-F]{40}$/,Fb=l3(27,"="),Vb=p3(27),_b=/^[0-9a-fA-F]{64}$/,Db=l3(43,"="),zb=p3(43),Ib=/^[0-9a-fA-F]{96}$/,jb=l3(64,""),Rb=p3(64),bb=/^[0-9a-fA-F]{128}$/,Pb=l3(86,"=="),Ab=p3(86);var n=N("$ZodCheck",($,J)=>{var Q;$._zod??($._zod={}),$._zod.def=J,(Q=$._zod).onattach??(Q.onattach=[])}),IH={number:"number",bigint:"bigint",object:"date"},T$=N("$ZodCheckLessThan",($,J)=>{n.init($,J);let Q=IH[typeof J.value];$._zod.onattach.push((W)=>{let X=W._zod.bag,Y=(J.inclusive?X.maximum:X.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(J.value<Y)if(J.inclusive)X.maximum=J.value;else X.exclusiveMaximum=J.value}),$._zod.check=(W)=>{if(J.inclusive?W.value<=J.value:W.value<J.value)return;W.issues.push({origin:Q,code:"too_big",maximum:typeof J.value==="object"?J.value.getTime():J.value,input:W.value,inclusive:J.inclusive,inst:$,continue:!J.abort})}}),w$=N("$ZodCheckGreaterThan",($,J)=>{n.init($,J);let Q=IH[typeof J.value];$._zod.onattach.push((W)=>{let X=W._zod.bag,Y=(J.inclusive?X.minimum:X.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(J.value>Y)if(J.inclusive)X.minimum=J.value;else X.exclusiveMinimum=J.value}),$._zod.check=(W)=>{if(J.inclusive?W.value>=J.value:W.value>J.value)return;W.issues.push({origin:Q,code:"too_small",minimum:typeof J.value==="object"?J.value.getTime():J.value,input:W.value,inclusive:J.inclusive,inst:$,continue:!J.abort})}}),BW=N("$ZodCheckMultipleOf",($,J)=>{n.init($,J),$._zod.onattach.push((Q)=>{var W;(W=Q._zod.bag).multipleOf??(W.multipleOf=J.value)}),$._zod.check=(Q)=>{if(typeof Q.value!==typeof J.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof Q.value==="bigint"?Q.value%J.value===BigInt(0):I7(Q.value,J.value)===0)return;Q.issues.push({origin:typeof Q.value,code:"not_multiple_of",divisor:J.value,input:Q.value,inst:$,continue:!J.abort})}}),qW=N("$ZodCheckNumberFormat",($,J)=>{n.init($,J),J.format=J.format||"float64";let Q=J.format?.includes("int"),W=Q?"int":"number",[X,Y]=E7[J.format];$._zod.onattach.push((K)=>{let B=K._zod.bag;if(B.format=J.format,B.minimum=X,B.maximum=Y,Q)B.pattern=JW}),$._zod.check=(K)=>{let B=K.value;if(Q){if(!Number.isInteger(B)){K.issues.push({expected:W,format:J.format,code:"invalid_type",continue:!1,input:B,inst:$});return}if(!Number.isSafeInteger(B)){if(B>0)K.issues.push({input:B,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:$,origin:W,inclusive:!0,continue:!J.abort});else K.issues.push({input:B,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:$,origin:W,inclusive:!0,continue:!J.abort});return}}if(B<X)K.issues.push({origin:"number",input:B,code:"too_small",minimum:X,inclusive:!0,inst:$,continue:!J.abort});if(B>Y)K.issues.push({origin:"number",input:B,code:"too_big",maximum:Y,inclusive:!0,inst:$,continue:!J.abort})}}),UW=N("$ZodCheckBigIntFormat",($,J)=>{n.init($,J);let[Q,W]=C7[J.format];$._zod.onattach.push((X)=>{let Y=X._zod.bag;Y.format=J.format,Y.minimum=Q,Y.maximum=W}),$._zod.check=(X)=>{let Y=X.value;if(Y<Q)X.issues.push({origin:"bigint",input:Y,code:"too_small",minimum:Q,inclusive:!0,inst:$,continue:!J.abort});if(Y>W)X.issues.push({origin:"bigint",input:Y,code:"too_big",maximum:W,inclusive:!0,inst:$,continue:!J.abort})}}),GW=N("$ZodCheckMaxSize",($,J)=>{var Q;n.init($,J),(Q=$._zod.def).when??(Q.when=(W)=>{let X=W.value;return!Q2(X)&&X.size!==void 0}),$._zod.onattach.push((W)=>{let X=W._zod.bag.maximum??Number.POSITIVE_INFINITY;if(J.maximum<X)W._zod.bag.maximum=J.maximum}),$._zod.check=(W)=>{let X=W.value;if(X.size<=J.maximum)return;W.issues.push({origin:g3(X),code:"too_big",maximum:J.maximum,inclusive:!0,input:X,inst:$,continue:!J.abort})}}),HW=N("$ZodCheckMinSize",($,J)=>{var Q;n.init($,J),(Q=$._zod.def).when??(Q.when=(W)=>{let X=W.value;return!Q2(X)&&X.size!==void 0}),$._zod.onattach.push((W)=>{let X=W._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(J.minimum>X)W._zod.bag.minimum=J.minimum}),$._zod.check=(W)=>{let X=W.value;if(X.size>=J.minimum)return;W.issues.push({origin:g3(X),code:"too_small",minimum:J.minimum,inclusive:!0,input:X,inst:$,continue:!J.abort})}}),ZW=N("$ZodCheckSizeEquals",($,J)=>{var Q;n.init($,J),(Q=$._zod.def).when??(Q.when=(W)=>{let X=W.value;return!Q2(X)&&X.size!==void 0}),$._zod.onattach.push((W)=>{let X=W._zod.bag;X.minimum=J.size,X.maximum=J.size,X.size=J.size}),$._zod.check=(W)=>{let X=W.value,Y=X.size;if(Y===J.size)return;let K=Y>J.size;W.issues.push({origin:g3(X),...K?{code:"too_big",maximum:J.size}:{code:"too_small",minimum:J.size},inclusive:!0,exact:!0,input:W.value,inst:$,continue:!J.abort})}}),LW=N("$ZodCheckMaxLength",($,J)=>{var Q;n.init($,J),(Q=$._zod.def).when??(Q.when=(W)=>{let X=W.value;return!Q2(X)&&X.length!==void 0}),$._zod.onattach.push((W)=>{let X=W._zod.bag.maximum??Number.POSITIVE_INFINITY;if(J.maximum<X)W._zod.bag.maximum=J.maximum}),$._zod.check=(W)=>{let X=W.value;if(X.length<=J.maximum)return;let K=x3(X);W.issues.push({origin:K,code:"too_big",maximum:J.maximum,inclusive:!0,input:X,inst:$,continue:!J.abort})}}),MW=N("$ZodCheckMinLength",($,J)=>{var Q;n.init($,J),(Q=$._zod.def).when??(Q.when=(W)=>{let X=W.value;return!Q2(X)&&X.length!==void 0}),$._zod.onattach.push((W)=>{let X=W._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(J.minimum>X)W._zod.bag.minimum=J.minimum}),$._zod.check=(W)=>{let X=W.value;if(X.length>=J.minimum)return;let K=x3(X);W.issues.push({origin:K,code:"too_small",minimum:J.minimum,inclusive:!0,input:X,inst:$,continue:!J.abort})}}),OW=N("$ZodCheckLengthEquals",($,J)=>{var Q;n.init($,J),(Q=$._zod.def).when??(Q.when=(W)=>{let X=W.value;return!Q2(X)&&X.length!==void 0}),$._zod.onattach.push((W)=>{let X=W._zod.bag;X.minimum=J.length,X.maximum=J.length,X.length=J.length}),$._zod.check=(W)=>{let X=W.value,Y=X.length;if(Y===J.length)return;let K=x3(X),B=Y>J.length;W.issues.push({origin:K,...B?{code:"too_big",maximum:J.length}:{code:"too_small",minimum:J.length},inclusive:!0,exact:!0,input:W.value,inst:$,continue:!J.abort})}}),j4=N("$ZodCheckStringFormat",($,J)=>{var Q,W;if(n.init($,J),$._zod.onattach.push((X)=>{let Y=X._zod.bag;if(Y.format=J.format,J.pattern)Y.patterns??(Y.patterns=new Set),Y.patterns.add(J.pattern)}),J.pattern)(Q=$._zod).check??(Q.check=(X)=>{if(J.pattern.lastIndex=0,J.pattern.test(X.value))return;X.issues.push({origin:"string",code:"invalid_format",format:J.format,input:X.value,...J.pattern?{pattern:J.pattern.toString()}:{},inst:$,continue:!J.abort})});else(W=$._zod).check??(W.check=()=>{})}),NW=N("$ZodCheckRegex",($,J)=>{j4.init($,J),$._zod.check=(Q)=>{if(J.pattern.lastIndex=0,J.pattern.test(Q.value))return;Q.issues.push({origin:"string",code:"invalid_format",format:"regex",input:Q.value,pattern:J.pattern.toString(),inst:$,continue:!J.abort})}}),FW=N("$ZodCheckLowerCase",($,J)=>{J.pattern??(J.pattern=YW),j4.init($,J)}),VW=N("$ZodCheckUpperCase",($,J)=>{J.pattern??(J.pattern=KW),j4.init($,J)}),_W=N("$ZodCheckIncludes",($,J)=>{n.init($,J);let Q=o1(J.includes),W=new RegExp(typeof J.position==="number"?`^.{${J.position}}${Q}`:Q);J.pattern=W,$._zod.onattach.push((X)=>{let Y=X._zod.bag;Y.patterns??(Y.patterns=new Set),Y.patterns.add(W)}),$._zod.check=(X)=>{if(X.value.includes(J.includes,J.position))return;X.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:J.includes,input:X.value,inst:$,continue:!J.abort})}}),DW=N("$ZodCheckStartsWith",($,J)=>{n.init($,J);let Q=new RegExp(`^${o1(J.prefix)}.*`);J.pattern??(J.pattern=Q),$._zod.onattach.push((W)=>{let X=W._zod.bag;X.patterns??(X.patterns=new Set),X.patterns.add(Q)}),$._zod.check=(W)=>{if(W.value.startsWith(J.prefix))return;W.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:J.prefix,input:W.value,inst:$,continue:!J.abort})}}),zW=N("$ZodCheckEndsWith",($,J)=>{n.init($,J);let Q=new RegExp(`.*${o1(J.suffix)}$`);J.pattern??(J.pattern=Q),$._zod.onattach.push((W)=>{let X=W._zod.bag;X.patterns??(X.patterns=new Set),X.patterns.add(Q)}),$._zod.check=(W)=>{if(W.value.endsWith(J.suffix))return;W.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:J.suffix,input:W.value,inst:$,continue:!J.abort})}});function zH($,J,Q){if($.issues.length)J.issues.push(...g1(Q,$.issues))}var IW=N("$ZodCheckProperty",($,J)=>{n.init($,J),$._zod.check=(Q)=>{let W=J.schema._zod.run({value:Q.value[J.property],issues:[]},{});if(W instanceof Promise)return W.then((X)=>zH(X,Q,J.property));zH(W,Q,J.property);return}}),jW=N("$ZodCheckMimeType",($,J)=>{n.init($,J);let Q=new Set(J.mime);$._zod.onattach.push((W)=>{W._zod.bag.mime=J.mime}),$._zod.check=(W)=>{if(Q.has(W.value.type))return;W.issues.push({code:"invalid_value",values:J.mime,input:W.value.type,inst:$,continue:!J.abort})}}),RW=N("$ZodCheckOverwrite",($,J)=>{n.init($,J),$._zod.check=(Q)=>{Q.value=J.tx(Q.value)}});class v${constructor($=[]){if(this.content=[],this.indent=0,this)this.args=$}indented($){this.indent+=1,$(this),this.indent-=1}write($){if(typeof $==="function"){$(this,{execution:"sync"}),$(this,{execution:"async"});return}let Q=$.split(`
64
- `).filter((Y)=>Y),W=Math.min(...Q.map((Y)=>Y.length-Y.trimStart().length)),X=Q.map((Y)=>Y.slice(W)).map((Y)=>" ".repeat(this.indent*2)+Y);for(let Y of X)this.content.push(Y)}compile(){let $=Function,J=this?.args,W=[...(this?.content??[""]).map((X)=>` ${X}`)];return new $(...J,W.join(`
65
- `))}}var bW={major:4,minor:3,patch:5};var f=N("$ZodType",($,J)=>{var Q;$??($={}),$._zod.def=J,$._zod.bag=$._zod.bag||{},$._zod.version=bW;let W=[...$._zod.def.checks??[]];if($._zod.traits.has("$ZodCheck"))W.unshift($);for(let X of W)for(let Y of X._zod.onattach)Y($);if(W.length===0)(Q=$._zod).deferred??(Q.deferred=[]),$._zod.deferred?.push(()=>{$._zod.run=$._zod.parse});else{let X=(K,B,q)=>{let U=Y2(K),G;for(let H of B){if(H._zod.def.when){if(!H._zod.def.when(K))continue}else if(U)continue;let L=K.issues.length,Z=H._zod.check(K);if(Z instanceof Promise&&q?.async===!1)throw new D0;if(G||Z instanceof Promise)G=(G??Promise.resolve()).then(async()=>{if(await Z,K.issues.length===L)return;if(!U)U=Y2(K,L)});else{if(K.issues.length===L)continue;if(!U)U=Y2(K,L)}}if(G)return G.then(()=>{return K});return K},Y=(K,B,q)=>{if(Y2(K))return K.aborted=!0,K;let U=X(B,W,q);if(U instanceof Promise){if(q.async===!1)throw new D0;return U.then((G)=>$._zod.parse(G,q))}return $._zod.parse(U,q)};$._zod.run=(K,B)=>{if(B.skipChecks)return $._zod.parse(K,B);if(B.direction==="backward"){let U=$._zod.parse({value:K.value,issues:[]},{...B,skipChecks:!0});if(U instanceof Promise)return U.then((G)=>{return Y(G,K,B)});return Y(U,K,B)}let q=$._zod.parse(K,B);if(q instanceof Promise){if(B.async===!1)throw new D0;return q.then((U)=>X(U,W,B))}return X(q,W,B)}}u($,"~standard",()=>({validate:(X)=>{try{let Y=T7($,X);return Y.success?{value:Y.data}:{issues:Y.error?.issues}}catch(Y){return w7($,X).then((K)=>K.success?{value:K.data}:{issues:K.error?.issues})}},vendor:"zod",version:1}))}),k2=N("$ZodString",($,J)=>{f.init($,J),$._zod.pattern=[...$?._zod.bag?.patterns??[]].pop()??e7($._zod.bag),$._zod.parse=(Q,W)=>{if(J.coerce)try{Q.value=String(Q.value)}catch(X){}if(typeof Q.value==="string")return Q;return Q.issues.push({expected:"string",code:"invalid_type",input:Q.value,inst:$}),Q}}),i=N("$ZodStringFormat",($,J)=>{j4.init($,J),k2.init($,J)}),AW=N("$ZodGUID",($,J)=>{J.pattern??(J.pattern=u7),i.init($,J)}),EW=N("$ZodUUID",($,J)=>{if(J.version){let W={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[J.version];if(W===void 0)throw Error(`Invalid UUID version: "${J.version}"`);J.pattern??(J.pattern=f2(W))}else J.pattern??(J.pattern=f2());i.init($,J)}),CW=N("$ZodEmail",($,J)=>{J.pattern??(J.pattern=m7),i.init($,J)}),SW=N("$ZodURL",($,J)=>{i.init($,J),$._zod.check=(Q)=>{try{let W=Q.value.trim(),X=new URL(W);if(J.hostname){if(J.hostname.lastIndex=0,!J.hostname.test(X.hostname))Q.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:J.hostname.source,input:Q.value,inst:$,continue:!J.abort})}if(J.protocol){if(J.protocol.lastIndex=0,!J.protocol.test(X.protocol.endsWith(":")?X.protocol.slice(0,-1):X.protocol))Q.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:J.protocol.source,input:Q.value,inst:$,continue:!J.abort})}if(J.normalize)Q.value=X.href;else Q.value=W;return}catch(W){Q.issues.push({code:"invalid_format",format:"url",input:Q.value,inst:$,continue:!J.abort})}}}),TW=N("$ZodEmoji",($,J)=>{J.pattern??(J.pattern=l7()),i.init($,J)}),wW=N("$ZodNanoID",($,J)=>{J.pattern??(J.pattern=g7),i.init($,J)}),vW=N("$ZodCUID",($,J)=>{J.pattern??(J.pattern=v7),i.init($,J)}),fW=N("$ZodCUID2",($,J)=>{J.pattern??(J.pattern=f7),i.init($,J)}),kW=N("$ZodULID",($,J)=>{J.pattern??(J.pattern=k7),i.init($,J)}),hW=N("$ZodXID",($,J)=>{J.pattern??(J.pattern=h7),i.init($,J)}),yW=N("$ZodKSUID",($,J)=>{J.pattern??(J.pattern=y7),i.init($,J)}),gW=N("$ZodISODateTime",($,J)=>{J.pattern??(J.pattern=t7(J)),i.init($,J)}),xW=N("$ZodISODate",($,J)=>{J.pattern??(J.pattern=s7),i.init($,J)}),uW=N("$ZodISOTime",($,J)=>{J.pattern??(J.pattern=a7(J)),i.init($,J)}),mW=N("$ZodISODuration",($,J)=>{J.pattern??(J.pattern=x7),i.init($,J)}),lW=N("$ZodIPv4",($,J)=>{J.pattern??(J.pattern=p7),i.init($,J),$._zod.bag.format="ipv4"}),pW=N("$ZodIPv6",($,J)=>{J.pattern??(J.pattern=c7),i.init($,J),$._zod.bag.format="ipv6",$._zod.check=(Q)=>{try{new URL(`http://[${Q.value}]`)}catch{Q.issues.push({code:"invalid_format",format:"ipv6",input:Q.value,inst:$,continue:!J.abort})}}}),cW=N("$ZodMAC",($,J)=>{J.pattern??(J.pattern=d7(J.delimiter)),i.init($,J),$._zod.bag.format="mac"}),dW=N("$ZodCIDRv4",($,J)=>{J.pattern??(J.pattern=r7),i.init($,J)}),rW=N("$ZodCIDRv6",($,J)=>{J.pattern??(J.pattern=i7),i.init($,J),$._zod.check=(Q)=>{let W=Q.value.split("/");try{if(W.length!==2)throw Error();let[X,Y]=W;if(!Y)throw Error();let K=Number(Y);if(`${K}`!==Y)throw Error();if(K<0||K>128)throw Error();new URL(`http://[${X}]`)}catch{Q.issues.push({code:"invalid_format",format:"cidrv6",input:Q.value,inst:$,continue:!J.abort})}}});function iW($){if($==="")return!0;if($.length%4!==0)return!1;try{return atob($),!0}catch{return!1}}var oW=N("$ZodBase64",($,J)=>{J.pattern??(J.pattern=o7),i.init($,J),$._zod.bag.contentEncoding="base64",$._zod.check=(Q)=>{if(iW(Q.value))return;Q.issues.push({code:"invalid_format",format:"base64",input:Q.value,inst:$,continue:!J.abort})}});function kH($){if(!S$.test($))return!1;let J=$.replace(/[-_]/g,(W)=>W==="-"?"+":"/"),Q=J.padEnd(Math.ceil(J.length/4)*4,"=");return iW(Q)}var nW=N("$ZodBase64URL",($,J)=>{J.pattern??(J.pattern=S$),i.init($,J),$._zod.bag.contentEncoding="base64url",$._zod.check=(Q)=>{if(kH(Q.value))return;Q.issues.push({code:"invalid_format",format:"base64url",input:Q.value,inst:$,continue:!J.abort})}}),sW=N("$ZodE164",($,J)=>{J.pattern??(J.pattern=n7),i.init($,J)});function hH($,J=null){try{let Q=$.split(".");if(Q.length!==3)return!1;let[W]=Q;if(!W)return!1;let X=JSON.parse(atob(W));if("typ"in X&&X?.typ!=="JWT")return!1;if(!X.alg)return!1;if(J&&(!("alg"in X)||X.alg!==J))return!1;return!0}catch{return!1}}var aW=N("$ZodJWT",($,J)=>{i.init($,J),$._zod.check=(Q)=>{if(hH(Q.value,J.alg))return;Q.issues.push({code:"invalid_format",format:"jwt",input:Q.value,inst:$,continue:!J.abort})}}),tW=N("$ZodCustomStringFormat",($,J)=>{i.init($,J),$._zod.check=(Q)=>{if(J.fn(Q.value))return;Q.issues.push({code:"invalid_format",format:J.format,input:Q.value,inst:$,continue:!J.abort})}}),x$=N("$ZodNumber",($,J)=>{f.init($,J),$._zod.pattern=$._zod.bag.pattern??m3,$._zod.parse=(Q,W)=>{if(J.coerce)try{Q.value=Number(Q.value)}catch(K){}let X=Q.value;if(typeof X==="number"&&!Number.isNaN(X)&&Number.isFinite(X))return Q;let Y=typeof X==="number"?Number.isNaN(X)?"NaN":!Number.isFinite(X)?"Infinity":void 0:void 0;return Q.issues.push({expected:"number",code:"invalid_type",input:X,inst:$,...Y?{received:Y}:{}}),Q}}),eW=N("$ZodNumberFormat",($,J)=>{qW.init($,J),x$.init($,J)}),c3=N("$ZodBoolean",($,J)=>{f.init($,J),$._zod.pattern=QW,$._zod.parse=(Q,W)=>{if(J.coerce)try{Q.value=Boolean(Q.value)}catch(Y){}let X=Q.value;if(typeof X==="boolean")return Q;return Q.issues.push({expected:"boolean",code:"invalid_type",input:X,inst:$}),Q}}),u$=N("$ZodBigInt",($,J)=>{f.init($,J),$._zod.pattern=$W,$._zod.parse=(Q,W)=>{if(J.coerce)try{Q.value=BigInt(Q.value)}catch(X){}if(typeof Q.value==="bigint")return Q;return Q.issues.push({expected:"bigint",code:"invalid_type",input:Q.value,inst:$}),Q}}),$X=N("$ZodBigIntFormat",($,J)=>{UW.init($,J),u$.init($,J)}),JX=N("$ZodSymbol",($,J)=>{f.init($,J),$._zod.parse=(Q,W)=>{let X=Q.value;if(typeof X==="symbol")return Q;return Q.issues.push({expected:"symbol",code:"invalid_type",input:X,inst:$}),Q}}),QX=N("$ZodUndefined",($,J)=>{f.init($,J),$._zod.pattern=XW,$._zod.values=new Set([void 0]),$._zod.optin="optional",$._zod.optout="optional",$._zod.parse=(Q,W)=>{let X=Q.value;if(typeof X>"u")return Q;return Q.issues.push({expected:"undefined",code:"invalid_type",input:X,inst:$}),Q}}),WX=N("$ZodNull",($,J)=>{f.init($,J),$._zod.pattern=WW,$._zod.values=new Set([null]),$._zod.parse=(Q,W)=>{let X=Q.value;if(X===null)return Q;return Q.issues.push({expected:"null",code:"invalid_type",input:X,inst:$}),Q}}),XX=N("$ZodAny",($,J)=>{f.init($,J),$._zod.parse=(Q)=>Q}),YX=N("$ZodUnknown",($,J)=>{f.init($,J),$._zod.parse=(Q)=>Q}),KX=N("$ZodNever",($,J)=>{f.init($,J),$._zod.parse=(Q,W)=>{return Q.issues.push({expected:"never",code:"invalid_type",input:Q.value,inst:$}),Q}}),BX=N("$ZodVoid",($,J)=>{f.init($,J),$._zod.parse=(Q,W)=>{let X=Q.value;if(typeof X>"u")return Q;return Q.issues.push({expected:"void",code:"invalid_type",input:X,inst:$}),Q}}),qX=N("$ZodDate",($,J)=>{f.init($,J),$._zod.parse=(Q,W)=>{if(J.coerce)try{Q.value=new Date(Q.value)}catch(B){}let X=Q.value,Y=X instanceof Date;if(Y&&!Number.isNaN(X.getTime()))return Q;return Q.issues.push({expected:"date",code:"invalid_type",input:X,...Y?{received:"Invalid Date"}:{},inst:$}),Q}});function RH($,J,Q){if($.issues.length)J.issues.push(...g1(Q,$.issues));J.value[Q]=$.value}var UX=N("$ZodArray",($,J)=>{f.init($,J),$._zod.parse=(Q,W)=>{let X=Q.value;if(!Array.isArray(X))return Q.issues.push({expected:"array",code:"invalid_type",input:X,inst:$}),Q;Q.value=Array(X.length);let Y=[];for(let K=0;K<X.length;K++){let B=X[K],q=J.element._zod.run({value:B,issues:[]},W);if(q instanceof Promise)Y.push(q.then((U)=>RH(U,Q,K)));else RH(q,Q,K)}if(Y.length)return Promise.all(Y).then(()=>Q);return Q}});function g$($,J,Q,W,X){if($.issues.length){if(X&&!(Q in W))return;J.issues.push(...g1(Q,$.issues))}if($.value===void 0){if(Q in W)J.value[Q]=void 0}else J.value[Q]=$.value}function yH($){let J=Object.keys($.shape);for(let W of J)if(!$.shape?.[W]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${W}": expected a Zod schema`);let Q=A7($.shape);return{...$,keys:J,keySet:new Set(J),numKeys:J.length,optionalKeys:new Set(Q)}}function gH($,J,Q,W,X,Y){let K=[],B=X.keySet,q=X.catchall._zod,U=q.def.type,G=q.optout==="optional";for(let H in J){if(B.has(H))continue;if(U==="never"){K.push(H);continue}let L=q.run({value:J[H],issues:[]},W);if(L instanceof Promise)$.push(L.then((Z)=>g$(Z,Q,H,J,G)));else g$(L,Q,H,J,G)}if(K.length)Q.issues.push({code:"unrecognized_keys",keys:K,input:J,inst:Y});if(!$.length)return Q;return Promise.all($).then(()=>{return Q})}var xH=N("$ZodObject",($,J)=>{if(f.init($,J),!Object.getOwnPropertyDescriptor(J,"shape")?.get){let B=J.shape;Object.defineProperty(J,"shape",{get:()=>{let q={...B};return Object.defineProperty(J,"shape",{value:q}),q}})}let W=O4(()=>yH(J));u($._zod,"propValues",()=>{let B=J.shape,q={};for(let U in B){let G=B[U]._zod;if(G.values){q[U]??(q[U]=new Set);for(let H of G.values)q[U].add(H)}}return q});let X=v2,Y=J.catchall,K;$._zod.parse=(B,q)=>{K??(K=W.value);let U=B.value;if(!X(U))return B.issues.push({expected:"object",code:"invalid_type",input:U,inst:$}),B;B.value={};let G=[],H=K.shape;for(let L of K.keys){let Z=H[L],M=Z._zod.optout==="optional",O=Z._zod.run({value:U[L],issues:[]},q);if(O instanceof Promise)G.push(O.then((V)=>g$(V,B,L,U,M)));else g$(O,B,L,U,M)}if(!Y)return G.length?Promise.all(G).then(()=>B):B;return gH(G,U,B,q,W.value,$)}}),GX=N("$ZodObjectJIT",($,J)=>{xH.init($,J);let Q=$._zod.parse,W=O4(()=>yH(J)),X=(L)=>{let Z=new v$(["shape","payload","ctx"]),M=W.value,O=(I)=>{let A=O$(I);return`shape[${A}]._zod.run({ value: input[${A}], issues: [] }, ctx)`};Z.write("const input = payload.value;");let V=Object.create(null),F=0;for(let I of M.keys)V[I]=`key_${F++}`;Z.write("const newResult = {};");for(let I of M.keys){let A=V[I],E=O$(I),R=L[I]?._zod?.optout==="optional";if(Z.write(`const ${A} = ${O(I)};`),R)Z.write(`
66
- if (${A}.issues.length) {
67
- if (${E} in input) {
68
- payload.issues = payload.issues.concat(${A}.issues.map(iss => ({
55
+ `;if(n.includes("%")||/\\(?![\\nrt])/.test(n))return;return n.replaceAll("\\n",`
56
+ `).replaceAll("\\r","\r").replaceAll("\\t","\t").replaceAll("\\\\","\\")}function mr(e){let t=Ao(e[1])==="--"?2:1;if(e.length<=t)return Qt;let n=e.slice(t);if(!n.every(Js))return Pn;return{kind:"literal",source:n.map(N).join(" ")}}function eS(e){let t=Ao(e[1])==="--"?2:1,n=e[t],r=Ao(n);if(n===void 0||e.length<=t+1||r==="-"||r===""||r==="-l"||r==="-p")return Qt;if(!Js(n))return Pn;return{kind:"literal",source:r}}function Ys(e,t){let n=iO(e);if(n===-1)return Qt;let r=sO(t);if(!r)return Qt;let o=[],i=r.command?.length??0;for(let s of r.references){let a=cO(s,e,n,r.ifs);if(!a)return Pn;if(i+=a.reduce((c,l)=>c+l.length+3,0),o.length+a.length>nO||i>rO)return Pn;o.push(...a)}if(r.command==="eval")return{kind:"literal",source:o.join(" ")};if(o.length===0||/\s/.test(o[0]??""))return{kind:"literal",source:""};return{kind:"literal",source:[r.command,r.command&&r.optionTerminator?"--":null,...o.map(uO)].filter((s)=>s!==null).join(" ")}}function tS(e,t,n,r){if(!yt(e.map(N)).readsStdinAsCommands)return Qt;let o=t.filter((i)=>(i.fd===void 0||i.fd===0)&&eO.has(i.operator)).at(-1);if(o){if(o.operator==="<<"||o.operator==="<<-")return Qt;if(o.operator!=="<<<"||o.target?.provenance!=="literal")return Pn;return{kind:"literal",source:o.target.text}}if(!n)return Qt;return r===void 0?Pn:{kind:"literal",source:r}}function bt(e){let t=yt(e.map(N)).scriptIndex;if(t===null)return Qt;let n=e[t],r=Ao(n);return Zi(n,r)?{kind:"literal",source:r}:Pn}var oO=new Set(["curl","wget","fetch","aria2c","http","https","xh","xhs","nc","ncat","netcat"]);function Hu(e){if(e.words.length!==2||e.redirections.length!==0||e.nested.length!==1)return!1;let t=e.words[0],n=e.words[1];if(!t||t.provenance!=="literal"||t.quoted||t.raw!==t.text||!n)return!1;if(!(t.text==="eval"&&n.quoted&&n.parts.length===3&&n.parts[0]?.raw==='"'&&n.parts[1]?.provenance==="command-substitution"&&n.parts[1].raw.startsWith("$(")&&n.parts[2]?.raw==='"'||(t.text==="source"||t.text===".")&&!n.quoted&&n.parts.length===1&&n.parts[0]?.provenance==="command-substitution"&&n.parts[0].raw.startsWith("<(")))return!1;let o=e.nested[0];if(o?.status!=="complete"||o.nodes.length!==1)return!1;let i=o.nodes[0];if(i?.kind!=="command"||i.redirections.length!==0||i.nested.length!==0||i.words.some((c)=>c.provenance!=="literal"||c.parts.some((l)=>l.provenance!=="literal")))return!1;let s=i.words[0]?.text;if(s===void 0||je(s)!==null)return!1;let a=G(H(s));return!oO.has(a)&&!de.has(a)&&!En(a)}function iO(e){return yt(e.map(N)).commandIndex??-1}function sO(e){let t=/^IFS=(?:'([^']*)'|"([^"]*)"|([^;\s]*))\s*;\s*(.+)$/.exec(e.trim()),n=t?.[4]??e.trim(),r=/^(\.|bash|command|dash|exec|eval|ksh|sh|source|zsh)(?:\s+(--))?\s+(.+)$/.exec(n),o=(r?.[3]??n).split(/\s+/).map(aO);if(o.length===0||o.some((i)=>i===null))return null;return{command:r?.[1]??null,optionTerminator:r?.[2]!==void 0,references:o.filter((i)=>!!i),ifs:t?t[1]??t[2]??t[3]??"":`
57
+ `}}function aO(e){let t=/^"\$(?:([0-9]+|[@*])|\{([0-9]+|[@*])\})"$/.exec(e),n=/^\$(?:([0-9]+|[@*])|\{([0-9]+|[@*])\})$/.exec(e),r=t??n;if(!r)return null;let o=r[1]??r[2];return{parameter:o==="@"||o==="*"?o:Number(o),quoted:t!==null}}function cO(e,t,n,r){let o=t.slice(n+2);if(e.parameter==="@")return e.quoted?Bu(o):lO(o,r);if(e.parameter==="*"){let a=Bu(o);if(!a)return;let c=a.join(r[0]??"");return e.quoted?[c]:Uu(c,r)}let i=t[n+1+e.parameter];if(i&&!Js(i))return;let s=Ao(i);return e.quoted?[s]:Uu(s,r)}function Bu(e){return e.every(Js)?e.map(N):void 0}function lO(e,t){let n=Bu(e);if(!n)return;let r=n.map((o)=>Uu(o,t));return r.some((o)=>o===void 0)?void 0:r.flatMap((o)=>o??[])}function Uu(e,t){if(["*","?","[","]"].some((n)=>e.includes(n)))return;if(t==="")return e===""?[]:[e];if(t===`
58
+ `)return e.trim().split(/\s+/).filter(Boolean);if(t.length!==1)return;return t===" "||t==="\t"||t===`
59
+ `?e.trim().split(/\s+/).filter(Boolean):e.split(t).filter(Boolean)}function Js(e){if(!e)return!0;return e.provenance==="unknown"?!/[$`]/.test(N(e)):e.provenance==="literal"}function Ao(e){return e?N(e):""}function uO(e){return`'${e.replaceAll("'",`'"'"'`)}'`}function Vu(e,t){return ju(et(e,"posix"),t)}function fr(e){return Vu(e,new Set(Array.from(e.matchAll(Xv)).flatMap((t)=>{let n=t[1]??t[2];return n===void 0?[]:[n]})))}function ju(e,t){if(e.status==="invalid"||e.status==="limited")return!1;let n=new Set(t);for(let r of e.nodes){if(r.kind==="group"){if(ju(r.body,n))return!0;continue}if(r.kind!=="command")continue;if(r.nested.some((o)=>ju(o,n))||nS(r.words,n))return!0;gO(r,n)}return!1}function nS(e,t){let n=e.findIndex((s)=>je(s.text)===null);if(n===-1)return!1;let r=e[n];if(!r)return!1;if(To(r,t))return!0;let o=H(r.text);if(o==="source"||o==="."){let s=e[n+1]?.text==="--"?n+2:n+1;return Jv(e[s],t)}if(de.has(o)){let s=e.slice(n),a=yt(s.map((l)=>l.text)),c=a.commandIndex??a.scriptIndex;return!a.syntaxCheck&&c!==null&&Jv(s[c],t)}let i=dO(e,n,t);if(i===null)return!1;if(i===-1)return!0;return nS(e.slice(i),t)}function dO(e,t,n){let r=H(e[t]?.text??"");if(r==="command")return mO(e,t+1);if(r==="exec")return fO(e,t+1);if(r==="env")return pO(e,t+1,n);return null}function mO(e,t){for(let n=t;n<e.length;n++){let r=e[n]?.text??"";if(r==="--")return e[n+1]?n+1:null;if(/^-[p]*[vV][pvV]*$/.test(r))return null;if(/^-p+$/.test(r))continue;return n}return null}function fO(e,t){for(let n=t;n<e.length;n++){let r=e[n]?.text??"";if(r==="--")return e[n+1]?n+1:null;if(r==="-a"){n++;continue}if(/^-a.+/.test(r)||/^-[cl]+$/.test(r))continue;return n}return null}function pO(e,t,n){for(let r=t;r<e.length;r++){let o=e[r],i=o?.text??"";if(i==="--")return e[r+1]?r+1:null;if(i==="-S"||i==="--split-string")return To(e[r+1],n)?-1:r+2;if(i.startsWith("-S")||i.startsWith("--split-string="))return To(o,n)?-1:r+1;if(i==="-u"||i==="--unset"||i==="-C"||i==="--chdir"||i==="-P"){r++;continue}if(i==="-i"||i==="-0"||i==="--null"||i.startsWith("-u=")||i.startsWith("--unset=")||i.startsWith("-C")||i.startsWith("--chdir=")||i.startsWith("-P"))continue;if(i.startsWith("-"))continue;if(je(i))continue;return r}return null}function gO(e,t){if(!e.words.every((n)=>je(n.text)!==null))return;for(let n of e.words){let r=je(n.text);if(!r)continue;if(To(n,t))t.add(r.name)}}function To(e,t){if(!e)return!1;return e.parts.filter((n)=>n.provenance==="variable").some((n)=>Array.from(n.raw.matchAll(Xv)).some((r)=>{let o=r[1]??r[2];return o!==void 0&&(tO.test(o)||t.has(o))}))}function Jv(e,t){return!!e&&(e.parts.some((n)=>n.provenance!=="literal"&&n.provenance!=="variable")||To(e,t))}var hO=new Set(["-c","-C","--git-dir","--work-tree","--namespace","--config-env"]),yO=new Set(["-c","-H","-l","--config","--context","--host","--log-level","--tlscacert","--tlscert","--tlskey"]),bO=new Set;function rS(e){if(e==="git")return hO;if(e==="docker")return yO;return bO}function pe(e,t){if(e.length===0||t.length===0)return null;let n=H(e[0]??""),r=we(e);for(let o of t){if(!vO(n,o.command))continue;if(!SO(n,e,o.subcommand))continue;if(xO(e,new Set(o.block_args),r))return{id:`custom.${o.name}`,reason:`[${o.name}] ${o.reason}`,intent:o.intent??"manual_only"}}return null}function vO(e,t){return e===H(t)}function SO(e,t,n){if(!n)return!0;return oS(t,1,n,rS(e))}function oS(e,t,n,r){let o=!1;for(let i=t;i<e.length;i++){let s=e[i];if(!s)continue;if(o){o=!1;continue}if(s==="--"){let a=e[i+1];if(a&&!a.startsWith("-"))return a===n;return!1}if(r.has(s)){o=!0;continue}if(s.startsWith("-")){if(!s.includes("=")&&_O(e,i,n,r))return!0;continue}return s===n}return!1}function _O(e,t,n,r){let o=e[t+1];if(!o||o.startsWith("-"))return!1;return oS(e,t+2,n,r)}function xO(e,t,n){for(let r of e)if(t.has(r))return!0;for(let r of n)if(t.has(r))return!0;return!1}function en(e,t,n={}){if(e.length===0)return null;let r=e[0];if(!r)return null;let o=H(r);if(o==="eval"){let i=mr(j(e));if(i.kind==="dynamic")return pr(n,t);if(i.kind==="literal"&&t.analyzeNested){let s=t.analyzeNested(i.source,{effectiveCwd:t.cwd,envAssignments:t.envAssignments});if(s)return s}return vt(n,t)}if(de.has(o)){if(Ve(e))return null;let i=ht(e);if(i){if(n.dynamicSourceInput??n.dynamicInput){let c=pr(n,t);if(c)return c}if(fr(i)){let c=pr(n,t);if(c)return c}if(!t.analyzeNested)return null;let a=t.analyzeNested(i,{effectiveCwd:t.cwd,envAssignments:t.envAssignments});if(a)return a;return null}let s=bt(j(e));if(s.kind==="dynamic")return pr(n,t);if(s.kind==="literal"){if(n.dynamicSourceInput)return pr(n,t);return null}if(n.dynamicSourceInput??n.dynamicInput)return pr(n,t);return null}if($e.has(o))return O(Us(e,(i)=>t.analyzeNested?t.analyzeNested(i,{effectiveCwd:t.cwd,envAssignments:t.envAssignments}):null),t.policy)??pe(e,t.policy?.rules??[])??vt(n,t);if(Oe(o)){let i=os(e);if(!i)return vt(n,t);if(ue(t.policy,"interpreter.one-liner-paranoid",!!t.paranoidInterpreters)){let a=O(S("interpreter.one-liner-paranoid",tr),t.policy);if(a)return a}if(as(o,i))return vt(n,t);let s=t.analyzeNested?.(i,{effectiveCwd:t.cwd,envAssignments:t.envAssignments});if(s&&s.id!=="raw-text.dangerous-command"&&(s.reason!==qt||ar(i)))return s;if(nr(i,t.scanWork))return O(S("interpreter.dangerous-command",vn),t.policy)??vt(n,t);return vt(n,t)}if(o==="rm"||o==="rmdir"){let i=o==="rm"&&(ot(e)||n.dynamicRmInput);return O(dr(j(e),{environment:t.environment,cwd:t.cwd,originalCwd:t.originalCwd,strict:t.strict,paranoid:t.paranoidRm,allowTmpdirVar:t.allowTmpdirVar,tmpdirWordSplittingUnsafe:dt(t.envAssignments,t.environment),trustedTmpdirValue:$t(t.envAssignments,t.environment),protectedGitMetadata:t.protectedGitMetadata,policy:t.policy}),t.policy)??(i&&n.dynamicRmInput?vt(n,t):null)??(i?CO(n,t):null)}if(o==="find")return Vs(j(e),{...t,derivedCommandWorkBudget:t.derivedCommandWorkBudget,analyzeTokens:(i,s)=>en(i,{...t,cwd:s??void 0,derivedCommandWorkBudget:t.derivedCommandWorkBudget},n)})??pe(e,t.policy?.rules??[])??vt(n,t);if(o==="git")return O(ur(j(e),{env:t.environment.env,cwd:t.cwd,envAssignments:t.envAssignments,policy:t.policy,worktreeMode:n.dynamicInput?!1:t.worktreeMode}),t.policy)??pe(e,t.policy?.rules??[])??vt(n,t);return pe(e,t.policy?.rules??[])??vt(n,t)}function pr(e,t){return e.shellDynamicMatch?O(e.shellDynamicMatch,t.policy):null}function vt(e,t){return e.dynamicSourceInput&&e.dynamicSourceMatch?O(e.dynamicSourceMatch,t.policy):null}function CO(e,t){return e.dynamicInput&&e.rmDynamicMatch?O(e.rmDynamicMatch,t.policy):null}var qu="xargs rm -rf with dynamic input is dangerous. Use explicit file list instead.",Ku="xargs dynamic input can supply arbitrary executable command source. Use an explicit child command and arguments instead.",wO="__CC_SAFETY_NET_XARGS_INPUT__",Xs="__CC_SAFETY_NET_XARGS_INTERPRETER_INPUT__",Qs="rm",EO=/(?:^|[;&|]\s*|\b(?:eval|source)\s+|\b(?:ba|da|z|k)?sh\s+-c\s+)\s*["']?\$(?:([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)|\{!?([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)(?:[^}]*)\})/g,RO=/(?:^|[;&|]\s*)\s*eval\b((?:\\.|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^\\'";&|\r\n])*)/g,PO=/\$(?:([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)|\{!?([0-9]+|[@*]|[A-Za-z_][A-Za-z0-9_]*)(?:[^}]*)\})/g,kO=/^(?:[0-9]+|[@*])$/;function aS(e,t){let n=e.map(N),{childStart:r,replacementToken:o}=kn(n),i=n.slice(r),s=S("xargs.shell-dynamic",Ku);if(TO(i,o,t)&&O(s,t.policy))return O(s,t.policy);for(let a of rt(i,t)){let c=a.tokens,l=o!==null&&c[0]!==i[0]&&(c[0]?.includes(o)??!1)?O(s,t.policy):null;if(l)return l;let u=dS(c,o,a.wrapperEnvAssignments),d=a.head==="rm"&&o!==null&&lS(c,o),f=en(c,{...t,cwd:a.cwd,envAssignments:a.envAssignments},{dynamicInput:u,dynamicSourceInput:d||cS(c,a.head,o,a.wrapperEnvAssignments,u,t.scanWork,t.environment),dynamicRmInput:d,shellDynamicMatch:s,dynamicSourceMatch:s,rmDynamicMatch:S("xargs.rm-recursive-force-dynamic",qu)});if(f)return f;let m=AO(c,o,t.policy?.rules??[]);if(m)return m;if(a.head==="git"){let h=o===null?[...c,wO]:c,b=o!==null&&(c.some((E)=>E.includes(o))||Array.from(a.envAssignments.values()).some((E)=>E.includes(o))),y=en(h,{...t,cwd:a.cwd,envAssignments:a.envAssignments,worktreeMode:o===null||b?!1:t.worktreeMode});if(y)return y}let p=pe(c,t.policy?.rules??[]);if(p)return p}return null}function AO(e,t,n){if(n.length===0)return null;if(t===null){for(let o of n){let i=pe([...e,...o.subcommand?[o.subcommand]:[],...o.block_args],n);if(i)return i}return null}let r=new Set(n.flatMap((o)=>[o.subcommand,...o.block_args].flatMap((i)=>i?e.flatMap((s)=>Yu(s,t,i)):[])));for(let o of r){let i=pe(e.map((s)=>s.replaceAll(t,o)),n);if(i)return i}return null}function Yu(e,t,n){let r=e.indexOf(t);if(r===-1||e.indexOf(t,r+t.length)!==-1)return[];let o=e.slice(0,r),i=e.slice(r+t.length);return n.startsWith(o)&&n.endsWith(i)?[n.slice(o.length,n.length-i.length)]:[]}function cS(e,t,n,r,o,i,s){if(de.has(t)){if(Ve(e))return!1;if(n!==null&&IO(e,n))return!0;let a=ht(e);if(!a){let c=bt(j(e));if(c.kind==="literal")return n!==null&&c.source.includes(n);return c.kind==="none"&&o}if(n!==null&&a.includes(n))return!0;if(Dt(a,i))return!0;return OO(a,n,r)}if(Oe(t))return iS(e,n,ss,Hy(t));if($e.has(t))return iS(e,n,Au,_v);if(t==="eval"){let a=mr(j(e));if(a.kind==="dynamic")return!0;if(n!==null)return a.kind==="literal"&&a.source.includes(n);return o}if(t==="find")return zO(e,n,i,s);if(t==="git"){let a=it(e);return n===null?a.subcommand===null:(a.subcommand?.includes(n)??!1)||a.subcommand!==null&&lr.has(a.subcommand.toLowerCase())&&uS(a.rest,n).some((c)=>c.includes(n))}return!1}function iS(e,t,n,r){let o=n(e);if(t===null)return o.optionsOpen||n([...e,Xs]).sources.some((c)=>c.value===Xs);if(o.sources.some((c)=>c.value.includes(t)))return!0;let i=new Set(o.sources.map((c)=>`${c.tokenIndex}\x00${c.kind}\x00${c.value}`)),s=r.flatMap((c)=>[c.selector,...c.valueForm==="attached-only"||c.valueForm==="attached-or-separate"?[`${c.selector}${Xs}`]:[],...c.valueForm==="equals-or-separate"?[`${c.selector}=${Xs}`]:[]]),a=new Set(s.flatMap((c)=>e.flatMap((l)=>Yu(l,t,c))));return Array.from(a).some((c)=>n(e.map((l)=>l.replaceAll(t,c))).sources.some((l)=>!i.has(`${l.tokenIndex}\x00${l.kind}\x00${l.value}`)))}function TO(e,t,n){if(e.length===0||(e[0]??"").toLowerCase()==="command")return!1;let r=new Set(Array.from(rt(e,n),(i)=>i.head)),o=t===null?[...e,Qs]:e.map((i,s)=>s===0?i:i.replaceAll(t,Qs));return Array.from(rt(o,n)).some((i)=>i.head===Qs&&!r.has(Qs))}function lS(e,t){return uS(e.slice(1),t).some((n)=>n.includes(t)&&(n.startsWith("-")||n.startsWith(t)))}function uS(e,t){let n=e.findIndex((r)=>r==="--"&&!r.includes(t));return n===-1?e:e.slice(0,n)}function dS(e,t,n){if(t===null)return!0;return e.some((r)=>r.includes(t))||Array.from(n.values()).some((r)=>r.includes(t))}function IO(e,t){let n=yt(e);if(n.commandIndex!==null&&(e[n.commandIndex]??"").includes(t)||n.scriptIndex!==null&&(e[n.scriptIndex]??"").includes(t))return!0;return["-c","-nc","-cn",`--${t}`,t].some((o)=>e.some((i,s)=>{if(s===0||!i.includes(t))return!1;return Yu(i,t,o).some((c)=>{let l=e.map((d,f)=>f===s?d.replaceAll(t,c):d),u=yt(l);if(u.commandIndex===null&&u.scriptIndex===null)return!1;if(n.commandIndex===null&&u.commandIndex!==null)return!0;if(n.scriptIndex===null&&u.scriptIndex!==null)return!0;if(u.commandIndex!==null&&(l[u.commandIndex]??"").includes(c))return!0;return u.scriptIndex!==null&&(l[u.scriptIndex]??"").includes(c)})}))}function OO(e,t,n){let r=new Set(t===null?[]:Array.from(n).filter(([,o])=>o.includes(t)).map(([o])=>o));for(let o of e.matchAll(EO))if(sS(o,r))return!0;for(let o of e.matchAll(RO))for(let i of(o[1]??"").matchAll(PO))if(sS(i,r))return!0;return Vu(e,r)}function sS(e,t){let n=e[1]??e[2];return n!==void 0&&(kO.test(n)||t.has(n))}function zO(e,t,n,r){if(t===null)return!0;let o=!1,i=0;for(let s=1;s<e.length;s++){let a=e[s]??"";if(!o&&!a.startsWith("-")&&a!=="!"&&a!=="("){if(a.indexOf(t)===0)return!0;continue}if(o=!0,i>0){i--;continue}if(Mt(a)){let l=Ro(e,s);s=l.nextIndex-1;for(let u of rt(l.tokens,{environment:r,cwd:void 0})){let d=dS(u.tokens,t,u.wrapperEnvAssignments);if(u.head==="rm"&&lS(u.tokens,t)||cS(u.tokens,u.head,t,u.wrapperEnvAssignments,d,n,r))return!0}continue}let c=Jt(a);if(c>0){if(i=c,a.includes(t))return!0;continue}if(a.includes(t))return!0}return!1}function kn(e){let t=new Set(["-L","-n","-P","-s","-a","-E","-R","-S","-e","-d","-J","--max-args","--max-procs","--max-chars","--arg-file","--eof","--delimiter","--max-lines","--process-slot-var"]),n=null,r=1;while(r<e.length){let o=e[r];if(!o)break;if(o==="--")return{childStart:r+1,replacementToken:n};if(o.startsWith("-")){if(o==="-I"){n=e[r+1]??"{}",r+=2;continue}if(o.startsWith("-I")&&o.length>2){n=o.slice(2),r++;continue}if(o==="--replace"){n="{}",r++;continue}if(o.startsWith("--replace=")){let i=o.slice(10);n=i===""?"{}":i,r++;continue}if(o==="-J"){n=e[r+1]??"{}",r+=2;continue}if(t.has(o))r+=2;else r++}else return{childStart:r,replacementToken:n}}return{childStart:e.length,replacementToken:n}}var Oo="parallel rm -rf with dynamic input is dangerous. Use explicit file list instead.",zo="parallel with shell -c can execute arbitrary commands from dynamic input. Run the inner command directly on an explicit file list instead.",DO="parallel without a command reads executable commands from dynamic input. Use an explicit command template or ::: arguments instead.",$O="parallel command construction cannot be verified safely. Use the default ::: separator, literal arguments, and built-in replacement strings.",LO=/\{[^{}\s]*\}/,vS=/\{\}|\{-?\d+\}/g,MO=["e","f","source","file","-e","-f","--source","--file"],WO=["c","e","eval","m","r","Mmodule","import","require","-c","-e","-m","-r","--eval","--import","--require"],FO=new Set(["-L","-d","-n","--delay","--delimiter","--header","--joblog","--jl","--max-args","--max-lines","--nice","--results","--result","--res","--tagstring","--timeout"]),GO=new Set(["--arg-file","--colsep","--rpl","--arg-sep","--arg-file-sep"]),mS=new Set(["-S","--sshlogin","--slf","--sshloginfile"]),ZO=new Set(["--workdir","--wd"]),fS="__CC_SAFETY_NET_PARALLEL_SOURCE__",BO=new TextEncoder,Xu=V.maxDerivedBytes+4*V.maxPlaceholderReplacements;function Re(e,t){for(let n of e){let r=t(n);if(r)return r}return null}function SS(e,t){return Re([...e],(n)=>Dt(n,t.scanWork))}function _S(e,t){let n=e.map(N);if((t.envAssignments?.has("PARALLEL")?t.envAssignments.get("PARALLEL"):t.environment.env.get("PARALLEL"))?.trim()){let p=Tn(t);if(p)return p}if(n.length===2&&(n[1]==="--version"||n[1]==="--help"))return null;let o=TS(n),{template:i,jobs:s,runsRemotely:a,readsCommandsFromInput:c,unsupported:l,workdir:u,dryRun:d}=o;if(l){let p=Tn(t);if(p)return p;let h=SS(t.envAssignments?.values()??[],t);if(h)return h}if(c){let p=JO(t);if(p)return p}if(u!==void 0&&a){let p=Tn(t);if(p)return p}let f=tz(u,t.cwd,t.environment.paths);if(f===null){let p=Tn(t);if(p)return p}let m=a?{...t,cwd:void 0,originalCwd:void 0}:f===null||f===void 0||f===t.cwd?t:{...t,cwd:f};if(d){if([...rt(i,m)].flatMap((h)=>[...h.envAssignments.values()]).some(nd)){let h=Tn(t);if(h)return h}return null}if(i.length===0){if(s.some((b)=>b.length!==1)){let b=Tn(t);if(b)return b}let p=s.map((b)=>b[0]??"");ze(t.budget,Qu(p));let h=RS(m.envAssignments,m.cwd,a);return Re(p,(b)=>t.analyzeNested(b,h))}return Re(rt(i,m),(p)=>UO(p,o,t,m))}function UO(e,t,n,r){let{jobs:o,templateHasPlaceholder:i,runsRemotely:s,usesStdin:a}=t,c=e.tokens,l={...r,cwd:e.cwd,envAssignments:e.envAssignments},u=[...e.envAssignments.values()];if(u.some(kS)){let y=Tn(n);if(y)return y}let d=SS(u,n);if(d)return d;let f=u.some(Q),m=i||f,p=a&&m,h=RS(e.envAssignments,e.wrapperCwd,s||p);if(de.has(e.head)){let y=()=>{if(!i||o.length===0)return null;return ze(n.budget,ea(c,o,"generic")),Re(o,(R)=>en(c.map((P)=>tn(P,R)),l))};if(Ve(c))return y();let E=ht(c);if(E){if(AS(E)){let v=An(n);if(v)return v;if(o.length===0)return null;return ze(n.budget,bS(E,o)),Re(o,(T)=>n.analyzeNested(tn(E,T),h))}if(Q(E)){if(o.length>0)return ze(n.budget,bS(E,o)),Re(o,(k)=>n.analyzeNested(tn(E,k),h));ze(n.budget,hS(E));let v=Po(E);if(v?.[0]&&H(v[0])==="rm"&&ot(v)){let k=gS(n);if(k)return k}let T=v?en(v,l,{dynamicInput:a,shellDynamicMatch:S("parallel.shell-dynamic",zo),rmDynamicMatch:S("parallel.rm-recursive-force-dynamic",Oo)}):null;if(T)return T;return n.analyzeNested(E,h)}let R=!f&&(!i||o.length>0)?(o.length>0?o:[void 0]).map((v)=>Ys(j(v===void 0?c:i?c.map((T)=>tn(T,v)):[...c,...v]),E)):[];if(R.some((v)=>v.kind==="dynamic")){let v=An(n);if(v)return v}let P=R.flatMap((v)=>v.kind==="literal"?[v.source]:[]);if(P.length>0)return ze(n.budget,Qu(P)),Re(P,(v)=>n.analyzeNested(v,h));if(ze(n.budget,hS(E)),fr(E)){let v=An(n);if(v)return v}let x=n.analyzeNested(E,h);if(x)return x;if(m)return An(n);return null}let w=bt(j(c));if(w.kind==="dynamic"||w.kind==="literal"&&Q(w.source))return An(n)??y();if(w.kind==="literal")return y();if(o.length>0){let R=An(n);if(R)return R;let P=y();if(P)return P;if(i)return null;let x=o.flatMap((v)=>v[0]===void 0?[]:[v[0]]);return ze(n.budget,Qu(x)),Re(x,(v)=>n.analyzeNested(v,h))}if(m||a)return An(n)??y();return null}if(e.head==="rm"&&ot(c)){if(i&&o.length>0)return ze(n.budget,ea(c,o,"rm")),Re(o,(E)=>Ju(c.map((w)=>ed(w,E)),e.cwd,r));if(o.length>0)return ze(n.budget,yS(c,o)),Re(o,(E)=>Ju([...c,...E],e.cwd,r));let y=Ju(c.flatMap((E,w)=>{if(w===0||!Q(E))return[E];return E.startsWith("-")?[ed(E,[""])]:[]}),e.cwd,r);if(y)return y;return gS(n)}ze(n.budget,i&&o.length>0?ea(c,o,"generic"):o.length>0?yS(c,o):ES(c));let b=o.length>0?o:[void 0];return Re(b,(y)=>{let E=y===void 0?c:i?c.map((z)=>tn(z,y)):[...c,...y],w=S("parallel.shell-dynamic",zo),R=a&&e.head==="find"?YO(E,r):null,P=CS(E,a,n.policy?.rules??[],n.budget)??R?.customResult??null,x=H(e.head),v=a&&(x==="rm"&&td(E)||x==="xargs"&&wS(E)||R?.rmOptions===!0),T=a&&(v||R?.executedSource===!0||R===null&&xS(E,x)),k=en(E,{...l,worktreeMode:s||a||m?!1:n.worktreeMode},{dynamicInput:a||m,dynamicRmInput:v,dynamicSourceInput:P!==null||T,shellDynamicMatch:w,dynamicSourceMatch:w,rmDynamicMatch:S("parallel.rm-recursive-force-dynamic",Oo)});if(T){let z=O(w,n.policy);if(z)return z}return k??P??pe(E,n.policy?.rules??[])})}function xS(e,t){if(Q(e[0]??""))return!0;if(t==="eval"||t==="source"||t===".")return!0;if(t==="parallel"||t==="xargs")return!0;if(de.has(t))return VO(e);if(t==="git")return jO(e);if(t==="find")return!0;if($e.has(t))return pS(e,MO,Eo);if(Oe(t))return pS(e,WO,is);return!1}function td(e){let t=e.indexOf("--"),n=e.slice(1,t===-1?void 0:t);if(!e.some(Q))return t===-1;return n.some((o)=>Q(o)&&(o.startsWith("-")||AS(o)))}function jO(e){if(HO(e))return!0;let t=it(e);if(t.subcommand===null||Q(t.subcommand))return!0;if(!lr.has(t.subcommand.toLowerCase()))return!1;let n=t.rest.indexOf("--"),r=t.rest.slice(0,n===-1?void 0:n);if(!e.some(Q))return n===-1;return r.some(Q)}function HO(e){for(let t=1;t<e.length;t++){let n=e[t];if(!n||n==="--"||!n.startsWith("-"))return!1;if(n==="-c"||n==="--config-env"){if(Q(e[t+1]??""))return!0;t++;continue}if(n.startsWith("-c")&&n.length>2||n.startsWith("--config-env=")){if(Q(n))return!0;continue}if(Q(n))return!0}return!1}function VO(e){if(Ve(e))return!1;let t=ht(e);if(t!==null)return Q(t);let n=bt(j(e));if(n.kind==="literal")return Q(n.source);if(n.kind==="dynamic")return!0;return!e.some(Q)}function pS(e,t,n){let r=n(e);if(r.some((i)=>Q(i.value)))return!0;if(!e.some(Q))return n([...e,fS]).some((i)=>i.value===fS);let o=new Set(r.map((i)=>`${i.tokenIndex}\x00${i.kind}\x00${i.value}`));return t.some((i)=>n(e.map((s)=>tn(s,[i]))).some((s)=>!o.has(`${s.tokenIndex}\x00${s.kind}\x00${s.value}`)))}function CS(e,t,n,r){if(!t||n.length===0)return null;let o=n.filter((s)=>H(s.command)===H(e[0]??""));if(o.length===0)return null;let i=e.some(Q);if(ze(r,qO(e,o,i)),!i)return Re(o,(s)=>pe([...e,...s.subcommand?[s.subcommand]:[],...s.block_args],[s]));return Re(o,(s)=>{let a=new Set([s.subcommand,...s.block_args].flatMap((c)=>c?KO(e,c):[]));return Re(a,(c)=>pe(e.map((l)=>tn(l,[c])),[s]))})}function qO(e,t,n){let r=n?In(qe(t.map((o)=>o.block_args.length+(o.subcommand?1:0)),V.maxChildAnalyses),2*Math.max(e.length,1),V.maxChildAnalyses):t.length;return{childAnalyses:r,derivedTokens:In(r,e.length,V.maxDerivedTokens)}}function KO(e,t){return e.flatMap((n)=>{let r=[...n.matchAll(/\{[^{}\s]*\}/g)];if(r.length!==1)return[];let o=r[0];if(!o||o.index===void 0)return[];let i=n.slice(0,o.index),s=n.slice(o.index+o[0].length);if(!t.startsWith(i)||!t.endsWith(s))return[t];let a=t.slice(i.length,t.length-s.length);return a!==t?[t,a]:[t]})}function YO(e,t){let n={customResult:null,executedSource:!e.some(Q),rmOptions:!1},r=!1,o=0,i=null,s=()=>{if(!i?.some(Q))return;for(let a of rt(i,t))n.executedSource||=xS(a.tokens,a.head),n.rmOptions||=a.head==="rm"&&td(a.tokens)||a.head==="xargs"&&wS(a.tokens),n.customResult??=CS(a.tokens,!0,t.policy?.rules??[],t.budget)};for(let a of e.slice(1)){if(!r&&!a.startsWith("-")&&a!=="!"&&a!=="("){n.executedSource||=Q(a);continue}if(r=!0,i){if(a===";"||a==="+"){s(),i=null;continue}i.push(a);continue}if(o>0){o--;continue}if(Mt(a)){i=[],n.executedSource||=Q(a);continue}let c=Jt(a);if(c>0){o=c,n.executedSource||=Q(a);continue}n.executedSource||=Q(a)}return s(),n}function wS(e){let t=e.slice(kn(e).childStart);return H(t[0]??"")==="rm"&&td(t)}function ta(e,t){return(n)=>O(S(e,t),n.policy)}var An=ta("parallel.shell-dynamic",zo),JO=ta("parallel.command-stream-dynamic",DO),Tn=ta("parallel.command-stream-dynamic",$O),gS=ta("parallel.rm-recursive-force-dynamic",Oo);function Ju(e,t,n){return O(dr(j(e),{environment:n.environment,cwd:t,originalCwd:n.originalCwd,strict:n.strict,paranoid:n.paranoidRm,allowTmpdirVar:n.allowTmpdirVar,tmpdirWordSplittingUnsafe:dt(n.envAssignments??new Map,n.environment),trustedTmpdirValue:$t(n.envAssignments??new Map,n.environment),protectedGitMetadata:n.protectedGitMetadata,policy:n.policy}),n.policy)}function Qu(e){return{childAnalyses:e.length,derivedTokens:e.length,derivedBytes:No(e)}}function hS(e){return ES([e])}function ES(e){return{childAnalyses:1,derivedTokens:e.length,derivedBytes:No(e)}}function yS(e,t){if(t.length>V.maxChildAnalyses)return{childAnalyses:t.length};return{childAnalyses:t.length,derivedTokens:qe(t.map((n)=>e.length+n.length),V.maxDerivedTokens),derivedBytes:qe([In(No(e),t.length,V.maxDerivedBytes),qe(t.map((n)=>No(n)),V.maxDerivedBytes)],V.maxDerivedBytes)}}function bS(e,t){return ea([e],t,"generic")}function ea(e,t,n){if(t.length>V.maxChildAnalyses)return{childAnalyses:t.length};let r=In(e.length,t.length,V.maxDerivedTokens);if(r>V.maxDerivedTokens)return{childAnalyses:t.length,derivedTokens:r};let o=ez(e.map((c)=>QO(c,n))),i=In(o.occurrences,t.length,V.maxPlaceholderReplacements);if(i>V.maxPlaceholderReplacements)return{childAnalyses:t.length,derivedTokens:r,placeholderReplacements:i};if(XO(o,t,i))return{childAnalyses:t.length,derivedTokens:r,derivedBytes:V.maxDerivedBytes+1,placeholderReplacements:i};let s=n==="generic"?tn:ed,a=qe(t.map((c)=>No(e.map((l)=>s(l,c)))),V.maxDerivedBytes);return{childAnalyses:t.length,derivedTokens:r,derivedBytes:a,placeholderReplacements:i}}function XO(e,t,n){let r=V.maxDerivedBytes+4*n;return qe([In(e.fixedBytes,t.length,r),In(e.occurrences,qe(t.map((o)=>o.reduce((i,s)=>Math.max(i,Io(s)),0)),r),r)],r)>r}function QO(e,t){let n=t==="generic"?e.matchAll(/\{[^{}\s]*\}/g):e.matchAll(vS),r=0,o=0,i=0;for(let s of n){if(r>=V.maxPlaceholderReplacements)return{occurrences:V.maxPlaceholderReplacements+1,fixedBytes:0};o=qe([o,Io(e.slice(i,s.index))],Xu),r++,i=s.index+s[0].length}return{occurrences:r,fixedBytes:r===0?Io(e):qe([o,Io(e.slice(i))],Xu)}}function ez(e){return{occurrences:qe(e.map((t)=>t.occurrences),V.maxPlaceholderReplacements),fixedBytes:qe(e.map((t)=>t.fixedBytes),Xu)}}function No(e,t=V.maxDerivedBytes){return qe(e.map(Io),t)}function Io(e){return BO.encode(e).byteLength}function qe(e,t){let n=0;for(let r of e){if(!Number.isSafeInteger(r)||r<0||r>t-n)return t+1;n+=r}return n}function In(e,t,n){if(!Number.isSafeInteger(e)||!Number.isSafeInteger(t)||e<0||t<0||e!==0&&t>Math.floor(n/e))return n+1;return e*t}function RS(e,t,n){let r={};if(e)r.envAssignments=e;if(n)return r.effectiveCwd=null,r.worktreeMode=!1,r;if(t!==void 0)r.effectiveCwd=t;return Object.keys(r).length>0?r:void 0}function tn(e,t){return e.replace(/\{[^{}\s]*\}/g,(n)=>PS(n,t))}function ed(e,t){return e.replace(vS,(n)=>PS(n,t))}function PS(e,t){let n=/^\{(-?\d+)[^{}\s]*\}$/.exec(e)?.[1];if(n===void 0)return t[0]??"";let r=Number(n),o=r>0?r-1:t.length+r;return t[o]??""}function Q(e){return LO.test(e)}function kS(e){if(nd(e))return!0;for(let t of e.matchAll(/\{[^{}\s]*\}/g))if(!/^(?:\{\}|\{-?\d+\})$/.test(t[0]))return!0;return!1}function nd(e){let t=e.indexOf("{=");return t!==-1&&e.indexOf("=}",t+2)!==-1}function AS(e){return/^\{[^{}\s]*\}$/.test(e)}function TS(e){let t=1,n=[],r=e.length,o=-1,i=!1,s=!1,a=!1,c,l=e.some((p)=>p==="::::"||p==="::::+"||p===":::+");while(t<e.length){let p=e[t];if(p===void 0)break;if(p===":::"){o=t;break}if(p==="--"){let w=Ou(e,t+1);n.push(...w.templateTokens),r=t+1,o=w.markerIndex;break}if(!p.startsWith("-")){let w=Ou(e,t);n.push(...w.templateTokens),r=t,o=w.markerIndex;break}let h=e[t+1],b=p.indexOf("="),y=b===-1?p:p.slice(0,b),E=b===-1?void 0:p.slice(b+1);if(p==="--dry-run"){a=!0,t++;continue}if(p==="-I"||p.startsWith("-I")&&p.length>2){l||=(p==="-I"?h:p.slice(2))!=="{}",t+=p==="-I"?2:1;continue}if(p==="--replace"||p==="-i"){l=!0,t+=2;continue}if(y==="--replace"||p.startsWith("-i")&&p.length>2){let w=y==="--replace"?E:p.slice(2);l||=w!==""&&w!=="{}",t++;continue}if(p==="-a"||GO.has(y)){l=!0,t+=E===void 0?2:1;continue}if(p==="--pipe"||p==="--pipepart"){s=!0,t++;continue}if(y==="--env"){l=!0,t+=E===void 0?2:1;continue}if(mS.has(y)||p.startsWith("-S")&&p.length>2){i=!0,t+=mS.has(p)?2:1;continue}if(ZO.has(y)){let w=E??h;if(w===void 0||w===":::"||w==="--"){l=!0,t++;continue}c=w,l||=E!==void 0&&w==="",t+=E===void 0?2:1;continue}if(p.startsWith("-j")&&p.length>2&&/^\d+$/.test(p.slice(2))){t++;continue}if(p.startsWith("--")&&E!==void 0){t++;continue}if(FO.has(p)){if(h===void 0||h===":::"||h==="--"){l=!0,t++;continue}t+=2;continue}t+=p==="-j"||p==="--jobs"?2:1}l||=n.some(a?nd:kS);let u=[];if(o!==-1){let p=[];for(let h=o+1;h<e.length;h++){let b=e[h];if(b===":::"){u.push(p),p=[];continue}if(b!==void 0)p.push(b)}u.push(p)}let d=nz(u),f=n.some(Q),m=n.length===0&&o===-1;return{template:n,jobs:d,childStart:r,templateHasPlaceholder:f,runsRemotely:i,usesStdin:s||o===-1,readsCommandsFromInput:m,unsupported:l,workdir:c,dryRun:a}}function tz(e,t,n){if(e===void 0)return;if(e==="..."||/[{}$`*?~[]/.test(e))return null;if(!t&&!NO(e))return null;try{return Vt(t??e,e,n)}catch{return null}}function nz(e){if(e.length===0||e.some((n)=>n.length===0))return[];let t=[[]];for(let n of e){if(n.length===1){let o=n[0];if(o===void 0)return[];for(let i of t)i.push(o);continue}let r=[];for(let o of t)for(let i of n)if(r.push([...o,i]),r.length>V.maxChildAnalyses)return r;t=r}return t}function IS(e){return TS(e).childStart}var rz="dynamic command name contains shell substitution output and cannot be verified safely. Use a literal executable name.",na="shell substitution output can change guarded command structure and cannot be verified safely. Use literal subcommands and options.";function od(e){return e?.parts.some((t)=>t.provenance==="command-substitution")??!1}function rd(e){return e?.parts.some((t)=>t.provenance==="literal"&&t.raw.replace(/^["']/,"").startsWith("-"))??!1}function zS(e,t,n,r,o=!1,i){let a=(po(e,t)||r&&e!=="powershell"&&t[0]?.provenance==="variable")&&ue(i,"shell.dynamic-executable",o)?S("shell.dynamic-executable",rz):null;return O(a,i)??NS(e,t,n,o,i)}function NS(e,t,n,r,o){if(t.length<2)return null;let i=t.flatMap((a,c)=>od(a)?[c]:[]);if(i.length===0)return null;let s=H(t[0]?.text??"");if(s==="git"){let a=Yn(e,t),c=iz(a);if(ue(o,"shell.dynamic-structure",r)&&i.some((d)=>d<=c))return O(S("shell.dynamic-structure",na),o);if(O(ur(a,{env:n.env}),o))return null;let l=t[c]?.text.toLowerCase(),u=a.findIndex((d,f)=>f>c&&N(d)==="--");if(ue(o,"shell.dynamic-structure",r)&&l&&lr.has(l)&&i.some((d)=>d>c&&(u===-1||d<u)))return O(S("shell.dynamic-structure",na),o);return null}if(s==="find")return ue(o,"shell.dynamic-structure",r)&&sz(t)?O(S("shell.dynamic-structure",na),o):null;if(s==="rm"){let a=t.findIndex((l,u)=>u>0&&N(l)==="--"),c=ot(t.map(N));return ue(o,"shell.dynamic-structure",r)&&i.some((l)=>(a===-1||l<a)&&(l<t.length-1||!c))?O(S("shell.dynamic-structure",na),o):null}if(s==="xargs")return OS(e,t.slice(kn(t.map(N)).childStart),"xargs",n,r,o);if(s==="parallel")return OS(e,t.slice(IS(t.map(N))),"parallel",n,r,o);return null}function OS(e,t,n,r,o,i){if(t.length===0)return null;let s=oz(t,r);if(po(e,s)){let c=O(S(`${n}.shell-dynamic`,n==="xargs"?Ku:zo),i);if(c)return c}let a=NS(e,s,r,o,i);if(a)return a;if(s[0]?.text==="rm"&&s.slice(1).some((c)=>od(c)&&rd(c)))return O(S(`${n}.rm-recursive-force-dynamic`,n==="xargs"?qu:Oo),i);return null}function oz(e,t){let n=Sn(e,t),r=n.rewritten?j(n.words.map(N)):n.words,o=r[0];return o&&N(o)==="busybox"?r.slice(1):r}function iz(e){let t=1;while(t<e.length){let n=e[t],r=n?N(n):"";if(ut.has(r)){t+=2;continue}if(r.startsWith("-")){t++;continue}return t}return t}function sz(e){let t=!1,n=0,r=!1,o=!1;for(let i=1;i<e.length;i++){let s=e[i];if(!s)continue;let a=od(s);if(n>0){n--;continue}if(o){if(s.text===";"||s.text==="+"){o=!1,t=!0,r=!1;continue}if(a&&(r||rd(s)))return!0;r=!1;continue}if(!t&&!s.text.startsWith("-")){if(a&&(i>1||rd(s)))return!0;continue}if(t=!0,a)return!0;let c=Jt(s.text);if(c>0){n=c;continue}if(Mt(s.text))o=!0,r=!0}return!1}function id(e,t){return e.some((n)=>{if(n.value==="-"&&(n.kind==="main-script"||n.kind==="program-file"))return!0;return!Zi(t[n.tokenIndex],n.value)})}var az="dd writing to a /dev device can destroy a disk or partition. Run device writes manually after confirming the target.",cz="mkfs formatting a /dev device erases everything on it. Run the format manually after confirming the target.",lz="shred permanently destroys the given target. Use rm for ordinary deletes, or run shred manually.";function DS(e,t){let n=t.slice(1);if(e==="dd"&&n.some((r)=>/^of=\/dev\/.+/.test(r)))return S("dd.device-write",az);if((e==="mkfs"||e.startsWith("mkfs."))&&n.some((r)=>r.startsWith("/dev/")))return S("mkfs.device",cz);if(e==="shred"&&n.length>0)return S("shred.target",lz);return null}var LS=[{heads:new Set(["rm","rmdir"]),analyze:(e)=>dr(e.words,{environment:e.options.environment,cwd:e.cwd,originalCwd:e.originalCwd,strict:e.options.strict,paranoid:e.options.paranoidRm,allowTmpdirVar:e.allowTmpdirVar,tmpdirWordSplittingUnsafe:dt(e.envAssignments,e.options.environment),trustedTmpdirValue:$t(e.envAssignments,e.options.environment),protectedGitMetadata:e.options.protectedGitMetadata,policy:e.options.policy})},{heads:new Set(["git"]),analyze:(e)=>ur(e.words,sd(e))},{heads:new Set(["find"]),analyze:(e)=>Vs(e.words,{environment:e.options.environment,cwd:e.cwd,originalCwd:e.originalCwd,strict:e.options.strict,allowTmpdirVar:e.allowTmpdirVar,tmpdirWordSplittingUnsafe:dt(e.envAssignments,e.options.environment),trustedTmpdirValue:$t(e.envAssignments,e.options.environment),protectedGitMetadata:e.options.protectedGitMetadata,derivedCommandWorkBudget:e.options.derivedCommandWorkBudget,envAssignments:e.envAssignments,policy:e.options.policy,analyzeTokens:e.analyzeChildTokens,analyzeNested:(t,n)=>On(e.options.analyzeNested(t,n))})},{heads:new Set(["xargs"]),analyze:(e)=>aS(e.words,{...$S(e),analyzeNested:(t,n)=>On(e.options.analyzeNested(t,n))})},{heads:new Set(["parallel"]),analyze:(e)=>_S(e.words,{...$S(e),budget:e.options.parallelBudget,analyzeNested:(t,n)=>On(e.options.analyzeNested(t,n))})}];function $S(e){return{environment:e.options.environment,cwd:e.cwd,originalCwd:e.originalCwd,strict:e.options.strict,paranoidRm:e.options.paranoidRm,paranoidInterpreters:e.options.paranoidInterpreters,allowTmpdirVar:e.allowTmpdirVar,protectedGitMetadata:e.options.protectedGitMetadata,derivedCommandWorkBudget:e.options.derivedCommandWorkBudget,envAssignments:e.envAssignments,worktreeMode:e.options.worktreeMode,policy:e.options.policy,scanWork:e.options.scanWork}}function On(e){return e?{id:e.ruleId??"",reason:e.reason,intent:e.intent??"manual_only"}:null}function sd(e){return{env:e.options.environment.env,cwd:e.cwd,dynamicArguments:e.dynamicArguments,envAssignments:e.envAssignments,policy:e.options.policy,worktreeMode:e.options.worktreeMode}}var GS="shell execution source cannot be verified safely. Use a literal command string or ask the user to run it manually.";function ZS(e){return LS.find((t)=>t.heads.has(e))?.analyze}function Do(e,t,n){let r=n.trace;if(e.length===0)return null;let o=n.commandView?.dialect??"posix",i=(A)=>A.map((Z)=>o==="posix"?N(Z):Z.text),s=n.effectiveCwd===null,a=s?void 0:n.effectiveCwd??n.cwd,c=s?void 0:n.cwd,l=ms(e);if(l.envAssignments.size>0)r?.recordSegment({type:"env-strip",input:i(e),envVars:[...l.envAssignments.keys()],output:i(l.words)});let u=Sn(l.words,n.environment,a,new Map([...n.envAssignments??[],...l.envAssignments])),d=u.envSplitValues??[];if(d.length>0){let A=[...d,...i(u.words)].join(" "),Z=Dt(A,n.scanWork);if(Z)return r?.recordSegment({type:"dangerous-text",token:A,matched:!0,reason:Z.reason}),St(Z);if(n.strict)return Le(r);let oe=fs(d,i(u.words));if(oe){Je(n.derivedCommandWorkBudget,oe.length);let le=n.analyzeNested(oe.join(" "),{effectiveCwd:u.cwd===void 0?n.effectiveCwd:u.cwd,envAssignments:new Map([...n.envAssignments??[],...l.envAssignments,...u.envAssignments])});if(le)return le}}let f=u.rewritten?j(i(u.words)):Yn(o,u.words),m=i(f),p={...n,wrapperNormalizationBudget:n.wrapperNormalizationBudget??{iterations:0}};if(r&&l.words.length>f.length){let A=i(l.words);r.recordSegment({type:"leading-tokens-stripped",input:A,removed:A.slice(0,A.length-f.length),output:m})}let h=new Map([...n.envAssignments??[],...l.envAssignments,...u.envAssignments]),b=m[0];if(!b)return null;if(En(b))throw new Ie;let y=H(b),E=u.cwd===null?void 0:u.cwd??a,w=u.cwd===null?void 0:c,R=u.cwd===void 0?n.effectiveCwd:u.cwd,P=!lo(h,n.environment),x=zS(o,u.words,n.environment,t===0,n.strict,n.policy);if(x)return r?.recordSegment({type:"rule-check",rule:"analyzer/segment.ts:analyzeDynamicCommandStructure",matched:!0,reason:x.reason}),St(x);let v=js(m,n.policy);if(v){for(let A of[v.childIndex,...v.alternativeChildIndices]){MS(p.wrapperNormalizationBudget);let Z=f.slice(A);r?.recordSegment({type:"transparent-wrapper",wrapper:v.wrapper,output:i(Z)});let oe=Do(Z,t,{...p,effectiveCwd:R,envAssignments:h});if(oe)return oe}return null}let T=y==="eval"?mr(f):y==="trap"?eS(f):void 0;if(T?.kind==="dynamic"&&(n.strict||!n.commandView||!Hu(n.commandView)))return Le(r);if(T?.kind==="literal"){r?.recordSegment({type:"recurse",reason:y==="eval"?"shell-eval":"shell-trap",innerCommand:T.source,depth:t+1});let A=n.analyzeNested(T.source,{effectiveCwd:R,envAssignments:h,functionDefinitions:n.functionDefinitions});if(A)return A}if(US(b,y)){if(Ve(m))return null;let A=uz(m,h,R,n,r,t);if(A)return A;let Z=ht(m);if(Z){let Vn=Ys(f,Z);if(Vn.kind==="dynamic")return Le(r);let vl=Vn.kind==="literal"?Vn.source:Z,Ph=dz(vl);r?.recordSegment({type:"shell-wrapper",wrapper:y,innerCommand:Ph}),r?.recordSegment({type:"recurse",reason:"shell-wrapper",innerCommand:Ph,depth:t+1});let kh=n.analyzeNested(vl,{effectiveCwd:R,envAssignments:h});if(kh)return kh;return fr(vl)?Le(r):null}let oe=bt(f);if(oe.kind==="dynamic")return Le(r);if(oe.kind==="literal")return ia(oe.source,R,h,n,r,t);let le=tS(f,n.commandView?.redirections??[],n.hasPipelineInput??!1,n.literalShellInput);if(le.kind==="dynamic")return Le(r);if(le.kind==="literal")return r?.recordSegment({type:"recurse",reason:"shell-stdin",innerCommand:le.source,depth:t+1}),n.analyzeNested(le.source,{effectiveCwd:R,envAssignments:h})}if(y==="source"||y==="."){let A=m[1]==="-p"?2:null;if(A!==null){let Vn=n.commandView?f[A]:void 0;if(!Vn)return null;if(Vn.provenance!=="literal")return Le(r)}let Z=A===null?1:3,oe=m[Z]==="--"?Z+1:Z,le=n.commandView?f[oe]:void 0;if(!le)return null;if(le.provenance==="literal")return ia(le.text,R,h,n,r,t);if(n.strict||!n.commandView||!Hu(n.commandView))return Le(r)}if($e.has(y)){if(n.strict&&id(Eo(m),f))return Le(r);let A=Us(m,(oe)=>On(n.analyzeNested(oe,{effectiveCwd:R,envAssignments:h}))),Z=O(A,n.policy);if(Z)return r?.recordSegment({type:"rule-check",rule:"awk:analyzeAwkSystemCallMatch",matched:!0,reason:Z.reason}),St(Z)}if(Oe(y)){if(n.strict&&id(is(m),f))return Le(r);let A=os(m);if(A){let Z=ue(n.policy,"interpreter.one-liner-paranoid",!!n.paranoidInterpreters);if(r?.recordSegment({type:"interpreter",interpreter:y,codeArg:A,paranoidBlocked:Z}),Z){let le=O(S("interpreter.one-liner-paranoid",tr),n.policy);if(le)return St(le)}if(as(y,A))return null;r?.recordSegment({type:"recurse",reason:"interpreter",innerCommand:A,depth:t+1});let oe=n.analyzeNested(A,{effectiveCwd:R,envAssignments:h});if(oe&&oe.ruleId!=="raw-text.dangerous-command"&&(oe.reason!==qt||ar(A)))return oe;if(nr(A,n.scanWork)){let le=O(S("interpreter.dangerous-command",vn),n.policy);if(le)return r?.recordSegment({type:"dangerous-text",token:A,matched:!0,reason:vn}),St(le)}r=void 0}}if(y==="busybox"&&m.length>1)return MS(p.wrapperNormalizationBudget),r?.recordSegment({type:"busybox",subcommand:m[1]??"unknown"}),r?.recordSegment({type:"recurse",reason:"busybox",innerCommand:m.slice(1).join(" "),depth:t+1}),Do(f.slice(1),t,{...p,effectiveCwd:R,envAssignments:h});let k=O(DS(y,m),n.policy);if(k)return r?.recordSegment({type:"rule-check",rule:"analyzer/device.ts:analyzeDeviceCommandMatch",matched:!0,reason:k.reason}),St(k);let z=r===p.trace?p:{...p,trace:r},L={words:f,head:y,cwd:E,originalCwd:w,envAssignments:h,allowTmpdirVar:P,dynamicArguments:u.words.some((A)=>A.provenance==="command-substitution"),depth:t,effectiveCwd:R,options:z,analyzeChildTokens:(A,Z)=>On(Do(j(A),t+1,{...z,commandView:void 0,effectiveCwd:Z,envAssignments:h}))??pe(A,z.policy.rules)},W=ZS(y);if(y==="rm"||y==="xargs"||y==="parallel")r?.recordSegment({type:"tmpdir-check",tmpdirValue:h.has("TMPDIR")||n.environment.env.has("TMPDIR")?"<redacted>":null,isOverriddenToNonTemp:!P,allowTmpdirVar:P});let U=r&&y==="git"?Bv(L.words,sd(L)):void 0,ge=WS(U?U.match:W?.(L)??null,n.policy);if(r)mz(L,ge,U?.relaxation??null);if(ge)return St(ge);let Ze=W!==void 0;if(!Ze)if(!ns.has(y)){let A=r?[]:void 0;for(let Z=1;Z<m.length;Z++){let oe=m[Z];if(!oe)continue;A?.push(oe);let le=WS(fz(L,m,Z),n.policy);if(le)return r?.recordSegment({type:"fallback-scan",tokensScanned:A??[],embeddedCommandFound:H(oe)}),St(le)}r?.recordSegment({type:"fallback-scan",tokensScanned:A??[]})}else r?.recordSegment({type:"fallback-scan",tokensScanned:[]});else r?.recordSegment({type:"fallback-scan",tokensScanned:[]});if(t===0||!Ze){let A=pe(m,n.policy.rules);if(r?.recordSegment({type:"custom-rules-check",rulesChecked:n.policy.rules.length>0,matched:!!A,reason:A?.reason}),A)return St(A)}else r?.recordSegment({type:"custom-rules-check",rulesChecked:!1,matched:!1});return null}function uz(e,t,n,r,o,i){let s=Kv(e);if(s.argvSource?.kind==="absent")return Le(o);if(s.argvSourceApplies&&s.argvSource){let c=ia(s.argvSource.value,n,t,r,o,i,!0);if(c)return c}if(!s.envSourceApplies||!s.envName)return null;let a=t.get(s.envName);if(!a)return null;return ia(a,n,t,r,o,i,!0)}function ia(e,t,n,r,o,i,s=!1){if(s&&/[$`*?[\]]/.test(e))return Le(o);let a=co(e,t,r.environment.paths),c=a?r.literalHeredocFiles?.get(a):void 0;if(c===void 0)return s?Le(o):null;return Je(r.derivedCommandWorkBudget,1),o?.recordSegment({type:"recurse",reason:"heredoc-file",innerCommand:c,depth:i+1}),r.analyzeNested(c,{effectiveCwd:t,envAssignments:n})}function dz(e){let t=e[0];return e.length>=2&&(t==='"'||t==="'")&&e.at(-1)===t?e.slice(1,-1):e}function mz(e,t,n){let r={git:"git:analyzeGitMatch",rm:"analyzer/rm.ts:analyzeRmMatch",find:"analyzer/find.ts:analyzeFindMatch",xargs:"analyzer/xargs.ts:analyzeXargs",parallel:"analyzer/parallel.ts:analyzeParallel"}[e.head];if(!r)return;if(e.options.trace?.recordSegment({type:"rule-check",rule:r,matched:!!t||!!n,reason:t?.reason??n?.originalReason}),n)e.options.trace?.recordSegment({type:"worktree-relaxation",originalReason:n.originalReason,gitCwd:n.gitCwd})}function MS(e){if(e.iterations>=Qn)throw new Ie;e.iterations++}function St(e){return{reason:e.reason,ruleId:e.id||void 0,intent:e.intent}}function Le(e){return e?.recordSegment({type:"error",message:GS}),St(BS())}function BS(){return{id:"",reason:GS,intent:"stop_and_explain"}}function US(e,t){return de.has(t)||e==="$SHELL"||e==="${SHELL}"||de.has(G(t))}function fz(e,t,n){let r=rt(t.slice(n),{environment:e.options.environment,cwd:e.cwd,envAssignments:e.envAssignments,policy:e.options.policy});for(let o of r){let i=pz(e,n,o);if(i)return i}return null}function pz(e,t,n){let r=n.tokens[0];if(!r)return null;let o=H(r);if(US(r,o)){Je(e.options.derivedCommandWorkBudget,e.words.length-t);let c=n.tokens;if(Ve(c))return null;let l=ht(c);if(!l){if(bt(j(c)).kind==="dynamic")return BS();return oa(e,n)}let u=e.options.analyzeNested(l,{effectiveCwd:n.wrapperCwd===void 0?e.effectiveCwd:n.wrapperCwd,envAssignments:n.envAssignments});return u?On(u):oa(e,n)}let i=ZS(o);if(!i||o==="xargs"||o==="parallel"){if(n.wrappedByTransparent&&e.options.policy.rules.length>0)Je(e.options.derivedCommandWorkBudget,e.words.length-t);return oa(e,n)}Je(e.options.derivedCommandWorkBudget,e.words.length-t);let s=[o,...n.tokens.slice(1)],a={...e,words:j(s),head:o,cwd:n.cwd,originalCwd:n.wrapperCwd===null?void 0:e.originalCwd,envAssignments:n.envAssignments,allowTmpdirVar:!lo(n.envAssignments,e.options.environment),effectiveCwd:n.wrapperCwd===void 0?e.effectiveCwd:n.wrapperCwd,options:o==="git"?{...e.options,worktreeMode:!1}:e.options};return i(a)??oa(e,n)}function oa(e,t){return t.wrappedByTransparent?pe(t.tokens,e.options.policy.rules):null}function WS(e,t){return e?.id.startsWith("custom.")||e?.id==="raw-text.dangerous-command"?e:O(e,t)}var gz=/^\s*(?:\$\(\s*)?[({]*\s*(?:command\s+|builtin\s+)?(?:cd|pushd|popd)(?:\s|$)/,hz=new Set(["cd","chdir","pop-location","popd","push-location","pushd","set-location","sl"]);function yz(e,t){let n=VS(e,t);if(n.length===0)return!1;let r=n[HS(n)];if(r==="cd"||r==="pushd"||r==="popd")return!0;return gz.test(e.join(" "))}function jS(e,t,n,r){if(e.dialect==="powershell"){let a=bz(e.words,r);if(a.kind==="none")return;if(!t||a.kind==="unknown")return null;return FS(xz(a.target),t,n.paths)}let o=e.words.map(N);if(!yz(o,n))return;if(!t)return null;let i=VS(o,n,t),s=HS(i);if(s===-1||i[s]!=="cd")return null;return FS(i[s+1],t,n.paths)}function FS(e,t,n){if(!e||e==="-"||e.includes("$")||e.includes("`"))return null;try{return Cz(Vt(t,e,n),t,n)?t:null}catch{return null}}function bz(e,t){let n=vz(e[0])?1:0,r=e[n];if(!Sz(r,n===1))return{kind:"none"};let o=r.text.toLowerCase(),i=o.split(/[\\/]/).pop()??o;if(!hz.has(i))return{kind:"none"};if(o!==i||i==="pop-location"||i==="popd")return{kind:"unknown"};return _z(e.slice(n+1),t)}function vz(e){return e?.provenance==="literal"&&!e.quoted&&e.raw===e.text&&(e.text==="&"||e.text===".")}function Sz(e,t){return e?.provenance==="literal"&&(t||!e.quoted&&e.raw===e.text)}function _z(e,t){let n;for(let r of e){if(r.provenance!=="literal"||n!==void 0)return{kind:"unknown"};n=r.text}if(n!==void 0)return{kind:"target",target:n};return t===void 0?{kind:"unknown"}:{kind:"target",target:t}}function xz(e){return e.includes("::")?void 0:e.replaceAll("\\","/")}function HS(e){let t=0;if(e[0]==="builtin"&&e.length>1)t=1;if(e[t]!=="time")return t;let n=t+1;while(e[n]?.startsWith("-"))n++;return n}function VS(e,t,n){let r=wz(e);return or([...r],t,n)}function Cz(e,t,n){let r=n.realpath(e),o=n.realpath(t);if(r===null||o===null)return ra(e)===ra(t);return ra(r)===ra(o)}function wz(e){let t=0;while(t<e.length){let n=e[t];if(n==="{"||n==="("||n==="$(")t++;else break}return e.slice(t)}var cd="TMPDIR",ld="IFS",qS=/^([A-Za-z_][A-Za-z0-9_]*)\+=/,KS=/^[A-Za-z_][A-Za-z0-9_]*$/,YS=new Set(["export","typeset","declare","readonly"]),Ez=new Set(["builtin","command","time"]);function JS(e,t){return{env:e,effectiveEnvAssignments:Tz(e,t),shellAssignments:new Map}}function XS(e){return{env:e.env,effectiveEnvAssignments:e.effectiveEnvAssignments?new Map(e.effectiveEnvAssignments):void 0,shellAssignments:new Map(e.shellAssignments)}}function ud(e,t){let n=e_(e,t);n.assignments.filter((s)=>s.persists).forEach((s)=>{t.shellAssignments.set(s.name,s.value),dd(t,s)});let r=n.commandIndex;if(r!==-1&&YS.has(e[r]??""))e.filter((s)=>KS.test(s)&&ad(s)).forEach((s)=>{Iz(t,s)});let o=r===-1?-1:t_(e,r);if(o===-1||e[o]!=="unset")return;let i=zz(e,o);if(i===null)return;e.slice(i).forEach((s)=>{Oz(t,s)})}function QS(e,t){let n=e_(e,t).assignments;if(n.length===0)return t.effectiveEnvAssignments;let r=new Map(t.effectiveEnvAssignments??[]);return n.forEach((o)=>{r.set(o.name,o.value)}),r}function e_(e,t){let n=e.findIndex((s)=>!Rz(s)),r=n!==-1&&YS.has(e[t_(e,n)]??""),o=Az(t);return{assignments:e.flatMap((s,a)=>{let c=Pz(s,o,t.env);if(!c)return[];if(n!==-1&&a>n&&!r&&!Ml(c.name))return[];return o.set(c.name,c.value),[{...c,persists:n===-1||r}]}),commandIndex:n}}function t_(e,t){let n=t;while(Ez.has(e[n]??"")){n+=1;while(e[n]?.startsWith("-")){if(/^-p*[vV][pvV]*$/.test(e[n]??""))return t;n+=1}}return n}function Rz(e){return je(e)!==null||qS.test(e)}function Pz(e,t,n){return je(e)??kz(e,t,n)}function kz(e,t,n){let r=ji(e,n,t);if(r)return r;let o=e.match(qS)?.[1];if(!o)return null;let i=e.indexOf("=");return{name:o,value:`${t.has(o)?t.get(o):n.get(o)??""}${e.slice(i+1)}`}}function ad(e){return e===cd||e===ld||Wl(e)}function Az(e){return new Map([...e.effectiveEnvAssignments??[],...e.shellAssignments])}function Tz(e,t){let n=[...Bi,cd,ld].map((r)=>{let o=e.get(r);return o===void 0?null:[r,o]}).filter((r)=>r!==null);if(n.length===0)return t;return new Map([...n,...t??[]])}function dd(e,t){let n=new Map(e.effectiveEnvAssignments??[]);n.set(t.name,t.value),e.effectiveEnvAssignments=n}function Iz(e,t){dd(e,{name:t,value:e.shellAssignments.get(t)??e.effectiveEnvAssignments?.get(t)??e.env.get(t)??""})}function Oz(e,t){if(!ad(t)&&!KS.test(t))return;if(e.shellAssignments.set(t,""),!ad(t)||t===cd||t===ld||to(t)){dd(e,{name:t,value:""});return}if(!e.effectiveEnvAssignments?.has(t))return;let n=new Map(e.effectiveEnvAssignments);n.delete(t),e.effectiveEnvAssignments=n.size===0?void 0:n}function zz(e,t){let n=t+1;while(n<e.length){let r=e[n];if(!r)return null;if(r==="--")return n+1;if(r==="-v"){n++;continue}if(r.startsWith("-"))return null;return n}return n}var Nz="Unquoted heredoc input is not supported safely. Quote the delimiter or ask the user to verify.",zn="This heredoc form or stdin consumer is not supported safely. Use a quoted heredoc with a supported consumer (cat, tee, git apply, git commit, gh pr create, gh issue create), or ask the user to verify.",Dz=64;function hd(e,t,n,r){let o=n.derivedCommandWorkBudget===void 0,i=n.parallelBudget===void 0;try{return $z(e,t,{...n,derivedCommandWorkBudget:n.derivedCommandWorkBudget??es(),parallelBudget:n.parallelBudget??qy()},r)}catch(s){let a=s instanceof Ie&&o?Wy:s instanceof us&&i?Vy:void 0;if(!a)throw s;if(n.trace?.currentSegmentIndex!==void 0)n.trace.recordSegment({type:"error",message:a});else n.trace?.recordGlobal({type:"error",message:a});return{reason:a,segment:e,intent:"stop_and_explain"}}}function $z(e,t,n,r){if(t>=ts)return n.trace?.recordSegment({type:"error",message:It}),{reason:It,segment:e,intent:"stop_and_explain"};let o=r??n.factStore?.getCommandProgram(e,n.shell??"auto")??et(e,n.shell);if(o.status==="limited")return n.trace?.recordSegment({type:"error",message:It}),{reason:It,segment:e,intent:"stop_and_explain"};if(o.status==="invalid"){let l=o.issues.find((u)=>u.code.includes("heredoc"));if(l){if(!n.strict)return gd(e,n);let u=`Unsupported heredoc syntax: ${l.message}`;return n.trace?.recordGlobal({type:"error",message:u}),{reason:u,segment:e,intent:"stop_and_explain"}}return a_(e,n),{reason:qt,segment:e,intent:"stop_and_explain"}}if(n.strict&&o.status==="partial")return a_(e,n),{reason:qt,segment:e,intent:"stop_and_explain"};if(o.issues.some((l)=>l.code.includes("quote"))&&!n.analyzePartialProgram)return gd(e,n);let s=n.cwd,a=n.effectiveCwd!==void 0?n.effectiveCwd:n.cwd,c=JS(n.environment.env,n.envAssignments);return ca(o,t,{...n,rootProgram:o},s,[{effectiveCwd:a,shellGitContextState:c,literalHeredocFiles:new Map(n.literalHeredocFiles),functionDefinitions:new Map(n.functionDefinitions)}]).result}function ca(e,t,n,r,o){let i=[...o],s,a;for(let[c,l]of e.nodes.entries()){if(l.kind==="connector"){a=l.operator;continue}let u=e.nodes[c+1],d=u?.kind==="connector"?u.operator:void 0,f=Lz(e,c,l,a,d),m=a==="&&"||a==="||",p=m?s:void 0,h=a==="&&"?p?.success??i:a==="||"?p?.failure??i:i,b=a==="||"?p?.success??[]:[],y=a==="&&"?p?.failure??[]:[],E=m||gr(d);if(l.kind==="function"){let k=h.flatMap((L)=>{let W=$o(L);return W.functionDefinitions.set(l.name,l.body),md(L,[W],f,d==="&",gr(d))}),z=fd(k,[],b,y,a,d);i=z.states,s=z.conditionalStates,a=void 0;continue}if(l.kind==="group"){let k=[],z=[];for(let W of h){let U=ca(l.body,t,n,r,[$o(W)]);if(U.result)return U;if(k.push(...md(W,U.states,f,d==="&",gr(d))),E)z.push(W,...f?U.states.map((ge)=>sa(W,ge)):U.states)}let L=fd(k,z,b,y,a,d);i=L.states,s=L.conditionalStates,a=void 0;continue}if(l.kind!=="command")continue;let w=n.trace?.flattenNested?n.trace.currentSegmentIndex:n.trace?.allocateSegment(),R=e.nodes[c-2],P=la(a)&&R?.kind==="command"?Qv(R)??Wz(R):void 0,x=[],v=[];for(let k of h){let z=Fz(l,t,n,r,[$o(k)]);if(z.result)return{result:z.result,states:i};let L=e.dialect==="powershell"?z.states:z.states.map((W)=>sa(k,W));for(let W of L){let U=$o(W),ge=Bz(l,t,n.trace?{...n,trace:c_(n.trace,w)}:n,r,U,la(a),P);if(ge)return{result:ge,states:i};let Ze=nN(l,U.functionDefinitions);if(Ze)Je(n.derivedCommandWorkBudget,ua(Ze));let A=Ze?t+1>=ts?pd(l.displayText,n,[U]):ca(Ze,t+1,n,r,[U]):{result:null,states:[U]};if(A.result)return A;if(x.push(...md(k,A.states,f,d==="&",gr(d))),E)v.push(k),v.push(...A.states.map((Z)=>f?sa(k,Z):Z))}}let T=fd(x,v,b,y,a,d);i=T.states,s=T.conditionalStates,a=void 0}return{result:null,states:i}}function Lz(e,t,n,r,o){if(n.kind==="group"&&n.style==="subshell")return!0;if(e.dialect==="posix"&&(la(r)||la(o)))return!0;if(o==="&")return!0;return e.dialect==="powershell"&&n.kind==="group"&&n.style==="brace"&&Mz(e,t)}function md(e,t,n,r,o){let i=n?t.map((a)=>sa(e,a)):[...t],s=o?i.flatMap((a)=>Lo(e.literalHeredocFiles,a.literalHeredocFiles)?[a]:[{...a,literalHeredocFiles:new Map(e.literalHeredocFiles)},a]):i;return r?[e,...s]:s}function sa(e,t){return{...e,literalHeredocFiles:new Map(t.literalHeredocFiles)}}function Mz(e,t){let n=[...e.nodes.slice(0,t)].reverse().find((o)=>o.kind==="command"||o.kind==="connector");if(!n||n.kind!=="command")return!0;let r=n.words[0]?.text.toLowerCase();if(r==="&"||r===".")return!1;if(r==="write-output"||r==="function"||r==="start-job")return!0;if(Gz(n))return!0;return n.source.replaceAll(/\s/g,"").toLowerCase()==="if($false)"}function la(e){return e==="|"||e==="|&"}function Wz(e){if(e?.dialect!=="powershell")return;if(e.words.length===1&&e.words[0]?.quoted&&e.words[0].provenance==="literal")return e.words[0].text;if(e.words[0]?.text.toLowerCase()==="write-output"&&e.words.length===2&&e.words[1]?.provenance==="literal")return e.words[1].text;return}function gr(e){return e==="&&"||e==="||"}function fd(e,t,n,r,o,i){let s={success:aa([...n,...e]),failure:aa([...r,...t])},a=gr(i)?s:void 0;return{states:gr(o)||a?aa([...s.success,...s.failure]):s.success,conditionalStates:a}}function c_(e,t,n=e.flattenNested){return{currentSegmentIndex:t,flattenNested:n,allocateSegment:e.allocateSegment,getNextSegmentIndex:e.getNextSegmentIndex,recordGlobal:e.recordGlobal,recordSegment:(r,o=t)=>e.recordSegment(r,o)}}function Fz(e,t,n,r,o){let i=e.nested.map((s)=>({program:s,depth:t}));if(e.dialect==="powershell"){let s=Zz(e);if(s){if(t+1>=ts)return pd(s,n,o);let a=et(s,"powershell");if(a.status==="limited")return pd(s,n,o);if(a.status!=="complete")return n_(i,n,r,o);Je(n.derivedCommandWorkBudget,ua(a)),i.push({program:a,depth:t+1})}}return n_(i,n,r,o)}function Gz(e){let t=e.words[0];return t?.provenance==="variable"&&e.words.at(-1)?.text==="="?t.text.toLowerCase():void 0}function n_(e,t,n,r){let o=[...r];for(let i of e){let s=[];for(let a of o){let c=ca(i.program,i.depth,t,n,[$o(a)]);if(c.result)return c;s.push(...c.states)}o=aa(s)}return{result:null,states:o}}function Zz(e){let t=e.words[0]?.provenance==="literal"&&!e.words[0].quoted&&e.words[0].raw===e.words[0].text&&(e.words[0].text==="&"||e.words[0].text==="."),n=t?1:0,r=e.words[n];if(r?.provenance!=="literal"||!t&&(r.quoted||r.raw!==r.text)||!["iex","invoke-expression"].includes(r.text.toLowerCase()))return;let o=e.words.slice(n+1),i=o[0]&&!o[0].quoted&&o[0].raw===o[0].text&&["-c","-command"].includes(o[0].text.toLowerCase())?1:0,s=o[i];return o.length===i+1&&s?.quoted&&s.provenance==="literal"?s.text:void 0}function ua(e){return e.nodes.reduce((t,n)=>t+(n.kind==="command"?n.words.length+n.nested.reduce((r,o)=>r+ua(o),0):n.kind==="group"||n.kind==="function"?ua(n.body):0),0)}function pd(e,t,n){return t.trace?.recordSegment({type:"error",message:It}),{result:{reason:It,segment:e,intent:"stop_and_explain"},states:[...n]}}function Bz(e,t,n,r,o,i,s){let a=Yz(e);if(a&&n.strict)return n.trace?.recordSegment({type:"error",message:a}),{reason:a,segment:e.source,intent:"stop_and_explain"};l_(e,o,"before-consumer",n.environment.paths);let c=Yn(e.dialect,e.words).map(N),l=e.displayText,u=QS(c,o.shellGitContextState);if(e.dialect==="powershell"){let m=O(vv(e,i,oN(n,o.effectiveCwd)),n.policy);if(n.trace?.recordSegment({type:"rule-check",rule:"analyzer/powershell/remove-item.ts:analyzePowerShellCommandViewMatch",matched:!!m,reason:m?.reason}),m)return rN(l,m)}if(c.length===1&&c[0]?.includes(" ")&&!po(e.dialect,e.words)){let m=O(Dt(c[0],n.scanWork),n.policy),p=m!==null&&!n.strict&&$y(e,n.rootProgram,n.scanWork);if(m&&!p)return n.trace?.recordSegment({type:"dangerous-text",token:c[0],matched:!0,reason:m.reason}),{reason:m.reason,segment:l,ruleId:m.id,intent:m.intent};n.trace?.recordSegment({type:"dangerous-text",token:c[0],matched:!1});let h=r_(e,a,o,u,s,n);if(h)return h;return ud(c,o.shellGitContextState),null}let d=Do(e.words,t,{...n,commandView:e,cwd:r,effectiveCwd:o.effectiveCwd,envAssignments:u,literalHeredocFiles:o.literalHeredocFiles,functionDefinitions:o.functionDefinitions,hasPipelineInput:i,literalShellInput:s,analyzeNested:(m,p)=>{let h=p&&Object.hasOwn(p,"effectiveCwd")?p.effectiveCwd:o.effectiveCwd,b=hd(m,t+1,{...n,derivedCommandWorkBudget:n.derivedCommandWorkBudget,effectiveCwd:h,envAssignments:p?.envAssignments??u,literalHeredocFiles:o.literalHeredocFiles,functionDefinitions:p?.functionDefinitions,worktreeMode:p?.worktreeMode??n.worktreeMode,trace:n.trace?c_(n.trace,n.trace.currentSegmentIndex,!0):void 0});return b?{reason:b.reason,ruleId:b.ruleId,intent:b.intent}:null}});if(d)return{...d,segment:l};let f=r_(e,a,o,u,s,n);if(f)return f;return ud(c,o.shellGitContextState),null}function r_(e,t,n,r,o,i){let s=Jz(e,t,n,r??new Map,i);if(s)return s;return l_(e,n,"after-consumer",i.environment.paths),n.literalHeredocFiles.clear(),Hz(e,t,n,i.environment.paths),eN(e,n,o,i.environment,i.trace),null}var Uz=new Set([">>","<>"]);function l_(e,t,n,r){for(let i of e.redirections){if(!(n==="before-consumer"?jz(i):Uz.has(i.operator)))continue;o_(i.target,t,r)}if(n!=="before-consumer"||!Me(e.words[0],"tee"))return;let o=u_(e.words.slice(1));if(!o)return;for(let i of o.operands)o_(i,t,r)}function jz(e){if(e.operator===">"||e.operator===">|")return!0;return e.operator===">&"&&e.fd===void 0&&e.target?.provenance==="literal"&&!/^(?:[0-9]+|-)$/.test(e.target.text)}function o_(e,t,n){let r=e?.provenance==="literal"?co(e.text,t.effectiveCwd,n):void 0;if(!r)return;t.literalHeredocFiles.delete(r)}function Hz(e,t,n,r){if(t)return;let o=e.redirections.find((i)=>i.operator==="<<"||i.operator==="<<-")?.heredoc;if(!o?.quotedDelimiter)return;for(let i of Vz(e)){let s=co(i.text,n.effectiveCwd,r);if(!s||!Zy(s))continue;if(!n.literalHeredocFiles.has(s)&&n.literalHeredocFiles.size>=Gy)throw new Ie;n.literalHeredocFiles.set(s,o.body)}}function Vz(e){let t=Kz(e.redirections)?.target,n=i_(t)?[t]:[];if(Me(e.words[0],"cat"))return qz(e.words)?n:[];if(!Me(e.words[0],"tee"))return[];let r=u_(e.words.slice(1));if(!r||r.append||r.hasUnsupportedOptions||!r.operands.every(i_))return[];return[...r.operands,...n]}function qz(e){let t=!1;for(let n of e.slice(1)){if(t||n.provenance!=="literal")return!1;if(n.text==="--"){t=!0;continue}if(!/^-u+$/.test(n.text))return!1}return!0}function Kz(e){let t=e.findLast((n)=>(n.fd??([">",">|",">>",">&"].includes(n.operator)?1:0))===1);return t?.operator===">"||t?.operator===">|"?t:void 0}function u_(e){let t=[],n=!0,r=!1,o=!1;for(let i of e){if(i.provenance!=="literal")return;if(n&&Me(i,"--")){n=!1;continue}if(n&&!i.quoted&&i.raw===i.text&&/^-[^-]/.test(i.text)){r||=i.text.slice(1).includes("a"),o||=[...i.text.slice(1)].some((s)=>s!=="a"&&s!=="i");continue}if(n&&!i.quoted&&i.raw===i.text&&i.text.startsWith("--")){r||=i.text==="--append",o||=i.text!=="--append"&&i.text!=="--ignore-interrupts";continue}t.push(i)}return{operands:t,append:r,hasUnsupportedOptions:o}}function i_(e){if(!e||e.provenance!=="literal"||e.text.length===0)return!1;if(e.quoted||e.raw!==e.text)return!0;return!e.raw.startsWith("~")&&!/[{}]/.test(e.raw)}function Me(e,t){return e?.text===t&&e.raw===t&&e.provenance==="literal"&&!e.quoted}function Yz(e){let t=e.redirections.filter((s)=>s.operator==="<<"||s.operator==="<<-");if(t.length===0)return;if(t.length!==1)return zn;let n=t[0];if(!n?.heredoc)return zn;if(!n.heredoc.quotedDelimiter)return Nz;if(n.fd!==void 0&&n.fd!==0)return zn;if(e.redirections.some((s)=>s!==n&&["<","<<","<<-","<<<","<&","<>"].includes(s.operator)))return zn;let r=e.redirections.some((s)=>s!==n&&s_(s.target));if(Me(e.words[0],"cat"))return r?zn:void 0;if(Me(e.words[0],"tee"))return r||e.words.slice(1).some(s_)?zn:void 0;let o=e.words[0],i=e.words[1];if(Me(o,"git")&&(Me(i,"apply")||Me(i,"commit")))return;if(Me(o,"gh")&&(Me(i,"pr")||Me(i,"issue"))&&Me(e.words[2],"create"))return;return zn}function s_(e){return e?.parts.some((t)=>t.provenance==="command-substitution"&&t.raw.startsWith(">("))??!1}function Jz(e,t,n,r,o){if(!t)return null;let i=e.redirections.filter((l)=>l.operator==="<<"||l.operator==="<<-"),s=i.flatMap((l)=>l.heredoc?[l.heredoc.body]:[]);if(Qz(e,i,n,r,o))return null;let a=Xz(e,i,o);if(a!==void 0)return a?{reason:a.reason,segment:e.displayText,ruleId:a.id,intent:a.intent}:null;let c=gd(s.length===i.length?s.join(`
60
+ `):e.source,o);return c?{...c,segment:e.displayText}:null}function Xz(e,t,n){let r=t.length===1?t[0]:void 0;if(!r?.heredoc?.quotedDelimiter||r.fd!==void 0&&r.fd!==0)return;let o=e.words[0];if(o?.provenance!=="literal"||!Oe(o.text))return;if(!e.words.slice(1).every((l)=>l.provenance==="literal"&&l.text.startsWith("-")))return;let s=r.heredoc.body,a=ue(n.policy,"interpreter.one-liner-paranoid",!!n.paranoidInterpreters);if(n.trace?.recordSegment({type:"interpreter",interpreter:o.text,codeArg:s,paranoidBlocked:a}),a){let l=O(S("interpreter.one-liner-paranoid",tr),n.policy);if(l)return l}if(!nr(s,n.scanWork))return null;let c=O(S("interpreter.dangerous-command",vn),n.policy);if(!c)return null;return n.trace?.recordSegment({type:"dangerous-text",token:s,matched:!0,reason:c.reason}),c}function Qz(e,t,n,r,o){let i=t.length===1?t[0]:void 0;if(!i?.heredoc?.quotedDelimiter||i.fd!==void 0&&i.fd!==0)return!1;let s=Sn(e.words,o.environment,n.effectiveCwd,r),a=s.words.map(N),c=H(a[0]??"");if((s.envSplitValues?.length??0)>0||!de.has(c)&&!de.has(G(c)))return!1;return Ve(a)}function eN(e,t,n,r,o){let i=jS(e,t.effectiveCwd,r,n);if(i===null)o?.recordSegment({type:"cwd-change",segment:e.words.map(N).join(" "),effectiveCwdNowUnknown:!0});if(i!==void 0)t.effectiveCwd=i}function $o(e){return{effectiveCwd:e.effectiveCwd,shellGitContextState:XS(e.shellGitContextState),literalHeredocFiles:new Map(e.literalHeredocFiles),functionDefinitions:new Map(e.functionDefinitions)}}function aa(e){let t=[];for(let n of e){if(!t.some((r)=>tN(r,n)))t.push(n);if(t.length>Dz)throw new Ie}return t}function tN(e,t){return e.effectiveCwd===t.effectiveCwd&&Lo(e.literalHeredocFiles,t.literalHeredocFiles)&&Lo(e.functionDefinitions,t.functionDefinitions)&&Lo(e.shellGitContextState.effectiveEnvAssignments,t.shellGitContextState.effectiveEnvAssignments)&&Lo(e.shellGitContextState.shellAssignments,t.shellGitContextState.shellAssignments)}function Lo(e,t){if(e===t)return!0;if(!e||!t||e.size!==t.size)return!1;return[...e].every(([n,r])=>t.get(n)===r&&t.has(n))}function nN(e,t){let n=ks(e);return n===void 0?void 0:t.get(n)}function rN(e,t){if(!t)return null;return{reason:t.reason,segment:e,ruleId:t.id,intent:t.intent}}function oN(e,t=e.effectiveCwd){let n=t===null;return{environment:e.environment,cwd:n?void 0:t??e.cwd,originalCwd:n?void 0:e.cwd,strict:e.strict,paranoid:e.paranoidRm,allowTmpdirVar:e.allowTmpdirVar,protectedGitMetadata:e.protectedGitMetadata,policy:e.policy}}function gd(e,t){let n=O(Dt(e,t.scanWork),t.policy),r=t.trace?.currentSegmentIndex??t.trace?.allocateSegment(),o={type:"dangerous-text",token:e,matched:!!n,reason:n?.reason};if(t.trace?.recordSegment(o,r),!n&&/^(?:cd|pushd)\s/.test(e))t.trace?.recordSegment({type:"cwd-change",segment:e,effectiveCwdNowUnknown:!0},r);return n?{reason:n.reason,segment:e,ruleId:n.id,intent:n.intent}:null}function a_(e,t){let n={type:"strict-unparseable",rawCommand:e,reason:qt};if(t.trace?.currentSegmentIndex===void 0)t.trace?.recordGlobal(n);else t.trace.recordSegment(n)}var me={level:{name:"CC_SAFETY_NET_LEVEL"},strict:{name:"CC_SAFETY_NET_STRICT",legacyName:"SAFETY_NET_STRICT"},paranoid:{name:"CC_SAFETY_NET_PARANOID",legacyName:"SAFETY_NET_PARANOID"},paranoidRm:{name:"CC_SAFETY_NET_PARANOID_RM",legacyName:"SAFETY_NET_PARANOID_RM"},paranoidInterpreters:{name:"CC_SAFETY_NET_PARANOID_INTERPRETERS",legacyName:"SAFETY_NET_PARANOID_INTERPRETERS"},worktree:{name:"CC_SAFETY_NET_WORKTREE",legacyName:"SAFETY_NET_WORKTREE"},debug:{name:"CC_SAFETY_NET_DEBUG"},auditScope:{name:"CC_SAFETY_NET_AUDIT_SCOPE"}},da=["standard","strict","paranoid"];function iN(e){return{failClosed:e==="strict"||e==="paranoid",paranoidRm:e==="paranoid",paranoidInterpreters:e==="paranoid"}}function sN(e,t){if(!t)return e;return da.indexOf(t)>da.indexOf(e)?t:e}function aN(){let e=_d(me.level);if(e===void 0||e==="")return;if(da.includes(e))return e;console.error(`CC Safety Net: ignored invalid ${me.level.name}=${JSON.stringify(e.slice(0,40))}. Use ${da.join(", ")}.`);return}function cN(e){if(e===void 0||e==="all")return"all";if(e==="blocked")return"blocked";return"invalid"}function bd(){return cN(_d(me.auditScope))==="all"}function vd(e){if(e.failClosed&&e.paranoidRm&&e.paranoidInterpreters)return"paranoid";if(e.failClosed&&!e.paranoidRm&&!e.paranoidInterpreters)return"strict";if(!e.failClosed&&!e.paranoidRm&&!e.paranoidInterpreters)return"standard";return"custom"}function Sd(e={}){let t=e.safety?.level??"standard",n=aN(),r=sN(t,n),o=iN(r),i={failClosed:r===t?"preset":"environment",paranoidRm:r===t?"preset":"environment",paranoidInterpreters:r===t?"preset":"environment"},s={failClosed:[`policy safety.level=${t}`],paranoidRm:[`policy safety.level=${t}`],paranoidInterpreters:[`policy safety.level=${t}`]};if(r!==t)s.failClosed.push(`env ${me.level.name}=${n}`),s.paranoidRm.push(`env ${me.level.name}=${n}`),s.paranoidInterpreters.push(`env ${me.level.name}=${n}`);if(e.safety?.overrides?.failClosed!==void 0)o.failClosed=e.safety.overrides.failClosed,i.failClosed="capability_override",s.failClosed.push("policy safety.overrides.fail_closed");if(e.safety?.overrides?.paranoidRm!==void 0)o.paranoidRm=e.safety.overrides.paranoidRm,i.paranoidRm="capability_override",s.paranoidRm.push("policy safety.overrides.paranoid_rm");if(e.safety?.overrides?.paranoidInterpreters!==void 0)o.paranoidInterpreters=e.safety.overrides.paranoidInterpreters,i.paranoidInterpreters="capability_override",s.paranoidInterpreters.push("policy safety.overrides.paranoid_interpreters");if(nn(me.strict))o.failClosed=!0,i.failClosed="environment",s.failClosed.push(`env ${me.strict.name}`);if(nn(me.paranoid))o.paranoidRm=!0,o.paranoidInterpreters=!0,i.paranoidRm="environment",i.paranoidInterpreters="environment",s.paranoidRm.push(`env ${me.paranoid.name}`),s.paranoidInterpreters.push(`env ${me.paranoid.name}`);if(nn(me.paranoidRm))o.paranoidRm=!0,i.paranoidRm="environment",s.paranoidRm.push(`env ${me.paranoidRm.name}`);if(nn(me.paranoidInterpreters))o.paranoidInterpreters=!0,i.paranoidInterpreters="environment",s.paranoidInterpreters.push(`env ${me.paranoidInterpreters.name}`);let a=!!e.worktreeMode||nn(me.worktree);return{strict:o.failClosed,paranoidRm:o.paranoidRm,paranoidInterpreters:o.paranoidInterpreters,worktreeMode:a,effectiveLevel:vd(o),capabilities:{fail_closed:{enabled:o.failClosed,source:i.failClosed,sources:s.failClosed},paranoid_rm:{enabled:o.paranoidRm,source:i.paranoidRm,sources:s.paranoidRm},paranoid_interpreters:{enabled:o.paranoidInterpreters,source:i.paranoidInterpreters,sources:s.paranoidInterpreters}}}}function nn(e){let t=typeof e==="string"?yd(e):_d(e);return t==="1"||t?.toLowerCase()==="true"}function yd(e){return Object.hasOwn(process.env,e)?process.env[e]:void 0}function _d(e){let t=yd(e.name);if(t!==void 0)return t;if(e.legacyName)return yd(e.legacyName);return}function d_(e){let t=e.effectiveCapabilities,n=e.strict??t.fail_closed.enabled,r=e.paranoidRm??t.paranoid_rm.enabled,o=e.paranoidInterpreters??t.paranoid_interpreters.enabled,i={fail_closed:xd(t.fail_closed,e.strict,"strict"),paranoid_rm:xd(t.paranoid_rm,e.paranoidRm,"paranoidRm"),paranoid_interpreters:xd(t.paranoid_interpreters,e.paranoidInterpreters,"paranoidInterpreters")};return{policy:Ny(e.policySnapshot.policy,i),effectiveCapabilities:i,effectiveLevel:vd({failClosed:n,paranoidRm:r,paranoidInterpreters:o}),strict:n,paranoidRm:r,paranoidInterpreters:o,worktreeMode:e.worktreeMode??!1}}function xd(e,t,n){if(t===void 0||t===e.enabled)return e;return{enabled:t,source:"capability_override",sources:[...e.sources,`analysis options.${n}`]}}function m_(e,t,n,r){let o=hd(e,0,{...t,...d_(t),factStore:r},n);if(!o)return null;return{kind:"deny",reason:o.reason,intent:o.intent??"manual_only",...o.ruleId?{ruleId:o.ruleId}:{},evidence:[{kind:"command",command:e,segment:o.segment}]}}import{basename as k$,dirname as hh}from"node:path";function ma(e,t,n,r,o){if(n.kind!=="command")return{toolName:e,input:t,route:n,context:r};return{toolName:e,input:t,route:n,context:r,command:o}}import{chmodSync as OU,existsSync as g$,mkdirSync as zU,readFileSync as h$}from"node:fs";import{dirname as y$,join as b$}from"node:path";import{createRequire as n$}from"node:module";var sh={};dn(sh,{$brand:()=>pa,$input:()=>ja,$output:()=>Ua,NEVER:()=>fa,TimePrecision:()=>mc,ZodAny:()=>Sg,ZodArray:()=>wg,ZodBase64:()=>Kc,ZodBase64URL:()=>Yc,ZodBigInt:()=>qr,ZodBigIntFormat:()=>Qc,ZodBoolean:()=>Vr,ZodCIDRv4:()=>Vc,ZodCIDRv6:()=>qc,ZodCUID:()=>Fc,ZodCUID2:()=>Gc,ZodCatch:()=>Hg,ZodCodec:()=>al,ZodCustom:()=>bi,ZodCustomStringFormat:()=>jr,ZodDate:()=>fi,ZodDefault:()=>Fg,ZodDiscriminatedUnion:()=>Rg,ZodE164:()=>Jc,ZodEmail:()=>Lc,ZodEmoji:()=>Mc,ZodEnum:()=>Br,ZodError:()=>H_,ZodExactOptional:()=>Lg,ZodFile:()=>Dg,ZodFirstPartyTypeKind:()=>cl,ZodFunction:()=>th,ZodGUID:()=>ci,ZodIPv4:()=>jc,ZodIPv6:()=>Hc,ZodISODate:()=>oi,ZodISODateTime:()=>ri,ZodISODuration:()=>si,ZodISOTime:()=>ii,ZodIntersection:()=>Pg,ZodIssueCode:()=>aC,ZodJWT:()=>Xc,ZodKSUID:()=>Uc,ZodLazy:()=>Xg,ZodLiteral:()=>Ng,ZodMAC:()=>fg,ZodMap:()=>Og,ZodNaN:()=>qg,ZodNanoID:()=>Wc,ZodNever:()=>xg,ZodNonOptional:()=>il,ZodNull:()=>bg,ZodNullable:()=>Wg,ZodNumber:()=>Hr,ZodNumberFormat:()=>Zn,ZodObject:()=>gi,ZodOptional:()=>ol,ZodPipe:()=>sl,ZodPrefault:()=>Zg,ZodPromise:()=>eh,ZodReadonly:()=>Kg,ZodRealError:()=>xe,ZodRecord:()=>yi,ZodSet:()=>zg,ZodString:()=>Ur,ZodStringFormat:()=>K,ZodSuccess:()=>jg,ZodSymbol:()=>hg,ZodTemplateLiteral:()=>Jg,ZodTransform:()=>$g,ZodTuple:()=>Ag,ZodType:()=>M,ZodULID:()=>Zc,ZodURL:()=>mi,ZodUUID:()=>Rt,ZodUndefined:()=>yg,ZodUnion:()=>hi,ZodUnknown:()=>_g,ZodVoid:()=>Cg,ZodXID:()=>Bc,ZodXor:()=>Eg,_ZodString:()=>$c,_default:()=>Gg,_function:()=>Xx,any:()=>Tx,array:()=>pi,base64:()=>fx,base64url:()=>px,bigint:()=>Ex,boolean:()=>gg,catch:()=>Vg,check:()=>Qx,cidrv4:()=>dx,cidrv6:()=>mx,clone:()=>ye,codec:()=>Kx,coerce:()=>ll,config:()=>se,core:()=>Et,cuid:()=>rx,cuid2:()=>ox,custom:()=>eC,date:()=>Ox,decode:()=>Pc,decodeAsync:()=>Ac,default:()=>JD,describe:()=>tC,discriminatedUnion:()=>Mx,e164:()=>gx,email:()=>V_,emoji:()=>tx,encode:()=>Rc,encodeAsync:()=>kc,endsWith:()=>Ir,enum:()=>nl,exactOptional:()=>Mg,file:()=>jx,flattenError:()=>vr,float32:()=>_x,float64:()=>xx,formatError:()=>Sr,fromJSONSchema:()=>ih,function:()=>Xx,getErrorMap:()=>lC,globalRegistry:()=>Ae,gt:()=>Ct,gte:()=>_e,guid:()=>q_,hash:()=>Sx,hex:()=>vx,hostname:()=>bx,httpUrl:()=>ex,includes:()=>Ar,instanceof:()=>rC,int:()=>Dc,int32:()=>Cx,int64:()=>Rx,intersection:()=>kg,ipv4:()=>cx,ipv6:()=>ux,iso:()=>ai,json:()=>iC,jwt:()=>hx,keyof:()=>zx,ksuid:()=>ax,lazy:()=>Qg,length:()=>Fn,literal:()=>Ux,locales:()=>Xo,looseObject:()=>$x,looseRecord:()=>Fx,lowercase:()=>Pr,lt:()=>xt,lte:()=>Ge,mac:()=>lx,map:()=>Gx,maxLength:()=>Wn,maxSize:()=>ln,meta:()=>nC,mime:()=>Or,minLength:()=>Ft,minSize:()=>wt,multipleOf:()=>cn,nan:()=>qx,nanoid:()=>nx,nativeEnum:()=>Bx,negative:()=>pc,never:()=>el,nonnegative:()=>hc,nonoptional:()=>Ug,nonpositive:()=>gc,normalize:()=>zr,null:()=>vg,nullable:()=>ui,nullish:()=>Hx,number:()=>pg,object:()=>Nx,optional:()=>li,overwrite:()=>st,parse:()=>xc,parseAsync:()=>Cc,partialRecord:()=>Wx,pipe:()=>di,positive:()=>fc,prefault:()=>Bg,preprocess:()=>sC,prettifyError:()=>Sa,promise:()=>Jx,property:()=>yc,readonly:()=>Yg,record:()=>Ig,refine:()=>nh,regex:()=>Rr,regexes:()=>Fe,registry:()=>Qo,safeDecode:()=>Ic,safeDecodeAsync:()=>zc,safeEncode:()=>Tc,safeEncodeAsync:()=>Oc,safeParse:()=>wc,safeParseAsync:()=>Ec,set:()=>Zx,setErrorMap:()=>cC,size:()=>Mn,slugify:()=>Lr,startsWith:()=>Tr,strictObject:()=>Dx,string:()=>Nc,stringFormat:()=>yx,stringbool:()=>oC,success:()=>Vx,superRefine:()=>rh,symbol:()=>kx,templateLiteral:()=>Yx,toJSONSchema:()=>ni,toLowerCase:()=>Dr,toUpperCase:()=>$r,transform:()=>rl,treeifyError:()=>va,trim:()=>Nr,tuple:()=>Tg,uint32:()=>wx,uint64:()=>Px,ulid:()=>ix,undefined:()=>Ax,union:()=>tl,unknown:()=>Gn,uppercase:()=>kr,url:()=>Q_,util:()=>I,uuid:()=>K_,uuidv4:()=>Y_,uuidv6:()=>J_,uuidv7:()=>X_,void:()=>Ix,xid:()=>sx,xor:()=>Lx,z:()=>ul});var ul={};dn(ul,{$brand:()=>pa,$input:()=>ja,$output:()=>Ua,NEVER:()=>fa,TimePrecision:()=>mc,ZodAny:()=>Sg,ZodArray:()=>wg,ZodBase64:()=>Kc,ZodBase64URL:()=>Yc,ZodBigInt:()=>qr,ZodBigIntFormat:()=>Qc,ZodBoolean:()=>Vr,ZodCIDRv4:()=>Vc,ZodCIDRv6:()=>qc,ZodCUID:()=>Fc,ZodCUID2:()=>Gc,ZodCatch:()=>Hg,ZodCodec:()=>al,ZodCustom:()=>bi,ZodCustomStringFormat:()=>jr,ZodDate:()=>fi,ZodDefault:()=>Fg,ZodDiscriminatedUnion:()=>Rg,ZodE164:()=>Jc,ZodEmail:()=>Lc,ZodEmoji:()=>Mc,ZodEnum:()=>Br,ZodError:()=>H_,ZodExactOptional:()=>Lg,ZodFile:()=>Dg,ZodFirstPartyTypeKind:()=>cl,ZodFunction:()=>th,ZodGUID:()=>ci,ZodIPv4:()=>jc,ZodIPv6:()=>Hc,ZodISODate:()=>oi,ZodISODateTime:()=>ri,ZodISODuration:()=>si,ZodISOTime:()=>ii,ZodIntersection:()=>Pg,ZodIssueCode:()=>aC,ZodJWT:()=>Xc,ZodKSUID:()=>Uc,ZodLazy:()=>Xg,ZodLiteral:()=>Ng,ZodMAC:()=>fg,ZodMap:()=>Og,ZodNaN:()=>qg,ZodNanoID:()=>Wc,ZodNever:()=>xg,ZodNonOptional:()=>il,ZodNull:()=>bg,ZodNullable:()=>Wg,ZodNumber:()=>Hr,ZodNumberFormat:()=>Zn,ZodObject:()=>gi,ZodOptional:()=>ol,ZodPipe:()=>sl,ZodPrefault:()=>Zg,ZodPromise:()=>eh,ZodReadonly:()=>Kg,ZodRealError:()=>xe,ZodRecord:()=>yi,ZodSet:()=>zg,ZodString:()=>Ur,ZodStringFormat:()=>K,ZodSuccess:()=>jg,ZodSymbol:()=>hg,ZodTemplateLiteral:()=>Jg,ZodTransform:()=>$g,ZodTuple:()=>Ag,ZodType:()=>M,ZodULID:()=>Zc,ZodURL:()=>mi,ZodUUID:()=>Rt,ZodUndefined:()=>yg,ZodUnion:()=>hi,ZodUnknown:()=>_g,ZodVoid:()=>Cg,ZodXID:()=>Bc,ZodXor:()=>Eg,_ZodString:()=>$c,_default:()=>Gg,_function:()=>Xx,any:()=>Tx,array:()=>pi,base64:()=>fx,base64url:()=>px,bigint:()=>Ex,boolean:()=>gg,catch:()=>Vg,check:()=>Qx,cidrv4:()=>dx,cidrv6:()=>mx,clone:()=>ye,codec:()=>Kx,coerce:()=>ll,config:()=>se,core:()=>Et,cuid:()=>rx,cuid2:()=>ox,custom:()=>eC,date:()=>Ox,decode:()=>Pc,decodeAsync:()=>Ac,describe:()=>tC,discriminatedUnion:()=>Mx,e164:()=>gx,email:()=>V_,emoji:()=>tx,encode:()=>Rc,encodeAsync:()=>kc,endsWith:()=>Ir,enum:()=>nl,exactOptional:()=>Mg,file:()=>jx,flattenError:()=>vr,float32:()=>_x,float64:()=>xx,formatError:()=>Sr,fromJSONSchema:()=>ih,function:()=>Xx,getErrorMap:()=>lC,globalRegistry:()=>Ae,gt:()=>Ct,gte:()=>_e,guid:()=>q_,hash:()=>Sx,hex:()=>vx,hostname:()=>bx,httpUrl:()=>ex,includes:()=>Ar,instanceof:()=>rC,int:()=>Dc,int32:()=>Cx,int64:()=>Rx,intersection:()=>kg,ipv4:()=>cx,ipv6:()=>ux,iso:()=>ai,json:()=>iC,jwt:()=>hx,keyof:()=>zx,ksuid:()=>ax,lazy:()=>Qg,length:()=>Fn,literal:()=>Ux,locales:()=>Xo,looseObject:()=>$x,looseRecord:()=>Fx,lowercase:()=>Pr,lt:()=>xt,lte:()=>Ge,mac:()=>lx,map:()=>Gx,maxLength:()=>Wn,maxSize:()=>ln,meta:()=>nC,mime:()=>Or,minLength:()=>Ft,minSize:()=>wt,multipleOf:()=>cn,nan:()=>qx,nanoid:()=>nx,nativeEnum:()=>Bx,negative:()=>pc,never:()=>el,nonnegative:()=>hc,nonoptional:()=>Ug,nonpositive:()=>gc,normalize:()=>zr,null:()=>vg,nullable:()=>ui,nullish:()=>Hx,number:()=>pg,object:()=>Nx,optional:()=>li,overwrite:()=>st,parse:()=>xc,parseAsync:()=>Cc,partialRecord:()=>Wx,pipe:()=>di,positive:()=>fc,prefault:()=>Bg,preprocess:()=>sC,prettifyError:()=>Sa,promise:()=>Jx,property:()=>yc,readonly:()=>Yg,record:()=>Ig,refine:()=>nh,regex:()=>Rr,regexes:()=>Fe,registry:()=>Qo,safeDecode:()=>Ic,safeDecodeAsync:()=>zc,safeEncode:()=>Tc,safeEncodeAsync:()=>Oc,safeParse:()=>wc,safeParseAsync:()=>Ec,set:()=>Zx,setErrorMap:()=>cC,size:()=>Mn,slugify:()=>Lr,startsWith:()=>Tr,strictObject:()=>Dx,string:()=>Nc,stringFormat:()=>yx,stringbool:()=>oC,success:()=>Vx,superRefine:()=>rh,symbol:()=>kx,templateLiteral:()=>Yx,toJSONSchema:()=>ni,toLowerCase:()=>Dr,toUpperCase:()=>$r,transform:()=>rl,treeifyError:()=>va,trim:()=>Nr,tuple:()=>Tg,uint32:()=>wx,uint64:()=>Px,ulid:()=>ix,undefined:()=>Ax,union:()=>tl,unknown:()=>Gn,uppercase:()=>kr,url:()=>Q_,util:()=>I,uuid:()=>K_,uuidv4:()=>Y_,uuidv6:()=>J_,uuidv7:()=>X_,void:()=>Ix,xid:()=>sx,xor:()=>Lx});var Et={};dn(Et,{$ZodAny:()=>af,$ZodArray:()=>mf,$ZodAsyncError:()=>_t,$ZodBase64:()=>Ym,$ZodBase64URL:()=>Jm,$ZodBigInt:()=>Ga,$ZodBigIntFormat:()=>nf,$ZodBoolean:()=>Ko,$ZodCIDRv4:()=>Vm,$ZodCIDRv6:()=>qm,$ZodCUID:()=>Dm,$ZodCUID2:()=>$m,$ZodCatch:()=>Tf,$ZodCheck:()=>J,$ZodCheckBigIntFormat:()=>dm,$ZodCheckEndsWith:()=>Cm,$ZodCheckGreaterThan:()=>za,$ZodCheckIncludes:()=>_m,$ZodCheckLengthEquals:()=>ym,$ZodCheckLessThan:()=>Oa,$ZodCheckLowerCase:()=>vm,$ZodCheckMaxLength:()=>gm,$ZodCheckMaxSize:()=>mm,$ZodCheckMimeType:()=>Em,$ZodCheckMinLength:()=>hm,$ZodCheckMinSize:()=>fm,$ZodCheckMultipleOf:()=>lm,$ZodCheckNumberFormat:()=>um,$ZodCheckOverwrite:()=>Rm,$ZodCheckProperty:()=>wm,$ZodCheckRegex:()=>bm,$ZodCheckSizeEquals:()=>pm,$ZodCheckStartsWith:()=>xm,$ZodCheckStringFormat:()=>Er,$ZodCheckUpperCase:()=>Sm,$ZodCodec:()=>Jo,$ZodCustom:()=>Mf,$ZodCustomStringFormat:()=>ef,$ZodDate:()=>df,$ZodDefault:()=>Rf,$ZodDiscriminatedUnion:()=>gf,$ZodE164:()=>Xm,$ZodEmail:()=>Im,$ZodEmoji:()=>zm,$ZodEncodeError:()=>Nn,$ZodEnum:()=>Sf,$ZodError:()=>jo,$ZodExactOptional:()=>wf,$ZodFile:()=>xf,$ZodFunction:()=>Df,$ZodGUID:()=>Am,$ZodIPv4:()=>Um,$ZodIPv6:()=>jm,$ZodISODate:()=>Gm,$ZodISODateTime:()=>Fm,$ZodISODuration:()=>Bm,$ZodISOTime:()=>Zm,$ZodIntersection:()=>hf,$ZodJWT:()=>Qm,$ZodKSUID:()=>Wm,$ZodLazy:()=>Lf,$ZodLiteral:()=>_f,$ZodMAC:()=>Hm,$ZodMap:()=>bf,$ZodNaN:()=>If,$ZodNanoID:()=>Nm,$ZodNever:()=>lf,$ZodNonOptional:()=>kf,$ZodNull:()=>sf,$ZodNullable:()=>Ef,$ZodNumber:()=>Fa,$ZodNumberFormat:()=>tf,$ZodObject:()=>F_,$ZodObjectJIT:()=>ff,$ZodOptional:()=>Ba,$ZodPipe:()=>Of,$ZodPrefault:()=>Pf,$ZodPromise:()=>$f,$ZodReadonly:()=>zf,$ZodRealError:()=>ke,$ZodRecord:()=>yf,$ZodRegistry:()=>Wf,$ZodSet:()=>vf,$ZodString:()=>Ln,$ZodStringFormat:()=>q,$ZodSuccess:()=>Af,$ZodSymbol:()=>rf,$ZodTemplateLiteral:()=>Nf,$ZodTransform:()=>Cf,$ZodTuple:()=>Za,$ZodType:()=>D,$ZodULID:()=>Lm,$ZodURL:()=>Om,$ZodUUID:()=>Tm,$ZodUndefined:()=>of,$ZodUnion:()=>Yo,$ZodUnknown:()=>cf,$ZodVoid:()=>uf,$ZodXID:()=>Mm,$ZodXor:()=>pf,$brand:()=>pa,$constructor:()=>g,$input:()=>ja,$output:()=>Ua,Doc:()=>Na,JSONSchema:()=>B_,JSONSchemaGenerator:()=>cg,NEVER:()=>fa,TimePrecision:()=>mc,_any:()=>lp,_array:()=>hp,_base64:()=>cc,_base64url:()=>lc,_bigint:()=>np,_boolean:()=>ep,_catch:()=>DD,_check:()=>Z_,_cidrv4:()=>sc,_cidrv6:()=>ac,_coercedBigint:()=>rp,_coercedBoolean:()=>tp,_coercedDate:()=>pp,_coercedNumber:()=>qf,_coercedString:()=>Gf,_cuid:()=>Qa,_cuid2:()=>ec,_custom:()=>bp,_date:()=>fp,_decode:()=>wa,_decodeAsync:()=>Ra,_default:()=>OD,_discriminatedUnion:()=>SD,_e164:()=>uc,_email:()=>Ha,_emoji:()=>Ja,_encode:()=>Ca,_encodeAsync:()=>Ea,_endsWith:()=>Ir,_enum:()=>RD,_file:()=>yp,_float32:()=>Yf,_float64:()=>Jf,_gt:()=>Ct,_gte:()=>_e,_guid:()=>ei,_includes:()=>Ar,_int:()=>Kf,_int32:()=>Xf,_int64:()=>op,_intersection:()=>_D,_ipv4:()=>oc,_ipv6:()=>ic,_isoDate:()=>Uf,_isoDateTime:()=>Bf,_isoDuration:()=>Hf,_isoTime:()=>jf,_jwt:()=>dc,_ksuid:()=>rc,_lazy:()=>WD,_length:()=>Fn,_literal:()=>kD,_lowercase:()=>Pr,_lt:()=>xt,_lte:()=>Ge,_mac:()=>Zf,_map:()=>wD,_max:()=>Ge,_maxLength:()=>Wn,_maxSize:()=>ln,_mime:()=>Or,_min:()=>_e,_minLength:()=>Ft,_minSize:()=>wt,_multipleOf:()=>cn,_nan:()=>gp,_nanoid:()=>Xa,_nativeEnum:()=>PD,_negative:()=>pc,_never:()=>dp,_nonnegative:()=>hc,_nonoptional:()=>zD,_nonpositive:()=>gc,_normalize:()=>zr,_null:()=>cp,_nullable:()=>ID,_number:()=>Vf,_optional:()=>TD,_overwrite:()=>st,_parse:()=>_r,_parseAsync:()=>xr,_pipe:()=>$D,_positive:()=>fc,_promise:()=>FD,_property:()=>yc,_readonly:()=>LD,_record:()=>CD,_refine:()=>vp,_regex:()=>Rr,_safeDecode:()=>ka,_safeDecodeAsync:()=>Ta,_safeEncode:()=>Pa,_safeEncodeAsync:()=>Aa,_safeParse:()=>Cr,_safeParseAsync:()=>wr,_set:()=>ED,_size:()=>Mn,_slugify:()=>Lr,_startsWith:()=>Tr,_string:()=>Ff,_stringFormat:()=>Mr,_stringbool:()=>Cp,_success:()=>ND,_superRefine:()=>Sp,_symbol:()=>sp,_templateLiteral:()=>MD,_toLowerCase:()=>Dr,_toUpperCase:()=>$r,_transform:()=>AD,_trim:()=>Nr,_tuple:()=>xD,_uint32:()=>Qf,_uint64:()=>ip,_ulid:()=>tc,_undefined:()=>ap,_union:()=>bD,_unknown:()=>up,_uppercase:()=>kr,_url:()=>ti,_uuid:()=>Va,_uuidv4:()=>qa,_uuidv6:()=>Ka,_uuidv7:()=>Ya,_void:()=>mp,_xid:()=>nc,_xor:()=>vD,clone:()=>ye,config:()=>se,createStandardJSONSchemaMethod:()=>bc,createToJSONSchemaMethod:()=>wp,decode:()=>$N,decodeAsync:()=>MN,describe:()=>_p,encode:()=>DN,encodeAsync:()=>LN,extractDefs:()=>Gr,finalize:()=>Zr,flattenError:()=>vr,formatError:()=>Sr,globalConfig:()=>Mo,globalRegistry:()=>Ae,initializeContext:()=>Fr,isValidBase64:()=>Km,isValidBase64URL:()=>$_,isValidJWT:()=>L_,locales:()=>Xo,meta:()=>xp,parse:()=>_a,parseAsync:()=>xa,prettifyError:()=>Sa,process:()=>X,regexes:()=>Fe,registry:()=>Qo,safeDecode:()=>FN,safeDecodeAsync:()=>ZN,safeEncode:()=>WN,safeEncodeAsync:()=>GN,safeParse:()=>zd,safeParseAsync:()=>Nd,toDotPath:()=>b_,toJSONSchema:()=>ni,treeifyError:()=>va,util:()=>I,version:()=>Pm});var fa=Object.freeze({status:"aborted"});function g(e,t,n){function r(a,c){if(!a._zod)Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1});if(a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let l=s.prototype,u=Object.keys(l);for(let d=0;d<u.length;d++){let f=u[d];if(!(f in a))a[f]=l[f].bind(a)}}let o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function s(a){var c;let l=n?.Parent?new i:this;r(l,a),(c=l._zod).deferred??(c.deferred=[]);for(let u of l._zod.deferred)u();return l}return Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:(a)=>{if(n?.Parent&&a instanceof n.Parent)return!0;return a?._zod?.traits?.has(e)}}),Object.defineProperty(s,"name",{value:e}),s}var pa=Symbol("zod_brand");class _t extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Nn extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}var Mo={};function se(e){if(e)Object.assign(Mo,e);return Mo}var I={};dn(I,{BIGINT_FORMAT_RANGES:()=>Id,Class:()=>h_,NUMBER_FORMAT_RANGES:()=>Td,aborted:()=>an,allowsEval:()=>Rd,assert:()=>fN,assertEqual:()=>lN,assertIs:()=>dN,assertNever:()=>mN,assertNotEqual:()=>uN,assignProp:()=>on,base64ToUint8Array:()=>p_,base64urlToUint8Array:()=>TN,cached:()=>yr,captureStackTrace:()=>ya,cleanEnum:()=>AN,cleanRegex:()=>Go,clone:()=>ye,cloneDef:()=>gN,createTransparentProxy:()=>_N,defineLazy:()=>F,esc:()=>ha,escapeRegex:()=>Ke,extend:()=>wN,finalizeIssue:()=>Pe,floatSafeRemainder:()=>wd,getElementAtPath:()=>hN,getEnumValues:()=>Fo,getLengthableOrigin:()=>Uo,getParsedType:()=>SN,getSizableOrigin:()=>Bo,hexToUint8Array:()=>ON,isObject:()=>Dn,isPlainObject:()=>sn,issue:()=>br,joinValues:()=>ga,jsonStringifyReplacer:()=>hr,merge:()=>RN,mergeDefs:()=>Wt,normalizeParams:()=>_,nullish:()=>rn,numKeys:()=>vN,objectClone:()=>pN,omit:()=>CN,optionalKeys:()=>Ad,parsedType:()=>Od,partial:()=>PN,pick:()=>xN,prefixIssues:()=>We,primitiveTypes:()=>kd,promiseAllObject:()=>yN,propertyKeyTypes:()=>Zo,randomString:()=>bN,required:()=>kN,safeExtend:()=>EN,shallowClone:()=>Pd,slugify:()=>Ed,stringifyPrimitive:()=>ba,uint8ArrayToBase64:()=>g_,uint8ArrayToBase64url:()=>IN,uint8ArrayToHex:()=>zN,unwrapMessage:()=>Wo});function lN(e){return e}function uN(e){return e}function dN(e){}function mN(e){throw Error("Unexpected value in exhaustive check")}function fN(e){}function Fo(e){let t=Object.values(e).filter((r)=>typeof r==="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function ga(e,t="|"){return e.map((n)=>ba(n)).join(t)}function hr(e,t){if(typeof t==="bigint")return t.toString();return t}function yr(e){return{get value(){{let n=e();return Object.defineProperty(this,"value",{value:n}),n}throw Error("cached value already set")}}}function rn(e){return e===null||e===void 0}function Go(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function wd(e,t){let n=(e.toString().split(".")[1]||"").length,r=t.toString(),o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){let c=r.match(/\d?e-(\d?)/);if(c?.[1])o=Number.parseInt(c[1])}let i=n>o?n:o,s=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return s%a/10**i}var f_=Symbol("evaluating");function F(e,t,n){let r=void 0;Object.defineProperty(e,t,{get(){if(r===f_)return;if(r===void 0)r=f_,r=n();return r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function pN(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function on(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Wt(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function gN(e){return Wt(e._zod.def)}function hN(e,t){if(!t)return e;return t.reduce((n,r)=>n?.[r],e)}function yN(e){let t=Object.keys(e),n=t.map((r)=>e[r]);return Promise.all(n).then((r)=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=r[i];return o})}function bN(e=10){let n="";for(let r=0;r<e;r++)n+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return n}function ha(e){return JSON.stringify(e)}function Ed(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var ya="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Dn(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Rd=yr(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function sn(e){if(Dn(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let n=t.prototype;if(Dn(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function Pd(e){if(sn(e))return{...e};if(Array.isArray(e))return[...e];return e}function vN(e){let t=0;for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n))t++;return t}var SN=(e)=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(e))return"array";if(e===null)return"null";if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function")return"promise";if(typeof Map<"u"&&e instanceof Map)return"map";if(typeof Set<"u"&&e instanceof Set)return"set";if(typeof Date<"u"&&e instanceof Date)return"date";if(typeof File<"u"&&e instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${t}`)}},Zo=new Set(["string","number","symbol"]),kd=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Ke(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ye(e,t,n){let r=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)r._zod.parent=e;return r}function _(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function _N(e){let t;return new Proxy({},{get(n,r,o){return t??(t=e()),Reflect.get(t,r,o)},set(n,r,o,i){return t??(t=e()),Reflect.set(t,r,o,i)},has(n,r){return t??(t=e()),Reflect.has(t,r)},deleteProperty(n,r){return t??(t=e()),Reflect.deleteProperty(t,r)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,o){return t??(t=e()),Reflect.defineProperty(t,r,o)}})}function ba(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Ad(e){return Object.keys(e).filter((t)=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Td={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Id={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function xN(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i=Wt(e._zod.def,{get shape(){let s={};for(let a in t){if(!(a in n.shape))throw Error(`Unrecognized key: "${a}"`);if(!t[a])continue;s[a]=n.shape[a]}return on(this,"shape",s),s},checks:[]});return ye(e,i)}function CN(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=Wt(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let a in t){if(!(a in n.shape))throw Error(`Unrecognized key: "${a}"`);if(!t[a])continue;delete s[a]}return on(this,"shape",s),s},checks:[]});return ye(e,i)}function wN(e,t){if(!sn(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let i=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=Wt(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return on(this,"shape",i),i}});return ye(e,o)}function EN(e,t){if(!sn(t))throw Error("Invalid input to safeExtend: expected a plain object");let n=Wt(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return on(this,"shape",r),r}});return ye(e,n)}function RN(e,t){let n=Wt(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return on(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return ye(e,n)}function PN(e,t,n){let o=t._zod.def.checks;if(o&&o.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let s=Wt(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(n)for(let l in n){if(!(l in a))throw Error(`Unrecognized key: "${l}"`);if(!n[l])continue;c[l]=e?new e({type:"optional",innerType:a[l]}):a[l]}else for(let l in a)c[l]=e?new e({type:"optional",innerType:a[l]}):a[l];return on(this,"shape",c),c},checks:[]});return ye(t,s)}function kN(e,t,n){let r=Wt(t._zod.def,{get shape(){let o=t._zod.def.shape,i={...o};if(n)for(let s in n){if(!(s in i))throw Error(`Unrecognized key: "${s}"`);if(!n[s])continue;i[s]=new e({type:"nonoptional",innerType:o[s]})}else for(let s in o)i[s]=new e({type:"nonoptional",innerType:o[s]});return on(this,"shape",i),i}});return ye(t,r)}function an(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function We(e,t){return t.map((n)=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Wo(e){return typeof e==="string"?e:e?.message}function Pe(e,t,n){let r={...e,path:e.path??[]};if(!e.message){let o=Wo(e.inst?._zod.def?.error?.(e))??Wo(t?.error?.(e))??Wo(n.customError?.(e))??Wo(n.localeError?.(e))??"Invalid input";r.message=o}if(delete r.inst,delete r.continue,!t?.reportInput)delete r.input;return r}function Bo(e){if(e instanceof Set)return"set";if(e instanceof Map)return"map";if(e instanceof File)return"file";return"unknown"}function Uo(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Od(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function br(...e){let[t,n,r]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:r};return{...t}}function AN(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map((t)=>t[1])}function p_(e){let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function g_(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function TN(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return p_(t+n)}function IN(e){return g_(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function ON(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw Error("Invalid hex string length");let n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=Number.parseInt(t.slice(r,r+2),16);return n}function zN(e){return Array.from(e).map((t)=>t.toString(16).padStart(2,"0")).join("")}class h_{constructor(...e){}}var y_=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,hr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},jo=g("$ZodError",y_),ke=g("$ZodError",y_,{Parent:Error});function vr(e,t=(n)=>n.message){let n={},r=[];for(let o of e.issues)if(o.path.length>0)n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o));else r.push(t(o));return{formErrors:r,fieldErrors:n}}function Sr(e,t=(n)=>n.message){let n={_errors:[]},r=(o)=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map((s)=>r({issues:s}));else if(i.code==="invalid_key")r({issues:i.issues});else if(i.code==="invalid_element")r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let s=n,a=0;while(a<i.path.length){let c=i.path[a];if(a!==i.path.length-1)s[c]=s[c]||{_errors:[]};else s[c]=s[c]||{_errors:[]},s[c]._errors.push(t(i));s=s[c],a++}}};return r(e),n}function va(e,t=(n)=>n.message){let n={errors:[]},r=(o,i=[])=>{var s,a;for(let c of o.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map((l)=>r({issues:l},c.path));else if(c.code==="invalid_key")r({issues:c.issues},c.path);else if(c.code==="invalid_element")r({issues:c.issues},c.path);else{let l=[...i,...c.path];if(l.length===0){n.errors.push(t(c));continue}let u=n,d=0;while(d<l.length){let f=l[d],m=d===l.length-1;if(typeof f==="string")u.properties??(u.properties={}),(s=u.properties)[f]??(s[f]={errors:[]}),u=u.properties[f];else u.items??(u.items=[]),(a=u.items)[f]??(a[f]={errors:[]}),u=u.items[f];if(m)u.errors.push(t(c));d++}}};return r(e),n}function b_(e){let t=[],n=e.map((r)=>typeof r==="object"?r.key:r);for(let r of n)if(typeof r==="number")t.push(`[${r}]`);else if(typeof r==="symbol")t.push(`[${JSON.stringify(String(r))}]`);else if(/[^\w$]/.test(r))t.push(`[${JSON.stringify(r)}]`);else{if(t.length)t.push(".");t.push(r)}return t.join("")}function Sa(e){let t=[],n=[...e.issues].sort((r,o)=>(r.path??[]).length-(o.path??[]).length);for(let r of n)if(t.push(`✖ ${r.message}`),r.path?.length)t.push(` → at ${b_(r.path)}`);return t.join(`
61
+ `)}var _r=(e)=>(t,n,r,o)=>{let i=r?Object.assign(r,{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new _t;if(s.issues.length){let a=new(o?.Err??e)(s.issues.map((c)=>Pe(c,i,se())));throw ya(a,o?.callee),a}return s.value},_a=_r(ke),xr=(e)=>async(t,n,r,o)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)s=await s;if(s.issues.length){let a=new(o?.Err??e)(s.issues.map((c)=>Pe(c,i,se())));throw ya(a,o?.callee),a}return s.value},xa=xr(ke),Cr=(e)=>(t,n,r)=>{let o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new _t;return i.issues.length?{success:!1,error:new(e??jo)(i.issues.map((s)=>Pe(s,o,se())))}:{success:!0,data:i.value}},zd=Cr(ke),wr=(e)=>async(t,n,r)=>{let o=r?Object.assign(r,{async:!0}):{async:!0},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)i=await i;return i.issues.length?{success:!1,error:new e(i.issues.map((s)=>Pe(s,o,se())))}:{success:!0,data:i.value}},Nd=wr(ke),Ca=(e)=>(t,n,r)=>{let o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return _r(e)(t,n,o)},DN=Ca(ke),wa=(e)=>(t,n,r)=>_r(e)(t,n,r),$N=wa(ke),Ea=(e)=>async(t,n,r)=>{let o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return xr(e)(t,n,o)},LN=Ea(ke),Ra=(e)=>async(t,n,r)=>xr(e)(t,n,r),MN=Ra(ke),Pa=(e)=>(t,n,r)=>{let o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Cr(e)(t,n,o)},WN=Pa(ke),ka=(e)=>(t,n,r)=>Cr(e)(t,n,r),FN=ka(ke),Aa=(e)=>async(t,n,r)=>{let o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return wr(e)(t,n,o)},GN=Aa(ke),Ta=(e)=>async(t,n,r)=>wr(e)(t,n,r),ZN=Ta(ke);var Fe={};dn(Fe,{base64:()=>Yd,base64url:()=>Ia,bigint:()=>nm,boolean:()=>om,browserEmail:()=>YN,cidrv4:()=>qd,cidrv6:()=>Kd,cuid:()=>Dd,cuid2:()=>$d,date:()=>Xd,datetime:()=>em,domain:()=>QN,duration:()=>Gd,e164:()=>Jd,email:()=>Bd,emoji:()=>Ud,extendedDuration:()=>BN,guid:()=>Zd,hex:()=>eD,hostname:()=>XN,html5Email:()=>VN,idnEmail:()=>KN,integer:()=>rm,ipv4:()=>jd,ipv6:()=>Hd,ksuid:()=>Wd,lowercase:()=>am,mac:()=>Vd,md5_base64:()=>nD,md5_base64url:()=>rD,md5_hex:()=>tD,nanoid:()=>Fd,null:()=>im,number:()=>Ho,rfc5322Email:()=>qN,sha1_base64:()=>iD,sha1_base64url:()=>sD,sha1_hex:()=>oD,sha256_base64:()=>cD,sha256_base64url:()=>lD,sha256_hex:()=>aD,sha384_base64:()=>dD,sha384_base64url:()=>mD,sha384_hex:()=>uD,sha512_base64:()=>pD,sha512_base64url:()=>gD,sha512_hex:()=>fD,string:()=>tm,time:()=>Qd,ulid:()=>Ld,undefined:()=>sm,unicodeEmail:()=>v_,uppercase:()=>cm,uuid:()=>$n,uuid4:()=>UN,uuid6:()=>jN,uuid7:()=>HN,xid:()=>Md});var Dd=/^[cC][^\s-]{8,}$/,$d=/^[0-9a-z]+$/,Ld=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Md=/^[0-9a-vA-V]{20}$/,Wd=/^[A-Za-z0-9]{27}$/,Fd=/^[a-zA-Z0-9_-]{21}$/,Gd=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,BN=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Zd=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,$n=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)},UN=$n(4),jN=$n(6),HN=$n(7),Bd=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,VN=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,qN=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,v_=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,KN=v_,YN=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,JN="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Ud(){return new RegExp(JN,"u")}var jd=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Hd=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Vd=(e)=>{let t=Ke(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},qd=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Kd=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Yd=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ia=/^[A-Za-z0-9_-]*$/,XN=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,QN=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,Jd=/^\+[1-9]\d{6,14}$/,S_="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Xd=new RegExp(`^${S_}$`);function __(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Qd(e){return new RegExp(`^${__(e)}$`)}function em(e){let t=__({precision:e.precision}),n=["Z"];if(e.local)n.push("");if(e.offset)n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${t}(?:${n.join("|")})`;return new RegExp(`^${S_}T(?:${r})$`)}var tm=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},nm=/^-?\d+n?$/,rm=/^-?\d+$/,Ho=/^-?\d+(?:\.\d+)?$/,om=/^(?:true|false)$/i,im=/^null$/i;var sm=/^undefined$/i;var am=/^[^A-Z]*$/,cm=/^[^a-z]*$/,eD=/^[0-9a-fA-F]*$/;function Vo(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function qo(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var tD=/^[0-9a-fA-F]{32}$/,nD=Vo(22,"=="),rD=qo(22),oD=/^[0-9a-fA-F]{40}$/,iD=Vo(27,"="),sD=qo(27),aD=/^[0-9a-fA-F]{64}$/,cD=Vo(43,"="),lD=qo(43),uD=/^[0-9a-fA-F]{96}$/,dD=Vo(64,""),mD=qo(64),fD=/^[0-9a-fA-F]{128}$/,pD=Vo(86,"=="),gD=qo(86);var J=g("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),C_={number:"number",bigint:"bigint",object:"date"},Oa=g("$ZodCheckLessThan",(e,t)=>{J.init(e,t);let n=C_[typeof t.value];e._zod.onattach.push((r)=>{let o=r._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<i)if(t.inclusive)o.maximum=t.value;else o.exclusiveMaximum=t.value}),e._zod.check=(r)=>{if(t.inclusive?r.value<=t.value:r.value<t.value)return;r.issues.push({origin:n,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),za=g("$ZodCheckGreaterThan",(e,t)=>{J.init(e,t);let n=C_[typeof t.value];e._zod.onattach.push((r)=>{let o=r._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>i)if(t.inclusive)o.minimum=t.value;else o.exclusiveMinimum=t.value}),e._zod.check=(r)=>{if(t.inclusive?r.value>=t.value:r.value>t.value)return;r.issues.push({origin:n,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),lm=g("$ZodCheckMultipleOf",(e,t)=>{J.init(e,t),e._zod.onattach.push((n)=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof n.value==="bigint"?n.value%t.value===BigInt(0):wd(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),um=g("$ZodCheckNumberFormat",(e,t)=>{J.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),r=n?"int":"number",[o,i]=Td[t.format];e._zod.onattach.push((s)=>{let a=s._zod.bag;if(a.format=t.format,a.minimum=o,a.maximum=i,n)a.pattern=rm}),e._zod.check=(s)=>{let a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});else s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}if(a<o)s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort});if(a>i)s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),dm=g("$ZodCheckBigIntFormat",(e,t)=>{J.init(e,t);let[n,r]=Id[t.format];e._zod.onattach.push((o)=>{let i=o._zod.bag;i.format=t.format,i.minimum=n,i.maximum=r}),e._zod.check=(o)=>{let i=o.value;if(i<n)o.issues.push({origin:"bigint",input:i,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort});if(i>r)o.issues.push({origin:"bigint",input:i,code:"too_big",maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),mm=g("$ZodCheckMaxSize",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=(r)=>{let o=r.value;return!rn(o)&&o.size!==void 0}),e._zod.onattach.push((r)=>{let o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<o)r._zod.bag.maximum=t.maximum}),e._zod.check=(r)=>{let o=r.value;if(o.size<=t.maximum)return;r.issues.push({origin:Bo(o),code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),fm=g("$ZodCheckMinSize",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=(r)=>{let o=r.value;return!rn(o)&&o.size!==void 0}),e._zod.onattach.push((r)=>{let o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>o)r._zod.bag.minimum=t.minimum}),e._zod.check=(r)=>{let o=r.value;if(o.size>=t.minimum)return;r.issues.push({origin:Bo(o),code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),pm=g("$ZodCheckSizeEquals",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=(r)=>{let o=r.value;return!rn(o)&&o.size!==void 0}),e._zod.onattach.push((r)=>{let o=r._zod.bag;o.minimum=t.size,o.maximum=t.size,o.size=t.size}),e._zod.check=(r)=>{let o=r.value,i=o.size;if(i===t.size)return;let s=i>t.size;r.issues.push({origin:Bo(o),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),gm=g("$ZodCheckMaxLength",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=(r)=>{let o=r.value;return!rn(o)&&o.length!==void 0}),e._zod.onattach.push((r)=>{let o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<o)r._zod.bag.maximum=t.maximum}),e._zod.check=(r)=>{let o=r.value;if(o.length<=t.maximum)return;let s=Uo(o);r.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),hm=g("$ZodCheckMinLength",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=(r)=>{let o=r.value;return!rn(o)&&o.length!==void 0}),e._zod.onattach.push((r)=>{let o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>o)r._zod.bag.minimum=t.minimum}),e._zod.check=(r)=>{let o=r.value;if(o.length>=t.minimum)return;let s=Uo(o);r.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),ym=g("$ZodCheckLengthEquals",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=(r)=>{let o=r.value;return!rn(o)&&o.length!==void 0}),e._zod.onattach.push((r)=>{let o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=(r)=>{let o=r.value,i=o.length;if(i===t.length)return;let s=Uo(o),a=i>t.length;r.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Er=g("$ZodCheckStringFormat",(e,t)=>{var n,r;if(J.init(e,t),e._zod.onattach.push((o)=>{let i=o._zod.bag;if(i.format=t.format,t.pattern)i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern)}),t.pattern)(n=e._zod).check??(n.check=(o)=>{if(t.pattern.lastIndex=0,t.pattern.test(o.value))return;o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(r=e._zod).check??(r.check=()=>{})}),bm=g("$ZodCheckRegex",(e,t)=>{Er.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),vm=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=am),Er.init(e,t)}),Sm=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=cm),Er.init(e,t)}),_m=g("$ZodCheckIncludes",(e,t)=>{J.init(e,t);let n=Ke(t.includes),r=new RegExp(typeof t.position==="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push((o)=>{let i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=(o)=>{if(o.value.includes(t.includes,t.position))return;o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),xm=g("$ZodCheckStartsWith",(e,t)=>{J.init(e,t);let n=new RegExp(`^${Ke(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push((r)=>{let o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=(r)=>{if(r.value.startsWith(t.prefix))return;r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Cm=g("$ZodCheckEndsWith",(e,t)=>{J.init(e,t);let n=new RegExp(`.*${Ke(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push((r)=>{let o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=(r)=>{if(r.value.endsWith(t.suffix))return;r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});function x_(e,t,n){if(e.issues.length)t.issues.push(...We(n,e.issues))}var wm=g("$ZodCheckProperty",(e,t)=>{J.init(e,t),e._zod.check=(n)=>{let r=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(r instanceof Promise)return r.then((o)=>x_(o,n,t.property));x_(r,n,t.property);return}}),Em=g("$ZodCheckMimeType",(e,t)=>{J.init(e,t);let n=new Set(t.mime);e._zod.onattach.push((r)=>{r._zod.bag.mime=t.mime}),e._zod.check=(r)=>{if(n.has(r.value.type))return;r.issues.push({code:"invalid_value",values:t.mime,input:r.value.type,inst:e,continue:!t.abort})}}),Rm=g("$ZodCheckOverwrite",(e,t)=>{J.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class Na{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
62
+ `).filter((i)=>i),r=Math.min(...n.map((i)=>i.length-i.trimStart().length)),o=n.map((i)=>i.slice(r)).map((i)=>" ".repeat(this.indent*2)+i);for(let i of o)this.content.push(i)}compile(){let e=Function,t=this?.args,r=[...(this?.content??[""]).map((o)=>` ${o}`)];return new e(...t,r.join(`
63
+ `))}}var Pm={major:4,minor:3,patch:5};var D=g("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Pm;let r=[...e._zod.def.checks??[]];if(e._zod.traits.has("$ZodCheck"))r.unshift(e);for(let o of r)for(let i of o._zod.onattach)i(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(s,a,c)=>{let l=an(s),u;for(let d of a){if(d._zod.def.when){if(!d._zod.def.when(s))continue}else if(l)continue;let f=s.issues.length,m=d._zod.check(s);if(m instanceof Promise&&c?.async===!1)throw new _t;if(u||m instanceof Promise)u=(u??Promise.resolve()).then(async()=>{if(await m,s.issues.length===f)return;if(!l)l=an(s,f)});else{if(s.issues.length===f)continue;if(!l)l=an(s,f)}}if(u)return u.then(()=>s);return s},i=(s,a,c)=>{if(an(s))return s.aborted=!0,s;let l=o(a,r,c);if(l instanceof Promise){if(c.async===!1)throw new _t;return l.then((u)=>e._zod.parse(u,c))}return e._zod.parse(l,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){let l=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});if(l instanceof Promise)return l.then((u)=>i(u,s,a));return i(l,s,a)}let c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new _t;return c.then((l)=>o(l,r,a))}return o(c,r,a)}}F(e,"~standard",()=>({validate:(o)=>{try{let i=zd(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch(i){return Nd(e,o).then((s)=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),Ln=g("$ZodString",(e,t)=>{D.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??tm(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(o){}if(typeof n.value==="string")return n;return n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),q=g("$ZodStringFormat",(e,t)=>{Er.init(e,t),Ln.init(e,t)}),Am=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Zd),q.init(e,t)}),Tm=g("$ZodUUID",(e,t)=>{if(t.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=$n(r))}else t.pattern??(t.pattern=$n());q.init(e,t)}),Im=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Bd),q.init(e,t)}),Om=g("$ZodURL",(e,t)=>{q.init(e,t),e._zod.check=(n)=>{try{let r=n.value.trim(),o=new URL(r);if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(o.hostname))n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})}if(t.protocol){if(t.protocol.lastIndex=0,!t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol))n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})}if(t.normalize)n.value=o.href;else n.value=r;return}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),zm=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Ud()),q.init(e,t)}),Nm=g("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Fd),q.init(e,t)}),Dm=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Dd),q.init(e,t)}),$m=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=$d),q.init(e,t)}),Lm=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Ld),q.init(e,t)}),Mm=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Md),q.init(e,t)}),Wm=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Wd),q.init(e,t)}),Fm=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=em(t)),q.init(e,t)}),Gm=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Xd),q.init(e,t)}),Zm=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Qd(t)),q.init(e,t)}),Bm=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Gd),q.init(e,t)}),Um=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=jd),q.init(e,t),e._zod.bag.format="ipv4"}),jm=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Hd),q.init(e,t),e._zod.bag.format="ipv6",e._zod.check=(n)=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),Hm=g("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=Vd(t.delimiter)),q.init(e,t),e._zod.bag.format="mac"}),Vm=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=qd),q.init(e,t)}),qm=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Kd),q.init(e,t),e._zod.check=(n)=>{let r=n.value.split("/");try{if(r.length!==2)throw Error();let[o,i]=r;if(!i)throw Error();let s=Number(i);if(`${s}`!==i)throw Error();if(s<0||s>128)throw Error();new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Km(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Ym=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Yd),q.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=(n)=>{if(Km(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function $_(e){if(!Ia.test(e))return!1;let t=e.replace(/[-_]/g,(r)=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Km(n)}var Jm=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ia),q.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=(n)=>{if($_(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Xm=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Jd),q.init(e,t)});function L_(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let o=JSON.parse(atob(r));if("typ"in o&&o?.typ!=="JWT")return!1;if(!o.alg)return!1;if(t&&(!("alg"in o)||o.alg!==t))return!1;return!0}catch{return!1}}var Qm=g("$ZodJWT",(e,t)=>{q.init(e,t),e._zod.check=(n)=>{if(L_(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),ef=g("$ZodCustomStringFormat",(e,t)=>{q.init(e,t),e._zod.check=(n)=>{if(t.fn(n.value))return;n.issues.push({code:"invalid_format",format:t.format,input:n.value,inst:e,continue:!t.abort})}}),Fa=g("$ZodNumber",(e,t)=>{D.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ho,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(s){}let o=n.value;if(typeof o==="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;let i=typeof o==="number"?Number.isNaN(o)?"NaN":!Number.isFinite(o)?"Infinity":void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),tf=g("$ZodNumberFormat",(e,t)=>{um.init(e,t),Fa.init(e,t)}),Ko=g("$ZodBoolean",(e,t)=>{D.init(e,t),e._zod.pattern=om,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(i){}let o=n.value;if(typeof o==="boolean")return n;return n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),Ga=g("$ZodBigInt",(e,t)=>{D.init(e,t),e._zod.pattern=nm,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch(o){}if(typeof n.value==="bigint")return n;return n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),nf=g("$ZodBigIntFormat",(e,t)=>{dm.init(e,t),Ga.init(e,t)}),rf=g("$ZodSymbol",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;if(typeof o==="symbol")return n;return n.issues.push({expected:"symbol",code:"invalid_type",input:o,inst:e}),n}}),of=g("$ZodUndefined",(e,t)=>{D.init(e,t),e._zod.pattern=sm,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(n,r)=>{let o=n.value;if(typeof o>"u")return n;return n.issues.push({expected:"undefined",code:"invalid_type",input:o,inst:e}),n}}),sf=g("$ZodNull",(e,t)=>{D.init(e,t),e._zod.pattern=im,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{let o=n.value;if(o===null)return n;return n.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),n}}),af=g("$ZodAny",(e,t)=>{D.init(e,t),e._zod.parse=(n)=>n}),cf=g("$ZodUnknown",(e,t)=>{D.init(e,t),e._zod.parse=(n)=>n}),lf=g("$ZodNever",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),uf=g("$ZodVoid",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;if(typeof o>"u")return n;return n.issues.push({expected:"void",code:"invalid_type",input:o,inst:e}),n}}),df=g("$ZodDate",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch(a){}let o=n.value,i=o instanceof Date;if(i&&!Number.isNaN(o.getTime()))return n;return n.issues.push({expected:"date",code:"invalid_type",input:o,...i?{received:"Invalid Date"}:{},inst:e}),n}});function E_(e,t,n){if(e.issues.length)t.issues.push(...We(n,e.issues));t.value[n]=e.value}var mf=g("$ZodArray",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);let i=[];for(let s=0;s<o.length;s++){let a=o[s],c=t.element._zod.run({value:a,issues:[]},r);if(c instanceof Promise)i.push(c.then((l)=>E_(l,n,s)));else E_(c,n,s)}if(i.length)return Promise.all(i).then(()=>n);return n}});function Wa(e,t,n,r,o){if(e.issues.length){if(o&&!(n in r))return;t.issues.push(...We(n,e.issues))}if(e.value===void 0){if(n in r)t.value[n]=void 0}else t.value[n]=e.value}function M_(e){let t=Object.keys(e.shape);for(let r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${r}": expected a Zod schema`);let n=Ad(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function W_(e,t,n,r,o,i){let s=[],a=o.keySet,c=o.catchall._zod,l=c.def.type,u=c.optout==="optional";for(let d in t){if(a.has(d))continue;if(l==="never"){s.push(d);continue}let f=c.run({value:t[d],issues:[]},r);if(f instanceof Promise)e.push(f.then((m)=>Wa(m,n,d,t,u)));else Wa(f,n,d,t,u)}if(s.length)n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i});if(!e.length)return n;return Promise.all(e).then(()=>n)}var F_=g("$ZodObject",(e,t)=>{if(D.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}let r=yr(()=>M_(t));F(e._zod,"propValues",()=>{let a=t.shape,c={};for(let l in a){let u=a[l]._zod;if(u.values){c[l]??(c[l]=new Set);for(let d of u.values)c[l].add(d)}}return c});let o=Dn,i=t.catchall,s;e._zod.parse=(a,c)=>{s??(s=r.value);let l=a.value;if(!o(l))return a.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),a;a.value={};let u=[],d=s.shape;for(let f of s.keys){let m=d[f],p=m._zod.optout==="optional",h=m._zod.run({value:l[f],issues:[]},c);if(h instanceof Promise)u.push(h.then((b)=>Wa(b,a,f,l,p)));else Wa(h,a,f,l,p)}if(!i)return u.length?Promise.all(u).then(()=>a):a;return W_(u,l,a,c,r.value,e)}}),ff=g("$ZodObjectJIT",(e,t)=>{F_.init(e,t);let n=e._zod.parse,r=yr(()=>M_(t)),o=(f)=>{let m=new Na(["shape","payload","ctx"]),p=r.value,h=(w)=>{let R=ha(w);return`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`};m.write("const input = payload.value;");let b=Object.create(null),y=0;for(let w of p.keys)b[w]=`key_${y++}`;m.write("const newResult = {};");for(let w of p.keys){let R=b[w],P=ha(w),v=f[w]?._zod?.optout==="optional";if(m.write(`const ${R} = ${h(w)};`),v)m.write(`
64
+ if (${R}.issues.length) {
65
+ if (${P} in input) {
66
+ payload.issues = payload.issues.concat(${R}.issues.map(iss => ({
69
67
  ...iss,
70
- path: iss.path ? [${E}, ...iss.path] : [${E}]
68
+ path: iss.path ? [${P}, ...iss.path] : [${P}]
71
69
  })));
72
70
  }
73
71
  }
74
72
 
75
- if (${A}.value === undefined) {
76
- if (${E} in input) {
77
- newResult[${E}] = undefined;
73
+ if (${R}.value === undefined) {
74
+ if (${P} in input) {
75
+ newResult[${P}] = undefined;
78
76
  }
79
77
  } else {
80
- newResult[${E}] = ${A}.value;
78
+ newResult[${P}] = ${R}.value;
81
79
  }
82
80
 
83
- `);else Z.write(`
84
- if (${A}.issues.length) {
85
- payload.issues = payload.issues.concat(${A}.issues.map(iss => ({
81
+ `);else m.write(`
82
+ if (${R}.issues.length) {
83
+ payload.issues = payload.issues.concat(${R}.issues.map(iss => ({
86
84
  ...iss,
87
- path: iss.path ? [${E}, ...iss.path] : [${E}]
85
+ path: iss.path ? [${P}, ...iss.path] : [${P}]
88
86
  })));
89
87
  }
90
88
 
91
- if (${A}.value === undefined) {
92
- if (${E} in input) {
93
- newResult[${E}] = undefined;
89
+ if (${R}.value === undefined) {
90
+ if (${P} in input) {
91
+ newResult[${P}] = undefined;
94
92
  }
95
93
  } else {
96
- newResult[${E}] = ${A}.value;
94
+ newResult[${P}] = ${R}.value;
97
95
  }
98
96
 
99
- `)}Z.write("payload.value = newResult;"),Z.write("return payload;");let b=Z.compile();return(I,A)=>b(L,I,A)},Y,K=v2,B=!v3.jitless,U=B&&R7.value,G=J.catchall,H;$._zod.parse=(L,Z)=>{H??(H=W.value);let M=L.value;if(!K(M))return L.issues.push({expected:"object",code:"invalid_type",input:M,inst:$}),L;if(B&&U&&Z?.async===!1&&Z.jitless!==!0){if(!Y)Y=X(J.shape);if(L=Y(L,Z),!G)return L;return gH([],M,L,Z,H,$)}return Q(L,Z)}});function bH($,J,Q,W){for(let Y of $)if(Y.issues.length===0)return J.value=Y.value,J;let X=$.filter((Y)=>!Y2(Y));if(X.length===1)return J.value=X[0].value,X[0];return J.issues.push({code:"invalid_union",input:J.value,inst:Q,errors:$.map((Y)=>Y.issues.map((K)=>A1(K,W,Y1())))}),J}var d3=N("$ZodUnion",($,J)=>{f.init($,J),u($._zod,"optin",()=>J.options.some((X)=>X._zod.optin==="optional")?"optional":void 0),u($._zod,"optout",()=>J.options.some((X)=>X._zod.optout==="optional")?"optional":void 0),u($._zod,"values",()=>{if(J.options.every((X)=>X._zod.values))return new Set(J.options.flatMap((X)=>Array.from(X._zod.values)));return}),u($._zod,"pattern",()=>{if(J.options.every((X)=>X._zod.pattern)){let X=J.options.map((Y)=>Y._zod.pattern);return new RegExp(`^(${X.map((Y)=>h3(Y.source)).join("|")})$`)}return});let Q=J.options.length===1,W=J.options[0]._zod.run;$._zod.parse=(X,Y)=>{if(Q)return W(X,Y);let K=!1,B=[];for(let q of J.options){let U=q._zod.run({value:X.value,issues:[]},Y);if(U instanceof Promise)B.push(U),K=!0;else{if(U.issues.length===0)return U;B.push(U)}}if(!K)return bH(B,X,$,Y);return Promise.all(B).then((q)=>{return bH(q,X,$,Y)})}});function PH($,J,Q,W){let X=$.filter((Y)=>Y.issues.length===0);if(X.length===1)return J.value=X[0].value,J;if(X.length===0)J.issues.push({code:"invalid_union",input:J.value,inst:Q,errors:$.map((Y)=>Y.issues.map((K)=>A1(K,W,Y1())))});else J.issues.push({code:"invalid_union",input:J.value,inst:Q,errors:[],inclusive:!1});return J}var HX=N("$ZodXor",($,J)=>{d3.init($,J),J.inclusive=!1;let Q=J.options.length===1,W=J.options[0]._zod.run;$._zod.parse=(X,Y)=>{if(Q)return W(X,Y);let K=!1,B=[];for(let q of J.options){let U=q._zod.run({value:X.value,issues:[]},Y);if(U instanceof Promise)B.push(U),K=!0;else B.push(U)}if(!K)return PH(B,X,$,Y);return Promise.all(B).then((q)=>{return PH(q,X,$,Y)})}}),ZX=N("$ZodDiscriminatedUnion",($,J)=>{J.inclusive=!1,d3.init($,J);let Q=$._zod.parse;u($._zod,"propValues",()=>{let X={};for(let Y of J.options){let K=Y._zod.propValues;if(!K||Object.keys(K).length===0)throw Error(`Invalid discriminated union option at index "${J.options.indexOf(Y)}"`);for(let[B,q]of Object.entries(K)){if(!X[B])X[B]=new Set;for(let U of q)X[B].add(U)}}return X});let W=O4(()=>{let X=J.options,Y=new Map;for(let K of X){let B=K._zod.propValues?.[J.discriminator];if(!B||B.size===0)throw Error(`Invalid discriminated union option at index "${J.options.indexOf(K)}"`);for(let q of B){if(Y.has(q))throw Error(`Duplicate discriminator value "${String(q)}"`);Y.set(q,K)}}return Y});$._zod.parse=(X,Y)=>{let K=X.value;if(!v2(K))return X.issues.push({code:"invalid_type",expected:"object",input:K,inst:$}),X;let B=W.value.get(K?.[J.discriminator]);if(B)return B._zod.run(X,Y);if(J.unionFallback)return Q(X,Y);return X.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:J.discriminator,input:K,path:[J.discriminator],inst:$}),X}}),LX=N("$ZodIntersection",($,J)=>{f.init($,J),$._zod.parse=(Q,W)=>{let X=Q.value,Y=J.left._zod.run({value:X,issues:[]},W),K=J.right._zod.run({value:X,issues:[]},W);if(Y instanceof Promise||K instanceof Promise)return Promise.all([Y,K]).then(([q,U])=>{return AH(Q,q,U)});return AH(Q,Y,K)}});function PW($,J){if($===J)return{valid:!0,data:$};if($ instanceof Date&&J instanceof Date&&+$===+J)return{valid:!0,data:$};if(X2($)&&X2(J)){let Q=Object.keys(J),W=Object.keys($).filter((Y)=>Q.indexOf(Y)!==-1),X={...$,...J};for(let Y of W){let K=PW($[Y],J[Y]);if(!K.valid)return{valid:!1,mergeErrorPath:[Y,...K.mergeErrorPath]};X[Y]=K.data}return{valid:!0,data:X}}if(Array.isArray($)&&Array.isArray(J)){if($.length!==J.length)return{valid:!1,mergeErrorPath:[]};let Q=[];for(let W=0;W<$.length;W++){let X=$[W],Y=J[W],K=PW(X,Y);if(!K.valid)return{valid:!1,mergeErrorPath:[W,...K.mergeErrorPath]};Q.push(K.data)}return{valid:!0,data:Q}}return{valid:!1,mergeErrorPath:[]}}function AH($,J,Q){let W=new Map,X;for(let B of J.issues)if(B.code==="unrecognized_keys"){X??(X=B);for(let q of B.keys){if(!W.has(q))W.set(q,{});W.get(q).l=!0}}else $.issues.push(B);for(let B of Q.issues)if(B.code==="unrecognized_keys")for(let q of B.keys){if(!W.has(q))W.set(q,{});W.get(q).r=!0}else $.issues.push(B);let Y=[...W].filter(([,B])=>B.l&&B.r).map(([B])=>B);if(Y.length&&X)$.issues.push({...X,keys:Y});if(Y2($))return $;let K=PW(J.value,Q.value);if(!K.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(K.mergeErrorPath)}`);return $.value=K.data,$}var m$=N("$ZodTuple",($,J)=>{f.init($,J);let Q=J.items;$._zod.parse=(W,X)=>{let Y=W.value;if(!Array.isArray(Y))return W.issues.push({input:Y,inst:$,expected:"tuple",code:"invalid_type"}),W;W.value=[];let K=[],B=[...Q].reverse().findIndex((G)=>G._zod.optin!=="optional"),q=B===-1?0:Q.length-B;if(!J.rest){let G=Y.length>Q.length,H=Y.length<q-1;if(G||H)return W.issues.push({...G?{code:"too_big",maximum:Q.length,inclusive:!0}:{code:"too_small",minimum:Q.length},input:Y,inst:$,origin:"array"}),W}let U=-1;for(let G of Q){if(U++,U>=Y.length){if(U>=q)continue}let H=G._zod.run({value:Y[U],issues:[]},X);if(H instanceof Promise)K.push(H.then((L)=>f$(L,W,U)));else f$(H,W,U)}if(J.rest){let G=Y.slice(Q.length);for(let H of G){U++;let L=J.rest._zod.run({value:H,issues:[]},X);if(L instanceof Promise)K.push(L.then((Z)=>f$(Z,W,U)));else f$(L,W,U)}}if(K.length)return Promise.all(K).then(()=>W);return W}});function f$($,J,Q){if($.issues.length)J.issues.push(...g1(Q,$.issues));J.value[Q]=$.value}var MX=N("$ZodRecord",($,J)=>{f.init($,J),$._zod.parse=(Q,W)=>{let X=Q.value;if(!X2(X))return Q.issues.push({expected:"record",code:"invalid_type",input:X,inst:$}),Q;let Y=[],K=J.keyType._zod.values;if(K){Q.value={};let B=new Set;for(let U of K)if(typeof U==="string"||typeof U==="number"||typeof U==="symbol"){B.add(typeof U==="number"?U.toString():U);let G=J.valueType._zod.run({value:X[U],issues:[]},W);if(G instanceof Promise)Y.push(G.then((H)=>{if(H.issues.length)Q.issues.push(...g1(U,H.issues));Q.value[U]=H.value}));else{if(G.issues.length)Q.issues.push(...g1(U,G.issues));Q.value[U]=G.value}}let q;for(let U in X)if(!B.has(U))q=q??[],q.push(U);if(q&&q.length>0)Q.issues.push({code:"unrecognized_keys",input:X,inst:$,keys:q})}else{Q.value={};for(let B of Reflect.ownKeys(X)){if(B==="__proto__")continue;let q=J.keyType._zod.run({value:B,issues:[]},W);if(q instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof B==="string"&&m3.test(B)&&q.issues.length&&q.issues.some((H)=>H.code==="invalid_type"&&H.expected==="number")){let H=J.keyType._zod.run({value:Number(B),issues:[]},W);if(H instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(H.issues.length===0)q=H}if(q.issues.length){if(J.mode==="loose")Q.value[B]=X[B];else Q.issues.push({code:"invalid_key",origin:"record",issues:q.issues.map((H)=>A1(H,W,Y1())),input:B,path:[B],inst:$});continue}let G=J.valueType._zod.run({value:X[B],issues:[]},W);if(G instanceof Promise)Y.push(G.then((H)=>{if(H.issues.length)Q.issues.push(...g1(B,H.issues));Q.value[q.value]=H.value}));else{if(G.issues.length)Q.issues.push(...g1(B,G.issues));Q.value[q.value]=G.value}}}if(Y.length)return Promise.all(Y).then(()=>Q);return Q}}),OX=N("$ZodMap",($,J)=>{f.init($,J),$._zod.parse=(Q,W)=>{let X=Q.value;if(!(X instanceof Map))return Q.issues.push({expected:"map",code:"invalid_type",input:X,inst:$}),Q;let Y=[];Q.value=new Map;for(let[K,B]of X){let q=J.keyType._zod.run({value:K,issues:[]},W),U=J.valueType._zod.run({value:B,issues:[]},W);if(q instanceof Promise||U instanceof Promise)Y.push(Promise.all([q,U]).then(([G,H])=>{EH(G,H,Q,K,X,$,W)}));else EH(q,U,Q,K,X,$,W)}if(Y.length)return Promise.all(Y).then(()=>Q);return Q}});function EH($,J,Q,W,X,Y,K){if($.issues.length)if(y3.has(typeof W))Q.issues.push(...g1(W,$.issues));else Q.issues.push({code:"invalid_key",origin:"map",input:X,inst:Y,issues:$.issues.map((B)=>A1(B,K,Y1()))});if(J.issues.length)if(y3.has(typeof W))Q.issues.push(...g1(W,J.issues));else Q.issues.push({origin:"map",code:"invalid_element",input:X,inst:Y,key:W,issues:J.issues.map((B)=>A1(B,K,Y1()))});Q.value.set($.value,J.value)}var NX=N("$ZodSet",($,J)=>{f.init($,J),$._zod.parse=(Q,W)=>{let X=Q.value;if(!(X instanceof Set))return Q.issues.push({input:X,inst:$,expected:"set",code:"invalid_type"}),Q;let Y=[];Q.value=new Set;for(let K of X){let B=J.valueType._zod.run({value:K,issues:[]},W);if(B instanceof Promise)Y.push(B.then((q)=>CH(q,Q)));else CH(B,Q)}if(Y.length)return Promise.all(Y).then(()=>Q);return Q}});function CH($,J){if($.issues.length)J.issues.push(...$.issues);J.value.add($.value)}var FX=N("$ZodEnum",($,J)=>{f.init($,J);let Q=k3(J.entries),W=new Set(Q);$._zod.values=W,$._zod.pattern=new RegExp(`^(${Q.filter((X)=>y3.has(typeof X)).map((X)=>typeof X==="string"?o1(X):X.toString()).join("|")})$`),$._zod.parse=(X,Y)=>{let K=X.value;if(W.has(K))return X;return X.issues.push({code:"invalid_value",values:Q,input:K,inst:$}),X}}),VX=N("$ZodLiteral",($,J)=>{if(f.init($,J),J.values.length===0)throw Error("Cannot create literal schema with no valid values");let Q=new Set(J.values);$._zod.values=Q,$._zod.pattern=new RegExp(`^(${J.values.map((W)=>typeof W==="string"?o1(W):W?o1(W.toString()):String(W)).join("|")})$`),$._zod.parse=(W,X)=>{let Y=W.value;if(Q.has(Y))return W;return W.issues.push({code:"invalid_value",values:J.values,input:Y,inst:$}),W}}),_X=N("$ZodFile",($,J)=>{f.init($,J),$._zod.parse=(Q,W)=>{let X=Q.value;if(X instanceof File)return Q;return Q.issues.push({expected:"file",code:"invalid_type",input:X,inst:$}),Q}}),DX=N("$ZodTransform",($,J)=>{f.init($,J),$._zod.parse=(Q,W)=>{if(W.direction==="backward")throw new w2($.constructor.name);let X=J.transform(Q.value,Q);if(W.async)return(X instanceof Promise?X:Promise.resolve(X)).then((K)=>{return Q.value=K,Q});if(X instanceof Promise)throw new D0;return Q.value=X,Q}});function SH($,J){if($.issues.length&&J===void 0)return{issues:[],value:void 0};return $}var l$=N("$ZodOptional",($,J)=>{f.init($,J),$._zod.optin="optional",$._zod.optout="optional",u($._zod,"values",()=>{return J.innerType._zod.values?new Set([...J.innerType._zod.values,void 0]):void 0}),u($._zod,"pattern",()=>{let Q=J.innerType._zod.pattern;return Q?new RegExp(`^(${h3(Q.source)})?$`):void 0}),$._zod.parse=(Q,W)=>{if(J.innerType._zod.optin==="optional"){let X=J.innerType._zod.run(Q,W);if(X instanceof Promise)return X.then((Y)=>SH(Y,Q.value));return SH(X,Q.value)}if(Q.value===void 0)return Q;return J.innerType._zod.run(Q,W)}}),zX=N("$ZodExactOptional",($,J)=>{l$.init($,J),u($._zod,"values",()=>J.innerType._zod.values),u($._zod,"pattern",()=>J.innerType._zod.pattern),$._zod.parse=(Q,W)=>{return J.innerType._zod.run(Q,W)}}),IX=N("$ZodNullable",($,J)=>{f.init($,J),u($._zod,"optin",()=>J.innerType._zod.optin),u($._zod,"optout",()=>J.innerType._zod.optout),u($._zod,"pattern",()=>{let Q=J.innerType._zod.pattern;return Q?new RegExp(`^(${h3(Q.source)}|null)$`):void 0}),u($._zod,"values",()=>{return J.innerType._zod.values?new Set([...J.innerType._zod.values,null]):void 0}),$._zod.parse=(Q,W)=>{if(Q.value===null)return Q;return J.innerType._zod.run(Q,W)}}),jX=N("$ZodDefault",($,J)=>{f.init($,J),$._zod.optin="optional",u($._zod,"values",()=>J.innerType._zod.values),$._zod.parse=(Q,W)=>{if(W.direction==="backward")return J.innerType._zod.run(Q,W);if(Q.value===void 0)return Q.value=J.defaultValue,Q;let X=J.innerType._zod.run(Q,W);if(X instanceof Promise)return X.then((Y)=>TH(Y,J));return TH(X,J)}});function TH($,J){if($.value===void 0)$.value=J.defaultValue;return $}var RX=N("$ZodPrefault",($,J)=>{f.init($,J),$._zod.optin="optional",u($._zod,"values",()=>J.innerType._zod.values),$._zod.parse=(Q,W)=>{if(W.direction==="backward")return J.innerType._zod.run(Q,W);if(Q.value===void 0)Q.value=J.defaultValue;return J.innerType._zod.run(Q,W)}}),bX=N("$ZodNonOptional",($,J)=>{f.init($,J),u($._zod,"values",()=>{let Q=J.innerType._zod.values;return Q?new Set([...Q].filter((W)=>W!==void 0)):void 0}),$._zod.parse=(Q,W)=>{let X=J.innerType._zod.run(Q,W);if(X instanceof Promise)return X.then((Y)=>wH(Y,$));return wH(X,$)}});function wH($,J){if(!$.issues.length&&$.value===void 0)$.issues.push({code:"invalid_type",expected:"nonoptional",input:$.value,inst:J});return $}var PX=N("$ZodSuccess",($,J)=>{f.init($,J),$._zod.parse=(Q,W)=>{if(W.direction==="backward")throw new w2("ZodSuccess");let X=J.innerType._zod.run(Q,W);if(X instanceof Promise)return X.then((Y)=>{return Q.value=Y.issues.length===0,Q});return Q.value=X.issues.length===0,Q}}),AX=N("$ZodCatch",($,J)=>{f.init($,J),u($._zod,"optin",()=>J.innerType._zod.optin),u($._zod,"optout",()=>J.innerType._zod.optout),u($._zod,"values",()=>J.innerType._zod.values),$._zod.parse=(Q,W)=>{if(W.direction==="backward")return J.innerType._zod.run(Q,W);let X=J.innerType._zod.run(Q,W);if(X instanceof Promise)return X.then((Y)=>{if(Q.value=Y.value,Y.issues.length)Q.value=J.catchValue({...Q,error:{issues:Y.issues.map((K)=>A1(K,W,Y1()))},input:Q.value}),Q.issues=[];return Q});if(Q.value=X.value,X.issues.length)Q.value=J.catchValue({...Q,error:{issues:X.issues.map((Y)=>A1(Y,W,Y1()))},input:Q.value}),Q.issues=[];return Q}}),EX=N("$ZodNaN",($,J)=>{f.init($,J),$._zod.parse=(Q,W)=>{if(typeof Q.value!=="number"||!Number.isNaN(Q.value))return Q.issues.push({input:Q.value,inst:$,expected:"nan",code:"invalid_type"}),Q;return Q}}),CX=N("$ZodPipe",($,J)=>{f.init($,J),u($._zod,"values",()=>J.in._zod.values),u($._zod,"optin",()=>J.in._zod.optin),u($._zod,"optout",()=>J.out._zod.optout),u($._zod,"propValues",()=>J.in._zod.propValues),$._zod.parse=(Q,W)=>{if(W.direction==="backward"){let Y=J.out._zod.run(Q,W);if(Y instanceof Promise)return Y.then((K)=>k$(K,J.in,W));return k$(Y,J.in,W)}let X=J.in._zod.run(Q,W);if(X instanceof Promise)return X.then((Y)=>k$(Y,J.out,W));return k$(X,J.out,W)}});function k$($,J,Q){if($.issues.length)return $.aborted=!0,$;return J._zod.run({value:$.value,issues:$.issues},Q)}var r3=N("$ZodCodec",($,J)=>{f.init($,J),u($._zod,"values",()=>J.in._zod.values),u($._zod,"optin",()=>J.in._zod.optin),u($._zod,"optout",()=>J.out._zod.optout),u($._zod,"propValues",()=>J.in._zod.propValues),$._zod.parse=(Q,W)=>{if((W.direction||"forward")==="forward"){let Y=J.in._zod.run(Q,W);if(Y instanceof Promise)return Y.then((K)=>h$(K,J,W));return h$(Y,J,W)}else{let Y=J.out._zod.run(Q,W);if(Y instanceof Promise)return Y.then((K)=>h$(K,J,W));return h$(Y,J,W)}}});function h$($,J,Q){if($.issues.length)return $.aborted=!0,$;if((Q.direction||"forward")==="forward"){let X=J.transform($.value,$);if(X instanceof Promise)return X.then((Y)=>y$($,Y,J.out,Q));return y$($,X,J.out,Q)}else{let X=J.reverseTransform($.value,$);if(X instanceof Promise)return X.then((Y)=>y$($,Y,J.in,Q));return y$($,X,J.in,Q)}}function y$($,J,Q,W){if($.issues.length)return $.aborted=!0,$;return Q._zod.run({value:J,issues:$.issues},W)}var SX=N("$ZodReadonly",($,J)=>{f.init($,J),u($._zod,"propValues",()=>J.innerType._zod.propValues),u($._zod,"values",()=>J.innerType._zod.values),u($._zod,"optin",()=>J.innerType?._zod?.optin),u($._zod,"optout",()=>J.innerType?._zod?.optout),$._zod.parse=(Q,W)=>{if(W.direction==="backward")return J.innerType._zod.run(Q,W);let X=J.innerType._zod.run(Q,W);if(X instanceof Promise)return X.then(vH);return vH(X)}});function vH($){return $.value=Object.freeze($.value),$}var TX=N("$ZodTemplateLiteral",($,J)=>{f.init($,J);let Q=[];for(let W of J.parts)if(typeof W==="object"&&W!==null){if(!W._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...W._zod.traits].shift()}`);let X=W._zod.pattern instanceof RegExp?W._zod.pattern.source:W._zod.pattern;if(!X)throw Error(`Invalid template literal part: ${W._zod.traits}`);let Y=X.startsWith("^")?1:0,K=X.endsWith("$")?X.length-1:X.length;Q.push(X.slice(Y,K))}else if(W===null||P7.has(typeof W))Q.push(o1(`${W}`));else throw Error(`Invalid template literal part: ${W}`);$._zod.pattern=new RegExp(`^${Q.join("")}$`),$._zod.parse=(W,X)=>{if(typeof W.value!=="string")return W.issues.push({input:W.value,inst:$,expected:"string",code:"invalid_type"}),W;if($._zod.pattern.lastIndex=0,!$._zod.pattern.test(W.value))return W.issues.push({input:W.value,inst:$,code:"invalid_format",format:J.format??"template_literal",pattern:$._zod.pattern.source}),W;return W}}),wX=N("$ZodFunction",($,J)=>{return f.init($,J),$._def=J,$._zod.def=J,$.implement=(Q)=>{if(typeof Q!=="function")throw Error("implement() must be called with a function");return function(...W){let X=$._def.input?D$($._def.input,W):W,Y=Reflect.apply(Q,this,X);if($._def.output)return D$($._def.output,Y);return Y}},$.implementAsync=(Q)=>{if(typeof Q!=="function")throw Error("implementAsync() must be called with a function");return async function(...W){let X=$._def.input?await z$($._def.input,W):W,Y=await Reflect.apply(Q,this,X);if($._def.output)return await z$($._def.output,Y);return Y}},$._zod.parse=(Q,W)=>{if(typeof Q.value!=="function")return Q.issues.push({code:"invalid_type",expected:"function",input:Q.value,inst:$}),Q;if($._def.output&&$._def.output._zod.def.type==="promise")Q.value=$.implementAsync(Q.value);else Q.value=$.implement(Q.value);return Q},$.input=(...Q)=>{let W=$.constructor;if(Array.isArray(Q[0]))return new W({type:"function",input:new m$({type:"tuple",items:Q[0],rest:Q[1]}),output:$._def.output});return new W({type:"function",input:Q[0],output:$._def.output})},$.output=(Q)=>{return new $.constructor({type:"function",input:$._def.input,output:Q})},$}),vX=N("$ZodPromise",($,J)=>{f.init($,J),$._zod.parse=(Q,W)=>{return Promise.resolve(Q.value).then((X)=>J.innerType._zod.run({value:X,issues:[]},W))}}),fX=N("$ZodLazy",($,J)=>{f.init($,J),u($._zod,"innerType",()=>J.getter()),u($._zod,"pattern",()=>$._zod.innerType?._zod?.pattern),u($._zod,"propValues",()=>$._zod.innerType?._zod?.propValues),u($._zod,"optin",()=>$._zod.innerType?._zod?.optin??void 0),u($._zod,"optout",()=>$._zod.innerType?._zod?.optout??void 0),$._zod.parse=(Q,W)=>{return $._zod.innerType._zod.run(Q,W)}}),kX=N("$ZodCustom",($,J)=>{n.init($,J),f.init($,J),$._zod.parse=(Q,W)=>{return Q},$._zod.check=(Q)=>{let W=Q.value,X=J.fn(W);if(X instanceof Promise)return X.then((Y)=>fH(Y,Q,W,$));fH(X,Q,W,$);return}});function fH($,J,Q,W){if(!$){let X={code:"custom",input:Q,inst:W,path:[...W._zod.def.path??[]],continue:!W._zod.def.abort};if(W._zod.def.params)X.params=W._zod.def.params;J.issues.push(N4(X))}}var i3={};var uH,p$=Symbol("ZodOutput"),c$=Symbol("ZodInput");class hX{constructor(){this._map=new WeakMap,this._idmap=new Map}add($,...J){let Q=J[0];if(this._map.set($,Q),Q&&typeof Q==="object"&&"id"in Q)this._idmap.set(Q.id,$);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove($){let J=this._map.get($);if(J&&typeof J==="object"&&"id"in J)this._idmap.delete(J.id);return this._map.delete($),this}get($){let J=$._zod.parent;if(J){let Q={...this.get(J)??{}};delete Q.id;let W={...Q,...this._map.get($)};return Object.keys(W).length?W:void 0}return this._map.get($)}has($){return this._map.has($)}}function o3(){return new hX}(uH=globalThis).__zod_globalRegistry??(uH.__zod_globalRegistry=o3());var C1=globalThis.__zod_globalRegistry;function yX($,J){return new $({type:"string",...z(J)})}function gX($,J){return new $({type:"string",coerce:!0,...z(J)})}function d$($,J){return new $({type:"string",format:"email",check:"string_format",abort:!1,...z(J)})}function n3($,J){return new $({type:"string",format:"guid",check:"string_format",abort:!1,...z(J)})}function r$($,J){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,...z(J)})}function i$($,J){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(J)})}function o$($,J){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(J)})}function n$($,J){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(J)})}function s3($,J){return new $({type:"string",format:"url",check:"string_format",abort:!1,...z(J)})}function s$($,J){return new $({type:"string",format:"emoji",check:"string_format",abort:!1,...z(J)})}function a$($,J){return new $({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(J)})}function t$($,J){return new $({type:"string",format:"cuid",check:"string_format",abort:!1,...z(J)})}function e$($,J){return new $({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(J)})}function $8($,J){return new $({type:"string",format:"ulid",check:"string_format",abort:!1,...z(J)})}function J8($,J){return new $({type:"string",format:"xid",check:"string_format",abort:!1,...z(J)})}function Q8($,J){return new $({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(J)})}function W8($,J){return new $({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(J)})}function X8($,J){return new $({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(J)})}function xX($,J){return new $({type:"string",format:"mac",check:"string_format",abort:!1,...z(J)})}function Y8($,J){return new $({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(J)})}function K8($,J){return new $({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(J)})}function B8($,J){return new $({type:"string",format:"base64",check:"string_format",abort:!1,...z(J)})}function q8($,J){return new $({type:"string",format:"base64url",check:"string_format",abort:!1,...z(J)})}function U8($,J){return new $({type:"string",format:"e164",check:"string_format",abort:!1,...z(J)})}function G8($,J){return new $({type:"string",format:"jwt",check:"string_format",abort:!1,...z(J)})}var H8={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function uX($,J){return new $({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(J)})}function mX($,J){return new $({type:"string",format:"date",check:"string_format",...z(J)})}function lX($,J){return new $({type:"string",format:"time",check:"string_format",precision:null,...z(J)})}function pX($,J){return new $({type:"string",format:"duration",check:"string_format",...z(J)})}function cX($,J){return new $({type:"number",checks:[],...z(J)})}function dX($,J){return new $({type:"number",coerce:!0,checks:[],...z(J)})}function rX($,J){return new $({type:"number",check:"number_format",abort:!1,format:"safeint",...z(J)})}function iX($,J){return new $({type:"number",check:"number_format",abort:!1,format:"float32",...z(J)})}function oX($,J){return new $({type:"number",check:"number_format",abort:!1,format:"float64",...z(J)})}function nX($,J){return new $({type:"number",check:"number_format",abort:!1,format:"int32",...z(J)})}function sX($,J){return new $({type:"number",check:"number_format",abort:!1,format:"uint32",...z(J)})}function aX($,J){return new $({type:"boolean",...z(J)})}function tX($,J){return new $({type:"boolean",coerce:!0,...z(J)})}function eX($,J){return new $({type:"bigint",...z(J)})}function $5($,J){return new $({type:"bigint",coerce:!0,...z(J)})}function J5($,J){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...z(J)})}function Q5($,J){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...z(J)})}function W5($,J){return new $({type:"symbol",...z(J)})}function X5($,J){return new $({type:"undefined",...z(J)})}function Y5($,J){return new $({type:"null",...z(J)})}function K5($){return new $({type:"any"})}function B5($){return new $({type:"unknown"})}function q5($,J){return new $({type:"never",...z(J)})}function U5($,J){return new $({type:"void",...z(J)})}function G5($,J){return new $({type:"date",...z(J)})}function H5($,J){return new $({type:"date",coerce:!0,...z(J)})}function Z5($,J){return new $({type:"nan",...z(J)})}function z0($,J){return new T$({check:"less_than",...z(J),value:$,inclusive:!1})}function u1($,J){return new T$({check:"less_than",...z(J),value:$,inclusive:!0})}function I0($,J){return new w$({check:"greater_than",...z(J),value:$,inclusive:!1})}function z1($,J){return new w$({check:"greater_than",...z(J),value:$,inclusive:!0})}function Z8($){return I0(0,$)}function L8($){return z0(0,$)}function M8($){return u1(0,$)}function O8($){return z1(0,$)}function K2($,J){return new BW({check:"multiple_of",...z(J),value:$})}function B2($,J){return new GW({check:"max_size",...z(J),maximum:$})}function j0($,J){return new HW({check:"min_size",...z(J),minimum:$})}function h2($,J){return new ZW({check:"size_equals",...z(J),size:$})}function y2($,J){return new LW({check:"max_length",...z(J),maximum:$})}function x0($,J){return new MW({check:"min_length",...z(J),minimum:$})}function g2($,J){return new OW({check:"length_equals",...z(J),length:$})}function R4($,J){return new NW({check:"string_format",format:"regex",...z(J),pattern:$})}function b4($){return new FW({check:"string_format",format:"lowercase",...z($)})}function P4($){return new VW({check:"string_format",format:"uppercase",...z($)})}function A4($,J){return new _W({check:"string_format",format:"includes",...z(J),includes:$})}function E4($,J){return new DW({check:"string_format",format:"starts_with",...z(J),prefix:$})}function C4($,J){return new zW({check:"string_format",format:"ends_with",...z(J),suffix:$})}function N8($,J,Q){return new IW({check:"property",property:$,schema:J,...z(Q)})}function S4($,J){return new jW({check:"mime_type",mime:$,...z(J)})}function Y0($){return new RW({check:"overwrite",tx:$})}function T4($){return Y0((J)=>J.normalize($))}function w4(){return Y0(($)=>$.trim())}function v4(){return Y0(($)=>$.toLowerCase())}function f4(){return Y0(($)=>$.toUpperCase())}function k4(){return Y0(($)=>j7($))}function L5($,J,Q){return new $({type:"array",element:J,...z(Q)})}function Sb($,J,Q){return new $({type:"union",options:J,...z(Q)})}function Tb($,J,Q){return new $({type:"union",options:J,inclusive:!1,...z(Q)})}function wb($,J,Q,W){return new $({type:"union",options:Q,discriminator:J,...z(W)})}function vb($,J,Q){return new $({type:"intersection",left:J,right:Q})}function fb($,J,Q,W){let X=Q instanceof f;return new $({type:"tuple",items:J,rest:X?Q:null,...z(X?W:Q)})}function kb($,J,Q,W){return new $({type:"record",keyType:J,valueType:Q,...z(W)})}function hb($,J,Q,W){return new $({type:"map",keyType:J,valueType:Q,...z(W)})}function yb($,J,Q){return new $({type:"set",valueType:J,...z(Q)})}function gb($,J,Q){let W=Array.isArray(J)?Object.fromEntries(J.map((X)=>[X,X])):J;return new $({type:"enum",entries:W,...z(Q)})}function xb($,J,Q){return new $({type:"enum",entries:J,...z(Q)})}function ub($,J,Q){return new $({type:"literal",values:Array.isArray(J)?J:[J],...z(Q)})}function M5($,J){return new $({type:"file",...z(J)})}function mb($,J){return new $({type:"transform",transform:J})}function lb($,J){return new $({type:"optional",innerType:J})}function pb($,J){return new $({type:"nullable",innerType:J})}function cb($,J,Q){return new $({type:"default",innerType:J,get defaultValue(){return typeof Q==="function"?Q():b7(Q)}})}function db($,J,Q){return new $({type:"nonoptional",innerType:J,...z(Q)})}function rb($,J){return new $({type:"success",innerType:J})}function ib($,J,Q){return new $({type:"catch",innerType:J,catchValue:typeof Q==="function"?Q:()=>Q})}function ob($,J,Q){return new $({type:"pipe",in:J,out:Q})}function nb($,J){return new $({type:"readonly",innerType:J})}function sb($,J,Q){return new $({type:"template_literal",parts:J,...z(Q)})}function ab($,J){return new $({type:"lazy",getter:J})}function tb($,J){return new $({type:"promise",innerType:J})}function O5($,J,Q){let W=z(Q);return W.abort??(W.abort=!0),new $({type:"custom",check:"custom",fn:J,...W})}function N5($,J,Q){return new $({type:"custom",check:"custom",fn:J,...z(Q)})}function F5($){let J=mH((Q)=>{return Q.addIssue=(W)=>{if(typeof W==="string")Q.issues.push(N4(W,Q.value,J._zod.def));else{let X=W;if(X.fatal)X.continue=!1;X.code??(X.code="custom"),X.input??(X.input=Q.value),X.inst??(X.inst=J),X.continue??(X.continue=!J._zod.def.abort),Q.issues.push(N4(X))}},$(Q.value,Q)});return J}function mH($,J){let Q=new n({check:"custom",...z(J)});return Q._zod.check=$,Q}function V5($){let J=new n({check:"describe"});return J._zod.onattach=[(Q)=>{let W=C1.get(Q)??{};C1.add(Q,{...W,description:$})}],J._zod.check=()=>{},J}function _5($){let J=new n({check:"meta"});return J._zod.onattach=[(Q)=>{let W=C1.get(Q)??{};C1.add(Q,{...W,...$})}],J._zod.check=()=>{},J}function D5($,J){let Q=z(J),W=Q.truthy??["true","1","yes","on","y","enabled"],X=Q.falsy??["false","0","no","off","n","disabled"];if(Q.case!=="sensitive")W=W.map((Z)=>typeof Z==="string"?Z.toLowerCase():Z),X=X.map((Z)=>typeof Z==="string"?Z.toLowerCase():Z);let Y=new Set(W),K=new Set(X),B=$.Codec??r3,q=$.Boolean??c3,G=new($.String??k2)({type:"string",error:Q.error}),H=new q({type:"boolean",error:Q.error}),L=new B({type:"pipe",in:G,out:H,transform:(Z,M)=>{let O=Z;if(Q.case!=="sensitive")O=O.toLowerCase();if(Y.has(O))return!0;else if(K.has(O))return!1;else return M.issues.push({code:"invalid_value",expected:"stringbool",values:[...Y,...K],input:M.value,inst:L,continue:!1}),{}},reverseTransform:(Z,M)=>{if(Z===!0)return W[0]||"true";else return X[0]||"false"},error:Q.error});return L}function h4($,J,Q,W={}){let X=z(W),Y={...z(W),check:"string_format",type:"string",format:J,fn:typeof Q==="function"?Q:(B)=>Q.test(B),...X};if(Q instanceof RegExp)Y.pattern=Q;return new $(Y)}var y4=()=>{throw Error("JSON Schema conversion is not bundled into this plugin artifact")},z5=()=>y4,F8=()=>y4,g4=y4,s=y4,x4=y4,u4=y4;var eb={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},I5=($,J,Q,W)=>{let X=Q;X.type="string";let{minimum:Y,maximum:K,format:B,patterns:q,contentEncoding:U}=$._zod.bag;if(typeof Y==="number")X.minLength=Y;if(typeof K==="number")X.maxLength=K;if(B){if(X.format=eb[B]??B,X.format==="")delete X.format;if(B==="time")delete X.format}if(U)X.contentEncoding=U;if(q&&q.size>0){let G=[...q];if(G.length===1)X.pattern=G[0].source;else if(G.length>1)X.allOf=[...G.map((H)=>({...J.target==="draft-07"||J.target==="draft-04"||J.target==="openapi-3.0"?{type:"string"}:{},pattern:H.source}))]}},j5=($,J,Q,W)=>{let X=Q,{minimum:Y,maximum:K,format:B,multipleOf:q,exclusiveMaximum:U,exclusiveMinimum:G}=$._zod.bag;if(typeof B==="string"&&B.includes("int"))X.type="integer";else X.type="number";if(typeof G==="number")if(J.target==="draft-04"||J.target==="openapi-3.0")X.minimum=G,X.exclusiveMinimum=!0;else X.exclusiveMinimum=G;if(typeof Y==="number"){if(X.minimum=Y,typeof G==="number"&&J.target!=="draft-04")if(G>=Y)delete X.minimum;else delete X.exclusiveMinimum}if(typeof U==="number")if(J.target==="draft-04"||J.target==="openapi-3.0")X.maximum=U,X.exclusiveMaximum=!0;else X.exclusiveMaximum=U;if(typeof K==="number"){if(X.maximum=K,typeof U==="number"&&J.target!=="draft-04")if(U<=K)delete X.maximum;else delete X.exclusiveMaximum}if(typeof q==="number")X.multipleOf=q},R5=($,J,Q,W)=>{Q.type="boolean"},b5=($,J,Q,W)=>{if(J.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},P5=($,J,Q,W)=>{if(J.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},A5=($,J,Q,W)=>{if(J.target==="openapi-3.0")Q.type="string",Q.nullable=!0,Q.enum=[null];else Q.type="null"},E5=($,J,Q,W)=>{if(J.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},C5=($,J,Q,W)=>{if(J.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},S5=($,J,Q,W)=>{Q.not={}},T5=($,J,Q,W)=>{},w5=($,J,Q,W)=>{},v5=($,J,Q,W)=>{if(J.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},f5=($,J,Q,W)=>{let X=$._zod.def,Y=k3(X.entries);if(Y.every((K)=>typeof K==="number"))Q.type="number";if(Y.every((K)=>typeof K==="string"))Q.type="string";Q.enum=Y},k5=($,J,Q,W)=>{let X=$._zod.def,Y=[];for(let K of X.values)if(K===void 0){if(J.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof K==="bigint")if(J.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else Y.push(Number(K));else Y.push(K);if(Y.length===0);else if(Y.length===1){let K=Y[0];if(Q.type=K===null?"null":typeof K,J.target==="draft-04"||J.target==="openapi-3.0")Q.enum=[K];else Q.const=K}else{if(Y.every((K)=>typeof K==="number"))Q.type="number";if(Y.every((K)=>typeof K==="string"))Q.type="string";if(Y.every((K)=>typeof K==="boolean"))Q.type="boolean";if(Y.every((K)=>K===null))Q.type="null";Q.enum=Y}},h5=($,J,Q,W)=>{if(J.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},y5=($,J,Q,W)=>{let X=Q,Y=$._zod.pattern;if(!Y)throw Error("Pattern not found in template literal");X.type="string",X.pattern=Y.source},g5=($,J,Q,W)=>{let X=Q,Y={type:"string",format:"binary",contentEncoding:"binary"},{minimum:K,maximum:B,mime:q}=$._zod.bag;if(K!==void 0)Y.minLength=K;if(B!==void 0)Y.maxLength=B;if(q)if(q.length===1)Y.contentMediaType=q[0],Object.assign(X,Y);else Object.assign(X,Y),X.anyOf=q.map((U)=>({contentMediaType:U}));else Object.assign(X,Y)},x5=($,J,Q,W)=>{Q.type="boolean"},u5=($,J,Q,W)=>{if(J.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},m5=($,J,Q,W)=>{if(J.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},l5=($,J,Q,W)=>{if(J.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},p5=($,J,Q,W)=>{if(J.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},c5=($,J,Q,W)=>{if(J.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},d5=($,J,Q,W)=>{let X=Q,Y=$._zod.def,{minimum:K,maximum:B}=$._zod.bag;if(typeof K==="number")X.minItems=K;if(typeof B==="number")X.maxItems=B;X.type="array",X.items=s(Y.element,J,{...W,path:[...W.path,"items"]})},r5=($,J,Q,W)=>{let X=Q,Y=$._zod.def;X.type="object",X.properties={};let K=Y.shape;for(let U in K)X.properties[U]=s(K[U],J,{...W,path:[...W.path,"properties",U]});let B=new Set(Object.keys(K)),q=new Set([...B].filter((U)=>{let G=Y.shape[U]._zod;if(J.io==="input")return G.optin===void 0;else return G.optout===void 0}));if(q.size>0)X.required=Array.from(q);if(Y.catchall?._zod.def.type==="never")X.additionalProperties=!1;else if(!Y.catchall){if(J.io==="output")X.additionalProperties=!1}else if(Y.catchall)X.additionalProperties=s(Y.catchall,J,{...W,path:[...W.path,"additionalProperties"]})},_8=($,J,Q,W)=>{let X=$._zod.def,Y=X.inclusive===!1,K=X.options.map((B,q)=>s(B,J,{...W,path:[...W.path,Y?"oneOf":"anyOf",q]}));if(Y)Q.oneOf=K;else Q.anyOf=K},i5=($,J,Q,W)=>{let X=$._zod.def,Y=s(X.left,J,{...W,path:[...W.path,"allOf",0]}),K=s(X.right,J,{...W,path:[...W.path,"allOf",1]}),B=(U)=>("allOf"in U)&&Object.keys(U).length===1,q=[...B(Y)?Y.allOf:[Y],...B(K)?K.allOf:[K]];Q.allOf=q},o5=($,J,Q,W)=>{let X=Q,Y=$._zod.def;X.type="array";let K=J.target==="draft-2020-12"?"prefixItems":"items",B=J.target==="draft-2020-12"?"items":J.target==="openapi-3.0"?"items":"additionalItems",q=Y.items.map((L,Z)=>s(L,J,{...W,path:[...W.path,K,Z]})),U=Y.rest?s(Y.rest,J,{...W,path:[...W.path,B,...J.target==="openapi-3.0"?[Y.items.length]:[]]}):null;if(J.target==="draft-2020-12"){if(X.prefixItems=q,U)X.items=U}else if(J.target==="openapi-3.0"){if(X.items={anyOf:q},U)X.items.anyOf.push(U);if(X.minItems=q.length,!U)X.maxItems=q.length}else if(X.items=q,U)X.additionalItems=U;let{minimum:G,maximum:H}=$._zod.bag;if(typeof G==="number")X.minItems=G;if(typeof H==="number")X.maxItems=H},n5=($,J,Q,W)=>{let X=Q,Y=$._zod.def;X.type="object";let K=Y.keyType,q=K._zod.bag?.patterns;if(Y.mode==="loose"&&q&&q.size>0){let G=s(Y.valueType,J,{...W,path:[...W.path,"patternProperties","*"]});X.patternProperties={};for(let H of q)X.patternProperties[H.source]=G}else{if(J.target==="draft-07"||J.target==="draft-2020-12")X.propertyNames=s(Y.keyType,J,{...W,path:[...W.path,"propertyNames"]});X.additionalProperties=s(Y.valueType,J,{...W,path:[...W.path,"additionalProperties"]})}let U=K._zod.values;if(U){let G=[...U].filter((H)=>typeof H==="string"||typeof H==="number");if(G.length>0)X.required=G}},s5=($,J,Q,W)=>{let X=$._zod.def,Y=s(X.innerType,J,W),K=J.seen.get($);if(J.target==="openapi-3.0")K.ref=X.innerType,Q.nullable=!0;else Q.anyOf=[Y,{type:"null"}]},a5=($,J,Q,W)=>{let X=$._zod.def;s(X.innerType,J,W);let Y=J.seen.get($);Y.ref=X.innerType},t5=($,J,Q,W)=>{let X=$._zod.def;s(X.innerType,J,W);let Y=J.seen.get($);Y.ref=X.innerType,Q.default=JSON.parse(JSON.stringify(X.defaultValue))},e5=($,J,Q,W)=>{let X=$._zod.def;s(X.innerType,J,W);let Y=J.seen.get($);if(Y.ref=X.innerType,J.io==="input")Q._prefault=JSON.parse(JSON.stringify(X.defaultValue))},$Y=($,J,Q,W)=>{let X=$._zod.def;s(X.innerType,J,W);let Y=J.seen.get($);Y.ref=X.innerType;let K;try{K=X.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}Q.default=K},JY=($,J,Q,W)=>{let X=$._zod.def,Y=J.io==="input"?X.in._zod.def.type==="transform"?X.out:X.in:X.out;s(Y,J,W);let K=J.seen.get($);K.ref=Y},QY=($,J,Q,W)=>{let X=$._zod.def;s(X.innerType,J,W);let Y=J.seen.get($);Y.ref=X.innerType,Q.readOnly=!0},WY=($,J,Q,W)=>{let X=$._zod.def;s(X.innerType,J,W);let Y=J.seen.get($);Y.ref=X.innerType},D8=($,J,Q,W)=>{let X=$._zod.def;s(X.innerType,J,W);let Y=J.seen.get($);Y.ref=X.innerType},XY=($,J,Q,W)=>{let X=$._zod.innerType;s(X,J,W);let Y=J.seen.get($);Y.ref=X},V8={string:I5,number:j5,boolean:R5,bigint:b5,symbol:P5,null:A5,undefined:E5,void:C5,never:S5,any:T5,unknown:w5,date:v5,enum:f5,literal:k5,nan:h5,template_literal:y5,file:g5,success:x5,custom:u5,function:m5,transform:l5,map:p5,set:c5,array:d5,object:r5,union:_8,intersection:i5,tuple:o5,record:n5,nullable:s5,nonoptional:a5,default:t5,prefault:e5,catch:$Y,pipe:JY,readonly:QY,promise:WY,optional:D8,lazy:XY};function a3($,J){if("_idmap"in $){let W=$,X=g4({...J,processors:V8}),Y={};for(let q of W._idmap.entries()){let[U,G]=q;s(G,X)}let K={},B={registry:W,uri:J?.uri,defs:Y};X.external=B;for(let q of W._idmap.entries()){let[U,G]=q;x4(X,G),K[U]=u4(X,G)}if(Object.keys(Y).length>0){let q=X.target==="draft-2020-12"?"$defs":"definitions";K.__shared={[q]:Y}}return{schemas:K}}let Q=g4({...J,processors:V8});return s($,Q),x4(Q,$),u4(Q,$)}class YY{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter($){this.ctx.counter=$}get seen(){return this.ctx.seen}constructor($){let J=$?.target??"draft-2020-12";if(J==="draft-4")J="draft-04";if(J==="draft-7")J="draft-07";this.ctx=g4({processors:V8,target:J,...$?.metadata&&{metadata:$.metadata},...$?.unrepresentable&&{unrepresentable:$.unrepresentable},...$?.override&&{override:$.override},...$?.io&&{io:$.io}})}process($,J={path:[],schemaPath:[]}){return s($,this.ctx,J)}emit($,J){if(J){if(J.cycles)this.ctx.cycles=J.cycles;if(J.reused)this.ctx.reused=J.reused;if(J.external)this.ctx.external=J.external}x4(this.ctx,$);let Q=u4(this.ctx,$),{"~standard":W,...X}=Q;return X}}var lH={};var Q6={};U2(Q6,{time:()=>qY,duration:()=>UY,datetime:()=>KY,date:()=>BY,ZodISOTime:()=>$6,ZodISODuration:()=>J6,ZodISODateTime:()=>t3,ZodISODate:()=>e3});var t3=N("ZodISODateTime",($,J)=>{gW.init($,J),o.init($,J)});function KY($){return uX(t3,$)}var e3=N("ZodISODate",($,J)=>{xW.init($,J),o.init($,J)});function BY($){return mX(e3,$)}var $6=N("ZodISOTime",($,J)=>{uW.init($,J),o.init($,J)});function qY($){return lX($6,$)}var J6=N("ZodISODuration",($,J)=>{mW.init($,J),o.init($,J)});function UY($){return pX(J6,$)}var cH=($,J)=>{u3.init($,J),$.name="ZodError",Object.defineProperties($,{format:{value:(Q)=>V4($,Q)},flatten:{value:(Q)=>F4($,Q)},addIssue:{value:(Q)=>{$.issues.push(Q),$.message=JSON.stringify($.issues,M4,2)}},addIssues:{value:(Q)=>{$.issues.push(...Q),$.message=JSON.stringify($.issues,M4,2)}},isEmpty:{get(){return $.issues.length===0}}})},dH=N("ZodError",cH),I1=N("ZodError",cH,{Parent:Error});var z8=_4(I1),I8=D4(I1),j8=z4(I1),R8=I4(I1),b8=I$(I1),P8=j$(I1),A8=R$(I1),E8=b$(I1),C8=P$(I1),S8=A$(I1),T8=E$(I1),w8=C$(I1);var y=N("ZodType",($,J)=>{return f.init($,J),Object.assign($["~standard"],{jsonSchema:{input:F8($,"input"),output:F8($,"output")}}),$.toJSONSchema=z5($,{}),$.def=J,$.type=J.type,Object.defineProperty($,"_def",{value:J}),$.check=(...Q)=>{return $.clone(w.mergeDefs(J,{checks:[...J.checks??[],...Q.map((W)=>typeof W==="function"?{_zod:{check:W,def:{check:"custom"},onattach:[]}}:W)]}),{parent:!0})},$.with=$.check,$.clone=(Q,W)=>N1($,Q,W),$.brand=()=>$,$.register=(Q,W)=>{return Q.add($,W),$},$.parse=(Q,W)=>z8($,Q,W,{callee:$.parse}),$.safeParse=(Q,W)=>j8($,Q,W),$.parseAsync=async(Q,W)=>I8($,Q,W,{callee:$.parseAsync}),$.safeParseAsync=async(Q,W)=>R8($,Q,W),$.spa=$.safeParseAsync,$.encode=(Q,W)=>b8($,Q,W),$.decode=(Q,W)=>P8($,Q,W),$.encodeAsync=async(Q,W)=>A8($,Q,W),$.decodeAsync=async(Q,W)=>E8($,Q,W),$.safeEncode=(Q,W)=>C8($,Q,W),$.safeDecode=(Q,W)=>S8($,Q,W),$.safeEncodeAsync=async(Q,W)=>T8($,Q,W),$.safeDecodeAsync=async(Q,W)=>w8($,Q,W),$.refine=(Q,W)=>$.check(eY(Q,W)),$.superRefine=(Q)=>$.check($K(Q)),$.overwrite=(Q)=>$.check(Y0(Q)),$.optional=()=>X6($),$.exactOptional=()=>kY($),$.nullable=()=>Y6($),$.nullish=()=>X6(Y6($)),$.nonoptional=(Q)=>mY($,Q),$.array=()=>U6($),$.or=(Q)=>$J([$,Q]),$.and=(Q)=>bY($,Q),$.transform=(Q)=>K6($,QJ(Q)),$.default=(Q)=>gY($,Q),$.prefault=(Q)=>uY($,Q),$.catch=(Q)=>cY($,Q),$.pipe=(Q)=>K6($,Q),$.readonly=()=>iY($),$.describe=(Q)=>{let W=$.clone();return C1.add(W,{description:Q}),W},Object.defineProperty($,"description",{get(){return C1.get($)?.description},configurable:!0}),$.meta=(...Q)=>{if(Q.length===0)return C1.get($);let W=$.clone();return C1.add(W,Q[0]),W},$.isOptional=()=>$.safeParse(void 0).success,$.isNullable=()=>$.safeParse(null).success,$.apply=(Q)=>Q($),$}),k8=N("_ZodString",($,J)=>{k2.init($,J),y.init($,J),$._zod.processJSONSchema=(W,X,Y)=>I5($,W,X,Y);let Q=$._zod.bag;$.format=Q.format??null,$.minLength=Q.minimum??null,$.maxLength=Q.maximum??null,$.regex=(...W)=>$.check(R4(...W)),$.includes=(...W)=>$.check(A4(...W)),$.startsWith=(...W)=>$.check(E4(...W)),$.endsWith=(...W)=>$.check(C4(...W)),$.min=(...W)=>$.check(x0(...W)),$.max=(...W)=>$.check(y2(...W)),$.length=(...W)=>$.check(g2(...W)),$.nonempty=(...W)=>$.check(x0(1,...W)),$.lowercase=(W)=>$.check(b4(W)),$.uppercase=(W)=>$.check(P4(W)),$.trim=()=>$.check(w4()),$.normalize=(...W)=>$.check(T4(...W)),$.toLowerCase=()=>$.check(v4()),$.toUpperCase=()=>$.check(f4()),$.slugify=()=>$.check(k4())}),l4=N("ZodString",($,J)=>{k2.init($,J),k8.init($,J),$.email=(Q)=>$.check(d$(h8,Q)),$.url=(Q)=>$.check(s3(B6,Q)),$.jwt=(Q)=>$.check(G8(a8,Q)),$.emoji=(Q)=>$.check(s$(y8,Q)),$.guid=(Q)=>$.check(n3(W6,Q)),$.uuid=(Q)=>$.check(r$(b0,Q)),$.uuidv4=(Q)=>$.check(i$(b0,Q)),$.uuidv6=(Q)=>$.check(o$(b0,Q)),$.uuidv7=(Q)=>$.check(n$(b0,Q)),$.nanoid=(Q)=>$.check(a$(g8,Q)),$.guid=(Q)=>$.check(n3(W6,Q)),$.cuid=(Q)=>$.check(t$(x8,Q)),$.cuid2=(Q)=>$.check(e$(u8,Q)),$.ulid=(Q)=>$.check($8(m8,Q)),$.base64=(Q)=>$.check(B8(o8,Q)),$.base64url=(Q)=>$.check(q8(n8,Q)),$.xid=(Q)=>$.check(J8(l8,Q)),$.ksuid=(Q)=>$.check(Q8(p8,Q)),$.ipv4=(Q)=>$.check(W8(c8,Q)),$.ipv6=(Q)=>$.check(X8(d8,Q)),$.cidrv4=(Q)=>$.check(Y8(r8,Q)),$.cidrv6=(Q)=>$.check(K8(i8,Q)),$.e164=(Q)=>$.check(U8(s8,Q)),$.datetime=(Q)=>$.check(KY(Q)),$.date=(Q)=>$.check(BY(Q)),$.time=(Q)=>$.check(qY(Q)),$.duration=(Q)=>$.check(UY(Q))});function v8($){return yX(l4,$)}var o=N("ZodStringFormat",($,J)=>{i.init($,J),k8.init($,J)}),h8=N("ZodEmail",($,J)=>{CW.init($,J),o.init($,J)});function rH($){return d$(h8,$)}var W6=N("ZodGUID",($,J)=>{AW.init($,J),o.init($,J)});function iH($){return n3(W6,$)}var b0=N("ZodUUID",($,J)=>{EW.init($,J),o.init($,J)});function oH($){return r$(b0,$)}function nH($){return i$(b0,$)}function sH($){return o$(b0,$)}function aH($){return n$(b0,$)}var B6=N("ZodURL",($,J)=>{SW.init($,J),o.init($,J)});function tH($){return s3(B6,$)}function eH($){return s3(B6,{protocol:/^https?$/,hostname:x1.domain,...w.normalizeParams($)})}var y8=N("ZodEmoji",($,J)=>{TW.init($,J),o.init($,J)});function $Z($){return s$(y8,$)}var g8=N("ZodNanoID",($,J)=>{wW.init($,J),o.init($,J)});function JZ($){return a$(g8,$)}var x8=N("ZodCUID",($,J)=>{vW.init($,J),o.init($,J)});function QZ($){return t$(x8,$)}var u8=N("ZodCUID2",($,J)=>{fW.init($,J),o.init($,J)});function WZ($){return e$(u8,$)}var m8=N("ZodULID",($,J)=>{kW.init($,J),o.init($,J)});function XZ($){return $8(m8,$)}var l8=N("ZodXID",($,J)=>{hW.init($,J),o.init($,J)});function YZ($){return J8(l8,$)}var p8=N("ZodKSUID",($,J)=>{yW.init($,J),o.init($,J)});function KZ($){return Q8(p8,$)}var c8=N("ZodIPv4",($,J)=>{lW.init($,J),o.init($,J)});function BZ($){return W8(c8,$)}var GY=N("ZodMAC",($,J)=>{cW.init($,J),o.init($,J)});function qZ($){return xX(GY,$)}var d8=N("ZodIPv6",($,J)=>{pW.init($,J),o.init($,J)});function UZ($){return X8(d8,$)}var r8=N("ZodCIDRv4",($,J)=>{dW.init($,J),o.init($,J)});function GZ($){return Y8(r8,$)}var i8=N("ZodCIDRv6",($,J)=>{rW.init($,J),o.init($,J)});function HZ($){return K8(i8,$)}var o8=N("ZodBase64",($,J)=>{oW.init($,J),o.init($,J)});function ZZ($){return B8(o8,$)}var n8=N("ZodBase64URL",($,J)=>{nW.init($,J),o.init($,J)});function LZ($){return q8(n8,$)}var s8=N("ZodE164",($,J)=>{sW.init($,J),o.init($,J)});function MZ($){return U8(s8,$)}var a8=N("ZodJWT",($,J)=>{aW.init($,J),o.init($,J)});function OZ($){return G8(a8,$)}var p4=N("ZodCustomStringFormat",($,J)=>{tW.init($,J),o.init($,J)});function NZ($,J,Q={}){return h4(p4,$,J,Q)}function FZ($){return h4(p4,"hostname",x1.hostname,$)}function VZ($){return h4(p4,"hex",x1.hex,$)}function _Z($,J){let Q=J?.enc??"hex",W=`${$}_${Q}`,X=x1[W];if(!X)throw Error(`Unrecognized hash format: ${W}`);return h4(p4,W,X,J)}var c4=N("ZodNumber",($,J)=>{x$.init($,J),y.init($,J),$._zod.processJSONSchema=(W,X,Y)=>j5($,W,X,Y),$.gt=(W,X)=>$.check(I0(W,X)),$.gte=(W,X)=>$.check(z1(W,X)),$.min=(W,X)=>$.check(z1(W,X)),$.lt=(W,X)=>$.check(z0(W,X)),$.lte=(W,X)=>$.check(u1(W,X)),$.max=(W,X)=>$.check(u1(W,X)),$.int=(W)=>$.check(f8(W)),$.safe=(W)=>$.check(f8(W)),$.positive=(W)=>$.check(I0(0,W)),$.nonnegative=(W)=>$.check(z1(0,W)),$.negative=(W)=>$.check(z0(0,W)),$.nonpositive=(W)=>$.check(u1(0,W)),$.multipleOf=(W,X)=>$.check(K2(W,X)),$.step=(W,X)=>$.check(K2(W,X)),$.finite=()=>$;let Q=$._zod.bag;$.minValue=Math.max(Q.minimum??Number.NEGATIVE_INFINITY,Q.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,$.maxValue=Math.min(Q.maximum??Number.POSITIVE_INFINITY,Q.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,$.isInt=(Q.format??"").includes("int")||Number.isSafeInteger(Q.multipleOf??0.5),$.isFinite=!0,$.format=Q.format??null});function HY($){return cX(c4,$)}var u2=N("ZodNumberFormat",($,J)=>{eW.init($,J),c4.init($,J)});function f8($){return rX(u2,$)}function DZ($){return iX(u2,$)}function zZ($){return oX(u2,$)}function IZ($){return nX(u2,$)}function jZ($){return sX(u2,$)}var d4=N("ZodBoolean",($,J)=>{c3.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>R5($,Q,W,X)});function ZY($){return aX(d4,$)}var r4=N("ZodBigInt",($,J)=>{u$.init($,J),y.init($,J),$._zod.processJSONSchema=(W,X,Y)=>b5($,W,X,Y),$.gte=(W,X)=>$.check(z1(W,X)),$.min=(W,X)=>$.check(z1(W,X)),$.gt=(W,X)=>$.check(I0(W,X)),$.gte=(W,X)=>$.check(z1(W,X)),$.min=(W,X)=>$.check(z1(W,X)),$.lt=(W,X)=>$.check(z0(W,X)),$.lte=(W,X)=>$.check(u1(W,X)),$.max=(W,X)=>$.check(u1(W,X)),$.positive=(W)=>$.check(I0(BigInt(0),W)),$.negative=(W)=>$.check(z0(BigInt(0),W)),$.nonpositive=(W)=>$.check(u1(BigInt(0),W)),$.nonnegative=(W)=>$.check(z1(BigInt(0),W)),$.multipleOf=(W,X)=>$.check(K2(W,X));let Q=$._zod.bag;$.minValue=Q.minimum??null,$.maxValue=Q.maximum??null,$.format=Q.format??null});function RZ($){return eX(r4,$)}var t8=N("ZodBigIntFormat",($,J)=>{$X.init($,J),r4.init($,J)});function bZ($){return J5(t8,$)}function PZ($){return Q5(t8,$)}var LY=N("ZodSymbol",($,J)=>{JX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>P5($,Q,W,X)});function AZ($){return W5(LY,$)}var MY=N("ZodUndefined",($,J)=>{QX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>E5($,Q,W,X)});function EZ($){return X5(MY,$)}var OY=N("ZodNull",($,J)=>{WX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>A5($,Q,W,X)});function NY($){return Y5(OY,$)}var FY=N("ZodAny",($,J)=>{XX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>T5($,Q,W,X)});function CZ(){return K5(FY)}var VY=N("ZodUnknown",($,J)=>{YX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>w5($,Q,W,X)});function x2(){return B5(VY)}var _Y=N("ZodNever",($,J)=>{KX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>S5($,Q,W,X)});function e8($){return q5(_Y,$)}var DY=N("ZodVoid",($,J)=>{BX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>C5($,Q,W,X)});function SZ($){return U5(DY,$)}var q6=N("ZodDate",($,J)=>{qX.init($,J),y.init($,J),$._zod.processJSONSchema=(W,X,Y)=>v5($,W,X,Y),$.min=(W,X)=>$.check(z1(W,X)),$.max=(W,X)=>$.check(u1(W,X));let Q=$._zod.bag;$.minDate=Q.minimum?new Date(Q.minimum):null,$.maxDate=Q.maximum?new Date(Q.maximum):null});function TZ($){return G5(q6,$)}var zY=N("ZodArray",($,J)=>{UX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>d5($,Q,W,X),$.element=J.element,$.min=(Q,W)=>$.check(x0(Q,W)),$.nonempty=(Q)=>$.check(x0(1,Q)),$.max=(Q,W)=>$.check(y2(Q,W)),$.length=(Q,W)=>$.check(g2(Q,W)),$.unwrap=()=>$.element});function U6($,J){return L5(zY,$,J)}function wZ($){let J=$._zod.def.shape;return JJ(Object.keys(J))}var G6=N("ZodObject",($,J)=>{GX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>r5($,Q,W,X),w.defineLazy($,"shape",()=>{return J.shape}),$.keyof=()=>JJ(Object.keys($._zod.def.shape)),$.catchall=(Q)=>$.clone({...$._zod.def,catchall:Q}),$.passthrough=()=>$.clone({...$._zod.def,catchall:x2()}),$.loose=()=>$.clone({...$._zod.def,catchall:x2()}),$.strict=()=>$.clone({...$._zod.def,catchall:e8()}),$.strip=()=>$.clone({...$._zod.def,catchall:void 0}),$.extend=(Q)=>{return w.extend($,Q)},$.safeExtend=(Q)=>{return w.safeExtend($,Q)},$.merge=(Q)=>w.merge($,Q),$.pick=(Q)=>w.pick($,Q),$.omit=(Q)=>w.omit($,Q),$.partial=(...Q)=>w.partial(WJ,$,Q[0]),$.required=(...Q)=>w.required(XJ,$,Q[0])});function vZ($,J){let Q={type:"object",shape:$??{},...w.normalizeParams(J)};return new G6(Q)}function fZ($,J){return new G6({type:"object",shape:$,catchall:e8(),...w.normalizeParams(J)})}function kZ($,J){return new G6({type:"object",shape:$,catchall:x2(),...w.normalizeParams(J)})}var H6=N("ZodUnion",($,J)=>{d3.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>_8($,Q,W,X),$.options=J.options});function $J($,J){return new H6({type:"union",options:$,...w.normalizeParams(J)})}var IY=N("ZodXor",($,J)=>{H6.init($,J),HX.init($,J),$._zod.processJSONSchema=(Q,W,X)=>_8($,Q,W,X),$.options=J.options});function hZ($,J){return new IY({type:"union",options:$,inclusive:!1,...w.normalizeParams(J)})}var jY=N("ZodDiscriminatedUnion",($,J)=>{H6.init($,J),ZX.init($,J)});function yZ($,J,Q){return new jY({type:"union",options:J,discriminator:$,...w.normalizeParams(Q)})}var RY=N("ZodIntersection",($,J)=>{LX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>i5($,Q,W,X)});function bY($,J){return new RY({type:"intersection",left:$,right:J})}var PY=N("ZodTuple",($,J)=>{m$.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>o5($,Q,W,X),$.rest=(Q)=>$.clone({...$._zod.def,rest:Q})});function AY($,J,Q){let W=J instanceof f,X=W?Q:J;return new PY({type:"tuple",items:$,rest:W?J:null,...w.normalizeParams(X)})}var Z6=N("ZodRecord",($,J)=>{MX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>n5($,Q,W,X),$.keyType=J.keyType,$.valueType=J.valueType});function EY($,J,Q){return new Z6({type:"record",keyType:$,valueType:J,...w.normalizeParams(Q)})}function gZ($,J,Q){let W=N1($);return W._zod.values=void 0,new Z6({type:"record",keyType:W,valueType:J,...w.normalizeParams(Q)})}function xZ($,J,Q){return new Z6({type:"record",keyType:$,valueType:J,mode:"loose",...w.normalizeParams(Q)})}var CY=N("ZodMap",($,J)=>{OX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>p5($,Q,W,X),$.keyType=J.keyType,$.valueType=J.valueType,$.min=(...Q)=>$.check(j0(...Q)),$.nonempty=(Q)=>$.check(j0(1,Q)),$.max=(...Q)=>$.check(B2(...Q)),$.size=(...Q)=>$.check(h2(...Q))});function uZ($,J,Q){return new CY({type:"map",keyType:$,valueType:J,...w.normalizeParams(Q)})}var SY=N("ZodSet",($,J)=>{NX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>c5($,Q,W,X),$.min=(...Q)=>$.check(j0(...Q)),$.nonempty=(Q)=>$.check(j0(1,Q)),$.max=(...Q)=>$.check(B2(...Q)),$.size=(...Q)=>$.check(h2(...Q))});function mZ($,J){return new SY({type:"set",valueType:$,...w.normalizeParams(J)})}var m4=N("ZodEnum",($,J)=>{FX.init($,J),y.init($,J),$._zod.processJSONSchema=(W,X,Y)=>f5($,W,X,Y),$.enum=J.entries,$.options=Object.values(J.entries);let Q=new Set(Object.keys(J.entries));$.extract=(W,X)=>{let Y={};for(let K of W)if(Q.has(K))Y[K]=J.entries[K];else throw Error(`Key ${K} not found in enum`);return new m4({...J,checks:[],...w.normalizeParams(X),entries:Y})},$.exclude=(W,X)=>{let Y={...J.entries};for(let K of W)if(Q.has(K))delete Y[K];else throw Error(`Key ${K} not found in enum`);return new m4({...J,checks:[],...w.normalizeParams(X),entries:Y})}});function JJ($,J){let Q=Array.isArray($)?Object.fromEntries($.map((W)=>[W,W])):$;return new m4({type:"enum",entries:Q,...w.normalizeParams(J)})}function lZ($,J){return new m4({type:"enum",entries:$,...w.normalizeParams(J)})}var TY=N("ZodLiteral",($,J)=>{VX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>k5($,Q,W,X),$.values=new Set(J.values),Object.defineProperty($,"value",{get(){if(J.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return J.values[0]}})});function pZ($,J){return new TY({type:"literal",values:Array.isArray($)?$:[$],...w.normalizeParams(J)})}var wY=N("ZodFile",($,J)=>{_X.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>g5($,Q,W,X),$.min=(Q,W)=>$.check(j0(Q,W)),$.max=(Q,W)=>$.check(B2(Q,W)),$.mime=(Q,W)=>$.check(S4(Array.isArray(Q)?Q:[Q],W))});function cZ($){return M5(wY,$)}var vY=N("ZodTransform",($,J)=>{DX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>l5($,Q,W,X),$._zod.parse=(Q,W)=>{if(W.direction==="backward")throw new w2($.constructor.name);Q.addIssue=(Y)=>{if(typeof Y==="string")Q.issues.push(w.issue(Y,Q.value,J));else{let K=Y;if(K.fatal)K.continue=!1;K.code??(K.code="custom"),K.input??(K.input=Q.value),K.inst??(K.inst=$),Q.issues.push(w.issue(K))}};let X=J.transform(Q.value,Q);if(X instanceof Promise)return X.then((Y)=>{return Q.value=Y,Q});return Q.value=X,Q}});function QJ($){return new vY({type:"transform",transform:$})}var WJ=N("ZodOptional",($,J)=>{l$.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>D8($,Q,W,X),$.unwrap=()=>$._zod.def.innerType});function X6($){return new WJ({type:"optional",innerType:$})}var fY=N("ZodExactOptional",($,J)=>{zX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>D8($,Q,W,X),$.unwrap=()=>$._zod.def.innerType});function kY($){return new fY({type:"optional",innerType:$})}var hY=N("ZodNullable",($,J)=>{IX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>s5($,Q,W,X),$.unwrap=()=>$._zod.def.innerType});function Y6($){return new hY({type:"nullable",innerType:$})}function dZ($){return X6(Y6($))}var yY=N("ZodDefault",($,J)=>{jX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>t5($,Q,W,X),$.unwrap=()=>$._zod.def.innerType,$.removeDefault=$.unwrap});function gY($,J){return new yY({type:"default",innerType:$,get defaultValue(){return typeof J==="function"?J():w.shallowClone(J)}})}var xY=N("ZodPrefault",($,J)=>{RX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>e5($,Q,W,X),$.unwrap=()=>$._zod.def.innerType});function uY($,J){return new xY({type:"prefault",innerType:$,get defaultValue(){return typeof J==="function"?J():w.shallowClone(J)}})}var XJ=N("ZodNonOptional",($,J)=>{bX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>a5($,Q,W,X),$.unwrap=()=>$._zod.def.innerType});function mY($,J){return new XJ({type:"nonoptional",innerType:$,...w.normalizeParams(J)})}var lY=N("ZodSuccess",($,J)=>{PX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>x5($,Q,W,X),$.unwrap=()=>$._zod.def.innerType});function rZ($){return new lY({type:"success",innerType:$})}var pY=N("ZodCatch",($,J)=>{AX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>$Y($,Q,W,X),$.unwrap=()=>$._zod.def.innerType,$.removeCatch=$.unwrap});function cY($,J){return new pY({type:"catch",innerType:$,catchValue:typeof J==="function"?J:()=>J})}var dY=N("ZodNaN",($,J)=>{EX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>h5($,Q,W,X)});function iZ($){return Z5(dY,$)}var YJ=N("ZodPipe",($,J)=>{CX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>JY($,Q,W,X),$.in=J.in,$.out=J.out});function K6($,J){return new YJ({type:"pipe",in:$,out:J})}var KJ=N("ZodCodec",($,J)=>{YJ.init($,J),r3.init($,J)});function oZ($,J,Q){return new KJ({type:"pipe",in:$,out:J,transform:Q.decode,reverseTransform:Q.encode})}var rY=N("ZodReadonly",($,J)=>{SX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>QY($,Q,W,X),$.unwrap=()=>$._zod.def.innerType});function iY($){return new rY({type:"readonly",innerType:$})}var oY=N("ZodTemplateLiteral",($,J)=>{TX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>y5($,Q,W,X)});function nZ($,J){return new oY({type:"template_literal",parts:$,...w.normalizeParams(J)})}var nY=N("ZodLazy",($,J)=>{fX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>XY($,Q,W,X),$.unwrap=()=>$._zod.def.getter()});function sY($){return new nY({type:"lazy",getter:$})}var aY=N("ZodPromise",($,J)=>{vX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>WY($,Q,W,X),$.unwrap=()=>$._zod.def.innerType});function sZ($){return new aY({type:"promise",innerType:$})}var tY=N("ZodFunction",($,J)=>{wX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>m5($,Q,W,X)});function aZ($){return new tY({type:"function",input:Array.isArray($?.input)?AY($?.input):$?.input??U6(x2()),output:$?.output??x2()})}var L6=N("ZodCustom",($,J)=>{kX.init($,J),y.init($,J),$._zod.processJSONSchema=(Q,W,X)=>u5($,Q,W,X)});function tZ($){let J=new n({check:"custom"});return J._zod.check=$,J}function eZ($,J){return O5(L6,$??(()=>!0),J)}function eY($,J={}){return N5(L6,$,J)}function $K($){return F5($)}var $L=V5,JL=_5;function QL($,J={}){let Q=new L6({type:"custom",check:"custom",fn:(W)=>W instanceof $,abort:!0,...w.normalizeParams(J)});return Q._zod.bag.Class=$,Q._zod.check=(W)=>{if(!(W.value instanceof $))W.issues.push({code:"invalid_type",expected:$.name,input:W.value,inst:Q,path:[...Q._zod.def.path??[]]})},Q}var WL=(...$)=>D5({Codec:KJ,Boolean:d4,String:l4},...$);function XL($){let J=sY(()=>{return $J([v8($),HY(),ZY(),NY(),U6(J),EY(v8(),J)])});return J}function YL($,J){return K6(QJ($),J)}var KL={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function BL($){Y1({customError:$})}function qL(){return Y1().customError}var BJ;(function($){})(BJ||(BJ={}));var WP=()=>{let $={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function J(X){return $[X]??null}let Q={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},W={nan:"NaN"};return(X)=>{switch(X.code){case"invalid_type":{let Y=W[X.expected]??X.expected,K=S7(X.input),B=W[K]??K;return`Invalid input: expected ${Y}, received ${B}`}case"invalid_value":if(X.values.length===1)return`Invalid input: expected ${F$(X.values[0])}`;return`Invalid option: expected one of ${M$(X.values,"|")}`;case"too_big":{let Y=X.inclusive?"<=":"<",K=J(X.origin);if(K)return`Too big: expected ${X.origin??"value"} to have ${Y}${X.maximum.toString()} ${K.unit??"elements"}`;return`Too big: expected ${X.origin??"value"} to be ${Y}${X.maximum.toString()}`}case"too_small":{let Y=X.inclusive?">=":">",K=J(X.origin);if(K)return`Too small: expected ${X.origin} to have ${Y}${X.minimum.toString()} ${K.unit}`;return`Too small: expected ${X.origin} to be ${Y}${X.minimum.toString()}`}case"invalid_format":{let Y=X;if(Y.format==="starts_with")return`Invalid string: must start with "${Y.prefix}"`;if(Y.format==="ends_with")return`Invalid string: must end with "${Y.suffix}"`;if(Y.format==="includes")return`Invalid string: must include "${Y.includes}"`;if(Y.format==="regex")return`Invalid string: must match pattern ${Y.pattern}`;return`Invalid ${Q[Y.format]??X.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${X.divisor}`;case"unrecognized_keys":return`Unrecognized key${X.keys.length>1?"s":""}: ${M$(X.keys,", ")}`;case"invalid_key":return`Invalid key in ${X.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${X.origin}`;default:return"Invalid input"}}};function JK(){return{localeError:WP()}}var QK=()=>{throw Error("JSON Schema conversion is not bundled into this plugin artifact")};var qJ={};U2(qJ,{string:()=>XP,number:()=>YP,date:()=>qP,boolean:()=>KP,bigint:()=>BP});function XP($){return gX(l4,$)}function YP($){return dX(c4,$)}function KP($){return tX(d4,$)}function BP($){return $5(r4,$)}function qP($){return H5(q6,$)}Y1(JK());var UP=UJ;var UL=Object.freeze(["hard_stop","use_alternative","scope_down","manual_only","stop_and_explain"]);var M6=64,GL="Rule config exceeds CC Safety Net's safe source limit.";var Nh=Object.freeze({maxSources:64,concurrency:4,maxRequests:131,maxResponseBytes:67108864});var XK=[{id:"secret.basename.env",category:"Basename",label:".env",description:"Blocks exact .env files.",basename:".env"},{id:"secret.basename.npmrc",category:"Basename",label:".npmrc",description:"Blocks npm credential config files.",basename:".npmrc"},{id:"secret.basename.pypirc",category:"Basename",label:".pypirc",description:"Blocks Python package index credential files.",basename:".pypirc"},{id:"secret.basename.netrc",category:"Basename",label:".netrc",description:"Blocks machine login credential files.",basename:".netrc"},{id:"secret.basename.git-credentials",category:"Basename",label:".git-credentials",description:"Blocks Git credential storage files.",basename:".git-credentials"},{id:"secret.basename.id-rsa",category:"Basename",label:"id_rsa",description:"Blocks RSA private key basenames.",basename:"id_rsa"},{id:"secret.basename.id-ed25519",category:"Basename",label:"id_ed25519",description:"Blocks Ed25519 private key basenames.",basename:"id_ed25519"},{id:"secret.basename.id-ecdsa",category:"Basename",label:"id_ecdsa",description:"Blocks ECDSA private key basenames.",basename:"id_ecdsa"},{id:"secret.basename.credentials",category:"Basename",label:"credentials",description:"Blocks generic credentials file basenames.",basename:"credentials"}],GJ={id:"secret.pattern.env-variant",category:"Pattern",label:".env.*",description:"Blocks environment-specific .env variants."},GP=[".bak",".backup",".copy",".disabled",".old",".orig",".save",".tmp"],HP=[{idSlug:"kube-config",label:"~/.kube/config",directoryParts:[".kube"],basename:"config"},{idSlug:"docker-config",label:"~/.docker/config.json",directoryParts:[".docker"],basename:"config.json"}],YK=[{id:"secret.home.ssh",category:"Home path",label:"~/.ssh",description:"Blocks home SSH configuration and key paths.",suffixParts:[".ssh"]},{id:"secret.home.aws",category:"Home path",label:"~/.aws",description:"Blocks home AWS credential and config paths.",suffixParts:[".aws"]},{id:"secret.home.gcp",category:"Home path",label:"~/.gcp",description:"Blocks home GCP credential paths.",suffixParts:[".gcp"]},{id:"secret.home.gcloud-config",category:"Home path",label:"~/.config/gcloud",description:"Blocks home Google Cloud SDK credential paths.",suffixParts:[".config","gcloud"]},{id:"secret.home.kube-config",category:"Home path",label:"~/.kube/config",description:"Blocks home Kubernetes config files.",suffixParts:[".kube","config"]},{id:"secret.home.docker-config",category:"Home path",label:"~/.docker/config.json",description:"Blocks home Docker credential config files.",suffixParts:[".docker","config.json"]},...HP.flatMap(($)=>GP.map((J)=>({id:["secret.home",$.idSlug,J.slice(1)].join("."),category:"Home path",label:[$.label,J].join(""),description:["Blocks home ",$.label,J," credential backup files."].join(""),suffixParts:[...$.directoryParts,[$.basename,J].join("")]}))),{id:"secret.home.gh-hosts",category:"Home path",label:"~/.config/gh/hosts.yml",description:"Blocks GitHub CLI host credential files.",suffixParts:[".config","gh","hosts.yml"]}];var HJ=[{id:"secret.cli.claude-code",category:"Coding CLI credential",label:"Claude Code credentials",paths:["~/.claude/.credentials.json"]},{id:"secret.cli.claude-code.config",category:"Coding CLI config",label:"Claude Code config",paths:["~/.claude/settings.json","~/.claude/settings.local.json","~/.claude.json","<project>/.claude/settings.local.json","<project>/.mcp.json"]},{id:"secret.cli.antigravity",category:"Coding CLI config",label:"Antigravity CLI hook config",paths:["~/.gemini/config/hooks.json","~/.gemini/config/mcp_config.json"]},{id:"secret.cli.codex",category:"Coding CLI credential",label:"Codex credentials",paths:["~/.codex/auth.json","~/.codex/.credentials.json","~/.codex/secrets","~/.codex/.sandbox-secrets"]},{id:"secret.cli.codex.config",category:"Coding CLI config",label:"Codex config",paths:["~/.codex/config.toml","~/.codex/<name>.config.toml"]},{id:"secret.cli.gemini",category:"Coding CLI credential",label:"Gemini CLI credentials",paths:["~/.gemini/oauth_creds.json","~/.gemini/mcp-oauth-tokens.json","~/.gemini/a2a-oauth-tokens.json","~/.gemini/gemini-credentials.json"]},{id:"secret.cli.gemini.config",category:"Coding CLI config",label:"Gemini CLI config",paths:["~/.gemini/settings.json","~/.gemini/google_accounts.json","<project>/.gemini/settings.json","/Library/Application Support/GeminiCli/settings.json","/etc/gemini-cli/settings.json"]},{id:"secret.cli.copilot-cli",category:"Coding CLI credential",label:"GitHub Copilot CLI credentials",paths:["~/.copilot/config.json","~/.copilot/mcp-oauth-config","~/.copilot/mcp-secrets"]},{id:"secret.cli.copilot-cli.config",category:"Coding CLI config",label:"GitHub Copilot CLI config",paths:["~/.copilot/mcp-config.json"]},{id:"secret.cli.kimi-code",category:"Coding CLI credential",label:"Kimi Code credentials",paths:["~/.kimi-code/server.token","~/.kimi-code/credentials","~/.kimi/credentials","~/.kimi/mcp-oauth"]},{id:"secret.cli.kimi-code.config",category:"Coding CLI config",label:"Kimi Code config",paths:["~/.kimi-code/config.toml","~/.kimi-code/mcp.json","~/.kimi/config.toml","~/.kimi/config.json","~/.kimi/config.json.bak","~/.kimi/mcp.json","<project>/.kimi-code/mcp.json"]},{id:"secret.cli.opencode",category:"Coding CLI credential",label:"OpenCode credentials",paths:["~/.local/share/opencode/auth.json","~/.local/share/opencode/mcp-auth.json","~/.local/share/opencode/opencode.db"]},{id:"secret.cli.opencode.config",category:"Coding CLI config",label:"OpenCode config",paths:["~/.config/opencode/opencode.json","~/.config/opencode/opencode.jsonc","/Library/Application Support/opencode/opencode.json","/etc/opencode/opencode.json","<project>/opencode.json","<project>/opencode.jsonc"]},{id:"secret.cli.pi",category:"Coding CLI credential",label:"Pi credentials",paths:["~/.pi/agent/auth.json"]},{id:"secret.cli.pi.config",category:"Coding CLI config",label:"Pi config",paths:["~/.pi/agent/models.json"]},{id:"secret.cli.amp",category:"Coding CLI credential",label:"Amp Code credentials",paths:["~/.local/share/amp/secrets.json","~/.amp/oauth"]},{id:"secret.cli.amp.config",category:"Coding CLI config",label:"Amp Code config",paths:["~/.config/amp/settings.json","~/.config/amp/settings.jsonc","<project>/.amp/settings.json","<project>/.amp/settings.jsonc"]},{id:"secret.cli.cursor",category:"Coding CLI credential",label:"Cursor CLI credentials",paths:["~/.cursor/auth.json","~/.config/cursor/auth.json","~/.cursor/projects/<name>/mcp-auth.json"]},{id:"secret.cli.cursor.config",category:"Coding CLI config",label:"Cursor CLI config",paths:["~/.cursor/mcp.json","<project>/.cursor/mcp.json"]}],HL=[{prefix:"id_rsa",slug:"id-rsa",label:"id_rsa"},{prefix:"id_dsa",slug:"id-dsa",label:"id_dsa"},{prefix:"id_ed25519",slug:"id-ed25519",label:"id_ed25519"},{prefix:"id_ecdsa",slug:"id-ecdsa",label:"id_ecdsa"},{prefix:"credentials",slug:"credentials",label:"credentials"}],ZP=[".bak",".backup",".copy",".disabled",".key",".old",".orig",".pem",".save",".tmp"],KK=HL.map(($)=>({id:`secret.variant.${$.slug}.separator`,category:"Variant",label:`${$.label}-* / ${$.label}_*`,description:`Blocks ${$.label} variants with dash or underscore suffixes.`,prefix:$.prefix})),BK=HL.flatMap(($)=>ZP.map((J)=>({id:`secret.variant.${$.slug}.${J.slice(1)}`,category:"Variant",label:`${$.label}${J}`,description:`Blocks ${$.label}${J} private credential variants.`,prefix:$.prefix,suffix:J}))),O6={id:"secret.pattern.ssh-key-basename",category:"Pattern",label:"*_(rsa|dsa|ed25519|ecdsa)",description:"Blocks extensionless SSH private key-like basenames.",pattern:/^.*_(rsa|dsa|ed25519|ecdsa)$/},qK=["agilekeychain","asc","bek","cscfg","fve","gnucash","jks","keychain","kwallet","mdf","ovpn","p12","pcap","pem","pfx","pkcs12","psafe3","rdp","sdf","tblk","tpm"].map(($)=>({id:`secret.ext.${$}`,category:"Extension",label:`.${$}`,description:`Blocks files with the .${$} extension.`,extension:$})),UK=[{id:"secret.ext-pattern.key",category:"Extension pattern",label:".key / .keypair",description:"Blocks key and keypair extension patterns.",pattern:/^key(pair)?$/},{id:"secret.ext-pattern.keystore",category:"Extension pattern",label:".keystore / .keyring",description:"Blocks keystore and keyring extension patterns.",pattern:/^key(store|ring)$/},{id:"secret.ext-pattern.kdbx",category:"Extension pattern",label:".kdb / .kdbx",description:"Blocks KeePass database extension patterns.",pattern:/^kdbx?$/}],ZL=[...XK,GJ,...YK,...KK,...BK,O6,...qK,...UK,...HJ].map(($)=>({id:$.id,category:$.category,label:$.label,...$.category==="Coding CLI config"?{defaultOff:!0}:{},..."paths"in $?{paths:$.paths}:{description:$.description}})),LL=new Set(HJ.flatMap(($)=>$.category==="Coding CLI config"?[$.id]:[])),LP=ZL.map(($)=>$.id),ZJ=new Set(LP);var Sh=MP(import.meta.url),ML,OP=Array(M6+1).fill("over-limit"),OL=/^[^/]+\/[^/]+$/,NP=/^sha256:[a-f0-9]{64}$/,LJ=`must be an integer between ${_J} and ${DJ}`,FP=["version","rules","overrides","transparent_wrappers"],VP=["version","safety","workflow","destructive_command_protection","secret_protection","audit"];function NL($){if(!n1($)||!Array.isArray($.rules)||$.rules.length<=M6)return $;return{$schema:$.$schema,version:$.version,rules:OP,overrides:$.overrides,transparent_wrappers:$.transparent_wrappers}}function _P(){let $=WK,J=(_)=>{let R=$.superRefine(_);return R._zod.def.when=()=>!0,R},Q=$.enum(UL),W=$.union([$.literal("off"),$.looseObject({reason:$.string({error:"required non-empty string"}).min(1,"required non-empty string").max(a2,`must be at most ${a2} characters`).describe("Replacement block reason"),intent:Q.optional()})],{error:'must be "off" or an object'}).describe("Disable a rule or replace its block reason and intent."),X=$.string({error:"must be a rulebook source string"}).min(1,"must be a non-empty rulebook source string"),Y=$.string({error:"must be a command string"}).regex(F2,"must match command pattern").describe("Command name such as 'git', 'docker', or 'rtk'."),K=$.looseObject({$schema:$.unknown().optional().describe("JSON Schema reference for IDE support"),version:$.literal(1).describe("Schema version (must be 1)"),rules:$.array(X,{error:"must be an array of rulebook source strings"}).max(M6,GL).default([]).describe("Rulebook source strings such as project-rules or owner/repo#main/team-rules"),overrides:$.record($.string().meta({pattern:OL.source}),W).default({}).describe("Rule overrides by id"),transparent_wrappers:$.array(Y,{error:"must be an array of command strings"}).default([]).describe("Commands that transparently execute a visible protected child command")}),B=(_,R)=>{if(!n1(_))return;if(Array.isArray(_.rules)&&_.rules.length<=M6){let C=new Set;_.rules.forEach((S,g)=>{if(typeof S!=="string"||S==="")return;if(S.trim()===""){R.addIssue({code:"custom",message:"must be a non-empty rulebook source string",path:["rules",g]});return}let x=n4(S);if(x){R.addIssue({code:"custom",message:x,path:["rules",g]});return}if(C.has(S)){R.addIssue({code:"custom",message:`duplicate rulebook source "${S}"`,path:["rules",g]});return}C.add(S)})}if(n1(_.overrides))for(let C of Object.keys(_.overrides)){if(OL.test(C))continue;R.addIssue({code:"custom",message:"must use <rulebook-name>/<rule-name>",path:["overrides",C]})}if(!Array.isArray(_.transparent_wrappers))return;let P=new Set;_.transparent_wrappers.forEach((C,S)=>{if(typeof C!=="string"||!F2.test(C))return;if(P.has(C)){R.addIssue({code:"custom",message:`duplicate command "${C}"`,path:["transparent_wrappers",S]});return}if(IU(C)){R.addIssue({code:"custom",message:`reserved command "${C}" cannot be a wrapper`,path:["transparent_wrappers",S]});return}P.add(C)})},q=$.preprocess(NL,K.check($.superRefine(B))),U=$.preprocess(NL,K.check(J(B))),G=$.strictObject({fail_closed:$.boolean().optional(),paranoid_rm:$.boolean().optional(),paranoid_interpreters:$.boolean().optional()}),H=(_,R)=>$.intersection($.record($.string().refine((P)=>_.has(P),{error:(P)=>`unknown ${R} rule id "${String(P.input)}"`}),$.unknown()),$.record($.string(),$.enum(["on","off"]))),L=(_)=>$.array($.string({error:"must be a non-empty path string"}),{error:"must be an array of paths"}).check(J((R,P)=>{if(!Array.isArray(R))return;let C=M2();R.forEach((S,g)=>{if(typeof S!=="string")return;let x=_(S,C);if(x)P.addIssue({code:"custom",message:x,path:[g]})})})),Z=$.strictObject({version:$.literal(1),safety:$.strictObject({level:$.enum(["standard","strict","paranoid"]).optional(),overrides:G.optional()}).optional(),workflow:$.strictObject({worktree_mode:$.boolean().optional()}).optional(),destructive_command_protection:$.strictObject({enabled:$.boolean().optional(),overrides:H(n6,"destructive command").optional(),allow_paths:L(f9).optional()}).optional(),secret_protection:$.strictObject({enabled:$.boolean().optional(),overrides:H(ZJ,"secret protection").optional(),deny_paths:L(k9).optional(),allow_paths:L(h9).optional()}).optional(),audit:$.strictObject({retention_days:$.number({error:LJ}).int(LJ).min(_J,LJ).max(DJ,LJ).optional().describe("Days of audit log history to keep before the sweep deletes it")}).optional()}),M=(_)=>{let R=(g,x)=>_==="legacy"?g:x,P=R("must match pattern (letters, numbers, hyphens, underscores)","must match command pattern"),C=`required non-empty string up to ${a2} characters`,S=$.looseObject({name:$.string({error:"required string"}).regex(q0,R("must match pattern (letters, numbers, hyphens, underscores; max 64 chars)","must match rule name pattern")),command:$.string({error:R("required string","required string matching command pattern")}).regex(F2,R(P,"required string matching command pattern")),subcommand:$.string({error:R("must be a string if provided","must match command pattern")}).regex(F2,P).optional(),block_args:$.array($.string({error:R("must be a string","must be a non-empty string")}).refine((g)=>g!=="",{error:R("must not be empty","must be a non-empty string")}),{error:R("required array","required non-empty array")}).refine((g)=>g.length>0,{error:R("must have at least one element","required non-empty array")}),reason:$.string({error:R("required string",C)}).refine((g)=>g!=="",{error:R("must not be empty",C)}).refine((g)=>g.length<=a2,{error:R(`must be at most ${a2} characters`,C)}),intent:Q.optional()},{error:"must be an object"});return $.array(S,{error:R("must be an array","required array")}).check(J((g,x)=>{if(!Array.isArray(g))return;let d=new Set;g.forEach((V1,T)=>{let m=n1(V1)?V1.name:void 0;if(typeof m!=="string")return;if(d.has(m.toLowerCase())){x.addIssue({code:"custom",message:`duplicate rule name "${m}"`,path:[T,"name"]});return}d.add(m.toLowerCase())})}))},O=$.looseObject({version:$.literal(1),rules:M("legacy").optional()}),V="required string matching rule name pattern",F=$.looseObject({command:$.string({error:"required non-empty string"}).refine((_)=>_.trim()!=="",{error:"required non-empty string"}),expect:$.enum(["blocked","allowed"]),rule:$.string({error:"must be a string if provided"}).optional()},{error:"must be an object"}).check(J((_,R)=>{if(!n1(_))return;if(_.expect!=="blocked"||typeof _.rule==="string")return;R.addIssue({code:"custom",message:"required string for blocked fixtures",path:["rule"]})})),b=$.looseObject({name:$.string({error:"required string matching rule name pattern"}).regex(q0,"required string matching rule name pattern"),version:$.string({error:"required non-empty string"}).refine((_)=>_!=="",{error:"required non-empty string"}),allowed_commands:$.array($.string({error:"must match command pattern"}).regex(F2,"must match command pattern"),{error:"required array"}).check(J((_,R)=>{if(!Array.isArray(_))return;let P=new Set;_.forEach((C,S)=>{if(typeof C!=="string"||!F2.test(C))return;if(P.has(C)){R.addIssue({code:"custom",message:`duplicate command "${C}"`,path:[S]});return}P.add(C)})})),rules:M("rulebook"),tests:$.array(F,{error:"must be an array if provided"}).optional()}).check(J((_,R)=>{if(!n1(_))return;let P=new Set(GK(_));if(Array.isArray(_.tests)){let S=new Set(_.tests.flatMap((g)=>n1(g)&&g.expect==="blocked"&&typeof g.rule==="string"?[g.rule]:[]));for(let g of S){if(P.has(g))continue;R.addIssue({code:"custom",message:`blocked fixture references unknown rule "${g}"`,path:["tests"]})}}if(!Array.isArray(_.allowed_commands)||!Array.isArray(_.rules))return;let C=new Set(_.allowed_commands.filter((S)=>typeof S==="string"));_.rules.forEach((S,g)=>{let x=n1(S)?S.command:void 0;if(typeof x!=="string"||C.has(x))return;R.addIssue({code:"custom",message:`"${x}" must be listed in allowed_commands`,path:["rules",g,"command"]})})})),I=$.string({error:"required string"}).refine((_)=>_.trim()!=="",{error:"required string"}),A=$.looseObject({spec:I,name:I,version:I,digest:$.string({error:"required sha256 digest"}).regex(NP,"required sha256 digest")},{error:"must be an object"}),E=$.looseObject({rulebooks:$.array($.intersection(A,$.discriminatedUnion("kind",[$.object({kind:$.literal("local-directory"),path:I}),$.object({kind:$.literal("github"),owner:I,repo:I,ref:I,commit:I,path:I,display_ref:$.unknown().optional()})],{error:(_)=>{if(!n1(_.input))return"must be an object";let R=_.input.kind;return typeof R==="string"?`unknown kind "${R}"`:"required string"}})))});return{RulesConfigSchema:q,RulesConfigDiagnosticSchema:U,RuleOverrideSchema:W,UserPolicySchema:Z,LegacyConfigSchema:O,RulebookSchema:b,RulesLockfileSchema:E}}function N6(){return ML??=_P(),ML}function FL(){return N6().RulesConfigSchema}function DP(){return N6().UserPolicySchema}function VL(){return N6().RulebookSchema}function _L(){return N6().RulesLockfileSchema}function GK($){let J=n1($)?$.rules:void 0;return(Array.isArray(J)?J:[]).flatMap((Q)=>{let W=n1(Q)?Q.name:void 0;return typeof W==="string"?[W]:[]})}function DL($){let J=N6().RulesConfigDiagnosticSchema.safeParse($);if(J.success)return{errors:[],sources:new Set(J.data.rules)};return{errors:i4(jL(J.error.issues,FP)),sources:RP($,J.error.issues)}}function zL($){let J=DP().safeParse($);if(J.success)return[];return i4(jL(J.error.issues,VP)," ")}function i4($,J=": ",Q=" "){return[...new Set($.flatMap((W)=>IL(W,J,Q,[])))]}function IL($,J,Q,W){let X=[...W,...$.path],Y=jP(X);if($.code==="unrecognized_keys")return $.keys.map((K)=>`${Y?`${Y}.`:""}unknown field "${K}"`);if($.code==="invalid_key")return $.issues.map((K)=>K.message);if($.code==="invalid_union"){let K=$.errors.flat().filter((B)=>B.path.length>0);if(K.length>0)return K.flatMap((B)=>IL(B,J,Q,X))}if(X.length===0)return[$.code==="invalid_type"?"Config must be an object":$.message];if(X.length===1&&($.code==="too_big"||$.code==="too_small")&&$.origin==="array")return[$.message];return[`${Y}${X.length===1?Q:J}${zP($)}`]}function zP($){if($.code==="invalid_value")return`must be ${IP($.values)}`;if($.code!=="invalid_type"||!$.message.startsWith("Invalid input:"))return $.message;if($.expected==="object"||$.expected==="record")return"must be an object if provided";return $.expected==="boolean"?"must be a boolean":$.message}function IP($){if($.length>3)return`one of ${$.join(", ")}`;let J=$.map((Q)=>typeof Q==="string"?`"${Q}"`:String(Q));if(J.length<2)return`${J[0]}`;return`${J.slice(0,-1).join(", ")}${J.length>2?",":""} or ${J.at(-1)}`}function jP($){return $.map((J,Q)=>{if(typeof J==="number")return`[${J}]`;return Q===0?String(J):`.${String(J)}`}).join("")}function jL($,J){let Q=$.map((Y)=>Y.path[1]),W=[...new Set(Q.filter((Y)=>typeof Y==="string"))],X=(Y,K)=>[Y.path.length===0?-1:J.indexOf(String(Y.path[0])),typeof K==="number"?K:W.indexOf(String(K)),Y.code==="custom"?0:1];return $.map((Y,K)=>({issue:Y,rank:X(Y,Q[K])})).sort((Y,K)=>Y.rank[0]-K.rank[0]||Y.rank[1]-K.rank[1]||Y.rank[2]-K.rank[2]).map((Y)=>Y.issue)}function RP($,J){let Q=n1($)?$.rules:void 0;if(!Array.isArray(Q))return new Set;if(J.some((X)=>X.path.length===1&&X.path[0]==="rules"))return new Set;let W=new Set(J.filter((X)=>X.path[0]==="rules"&&typeof X.path[1]==="number").map((X)=>X.path[1]));return new Set(Q.filter((X,Y)=>typeof X==="string"&&!W.has(Y)))}function n1($){return!!$&&typeof $==="object"&&!Array.isArray($)}function bP($){return DL($)}function HK($){try{let J=G2(PP($));if(J===null)return{config:null,errors:[]};if(!J.trim())return{config:null,errors:["Config file is empty"]};let Q=JSON.parse(J),W=bP(Q);if(W.errors.length>0)return{config:null,errors:W.errors};let X=FL().parse(Q);return{config:{version:1,rules:X.rules??[],overrides:X.overrides??{},transparent_wrappers:X.transparent_wrappers??[]},errors:[]}}catch(J){if(J instanceof K1)return{config:null,errors:[J.message]};let Q=J instanceof Error?J.message:String(J);return{config:null,errors:[J instanceof SyntaxError?"Invalid JSON":Q]}}}function PP($){return typeof $==="string"?C6($):$}var TP=new Set(["standard","strict","paranoid"]),wP={version:1,safety:{level:"standard",overrides:{}},workflow:{worktree_mode:!1},destructive_command_protection:{enabled:!0,overrides:{},allow_paths:[]},secret_protection:{enabled:!0,overrides:{},deny_paths:[],allow_paths:[]},audit:{retention_days:b6}};function ZK($){return SP(CP(H2($)),w6)}function AL($={}){let J=yP(ZK($));return{safety:J.policy.safety,worktreeMode:J.policy.worktreeMode,destructiveCommandProtectionEnabled:J.policy.destructiveCommandProtectionEnabled,destructiveCommandRuleOverrides:J.policy.destructiveCommandRuleOverrides,destructiveCommandAllowPaths:J.policy.destructiveCommandAllowPaths,secretProtection:J.policy.secretProtection,errors:J.errors,...J.fallback?{fallback:J.fallback}:{}}}function RL($){if(!P0($))return hP();let J=P0($.safety)?$.safety:{},Q=P0(J.overrides)?J.overrides:{},W=P0($.workflow)?$.workflow:{},X=P0($.destructive_command_protection)?$.destructive_command_protection:{},Y=P0($.secret_protection)?$.secret_protection:{};return{version:1,safety:{level:TP.has(J.level)?J.level:"standard",overrides:{...typeof Q.fail_closed==="boolean"?{fail_closed:Q.fail_closed}:{},...typeof Q.paranoid_rm==="boolean"?{paranoid_rm:Q.paranoid_rm}:{},...typeof Q.paranoid_interpreters==="boolean"?{paranoid_interpreters:Q.paranoid_interpreters}:{}}},workflow:{worktree_mode:typeof W.worktree_mode==="boolean"?W.worktree_mode:!1},destructive_command_protection:{enabled:typeof X.enabled==="boolean"?X.enabled:!0,overrides:bL(X.overrides,n6),allow_paths:fP(X.allow_paths)},secret_protection:{enabled:typeof Y.enabled==="boolean"?Y.enabled:!0,overrides:bL(Y.overrides,ZJ),deny_paths:vP(Y.deny_paths),allow_paths:kP(Y.allow_paths)},audit:{retention_days:P6(P0($.audit)?$.audit.retention_days:void 0)}}}function bL($,J){if(!P0($))return{};return Object.fromEntries(Object.entries($).flatMap(([Q,W])=>J.has(Q)&&(W==="on"||W==="off")?[[Q,W]]:[]))}function vP($){if(!Array.isArray($))return[];let J=M2();return $.filter((Q)=>k9(Q,J)===null)}function fP($){if(!Array.isArray($))return[];let J=M2();return $.filter((Q)=>f9(Q,J)===null)}function kP($){if(!Array.isArray($))return[];let J=M2();return $.filter((Q)=>h9(Q,J)===null)}function P0($){return!!$&&typeof $==="object"&&!Array.isArray($)}function hP(){return structuredClone(wP)}function yP($){let J=gP();if(!AP($)){let Q=globalThis.__CC_SAFETY_NET_EMBEDDED_POLICY__;if(!P0(Q))return{policy:J,errors:[]};return{policy:PL(RL(Q)),errors:[]}}try{let Q=EP($,"utf-8");if(!Q.trim())return{policy:J,errors:[`${$}: Config file is empty`],fallback:"defaults"};let W=JSON.parse(Q),X=zL(W),Y=PL(RL(W));if(X.length>0)return{policy:Y,errors:X.map((K)=>`${$}: ${K}`),fallback:P0(W)?"salvaged":"defaults"};return{policy:Y,errors:[]}}catch(Q){let W=Q instanceof Error?Q.message:String(Q);return{policy:J,errors:[`${$}: ${Q instanceof SyntaxError?"Invalid JSON":W}`],fallback:"defaults"}}}function EL($){let J=Object.entries($),Q=new Set(J.flatMap(([W,X])=>X==="on"?[W]:[]));return new Set([...[...LL].filter((W)=>!Q.has(W)),...J.flatMap(([W,X])=>X==="off"?[W]:[])])}function gP(){return{safety:{},worktreeMode:!1,destructiveCommandProtectionEnabled:!0,destructiveCommandRuleOverrides:{},destructiveCommandAllowPaths:[],secretProtection:{enabled:!0,disabledRules:EL({}),denyPaths:[],allowPaths:[]}}}function PL($){return{safety:xP($.safety),worktreeMode:$.workflow.worktree_mode,destructiveCommandProtectionEnabled:$.destructive_command_protection.enabled,destructiveCommandRuleOverrides:$.destructive_command_protection.overrides,destructiveCommandAllowPaths:$.destructive_command_protection.allow_paths,secretProtection:{enabled:$.secret_protection.enabled,disabledRules:EL($.secret_protection.overrides),denyPaths:$.secret_protection.deny_paths,allowPaths:$.secret_protection.allow_paths}}}function xP($){let J={...$.overrides.fail_closed!==void 0?{failClosed:$.overrides.fail_closed}:{},...$.overrides.paranoid_rm!==void 0?{paranoidRm:$.overrides.paranoid_rm}:{},...$.overrides.paranoid_interpreters!==void 0?{paranoidInterpreters:$.overrides.paranoid_interpreters}:{}};return{level:$.level,...Object.keys(J).length>0?{overrides:J}:{}}}var wL="This path contains the protected policy config and you must not modify or delete it.",uP=new Set(["[","cat","file","grep","head","jq","less","ls","more","rg","sed","stat","tail","test","wc"]);function vL($){let J=L2(T0()),Q=rP($.invocation.context.executionCwd,J);if($.invocation.route.kind==="patch")return CL($.paths,!1,$.invocation.context.executionCwd,Q,J);let W=f1($,"input-candidate");if($.invocation.route.kind==="command")return W?SL(W.shell,$.invocation.context.executionCwd,Q,J):null;if($.invocation.route.kind==="unknown"&&W){let X=SL(W.shell,$.invocation.context.executionCwd,Q,J);if(X)return X}return CL($.paths,$.invocation.route.kind==="grep"||$.invocation.route.kind==="glob"||A9($.invocation.toolName),$.invocation.context.executionCwd,Q,J)}function CL($,J,Q,W,X){if(J)return null;let Y=$.find((K)=>F6(K,Q,W,X));return Y?{target:Y}:null}function SL($,J,Q,W){let X=C9($,J,W,{findSegmentTarget:(Y,K)=>mP(Y,K,Q,W)?.target??null,isRedirectionTarget:(Y,K)=>F6(Y,K.cwd,Q,W),findMalformedTarget:(Y)=>dP(Y,J,Q,W)?.target??null,normalizeCwd:O1});return X?{target:X}:null}function mP($,J,Q,W){if(O3($))return null;let X=W.environment,Y=c1([...$],X),K=l(Y[0]??"").toLowerCase(),B=Y.slice(1);if(K==="rm"&&lP(B)){let q=pP(B).find((U)=>TL(k1(U,J.variables),J.cwd,Q,W));if(q)return{target:q}}if(K==="find"){if(p9(Y,1)||kQ(Y,X)){let U=(l9(p(Y))??p(["."])).find((G)=>{let H=k1(G.text,J.variables);return F6(H,J.cwd,Q,W)||TL(H,J.cwd,Q,W)})?.text;if(U)return{target:U}}}if(K==="mv"){let q=S9(B).sources.find((U)=>iP(k1(U,J.variables),J.cwd,Q,W));if(q)return{target:q}}if(cP($,X))return null;for(let q of $)for(let U of fL(q))if(F6(k1(U,J.variables),J.cwd,Q,W))return{target:U};return null}function lP($){return $.some((J)=>J==="--recursive"||J.startsWith("-")&&!J.startsWith("--")&&/[rR]/.test(J.slice(1)))}function pP($){let J=$.indexOf("--");if(J!==-1)return[...$.slice(0,J).filter((Q)=>!Q.startsWith("-")),...$.slice(J+1)];return $.filter((Q)=>!Q.startsWith("-"))}function cP($,J){let Q=c1([...$],J);if(Q.length===0)return!1;let W=l(Q[0]??"").toLowerCase();if(!uP.has(W))return!1;if(W!=="sed")return!0;return!Q.slice(1).some((X)=>X.startsWith("-i")||X==="--in-place"||X.startsWith("--in-place="))}function dP($,J,Q,W){for(let X of $.split(/\s+/))for(let Y of fL(X))if(F6(Y,J,Q,W))return{target:Y};return null}function fL($){let J=$.trim().replace(/^['"]|['"]$/g,""),Q=J.indexOf("=");return Q===-1||Q===J.length-1?[J]:[J,J.slice(Q+1)]}function rP($,J){let Q=O1(ZK(),$,J),W=LK(Q),X=new Set;for(let Y=W;;Y=LK(Y))if(X.add(V6(Y)),LK(Y)===Y)break;return{file:V6(Q),directoryAndAncestors:X}}function F6($,J,Q,W){return V6(O1($,J,W))===Q.file}function TL($,J,Q,W){return Q.directoryAndAncestors.has(V6(O1($,J,W)))}function iP($,J,Q,W){let X=V6(O1($,J,W));return X===Q.file||Q.directoryAndAncestors.has(X)}function V6($){return process.platform==="win32"?$.toLowerCase():$}import{homedir as OK}from"node:os";import{isAbsolute as MJ,posix as oP,resolve as NJ,win32 as nP}from"node:path";import{fileURLToPath as sP}from"node:url";var dL="Access to a sensitive path is not allowed.",rL=new Set(["echo","printf"]),aP=new Set(["find"]),tP=new Set(["-exec","-execdir"]),eP=new Set([";","+"]),$A=new Set(["-delete","-exec","-execdir","-fls","-fprint","-fprint0","-fprintf","-ok","-okdir"]),JA=new Set(["-name","-iname","-path","-ipath","-wholename","-iwholename","-samefile"]),QA=new Set(["python","python2","python3","node","deno","bun","ruby","perl","php","rscript","osascript","bash","sh","zsh","dash","ksh"]),WA=new Set(["node","bun"]),XA=new Set(["bun","child_process","deno","dotenv","fs","subprocess"]),YA=new Set(["append","awk","base64","cat","chmod","chown","connect","copy","cp","database","dd","eval","exec","fetch","file","function","grep","head","include","load","move","mv","open","popen","read","remove","rename","require","rg","rm","sed","shell","source","spawn","strings","system","tail","tar","truncate","unlink","write","xxd","zip"]),iL=new Set(["-c","-e","-r","-E","--eval","--exec"]),KA=new Set(["src/cli/cc-safety-net.ts","dist/bin/cc-safety-net.js"]),kL=new Set(["cc-safety-net","ccsn"]),BA=new Set(["bunx","npx","pnpx"]),qA=new Set(["bun","node"]),UA=new Map([["c",new Set(["bash","sh","zsh","dash","ksh","python"])],["e",new Set(["node","deno","bun","ruby","perl","rscript","osascript"])],["E",new Set(["perl"])],["r",new Set(["php"])]]),GA=new Set(["grep","rg"]),hL="f",yL="file",HA="files",ZA=new Set(["e","f"]),LA=new Set(["regexp","file"]),MA=new Set(["e","f","A","B","C","m"]),OA=new Set(["regexp","file","after-context","before-context","context","max-count"]),NA=new Set(["|","|&"]),MK="__CC_SAFETY_NET_PIPE_INPUT__",oL=new Set(["bash","sh","zsh","dash","ksh"]),FA=new Map([["bash",new Set(["-O"])],["sh",new Set(["-O"])],["zsh",new Set(["-o"])],["dash",new Set(["-o"])],["ksh",new Set(["-o"])],["python",new Set(["-W","-X"])],["node",new Set(["-r","--require","--loader","--import","--input-type"])]]);function gL($,J,Q,W,X){let Y=a4();for(let K of $){if(XE(K,J,Q?.denyPaths??[],W,Y))return{target:K,ruleId:"secret.deny-path"};if(X&&!X.has(K))continue;let B=QE(K,J,Q,Y);if(B){if(!B.startsWith("secret.cli.")&&YE(K,J,Q?.allowPaths??[],W,Y))continue;return{target:K,ruleId:B}}}return null}function nL($,J,Q={}){let W=xL($),X=gL(W,$.invocation.context.executionCwd,J,$.invocation.context.configCwd),Y=X?.ruleId!=="secret.deny-path"&&Q.strict===!1?xL($,{refineJavaScriptInlineData:!0}):W,K=Y.length===W.length?X:gL(W,$.invocation.context.executionCwd,J,$.invocation.context.configCwd,new Set(Y));if(K?.ruleId!=="secret.deny-path"&&Q.strict===!1&&VA($))return null;return K}function VA($){if($.invocation.route.kind!=="command")return!1;let J=f1($,"input-candidate")??f1($,"declared-command");if(!J)return!1;if(J.program.nodes.some((K)=>K.kind==="command"&&K.nested.length>0))return!1;let Q=[];for(let K of J.shell.entries){if(K.kind==="operator"&&K.boundary)return!1;if(K.kind==="redirection")return!1;if(K.kind!=="operator")Q.push(L0(K.text))}let W=o4(Q);if(W.length===0)return!1;let X=l2(W[0]??"").toLowerCase(),Y=W.slice(1);if(X==="ls"||X==="stat")return!0;if(X==="test")return Y.length===2&&(Y[0]==="-e"||Y[0]==="-f");if(X!=="find")return!1;return!Y.some((K)=>$A.has(K))}function xL($,J={}){if($.invocation.route.kind==="command"){let W=f1($,"input-candidate");return W?z6(W.shell,$.store,J):[]}if($.invocation.route.kind!=="unknown")return[...$.paths];let Q=f1($,"input-candidate");return[...Q?z6(Q.shell,$.store,J):[],...$.paths]}function z6($,J,Q){if($.status==="structural-limit")throw new n0;if($.status==="unclosed-quote")return[];if($.status==="invalid")throw Error("Unable to parse command for secret protection");let W=[...$.assignmentFallbacks,...gA(L0($.source),J,Q)],X=[],Y=null;for(let K of $.entries){if(K.kind==="operator"){if(!K.boundary)continue;if(X.length>0){if(W.push(...OJ(X,J,Q)),Y!==null)W.push(...mL(Y,X,J,Q));Y=NA.has(K.operator)?X:null,X=[]}else Y=null;continue}if(K.kind==="redirection"){let B=K.target?L0(K.target):void 0;if(B&&K.targetOrder==="legacy-segment")X.push(B);else if(B)W.push(B);continue}X.push(L0(K.text))}if(X.length>0){if(W.push(...OJ(X,J,Q)),Y!==null)W.push(...mL(Y,X,J,Q))}return W}function OJ($,J,Q){let W=EA($),X=o4($);if(X.length===0)return W;let Y=X[0]??"",K=l2(Y).toLowerCase(),B=X.slice(1),q=DA(Y,K,B);if(q)return[...W,...q];if(rL.has(K))return W;if(GA.has(K))return[...W,...rA(B)];if(aP.has(K))return[...W,...CA(B,J,Q)];if(h1.has(K))return[...W,...B.flatMap((U)=>lL("awk",U)),...B.flatMap((U)=>TA(U,J,Q)),...B.flatMap(wA)];if(tL(K)){if(oL.has(K)){let U=nq(K,B);if(U!==null&&J.getShellSyntax(U).status==="structural-limit")throw new n0}return[...W,...SA(K,B,Q)]}return[...W,...B.flatMap((U)=>lL(K,U))]}function _A($,J){if(kL.has($))return J[0]==="explain"?0:null;if(BA.has($)){let Q=J[0]==="-y"||J[0]==="--yes"?1:0;return kL.has(J[Q]??"")&&J[Q+1]==="explain"?Q+1:null}if(qA.has($)){if(uL(J[0])&&J[1]==="explain")return 1;if($==="bun"&&J[0]==="run"&&uL(J[1])&&J[2]==="explain")return 2}return null}function DA($,J,Q){let W=_A(J,Q);if(W===null)return null;let X=[$,...Q.slice(0,W)],Y=Q.slice(W+1);for(let K=0;K<Y.length;K++){let B=Y[K];if(B==="--json"||B==="--help"||B==="-h")continue;if(B==="--cwd"){let q=Y[K+1];if(q&&!q.startsWith("--"))X.push(q);K++;continue}return X}return X}function uL($){let J=$?.replaceAll("\\","/");return[...KA].some((Q)=>J===Q||J?.endsWith(`/${Q}`))}function mL($,J,Q,W){if(bA(J,Q,W))return zA($);let X=PA(J);if(X===null)return[];return IA($).flatMap((Y)=>oL.has(X)?z6(Q.getShellSyntax(Y),Q,W):$M(Y))}function zA($){let J=o4($);if(J.length===0)return[];let Q=l2(J[0]??"").toLowerCase();if(!rL.has(Q))return[];return J.slice(1)}function IA($){let J=o4($);if(J.length===0)return[];let Q=l2(J[0]??"").toLowerCase(),W=J.slice(1);if(Q==="echo"){let X=W.findIndex((Y)=>!/^-[neE]+$/.test(Y));return[(X===-1?[]:W.slice(X)).join(" ")]}if(Q==="printf")return jA(W);return[]}function jA($){let J=$[0];if(J===void 0)return[];let Q=(J.match(/%%|%[bqs]/g)??[]).filter((X)=>X!=="%%").length;if(Q===0||$.length===1)return[sL(J)];let W=$.slice(1);return Array.from({length:Math.ceil(W.length/Q)},(X,Y)=>RA(J,W.slice(Y*Q,(Y+1)*Q)))}function RA($,J){let Q=0;return sL($.replace(/%%|%[bqs]/g,(W)=>{if(W==="%%")return"%";let X=J[Q]??"";return Q++,X}))}function sL($){return $.replace(/\\n/g,`
100
- `).replace(/\\t/g,"\t").replace(/\\r/g,"\r")}function bA($,J,Q){let W=o4($);if(W.length===0||l2(W[0]??"").toLowerCase()!=="xargs")return!1;let X=A2(W),Y=W.slice(X.childStart);if(Y.length===0)return!1;if(X.replacementToken==="")return!1;let K=X.replacementToken,B=K===null?[...Y,MK]:Y.map((q)=>q.split(K).join(MK));return OJ(B,J,Q).some((q)=>q.includes(MK))}function PA($){let J=o4($);if(J.length===0)return null;let Q=l2(J[0]??"").toLowerCase();if(!tL(Q))return null;return AA(Q,J.slice(1))?Q:null}function AA($,J){let Q=aL($);for(let W=0;W<J.length;W++){let X=J[W];if(X===void 0)break;if(iL.has(X)||eL($,X)||/^--(?:eval|exec)=/.test(X))return!1;if(X==="-")return!0;if(X.startsWith("-")){if(Q==="python"&&X==="-m")return!1;if(FA.get(Q)?.has(X))W++;continue}return!1}return!0}function aL($){return/^python\d/.test($)?"python":$}function EA($){let J=[];for(let Q of $){if(WM(Q))continue;let W=/^[A-Za-z_][A-Za-z0-9_]*=(.*)$/.exec(Q);if(W===null)break;if(W[1]!==void 0&&W[1]!=="")J.push(W[1])}return J}function lL($,J){if(J==="--")return[];let Q=[],W=J.indexOf("=");if(W>0&&W<J.length-1)Q.push(J.slice(W+1));if(J.startsWith("-"))return Q;if($==="tar"&&/\.(?:tar|tgz|tar\.gz|zip)$/i.test(J))return Q;if($==="zip"&&/\.zip$/i.test(J))return Q;return Q.push(J),Q}function CA($,J,Q){let W=$.findIndex((Y)=>Y.startsWith("-")||Y==="("||Y==="!"||Y===";"),X=[...$.slice(0,W===-1?$.length:W)];for(let Y=0;Y<$.length;Y++){if(!tP.has($[Y]??""))continue;let K=$.slice(Y+1),B=K.findIndex((G)=>eP.has(G)),q=B===-1?K:K.slice(0,B),U=OJ(q,J,Q);if(X.push(...U.filter((G)=>G!=="{}")),!U.includes("{}"))continue;X.push(...$.slice(0,Y).flatMap((G,H,L)=>{if(!JA.has(G))return[];let Z=L[H+1];return Z===void 0?[]:[Z,Z.replace(/^\*+\//,"").replace(/\/\*+$/g,"").replace(/^\*+/,"").replace(/\*+$/g,"")]}))}return X}function tL($){return QA.has($)||/^python\d/.test($)}function SA($,J,Q){let W=[];for(let X=0;X<J.length;X++){let Y=J[X];if(Y===void 0)break;if(iL.has(Y)||eL($,Y)){let B=J[X+1];if(B!==void 0)W.push(...pL($,B,Q)),X++;continue}let K=/^--(?:eval|exec)=(.*)$/.exec(Y);if(K!==null&&K[1]!==void 0){W.push(...pL($,K[1],Q));continue}if(!Y.startsWith("-"))W.push(Y)}return W}function eL($,J){if(!J.startsWith("-")||J.startsWith("--")||J.length<=2)return!1;return UA.get(J[J.length-1]??"")?.has(aL($))??!1}function TA($,J,Q){if(!$.includes("system"))return[];return TQ($)?.commands.flatMap((W)=>z6(J.getShellSyntax(W),J,Q))??[]}function wA($){return Array.from($.matchAll(/\bgetline(?:\s+[A-Za-z_][A-Za-z0-9_]*)?\s*<\s*"((?:\\.|[^"\\])*)"/g)).map((J)=>J[1]).filter((J)=>J!==void 0&&J!=="")}function $M($){let J=Array.from($.matchAll(/(['"`])((?:\\.|(?!\1).)*)\1/g)).map((W)=>W[2]).filter((W)=>W!==void 0&&W!==""),Q=($.match(/[\w./~@+-]*[./~][\w./~@+-]*/g)??[]).filter((W)=>W!=="process.versions.sqlite"||J.some((X)=>X.includes(W)));return[...J,...J.flatMap(JM),...Q]}function pL($,J,Q){let W=$M(J);if(!Q.refineJavaScriptInlineData||!WA.has($)||W.length===0)return W;let X=vA(J);return X!==null&&!kA(X)?[]:W}function vA($){let J=$.split("");for(let Q=0;Q<$.length;Q++){let W=$[Q];if(W!=="'"&&W!=='"'&&W!=="`")continue;if(W==="`"&&fA($,Q))return null;J[Q]=" ";let X=!1;for(let Y=Q+1;Y<$.length;Y++){let K=$[Y];if(J[Y]=" ",K==="\\"){if(Y++,Y<$.length)J[Y]=" ";continue}if(W==="`"&&K==="$"&&$[Y+1]==="{")return null;if(W!=="`"&&(K===`
101
- `||K==="\r"))return null;if(K!==W)continue;Q=Y,X=!0;break}if(!X)return null}return J.join("")}function fA($,J){for(let Q=J-1;Q>=0;Q--){let W=$[Q];if(!W||/\s/.test(W))continue;return/[\w$\])]/.test(W)}return!1}function kA($){for(let J of $.matchAll(/[A-Za-z_$][A-Za-z0-9_$]*/g)){let Q=J[0],W=J.index;if(XA.has(Q.toLowerCase()))return!0;let X=Q.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[_$\s]+/).map((Y)=>Y.toLowerCase());if(!X.some((Y)=>YA.has(Y)))continue;if(X.length>1)return!0;if(hA($,W)===".")return!0;if(yA($,W+Q.length)==="(")return!0}return!1}function hA($,J){for(let Q=J-1;Q>=0;Q--)if(!/\s/.test($[Q]??""))return $[Q];return}function yA($,J){for(let Q=J;Q<$.length;Q++)if(!/\s/.test($[Q]??""))return $[Q];return}function gA($,J,Q){return pA($).flatMap((W)=>{let X=J.getShellSyntax(W);if(X.status==="invalid")return[];return[...z6(X,J,Q),...xA(X)?uA(X):[]]})}function xA($){let J=$.entries;for(let Q=0;Q<J.length;Q++){let W=J[Q];if(W?.kind!=="word"||l2(L0(W.text)).toLowerCase()!=="base64")continue;for(let X=Q+1;X<J.length;X++){let Y=J[X];if(Y?.kind==="operator")break;if(Y?.kind!=="word")continue;let K=L0(Y.text);if(K==="--decode"||!K.startsWith("--")&&K.startsWith("-")&&/[dD]/.test(K))return!0}}return!1}function uA($){return $.entries.flatMap((J)=>J.kind==="word"?[L0(J.text)]:J.kind==="redirection"&&J.target?[L0(J.target)]:[]).flatMap(JM)}function JM($){let J=lA($);if(J===null)return[];let Q=Buffer.from(J,"base64").toString("utf8");if(Q===""||mA(Q))return[];return Buffer.from(Q,"utf8").toString("base64").replace(/=+$/g,"")===J.replace(/=+$/g,"")?[Q]:[]}function mA($){return Array.from($).some((J)=>{let Q=J.charCodeAt(0);return Q<32||Q===127})}function lA($){if($.length<8||!/^[A-Za-z0-9+/_-]+={0,2}$/.test($))return null;if(/=/.test($.replace(/=+$/g,"")))return null;let J=$.replace(/=+$/g,"");if(J.length%4===1)return null;return`${J.replace(/-/g,"+").replace(/_/g,"/")}${"=".repeat((4-J.length%4)%4)}`}function pA($){let J=[],Q={inSingle:!1,inDouble:!1,escaped:!1};for(let W=0;W<$.length;W++){let X=$[W];if(!X)break;if(H3(X,Q))continue;if(QM($,W,Q)){let Y=cA($,W+1);if(Y!==null)J.push(Y.body),W=Y.endIndex;continue}if(!Q.inSingle&&X==="`"){let Y=dA($,W);if(Y!==null)J.push(Y.body),W=Y.endIndex}}return J}function cA($,J){let Q={inSingle:!1,inDouble:!1,escaped:!1},W=1;for(let X=J+1;X<$.length;X++){let Y=$[X];if(!Y)break;if(H3(Y,Q))continue;if(QM($,X,Q)){W++,X++;continue}if(!Q.inSingle&&!Q.inDouble&&Y===")"){if(W--,W===0)return{body:$.slice(J+1,X),endIndex:X}}}return null}function dA($,J){let Q=!1;for(let W=J+1;W<$.length;W++){let X=$[W];if(!X)break;if(Q){Q=!1;continue}if(X==="\\"){Q=!0;continue}if(X==="`")return{body:$.slice(J+1,W),endIndex:W}}return null}function QM($,J,Q){return!Q.inSingle&&$[J]==="$"&&$[J+1]==="("&&$[J+2]!=="("}function rA($){let J=[],Q=[],W=!1,X=!1,Y=!1;for(let q=0;q<$.length;q++){let U=$[q];if(U===void 0)break;if(!Y&&U==="--"){Y=!0;continue}if(Y){Q.push(U);continue}let G=/^--([^=]+)(?:=(.*))?$/.exec(U);if(G!==null){let H=G[1]??"",L=G[2];if(H===HA)X=!0;if(LA.has(H))W=!0;if(L!==void 0){if(H===yL)J.push(L);continue}if(OA.has(H)){let Z=$[q+1];if(H===yL&&Z!==void 0)J.push(Z);q++}continue}if(U.startsWith("-")&&U.length>1){let H=U.slice(1),L="",Z="";for(let M=0;M<H.length;M++){let O=H[M]??"";if(ZA.has(O))W=!0;if(MA.has(O)){L=O,Z=H.slice(M+1);break}}if(L!=="")if(Z.length>0){if(L===hL)J.push(Z)}else{let M=$[q+1];if(L===hL&&M!==void 0)J.push(M);q++}continue}Q.push(U)}let B=!W&&!X?Q.slice(1):Q;return[...J,...B]}function o4($){let J=$.findIndex((Q)=>!WM(Q)&&!/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(Q));return J===-1?[]:[...$.slice(J)]}function WM($){return $==="env"||$==="command"||$==="builtin"||$==="sudo"}var iA=new Set(["id_rsa.pub","id_ed25519.pub","id_ecdsa.pub"]),oA=".env.",nA=new Set([".env.example",".env.sample",".env.template",".env.defaults"]),sA=[".env.example.",".env.sample."];function aA($){let J;try{J=new URL($.trim())}catch{return!1}return J.protocol!=="file:"&&J.host!==""}function tA($){return $.length>0&&!/\s/.test($)}function eA($,J,Q){try{let W=I6($,J,Q);return W!==""&&m1.entryKind(W)!=="missing"}catch(W){if(W instanceof S1)throw W;return!1}}var $E=new Set(["node_modules","__pycache__"]),JE=[["vendor","bundle"],["vendor","cache"]];function QE($,J,Q,W){if(aA($))return null;let X=m0($,J,W);if(!X)return null;let Y=Q1(X.split("/").pop()??""),K=Q1(X),B=()=>tA(Y)||eA($,J,W);if(nA.has(Y)||sA.some((H)=>Y.startsWith(H)))return null;let q=Q1(qE($,J,W));for(let H of YK){let L=`~/${H.suffixParts.join("/")}`;if((cL(K,L)||cL(q,L))&&u0(H.id,Q))return H.id}let U=WE(X,J,Q,W);if(U)return U;if(iA.has(Y))return null;for(let H of XK)if(Y===H.basename&&u0(H.id,Q))return H.id;if(Y.startsWith(oA)&&u0(GJ.id,Q)&&B())return GJ.id;for(let H of KK)if(Y.length>H.prefix.length&&Y.startsWith(H.prefix)){let L=Y.slice(H.prefix.length)[0];if((L==="-"||L==="_")&&u0(H.id,Q)&&B())return H.id}for(let H of BK)if(Y.length>H.prefix.length&&Y.startsWith(H.prefix)){if(Y.slice(H.prefix.length)===H.suffix&&u0(H.id,Q))return H.id}if(KE(K))return null;if(!Y.includes(".")&&O6.pattern.test(Y)&&u0(O6.id,Q))return O6.id;let G=BE(Y,Q);if(G)return G;return null}function WE($,J,Q,W){return HJ.find((X)=>{if(!u0(X.id,Q))return!1;switch(X.id){case"secret.cli.claude-code":return J1($,W1(process.env.CLAUDE_CONFIG_DIR,"~/.claude",J,W),[".credentials.json"]);case"secret.cli.claude-code.config":{let Y=Q1($).split("/");return J1($,W1(process.env.CLAUDE_CONFIG_DIR,"~/.claude",J,W),["settings.json","settings.local.json"])||D6($,"~/.claude.json",J,W)||Y.at(-1)==="settings.local.json"&&Y.at(-2)===".claude"||Y.at(-1)===".mcp.json"}case"secret.cli.antigravity":return J1($,m0("~/.gemini/config",J,W),["hooks.json","mcp_config.json"]);case"secret.cli.codex":{let Y=W1(process.env.CODEX_HOME,"~/.codex",J,W);return J1($,Y,["auth.json",".credentials.json"])||_6($,Y,["secrets",".sandbox-secrets"])}case"secret.cli.codex.config":{let Y=W1(process.env.CODEX_HOME,"~/.codex",J,W),K=Q1($).split("/").at(-1)??"";return J1($,Y,["config.toml"])||K.endsWith(".config.toml")&&J1($,Y,[K])}case"secret.cli.gemini":return J1($,F1(W1(process.env.GEMINI_CLI_HOME,"~",J,W),".gemini"),["oauth_creds.json","mcp-oauth-tokens.json","a2a-oauth-tokens.json","gemini-credentials.json"]);case"secret.cli.gemini.config":{let Y=Q1($).split("/"),K=process.env.ProgramData?[F1(W1(process.env.ProgramData,"",J,W),"gemini-cli")]:[];return J1($,F1(W1(process.env.GEMINI_CLI_HOME,"~",J,W),".gemini"),["settings.json","google_accounts.json"])||Y.at(-1)==="settings.json"&&Y.at(-2)===".gemini"||(process.env.GEMINI_CLI_SYSTEM_SETTINGS_PATH?.trim()?D6($,process.env.GEMINI_CLI_SYSTEM_SETTINGS_PATH,J,W):!1)||["/Library/Application Support/GeminiCli","/etc/gemini-cli",...K].some((B)=>J1($,m0(B,J,W),["settings.json"]))}case"secret.cli.copilot-cli":{let Y=W1(process.env.COPILOT_HOME,"~/.copilot",J,W);return J1($,Y,["config.json"])||_6($,Y,["mcp-oauth-config","mcp-secrets"])}case"secret.cli.copilot-cli.config":return J1($,W1(process.env.COPILOT_HOME,"~/.copilot",J,W),["mcp-config.json"]);case"secret.cli.kimi-code":{let Y=W1(process.env.KIMI_CODE_HOME,"~/.kimi-code",J,W),K=W1(process.env.KIMI_SHARE_DIR,"~/.kimi",J,W);return J1($,Y,["server.token"])||_6($,Y,["credentials"])||_6($,K,["credentials","mcp-oauth"])}case"secret.cli.kimi-code.config":{let Y=["config.toml","mcp.json"],K=Q1($).split("/");return K.at(-1)==="mcp.json"&&K.at(-2)===".kimi-code"||J1($,W1(process.env.KIMI_CODE_HOME,"~/.kimi-code",J,W),Y)||J1($,W1(process.env.KIMI_SHARE_DIR,"~/.kimi",J,W),[...Y,"config.json","config.json.bak"])}case"secret.cli.opencode":{let Y=F1(W1(process.env.XDG_DATA_HOME,"~/.local/share",J,W),"opencode"),K=Q1($).split("/").at(-1)??"",B=process.env.OPENCODE_DB?.trim(),q=B&&B!==":memory:"?[B,`${B}-wal`,`${B}-shm`]:[];return J1($,Y,["auth.json","mcp-auth.json"])||/^opencode(-.+)?\.db(-wal|-shm)?$/.test(K)&&J1($,Y,[K])||q.some((U)=>D6($,U,J,W))}case"secret.cli.opencode.config":{let Y=process.env.OPENCODE_CONFIG_DIR?W1(process.env.OPENCODE_CONFIG_DIR,"~/.config/opencode",J,W):F1(W1(process.env.XDG_CONFIG_HOME,"~/.config",J,W),"opencode"),K=process.env.ProgramData?[F1(W1(process.env.ProgramData,"",J,W),"opencode")]:[],B=["opencode.json","opencode.jsonc"];return B.includes(Q1($).split("/").at(-1)??"")||J1($,Y,B)||(process.env.OPENCODE_CONFIG?.trim()?D6($,process.env.OPENCODE_CONFIG,J,W):!1)||["/Library/Application Support/opencode","/etc/opencode",...K].some((q)=>J1($,m0(q,J,W),B))}case"secret.cli.pi":return J1($,W1(process.env.PI_CODING_AGENT_DIR,"~/.pi/agent",J,W),["auth.json"]);case"secret.cli.pi.config":return J1($,W1(process.env.PI_CODING_AGENT_DIR,"~/.pi/agent",J,W),["models.json"]);case"secret.cli.amp":{let Y=m0("~",J,W);return[F1(W1(process.env.XDG_DATA_HOME,"~/.local/share",J,W),"amp"),F1(Y,".local","share","amp")].some((B)=>J1($,B,["secrets.json"]))||_6($,F1(Y,".amp"),["oauth"])}case"secret.cli.amp.config":{let Y=["settings.json","settings.jsonc"],K=[F1(W1(process.env.XDG_CONFIG_HOME,"~/.config",J,W),"amp"),F1(m0("~",J,W),".config","amp")],B=Q1($).split("/");return K.some((q)=>J1($,q,Y))||B.at(-2)===".amp"&&Y.includes(B.at(-1)??"")||(process.env.AMP_SETTINGS_FILE?.trim()?D6($,process.env.AMP_SETTINGS_FILE,J,W):!1)}case"secret.cli.cursor":{let Y=F1(W1(process.env.XDG_CONFIG_HOME,"~/.config",J,W),"cursor"),K=F1(W1(process.env.CURSOR_DATA_DIR,"~/.cursor",J,W),"projects");return J1($,m0("~/.cursor",J,W),["auth.json"])||J1($,Y,["auth.json"])||Q1($).split("/").at(-1)==="mcp-auth.json"&&m2(Q1($),Q1(K))}case"secret.cli.cursor.config":{let Y=Q1($).split("/");return Y.at(-1)==="mcp.json"&&Y.at(-2)===".cursor"}default:return!1}})?.id??null}function W1($,J,Q,W){return m0($?.trim()?$:J,Q,W)}function J1($,J,Q){return Q.some((W)=>XM($,F1(J,W)))}function _6($,J,Q){return Q.some((W)=>m2(Q1($),Q1(F1(J,W))))}function D6($,J,Q,W){return XM($,m0(J,Q,W))}function XM($,J){return Q1($)===Q1(J)}function F1($,...J){return K0([$,...J].filter(Boolean).join("/"))}function XE($,J,Q,W,X){if(Q.length===0)return!1;let Y=Q1(I6($,J,X));return Q.some((K)=>m2(Y,Q1(I6(K,W,X))))}function YE($,J,Q,W,X){if(Q.length===0)return!1;let Y=Q1(I6($,J,X));if(!Y)return!1;let K=process.env.HOME??OK(),B=K?K0(a(K,m1,X)):"",q=Q1(B),U=process.env.CC_SAFETY_NET_HOME,G=Q1(U?K0(a(NJ(U),m1,X)):B&&K0(a(`${B}/.cc-safety-net`,m1,X)));if(G&&m2(Y,G))return!1;return Q.some((H)=>{let L=Q1(I6(H,W,X));if(!L)return!1;if(q&&(q===L||q.startsWith(L.endsWith("/")?L:`${L}/`)))return!1;return m2(Y,L)})}function KE($){let J=$.split("/");return J.some((Q)=>$E.has(Q))||JE.some(([Q,W])=>J.some((X,Y)=>X===Q&&J[Y+1]===W))}function BE($,J){let Q=$.lastIndexOf("."),W=Q>0&&Q<$.length-1?$.slice(Q+1):"";if(W==="")return null;for(let X of qK)if(W===X.extension&&u0(X.id,J))return X.id;for(let X of UK)if(X.pattern.test(W)&&u0(X.id,J))return X.id;return null}function Q1($){return $.toLowerCase()}function u0($,J){if(!J?.disabledRules)return!0;if(Array.isArray(J.disabledRules))return!J.disabledRules.includes($);return!J.disabledRules.has($)}function m0($,J,Q){let{home:W,normalized:X}=NK($,Q);if(!X)return"";if(!W)return X;let Y=FK(X,W),K=MJ(Y)?Y:K0(NJ(J,Y)),B=K0(a(K,m1,Q));if(!m2(B,W)){if(MJ(Y))return B;return B===K?X:B}let q=B.slice(W.length);return q?`~${q}`:"~"}function cL($,J){return $===J||$.startsWith(`${J}/`)}function qE($,J,Q){let{home:W,normalized:X}=NK($,Q);if(!X||!W)return"";let Y=FK(X,W),K=oP.normalize(MJ(Y)?Y:K0(NJ(J,Y))),B=K0(process.env.HOME??OK()),q=(H)=>process.platform==="win32"?H.toLowerCase():H,U=[W,B].find((H)=>H!==""&&m2(q(K),q(H)));if(U===void 0)return"";let G=K.slice(U.length);return G?`~${G}`:"~"}function I6($,J,Q){let{home:W,normalized:X}=NK($,Q);if(!X)return"";let Y=W?FK(X,W):X;return K0(a(MJ(Y)?Y:NJ(J,Y),m1,Q))}function NK($,J){let Q=process.env.HOME??OK(),W=Q?K0(a(Q,m1,J)):"",X=K0(UE(L0($)));return{home:W,normalized:X}}function UE($){if(!$.trim().toLowerCase().startsWith("file:"))return $;try{return sP($)}catch{return $}}function FK($,J){if($==="~")return J;if($.startsWith("~/"))return F1(J,$.slice(2));return $}function GE($){if(process.platform==="win32")return!0;return nP.parse($).root.length>1}function K0($){let J=$.trim(),Q=(GE(J)?J.replace(/\\/g,"/"):J).replace(/\/{2,}/g,"/").replace(/^\.\//,"");if(Q==="/")return Q;return Q.replace(/\/+$/g,"")}function m2($,J){return $===J||$.startsWith(J.endsWith("/")?J:`${J}/`)}function l2($){return $.split(/[\\/]/).pop()?.replace(/\.exe$/i,"")??$}import{dirname as FJ}from"node:path";var YM="Rulebook exceeds CC Safety Net's safe validation limits.",KM="Additional rulebook validation errors were omitted.",B0=Object.freeze({maxAllowedCommands:1024,maxRules:1024,maxTests:2048,maxBlockArgsPerRule:1024,maxTotalBlockArgs:16384,maxStringCodeUnits:1048576,maxAggregateStringCodeUnits:4194304,maxFixtureCommandCodeUnits:131072,maxValidationErrors:64});function BM($){if(VK($.allowed_commands,B0.maxAllowedCommands)||VK($.rules,B0.maxRules)||VK($.tests,B0.maxTests))return!1;let{maxAggregateStringCodeUnits:J,maxTotalBlockArgs:Q}=B0,W=(X,Y=!1)=>{if(typeof X!=="string")return!0;if(X.length>B0.maxStringCodeUnits||Y&&X.length>B0.maxFixtureCommandCodeUnits||X.length>J)return!1;return J-=X.length,!0};if(!W($.name)||!W($.version)||!W($.description)||!W($.author)||!W($.migrated_from))return!1;if(Array.isArray($.allowed_commands)){for(let X of $.allowed_commands)if(!W(X))return!1}if(Array.isArray($.rules))for(let X of $.rules){if(!X||typeof X!=="object")continue;let Y=X;if(!W(Y.name)||!W(Y.command)||!W(Y.subcommand)||!W(Y.reason)||!W(Y.intent))return!1;if(!Array.isArray(Y.block_args))continue;if(Y.block_args.length>B0.maxBlockArgsPerRule||Y.block_args.length>Q)return!1;Q-=Y.block_args.length;for(let K of Y.block_args)if(!W(K))return!1}if(Array.isArray($.tests))for(let X of $.tests){if(!X||typeof X!=="object")continue;let Y=X;if(!W(Y.command,!0)||!W(Y.expect)||!W(Y.rule))return!1}return!0}function VK($,J){return Array.isArray($)&&$.length>J}function HE($){if(!ZE($))return{errors:["Rulebook must be an object"],ruleNames:new Set};if(!BM($))return{errors:[YM],ruleNames:new Set};let J=VL().safeParse($),Q=[...$.rulebook_version===1?[]:["rulebook_version must be 1"],...J.success?[]:i4(J.error.issues,": ",": ")];return{errors:Q.length>B0.maxValidationErrors?[...Q.slice(0,B0.maxValidationErrors),KM]:Q,ruleNames:new Set(GK($).map((W)=>W.toLowerCase()))}}function _K($){let J=HE($);if(J.errors.length>0)throw Error(J.errors.join("; "));return $}function ZE($){return!!$&&typeof $==="object"&&!Array.isArray($)}function DK($){if(T6($.spec))return OE($);return ME($)}function ME($){if(!q0.test($.spec))return`Local rulebook sources must be bare names matching ${q0}: ${$.spec}`;if($.kind!=="local-directory")return`lock entry for ${$.spec} must use local-directory kind`;if($.path===$.spec&&$.name===$.spec)return null;return`lock entry for ${$.spec} does not match local source identity`}function OE($){let J=n4($.spec);if(J)return J;let Q=S6($.spec);if($.kind!=="github")return`lock entry for ${$.spec} must use github kind`;if($.owner===Q.owner&&$.repo===Q.repo&&$.ref===Q.ref&&$.path===Q.path&&$.name===Q.name)return null;return`lock entry for ${$.spec} does not match GitHub source identity`}function qM($){let J=typeof $==="string"?$:$.path;try{let Q=G2(typeof $==="string"?C6($):$);if(Q===null)return{lock:null,errors:[]};let W=JSON.parse(Q);if(!W||typeof W!=="object")return{lock:null,errors:[`malformed lockfile ${J}: must be an object`]};let X=W;if(X.version!==1||!Array.isArray(X.rulebooks))return{lock:null,errors:[`malformed lockfile ${J}`]};let Y=_L().safeParse(X),K=X.rulebooks.flatMap((q,U)=>{let G=Y.success?[]:Y.error.issues.filter((L)=>L.path[1]===U);if(G.length>0)return i4(G).map((L)=>`${J}: ${L}`);let H=DK(q);return H?[`${J}: rulebooks[${U}]: ${H}`]:[]});if(!Y.success||K.length>0)return{lock:null,errors:[`malformed lockfile ${J}`,...K]};return{lock:{version:1,rulebooks:Y.data.rulebooks.map((q)=>{if(q.kind==="local-directory")return{spec:q.spec,kind:q.kind,path:q.path,name:q.name,version:q.version,digest:q.digest};let U={spec:q.spec,kind:q.kind,owner:q.owner,repo:q.repo,ref:q.ref,commit:q.commit,path:q.path,name:q.name,version:q.version,digest:q.digest};return typeof q.display_ref==="string"&&q.display_ref!==""?{...U,display_ref:q.display_ref}:U})},errors:[]}}catch(Q){if(Q instanceof K1)return{lock:null,errors:[Q.message]};return{lock:null,errors:["malformed lockfile"]}}}import{createHash as NE}from"node:crypto";var ty=Object.freeze({timeoutMs:15000,metadataBytes:524288,commitBytes:262144,treeBytes:16777216,rawBytes:4194304});function UM($){return`sha256:${NE("sha256").update($).digest("hex")}`}function MM($={}){let J=uK($),Q=!1;try{Q=wK(J.userConfigTarget,J.projectConfigTarget)}catch(L){if(L instanceof K1)return DE(J,L.message);throw L}let W=HK(J.userConfigTarget),X=Q?{config:null,errors:[]}:HK(J.projectConfigTarget),Y=LM(J.userConfigPath,W.errors),K=LM(J.projectConfigPath,X.errors),B=new Set,q=W.config?GM(W.config,J.userLockPath,FJ(J.userConfigPath),$,"user",J.userScope,B):j6(),U=X.config?GM(X.config,J.projectLockPath,FJ(J.projectConfigPath),$,"project",J.projectScope,B):j6(),G=W.config?.overrides??{},H=X.config?.overrides??{};return{rules:[...HM(q.rules,G),...HM(U.rules,H)],transparent_wrappers:VE(W.config,X.config),rulebooks:[...q.rulebooks,...U.rulebooks],errors:[...Y,...K,...q.errors,...U.errors],warnings:[...q.warnings,...U.warnings,...q.canValidateOverrides?ZM(G,q.knownRuleIds,J.userConfigPath):[],...q.canValidateOverrides?_E(H,q.knownRuleIds,J.projectConfigPath):[],...U.canValidateOverrides?ZM(H,U.knownRuleIds,J.projectConfigPath):[]],userConfig:W.config??void 0,projectConfig:X.config??void 0,...J}}function GM($,J,Q,W,X,Y=l0(FJ(FJ(Q)),X==="user"?"user policy":"project policy"),K=new Set){let B;try{B=E0(Y,J)}catch(V){if(V instanceof K1)return{...j6(),errors:[V.message],canValidateOverrides:!1};throw V}let q=qM(B);if(q.errors.length>0)return{...j6(),errors:q.errors,canValidateOverrides:!1};let U=q.lock;if(!U&&$.rules.length>0)return{...j6(),errors:[`missing lockfile ${J}; run ${d0}`],canValidateOverrides:!1};let G=U?.rulebooks??[],H=new Map(G.map((V)=>[V.spec,V])),L=[],Z=[],M=$.rules.flatMap((V)=>{let F=H.get(V);if(!F)return L.push(`missing lock entry for ${V}; run ${d0}`),[];let b=FE(F,Q,W,Y);if(b.errors.length>0||!b.rulebook)return L.push(...b.errors),[];let I=b.rulebook;if(K.has(I.name))return Z.push(`duplicate active rulebook name "${I.name}" for ${V}; keeping the first and ignoring this one, so its rules are not active; rename one of them, then run ${d0}`),[];return K.add(I.name),[{rules:I.rules.map((A)=>({...A,name:`${I.name}/${A.name}`})),rulebook:{source:X,spec:F.spec,name:I.name,version:I.version,rules:I.rules.map((A)=>`${I.name}/${A.name}`)}}]}),O=M.flatMap((V)=>V.rules);return{rules:O,rulebooks:M.map((V)=>V.rulebook),entries:G,knownRuleIds:new Set(O.map((V)=>V.name)),errors:L,warnings:Z,canValidateOverrides:L.length===0}}function FE($,J,Q,W){let X=PJ($,AJ(J,Q)),Y;try{Y=G2(E0(W,X))}catch(B){if(B instanceof K1)return{rulebook:null,errors:[B.message]};throw B}if(Y===null)return{rulebook:null,errors:[`missing cache entry for ${$.spec}; run ${d0}`]};if(UM(Y)!==$.digest)return{rulebook:null,errors:[`cache digest mismatch for ${$.spec}; run ${d0}`]};let K;try{K=JSON.parse(Y)}catch{return{rulebook:null,errors:[`invalid cached rulebook for ${$.spec}`]}}try{_K(K)}catch(B){return{rulebook:null,errors:[`invalid cached rulebook for ${$.spec}: ${B instanceof Error?B.message:"invalid rulebook"}`]}}return{rulebook:K,errors:[]}}function VE($,J){return[...new Set([...$?.transparent_wrappers??[],...J?.transparent_wrappers??[]])]}function HM($,J){return $.flatMap((Q)=>{let W=J[Q.name];if(W==="off")return[];if(W&&typeof W==="object")return[{...Q,intent:W.intent??Q.intent,reason:W.reason}];return[Q]})}function ZM($,J,Q){return Object.keys($).filter((W)=>!J.has(W)).map((W)=>`unknown override key "${W}" in ${Q}; only that override is ignored and other overrides and rules keep their configured state; correct or remove it in that file`)}function _E($,J,Q){return Object.keys($).filter((W)=>J.has(W)).map((W)=>`project override cannot target user-scoped rule "${W}" in ${Q}; only that override is ignored and the rule keeps its user-configured state; remove it from that file`)}function LM($,J){return J.map((Q)=>Q.startsWith("Unable to access ")?Q:`${$}: ${Q}`)}function DE($,J){return{rules:[],transparent_wrappers:[],rulebooks:[],errors:[J],warnings:[],userConfigPath:$.userConfigPath,projectConfigPath:$.projectConfigPath,userLockPath:$.userLockPath,projectLockPath:$.projectLockPath}}function j6(){return{rules:[],rulebooks:[],entries:[],knownRuleIds:new Set,errors:[],warnings:[],canValidateOverrides:!0}}function OM($={}){let J=MM($),Q=AL($),W={rules:J.rules,transparentWrappers:J.transparent_wrappers,safety:Q.safety,worktreeMode:Q.worktreeMode,destructiveCommandProtectionEnabled:Q.destructiveCommandProtectionEnabled,destructiveCommandRuleOverrides:Q.destructiveCommandRuleOverrides,destructiveCommandAllowPaths:Q.destructiveCommandAllowPaths,secretProtection:{enabled:Q.secretProtection.enabled??!0,disabledRules:[...Q.secretProtection.disabledRules??[]],denyPaths:Q.secretProtection.denyPaths,allowPaths:Q.secretProtection.allowPaths??[]}},X={...J.userConfig?.overrides??{},...J.projectConfig?.overrides??{}},Y=Object.freeze(Object.fromEntries(W.rules.map((K)=>{let B=J.rulebooks.find((U)=>U.rules.includes(K.name)),q=X[K.name];return[K.name,Object.freeze({id:K.name,...B?{rulebook:Object.freeze({name:B.name,version:B.version}),...RE(B.spec)?{source:B.spec}:{}}:{},...q&&typeof q==="object"?{override:Object.freeze({type:"reason",reason:q.reason})}:{}})]})));return bE(W,zE(J,Q),Y)}function zE($,J){let Q=jE(J);if($.errors.length===0&&$.warnings.length===0&&!Q)return;return{diagnostics:[...$.errors,...$.warnings,...J.errors],reason:PE($.errors.length>0?IE($.errors):void 0,$.warnings.length>0?zK($.warnings.join("; ")):void 0,Q)}}function IE($){return`${zK($.join("; "))} Those rule sources are not active; every other rule and all built-in protections still apply`}function jE($){if($.errors.length===0)return;let J=$.fallback==="salvaged"?"the salvaged policy with protective defaults":"built-in protective defaults";return`invalid policy config: ${$.errors.join("; ")}. Enforcing ${J}; the invalid values are not active. Fix the policy file manually`}function RE($){return/^(?:[A-Za-z0-9_.-]+$|https:\/\/github\.com\/|github:|gh:|[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+(?:#|$))/.test($)}function bE($,J,Q=Object.freeze({})){let W=NM(structuredClone($));if(!J)return Object.freeze({state:"ready",policy:W,diagnostics:Object.freeze([]),ruleMetadata:Q});return Object.freeze({state:"degraded",policy:W,diagnostics:Object.freeze([...J.diagnostics]),reason:J.reason,ruleMetadata:Q})}function NM($){if(typeof $!=="object"||$===null)return $;for(let J of Object.values($))NM(J);return Object.freeze($)}function PE(...$){return zK($.filter((J)=>!!J).join("; "))}function zK($){return/[.!?]$/.test($)?$:`${$}.`}class q2 extends Error{stage;evaluation;name="GuardEvaluationError";constructor($,J,Q){super(`CC Safety Net ${$} dependency failed`,{cause:Q});this.stage=$;this.evaluation=J}}var AE={findPolicyMutation:vL,findGitMetadataMutation:$U,resolveGitMetadata:zQ,loadPolicySnapshot:OM,findSensitiveTarget:nL,analyzeCommand:HH,getModes:V7};function FM($,J={}){let Q={...AE,...J.dependencies},W=SE($),X=R6($)?$.command:W,Y=p2("policy-protection",X,()=>E9($,J.factParserDependencies)),K=f1(Y,"declared-command");if(R6($)&&$.command?.trim()&&K?.program.status==="limited")return{stage:"command-analysis",decision:{kind:"deny",reason:S0,intent:"stop_and_explain",evidence:[{kind:"command",command:$.command,segment:$.command}]}};if(f1(Y,"input-candidate")?.program.status==="limited")return{stage:"command-validation",decision:{kind:"deny",reason:QB,intent:"stop_and_explain",evidence:[]}};let B=p2("policy-protection",X,()=>Q.resolveGitMetadata($.context.executionCwd)),q=p2("policy-protection",X,()=>Q.findPolicyMutation(Y));if(q){let V=X??q.target;return{stage:"policy-protection",decision:{kind:"deny",reason:wL,intent:"hard_stop",evidence:[{kind:"command",command:V,segment:q.target},{kind:"path",target:q.target}]}}}let U=p2("policy-protection",X,()=>Q.findGitMetadataMutation(Y,B));if(U){let V=X??U.target;return{stage:"policy-protection",decision:{kind:"deny",reason:d1,intent:"hard_stop",evidence:[{kind:"command",command:V,segment:U.target},{kind:"path",target:U.target}]}}}let G=p2("config-load",X,()=>Q.loadPolicySnapshot({...J.policyOptions,cwd:$.context.configCwd})),H=G.policy,L=Q.getModes(H),Z={level:L.effectiveLevel,...EE(G)},M=H.secretProtection.enabled===!1?null:p2("secret-protection",X,()=>Q.findSensitiveTarget(Y,H.secretProtection,{strict:R6($)?L.strict:void 0}));if(M){let V=X??M.target;return{stage:"secret-protection",...Z,decision:{kind:"deny",reason:dL,intent:"hard_stop",ruleId:M.ruleId,evidence:[{kind:"command",command:V,segment:M.target},{kind:"path",target:M.target}]}}}if(!R6($))return{stage:"non-command",...Z,decision:{kind:"allow"}};if(!$.command||$.command.trim()==="")return{...IK("command-validation",X),...Z};let O=p2("command-analysis",X,()=>{return Q.analyzeCommand($.command,{cwd:$.context.executionCwd,shell:$.route.shell,policySnapshot:G,environment:T0(),protectedGitMetadata:B,effectiveCapabilities:L.capabilities,strict:L.strict,paranoidRm:L.paranoidRm,paranoidInterpreters:L.paranoidInterpreters,worktreeMode:L.worktreeMode},CE(Y),Y.store)});if(O)return{stage:"command-analysis",...Z,decision:O};return{stage:"command-analysis",...Z,decision:{kind:"allow"}}}function EE($){if($.state==="ready")return{};return{configFallback:{reason:$.reason}}}function CE($){return f1($,"declared-command")?.program}function SE($){try{return X4($.input)}catch(J){let Q=R6($)?$.command:void 0;throw new q2("policy-protection",IK("policy-protection",J instanceof k0?void 0:Q),J)}}function p2($,J,Q){try{return Q()}catch(W){throw new q2($,IK($,W instanceof k0?void 0:J),W)}}function IK($,J){return{stage:$,decision:{kind:"deny",reason:k6,intent:"stop_and_explain",evidence:J?[{kind:"command",command:J,segment:J}]:[]}}}function R6($){return $.route.kind==="command"}function _M($,J){try{let Q=FM($,J.guard);return VM($,Q,J),Q}catch(Q){if(!(Q instanceof q2))throw Q;throw VM($,Q.evaluation,J,!(Q.cause instanceof k0),{stage:Q.stage,errorCode:TE(Q.cause)}),Q}}function VM($,J,Q,W=!0,X){aK(sK($,J,Q.guard?.auditAllowed??!1,W,X),Q.audit.getSessionId,{agent:Q.audit.agent,shape:Q.audit.shape,homeDir:Q.audit.homeDir})}function TE($){if($ instanceof S1)return"path-canonicalization-limit";if($ instanceof k0)return"tool-input-limit";if($ instanceof n0)return"structural-shell-syntax-limit";return"unexpected-error"}var zM="exec",wE=new Set(["auto","gateway"]);function IM($){$.on("before_tool_call",vE($),{matcher:[zM],priority:50})}function vE($,J={}){return(Q,W)=>{if(W.abortSignal?.aborted)return jK(wJ());let X=fE(Q,W,$);if(!X)return;let Y=()=>W.sessionId??W.sessionKey;if("malformed"in X)return tK(X.denial,Y,{agent:"openclaw",toolName:X.denial.toolName,cwd:X.cwd}),jK(X.denial);try{let K=_M(X,{guard:{auditAllowed:N7(),dependencies:J.guardDependencies},audit:{agent:"openclaw",getSessionId:Y}});return DM(K,K.stage!=="config-state")}catch(K){if(!(K instanceof q2))throw K;if(J2(H1.debug))console.error(`CC Safety Net debug: openclaw before_tool_call analysis failed: ${BB(K.cause)}`);return DM(K.evaluation,!0)}}}function fE($,J,Q){if(!$||typeof $!=="object")return c2(null);let W=$.toolName;if(typeof W!=="string"||W.trim()==="")return c2(null);if(W!==zM)return;if($.toolKind!==void 0)return;let X=$.params;if(!X||typeof X!=="object"||Array.isArray(X))return c2(null,W);let Y=X,K=Y.command;if(typeof K!=="string"||K.trim()==="")return c2(null,W);if(Y.host!==void 0&&!wE.has(Y.host))return c2(null,W,K);let B=kE(Q,J.agentId);if(!B)return c2(null,W,K);let q=hE(B,Y);if(!q)return c2(B,W,K,typeof Y.workdir==="string"?Y.workdir:void 0);return H$(W,Y,{kind:"command",shell:"auto"},{configCwd:B,executionCwd:q},K)}function kE($,J){if(typeof J!=="string"||J.trim()==="")return;try{let Q=$.runtime.agent.resolveAgentWorkspaceDir($.config,J);if(typeof Q!=="string"||Q.trim()==="")return;return f6(".",[Q])}catch{return}}function hE($,J){if(!Object.hasOwn(J,"workdir")||J.workdir===void 0)return $;let Q=J.workdir;if(typeof Q!=="string"||Q.trim()==="")return;return f6(Q,[$])}function c2($,J,Q,W){return{malformed:!0,denial:wJ({command:Q,segment:W,toolName:J}),cwd:$}}function DM($,J){let Q=YB($,{includeEvidence:J});return Q?jK(Q):void 0}function jK($){return{block:!0,blockReason:KB($)}}var rg={...PK,register:IM};export{rg as default};
97
+ `)}m.write("payload.value = newResult;"),m.write("return payload;");let E=m.compile();return(w,R)=>E(f,w,R)},i,s=Dn,a=!Mo.jitless,l=a&&Rd.value,u=t.catchall,d;e._zod.parse=(f,m)=>{d??(d=r.value);let p=f.value;if(!s(p))return f.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),f;if(a&&l&&m?.async===!1&&m.jitless!==!0){if(!i)i=o(t.shape);if(f=i(f,m),!u)return f;return W_([],p,f,m,d,e)}return n(f,m)}});function R_(e,t,n,r){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter((i)=>!an(i));if(o.length===1)return t.value=o[0].value,o[0];return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((i)=>i.issues.map((s)=>Pe(s,r,se())))}),t}var Yo=g("$ZodUnion",(e,t)=>{D.init(e,t),F(e._zod,"optin",()=>t.options.some((o)=>o._zod.optin==="optional")?"optional":void 0),F(e._zod,"optout",()=>t.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),F(e._zod,"values",()=>{if(t.options.every((o)=>o._zod.values))return new Set(t.options.flatMap((o)=>Array.from(o._zod.values)));return}),F(e._zod,"pattern",()=>{if(t.options.every((o)=>o._zod.pattern)){let o=t.options.map((i)=>i._zod.pattern);return new RegExp(`^(${o.map((i)=>Go(i.source)).join("|")})$`)}return});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(n)return r(o,i);let s=!1,a=[];for(let c of t.options){let l=c._zod.run({value:o.value,issues:[]},i);if(l instanceof Promise)a.push(l),s=!0;else{if(l.issues.length===0)return l;a.push(l)}}if(!s)return R_(a,o,e,i);return Promise.all(a).then((c)=>R_(c,o,e,i))}});function P_(e,t,n,r){let o=e.filter((i)=>i.issues.length===0);if(o.length===1)return t.value=o[0].value,t;if(o.length===0)t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map((i)=>i.issues.map((s)=>Pe(s,r,se())))});else t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1});return t}var pf=g("$ZodXor",(e,t)=>{Yo.init(e,t),t.inclusive=!1;let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(n)return r(o,i);let s=!1,a=[];for(let c of t.options){let l=c._zod.run({value:o.value,issues:[]},i);if(l instanceof Promise)a.push(l),s=!0;else a.push(l)}if(!s)return P_(a,o,e,i);return Promise.all(a).then((c)=>P_(c,o,e,i))}}),gf=g("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Yo.init(e,t);let n=e._zod.parse;F(e._zod,"propValues",()=>{let o={};for(let i of t.options){let s=i._zod.propValues;if(!s||Object.keys(s).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let[a,c]of Object.entries(s)){if(!o[a])o[a]=new Set;for(let l of c)o[a].add(l)}}return o});let r=yr(()=>{let o=t.options,i=new Map;for(let s of o){let a=s._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let c of a){if(i.has(c))throw Error(`Duplicate discriminator value "${String(c)}"`);i.set(c,s)}}return i});e._zod.parse=(o,i)=>{let s=o.value;if(!Dn(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;let a=r.value.get(s?.[t.discriminator]);if(a)return a._zod.run(o,i);if(t.unionFallback)return n(o,i);return o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:s,path:[t.discriminator],inst:e}),o}}),hf=g("$ZodIntersection",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{let o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([c,l])=>k_(n,c,l));return k_(n,i,s)}});function km(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(sn(e)&&sn(t)){let n=Object.keys(t),r=Object.keys(e).filter((i)=>n.indexOf(i)!==-1),o={...e,...t};for(let i of r){let s=km(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let o=e[r],i=t[r],s=km(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function k_(e,t,n){let r=new Map,o;for(let a of t.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(let c of a.keys){if(!r.has(c))r.set(c,{});r.get(c).l=!0}}else e.issues.push(a);for(let a of n.issues)if(a.code==="unrecognized_keys")for(let c of a.keys){if(!r.has(c))r.set(c,{});r.get(c).r=!0}else e.issues.push(a);let i=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&o)e.issues.push({...o,keys:i});if(an(e))return e;let s=km(t.value,n.value);if(!s.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}var Za=g("$ZodTuple",(e,t)=>{D.init(e,t);let n=t.items;e._zod.parse=(r,o)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=[];let s=[],a=[...n].reverse().findIndex((u)=>u._zod.optin!=="optional"),c=a===-1?0:n.length-a;if(!t.rest){let u=i.length>n.length,d=i.length<c-1;if(u||d)return r.issues.push({...u?{code:"too_big",maximum:n.length,inclusive:!0}:{code:"too_small",minimum:n.length},input:i,inst:e,origin:"array"}),r}let l=-1;for(let u of n){if(l++,l>=i.length){if(l>=c)continue}let d=u._zod.run({value:i[l],issues:[]},o);if(d instanceof Promise)s.push(d.then((f)=>Da(f,r,l)));else Da(d,r,l)}if(t.rest){let u=i.slice(n.length);for(let d of u){l++;let f=t.rest._zod.run({value:d,issues:[]},o);if(f instanceof Promise)s.push(f.then((m)=>Da(m,r,l)));else Da(f,r,l)}}if(s.length)return Promise.all(s).then(()=>r);return r}});function Da(e,t,n){if(e.issues.length)t.issues.push(...We(n,e.issues));t.value[n]=e.value}var yf=g("$ZodRecord",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;if(!sn(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;let i=[],s=t.keyType._zod.values;if(s){n.value={};let a=new Set;for(let l of s)if(typeof l==="string"||typeof l==="number"||typeof l==="symbol"){a.add(typeof l==="number"?l.toString():l);let u=t.valueType._zod.run({value:o[l],issues:[]},r);if(u instanceof Promise)i.push(u.then((d)=>{if(d.issues.length)n.issues.push(...We(l,d.issues));n.value[l]=d.value}));else{if(u.issues.length)n.issues.push(...We(l,u.issues));n.value[l]=u.value}}let c;for(let l in o)if(!a.has(l))c=c??[],c.push(l);if(c&&c.length>0)n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{n.value={};for(let a of Reflect.ownKeys(o)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof a==="string"&&Ho.test(a)&&c.issues.length&&c.issues.some((d)=>d.code==="invalid_type"&&d.expected==="number")){let d=t.keyType._zod.run({value:Number(a),issues:[]},r);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(d.issues.length===0)c=d}if(c.issues.length){if(t.mode==="loose")n.value[a]=o[a];else n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map((d)=>Pe(d,r,se())),input:a,path:[a],inst:e});continue}let u=t.valueType._zod.run({value:o[a],issues:[]},r);if(u instanceof Promise)i.push(u.then((d)=>{if(d.issues.length)n.issues.push(...We(a,d.issues));n.value[c.value]=d.value}));else{if(u.issues.length)n.issues.push(...We(a,u.issues));n.value[c.value]=u.value}}}if(i.length)return Promise.all(i).then(()=>n);return n}}),bf=g("$ZodMap",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;if(!(o instanceof Map))return n.issues.push({expected:"map",code:"invalid_type",input:o,inst:e}),n;let i=[];n.value=new Map;for(let[s,a]of o){let c=t.keyType._zod.run({value:s,issues:[]},r),l=t.valueType._zod.run({value:a,issues:[]},r);if(c instanceof Promise||l instanceof Promise)i.push(Promise.all([c,l]).then(([u,d])=>{A_(u,d,n,s,o,e,r)}));else A_(c,l,n,s,o,e,r)}if(i.length)return Promise.all(i).then(()=>n);return n}});function A_(e,t,n,r,o,i,s){if(e.issues.length)if(Zo.has(typeof r))n.issues.push(...We(r,e.issues));else n.issues.push({code:"invalid_key",origin:"map",input:o,inst:i,issues:e.issues.map((a)=>Pe(a,s,se()))});if(t.issues.length)if(Zo.has(typeof r))n.issues.push(...We(r,t.issues));else n.issues.push({origin:"map",code:"invalid_element",input:o,inst:i,key:r,issues:t.issues.map((a)=>Pe(a,s,se()))});n.value.set(e.value,t.value)}var vf=g("$ZodSet",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;if(!(o instanceof Set))return n.issues.push({input:o,inst:e,expected:"set",code:"invalid_type"}),n;let i=[];n.value=new Set;for(let s of o){let a=t.valueType._zod.run({value:s,issues:[]},r);if(a instanceof Promise)i.push(a.then((c)=>T_(c,n)));else T_(a,n)}if(i.length)return Promise.all(i).then(()=>n);return n}});function T_(e,t){if(e.issues.length)t.issues.push(...e.issues);t.value.add(e.value)}var Sf=g("$ZodEnum",(e,t)=>{D.init(e,t);let n=Fo(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter((o)=>Zo.has(typeof o)).map((o)=>typeof o==="string"?Ke(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{let s=o.value;if(r.has(s))return o;return o.issues.push({code:"invalid_value",values:n,input:s,inst:e}),o}}),_f=g("$ZodLiteral",(e,t)=>{if(D.init(e,t),t.values.length===0)throw Error("Cannot create literal schema with no valid values");let n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map((r)=>typeof r==="string"?Ke(r):r?Ke(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{let i=r.value;if(n.has(i))return r;return r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),xf=g("$ZodFile",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;if(o instanceof File)return n;return n.issues.push({expected:"file",code:"invalid_type",input:o,inst:e}),n}}),Cf=g("$ZodTransform",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Nn(e.constructor.name);let o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then((s)=>(n.value=s,n));if(o instanceof Promise)throw new _t;return n.value=o,n}});function I_(e,t){if(e.issues.length&&t===void 0)return{issues:[],value:void 0};return e}var Ba=g("$ZodOptional",(e,t)=>{D.init(e,t),e._zod.optin="optional",e._zod.optout="optional",F(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),F(e._zod,"pattern",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${Go(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){let o=t.innerType._zod.run(n,r);if(o instanceof Promise)return o.then((i)=>I_(i,n.value));return I_(o,n.value)}if(n.value===void 0)return n;return t.innerType._zod.run(n,r)}}),wf=g("$ZodExactOptional",(e,t)=>{Ba.init(e,t),F(e._zod,"values",()=>t.innerType._zod.values),F(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Ef=g("$ZodNullable",(e,t)=>{D.init(e,t),F(e._zod,"optin",()=>t.innerType._zod.optin),F(e._zod,"optout",()=>t.innerType._zod.optout),F(e._zod,"pattern",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${Go(n.source)}|null)$`):void 0}),F(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>{if(n.value===null)return n;return t.innerType._zod.run(n,r)}}),Rf=g("$ZodDefault",(e,t)=>{D.init(e,t),e._zod.optin="optional",F(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;let o=t.innerType._zod.run(n,r);if(o instanceof Promise)return o.then((i)=>O_(i,t));return O_(o,t)}});function O_(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Pf=g("$ZodPrefault",(e,t)=>{D.init(e,t),e._zod.optin="optional",F(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,r)}}),kf=g("$ZodNonOptional",(e,t)=>{D.init(e,t),F(e._zod,"values",()=>{let n=t.innerType._zod.values;return n?new Set([...n].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{let o=t.innerType._zod.run(n,r);if(o instanceof Promise)return o.then((i)=>z_(i,e));return z_(o,e)}});function z_(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}var Af=g("$ZodSuccess",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Nn("ZodSuccess");let o=t.innerType._zod.run(n,r);if(o instanceof Promise)return o.then((i)=>(n.value=i.issues.length===0,n));return n.value=o.issues.length===0,n}}),Tf=g("$ZodCatch",(e,t)=>{D.init(e,t),F(e._zod,"optin",()=>t.innerType._zod.optin),F(e._zod,"optout",()=>t.innerType._zod.optout),F(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);let o=t.innerType._zod.run(n,r);if(o instanceof Promise)return o.then((i)=>{if(n.value=i.value,i.issues.length)n.value=t.catchValue({...n,error:{issues:i.issues.map((s)=>Pe(s,r,se()))},input:n.value}),n.issues=[];return n});if(n.value=o.value,o.issues.length)n.value=t.catchValue({...n,error:{issues:o.issues.map((i)=>Pe(i,r,se()))},input:n.value}),n.issues=[];return n}}),If=g("$ZodNaN",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{if(typeof n.value!=="number"||!Number.isNaN(n.value))return n.issues.push({input:n.value,inst:e,expected:"nan",code:"invalid_type"}),n;return n}}),Of=g("$ZodPipe",(e,t)=>{D.init(e,t),F(e._zod,"values",()=>t.in._zod.values),F(e._zod,"optin",()=>t.in._zod.optin),F(e._zod,"optout",()=>t.out._zod.optout),F(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){let i=t.out._zod.run(n,r);if(i instanceof Promise)return i.then((s)=>$a(s,t.in,r));return $a(i,t.in,r)}let o=t.in._zod.run(n,r);if(o instanceof Promise)return o.then((i)=>$a(i,t.out,r));return $a(o,t.out,r)}});function $a(e,t,n){if(e.issues.length)return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var Jo=g("$ZodCodec",(e,t)=>{D.init(e,t),F(e._zod,"values",()=>t.in._zod.values),F(e._zod,"optin",()=>t.in._zod.optin),F(e._zod,"optout",()=>t.out._zod.optout),F(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if((r.direction||"forward")==="forward"){let i=t.in._zod.run(n,r);if(i instanceof Promise)return i.then((s)=>La(s,t,r));return La(i,t,r)}else{let i=t.out._zod.run(n,r);if(i instanceof Promise)return i.then((s)=>La(s,t,r));return La(i,t,r)}}});function La(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||"forward")==="forward"){let o=t.transform(e.value,e);if(o instanceof Promise)return o.then((i)=>Ma(e,i,t.out,n));return Ma(e,o,t.out,n)}else{let o=t.reverseTransform(e.value,e);if(o instanceof Promise)return o.then((i)=>Ma(e,i,t.in,n));return Ma(e,o,t.in,n)}}function Ma(e,t,n,r){if(e.issues.length)return e.aborted=!0,e;return n._zod.run({value:t,issues:e.issues},r)}var zf=g("$ZodReadonly",(e,t)=>{D.init(e,t),F(e._zod,"propValues",()=>t.innerType._zod.propValues),F(e._zod,"values",()=>t.innerType._zod.values),F(e._zod,"optin",()=>t.innerType?._zod?.optin),F(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);let o=t.innerType._zod.run(n,r);if(o instanceof Promise)return o.then(N_);return N_(o)}});function N_(e){return e.value=Object.freeze(e.value),e}var Nf=g("$ZodTemplateLiteral",(e,t)=>{D.init(e,t);let n=[];for(let r of t.parts)if(typeof r==="object"&&r!==null){if(!r._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...r._zod.traits].shift()}`);let o=r._zod.pattern instanceof RegExp?r._zod.pattern.source:r._zod.pattern;if(!o)throw Error(`Invalid template literal part: ${r._zod.traits}`);let i=o.startsWith("^")?1:0,s=o.endsWith("$")?o.length-1:o.length;n.push(o.slice(i,s))}else if(r===null||kd.has(typeof r))n.push(Ke(`${r}`));else throw Error(`Invalid template literal part: ${r}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(r,o)=>{if(typeof r.value!=="string")return r.issues.push({input:r.value,inst:e,expected:"string",code:"invalid_type"}),r;if(e._zod.pattern.lastIndex=0,!e._zod.pattern.test(r.value))return r.issues.push({input:r.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),r;return r}}),Df=g("$ZodFunction",(e,t)=>(D.init(e,t),e._def=t,e._zod.def=t,e.implement=(n)=>{if(typeof n!=="function")throw Error("implement() must be called with a function");return function(...r){let o=e._def.input?_a(e._def.input,r):r,i=Reflect.apply(n,this,o);if(e._def.output)return _a(e._def.output,i);return i}},e.implementAsync=(n)=>{if(typeof n!=="function")throw Error("implementAsync() must be called with a function");return async function(...r){let o=e._def.input?await xa(e._def.input,r):r,i=await Reflect.apply(n,this,o);if(e._def.output)return await xa(e._def.output,i);return i}},e._zod.parse=(n,r)=>{if(typeof n.value!=="function")return n.issues.push({code:"invalid_type",expected:"function",input:n.value,inst:e}),n;if(e._def.output&&e._def.output._zod.def.type==="promise")n.value=e.implementAsync(n.value);else n.value=e.implement(n.value);return n},e.input=(...n)=>{let r=e.constructor;if(Array.isArray(n[0]))return new r({type:"function",input:new Za({type:"tuple",items:n[0],rest:n[1]}),output:e._def.output});return new r({type:"function",input:n[0],output:e._def.output})},e.output=(n)=>new e.constructor({type:"function",input:e._def.input,output:n}),e)),$f=g("$ZodPromise",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>Promise.resolve(n.value).then((o)=>t.innerType._zod.run({value:o,issues:[]},r))}),Lf=g("$ZodLazy",(e,t)=>{D.init(e,t),F(e._zod,"innerType",()=>t.getter()),F(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),F(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),F(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),F(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),Mf=g("$ZodCustom",(e,t)=>{J.init(e,t),D.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=(n)=>{let r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then((i)=>D_(i,n,r,e));D_(o,n,r,e);return}});function D_(e,t,n,r){if(!e){let o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};if(r._zod.def.params)o.params=r._zod.def.params;t.issues.push(br(o))}}var Xo={};var G_,Ua=Symbol("ZodOutput"),ja=Symbol("ZodInput");class Wf{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==="object"&&"id"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Qo(){return new Wf}(G_=globalThis).__zod_globalRegistry??(G_.__zod_globalRegistry=Qo());var Ae=globalThis.__zod_globalRegistry;function Ff(e,t){return new e({type:"string",..._(t)})}function Gf(e,t){return new e({type:"string",coerce:!0,..._(t)})}function Ha(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,..._(t)})}function ei(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,..._(t)})}function Va(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,..._(t)})}function qa(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",..._(t)})}function Ka(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",..._(t)})}function Ya(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",..._(t)})}function ti(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,..._(t)})}function Ja(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,..._(t)})}function Xa(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,..._(t)})}function Qa(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,..._(t)})}function ec(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,..._(t)})}function tc(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,..._(t)})}function nc(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,..._(t)})}function rc(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,..._(t)})}function oc(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,..._(t)})}function ic(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,..._(t)})}function Zf(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,..._(t)})}function sc(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,..._(t)})}function ac(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,..._(t)})}function cc(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,..._(t)})}function lc(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,..._(t)})}function uc(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,..._(t)})}function dc(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,..._(t)})}var mc={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Bf(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,..._(t)})}function Uf(e,t){return new e({type:"string",format:"date",check:"string_format",..._(t)})}function jf(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,..._(t)})}function Hf(e,t){return new e({type:"string",format:"duration",check:"string_format",..._(t)})}function Vf(e,t){return new e({type:"number",checks:[],..._(t)})}function qf(e,t){return new e({type:"number",coerce:!0,checks:[],..._(t)})}function Kf(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",..._(t)})}function Yf(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",..._(t)})}function Jf(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",..._(t)})}function Xf(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",..._(t)})}function Qf(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",..._(t)})}function ep(e,t){return new e({type:"boolean",..._(t)})}function tp(e,t){return new e({type:"boolean",coerce:!0,..._(t)})}function np(e,t){return new e({type:"bigint",..._(t)})}function rp(e,t){return new e({type:"bigint",coerce:!0,..._(t)})}function op(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",..._(t)})}function ip(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",..._(t)})}function sp(e,t){return new e({type:"symbol",..._(t)})}function ap(e,t){return new e({type:"undefined",..._(t)})}function cp(e,t){return new e({type:"null",..._(t)})}function lp(e){return new e({type:"any"})}function up(e){return new e({type:"unknown"})}function dp(e,t){return new e({type:"never",..._(t)})}function mp(e,t){return new e({type:"void",..._(t)})}function fp(e,t){return new e({type:"date",..._(t)})}function pp(e,t){return new e({type:"date",coerce:!0,..._(t)})}function gp(e,t){return new e({type:"nan",..._(t)})}function xt(e,t){return new Oa({check:"less_than",..._(t),value:e,inclusive:!1})}function Ge(e,t){return new Oa({check:"less_than",..._(t),value:e,inclusive:!0})}function Ct(e,t){return new za({check:"greater_than",..._(t),value:e,inclusive:!1})}function _e(e,t){return new za({check:"greater_than",..._(t),value:e,inclusive:!0})}function fc(e){return Ct(0,e)}function pc(e){return xt(0,e)}function gc(e){return Ge(0,e)}function hc(e){return _e(0,e)}function cn(e,t){return new lm({check:"multiple_of",..._(t),value:e})}function ln(e,t){return new mm({check:"max_size",..._(t),maximum:e})}function wt(e,t){return new fm({check:"min_size",..._(t),minimum:e})}function Mn(e,t){return new pm({check:"size_equals",..._(t),size:e})}function Wn(e,t){return new gm({check:"max_length",..._(t),maximum:e})}function Ft(e,t){return new hm({check:"min_length",..._(t),minimum:e})}function Fn(e,t){return new ym({check:"length_equals",..._(t),length:e})}function Rr(e,t){return new bm({check:"string_format",format:"regex",..._(t),pattern:e})}function Pr(e){return new vm({check:"string_format",format:"lowercase",..._(e)})}function kr(e){return new Sm({check:"string_format",format:"uppercase",..._(e)})}function Ar(e,t){return new _m({check:"string_format",format:"includes",..._(t),includes:e})}function Tr(e,t){return new xm({check:"string_format",format:"starts_with",..._(t),prefix:e})}function Ir(e,t){return new Cm({check:"string_format",format:"ends_with",..._(t),suffix:e})}function yc(e,t,n){return new wm({check:"property",property:e,schema:t,..._(n)})}function Or(e,t){return new Em({check:"mime_type",mime:e,..._(t)})}function st(e){return new Rm({check:"overwrite",tx:e})}function zr(e){return st((t)=>t.normalize(e))}function Nr(){return st((e)=>e.trim())}function Dr(){return st((e)=>e.toLowerCase())}function $r(){return st((e)=>e.toUpperCase())}function Lr(){return st((e)=>Ed(e))}function hp(e,t,n){return new e({type:"array",element:t,..._(n)})}function bD(e,t,n){return new e({type:"union",options:t,..._(n)})}function vD(e,t,n){return new e({type:"union",options:t,inclusive:!1,..._(n)})}function SD(e,t,n,r){return new e({type:"union",options:n,discriminator:t,..._(r)})}function _D(e,t,n){return new e({type:"intersection",left:t,right:n})}function xD(e,t,n,r){let o=n instanceof D;return new e({type:"tuple",items:t,rest:o?n:null,..._(o?r:n)})}function CD(e,t,n,r){return new e({type:"record",keyType:t,valueType:n,..._(r)})}function wD(e,t,n,r){return new e({type:"map",keyType:t,valueType:n,..._(r)})}function ED(e,t,n){return new e({type:"set",valueType:t,..._(n)})}function RD(e,t,n){let r=Array.isArray(t)?Object.fromEntries(t.map((o)=>[o,o])):t;return new e({type:"enum",entries:r,..._(n)})}function PD(e,t,n){return new e({type:"enum",entries:t,..._(n)})}function kD(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],..._(n)})}function yp(e,t){return new e({type:"file",..._(t)})}function AD(e,t){return new e({type:"transform",transform:t})}function TD(e,t){return new e({type:"optional",innerType:t})}function ID(e,t){return new e({type:"nullable",innerType:t})}function OD(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n==="function"?n():Pd(n)}})}function zD(e,t,n){return new e({type:"nonoptional",innerType:t,..._(n)})}function ND(e,t){return new e({type:"success",innerType:t})}function DD(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n==="function"?n:()=>n})}function $D(e,t,n){return new e({type:"pipe",in:t,out:n})}function LD(e,t){return new e({type:"readonly",innerType:t})}function MD(e,t,n){return new e({type:"template_literal",parts:t,..._(n)})}function WD(e,t){return new e({type:"lazy",getter:t})}function FD(e,t){return new e({type:"promise",innerType:t})}function bp(e,t,n){let r=_(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function vp(e,t,n){return new e({type:"custom",check:"custom",fn:t,..._(n)})}function Sp(e){let t=Z_((n)=>(n.addIssue=(r)=>{if(typeof r==="string")n.issues.push(br(r,n.value,t._zod.def));else{let o=r;if(o.fatal)o.continue=!1;o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(br(o))}},e(n.value,n)));return t}function Z_(e,t){let n=new J({check:"custom",..._(t)});return n._zod.check=e,n}function _p(e){let t=new J({check:"describe"});return t._zod.onattach=[(n)=>{let r=Ae.get(n)??{};Ae.add(n,{...r,description:e})}],t._zod.check=()=>{},t}function xp(e){let t=new J({check:"meta"});return t._zod.onattach=[(n)=>{let r=Ae.get(n)??{};Ae.add(n,{...r,...e})}],t._zod.check=()=>{},t}function Cp(e,t){let n=_(t),r=n.truthy??["true","1","yes","on","y","enabled"],o=n.falsy??["false","0","no","off","n","disabled"];if(n.case!=="sensitive")r=r.map((m)=>typeof m==="string"?m.toLowerCase():m),o=o.map((m)=>typeof m==="string"?m.toLowerCase():m);let i=new Set(r),s=new Set(o),a=e.Codec??Jo,c=e.Boolean??Ko,u=new(e.String??Ln)({type:"string",error:n.error}),d=new c({type:"boolean",error:n.error}),f=new a({type:"pipe",in:u,out:d,transform:(m,p)=>{let h=m;if(n.case!=="sensitive")h=h.toLowerCase();if(i.has(h))return!0;else if(s.has(h))return!1;else return p.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...s],input:p.value,inst:f,continue:!1}),{}},reverseTransform:(m,p)=>{if(m===!0)return r[0]||"true";else return o[0]||"false"},error:n.error});return f}function Mr(e,t,n,r={}){let o=_(r),i={..._(r),check:"string_format",type:"string",format:t,fn:typeof n==="function"?n:(a)=>n.test(a),...o};if(n instanceof RegExp)i.pattern=n;return new e(i)}var Wr=()=>{throw Error("JSON Schema conversion is not bundled into this plugin artifact")},wp=()=>Wr,bc=()=>Wr,Fr=Wr,X=Wr,Gr=Wr,Zr=Wr;var GD={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ep=(e,t,n,r)=>{let o=n;o.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof i==="number")o.minLength=i;if(typeof s==="number")o.maxLength=s;if(a){if(o.format=GD[a]??a,o.format==="")delete o.format;if(a==="time")delete o.format}if(l)o.contentEncoding=l;if(c&&c.size>0){let u=[...c];if(u.length===1)o.pattern=u[0].source;else if(u.length>1)o.allOf=[...u.map((d)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))]}},Rp=(e,t,n,r)=>{let o=n,{minimum:i,maximum:s,format:a,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;if(typeof a==="string"&&a.includes("int"))o.type="integer";else o.type="number";if(typeof u==="number")if(t.target==="draft-04"||t.target==="openapi-3.0")o.minimum=u,o.exclusiveMinimum=!0;else o.exclusiveMinimum=u;if(typeof i==="number"){if(o.minimum=i,typeof u==="number"&&t.target!=="draft-04")if(u>=i)delete o.minimum;else delete o.exclusiveMinimum}if(typeof l==="number")if(t.target==="draft-04"||t.target==="openapi-3.0")o.maximum=l,o.exclusiveMaximum=!0;else o.exclusiveMaximum=l;if(typeof s==="number"){if(o.maximum=s,typeof l==="number"&&t.target!=="draft-04")if(l<=s)delete o.maximum;else delete o.exclusiveMaximum}if(typeof c==="number")o.multipleOf=c},Pp=(e,t,n,r)=>{n.type="boolean"},kp=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},Ap=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},Tp=(e,t,n,r)=>{if(t.target==="openapi-3.0")n.type="string",n.nullable=!0,n.enum=[null];else n.type="null"},Ip=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},Op=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},zp=(e,t,n,r)=>{n.not={}},Np=(e,t,n,r)=>{},Dp=(e,t,n,r)=>{},$p=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},Lp=(e,t,n,r)=>{let o=e._zod.def,i=Fo(o.entries);if(i.every((s)=>typeof s==="number"))n.type="number";if(i.every((s)=>typeof s==="string"))n.type="string";n.enum=i},Mp=(e,t,n,r)=>{let o=e._zod.def,i=[];for(let s of o.values)if(s===void 0){if(t.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s==="bigint")if(t.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else i.push(Number(s));else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[s];else n.const=s}else{if(i.every((s)=>typeof s==="number"))n.type="number";if(i.every((s)=>typeof s==="string"))n.type="string";if(i.every((s)=>typeof s==="boolean"))n.type="boolean";if(i.every((s)=>s===null))n.type="null";n.enum=i}},Wp=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},Fp=(e,t,n,r)=>{let o=n,i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");o.type="string",o.pattern=i.source},Gp=(e,t,n,r)=>{let o=n,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:a,mime:c}=e._zod.bag;if(s!==void 0)i.minLength=s;if(a!==void 0)i.maxLength=a;if(c)if(c.length===1)i.contentMediaType=c[0],Object.assign(o,i);else Object.assign(o,i),o.anyOf=c.map((l)=>({contentMediaType:l}));else Object.assign(o,i)},Zp=(e,t,n,r)=>{n.type="boolean"},Bp=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},Up=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},jp=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},Hp=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},Vp=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},qp=(e,t,n,r)=>{let o=n,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;if(typeof s==="number")o.minItems=s;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=X(i.element,t,{...r,path:[...r.path,"items"]})},Kp=(e,t,n,r)=>{let o=n,i=e._zod.def;o.type="object",o.properties={};let s=i.shape;for(let l in s)o.properties[l]=X(s[l],t,{...r,path:[...r.path,"properties",l]});let a=new Set(Object.keys(s)),c=new Set([...a].filter((l)=>{let u=i.shape[l]._zod;if(t.io==="input")return u.optin===void 0;else return u.optout===void 0}));if(c.size>0)o.required=Array.from(c);if(i.catchall?._zod.def.type==="never")o.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")o.additionalProperties=!1}else if(i.catchall)o.additionalProperties=X(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})},Sc=(e,t,n,r)=>{let o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>X(a,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));if(i)n.oneOf=s;else n.anyOf=s},Yp=(e,t,n,r)=>{let o=e._zod.def,i=X(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=X(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=(l)=>("allOf"in l)&&Object.keys(l).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];n.allOf=c},Jp=(e,t,n,r)=>{let o=n,i=e._zod.def;o.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((f,m)=>X(f,t,{...r,path:[...r.path,s,m]})),l=i.rest?X(i.rest,t,{...r,path:[...r.path,a,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;if(t.target==="draft-2020-12"){if(o.prefixItems=c,l)o.items=l}else if(t.target==="openapi-3.0"){if(o.items={anyOf:c},l)o.items.anyOf.push(l);if(o.minItems=c.length,!l)o.maxItems=c.length}else if(o.items=c,l)o.additionalItems=l;let{minimum:u,maximum:d}=e._zod.bag;if(typeof u==="number")o.minItems=u;if(typeof d==="number")o.maxItems=d},Xp=(e,t,n,r)=>{let o=n,i=e._zod.def;o.type="object";let s=i.keyType,c=s._zod.bag?.patterns;if(i.mode==="loose"&&c&&c.size>0){let u=X(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(let d of c)o.patternProperties[d.source]=u}else{if(t.target==="draft-07"||t.target==="draft-2020-12")o.propertyNames=X(i.keyType,t,{...r,path:[...r.path,"propertyNames"]});o.additionalProperties=X(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}let l=s._zod.values;if(l){let u=[...l].filter((d)=>typeof d==="string"||typeof d==="number");if(u.length>0)o.required=u}},Qp=(e,t,n,r)=>{let o=e._zod.def,i=X(o.innerType,t,r),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=o.innerType,n.nullable=!0;else n.anyOf=[i,{type:"null"}]},eg=(e,t,n,r)=>{let o=e._zod.def;X(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType},tg=(e,t,n,r)=>{let o=e._zod.def;X(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},ng=(e,t,n,r)=>{let o=e._zod.def;X(o.innerType,t,r);let i=t.seen.get(e);if(i.ref=o.innerType,t.io==="input")n._prefault=JSON.parse(JSON.stringify(o.defaultValue))},rg=(e,t,n,r)=>{let o=e._zod.def;X(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}n.default=s},og=(e,t,n,r)=>{let o=e._zod.def,i=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;X(i,t,r);let s=t.seen.get(e);s.ref=i},ig=(e,t,n,r)=>{let o=e._zod.def;X(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},sg=(e,t,n,r)=>{let o=e._zod.def;X(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType},_c=(e,t,n,r)=>{let o=e._zod.def;X(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType},ag=(e,t,n,r)=>{let o=e._zod.innerType;X(o,t,r);let i=t.seen.get(e);i.ref=o},vc={string:Ep,number:Rp,boolean:Pp,bigint:kp,symbol:Ap,null:Tp,undefined:Ip,void:Op,never:zp,any:Np,unknown:Dp,date:$p,enum:Lp,literal:Mp,nan:Wp,template_literal:Fp,file:Gp,success:Zp,custom:Bp,function:Up,transform:jp,map:Hp,set:Vp,array:qp,object:Kp,union:Sc,intersection:Yp,tuple:Jp,record:Xp,nullable:Qp,nonoptional:eg,default:tg,prefault:ng,catch:rg,pipe:og,readonly:ig,promise:sg,optional:_c,lazy:ag};function ni(e,t){if("_idmap"in e){let r=e,o=Fr({...t,processors:vc}),i={};for(let c of r._idmap.entries()){let[l,u]=c;X(u,o)}let s={},a={registry:r,uri:t?.uri,defs:i};o.external=a;for(let c of r._idmap.entries()){let[l,u]=c;Gr(o,u),s[l]=Zr(o,u)}if(Object.keys(i).length>0){let c=o.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:i}}return{schemas:s}}let n=Fr({...t,processors:vc});return X(e,n),Gr(n,e),Zr(n,e)}class cg{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(e){this.ctx.counter=e}get seen(){return this.ctx.seen}constructor(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";this.ctx=Fr({processors:vc,target:t,...e?.metadata&&{metadata:e.metadata},...e?.unrepresentable&&{unrepresentable:e.unrepresentable},...e?.override&&{override:e.override},...e?.io&&{io:e.io}})}process(e,t={path:[],schemaPath:[]}){return X(e,this.ctx,t)}emit(e,t){if(t){if(t.cycles)this.ctx.cycles=t.cycles;if(t.reused)this.ctx.reused=t.reused;if(t.external)this.ctx.external=t.external}Gr(this.ctx,e);let n=Zr(this.ctx,e),{"~standard":r,...o}=n;return o}}var B_={};var ai={};dn(ai,{ZodISODate:()=>oi,ZodISODateTime:()=>ri,ZodISODuration:()=>si,ZodISOTime:()=>ii,date:()=>ug,datetime:()=>lg,duration:()=>mg,time:()=>dg});var ri=g("ZodISODateTime",(e,t)=>{Fm.init(e,t),K.init(e,t)});function lg(e){return Bf(ri,e)}var oi=g("ZodISODate",(e,t)=>{Gm.init(e,t),K.init(e,t)});function ug(e){return Uf(oi,e)}var ii=g("ZodISOTime",(e,t)=>{Zm.init(e,t),K.init(e,t)});function dg(e){return jf(ii,e)}var si=g("ZodISODuration",(e,t)=>{Bm.init(e,t),K.init(e,t)});function mg(e){return Hf(si,e)}var j_=(e,t)=>{jo.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:(n)=>Sr(e,n)},flatten:{value:(n)=>vr(e,n)},addIssue:{value:(n)=>{e.issues.push(n),e.message=JSON.stringify(e.issues,hr,2)}},addIssues:{value:(n)=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,hr,2)}},isEmpty:{get(){return e.issues.length===0}}})},H_=g("ZodError",j_),xe=g("ZodError",j_,{Parent:Error});var xc=_r(xe),Cc=xr(xe),wc=Cr(xe),Ec=wr(xe),Rc=Ca(xe),Pc=wa(xe),kc=Ea(xe),Ac=Ra(xe),Tc=Pa(xe),Ic=ka(xe),Oc=Aa(xe),zc=Ta(xe);var M=g("ZodType",(e,t)=>(D.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:bc(e,"input"),output:bc(e,"output")}}),e.toJSONSchema=wp(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(I.mergeDefs(t,{checks:[...t.checks??[],...n.map((r)=>typeof r==="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),e.with=e.check,e.clone=(n,r)=>ye(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e),e.parse=(n,r)=>xc(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>wc(e,n,r),e.parseAsync=async(n,r)=>Cc(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Ec(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>Rc(e,n,r),e.decode=(n,r)=>Pc(e,n,r),e.encodeAsync=async(n,r)=>kc(e,n,r),e.decodeAsync=async(n,r)=>Ac(e,n,r),e.safeEncode=(n,r)=>Tc(e,n,r),e.safeDecode=(n,r)=>Ic(e,n,r),e.safeEncodeAsync=async(n,r)=>Oc(e,n,r),e.safeDecodeAsync=async(n,r)=>zc(e,n,r),e.refine=(n,r)=>e.check(nh(n,r)),e.superRefine=(n)=>e.check(rh(n)),e.overwrite=(n)=>e.check(st(n)),e.optional=()=>li(e),e.exactOptional=()=>Mg(e),e.nullable=()=>ui(e),e.nullish=()=>li(ui(e)),e.nonoptional=(n)=>Ug(e,n),e.array=()=>pi(e),e.or=(n)=>tl([e,n]),e.and=(n)=>kg(e,n),e.transform=(n)=>di(e,rl(n)),e.default=(n)=>Gg(e,n),e.prefault=(n)=>Bg(e,n),e.catch=(n)=>Vg(e,n),e.pipe=(n)=>di(e,n),e.readonly=()=>Yg(e),e.describe=(n)=>{let r=e.clone();return Ae.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return Ae.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Ae.get(e);let r=e.clone();return Ae.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=(n)=>n(e),e)),$c=g("_ZodString",(e,t)=>{Ln.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,i)=>Ep(e,r,o,i);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(Rr(...r)),e.includes=(...r)=>e.check(Ar(...r)),e.startsWith=(...r)=>e.check(Tr(...r)),e.endsWith=(...r)=>e.check(Ir(...r)),e.min=(...r)=>e.check(Ft(...r)),e.max=(...r)=>e.check(Wn(...r)),e.length=(...r)=>e.check(Fn(...r)),e.nonempty=(...r)=>e.check(Ft(1,...r)),e.lowercase=(r)=>e.check(Pr(r)),e.uppercase=(r)=>e.check(kr(r)),e.trim=()=>e.check(Nr()),e.normalize=(...r)=>e.check(zr(...r)),e.toLowerCase=()=>e.check(Dr()),e.toUpperCase=()=>e.check($r()),e.slugify=()=>e.check(Lr())}),Ur=g("ZodString",(e,t)=>{Ln.init(e,t),$c.init(e,t),e.email=(n)=>e.check(Ha(Lc,n)),e.url=(n)=>e.check(ti(mi,n)),e.jwt=(n)=>e.check(dc(Xc,n)),e.emoji=(n)=>e.check(Ja(Mc,n)),e.guid=(n)=>e.check(ei(ci,n)),e.uuid=(n)=>e.check(Va(Rt,n)),e.uuidv4=(n)=>e.check(qa(Rt,n)),e.uuidv6=(n)=>e.check(Ka(Rt,n)),e.uuidv7=(n)=>e.check(Ya(Rt,n)),e.nanoid=(n)=>e.check(Xa(Wc,n)),e.guid=(n)=>e.check(ei(ci,n)),e.cuid=(n)=>e.check(Qa(Fc,n)),e.cuid2=(n)=>e.check(ec(Gc,n)),e.ulid=(n)=>e.check(tc(Zc,n)),e.base64=(n)=>e.check(cc(Kc,n)),e.base64url=(n)=>e.check(lc(Yc,n)),e.xid=(n)=>e.check(nc(Bc,n)),e.ksuid=(n)=>e.check(rc(Uc,n)),e.ipv4=(n)=>e.check(oc(jc,n)),e.ipv6=(n)=>e.check(ic(Hc,n)),e.cidrv4=(n)=>e.check(sc(Vc,n)),e.cidrv6=(n)=>e.check(ac(qc,n)),e.e164=(n)=>e.check(uc(Jc,n)),e.datetime=(n)=>e.check(lg(n)),e.date=(n)=>e.check(ug(n)),e.time=(n)=>e.check(dg(n)),e.duration=(n)=>e.check(mg(n))});function Nc(e){return Ff(Ur,e)}var K=g("ZodStringFormat",(e,t)=>{q.init(e,t),$c.init(e,t)}),Lc=g("ZodEmail",(e,t)=>{Im.init(e,t),K.init(e,t)});function V_(e){return Ha(Lc,e)}var ci=g("ZodGUID",(e,t)=>{Am.init(e,t),K.init(e,t)});function q_(e){return ei(ci,e)}var Rt=g("ZodUUID",(e,t)=>{Tm.init(e,t),K.init(e,t)});function K_(e){return Va(Rt,e)}function Y_(e){return qa(Rt,e)}function J_(e){return Ka(Rt,e)}function X_(e){return Ya(Rt,e)}var mi=g("ZodURL",(e,t)=>{Om.init(e,t),K.init(e,t)});function Q_(e){return ti(mi,e)}function ex(e){return ti(mi,{protocol:/^https?$/,hostname:Fe.domain,...I.normalizeParams(e)})}var Mc=g("ZodEmoji",(e,t)=>{zm.init(e,t),K.init(e,t)});function tx(e){return Ja(Mc,e)}var Wc=g("ZodNanoID",(e,t)=>{Nm.init(e,t),K.init(e,t)});function nx(e){return Xa(Wc,e)}var Fc=g("ZodCUID",(e,t)=>{Dm.init(e,t),K.init(e,t)});function rx(e){return Qa(Fc,e)}var Gc=g("ZodCUID2",(e,t)=>{$m.init(e,t),K.init(e,t)});function ox(e){return ec(Gc,e)}var Zc=g("ZodULID",(e,t)=>{Lm.init(e,t),K.init(e,t)});function ix(e){return tc(Zc,e)}var Bc=g("ZodXID",(e,t)=>{Mm.init(e,t),K.init(e,t)});function sx(e){return nc(Bc,e)}var Uc=g("ZodKSUID",(e,t)=>{Wm.init(e,t),K.init(e,t)});function ax(e){return rc(Uc,e)}var jc=g("ZodIPv4",(e,t)=>{Um.init(e,t),K.init(e,t)});function cx(e){return oc(jc,e)}var fg=g("ZodMAC",(e,t)=>{Hm.init(e,t),K.init(e,t)});function lx(e){return Zf(fg,e)}var Hc=g("ZodIPv6",(e,t)=>{jm.init(e,t),K.init(e,t)});function ux(e){return ic(Hc,e)}var Vc=g("ZodCIDRv4",(e,t)=>{Vm.init(e,t),K.init(e,t)});function dx(e){return sc(Vc,e)}var qc=g("ZodCIDRv6",(e,t)=>{qm.init(e,t),K.init(e,t)});function mx(e){return ac(qc,e)}var Kc=g("ZodBase64",(e,t)=>{Ym.init(e,t),K.init(e,t)});function fx(e){return cc(Kc,e)}var Yc=g("ZodBase64URL",(e,t)=>{Jm.init(e,t),K.init(e,t)});function px(e){return lc(Yc,e)}var Jc=g("ZodE164",(e,t)=>{Xm.init(e,t),K.init(e,t)});function gx(e){return uc(Jc,e)}var Xc=g("ZodJWT",(e,t)=>{Qm.init(e,t),K.init(e,t)});function hx(e){return dc(Xc,e)}var jr=g("ZodCustomStringFormat",(e,t)=>{ef.init(e,t),K.init(e,t)});function yx(e,t,n={}){return Mr(jr,e,t,n)}function bx(e){return Mr(jr,"hostname",Fe.hostname,e)}function vx(e){return Mr(jr,"hex",Fe.hex,e)}function Sx(e,t){let n=t?.enc??"hex",r=`${e}_${n}`,o=Fe[r];if(!o)throw Error(`Unrecognized hash format: ${r}`);return Mr(jr,r,o,t)}var Hr=g("ZodNumber",(e,t)=>{Fa.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,i)=>Rp(e,r,o,i),e.gt=(r,o)=>e.check(Ct(r,o)),e.gte=(r,o)=>e.check(_e(r,o)),e.min=(r,o)=>e.check(_e(r,o)),e.lt=(r,o)=>e.check(xt(r,o)),e.lte=(r,o)=>e.check(Ge(r,o)),e.max=(r,o)=>e.check(Ge(r,o)),e.int=(r)=>e.check(Dc(r)),e.safe=(r)=>e.check(Dc(r)),e.positive=(r)=>e.check(Ct(0,r)),e.nonnegative=(r)=>e.check(_e(0,r)),e.negative=(r)=>e.check(xt(0,r)),e.nonpositive=(r)=>e.check(Ge(0,r)),e.multipleOf=(r,o)=>e.check(cn(r,o)),e.step=(r,o)=>e.check(cn(r,o)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??0.5),e.isFinite=!0,e.format=n.format??null});function pg(e){return Vf(Hr,e)}var Zn=g("ZodNumberFormat",(e,t)=>{tf.init(e,t),Hr.init(e,t)});function Dc(e){return Kf(Zn,e)}function _x(e){return Yf(Zn,e)}function xx(e){return Jf(Zn,e)}function Cx(e){return Xf(Zn,e)}function wx(e){return Qf(Zn,e)}var Vr=g("ZodBoolean",(e,t)=>{Ko.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Pp(e,n,r,o)});function gg(e){return ep(Vr,e)}var qr=g("ZodBigInt",(e,t)=>{Ga.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,i)=>kp(e,r,o,i),e.gte=(r,o)=>e.check(_e(r,o)),e.min=(r,o)=>e.check(_e(r,o)),e.gt=(r,o)=>e.check(Ct(r,o)),e.gte=(r,o)=>e.check(_e(r,o)),e.min=(r,o)=>e.check(_e(r,o)),e.lt=(r,o)=>e.check(xt(r,o)),e.lte=(r,o)=>e.check(Ge(r,o)),e.max=(r,o)=>e.check(Ge(r,o)),e.positive=(r)=>e.check(Ct(BigInt(0),r)),e.negative=(r)=>e.check(xt(BigInt(0),r)),e.nonpositive=(r)=>e.check(Ge(BigInt(0),r)),e.nonnegative=(r)=>e.check(_e(BigInt(0),r)),e.multipleOf=(r,o)=>e.check(cn(r,o));let n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null});function Ex(e){return np(qr,e)}var Qc=g("ZodBigIntFormat",(e,t)=>{nf.init(e,t),qr.init(e,t)});function Rx(e){return op(Qc,e)}function Px(e){return ip(Qc,e)}var hg=g("ZodSymbol",(e,t)=>{rf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ap(e,n,r,o)});function kx(e){return sp(hg,e)}var yg=g("ZodUndefined",(e,t)=>{of.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ip(e,n,r,o)});function Ax(e){return ap(yg,e)}var bg=g("ZodNull",(e,t)=>{sf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Tp(e,n,r,o)});function vg(e){return cp(bg,e)}var Sg=g("ZodAny",(e,t)=>{af.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Np(e,n,r,o)});function Tx(){return lp(Sg)}var _g=g("ZodUnknown",(e,t)=>{cf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Dp(e,n,r,o)});function Gn(){return up(_g)}var xg=g("ZodNever",(e,t)=>{lf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>zp(e,n,r,o)});function el(e){return dp(xg,e)}var Cg=g("ZodVoid",(e,t)=>{uf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Op(e,n,r,o)});function Ix(e){return mp(Cg,e)}var fi=g("ZodDate",(e,t)=>{df.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,i)=>$p(e,r,o,i),e.min=(r,o)=>e.check(_e(r,o)),e.max=(r,o)=>e.check(Ge(r,o));let n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null});function Ox(e){return fp(fi,e)}var wg=g("ZodArray",(e,t)=>{mf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>qp(e,n,r,o),e.element=t.element,e.min=(n,r)=>e.check(Ft(n,r)),e.nonempty=(n)=>e.check(Ft(1,n)),e.max=(n,r)=>e.check(Wn(n,r)),e.length=(n,r)=>e.check(Fn(n,r)),e.unwrap=()=>e.element});function pi(e,t){return hp(wg,e,t)}function zx(e){let t=e._zod.def.shape;return nl(Object.keys(t))}var gi=g("ZodObject",(e,t)=>{ff.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Kp(e,n,r,o),I.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>nl(Object.keys(e._zod.def.shape)),e.catchall=(n)=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Gn()}),e.loose=()=>e.clone({...e._zod.def,catchall:Gn()}),e.strict=()=>e.clone({...e._zod.def,catchall:el()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=(n)=>I.extend(e,n),e.safeExtend=(n)=>I.safeExtend(e,n),e.merge=(n)=>I.merge(e,n),e.pick=(n)=>I.pick(e,n),e.omit=(n)=>I.omit(e,n),e.partial=(...n)=>I.partial(ol,e,n[0]),e.required=(...n)=>I.required(il,e,n[0])});function Nx(e,t){let n={type:"object",shape:e??{},...I.normalizeParams(t)};return new gi(n)}function Dx(e,t){return new gi({type:"object",shape:e,catchall:el(),...I.normalizeParams(t)})}function $x(e,t){return new gi({type:"object",shape:e,catchall:Gn(),...I.normalizeParams(t)})}var hi=g("ZodUnion",(e,t)=>{Yo.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Sc(e,n,r,o),e.options=t.options});function tl(e,t){return new hi({type:"union",options:e,...I.normalizeParams(t)})}var Eg=g("ZodXor",(e,t)=>{hi.init(e,t),pf.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Sc(e,n,r,o),e.options=t.options});function Lx(e,t){return new Eg({type:"union",options:e,inclusive:!1,...I.normalizeParams(t)})}var Rg=g("ZodDiscriminatedUnion",(e,t)=>{hi.init(e,t),gf.init(e,t)});function Mx(e,t,n){return new Rg({type:"union",options:t,discriminator:e,...I.normalizeParams(n)})}var Pg=g("ZodIntersection",(e,t)=>{hf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Yp(e,n,r,o)});function kg(e,t){return new Pg({type:"intersection",left:e,right:t})}var Ag=g("ZodTuple",(e,t)=>{Za.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Jp(e,n,r,o),e.rest=(n)=>e.clone({...e._zod.def,rest:n})});function Tg(e,t,n){let r=t instanceof D,o=r?n:t;return new Ag({type:"tuple",items:e,rest:r?t:null,...I.normalizeParams(o)})}var yi=g("ZodRecord",(e,t)=>{yf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Xp(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function Ig(e,t,n){return new yi({type:"record",keyType:e,valueType:t,...I.normalizeParams(n)})}function Wx(e,t,n){let r=ye(e);return r._zod.values=void 0,new yi({type:"record",keyType:r,valueType:t,...I.normalizeParams(n)})}function Fx(e,t,n){return new yi({type:"record",keyType:e,valueType:t,mode:"loose",...I.normalizeParams(n)})}var Og=g("ZodMap",(e,t)=>{bf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Hp(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...n)=>e.check(wt(...n)),e.nonempty=(n)=>e.check(wt(1,n)),e.max=(...n)=>e.check(ln(...n)),e.size=(...n)=>e.check(Mn(...n))});function Gx(e,t,n){return new Og({type:"map",keyType:e,valueType:t,...I.normalizeParams(n)})}var zg=g("ZodSet",(e,t)=>{vf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Vp(e,n,r,o),e.min=(...n)=>e.check(wt(...n)),e.nonempty=(n)=>e.check(wt(1,n)),e.max=(...n)=>e.check(ln(...n)),e.size=(...n)=>e.check(Mn(...n))});function Zx(e,t){return new zg({type:"set",valueType:e,...I.normalizeParams(t)})}var Br=g("ZodEnum",(e,t)=>{Sf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,i)=>Lp(e,r,o,i),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{let i={};for(let s of r)if(n.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new Br({...t,checks:[],...I.normalizeParams(o),entries:i})},e.exclude=(r,o)=>{let i={...t.entries};for(let s of r)if(n.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new Br({...t,checks:[],...I.normalizeParams(o),entries:i})}});function nl(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new Br({type:"enum",entries:n,...I.normalizeParams(t)})}function Bx(e,t){return new Br({type:"enum",entries:e,...I.normalizeParams(t)})}var Ng=g("ZodLiteral",(e,t)=>{_f.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Mp(e,n,r,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Ux(e,t){return new Ng({type:"literal",values:Array.isArray(e)?e:[e],...I.normalizeParams(t)})}var Dg=g("ZodFile",(e,t)=>{xf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Gp(e,n,r,o),e.min=(n,r)=>e.check(wt(n,r)),e.max=(n,r)=>e.check(ln(n,r)),e.mime=(n,r)=>e.check(Or(Array.isArray(n)?n:[n],r))});function jx(e){return yp(Dg,e)}var $g=g("ZodTransform",(e,t)=>{Cf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>jp(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Nn(e.constructor.name);n.addIssue=(i)=>{if(typeof i==="string")n.issues.push(I.issue(i,n.value,t));else{let s=i;if(s.fatal)s.continue=!1;s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=e),n.issues.push(I.issue(s))}};let o=t.transform(n.value,n);if(o instanceof Promise)return o.then((i)=>(n.value=i,n));return n.value=o,n}});function rl(e){return new $g({type:"transform",transform:e})}var ol=g("ZodOptional",(e,t)=>{Ba.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>_c(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function li(e){return new ol({type:"optional",innerType:e})}var Lg=g("ZodExactOptional",(e,t)=>{wf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>_c(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Mg(e){return new Lg({type:"optional",innerType:e})}var Wg=g("ZodNullable",(e,t)=>{Ef.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Qp(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function ui(e){return new Wg({type:"nullable",innerType:e})}function Hx(e){return li(ui(e))}var Fg=g("ZodDefault",(e,t)=>{Rf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>tg(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Gg(e,t){return new Fg({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():I.shallowClone(t)}})}var Zg=g("ZodPrefault",(e,t)=>{Pf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ng(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Bg(e,t){return new Zg({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():I.shallowClone(t)}})}var il=g("ZodNonOptional",(e,t)=>{kf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>eg(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ug(e,t){return new il({type:"nonoptional",innerType:e,...I.normalizeParams(t)})}var jg=g("ZodSuccess",(e,t)=>{Af.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Zp(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Vx(e){return new jg({type:"success",innerType:e})}var Hg=g("ZodCatch",(e,t)=>{Tf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>rg(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Vg(e,t){return new Hg({type:"catch",innerType:e,catchValue:typeof t==="function"?t:()=>t})}var qg=g("ZodNaN",(e,t)=>{If.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Wp(e,n,r,o)});function qx(e){return gp(qg,e)}var sl=g("ZodPipe",(e,t)=>{Of.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>og(e,n,r,o),e.in=t.in,e.out=t.out});function di(e,t){return new sl({type:"pipe",in:e,out:t})}var al=g("ZodCodec",(e,t)=>{sl.init(e,t),Jo.init(e,t)});function Kx(e,t,n){return new al({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}var Kg=g("ZodReadonly",(e,t)=>{zf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ig(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Yg(e){return new Kg({type:"readonly",innerType:e})}var Jg=g("ZodTemplateLiteral",(e,t)=>{Nf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Fp(e,n,r,o)});function Yx(e,t){return new Jg({type:"template_literal",parts:e,...I.normalizeParams(t)})}var Xg=g("ZodLazy",(e,t)=>{Lf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ag(e,n,r,o),e.unwrap=()=>e._zod.def.getter()});function Qg(e){return new Xg({type:"lazy",getter:e})}var eh=g("ZodPromise",(e,t)=>{$f.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>sg(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Jx(e){return new eh({type:"promise",innerType:e})}var th=g("ZodFunction",(e,t)=>{Df.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Up(e,n,r,o)});function Xx(e){return new th({type:"function",input:Array.isArray(e?.input)?Tg(e?.input):e?.input??pi(Gn()),output:e?.output??Gn()})}var bi=g("ZodCustom",(e,t)=>{Mf.init(e,t),M.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Bp(e,n,r,o)});function Qx(e){let t=new J({check:"custom"});return t._zod.check=e,t}function eC(e,t){return bp(bi,e??(()=>!0),t)}function nh(e,t={}){return vp(bi,e,t)}function rh(e){return Sp(e)}var tC=_p,nC=xp;function rC(e,t={}){let n=new bi({type:"custom",check:"custom",fn:(r)=>r instanceof e,abort:!0,...I.normalizeParams(t)});return n._zod.bag.Class=e,n._zod.check=(r)=>{if(!(r.value instanceof e))r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:n,path:[...n._zod.def.path??[]]})},n}var oC=(...e)=>Cp({Codec:al,Boolean:Vr,String:Ur},...e);function iC(e){let t=Qg(()=>tl([Nc(e),pg(),gg(),vg(),pi(t),Ig(Nc(),t)]));return t}function sC(e,t){return di(rl(e),t)}var aC={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function cC(e){se({customError:e})}function lC(){return se().customError}var cl;(function(e){})(cl||(cl={}));var jD=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(o){return e[o]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};return(o)=>{switch(o.code){case"invalid_type":{let i=r[o.expected]??o.expected,s=Od(o.input),a=r[s]??s;return`Invalid input: expected ${i}, received ${a}`}case"invalid_value":if(o.values.length===1)return`Invalid input: expected ${ba(o.values[0])}`;return`Invalid option: expected one of ${ga(o.values,"|")}`;case"too_big":{let i=o.inclusive?"<=":"<",s=t(o.origin);if(s)return`Too big: expected ${o.origin??"value"} to have ${i}${o.maximum.toString()} ${s.unit??"elements"}`;return`Too big: expected ${o.origin??"value"} to be ${i}${o.maximum.toString()}`}case"too_small":{let i=o.inclusive?">=":">",s=t(o.origin);if(s)return`Too small: expected ${o.origin} to have ${i}${o.minimum.toString()} ${s.unit}`;return`Too small: expected ${o.origin} to be ${i}${o.minimum.toString()}`}case"invalid_format":{let i=o;if(i.format==="starts_with")return`Invalid string: must start with "${i.prefix}"`;if(i.format==="ends_with")return`Invalid string: must end with "${i.suffix}"`;if(i.format==="includes")return`Invalid string: must include "${i.includes}"`;if(i.format==="regex")return`Invalid string: must match pattern ${i.pattern}`;return`Invalid ${n[i.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${ga(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function oh(){return{localeError:jD()}}var ih=()=>{throw Error("JSON Schema conversion is not bundled into this plugin artifact")};var ll={};dn(ll,{bigint:()=>KD,boolean:()=>qD,date:()=>YD,number:()=>VD,string:()=>HD});function HD(e){return Gf(Ur,e)}function VD(e){return qf(Hr,e)}function qD(e){return tp(Vr,e)}function KD(e){return rp(qr,e)}function YD(e){return pp(fi,e)}se(oh());var JD=ul;var uC=Object.freeze(["hard_stop","use_alternative","scope_down","manual_only","stop_and_explain"]);var vi=64,dC="Rule config exceeds CC Safety Net's safe source limit.";var aU=Object.freeze({maxSources:64,concurrency:4,maxRequests:131,maxResponseBytes:67108864});var ah=[{id:"secret.basename.env",category:"Basename",label:".env",description:"Blocks exact .env files.",basename:".env"},{id:"secret.basename.npmrc",category:"Basename",label:".npmrc",description:"Blocks npm credential config files.",basename:".npmrc"},{id:"secret.basename.pypirc",category:"Basename",label:".pypirc",description:"Blocks Python package index credential files.",basename:".pypirc"},{id:"secret.basename.netrc",category:"Basename",label:".netrc",description:"Blocks machine login credential files.",basename:".netrc"},{id:"secret.basename.git-credentials",category:"Basename",label:".git-credentials",description:"Blocks Git credential storage files.",basename:".git-credentials"},{id:"secret.basename.id-rsa",category:"Basename",label:"id_rsa",description:"Blocks RSA private key basenames.",basename:"id_rsa"},{id:"secret.basename.id-ed25519",category:"Basename",label:"id_ed25519",description:"Blocks Ed25519 private key basenames.",basename:"id_ed25519"},{id:"secret.basename.id-ecdsa",category:"Basename",label:"id_ecdsa",description:"Blocks ECDSA private key basenames.",basename:"id_ecdsa"},{id:"secret.basename.credentials",category:"Basename",label:"credentials",description:"Blocks generic credentials file basenames.",basename:"credentials"}],dl={id:"secret.pattern.env-variant",category:"Pattern",label:".env.*",description:"Blocks environment-specific .env variants."},XD=[".bak",".backup",".copy",".disabled",".old",".orig",".save",".tmp"],QD=[{idSlug:"kube-config",label:"~/.kube/config",directoryParts:[".kube"],basename:"config"},{idSlug:"docker-config",label:"~/.docker/config.json",directoryParts:[".docker"],basename:"config.json"}],ch=[{id:"secret.home.ssh",category:"Home path",label:"~/.ssh",description:"Blocks home SSH configuration and key paths.",suffixParts:[".ssh"]},{id:"secret.home.aws",category:"Home path",label:"~/.aws",description:"Blocks home AWS credential and config paths.",suffixParts:[".aws"]},{id:"secret.home.gcp",category:"Home path",label:"~/.gcp",description:"Blocks home GCP credential paths.",suffixParts:[".gcp"]},{id:"secret.home.gcloud-config",category:"Home path",label:"~/.config/gcloud",description:"Blocks home Google Cloud SDK credential paths.",suffixParts:[".config","gcloud"]},{id:"secret.home.kube-config",category:"Home path",label:"~/.kube/config",description:"Blocks home Kubernetes config files.",suffixParts:[".kube","config"]},{id:"secret.home.docker-config",category:"Home path",label:"~/.docker/config.json",description:"Blocks home Docker credential config files.",suffixParts:[".docker","config.json"]},...QD.flatMap((e)=>XD.map((t)=>({id:["secret.home",e.idSlug,t.slice(1)].join("."),category:"Home path",label:[e.label,t].join(""),description:["Blocks home ",e.label,t," credential backup files."].join(""),suffixParts:[...e.directoryParts,[e.basename,t].join("")]}))),{id:"secret.home.gh-hosts",category:"Home path",label:"~/.config/gh/hosts.yml",description:"Blocks GitHub CLI host credential files.",suffixParts:[".config","gh","hosts.yml"]}];var ml=[{id:"secret.cli.claude-code",category:"Coding CLI credential",label:"Claude Code credentials",paths:["~/.claude/.credentials.json"]},{id:"secret.cli.claude-code.config",category:"Coding CLI config",label:"Claude Code config",paths:["~/.claude/settings.json","~/.claude/settings.local.json","~/.claude.json","<project>/.claude/settings.local.json","<project>/.mcp.json"]},{id:"secret.cli.antigravity",category:"Coding CLI config",label:"Antigravity CLI hook config",paths:["~/.gemini/config/hooks.json","~/.gemini/config/mcp_config.json"]},{id:"secret.cli.codex",category:"Coding CLI credential",label:"Codex credentials",paths:["~/.codex/auth.json","~/.codex/.credentials.json","~/.codex/secrets","~/.codex/.sandbox-secrets"]},{id:"secret.cli.codex.config",category:"Coding CLI config",label:"Codex config",paths:["~/.codex/config.toml","~/.codex/<name>.config.toml"]},{id:"secret.cli.gemini",category:"Coding CLI credential",label:"Gemini CLI credentials",paths:["~/.gemini/oauth_creds.json","~/.gemini/mcp-oauth-tokens.json","~/.gemini/a2a-oauth-tokens.json","~/.gemini/gemini-credentials.json"]},{id:"secret.cli.gemini.config",category:"Coding CLI config",label:"Gemini CLI config",paths:["~/.gemini/settings.json","~/.gemini/google_accounts.json","<project>/.gemini/settings.json","/Library/Application Support/GeminiCli/settings.json","/etc/gemini-cli/settings.json"]},{id:"secret.cli.copilot-cli",category:"Coding CLI credential",label:"GitHub Copilot CLI credentials",paths:["~/.copilot/config.json","~/.copilot/mcp-oauth-config","~/.copilot/mcp-secrets"]},{id:"secret.cli.copilot-cli.config",category:"Coding CLI config",label:"GitHub Copilot CLI config",paths:["~/.copilot/mcp-config.json"]},{id:"secret.cli.kimi-code",category:"Coding CLI credential",label:"Kimi Code credentials",paths:["~/.kimi-code/server.token","~/.kimi-code/credentials","~/.kimi/credentials","~/.kimi/mcp-oauth"]},{id:"secret.cli.kimi-code.config",category:"Coding CLI config",label:"Kimi Code config",paths:["~/.kimi-code/config.toml","~/.kimi-code/mcp.json","~/.kimi/config.toml","~/.kimi/config.json","~/.kimi/config.json.bak","~/.kimi/mcp.json","<project>/.kimi-code/mcp.json"]},{id:"secret.cli.opencode",category:"Coding CLI credential",label:"OpenCode credentials",paths:["~/.local/share/opencode/auth.json","~/.local/share/opencode/mcp-auth.json","~/.local/share/opencode/opencode.db"]},{id:"secret.cli.opencode.config",category:"Coding CLI config",label:"OpenCode config",paths:["~/.config/opencode/opencode.json","~/.config/opencode/opencode.jsonc","/Library/Application Support/opencode/opencode.json","/etc/opencode/opencode.json","<project>/opencode.json","<project>/opencode.jsonc"]},{id:"secret.cli.pi",category:"Coding CLI credential",label:"Pi credentials",paths:["~/.pi/agent/auth.json"]},{id:"secret.cli.pi.config",category:"Coding CLI config",label:"Pi config",paths:["~/.pi/agent/models.json"]},{id:"secret.cli.amp",category:"Coding CLI credential",label:"Amp Code credentials",paths:["~/.local/share/amp/secrets.json","~/.amp/oauth"]},{id:"secret.cli.amp.config",category:"Coding CLI config",label:"Amp Code config",paths:["~/.config/amp/settings.json","~/.config/amp/settings.jsonc","<project>/.amp/settings.json","<project>/.amp/settings.jsonc"]},{id:"secret.cli.cursor",category:"Coding CLI credential",label:"Cursor CLI credentials",paths:["~/.cursor/auth.json","~/.config/cursor/auth.json","~/.cursor/projects/<name>/mcp-auth.json"]},{id:"secret.cli.cursor.config",category:"Coding CLI config",label:"Cursor CLI config",paths:["~/.cursor/mcp.json","<project>/.cursor/mcp.json"]}],mC=[{prefix:"id_rsa",slug:"id-rsa",label:"id_rsa"},{prefix:"id_dsa",slug:"id-dsa",label:"id_dsa"},{prefix:"id_ed25519",slug:"id-ed25519",label:"id_ed25519"},{prefix:"id_ecdsa",slug:"id-ecdsa",label:"id_ecdsa"},{prefix:"credentials",slug:"credentials",label:"credentials"}],e$=[".bak",".backup",".copy",".disabled",".key",".old",".orig",".pem",".save",".tmp"],lh=mC.map((e)=>({id:`secret.variant.${e.slug}.separator`,category:"Variant",label:`${e.label}-* / ${e.label}_*`,description:`Blocks ${e.label} variants with dash or underscore suffixes.`,prefix:e.prefix})),uh=mC.flatMap((e)=>e$.map((t)=>({id:`secret.variant.${e.slug}.${t.slice(1)}`,category:"Variant",label:`${e.label}${t}`,description:`Blocks ${e.label}${t} private credential variants.`,prefix:e.prefix,suffix:t}))),Si={id:"secret.pattern.ssh-key-basename",category:"Pattern",label:"*_(rsa|dsa|ed25519|ecdsa)",description:"Blocks extensionless SSH private key-like basenames.",pattern:/^.*_(rsa|dsa|ed25519|ecdsa)$/},dh=["agilekeychain","asc","bek","cscfg","fve","gnucash","jks","keychain","kwallet","mdf","ovpn","p12","pcap","pem","pfx","pkcs12","psafe3","rdp","sdf","tblk","tpm"].map((e)=>({id:`secret.ext.${e}`,category:"Extension",label:`.${e}`,description:`Blocks files with the .${e} extension.`,extension:e})),mh=[{id:"secret.ext-pattern.key",category:"Extension pattern",label:".key / .keypair",description:"Blocks key and keypair extension patterns.",pattern:/^key(pair)?$/},{id:"secret.ext-pattern.keystore",category:"Extension pattern",label:".keystore / .keyring",description:"Blocks keystore and keyring extension patterns.",pattern:/^key(store|ring)$/},{id:"secret.ext-pattern.kdbx",category:"Extension pattern",label:".kdb / .kdbx",description:"Blocks KeePass database extension patterns.",pattern:/^kdbx?$/}],fC=[...ah,dl,...ch,...lh,...uh,Si,...dh,...mh,...ml].map((e)=>({id:e.id,category:e.category,label:e.label,...e.category==="Coding CLI config"?{defaultOff:!0}:{},..."paths"in e?{paths:e.paths}:{description:e.description}})),pC=new Set(ml.flatMap((e)=>e.category==="Coding CLI config"?[e.id]:[])),t$=fC.map((e)=>e.id),fl=new Set(t$);var _U=n$(import.meta.url),gC,r$=Array(vi+1).fill("over-limit"),hC=/^[^/]+\/[^/]+$/,o$=/^sha256:[a-f0-9]{64}$/,pl=`must be an integer between ${Sl} and ${_l}`,i$=["version","rules","overrides","transparent_wrappers"],s$=["version","safety","workflow","destructive_command_protection","secret_protection","audit"];function yC(e){if(!Ye(e)||!Array.isArray(e.rules)||e.rules.length<=vi)return e;return{$schema:e.$schema,version:e.version,rules:r$,overrides:e.overrides,transparent_wrappers:e.transparent_wrappers}}function a$(){let e=sh,t=(x)=>{let v=e.superRefine(x);return v._zod.def.when=()=>!0,v},n=e.enum(uC),r=e.union([e.literal("off"),e.looseObject({reason:e.string({error:"required non-empty string"}).min(1,"required non-empty string").max(er,`must be at most ${er} characters`).describe("Replacement block reason"),intent:n.optional()})],{error:'must be "off" or an object'}).describe("Disable a rule or replace its block reason and intent."),o=e.string({error:"must be a rulebook source string"}).min(1,"must be a non-empty rulebook source string"),i=e.string({error:"must be a command string"}).regex(bn,"must match command pattern").describe("Command name such as 'git', 'docker', or 'rtk'."),s=e.looseObject({$schema:e.unknown().optional().describe("JSON Schema reference for IDE support"),version:e.literal(1).describe("Schema version (must be 1)"),rules:e.array(o,{error:"must be an array of rulebook source strings"}).max(vi,dC).default([]).describe("Rulebook source strings such as project-rules or owner/repo#main/team-rules"),overrides:e.record(e.string().meta({pattern:hC.source}),r).default({}).describe("Rule overrides by id"),transparent_wrappers:e.array(i,{error:"must be an array of command strings"}).default([]).describe("Commands that transparently execute a visible protected child command")}),a=(x,v)=>{if(!Ye(x))return;if(Array.isArray(x.rules)&&x.rules.length<=vi){let k=new Set;x.rules.forEach((z,L)=>{if(typeof z!=="string"||z==="")return;if(z.trim()===""){v.addIssue({code:"custom",message:"must be a non-empty rulebook source string",path:["rules",L]});return}let W=Xr(z);if(W){v.addIssue({code:"custom",message:W,path:["rules",L]});return}if(k.has(z)){v.addIssue({code:"custom",message:`duplicate rulebook source "${z}"`,path:["rules",L]});return}k.add(z)})}if(Ye(x.overrides))for(let k of Object.keys(x.overrides)){if(hC.test(k))continue;v.addIssue({code:"custom",message:"must use <rulebook-name>/<rule-name>",path:["overrides",k]})}if(!Array.isArray(x.transparent_wrappers))return;let T=new Set;x.transparent_wrappers.forEach((k,z)=>{if(typeof k!=="string"||!bn.test(k))return;if(T.has(k)){v.addIssue({code:"custom",message:`duplicate command "${k}"`,path:["transparent_wrappers",z]});return}if(Rv(k)){v.addIssue({code:"custom",message:`reserved command "${k}" cannot be a wrapper`,path:["transparent_wrappers",z]});return}T.add(k)})},c=e.preprocess(yC,s.check(e.superRefine(a))),l=e.preprocess(yC,s.check(t(a))),u=e.strictObject({fail_closed:e.boolean().optional(),paranoid_rm:e.boolean().optional(),paranoid_interpreters:e.boolean().optional()}),d=(x,v)=>e.intersection(e.record(e.string().refine((T)=>x.has(T),{error:(T)=>`unknown ${v} rule id "${String(T.input)}"`}),e.unknown()),e.record(e.string(),e.enum(["on","off"]))),f=(x)=>e.array(e.string({error:"must be a non-empty path string"}),{error:"must be an array of paths"}).check(t((v,T)=>{if(!Array.isArray(v))return;let k=hn();v.forEach((z,L)=>{if(typeof z!=="string")return;let W=x(z,k);if(W)T.addIssue({code:"custom",message:W,path:[L]})})})),m=e.strictObject({version:e.literal(1),safety:e.strictObject({level:e.enum(["standard","strict","paranoid"]).optional(),overrides:u.optional()}).optional(),workflow:e.strictObject({worktree_mode:e.boolean().optional()}).optional(),destructive_command_protection:e.strictObject({enabled:e.boolean().optional(),overrides:d(Xi,"destructive command").optional(),allow_paths:f(Ws).optional()}).optional(),secret_protection:e.strictObject({enabled:e.boolean().optional(),overrides:d(fl,"secret protection").optional(),deny_paths:f(Fs).optional(),allow_paths:f(Gs).optional()}).optional(),audit:e.strictObject({retention_days:e.number({error:pl}).int(pl).min(Sl,pl).max(_l,pl).optional().describe("Days of audit log history to keep before the sweep deletes it")}).optional()}),p=(x)=>{let v=(L,W)=>x==="legacy"?L:W,T=v("must match pattern (letters, numbers, hyphens, underscores)","must match command pattern"),k=`required non-empty string up to ${er} characters`,z=e.looseObject({name:e.string({error:"required string"}).regex(lt,v("must match pattern (letters, numbers, hyphens, underscores; max 64 chars)","must match rule name pattern")),command:e.string({error:v("required string","required string matching command pattern")}).regex(bn,v(T,"required string matching command pattern")),subcommand:e.string({error:v("must be a string if provided","must match command pattern")}).regex(bn,T).optional(),block_args:e.array(e.string({error:v("must be a string","must be a non-empty string")}).refine((L)=>L!=="",{error:v("must not be empty","must be a non-empty string")}),{error:v("required array","required non-empty array")}).refine((L)=>L.length>0,{error:v("must have at least one element","required non-empty array")}),reason:e.string({error:v("required string",k)}).refine((L)=>L!=="",{error:v("must not be empty",k)}).refine((L)=>L.length<=er,{error:v(`must be at most ${er} characters`,k)}),intent:n.optional()},{error:"must be an object"});return e.array(z,{error:v("must be an array","required array")}).check(t((L,W)=>{if(!Array.isArray(L))return;let U=new Set;L.forEach((ge,Ze)=>{let A=Ye(ge)?ge.name:void 0;if(typeof A!=="string")return;if(U.has(A.toLowerCase())){W.addIssue({code:"custom",message:`duplicate rule name "${A}"`,path:[Ze,"name"]});return}U.add(A.toLowerCase())})}))},h=e.looseObject({version:e.literal(1),rules:p("legacy").optional()}),b="required string matching rule name pattern",y=e.looseObject({command:e.string({error:"required non-empty string"}).refine((x)=>x.trim()!=="",{error:"required non-empty string"}),expect:e.enum(["blocked","allowed"]),rule:e.string({error:"must be a string if provided"}).optional()},{error:"must be an object"}).check(t((x,v)=>{if(!Ye(x))return;if(x.expect!=="blocked"||typeof x.rule==="string")return;v.addIssue({code:"custom",message:"required string for blocked fixtures",path:["rule"]})})),E=e.looseObject({name:e.string({error:"required string matching rule name pattern"}).regex(lt,"required string matching rule name pattern"),version:e.string({error:"required non-empty string"}).refine((x)=>x!=="",{error:"required non-empty string"}),allowed_commands:e.array(e.string({error:"must match command pattern"}).regex(bn,"must match command pattern"),{error:"required array"}).check(t((x,v)=>{if(!Array.isArray(x))return;let T=new Set;x.forEach((k,z)=>{if(typeof k!=="string"||!bn.test(k))return;if(T.has(k)){v.addIssue({code:"custom",message:`duplicate command "${k}"`,path:[z]});return}T.add(k)})})),rules:p("rulebook"),tests:e.array(y,{error:"must be an array if provided"}).optional()}).check(t((x,v)=>{if(!Ye(x))return;let T=new Set(fh(x));if(Array.isArray(x.tests)){let z=new Set(x.tests.flatMap((L)=>Ye(L)&&L.expect==="blocked"&&typeof L.rule==="string"?[L.rule]:[]));for(let L of z){if(T.has(L))continue;v.addIssue({code:"custom",message:`blocked fixture references unknown rule "${L}"`,path:["tests"]})}}if(!Array.isArray(x.allowed_commands)||!Array.isArray(x.rules))return;let k=new Set(x.allowed_commands.filter((z)=>typeof z==="string"));x.rules.forEach((z,L)=>{let W=Ye(z)?z.command:void 0;if(typeof W!=="string"||k.has(W))return;v.addIssue({code:"custom",message:`"${W}" must be listed in allowed_commands`,path:["rules",L,"command"]})})})),w=e.string({error:"required string"}).refine((x)=>x.trim()!=="",{error:"required string"}),R=e.looseObject({spec:w,name:w,version:w,digest:e.string({error:"required sha256 digest"}).regex(o$,"required sha256 digest")},{error:"must be an object"}),P=e.looseObject({rulebooks:e.array(e.intersection(R,e.discriminatedUnion("kind",[e.object({kind:e.literal("local-directory"),path:w}),e.object({kind:e.literal("github"),owner:w,repo:w,ref:w,commit:w,path:w,display_ref:e.unknown().optional()})],{error:(x)=>{if(!Ye(x.input))return"must be an object";let v=x.input.kind;return typeof v==="string"?`unknown kind "${v}"`:"required string"}})))});return{RulesConfigSchema:c,RulesConfigDiagnosticSchema:l,RuleOverrideSchema:r,UserPolicySchema:m,LegacyConfigSchema:h,RulebookSchema:E,RulesLockfileSchema:P}}function _i(){return gC??=a$(),gC}function bC(){return _i().RulesConfigSchema}function c$(){return _i().UserPolicySchema}function vC(){return _i().RulebookSchema}function SC(){return _i().RulesLockfileSchema}function fh(e){let t=Ye(e)?e.rules:void 0;return(Array.isArray(t)?t:[]).flatMap((n)=>{let r=Ye(n)?n.name:void 0;return typeof r==="string"?[r]:[]})}function _C(e){let t=_i().RulesConfigDiagnosticSchema.safeParse(e);if(t.success)return{errors:[],sources:new Set(t.data.rules)};return{errors:Kr(wC(t.error.issues,i$)),sources:m$(e,t.error.issues)}}function xC(e){let t=c$().safeParse(e);if(t.success)return[];return Kr(wC(t.error.issues,s$)," ")}function Kr(e,t=": ",n=" "){return[...new Set(e.flatMap((r)=>CC(r,t,n,[])))]}function CC(e,t,n,r){let o=[...r,...e.path],i=d$(o);if(e.code==="unrecognized_keys")return e.keys.map((s)=>`${i?`${i}.`:""}unknown field "${s}"`);if(e.code==="invalid_key")return e.issues.map((s)=>s.message);if(e.code==="invalid_union"){let s=e.errors.flat().filter((a)=>a.path.length>0);if(s.length>0)return s.flatMap((a)=>CC(a,t,n,o))}if(o.length===0)return[e.code==="invalid_type"?"Config must be an object":e.message];if(o.length===1&&(e.code==="too_big"||e.code==="too_small")&&e.origin==="array")return[e.message];return[`${i}${o.length===1?n:t}${l$(e)}`]}function l$(e){if(e.code==="invalid_value")return`must be ${u$(e.values)}`;if(e.code!=="invalid_type"||!e.message.startsWith("Invalid input:"))return e.message;if(e.expected==="object"||e.expected==="record")return"must be an object if provided";return e.expected==="boolean"?"must be a boolean":e.message}function u$(e){if(e.length>3)return`one of ${e.join(", ")}`;let t=e.map((n)=>typeof n==="string"?`"${n}"`:String(n));if(t.length<2)return`${t[0]}`;return`${t.slice(0,-1).join(", ")}${t.length>2?",":""} or ${t.at(-1)}`}function d$(e){return e.map((t,n)=>{if(typeof t==="number")return`[${t}]`;return n===0?String(t):`.${String(t)}`}).join("")}function wC(e,t){let n=e.map((i)=>i.path[1]),r=[...new Set(n.filter((i)=>typeof i==="string"))],o=(i,s)=>[i.path.length===0?-1:t.indexOf(String(i.path[0])),typeof s==="number"?s:r.indexOf(String(s)),i.code==="custom"?0:1];return e.map((i,s)=>({issue:i,rank:o(i,n[s])})).sort((i,s)=>i.rank[0]-s.rank[0]||i.rank[1]-s.rank[1]||i.rank[2]-s.rank[2]).map((i)=>i.issue)}function m$(e,t){let n=Ye(e)?e.rules:void 0;if(!Array.isArray(n))return new Set;if(t.some((o)=>o.path.length===1&&o.path[0]==="rules"))return new Set;let r=new Set(t.filter((o)=>o.path[0]==="rules"&&typeof o.path[1]==="number").map((o)=>o.path[1]));return new Set(n.filter((o,i)=>typeof o==="string"&&!r.has(i)))}function Ye(e){return!!e&&typeof e==="object"&&!Array.isArray(e)}function f$(e){return _C(e)}function ph(e){try{let t=mn(p$(e));if(t===null)return{config:null,errors:[]};if(!t.trim())return{config:null,errors:["Config file is empty"]};let n=JSON.parse(t),r=f$(n);if(r.errors.length>0)return{config:null,errors:r.errors};let o=bC().parse(n);return{config:{version:1,rules:o.rules??[],overrides:o.overrides??{},transparent_wrappers:o.transparent_wrappers??[]},errors:[]}}catch(t){if(t instanceof ae)return{config:null,errors:[t.message]};let n=t instanceof Error?t.message:String(t);return{config:null,errors:[t instanceof SyntaxError?"Invalid JSON":n]}}}function p$(e){return typeof e==="string"?zi(e):e}var v$=new Set(["standard","strict","paranoid"]),S$={version:1,safety:{level:"standard",overrides:{}},workflow:{worktree_mode:!1},destructive_command_protection:{enabled:!0,overrides:{},allow_paths:[]},secret_protection:{enabled:!0,overrides:{},deny_paths:[],allow_paths:[]},audit:{retention_days:Ai}};function gh(e){return b$(y$(fn(e)),$i)}function kC(e={}){let t=E$(gh(e));return{...t.policy,errors:t.errors,...t.fallback?{fallback:t.fallback}:{}}}function EC(e){if(!Pt(e))return w$();let t=Pt(e.safety)?e.safety:{},n=Pt(t.overrides)?t.overrides:{},r=Pt(e.workflow)?e.workflow:{},o=Pt(e.destructive_command_protection)?e.destructive_command_protection:{},i=Pt(e.secret_protection)?e.secret_protection:{};return{version:1,safety:{level:v$.has(t.level)?t.level:"standard",overrides:{...typeof n.fail_closed==="boolean"?{fail_closed:n.fail_closed}:{},...typeof n.paranoid_rm==="boolean"?{paranoid_rm:n.paranoid_rm}:{},...typeof n.paranoid_interpreters==="boolean"?{paranoid_interpreters:n.paranoid_interpreters}:{}}},workflow:{worktree_mode:typeof r.worktree_mode==="boolean"?r.worktree_mode:!1},destructive_command_protection:{enabled:typeof o.enabled==="boolean"?o.enabled:!0,overrides:RC(o.overrides,Xi),allow_paths:x$(o.allow_paths)},secret_protection:{enabled:typeof i.enabled==="boolean"?i.enabled:!0,overrides:RC(i.overrides,fl),deny_paths:_$(i.deny_paths),allow_paths:C$(i.allow_paths)},audit:{retention_days:Ti(Pt(e.audit)?e.audit.retention_days:void 0)}}}function RC(e,t){if(!Pt(e))return{};return Object.fromEntries(Object.entries(e).flatMap(([n,r])=>t.has(n)&&(r==="on"||r==="off")?[[n,r]]:[]))}function _$(e){if(!Array.isArray(e))return[];let t=hn();return e.filter((n)=>Fs(n,t)===null)}function x$(e){if(!Array.isArray(e))return[];let t=hn();return e.filter((n)=>Ws(n,t)===null)}function C$(e){if(!Array.isArray(e))return[];let t=hn();return e.filter((n)=>Gs(n,t)===null)}function Pt(e){return!!e&&typeof e==="object"&&!Array.isArray(e)}function w$(){return structuredClone(S$)}function E$(e){let t=R$();if(!g$(e)){let n=globalThis.__CC_SAFETY_NET_EMBEDDED_POLICY__;if(!Pt(n))return{policy:t,errors:[]};return{policy:PC(EC(n)),errors:[]}}try{let n=h$(e,"utf-8");if(!n.trim())return{policy:t,errors:[`${e}: Config file is empty`],fallback:"defaults"};let r=JSON.parse(n),o=xC(r),i=PC(EC(r));if(o.length>0)return{policy:i,errors:o.map((s)=>`${e}: ${s}`),fallback:Pt(r)?"salvaged":"defaults"};return{policy:i,errors:[]}}catch(n){let r=n instanceof Error?n.message:String(n);return{policy:t,errors:[`${e}: ${n instanceof SyntaxError?"Invalid JSON":r}`],fallback:"defaults"}}}function AC(e){let t=Object.entries(e),n=new Set(t.flatMap(([r,o])=>o==="on"?[r]:[]));return[...new Set([...[...pC].filter((r)=>!n.has(r)),...t.flatMap(([r,o])=>o==="off"?[r]:[])])]}function R$(){return{safety:{},worktreeMode:!1,destructiveCommandProtectionEnabled:!0,destructiveCommandRuleOverrides:{},destructiveCommandAllowPaths:[],secretProtection:{enabled:!0,disabledRules:AC({}),denyPaths:[],allowPaths:[]}}}function PC(e){return{safety:P$(e.safety),worktreeMode:e.workflow.worktree_mode,destructiveCommandProtectionEnabled:e.destructive_command_protection.enabled,destructiveCommandRuleOverrides:e.destructive_command_protection.overrides,destructiveCommandAllowPaths:e.destructive_command_protection.allow_paths,secretProtection:{enabled:e.secret_protection.enabled,disabledRules:AC(e.secret_protection.overrides),denyPaths:e.secret_protection.deny_paths,allowPaths:e.secret_protection.allow_paths}}}function P$(e){let t={...e.overrides.fail_closed!==void 0?{failClosed:e.overrides.fail_closed}:{},...e.overrides.paranoid_rm!==void 0?{paranoidRm:e.overrides.paranoid_rm}:{},...e.overrides.paranoid_interpreters!==void 0?{paranoidInterpreters:e.overrides.paranoid_interpreters}:{}};return{level:e.level,...Object.keys(t).length>0?{overrides:t}:{}}}var zC="This path contains the protected policy config and you must not modify or delete it.",A$=new Set(["[","cat","file","grep","head","jq","less","ls","more","rg","sed","stat","tail","test","wc"]);function NC(e){let t=gn(Ot()),n=D$(e.invocation.context.executionCwd,t);if(e.invocation.route.kind==="patch")return TC(e.paths,!1,e.invocation.context.executionCwd,n,t);let r=Ne(e,"input-candidate");if(e.invocation.route.kind==="command")return r?IC(r.shell,e.invocation.context.executionCwd,n,t):null;if(e.invocation.route.kind==="unknown"&&r){let o=IC(r.shell,e.invocation.context.executionCwd,n,t);if(o)return o}return TC(e.paths,e.invocation.route.kind==="grep"||e.invocation.route.kind==="glob"||Os(e.invocation.toolName),e.invocation.context.executionCwd,n,t)}function TC(e,t,n,r,o){if(t)return null;let i=e.find((s)=>xi(s,n,r,o));return i?{target:i}:null}function IC(e,t,n,r){let o=Ns(e,t,r,{findSegmentTarget:(i,s)=>T$(i,s,n,r)?.target??null,isRedirectionTarget:(i,s)=>xi(i,s.cwd,n,r),findMalformedTarget:(i)=>N$(i,t,n,r)?.target??null,normalizeCwd:ve});return o?{target:o}:null}function T$(e,t,n,r){if(So(e))return null;let o=r.environment,i=Kt([...e],o),s=G(i[0]??"").toLowerCase(),a=i.slice(1);if(s==="rm"&&I$(a)){let c=O$(a).find((l)=>OC(De(l,t.variables),t.cwd,n,r));if(c)return{target:c}}if(s==="find"){if(Ks(i,1)||Nu(i,o)){let l=(qs(j(i))??j(["."])).find((u)=>{let d=De(u.text,t.variables);return xi(d,t.cwd,n,r)||OC(d,t.cwd,n,r)})?.text;if(l)return{target:l}}}if(s==="mv"){let c=Ds(a).sources.find((l)=>$$(De(l,t.variables),t.cwd,n,r));if(c)return{target:c}}if(z$(e,o))return null;for(let c of[...e,...i])for(let l of DC(c))if(xi(De(l,t.variables),t.cwd,n,r))return{target:l};return null}function I$(e){return e.some((t)=>t==="--recursive"||t.startsWith("-")&&!t.startsWith("--")&&/[rR]/.test(t.slice(1)))}function O$(e){let t=e.indexOf("--");if(t!==-1)return[...e.slice(0,t).filter((n)=>!n.startsWith("-")),...e.slice(t+1)];return e.filter((n)=>!n.startsWith("-"))}function z$(e,t){let n=Kt([...e],t);if(n.length===0)return!1;let r=G(n[0]??"").toLowerCase();if(!A$.has(r))return!1;if(r!=="sed")return!0;return!n.slice(1).some((o)=>o.startsWith("-i")||o==="--in-place"||o.startsWith("--in-place="))}function N$(e,t,n,r){for(let o of e.split(/\s+/))for(let i of DC(o))if(xi(i,t,n,r))return{target:i};return null}function DC(e){let t=e.trim().replace(/^['"]|['"]$/g,""),n=t.indexOf("=");return n===-1||n===t.length-1?[t]:[t,t.slice(n+1)]}function D$(e,t){let n=ve(gh(),e,t),r=hh(n),o=new Set;for(let i=r;;i=hh(i))if(o.add(Yr(i)),hh(i)===i)break;return{file:Yr(n),directoryAndAncestors:o}}function xi(e,t,n,r){let o=ev(e,t,r,(i)=>Yr(i)===k$(n.file));return o!==null&&Yr(o)===n.file}function OC(e,t,n,r){return n.directoryAndAncestors.has(Yr(ve(e,t,r)))}function $$(e,t,n,r){let o=Yr(ve(e,t,r));return o===n.file||n.directoryAndAncestors.has(o)}function Yr(e){return process.platform==="win32"?e.toLowerCase():e}import{homedir as bh}from"node:os";import{isAbsolute as gl,posix as L$,resolve as yl,win32 as M$}from"node:path";import{fileURLToPath as W$}from"node:url";var HC="Access to a sensitive path is not allowed.",VC=new Set(["echo","printf"]),F$=new Set(["find"]),G$=new Set(["-exec","-execdir"]),Z$=new Set([";","+"]),B$=new Set(["-delete","-exec","-execdir","-fls","-fprint","-fprint0","-fprintf","-ok","-okdir"]),U$=new Set(["-name","-iname","-path","-ipath","-wholename","-iwholename","-samefile"]),j$=new Set(["python","python2","python3","node","deno","bun","ruby","perl","php","rscript","osascript","bash","sh","zsh","dash","ksh"]),H$=new Set(["node","bun"]),V$=new Set(["bun","child_process","deno","dotenv","fs","subprocess"]),q$=new Set(["append","awk","base64","cat","chmod","chown","connect","copy","cp","database","dd","eval","exec","fetch","file","function","grep","head","include","load","move","mv","open","popen","read","remove","rename","require","rg","rm","sed","shell","source","spawn","strings","system","tail","tar","truncate","unlink","write","xxd","zip"]),qC=new Set(["-c","-e","-r","-E","--eval","--exec"]),K$=new Set(["src/cli/cc-safety-net.ts","dist/bin/cc-safety-net.js"]),$C=new Set(["cc-safety-net","ccsn"]),Y$=new Set(["bunx","npx","pnpx"]),J$=new Set(["bun","node"]),X$=new Map([["c",new Set(["bash","sh","zsh","dash","ksh","python"])],["e",new Set(["node","deno","bun","ruby","perl","rscript","osascript"])],["E",new Set(["perl"])],["r",new Set(["php"])]]),Q$=new Set(["grep","rg"]),LC="f",MC="file",e0="files",t0=new Set(["e","f"]),n0=new Set(["regexp","file"]),r0=new Set(["e","f","A","B","C","m"]),o0=new Set(["regexp","file","after-context","before-context","context","max-count"]),i0=new Set(["|","|&"]),yh="__CC_SAFETY_NET_PIPE_INPUT__",KC=new Set(["bash","sh","zsh","dash","ksh"]),s0=new Map([["bash",new Set(["-O"])],["sh",new Set(["-O"])],["zsh",new Set(["-o"])],["dash",new Set(["-o"])],["ksh",new Set(["-o"])],["python",new Set(["-W","-X"])],["node",new Set(["-r","--require","--loader","--import","--input-type"])]]);function WC(e,t,n,r,o){let i=eo();for(let s of e){if(V0(s,t,n?.denyPaths??[],r,i))return{target:s,ruleId:"secret.deny-path"};if(o&&!o.has(s))continue;let a=j0(s,t,n,i);if(a){if(!a.startsWith("secret.cli.")&&q0(s,t,n?.allowPaths??[],r,i))continue;return{target:s,ruleId:a}}}return null}function YC(e,t,n={}){let r=FC(e),o=WC(r,e.invocation.context.executionCwd,t,e.invocation.context.configCwd),i=o?.ruleId!=="secret.deny-path"&&n.strict===!1?FC(e,{refineJavaScriptInlineData:!0}):r,s=i.length===r.length?o:WC(r,e.invocation.context.executionCwd,t,e.invocation.context.configCwd,new Set(i));if(s?.ruleId!=="secret.deny-path"&&n.strict===!1&&a0(e))return null;return s}function a0(e){if(e.invocation.route.kind!=="command")return!1;let t=Ne(e,"input-candidate")??Ne(e,"declared-command");if(!t)return!1;if(t.program.nodes.some((s)=>s.kind==="command"&&s.nested.length>0))return!1;let n=[];for(let s of t.shell.entries){if(s.kind==="operator"&&s.boundary)return!1;if(s.kind==="redirection")return!1;if(s.kind!=="operator")n.push(pt(s.text))}let r=Jr(n);if(r.length===0)return!1;let o=Un(r[0]??"").toLowerCase(),i=r.slice(1);if(o==="ls"||o==="stat")return!0;if(o==="test")return i.length===2&&(i[0]==="-e"||i[0]==="-f");if(o!=="find")return!1;return!i.some((s)=>B$.has(s))}function FC(e,t={}){if(e.invocation.route.kind==="command"){let r=Ne(e,"input-candidate");return r?Ei(r.shell,e.store,t):[]}if(e.invocation.route.kind!=="unknown")return[...e.paths];let n=Ne(e,"input-candidate");return[...n?Ei(n.shell,e.store,t):[],...e.paths]}function Ei(e,t,n){if(e.status==="structural-limit")throw new ft;if(e.status==="unclosed-quote")return[];if(e.status==="invalid")throw Error("Unable to parse command for secret protection");let r=[...e.assignmentFallbacks,...P0(pt(e.source),t,n)],o=[],i=null;for(let s of e.entries){if(s.kind==="operator"){if(!s.boundary)continue;if(o.length>0){if(r.push(...hl(o,t,n)),i!==null)r.push(...ZC(i,o,t,n));i=i0.has(s.operator)?o:null,o=[]}else i=null;continue}if(s.kind==="redirection"){let a=s.target?pt(s.target):void 0;if(a&&s.targetOrder==="legacy-segment")o.push(a);else if(a)r.push(a);continue}o.push(pt(s.text))}if(o.length>0){if(r.push(...hl(o,t,n)),i!==null)r.push(...ZC(i,o,t,n))}return r}function hl(e,t,n){let r=y0(e),o=Jr(e);if(o.length===0)return r;let i=o[0]??"",s=Un(i).toLowerCase(),a=o.slice(1),c=l0(i,s,a);if(c)return[...r,...c];if(VC.has(s))return r;if(Q$.has(s))return[...r,...D0(a)];if(F$.has(s))return[...r,...b0(a,t,n)];if($e.has(s))return[...r,...a.flatMap((l)=>BC("awk",l)),...a.flatMap((l)=>S0(l,t,n)),...a.flatMap(_0)];if(QC(s)){if(KC.has(s)){let l=Jb(s,a);if(l!==null&&t.getShellSyntax(l).status==="structural-limit")throw new ft}return[...r,...v0(s,a,n)]}return[...r,...a.flatMap((l)=>BC(s,l))]}function c0(e,t){if($C.has(e))return t[0]==="explain"?0:null;if(Y$.has(e)){let n=t[0]==="-y"||t[0]==="--yes"?1:0;return $C.has(t[n]??"")&&t[n+1]==="explain"?n+1:null}if(J$.has(e)){if(GC(t[0])&&t[1]==="explain")return 1;if(e==="bun"&&t[0]==="run"&&GC(t[1])&&t[2]==="explain")return 2}return null}function l0(e,t,n){let r=c0(t,n);if(r===null)return null;let o=[e,...n.slice(0,r)],i=n.slice(r+1);for(let s=0;s<i.length;s++){let a=i[s];if(a==="--json"||a==="--help"||a==="-h")continue;if(a==="--cwd"){let c=i[s+1];if(c&&!c.startsWith("--"))o.push(c);s++;continue}return o}return o}function GC(e){let t=e?.replaceAll("\\","/");return[...K$].some((n)=>t===n||t?.endsWith(`/${n}`))}function ZC(e,t,n,r){if(p0(t,n,r))return u0(e);let o=g0(t);if(o===null)return[];return d0(e).flatMap((i)=>KC.has(o)?Ei(n.getShellSyntax(i),n,r):tw(i))}function u0(e){let t=Jr(e);if(t.length===0)return[];let n=Un(t[0]??"").toLowerCase();if(!VC.has(n))return[];return t.slice(1)}function d0(e){let t=Jr(e);if(t.length===0)return[];let n=Un(t[0]??"").toLowerCase(),r=t.slice(1);if(n==="echo"){let o=r.findIndex((i)=>!/^-[neE]+$/.test(i));return[(o===-1?[]:r.slice(o)).join(" ")]}if(n==="printf")return m0(r);return[]}function m0(e){let t=e[0];if(t===void 0)return[];let n=(t.match(/%%|%[bqs]/g)??[]).filter((o)=>o!=="%%").length;if(n===0||e.length===1)return[JC(t)];let r=e.slice(1);return Array.from({length:Math.ceil(r.length/n)},(o,i)=>f0(t,r.slice(i*n,(i+1)*n)))}function f0(e,t){let n=0;return JC(e.replace(/%%|%[bqs]/g,(r)=>{if(r==="%%")return"%";let o=t[n]??"";return n++,o}))}function JC(e){return e.replace(/\\n/g,`
98
+ `).replace(/\\t/g,"\t").replace(/\\r/g,"\r")}function p0(e,t,n){let r=Jr(e);if(r.length===0||Un(r[0]??"").toLowerCase()!=="xargs")return!1;let o=kn(r),i=r.slice(o.childStart);if(i.length===0)return!1;if(o.replacementToken==="")return!1;let s=o.replacementToken,a=s===null?[...i,yh]:i.map((c)=>c.split(s).join(yh));return hl(a,t,n).some((c)=>c.includes(yh))}function g0(e){let t=Jr(e);if(t.length===0)return null;let n=Un(t[0]??"").toLowerCase();if(!QC(n))return null;return h0(n,t.slice(1))?n:null}function h0(e,t){let n=XC(e);for(let r=0;r<t.length;r++){let o=t[r];if(o===void 0)break;if(qC.has(o)||ew(e,o)||/^--(?:eval|exec)=/.test(o))return!1;if(o==="-")return!0;if(o.startsWith("-")){if(n==="python"&&o==="-m")return!1;if(s0.get(n)?.has(o))r++;continue}return!1}return!0}function XC(e){return/^python\d/.test(e)?"python":e}function y0(e){let t=[];for(let n of e){if(ow(n))continue;let r=/^[A-Za-z_][A-Za-z0-9_]*=(.*)$/.exec(n);if(r===null)break;if(r[1]!==void 0&&r[1]!=="")t.push(r[1])}return t}function BC(e,t){if(t==="--")return[];let n=[],r=t.indexOf("=");if(r>0&&r<t.length-1)n.push(t.slice(r+1));if(t.startsWith("-"))return n;if(e==="tar"&&/\.(?:tar|tgz|tar\.gz|zip)$/i.test(t))return n;if(e==="zip"&&/\.zip$/i.test(t))return n;return n.push(t),n}function b0(e,t,n){let r=e.findIndex((i)=>i.startsWith("-")||i==="("||i==="!"||i===";"),o=[...e.slice(0,r===-1?e.length:r)];for(let i=0;i<e.length;i++){if(!G$.has(e[i]??""))continue;let s=e.slice(i+1),a=s.findIndex((u)=>Z$.has(u)),c=a===-1?s:s.slice(0,a),l=hl(c,t,n);if(o.push(...l.filter((u)=>u!=="{}")),!l.includes("{}"))continue;o.push(...e.slice(0,i).flatMap((u,d,f)=>{if(!U$.has(u))return[];let m=f[d+1];return m===void 0?[]:[m,m.replace(/^\*+\//,"").replace(/\/\*+$/g,"").replace(/^\*+/,"").replace(/\*+$/g,"")]}))}return o}function QC(e){return j$.has(e)||/^python\d/.test(e)}function v0(e,t,n){let r=[];for(let o=0;o<t.length;o++){let i=t[o];if(i===void 0)break;if(qC.has(i)||ew(e,i)){let a=t[o+1];if(a!==void 0)r.push(...UC(e,a,n)),o++;continue}let s=/^--(?:eval|exec)=(.*)$/.exec(i);if(s!==null&&s[1]!==void 0){r.push(...UC(e,s[1],n));continue}if(!i.startsWith("-"))r.push(i)}return r}function ew(e,t){if(!t.startsWith("-")||t.startsWith("--")||t.length<=2)return!1;return X$.get(t[t.length-1]??"")?.has(XC(e))??!1}function S0(e,t,n){if(!e.includes("system"))return[];return Tu(e)?.commands.flatMap((r)=>Ei(t.getShellSyntax(r),t,n))??[]}function _0(e){return Array.from(e.matchAll(/\bgetline(?:\s+[A-Za-z_][A-Za-z0-9_]*)?\s*<\s*"((?:\\.|[^"\\])*)"/g)).map((t)=>t[1]).filter((t)=>t!==void 0&&t!=="")}function tw(e){let t=Array.from(e.matchAll(/(['"`])((?:\\.|(?!\1).)*)\1/g)).map((r)=>r[2]).filter((r)=>r!==void 0&&r!==""),n=(e.match(/[\w./~@+-]*[./~][\w./~@+-]*/g)??[]).filter((r)=>r!=="process.versions.sqlite"||t.some((o)=>o.includes(r)));return[...t,...t.flatMap(nw),...n]}function UC(e,t,n){let r=tw(t);if(!n.refineJavaScriptInlineData||!H$.has(e)||r.length===0)return r;let o=x0(t);return o!==null&&!w0(o)?[]:r}function x0(e){let t=e.split("");for(let n=0;n<e.length;n++){let r=e[n];if(r!=="'"&&r!=='"'&&r!=="`")continue;if(r==="`"&&C0(e,n))return null;t[n]=" ";let o=!1;for(let i=n+1;i<e.length;i++){let s=e[i];if(t[i]=" ",s==="\\"){if(i++,i<e.length)t[i]=" ";continue}if(r==="`"&&s==="$"&&e[i+1]==="{")return null;if(r!=="`"&&(s===`
99
+ `||s==="\r"))return null;if(s!==r)continue;n=i,o=!0;break}if(!o)return null}return t.join("")}function C0(e,t){for(let n=t-1;n>=0;n--){let r=e[n];if(!r||/\s/.test(r))continue;return/[\w$\])]/.test(r)}return!1}function w0(e){for(let t of e.matchAll(/[A-Za-z_$][A-Za-z0-9_$]*/g)){let n=t[0],r=t.index;if(V$.has(n.toLowerCase()))return!0;let o=n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[_$\s]+/).map((i)=>i.toLowerCase());if(!o.some((i)=>q$.has(i)))continue;if(o.length>1)return!0;if(E0(e,r)===".")return!0;if(R0(e,r+n.length)==="(")return!0}return!1}function E0(e,t){for(let n=t-1;n>=0;n--)if(!/\s/.test(e[n]??""))return e[n];return}function R0(e,t){for(let n=t;n<e.length;n++)if(!/\s/.test(e[n]??""))return e[n];return}function P0(e,t,n){return O0(e).flatMap((r)=>{let o=t.getShellSyntax(r);if(o.status==="invalid")return[];return[...Ei(o,t,n),...k0(o)?A0(o):[]]})}function k0(e){let t=e.entries;for(let n=0;n<t.length;n++){let r=t[n];if(r?.kind!=="word"||Un(pt(r.text)).toLowerCase()!=="base64")continue;for(let o=n+1;o<t.length;o++){let i=t[o];if(i?.kind==="operator")break;if(i?.kind!=="word")continue;let s=pt(i.text);if(s==="--decode"||!s.startsWith("--")&&s.startsWith("-")&&/[dD]/.test(s))return!0}}return!1}function A0(e){return e.entries.flatMap((t)=>t.kind==="word"?[pt(t.text)]:t.kind==="redirection"&&t.target?[pt(t.target)]:[]).flatMap(nw)}function nw(e){let t=I0(e);if(t===null)return[];let n=Buffer.from(t,"base64").toString("utf8");if(n===""||T0(n))return[];return Buffer.from(n,"utf8").toString("base64").replace(/=+$/g,"")===t.replace(/=+$/g,"")?[n]:[]}function T0(e){return Array.from(e).some((t)=>{let n=t.charCodeAt(0);return n<32||n===127})}function I0(e){if(e.length<8||!/^[A-Za-z0-9+/_-]+={0,2}$/.test(e))return null;if(/=/.test(e.replace(/=+$/g,"")))return null;let t=e.replace(/=+$/g,"");if(t.length%4===1)return null;return`${t.replace(/-/g,"+").replace(/_/g,"/")}${"=".repeat((4-t.length%4)%4)}`}function O0(e){let t=[],n={inSingle:!1,inDouble:!1,escaped:!1};for(let r=0;r<e.length;r++){let o=e[r];if(!o)break;if(go(o,n))continue;if(rw(e,r,n)){let i=z0(e,r+1);if(i!==null)t.push(i.body),r=i.endIndex;continue}if(!n.inSingle&&o==="`"){let i=N0(e,r);if(i!==null)t.push(i.body),r=i.endIndex}}return t}function z0(e,t){let n={inSingle:!1,inDouble:!1,escaped:!1},r=1;for(let o=t+1;o<e.length;o++){let i=e[o];if(!i)break;if(go(i,n))continue;if(rw(e,o,n)){r++,o++;continue}if(!n.inSingle&&!n.inDouble&&i===")"){if(r--,r===0)return{body:e.slice(t+1,o),endIndex:o}}}return null}function N0(e,t){let n=!1;for(let r=t+1;r<e.length;r++){let o=e[r];if(!o)break;if(n){n=!1;continue}if(o==="\\"){n=!0;continue}if(o==="`")return{body:e.slice(t+1,r),endIndex:r}}return null}function rw(e,t,n){return!n.inSingle&&e[t]==="$"&&e[t+1]==="("&&e[t+2]!=="("}function D0(e){let t=[],n=[],r=!1,o=!1,i=!1;for(let c=0;c<e.length;c++){let l=e[c];if(l===void 0)break;if(!i&&l==="--"){i=!0;continue}if(i){n.push(l);continue}let u=/^--([^=]+)(?:=(.*))?$/.exec(l);if(u!==null){let d=u[1]??"",f=u[2];if(d===e0)o=!0;if(n0.has(d))r=!0;if(f!==void 0){if(d===MC)t.push(f);continue}if(o0.has(d)){let m=e[c+1];if(d===MC&&m!==void 0)t.push(m);c++}continue}if(l.startsWith("-")&&l.length>1){let d=l.slice(1),f="",m="";for(let p=0;p<d.length;p++){let h=d[p]??"";if(t0.has(h))r=!0;if(r0.has(h)){f=h,m=d.slice(p+1);break}}if(f!=="")if(m.length>0){if(f===LC)t.push(m)}else{let p=e[c+1];if(f===LC&&p!==void 0)t.push(p);c++}continue}n.push(l)}let a=!r&&!o?n.slice(1):n;return[...t,...a]}function Jr(e){let t=e.findIndex((n)=>!ow(n)&&!/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(n));return t===-1?[]:[...e.slice(t)]}function ow(e){return e==="env"||e==="command"||e==="builtin"||e==="sudo"}var $0=new Set(["id_rsa.pub","id_ed25519.pub","id_ecdsa.pub"]),L0=".env.",M0=new Set([".env.example",".env.sample",".env.template",".env.defaults"]),W0=[".env.example.",".env.sample."];function F0(e){let t;try{t=new URL(e.trim())}catch{return!1}return t.protocol!=="file:"&&t.host!==""}function G0(e){return e.length>0&&!/\s/.test(e)}function Z0(e,t,n){try{let r=Ri(e,t,n);return r!==""&&Be.entryKind(r)!=="missing"}catch(r){if(r instanceof he)throw r;return!1}}var B0=new Set(["node_modules","__pycache__"]),U0=[["vendor","bundle"],["vendor","cache"]];function j0(e,t,n,r){if(F0(e))return null;let o=Zt(e,t,r);if(!o)return null;let i=re(o.split("/").pop()??""),s=re(o),a=()=>G0(i)||Z0(e,t,r);if(M0.has(i)||W0.some((d)=>i.startsWith(d)))return null;let c=re(J0(e,t,r));for(let d of ch){let f=`~/${d.suffixParts.join("/")}`;if((jC(s,f)||jC(c,f))&&Gt(d.id,n))return d.id}let l=H0(o,t,n,r);if(l)return l;if($0.has(i))return null;for(let d of ah)if(i===d.basename&&Gt(d.id,n))return d.id;if(i.startsWith(L0)&&Gt(dl.id,n)&&a())return dl.id;for(let d of lh)if(i.length>d.prefix.length&&i.startsWith(d.prefix)){let f=i.slice(d.prefix.length)[0];if((f==="-"||f==="_")&&Gt(d.id,n)&&a())return d.id}for(let d of uh)if(i.length>d.prefix.length&&i.startsWith(d.prefix)){if(i.slice(d.prefix.length)===d.suffix&&Gt(d.id,n))return d.id}if(K0(s))return null;if(!i.includes(".")&&Si.pattern.test(i)&&Gt(Si.id,n))return Si.id;let u=Y0(i,n);if(u)return u;return null}function H0(e,t,n,r){return ml.find((o)=>{if(!Gt(o.id,n))return!1;switch(o.id){case"secret.cli.claude-code":return ne(e,ie(process.env.CLAUDE_CONFIG_DIR,"~/.claude",t,r),[".credentials.json"]);case"secret.cli.claude-code.config":{let i=re(e).split("/");return ne(e,ie(process.env.CLAUDE_CONFIG_DIR,"~/.claude",t,r),["settings.json","settings.local.json"])||wi(e,"~/.claude.json",t,r)||i.at(-1)==="settings.local.json"&&i.at(-2)===".claude"||i.at(-1)===".mcp.json"}case"secret.cli.antigravity":return ne(e,Zt("~/.gemini/config",t,r),["hooks.json","mcp_config.json"]);case"secret.cli.codex":{let i=ie(process.env.CODEX_HOME,"~/.codex",t,r);return ne(e,i,["auth.json",".credentials.json"])||Ci(e,i,["secrets",".sandbox-secrets"])}case"secret.cli.codex.config":{let i=ie(process.env.CODEX_HOME,"~/.codex",t,r),s=re(e).split("/").at(-1)??"";return ne(e,i,["config.toml"])||s.endsWith(".config.toml")&&ne(e,i,[s])}case"secret.cli.gemini":return ne(e,be(ie(process.env.GEMINI_CLI_HOME,"~",t,r),".gemini"),["oauth_creds.json","mcp-oauth-tokens.json","a2a-oauth-tokens.json","gemini-credentials.json"]);case"secret.cli.gemini.config":{let i=re(e).split("/"),s=process.env.ProgramData?[be(ie(process.env.ProgramData,"",t,r),"gemini-cli")]:[];return ne(e,be(ie(process.env.GEMINI_CLI_HOME,"~",t,r),".gemini"),["settings.json","google_accounts.json"])||i.at(-1)==="settings.json"&&i.at(-2)===".gemini"||(process.env.GEMINI_CLI_SYSTEM_SETTINGS_PATH?.trim()?wi(e,process.env.GEMINI_CLI_SYSTEM_SETTINGS_PATH,t,r):!1)||["/Library/Application Support/GeminiCli","/etc/gemini-cli",...s].some((a)=>ne(e,Zt(a,t,r),["settings.json"]))}case"secret.cli.copilot-cli":{let i=ie(process.env.COPILOT_HOME,"~/.copilot",t,r);return ne(e,i,["config.json"])||Ci(e,i,["mcp-oauth-config","mcp-secrets"])}case"secret.cli.copilot-cli.config":return ne(e,ie(process.env.COPILOT_HOME,"~/.copilot",t,r),["mcp-config.json"]);case"secret.cli.kimi-code":{let i=ie(process.env.KIMI_CODE_HOME,"~/.kimi-code",t,r),s=ie(process.env.KIMI_SHARE_DIR,"~/.kimi",t,r);return ne(e,i,["server.token"])||Ci(e,i,["credentials"])||Ci(e,s,["credentials","mcp-oauth"])}case"secret.cli.kimi-code.config":{let i=["config.toml","mcp.json"],s=re(e).split("/");return s.at(-1)==="mcp.json"&&s.at(-2)===".kimi-code"||ne(e,ie(process.env.KIMI_CODE_HOME,"~/.kimi-code",t,r),i)||ne(e,ie(process.env.KIMI_SHARE_DIR,"~/.kimi",t,r),[...i,"config.json","config.json.bak"])}case"secret.cli.opencode":{let i=be(ie(process.env.XDG_DATA_HOME,"~/.local/share",t,r),"opencode"),s=re(e).split("/").at(-1)??"",a=process.env.OPENCODE_DB?.trim(),c=a&&a!==":memory:"?[a,`${a}-wal`,`${a}-shm`]:[];return ne(e,i,["auth.json","mcp-auth.json"])||/^opencode(-.+)?\.db(-wal|-shm)?$/.test(s)&&ne(e,i,[s])||c.some((l)=>wi(e,l,t,r))}case"secret.cli.opencode.config":{let i=process.env.OPENCODE_CONFIG_DIR?ie(process.env.OPENCODE_CONFIG_DIR,"~/.config/opencode",t,r):be(ie(process.env.XDG_CONFIG_HOME,"~/.config",t,r),"opencode"),s=process.env.ProgramData?[be(ie(process.env.ProgramData,"",t,r),"opencode")]:[],a=["opencode.json","opencode.jsonc"];return a.includes(re(e).split("/").at(-1)??"")||ne(e,i,a)||(process.env.OPENCODE_CONFIG?.trim()?wi(e,process.env.OPENCODE_CONFIG,t,r):!1)||["/Library/Application Support/opencode","/etc/opencode",...s].some((c)=>ne(e,Zt(c,t,r),a))}case"secret.cli.pi":return ne(e,ie(process.env.PI_CODING_AGENT_DIR,"~/.pi/agent",t,r),["auth.json"]);case"secret.cli.pi.config":return ne(e,ie(process.env.PI_CODING_AGENT_DIR,"~/.pi/agent",t,r),["models.json"]);case"secret.cli.amp":{let i=Zt("~",t,r);return[be(ie(process.env.XDG_DATA_HOME,"~/.local/share",t,r),"amp"),be(i,".local","share","amp")].some((a)=>ne(e,a,["secrets.json"]))||Ci(e,be(i,".amp"),["oauth"])}case"secret.cli.amp.config":{let i=["settings.json","settings.jsonc"],s=[be(ie(process.env.XDG_CONFIG_HOME,"~/.config",t,r),"amp"),be(Zt("~",t,r),".config","amp")],a=re(e).split("/");return s.some((c)=>ne(e,c,i))||a.at(-2)===".amp"&&i.includes(a.at(-1)??"")||(process.env.AMP_SETTINGS_FILE?.trim()?wi(e,process.env.AMP_SETTINGS_FILE,t,r):!1)}case"secret.cli.cursor":{let i=be(ie(process.env.XDG_CONFIG_HOME,"~/.config",t,r),"cursor"),s=be(ie(process.env.CURSOR_DATA_DIR,"~/.cursor",t,r),"projects");return ne(e,Zt("~/.cursor",t,r),["auth.json"])||ne(e,i,["auth.json"])||re(e).split("/").at(-1)==="mcp-auth.json"&&Bn(re(e),re(s))}case"secret.cli.cursor.config":{let i=re(e).split("/");return i.at(-1)==="mcp.json"&&i.at(-2)===".cursor"}default:return!1}})?.id??null}function ie(e,t,n,r){return Zt(e?.trim()?e:t,n,r)}function ne(e,t,n){return n.some((r)=>iw(e,be(t,r)))}function Ci(e,t,n){return n.some((r)=>Bn(re(e),re(be(t,r))))}function wi(e,t,n,r){return iw(e,Zt(t,n,r))}function iw(e,t){return re(e)===re(t)}function be(e,...t){return at([e,...t].filter(Boolean).join("/"))}function V0(e,t,n,r,o){if(n.length===0)return!1;let i=re(Ri(e,t,o));return n.some((s)=>Bn(i,re(Ri(s,r,o))))}function q0(e,t,n,r,o){if(n.length===0)return!1;let i=re(Ri(e,t,o));if(!i)return!1;let s=process.env.HOME??bh(),a=s?at(Y(s,Be,o)):"",c=re(a),l=process.env.CC_SAFETY_NET_HOME,u=re(l?at(Y(yl(l),Be,o)):a&&at(Y(`${a}/.cc-safety-net`,Be,o)));if(u&&Bn(i,u))return!1;return n.some((d)=>{let f=re(Ri(d,r,o));if(!f)return!1;if(c&&(c===f||c.startsWith(f.endsWith("/")?f:`${f}/`)))return!1;return Bn(i,f)})}function K0(e){let t=e.split("/");return t.some((n)=>B0.has(n))||U0.some(([n,r])=>t.some((o,i)=>o===n&&t[i+1]===r))}function Y0(e,t){let n=e.lastIndexOf("."),r=n>0&&n<e.length-1?e.slice(n+1):"";if(r==="")return null;for(let o of dh)if(r===o.extension&&Gt(o.id,t))return o.id;for(let o of mh)if(o.pattern.test(r)&&Gt(o.id,t))return o.id;return null}function re(e){return e.toLowerCase()}function Gt(e,t){return!t?.disabledRules?.includes(e)}function Zt(e,t,n){let{home:r,normalized:o}=vh(e,n);if(!o)return"";if(!r)return o;let i=Sh(o,r),s=gl(i)?i:at(yl(t,i)),a=at(Y(s,Be,n));if(!Bn(a,r)){if(gl(i))return a;return a===s?o:a}let c=a.slice(r.length);return c?`~${c}`:"~"}function jC(e,t){return e===t||e.startsWith(`${t}/`)}function J0(e,t,n){let{home:r,normalized:o}=vh(e,n);if(!o||!r)return"";let i=Sh(o,r),s=L$.normalize(gl(i)?i:at(yl(t,i))),a=at(process.env.HOME??bh()),c=(d)=>process.platform==="win32"?d.toLowerCase():d,l=[r,a].find((d)=>d!==""&&Bn(c(s),c(d)));if(l===void 0)return"";let u=s.slice(l.length);return u?`~${u}`:"~"}function Ri(e,t,n){let{home:r,normalized:o}=vh(e,n);if(!o)return"";let i=r?Sh(o,r):o;return at(Y(gl(i)?i:yl(t,i),Be,n))}function vh(e,t){let n=process.env.HOME??bh(),r=n?at(Y(n,Be,t)):"",o=at(X0(pt(e)));return{home:r,normalized:o}}function X0(e){if(!e.trim().toLowerCase().startsWith("file:"))return e;try{return W$(e)}catch{return e}}function Sh(e,t){if(e==="~")return t;if(e.startsWith("~/"))return be(t,e.slice(2));return e}function Q0(e){if(process.platform==="win32")return!0;return M$.parse(e).root.length>1}function at(e){let t=e.trim(),n=(Q0(t)?t.replace(/\\/g,"/"):t).replace(/\/{2,}/g,"/").replace(/^\.\//,"");if(n==="/")return n;return n.replace(/\/+$/g,"")}function Bn(e,t){return e===t||e.startsWith(t.endsWith("/")?t:`${t}/`)}function Un(e){return e.split(/[\\/]/).pop()?.replace(/\.exe$/i,"")??e}import{dirname as bl}from"node:path";var sw="Rulebook exceeds CC Safety Net's safe validation limits.",aw="Additional rulebook validation errors were omitted.",ct=Object.freeze({maxAllowedCommands:1024,maxRules:1024,maxTests:2048,maxBlockArgsPerRule:1024,maxTotalBlockArgs:16384,maxStringCodeUnits:1048576,maxAggregateStringCodeUnits:4194304,maxFixtureCommandCodeUnits:131072,maxValidationErrors:64});function cw(e){if(_h(e.allowed_commands,ct.maxAllowedCommands)||_h(e.rules,ct.maxRules)||_h(e.tests,ct.maxTests))return!1;let{maxAggregateStringCodeUnits:t,maxTotalBlockArgs:n}=ct,r=(o,i=!1)=>{if(typeof o!=="string")return!0;if(o.length>ct.maxStringCodeUnits||i&&o.length>ct.maxFixtureCommandCodeUnits||o.length>t)return!1;return t-=o.length,!0};if(!r(e.name)||!r(e.version)||!r(e.description)||!r(e.author)||!r(e.migrated_from))return!1;if(Array.isArray(e.allowed_commands)){for(let o of e.allowed_commands)if(!r(o))return!1}if(Array.isArray(e.rules))for(let o of e.rules){if(!o||typeof o!=="object")continue;let i=o;if(!r(i.name)||!r(i.command)||!r(i.subcommand)||!r(i.reason)||!r(i.intent))return!1;if(!Array.isArray(i.block_args))continue;if(i.block_args.length>ct.maxBlockArgsPerRule||i.block_args.length>n)return!1;n-=i.block_args.length;for(let s of i.block_args)if(!r(s))return!1}if(Array.isArray(e.tests))for(let o of e.tests){if(!o||typeof o!=="object")continue;let i=o;if(!r(i.command,!0)||!r(i.expect)||!r(i.rule))return!1}return!0}function _h(e,t){return Array.isArray(e)&&e.length>t}function eL(e){if(!tL(e))return{errors:["Rulebook must be an object"],ruleNames:new Set};if(!cw(e))return{errors:[sw],ruleNames:new Set};let t=vC().safeParse(e),n=[...e.rulebook_version===1?[]:["rulebook_version must be 1"],...t.success?[]:Kr(t.error.issues,": ",": ")];return{errors:n.length>ct.maxValidationErrors?[...n.slice(0,ct.maxValidationErrors),aw]:n,ruleNames:new Set(fh(e).map((r)=>r.toLowerCase()))}}function xh(e){let t=eL(e);if(t.errors.length>0)throw Error(t.errors.join("; "));return e}function tL(e){return!!e&&typeof e==="object"&&!Array.isArray(e)}function Ch(e){if(Di(e.spec))return oL(e);return rL(e)}function rL(e){if(!lt.test(e.spec))return`Local rulebook sources must be bare names matching ${lt}: ${e.spec}`;if(e.kind!=="local-directory")return`lock entry for ${e.spec} must use local-directory kind`;if(e.path===e.spec&&e.name===e.spec)return null;return`lock entry for ${e.spec} does not match local source identity`}function oL(e){let t=Xr(e.spec);if(t)return t;let n=Ni(e.spec);if(e.kind!=="github")return`lock entry for ${e.spec} must use github kind`;if(e.owner===n.owner&&e.repo===n.repo&&e.ref===n.ref&&e.path===n.path&&e.name===n.name)return null;return`lock entry for ${e.spec} does not match GitHub source identity`}function lw(e){let t=typeof e==="string"?e:e.path;try{let n=mn(typeof e==="string"?zi(e):e);if(n===null)return{lock:null,errors:[]};let r=JSON.parse(n);if(!r||typeof r!=="object")return{lock:null,errors:[`malformed lockfile ${t}: must be an object`]};let o=r;if(o.version!==1||!Array.isArray(o.rulebooks))return{lock:null,errors:[`malformed lockfile ${t}`]};let i=SC().safeParse(o),s=o.rulebooks.flatMap((c,l)=>{let u=i.success?[]:i.error.issues.filter((f)=>f.path[1]===l);if(u.length>0)return Kr(u).map((f)=>`${t}: ${f}`);let d=Ch(c);return d?[`${t}: rulebooks[${l}]: ${d}`]:[]});if(!i.success||s.length>0)return{lock:null,errors:[`malformed lockfile ${t}`,...s]};return{lock:{version:1,rulebooks:i.data.rulebooks.map((c)=>{if(c.kind==="local-directory")return{spec:c.spec,kind:c.kind,path:c.path,name:c.name,version:c.version,digest:c.digest};let l={spec:c.spec,kind:c.kind,owner:c.owner,repo:c.repo,ref:c.ref,commit:c.commit,path:c.path,name:c.name,version:c.version,digest:c.digest};return typeof c.display_ref==="string"&&c.display_ref!==""?{...l,display_ref:c.display_ref}:l})},errors:[]}}catch(n){if(n instanceof ae)return{lock:null,errors:[n.message]};return{lock:null,errors:["malformed lockfile"]}}}import{createHash as iL}from"node:crypto";var Zj=Object.freeze({timeoutMs:15000,metadataBytes:524288,commitBytes:262144,treeBytes:16777216,rawBytes:4194304});function uw(e){return`sha256:${iL("sha256").update(e).digest("hex")}`}function gw(e={}){let t=Bh(e),n=!1;try{n=Dh(t.userConfigTarget,t.projectConfigTarget)}catch(f){if(f instanceof ae)return lL(t,f.message);throw f}let r=ph(t.userConfigTarget),o=n?{config:null,errors:[]}:ph(t.projectConfigTarget),i=pw(t.userConfigPath,r.errors),s=pw(t.projectConfigPath,o.errors),a=new Set,c=r.config?dw(r.config,t.userLockPath,bl(t.userConfigPath),e,"user",t.userScope,a):Pi(),l=o.config?dw(o.config,t.projectLockPath,bl(t.projectConfigPath),e,"project",t.projectScope,a):Pi(),u=r.config?.overrides??{},d=o.config?.overrides??{};return{rules:[...mw(c.rules,u),...mw(l.rules,d)],transparent_wrappers:aL(r.config,o.config),rulebooks:[...c.rulebooks,...l.rulebooks],errors:[...i,...s,...c.errors,...l.errors],warnings:[...c.warnings,...l.warnings,...c.canValidateOverrides?fw(u,c.knownRuleIds,t.userConfigPath):[],...c.canValidateOverrides?cL(d,c.knownRuleIds,t.projectConfigPath):[],...l.canValidateOverrides?fw(d,l.knownRuleIds,t.projectConfigPath):[]],userConfig:r.config??void 0,projectConfig:o.config??void 0,...t}}function dw(e,t,n,r,o,i=Bt(bl(bl(n)),o==="user"?"user policy":"project policy"),s=new Set){let a;try{a=At(i,t)}catch(b){if(b instanceof ae)return{...Pi(),errors:[b.message],canValidateOverrides:!1};throw b}let c=lw(a);if(c.errors.length>0)return{...Pi(),errors:c.errors,canValidateOverrides:!1};let l=c.lock;if(!l&&e.rules.length>0)return{...Pi(),errors:[`missing lockfile ${t}; run ${Ht}`],canValidateOverrides:!1};let u=l?.rulebooks??[],d=new Map(u.map((b)=>[b.spec,b])),f=[],m=[],p=e.rules.flatMap((b)=>{let y=d.get(b);if(!y)return f.push(`missing lock entry for ${b}; run ${Ht}`),[];let E=sL(y,n,r,i);if(E.errors.length>0||!E.rulebook)return f.push(...E.errors),[];let w=E.rulebook;if(s.has(w.name))return m.push(`duplicate active rulebook name "${w.name}" for ${b}; keeping the first and ignoring this one, so its rules are not active; rename one of them, then run ${Ht}`),[];return s.add(w.name),[{rules:w.rules.map((R)=>({...R,name:`${w.name}/${R.name}`})),rulebook:{source:o,spec:y.spec,name:w.name,version:w.version,rules:w.rules.map((R)=>`${w.name}/${R.name}`)}}]}),h=p.flatMap((b)=>b.rules);return{rules:h,rulebooks:p.map((b)=>b.rulebook),entries:u,knownRuleIds:new Set(h.map((b)=>b.name)),errors:f,warnings:m,canValidateOverrides:f.length===0}}function sL(e,t,n,r){let o=Pl(e,kl(t,n)),i;try{i=mn(At(r,o))}catch(a){if(a instanceof ae)return{rulebook:null,errors:[a.message]};throw a}if(i===null)return{rulebook:null,errors:[`missing cache entry for ${e.spec}; run ${Ht}`]};if(uw(i)!==e.digest)return{rulebook:null,errors:[`cache digest mismatch for ${e.spec}; run ${Ht}`]};let s;try{s=JSON.parse(i)}catch{return{rulebook:null,errors:[`invalid cached rulebook for ${e.spec}`]}}try{xh(s)}catch(a){return{rulebook:null,errors:[`invalid cached rulebook for ${e.spec}: ${a instanceof Error?a.message:"invalid rulebook"}`]}}return{rulebook:s,errors:[]}}function aL(e,t){return[...new Set([...e?.transparent_wrappers??[],...t?.transparent_wrappers??[]])]}function mw(e,t){return e.flatMap((n)=>{let r=t[n.name];if(r==="off")return[];if(r&&typeof r==="object")return[{...n,intent:r.intent??n.intent,reason:r.reason}];return[n]})}function fw(e,t,n){return Object.keys(e).filter((r)=>!t.has(r)).map((r)=>`unknown override key "${r}" in ${n}; only that override is ignored and other overrides and rules keep their configured state; correct or remove it in that file`)}function cL(e,t,n){return Object.keys(e).filter((r)=>t.has(r)).map((r)=>`project override cannot target user-scoped rule "${r}" in ${n}; only that override is ignored and the rule keeps its user-configured state; remove it from that file`)}function pw(e,t){return t.map((n)=>n.startsWith("Unable to access ")?n:`${e}: ${n}`)}function lL(e,t){return{rules:[],transparent_wrappers:[],rulebooks:[],errors:[t],warnings:[],userConfigPath:e.userConfigPath,projectConfigPath:e.projectConfigPath,userLockPath:e.userLockPath,projectLockPath:e.projectLockPath}}function Pi(){return{rules:[],rulebooks:[],entries:[],knownRuleIds:new Set,errors:[],warnings:[],canValidateOverrides:!0}}function hw(e={}){let t=gw(e),n=kC(e),r={rules:t.rules,transparentWrappers:t.transparent_wrappers,safety:n.safety,worktreeMode:n.worktreeMode,destructiveCommandProtectionEnabled:n.destructiveCommandProtectionEnabled,destructiveCommandRuleOverrides:n.destructiveCommandRuleOverrides,destructiveCommandAllowPaths:n.destructiveCommandAllowPaths,secretProtection:{enabled:n.secretProtection.enabled??!0,disabledRules:n.secretProtection.disabledRules??[],denyPaths:n.secretProtection.denyPaths,allowPaths:n.secretProtection.allowPaths??[]}},o={...t.userConfig?.overrides??{},...t.projectConfig?.overrides??{}},i=Object.freeze(Object.fromEntries(r.rules.map((s)=>{let a=t.rulebooks.find((l)=>l.rules.includes(s.name)),c=o[s.name];return[s.name,Object.freeze({id:s.name,...a?{rulebook:Object.freeze({name:a.name,version:a.version}),...fL(a.spec)?{source:a.spec}:{}}:{},...c&&typeof c==="object"?{override:Object.freeze({type:"reason",reason:c.reason})}:{}})]})));return pL(r,uL(t,n),i)}function uL(e,t){let n=mL(t);if(e.errors.length===0&&e.warnings.length===0&&!n)return;return{diagnostics:[...e.errors,...e.warnings,...t.errors],reason:gL(e.errors.length>0?dL(e.errors):void 0,e.warnings.length>0?wh(e.warnings.join("; ")):void 0,n)}}function dL(e){return`${wh(e.join("; "))} Those rule sources are not active; every other rule and all built-in protections still apply`}function mL(e){if(e.errors.length===0)return;let t=e.fallback==="salvaged"?"the salvaged policy with protective defaults":"built-in protective defaults";return`invalid policy config: ${e.errors.join("; ")}. Enforcing ${t}; the invalid values are not active. Fix the policy file manually`}function fL(e){return/^(?:[A-Za-z0-9_.-]+$|https:\/\/github\.com\/|github:|gh:|[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+(?:#|$))/.test(e)}function pL(e,t,n=Object.freeze({})){let r=yw(structuredClone(e));if(!t)return Object.freeze({state:"ready",policy:r,diagnostics:Object.freeze([]),ruleMetadata:n});return Object.freeze({state:"degraded",policy:r,diagnostics:Object.freeze([...t.diagnostics]),reason:t.reason,ruleMetadata:n})}function yw(e){if(typeof e!=="object"||e===null)return e;for(let t of Object.values(e))yw(t);return Object.freeze(e)}function gL(...e){return wh(e.filter((t)=>!!t).join("; "))}function wh(e){return/[.!?]$/.test(e)?e:`${e}.`}class un extends Error{stage;evaluation;name="GuardEvaluationError";constructor(e,t,n){super(`CC Safety Net ${e} dependency failed`,{cause:n});this.stage=e;this.evaluation=t}}var hL={findPolicyMutation:NC,findGitMetadataMutation:ov,resolveGitMetadata:Su,loadPolicySnapshot:hw,findSensitiveTarget:YC,analyzeCommand:m_,getModes:Sd};function bw(e,t={}){let n={...hL,...t.dependencies},r=vL(e),o=ki(e)?e.command:r,i=jn("policy-protection",o,()=>zs(e,t.factParserDependencies)),s=Ne(i,"declared-command");if(ki(e)&&e.command?.trim()&&s?.program.status==="limited")return{stage:"command-analysis",decision:{kind:"deny",reason:It,intent:"stop_and_explain",evidence:[{kind:"command",command:e.command,segment:e.command}]}};if(Ne(i,"input-candidate")?.program.status==="limited")return{stage:"command-validation",decision:{kind:"deny",reason:iy,intent:"stop_and_explain",evidence:[]}};let a=jn("policy-protection",o,()=>n.resolveGitMetadata(e.context.executionCwd)),c=jn("policy-protection",o,()=>n.findPolicyMutation(i));if(c){let b=o??c.target;return{stage:"policy-protection",decision:{kind:"deny",reason:zC,intent:"hard_stop",evidence:[{kind:"command",command:b,segment:c.target}]}}}let l=jn("policy-protection",o,()=>n.findGitMetadataMutation(i,a));if(l){let b=o??l.target;return{stage:"policy-protection",decision:{kind:"deny",reason:He,intent:"hard_stop",evidence:[{kind:"command",command:b,segment:l.target}]}}}let u=jn("config-load",o,()=>n.loadPolicySnapshot({...t.policyOptions,cwd:e.context.configCwd})),d=u.policy,f=n.getModes(d),m={level:f.effectiveLevel,...yL(u)},p=d.secretProtection.enabled===!1?null:jn("secret-protection",o,()=>n.findSensitiveTarget(i,d.secretProtection,{strict:ki(e)?f.strict:void 0}));if(p){let b=o??p.target;return{stage:"secret-protection",...m,decision:{kind:"deny",reason:HC,intent:"hard_stop",ruleId:p.ruleId,evidence:[{kind:"command",command:b,segment:p.target}]}}}if(!ki(e))return{stage:"non-command",...m,decision:{kind:"allow"}};if(!e.command||e.command.trim()==="")return{...Eh("command-validation",o),...m};let h=jn("command-analysis",o,()=>n.analyzeCommand(e.command,{cwd:e.context.executionCwd,shell:e.route.shell,policySnapshot:u,environment:Ot(),protectedGitMetadata:a,effectiveCapabilities:f.capabilities,strict:f.strict,paranoidRm:f.paranoidRm,paranoidInterpreters:f.paranoidInterpreters,worktreeMode:f.worktreeMode},bL(i),i.store));if(h)return{stage:"command-analysis",...m,decision:h};return{stage:"command-analysis",...m,decision:{kind:"allow"}}}function yL(e){if(e.state==="ready")return{};return{configFallback:{reason:e.reason}}}function bL(e){return Ne(e,"declared-command")?.program}function vL(e){try{return vo(e.input)}catch(t){let n=ki(e)?e.command:void 0;throw new un("policy-protection",Eh("policy-protection",t instanceof Lt?void 0:n,t),t)}}function jn(e,t,n){try{return n()}catch(r){throw new un(e,Eh(e,r instanceof Lt?void 0:t,r),r)}}function Eh(e,t,n){let r=n instanceof he||n instanceof ft;return{stage:e,decision:{kind:"deny",reason:r?sy:Wi,intent:"stop_and_explain",evidence:t?[{kind:"command",command:t,segment:t}]:[]}}}function ki(e){return e.route.kind==="command"}function Sw(e,t){try{let n=bw(e,t.guard);return vw(e,n,t),n}catch(n){if(!(n instanceof un))throw n;throw vw(e,n.evaluation,t,!(n.cause instanceof Lt),{stage:n.stage,errorCode:SL(n.cause)}),n}}function vw(e,t,n,r=!0,o){ey(Qh(e,t,n.guard?.auditAllowed??!1,r,o),n.audit.getSessionId,{agent:n.audit.agent,shape:n.audit.shape,homeDir:n.audit.homeDir})}function SL(e){if(e instanceof he)return"path-canonicalization-limit";if(e instanceof Lt)return"tool-input-limit";if(e instanceof ft)return"structural-shell-syntax-limit";return"unexpected-error"}var xw="exec",_L=new Set(["auto","gateway"]);function Cw(e){e.on("before_tool_call",xL(e),{matcher:[xw],priority:50})}function xL(e,t={}){return(n,r)=>{if(r.abortSignal?.aborted)return Rh(zl());let o=CL(n,r,e);if(!o)return;let i=()=>r.sessionId??r.sessionKey;if("malformed"in o)return ty(o.denial,i,{agent:"openclaw",toolName:o.denial.toolName,cwd:o.cwd}),Rh(o.denial);try{let s=Sw(o,{guard:{auditAllowed:bd(),dependencies:t.guardDependencies},audit:{agent:"openclaw",getSessionId:i}});return _w(s,!0)}catch(s){if(!(s instanceof un))throw s;if(nn(me.debug))console.error(`CC Safety Net debug: openclaw before_tool_call analysis failed: ${dy(s.cause)}`);return _w(s.evaluation,!0)}}}function CL(e,t,n){if(!e||typeof e!=="object")return Hn(null);let r=e.toolName;if(typeof r!=="string"||r.trim()==="")return Hn(null);if(r!==xw)return;if(e.toolKind!==void 0)return;let o=e.params;if(!o||typeof o!=="object"||Array.isArray(o))return Hn(null,r);let i=o,s=i.command;if(typeof s!=="string"||s.trim()==="")return Hn(null,r);if(i.host!==void 0&&!_L.has(i.host))return Hn(null,r,s);let a=wL(n,t.agentId);if(!a)return Hn(null,r,s);let c=EL(a,i);if(!c)return Hn(a,r,s,typeof i.workdir==="string"?i.workdir:void 0);return ma(r,i,{kind:"command",shell:"auto"},{configCwd:a,executionCwd:c},s)}function wL(e,t){if(typeof t!=="string"||t.trim()==="")return;try{let n=e.runtime.agent.resolveAgentWorkspaceDir(e.config,t);if(typeof n!=="string"||n.trim()==="")return;return Mi(".",[n])}catch{return}}function EL(e,t){if(!Object.hasOwn(t,"workdir")||t.workdir===void 0)return e;let n=t.workdir;if(typeof n!=="string"||n.trim()==="")return;return Mi(n,[e])}function Hn(e,t,n,r){return{malformed:!0,denial:zl({command:n,segment:r,toolName:t}),cwd:e}}function _w(e,t){let n=ly(e,{includeEvidence:t});return n?Rh(n):void 0}function Rh(e){return{block:!0,blockReason:uy(e)}}var L2={...Ah,register:Cw};export{L2 as default};