cc-safety-net 2.0.3 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  // cc-safety-net managed OpenClaw plugin. Do not edit. Reinstall with: npx -y cc-safety-net install --openclaw
2
- // version: 2.0.3
2
+ // version: 2.0.5
3
3
  var NM=Object.defineProperty;var FM=($)=>$;function VM($,J){this[$]=FM.bind(null,J)}var B2=($,J)=>{for(var Q in J)NM($,Q,{get:J[Q],enumerable:!0,configurable:!0,set:VM.bind(J,Q)})};var OK={id:"cc-safety-net",name:"CC Safety Net",description:"Block destructive commands and secret-file access before OpenClaw runs a tool."};import{randomBytes as ZO}from"node:crypto";import{appendFileSync as LO,mkdirSync as MO}from"node:fs";import{homedir as OO,userInfo as NO}from"node:os";import{isAbsolute as FO,join as RJ}from"node:path";var _M=[/\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 j0($){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 DM(J)}function DM($){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 _M)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 SK,readdirSync as eM,readFileSync as fK,rmdirSync as $O,statSync as TK,unlinkSync as JO,utimesSync as QO,writeFileSync as XO}from"node:fs";import{dirname as YO,join as l2}from"node:path";var R6=30,HJ=1,ZJ=365;function I6($){if(typeof $!=="number"||!Number.isInteger($))return 30;if($<1)return 1;return $>365?365:$}import{homedir as yM}from"node:os";import{dirname as l0,isAbsolute as xM,join as p0,relative as uM,resolve as P0,sep as mM}from"node:path";import{closeSync as zM,constants as NK,fstatSync as RM,fsyncSync as DE,lstatSync as FK,mkdirSync as zE,openSync as IM,readdirSync as RE,readFileSync as jM,realpathSync as j6,renameSync as IE,rmdirSync as jE,statSync as bM,unlinkSync as bE,writeFileSync as PE}from"node:fs";import{isAbsolute as VK,join as _K,normalize as PM,parse as AM,relative as LJ,resolve as MJ,sep as OJ}from"node:path";var EM=Symbol("PolicyFilesystemScope"),CM=Symbol("PolicyFilesystemTarget"),SM=NK.O_NOFOLLOW??0;class W1 extends Error{constructor($){super(`Unable to access ${$} filesystem safely.`);this.name="PolicyFilesystemError"}}function m0($,J){return{[EM]:!0,root:MJ($),label:J}}function DK($,J){let Q=PM(J);if(J===""||VK(J)||Q===".."||Q.startsWith(`..${OJ}`))throw new W1($.label);return{[CM]:!0,scope:$,relativePath:Q,path:_K($.root,Q)}}function b0($,J){let Q=LJ($.root,MJ(J));return DK($,Q)}function P6($,J="rules policy"){let Q=MJ($),X=AM(Q).dir;return DK(m0(X,J),LJ(X,Q))}function q2($){try{if(!b6($,!1).exists)return null;let Q=IM($.path,NK.O_RDONLY|SM);try{let X=RM(Q);if(!X.isFile())throw new W1($.scope.label);let Y=jM(Q,"utf-8"),W=FK($.path);if(!W.isFile()||W.isSymbolicLink()||X.dev!==W.dev||X.ino!==W.ino)throw new W1($.scope.label);return b6($,!1),Y}finally{zM(Q)}}catch(J){vM($.scope.label,J)}}function zK($,J){if($.path===J.path)return!0;try{if(!b6($,!1).exists||!b6(J,!1).exists)return!1;return j6($.path)===j6(J.path)}catch(Q){if(Q instanceof W1)throw Q;throw new W1($.scope.label)}}function b6($,J,Q="file"){let X=TM($.scope);if(!X)return{exists:!1};let Y=$.relativePath.split(OJ);for(let W of Y.keys()){let K=_K($.scope.root,...Y.slice(0,W+1)),B=RK(K);if(!B){if(W===Y.length-1&&J)return{exists:!1};return{exists:!1}}if(B.isSymbolicLink())throw new W1($.scope.label);if(W<Y.length-1&&!B.isDirectory())throw new W1($.scope.label);if(W===Y.length-1&&(Q==="file"?!B.isFile():!B.isDirectory()))throw new W1($.scope.label);wM(X,j6(K),$.scope.label)}return{exists:!0}}function TM($){if(!RK($.root))return null;if(!bM($.root).isDirectory())throw new W1($.label);return j6($.root)}function wM($,J,Q){let X=LJ($,J);if(X===".."||X.startsWith(`..${OJ}`)||VK(X))throw new W1(Q)}function RK($){try{return FK($)}catch(J){if(fM(J)&&J.code==="ENOENT")return null;throw J}}function vM($,J){if(J instanceof W1)throw J;throw new W1($)}function fM($){return $ instanceof Error&&"code"in $}var Y0=/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/,NJ="rulebook.json",FJ=".cc-safety-net/rules";var IK=/^([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)#(.+)$/;var hM=/^[A-Za-z0-9._-]+$/,kM=".cc-safety-net/rules".replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),gM="rulebook.json".replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),jK=new RegExp(`^${kM}/(${Y0.source.slice(1,-1)})/${gM}$`);function bK($){return`.cc-safety-net/rules/${$}/rulebook.json`}function o4($){if(E6($))try{return A6($),null}catch(J){return J instanceof Error?J.message:String(J)}return Y0.test($)?null:`Local rulebook sources must be bare names matching ${Y0}: ${$}`}function A6($){if($.startsWith("github:"))throw Error(`Invalid rulebook source: ${$}`);let J=$.match(IK);if(!J?.[1]||!J[2]||!J[3])throw Error(`Invalid GitHub rulebook source: ${$}`);let[Q,X,...Y]=J[3].split("/");if(!Q||!hM.test(Q))throw Error(`GitHub rulebook refs must be a single path segment: ${$}`);if(!X||Y.length>0||!Y0.test(X))throw Error(`GitHub rulebook sources must be owner/repo#ref/<rulebook-name>: ${$}`);return{owner:J[1],repo:J[2],ref:Q,path:bK(X),name:X}}function E6($){return IK.test($)}var AK="rule.json",C6="policy.json",lM="rule.lock";var EK=".cc-safety-net",pM="rules",PK="cache",cM="CC_SAFETY_NET_HOME",c0="`cc-safety-net rule sync`";function dM($){return P0($??process.cwd(),FJ)}function rM($){return p0(dM($),AK)}function U2($){return $?.userConfigDir??($?.userConfigPath?l0($.userConfigPath):p0(iM(),pM))}function iM(){let $=process.env[cM];return $?P0($):p0(yM(),EK)}function oM($){return p0(U2($),AK)}function n4($){return p0(l0($),lM)}function CK($){let J=$.userConfigPath??oM($),Q=$.projectConfigPath??rM($.cwd),X=nM(J,$),Y=sM(Q,$);return{userConfigPath:J,projectConfigPath:Q,userLockPath:n4(J),projectLockPath:n4(Q),userScope:X,projectScope:Y,userConfigTarget:b0(X,J),projectConfigTarget:b0(Y,Q),userLockTarget:b0(X,n4(J)),projectLockTarget:b0(Y,n4(Q))}}function nM($,J){let Q=J.userConfigPath?l0(l0(P0(J.userConfigPath))):l0(P0(J.userConfigDir??U2(J)));return m0(Q,"user policy")}function sM($,J){let Q=P0(J.cwd??process.cwd()),X=P0($),Y=uM(Q,X);if(Y!==".."&&!Y.startsWith(`..${mM}`)&&!xM(Y))return m0(Q,"project policy");return m0(l0(l0(X)),"project policy")}function VJ($,J){let Q=$.digest.startsWith("sha256:")?$.digest.slice(7):$.digest;return p0(tM(J),"rulebooks",`${aM($)}--${Q.slice(0,12)}`,NJ)}function _J($,J){let Q=J;return{cacheConfigDir:$,cwd:J.cwd,global:Q.global}}function aM($){return($.kind==="github"&&$.display_ref?`${$.owner}/${$.repo}#${$.display_ref}/${$.name}`:$.spec).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"rulebook"}function tM($){let J=$?.cacheConfigDir??U2($),Q=$;if(Q&&!Q.global&&Q.cwd&&P0(J)===P0(Q.cwd))return p0(P0(Q.cwd),EK,PK);return p0(l0(J),PK)}var zJ=86400000,WO=".last-prune",KO=/^\d{4}-\d{2}$/,BO=/^((\d{4}-\d{2})-\d{2})-.+\.jsonl$/,wK=($)=>Math.floor($/zJ);function qO($){try{let J=l2(YO(U2($)),C6),Q=JSON.parse(fK(J,"utf-8"));return I6(Q?.audit?.retention_days)}catch{return R6}}function hK($,J=()=>new Date){try{let Q=J().getTime();if(!TK($,{throwIfNoEntry:!1})?.isDirectory())return;let X=l2($,WO),Y=TK(X,{throwIfNoEntry:!1})?.mtimeMs;if(Y!==void 0&&wK(Y)===wK(Q))return;let W=Q-qO()*zJ,K=new Date(Q).toISOString().slice(0,7);for(let B of DJ($)){if(B.isDirectory()){UO(l2($,B.name),W,K);continue}if(B.isFile()&&B.name.endsWith(".jsonl"))GO(l2($,B.name),W)}XO(X,"",{mode:384}),QO(X,Q/1000,Q/1000)}catch{}}function UO($,J,Q){for(let X of DJ($)){if(!X.isDirectory()||!KO.test(X.name))continue;let Y=l2($,X.name);for(let W of DJ(Y)){if(!W.isFile())continue;let K=BO.exec(W.name);if(!K||K[2]!==X.name)continue;let B=Date.parse(`${K[1]}T00:00:00.000Z`)+zJ;if(!Number.isFinite(B)||B>=J)continue;kK(l2(Y,W.name))}if(X.name!==Q)vK(Y)}vK($)}function GO($,J){try{let Q=SK($);if(Q.mtimeMs>=J)return;let X=fK($,"utf-8").split(`
4
- `).filter((Y)=>Y.trim()).map(HO);if(X.length===0)return;if(X.some((Y)=>Y===void 0||Y>=J))return;if(SK($).mtimeMs!==Q.mtimeMs)return;kK($)}catch{}}function HO($){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 DJ($){try{return eM($,{withFileTypes:!0,encoding:"utf8"})}catch{return[]}}function kK($){try{JO($)}catch{}}function vK($){try{$O($)}catch{}}var VO="2.0.3",_O=1e4,DO=2000,zO=256,RO=32768;function IO($){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 jO($){return($??"").replace(/[^A-Za-z0-9]/g,"-").slice(0,180)||"no-cwd"}function IJ($,J,Q,X,Y,W={}){let K=IO($);if(!K)return;let B=W.homeDir??gK();if(!B)return;let q=bO(B);if(!q)return;try{let U=(W.now??(()=>new Date))().toISOString(),G=S6(j0(J),_O),H=S6(j0(Q),DO),L=W.toolName?S6(j0(W.toolName),zO):void 0,Z=Y===null?void 0:S6(j0(Y),RO),M=RJ(q,jO(Z?.value??null),U.slice(0,7));MO(M,{recursive:!0,mode:448});let O=RJ(M,`${U.slice(0,10)}-${K}.jsonl`),V={ts:U,id:(W.createId??(()=>ZO(8).toString("hex")))(),v:VO,sessionId:K,decision:W.decision??"deny",agent:W.agent,shape:W.shape,level:W.level,configFallback:W.configFallback,toolName:L?.value,command:G.value,segment:H.value,...G.truncated||H.truncated||L?.truncated||Z?.truncated?{truncated:!0}:{},reason:X,ruleId:W.ruleId,intent:W.intent,failureStage:W.failureStage,errorCode:W.errorCode,cwd:Z?.value??null};LO(O,`${JSON.stringify(V)}
4
+ `).filter((Y)=>Y.trim()).map(HO);if(X.length===0)return;if(X.some((Y)=>Y===void 0||Y>=J))return;if(SK($).mtimeMs!==Q.mtimeMs)return;kK($)}catch{}}function HO($){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 DJ($){try{return eM($,{withFileTypes:!0,encoding:"utf8"})}catch{return[]}}function kK($){try{JO($)}catch{}}function vK($){try{$O($)}catch{}}var VO="2.0.5",_O=1e4,DO=2000,zO=256,RO=32768;function IO($){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 jO($){return($??"").replace(/[^A-Za-z0-9]/g,"-").slice(0,180)||"no-cwd"}function IJ($,J,Q,X,Y,W={}){let K=IO($);if(!K)return;let B=W.homeDir??gK();if(!B)return;let q=bO(B);if(!q)return;try{let U=(W.now??(()=>new Date))().toISOString(),G=S6(j0(J),_O),H=S6(j0(Q),DO),L=W.toolName?S6(j0(W.toolName),zO):void 0,Z=Y===null?void 0:S6(j0(Y),RO),M=RJ(q,jO(Z?.value??null),U.slice(0,7));MO(M,{recursive:!0,mode:448});let O=RJ(M,`${U.slice(0,10)}-${K}.jsonl`),V={ts:U,id:(W.createId??(()=>ZO(8).toString("hex")))(),v:VO,sessionId:K,decision:W.decision??"deny",agent:W.agent,shape:W.shape,level:W.level,configFallback:W.configFallback,toolName:L?.value,command:G.value,segment:H.value,...G.truncated||H.truncated||L?.truncated||Z?.truncated?{truncated:!0}:{},reason:X,ruleId:W.ruleId,intent:W.intent,failureStage:W.failureStage,errorCode:W.errorCode,cwd:Z?.value??null};LO(O,`${JSON.stringify(V)}
5
5
  `,{encoding:"utf-8",mode:384}),hK(q,W.now)}catch{}}function S6($,J){return{value:$.slice(0,J),truncated:$.length>J}}function gK($=process.env.CC_SAFETY_NET_AUDIT_HOME||process.env.HOME){let J=$||OO()||NO().homedir;return J&&FO(J)?J:null}function bO($=gK()){return $?RJ($,".cc-safety-net","logs"):null}function xK($,J,Q,X=!0,Y){if(J.decision.kind==="allow"){if(!Q||$.route.kind!=="command")return;let B=yK($);return{decision:"allow",command:B,segment:B,reason:"allowed",cwd:$.context.executionCwd,toolName:$.toolName,level:J.level,...J.configFallback?{configFallback:!0}:{}}}let W=J.decision.evidence.find((B)=>B.kind==="command"),K=W?.command??(X?yK($):"");return{decision:"deny",command:K,segment:W?.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:Y?.stage,errorCode:Y?.errorCode}}function yK($){return"command"in $?$.command??"":""}function uK($,J,Q){if(!$)return;let X;try{X=J()}catch{return}if(typeof X!=="string"||!X.trim())return;IJ(X,$.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 mK($,J,Q){let X;try{X=J()}catch{return}if(typeof X!=="string"||!X.trim())return;IJ(X,$.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 vO,statSync as fO}from"node:fs";import{isAbsolute as pK,relative as hO,resolve as kO,sep as gO}from"node:path";import{dirname as PO,isAbsolute as AO,parse as EO,sep as CO}from"node:path";function G2($,J=process.platform){if(J!=="win32")return!1;return($[0]==="/"||$[0]==="\\")&&($[1]==="/"||$[1]==="\\")}function d0($,J,Q){if(G2(J))throw Error("Unsupported Windows namespace path");let X=AO(J)?TO(J):"",Y=X||$;for(let W of wO(X?J.slice(X.length):J)){if(W===""||W===".")continue;if(W===".."){Y=PO(Y);continue}let K=SO(Y,W),B=Q.entryKind(K),q=B==="symlink"?Q.realpath(K):K;if(B==="missing"||q===null)throw Error(`Cannot resolve path component: ${K}`);Y=q}return Y}function SO($,J){return $.endsWith("/")||$.endsWith("\\")?`${$}${J}`:`${$}${CO}${J}`}function TO($){return EO($).root}function wO($){let J=process.platform==="win32"?/[\\/]+/:/\/+/;return $.split(J)}function T6($,J){if(G2($))return;let Q=J.flatMap((Y)=>lK(Y));if(!Q[0])return;let X=lK(pK($)?$:kO(Q[0],$))[0];if(!X)return;return Q.some((Y)=>cK(X,Y))?X:void 0}function lK($){try{let J=vO($);return fO(J).isDirectory()?[J]:[]}catch{return[]}}function cK($,J){let Q=hO(J,$);return Q===""||Q!==".."&&!Q.startsWith(`..${gO}`)&&!pK(Q)}var r0="Command could not be safely analyzed (strict mode). Simplify the command and retry, or ask the user to verify.",A0="Command exceeds maximum recursion depth and cannot be safely analyzed. Flatten the nesting and retry.",dK="CC Safety Net could not validate the command because its structure exceeds safe analysis limits.",w6="CC Safety Net failed closed because command analysis failed unexpectedly. This is not caused by your command. Report it to the user.";function iK($){let{reason:J,command:Q,segment:X,toolName:Y}=$,W=$.maxLen??200,K=$.redact??((q)=>q),B=`BLOCKED by CC Safety Net
6
6
 
7
7
  Reason: ${K(J)}`;if($.ruleId)B+=`
@@ -96,6 +96,6 @@ ${yO($.intent??"manual_only")}`,B}function yO($){switch($){case"hard_stop":retur
96
96
  newResult[${E}] = ${A}.value;
97
97
  }
98
98
 
99
- `)}Z.write("payload.value = newResult;"),Z.write("return payload;");let b=Z.compile();return(R,A)=>b(L,R,A)},W,K=S2,B=!w3.jitless,U=B&&O7.value,G=J.catchall,H;$._zod.parse=(L,Z)=>{H??(H=X.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(!W)W=Y(J.shape);if(L=W(L,Z),!G)return L;return SH([],M,L,Z,H,$)}return Q(L,Z)}});function FH($,J,Q,X){for(let W of $)if(W.issues.length===0)return J.value=W.value,J;let Y=$.filter((W)=>!X2(W));if(Y.length===1)return J.value=Y[0].value,Y[0];return J.issues.push({code:"invalid_union",input:J.value,inst:Q,errors:$.map((W)=>W.issues.map((K)=>P1(K,X,Y1())))}),J}var c3=N("$ZodUnion",($,J)=>{v.init($,J),u($._zod,"optin",()=>J.options.some((Y)=>Y._zod.optin==="optional")?"optional":void 0),u($._zod,"optout",()=>J.options.some((Y)=>Y._zod.optout==="optional")?"optional":void 0),u($._zod,"values",()=>{if(J.options.every((Y)=>Y._zod.values))return new Set(J.options.flatMap((Y)=>Array.from(Y._zod.values)));return}),u($._zod,"pattern",()=>{if(J.options.every((Y)=>Y._zod.pattern)){let Y=J.options.map((W)=>W._zod.pattern);return new RegExp(`^(${Y.map((W)=>h3(W.source)).join("|")})$`)}return});let Q=J.options.length===1,X=J.options[0]._zod.run;$._zod.parse=(Y,W)=>{if(Q)return X(Y,W);let K=!1,B=[];for(let q of J.options){let U=q._zod.run({value:Y.value,issues:[]},W);if(U instanceof Promise)B.push(U),K=!0;else{if(U.issues.length===0)return U;B.push(U)}}if(!K)return FH(B,Y,$,W);return Promise.all(B).then((q)=>{return FH(q,Y,$,W)})}});function VH($,J,Q,X){let Y=$.filter((W)=>W.issues.length===0);if(Y.length===1)return J.value=Y[0].value,J;if(Y.length===0)J.issues.push({code:"invalid_union",input:J.value,inst:Q,errors:$.map((W)=>W.issues.map((K)=>P1(K,X,Y1())))});else J.issues.push({code:"invalid_union",input:J.value,inst:Q,errors:[],inclusive:!1});return J}var Q5=N("$ZodXor",($,J)=>{c3.init($,J),J.inclusive=!1;let Q=J.options.length===1,X=J.options[0]._zod.run;$._zod.parse=(Y,W)=>{if(Q)return X(Y,W);let K=!1,B=[];for(let q of J.options){let U=q._zod.run({value:Y.value,issues:[]},W);if(U instanceof Promise)B.push(U),K=!0;else B.push(U)}if(!K)return VH(B,Y,$,W);return Promise.all(B).then((q)=>{return VH(q,Y,$,W)})}}),X5=N("$ZodDiscriminatedUnion",($,J)=>{J.inclusive=!1,c3.init($,J);let Q=$._zod.parse;u($._zod,"propValues",()=>{let Y={};for(let W of J.options){let K=W._zod.propValues;if(!K||Object.keys(K).length===0)throw Error(`Invalid discriminated union option at index "${J.options.indexOf(W)}"`);for(let[B,q]of Object.entries(K)){if(!Y[B])Y[B]=new Set;for(let U of q)Y[B].add(U)}}return Y});let X=Z4(()=>{let Y=J.options,W=new Map;for(let K of Y){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(W.has(q))throw Error(`Duplicate discriminator value "${String(q)}"`);W.set(q,K)}}return W});$._zod.parse=(Y,W)=>{let K=Y.value;if(!S2(K))return Y.issues.push({code:"invalid_type",expected:"object",input:K,inst:$}),Y;let B=X.value.get(K?.[J.discriminator]);if(B)return B._zod.run(Y,W);if(J.unionFallback)return Q(Y,W);return Y.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:J.discriminator,input:K,path:[J.discriminator],inst:$}),Y}}),Y5=N("$ZodIntersection",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value,W=J.left._zod.run({value:Y,issues:[]},X),K=J.right._zod.run({value:Y,issues:[]},X);if(W instanceof Promise||K instanceof Promise)return Promise.all([W,K]).then(([q,U])=>{return _H(Q,q,U)});return _H(Q,W,K)}});function FX($,J){if($===J)return{valid:!0,data:$};if($ instanceof Date&&J instanceof Date&&+$===+J)return{valid:!0,data:$};if(Q2($)&&Q2(J)){let Q=Object.keys(J),X=Object.keys($).filter((W)=>Q.indexOf(W)!==-1),Y={...$,...J};for(let W of X){let K=FX($[W],J[W]);if(!K.valid)return{valid:!1,mergeErrorPath:[W,...K.mergeErrorPath]};Y[W]=K.data}return{valid:!0,data:Y}}if(Array.isArray($)&&Array.isArray(J)){if($.length!==J.length)return{valid:!1,mergeErrorPath:[]};let Q=[];for(let X=0;X<$.length;X++){let Y=$[X],W=J[X],K=FX(Y,W);if(!K.valid)return{valid:!1,mergeErrorPath:[X,...K.mergeErrorPath]};Q.push(K.data)}return{valid:!0,data:Q}}return{valid:!1,mergeErrorPath:[]}}function _H($,J,Q){let X=new Map,Y;for(let B of J.issues)if(B.code==="unrecognized_keys"){Y??(Y=B);for(let q of B.keys){if(!X.has(q))X.set(q,{});X.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(!X.has(q))X.set(q,{});X.get(q).r=!0}else $.issues.push(B);let W=[...X].filter(([,B])=>B.l&&B.r).map(([B])=>B);if(W.length&&Y)$.issues.push({...Y,keys:W});if(X2($))return $;let K=FX(J.value,Q.value);if(!K.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(K.mergeErrorPath)}`);return $.value=K.data,$}var f$=N("$ZodTuple",($,J)=>{v.init($,J);let Q=J.items;$._zod.parse=(X,Y)=>{let W=X.value;if(!Array.isArray(W))return X.issues.push({input:W,inst:$,expected:"tuple",code:"invalid_type"}),X;X.value=[];let K=[],B=[...Q].reverse().findIndex((G)=>G._zod.optin!=="optional"),q=B===-1?0:Q.length-B;if(!J.rest){let G=W.length>Q.length,H=W.length<q-1;if(G||H)return X.issues.push({...G?{code:"too_big",maximum:Q.length,inclusive:!0}:{code:"too_small",minimum:Q.length},input:W,inst:$,origin:"array"}),X}let U=-1;for(let G of Q){if(U++,U>=W.length){if(U>=q)continue}let H=G._zod.run({value:W[U],issues:[]},Y);if(H instanceof Promise)K.push(H.then((L)=>A$(L,X,U)));else A$(H,X,U)}if(J.rest){let G=W.slice(Q.length);for(let H of G){U++;let L=J.rest._zod.run({value:H,issues:[]},Y);if(L instanceof Promise)K.push(L.then((Z)=>A$(Z,X,U)));else A$(L,X,U)}}if(K.length)return Promise.all(K).then(()=>X);return X}});function A$($,J,Q){if($.issues.length)J.issues.push(...g1(Q,$.issues));J.value[Q]=$.value}var W5=N("$ZodRecord",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value;if(!Q2(Y))return Q.issues.push({expected:"record",code:"invalid_type",input:Y,inst:$}),Q;let W=[],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:Y[U],issues:[]},X);if(G instanceof Promise)W.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 Y)if(!B.has(U))q=q??[],q.push(U);if(q&&q.length>0)Q.issues.push({code:"unrecognized_keys",input:Y,inst:$,keys:q})}else{Q.value={};for(let B of Reflect.ownKeys(Y)){if(B==="__proto__")continue;let q=J.keyType._zod.run({value:B,issues:[]},X);if(q instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof B==="string"&&u3.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:[]},X);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]=Y[B];else Q.issues.push({code:"invalid_key",origin:"record",issues:q.issues.map((H)=>P1(H,X,Y1())),input:B,path:[B],inst:$});continue}let G=J.valueType._zod.run({value:Y[B],issues:[]},X);if(G instanceof Promise)W.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(W.length)return Promise.all(W).then(()=>Q);return Q}}),K5=N("$ZodMap",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value;if(!(Y instanceof Map))return Q.issues.push({expected:"map",code:"invalid_type",input:Y,inst:$}),Q;let W=[];Q.value=new Map;for(let[K,B]of Y){let q=J.keyType._zod.run({value:K,issues:[]},X),U=J.valueType._zod.run({value:B,issues:[]},X);if(q instanceof Promise||U instanceof Promise)W.push(Promise.all([q,U]).then(([G,H])=>{DH(G,H,Q,K,Y,$,X)}));else DH(q,U,Q,K,Y,$,X)}if(W.length)return Promise.all(W).then(()=>Q);return Q}});function DH($,J,Q,X,Y,W,K){if($.issues.length)if(k3.has(typeof X))Q.issues.push(...g1(X,$.issues));else Q.issues.push({code:"invalid_key",origin:"map",input:Y,inst:W,issues:$.issues.map((B)=>P1(B,K,Y1()))});if(J.issues.length)if(k3.has(typeof X))Q.issues.push(...g1(X,J.issues));else Q.issues.push({origin:"map",code:"invalid_element",input:Y,inst:W,key:X,issues:J.issues.map((B)=>P1(B,K,Y1()))});Q.value.set($.value,J.value)}var B5=N("$ZodSet",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value;if(!(Y instanceof Set))return Q.issues.push({input:Y,inst:$,expected:"set",code:"invalid_type"}),Q;let W=[];Q.value=new Set;for(let K of Y){let B=J.valueType._zod.run({value:K,issues:[]},X);if(B instanceof Promise)W.push(B.then((q)=>zH(q,Q)));else zH(B,Q)}if(W.length)return Promise.all(W).then(()=>Q);return Q}});function zH($,J){if($.issues.length)J.issues.push(...$.issues);J.value.add($.value)}var q5=N("$ZodEnum",($,J)=>{v.init($,J);let Q=f3(J.entries),X=new Set(Q);$._zod.values=X,$._zod.pattern=new RegExp(`^(${Q.filter((Y)=>k3.has(typeof Y)).map((Y)=>typeof Y==="string"?r1(Y):Y.toString()).join("|")})$`),$._zod.parse=(Y,W)=>{let K=Y.value;if(X.has(K))return Y;return Y.issues.push({code:"invalid_value",values:Q,input:K,inst:$}),Y}}),U5=N("$ZodLiteral",($,J)=>{if(v.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((X)=>typeof X==="string"?r1(X):X?r1(X.toString()):String(X)).join("|")})$`),$._zod.parse=(X,Y)=>{let W=X.value;if(Q.has(W))return X;return X.issues.push({code:"invalid_value",values:J.values,input:W,inst:$}),X}}),G5=N("$ZodFile",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value;if(Y instanceof File)return Q;return Q.issues.push({expected:"file",code:"invalid_type",input:Y,inst:$}),Q}}),H5=N("$ZodTransform",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{if(X.direction==="backward")throw new C2($.constructor.name);let Y=J.transform(Q.value,Q);if(X.async)return(Y instanceof Promise?Y:Promise.resolve(Y)).then((K)=>{return Q.value=K,Q});if(Y instanceof Promise)throw new F0;return Q.value=Y,Q}});function RH($,J){if($.issues.length&&J===void 0)return{issues:[],value:void 0};return $}var h$=N("$ZodOptional",($,J)=>{v.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,X)=>{if(J.innerType._zod.optin==="optional"){let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>RH(W,Q.value));return RH(Y,Q.value)}if(Q.value===void 0)return Q;return J.innerType._zod.run(Q,X)}}),Z5=N("$ZodExactOptional",($,J)=>{h$.init($,J),u($._zod,"values",()=>J.innerType._zod.values),u($._zod,"pattern",()=>J.innerType._zod.pattern),$._zod.parse=(Q,X)=>{return J.innerType._zod.run(Q,X)}}),L5=N("$ZodNullable",($,J)=>{v.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,X)=>{if(Q.value===null)return Q;return J.innerType._zod.run(Q,X)}}),M5=N("$ZodDefault",($,J)=>{v.init($,J),$._zod.optin="optional",u($._zod,"values",()=>J.innerType._zod.values),$._zod.parse=(Q,X)=>{if(X.direction==="backward")return J.innerType._zod.run(Q,X);if(Q.value===void 0)return Q.value=J.defaultValue,Q;let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>IH(W,J));return IH(Y,J)}});function IH($,J){if($.value===void 0)$.value=J.defaultValue;return $}var O5=N("$ZodPrefault",($,J)=>{v.init($,J),$._zod.optin="optional",u($._zod,"values",()=>J.innerType._zod.values),$._zod.parse=(Q,X)=>{if(X.direction==="backward")return J.innerType._zod.run(Q,X);if(Q.value===void 0)Q.value=J.defaultValue;return J.innerType._zod.run(Q,X)}}),N5=N("$ZodNonOptional",($,J)=>{v.init($,J),u($._zod,"values",()=>{let Q=J.innerType._zod.values;return Q?new Set([...Q].filter((X)=>X!==void 0)):void 0}),$._zod.parse=(Q,X)=>{let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>jH(W,$));return jH(Y,$)}});function jH($,J){if(!$.issues.length&&$.value===void 0)$.issues.push({code:"invalid_type",expected:"nonoptional",input:$.value,inst:J});return $}var F5=N("$ZodSuccess",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{if(X.direction==="backward")throw new C2("ZodSuccess");let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>{return Q.value=W.issues.length===0,Q});return Q.value=Y.issues.length===0,Q}}),V5=N("$ZodCatch",($,J)=>{v.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,X)=>{if(X.direction==="backward")return J.innerType._zod.run(Q,X);let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>{if(Q.value=W.value,W.issues.length)Q.value=J.catchValue({...Q,error:{issues:W.issues.map((K)=>P1(K,X,Y1()))},input:Q.value}),Q.issues=[];return Q});if(Q.value=Y.value,Y.issues.length)Q.value=J.catchValue({...Q,error:{issues:Y.issues.map((W)=>P1(W,X,Y1()))},input:Q.value}),Q.issues=[];return Q}}),_5=N("$ZodNaN",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{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}}),D5=N("$ZodPipe",($,J)=>{v.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,X)=>{if(X.direction==="backward"){let W=J.out._zod.run(Q,X);if(W instanceof Promise)return W.then((K)=>E$(K,J.in,X));return E$(W,J.in,X)}let Y=J.in._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>E$(W,J.out,X));return E$(Y,J.out,X)}});function E$($,J,Q){if($.issues.length)return $.aborted=!0,$;return J._zod.run({value:$.value,issues:$.issues},Q)}var d3=N("$ZodCodec",($,J)=>{v.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,X)=>{if((X.direction||"forward")==="forward"){let W=J.in._zod.run(Q,X);if(W instanceof Promise)return W.then((K)=>C$(K,J,X));return C$(W,J,X)}else{let W=J.out._zod.run(Q,X);if(W instanceof Promise)return W.then((K)=>C$(K,J,X));return C$(W,J,X)}}});function C$($,J,Q){if($.issues.length)return $.aborted=!0,$;if((Q.direction||"forward")==="forward"){let Y=J.transform($.value,$);if(Y instanceof Promise)return Y.then((W)=>S$($,W,J.out,Q));return S$($,Y,J.out,Q)}else{let Y=J.reverseTransform($.value,$);if(Y instanceof Promise)return Y.then((W)=>S$($,W,J.in,Q));return S$($,Y,J.in,Q)}}function S$($,J,Q,X){if($.issues.length)return $.aborted=!0,$;return Q._zod.run({value:J,issues:$.issues},X)}var z5=N("$ZodReadonly",($,J)=>{v.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,X)=>{if(X.direction==="backward")return J.innerType._zod.run(Q,X);let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then(bH);return bH(Y)}});function bH($){return $.value=Object.freeze($.value),$}var R5=N("$ZodTemplateLiteral",($,J)=>{v.init($,J);let Q=[];for(let X of J.parts)if(typeof X==="object"&&X!==null){if(!X._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...X._zod.traits].shift()}`);let Y=X._zod.pattern instanceof RegExp?X._zod.pattern.source:X._zod.pattern;if(!Y)throw Error(`Invalid template literal part: ${X._zod.traits}`);let W=Y.startsWith("^")?1:0,K=Y.endsWith("$")?Y.length-1:Y.length;Q.push(Y.slice(W,K))}else if(X===null||F7.has(typeof X))Q.push(r1(`${X}`));else throw Error(`Invalid template literal part: ${X}`);$._zod.pattern=new RegExp(`^${Q.join("")}$`),$._zod.parse=(X,Y)=>{if(typeof X.value!=="string")return X.issues.push({input:X.value,inst:$,expected:"string",code:"invalid_type"}),X;if($._zod.pattern.lastIndex=0,!$._zod.pattern.test(X.value))return X.issues.push({input:X.value,inst:$,code:"invalid_format",format:J.format??"template_literal",pattern:$._zod.pattern.source}),X;return X}}),I5=N("$ZodFunction",($,J)=>{return v.init($,J),$._def=J,$._zod.def=J,$.implement=(Q)=>{if(typeof Q!=="function")throw Error("implement() must be called with a function");return function(...X){let Y=$._def.input?L$($._def.input,X):X,W=Reflect.apply(Q,this,Y);if($._def.output)return L$($._def.output,W);return W}},$.implementAsync=(Q)=>{if(typeof Q!=="function")throw Error("implementAsync() must be called with a function");return async function(...X){let Y=$._def.input?await M$($._def.input,X):X,W=await Reflect.apply(Q,this,Y);if($._def.output)return await M$($._def.output,W);return W}},$._zod.parse=(Q,X)=>{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 X=$.constructor;if(Array.isArray(Q[0]))return new X({type:"function",input:new f$({type:"tuple",items:Q[0],rest:Q[1]}),output:$._def.output});return new X({type:"function",input:Q[0],output:$._def.output})},$.output=(Q)=>{return new $.constructor({type:"function",input:$._def.input,output:Q})},$}),j5=N("$ZodPromise",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{return Promise.resolve(Q.value).then((Y)=>J.innerType._zod.run({value:Y,issues:[]},X))}}),b5=N("$ZodLazy",($,J)=>{v.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,X)=>{return $._zod.innerType._zod.run(Q,X)}}),P5=N("$ZodCustom",($,J)=>{o.init($,J),v.init($,J),$._zod.parse=(Q,X)=>{return Q},$._zod.check=(Q)=>{let X=Q.value,Y=J.fn(X);if(Y instanceof Promise)return Y.then((W)=>PH(W,Q,X,$));PH(Y,Q,X,$);return}});function PH($,J,Q,X){if(!$){let Y={code:"custom",input:Q,inst:X,path:[...X._zod.def.path??[]],continue:!X._zod.def.abort};if(X._zod.def.params)Y.params=X._zod.def.params;J.issues.push(L4(Y))}}var r3={};var wH,k$=Symbol("ZodOutput"),g$=Symbol("ZodInput");class A5{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 X={...Q,...this._map.get($)};return Object.keys(X).length?X:void 0}return this._map.get($)}has($){return this._map.has($)}}function i3(){return new A5}(wH=globalThis).__zod_globalRegistry??(wH.__zod_globalRegistry=i3());var E1=globalThis.__zod_globalRegistry;function E5($,J){return new $({type:"string",...D(J)})}function C5($,J){return new $({type:"string",coerce:!0,...D(J)})}function y$($,J){return new $({type:"string",format:"email",check:"string_format",abort:!1,...D(J)})}function o3($,J){return new $({type:"string",format:"guid",check:"string_format",abort:!1,...D(J)})}function x$($,J){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,...D(J)})}function u$($,J){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...D(J)})}function m$($,J){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...D(J)})}function l$($,J){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...D(J)})}function n3($,J){return new $({type:"string",format:"url",check:"string_format",abort:!1,...D(J)})}function p$($,J){return new $({type:"string",format:"emoji",check:"string_format",abort:!1,...D(J)})}function c$($,J){return new $({type:"string",format:"nanoid",check:"string_format",abort:!1,...D(J)})}function d$($,J){return new $({type:"string",format:"cuid",check:"string_format",abort:!1,...D(J)})}function r$($,J){return new $({type:"string",format:"cuid2",check:"string_format",abort:!1,...D(J)})}function i$($,J){return new $({type:"string",format:"ulid",check:"string_format",abort:!1,...D(J)})}function o$($,J){return new $({type:"string",format:"xid",check:"string_format",abort:!1,...D(J)})}function n$($,J){return new $({type:"string",format:"ksuid",check:"string_format",abort:!1,...D(J)})}function s$($,J){return new $({type:"string",format:"ipv4",check:"string_format",abort:!1,...D(J)})}function a$($,J){return new $({type:"string",format:"ipv6",check:"string_format",abort:!1,...D(J)})}function S5($,J){return new $({type:"string",format:"mac",check:"string_format",abort:!1,...D(J)})}function t$($,J){return new $({type:"string",format:"cidrv4",check:"string_format",abort:!1,...D(J)})}function e$($,J){return new $({type:"string",format:"cidrv6",check:"string_format",abort:!1,...D(J)})}function $8($,J){return new $({type:"string",format:"base64",check:"string_format",abort:!1,...D(J)})}function J8($,J){return new $({type:"string",format:"base64url",check:"string_format",abort:!1,...D(J)})}function Q8($,J){return new $({type:"string",format:"e164",check:"string_format",abort:!1,...D(J)})}function X8($,J){return new $({type:"string",format:"jwt",check:"string_format",abort:!1,...D(J)})}var Y8={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function T5($,J){return new $({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...D(J)})}function w5($,J){return new $({type:"string",format:"date",check:"string_format",...D(J)})}function v5($,J){return new $({type:"string",format:"time",check:"string_format",precision:null,...D(J)})}function f5($,J){return new $({type:"string",format:"duration",check:"string_format",...D(J)})}function h5($,J){return new $({type:"number",checks:[],...D(J)})}function k5($,J){return new $({type:"number",coerce:!0,checks:[],...D(J)})}function g5($,J){return new $({type:"number",check:"number_format",abort:!1,format:"safeint",...D(J)})}function y5($,J){return new $({type:"number",check:"number_format",abort:!1,format:"float32",...D(J)})}function x5($,J){return new $({type:"number",check:"number_format",abort:!1,format:"float64",...D(J)})}function u5($,J){return new $({type:"number",check:"number_format",abort:!1,format:"int32",...D(J)})}function m5($,J){return new $({type:"number",check:"number_format",abort:!1,format:"uint32",...D(J)})}function l5($,J){return new $({type:"boolean",...D(J)})}function p5($,J){return new $({type:"boolean",coerce:!0,...D(J)})}function c5($,J){return new $({type:"bigint",...D(J)})}function d5($,J){return new $({type:"bigint",coerce:!0,...D(J)})}function r5($,J){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...D(J)})}function i5($,J){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...D(J)})}function o5($,J){return new $({type:"symbol",...D(J)})}function n5($,J){return new $({type:"undefined",...D(J)})}function s5($,J){return new $({type:"null",...D(J)})}function a5($){return new $({type:"any"})}function t5($){return new $({type:"unknown"})}function e5($,J){return new $({type:"never",...D(J)})}function $Y($,J){return new $({type:"void",...D(J)})}function JY($,J){return new $({type:"date",...D(J)})}function QY($,J){return new $({type:"date",coerce:!0,...D(J)})}function XY($,J){return new $({type:"nan",...D(J)})}function V0($,J){return new j$({check:"less_than",...D(J),value:$,inclusive:!1})}function x1($,J){return new j$({check:"less_than",...D(J),value:$,inclusive:!0})}function _0($,J){return new b$({check:"greater_than",...D(J),value:$,inclusive:!1})}function D1($,J){return new b$({check:"greater_than",...D(J),value:$,inclusive:!0})}function W8($){return _0(0,$)}function K8($){return V0(0,$)}function B8($){return x1(0,$)}function q8($){return D1(0,$)}function Y2($,J){return new t7({check:"multiple_of",...D(J),value:$})}function W2($,J){return new JX({check:"max_size",...D(J),maximum:$})}function D0($,J){return new QX({check:"min_size",...D(J),minimum:$})}function v2($,J){return new XX({check:"size_equals",...D(J),size:$})}function f2($,J){return new YX({check:"max_length",...D(J),maximum:$})}function y0($,J){return new WX({check:"min_length",...D(J),minimum:$})}function h2($,J){return new KX({check:"length_equals",...D(J),length:$})}function z4($,J){return new BX({check:"string_format",format:"regex",...D(J),pattern:$})}function R4($){return new qX({check:"string_format",format:"lowercase",...D($)})}function I4($){return new UX({check:"string_format",format:"uppercase",...D($)})}function j4($,J){return new GX({check:"string_format",format:"includes",...D(J),includes:$})}function b4($,J){return new HX({check:"string_format",format:"starts_with",...D(J),prefix:$})}function P4($,J){return new ZX({check:"string_format",format:"ends_with",...D(J),suffix:$})}function U8($,J,Q){return new LX({check:"property",property:$,schema:J,...D(Q)})}function A4($,J){return new MX({check:"mime_type",mime:$,...D(J)})}function Q0($){return new OX({check:"overwrite",tx:$})}function E4($){return Q0((J)=>J.normalize($))}function C4(){return Q0(($)=>$.trim())}function S4(){return Q0(($)=>$.toLowerCase())}function T4(){return Q0(($)=>$.toUpperCase())}function w4(){return Q0(($)=>M7($))}function YY($,J,Q){return new $({type:"array",element:J,...D(Q)})}function Fb($,J,Q){return new $({type:"union",options:J,...D(Q)})}function Vb($,J,Q){return new $({type:"union",options:J,inclusive:!1,...D(Q)})}function _b($,J,Q,X){return new $({type:"union",options:Q,discriminator:J,...D(X)})}function Db($,J,Q){return new $({type:"intersection",left:J,right:Q})}function zb($,J,Q,X){let Y=Q instanceof v;return new $({type:"tuple",items:J,rest:Y?Q:null,...D(Y?X:Q)})}function Rb($,J,Q,X){return new $({type:"record",keyType:J,valueType:Q,...D(X)})}function Ib($,J,Q,X){return new $({type:"map",keyType:J,valueType:Q,...D(X)})}function jb($,J,Q){return new $({type:"set",valueType:J,...D(Q)})}function bb($,J,Q){let X=Array.isArray(J)?Object.fromEntries(J.map((Y)=>[Y,Y])):J;return new $({type:"enum",entries:X,...D(Q)})}function Pb($,J,Q){return new $({type:"enum",entries:J,...D(Q)})}function Ab($,J,Q){return new $({type:"literal",values:Array.isArray(J)?J:[J],...D(Q)})}function WY($,J){return new $({type:"file",...D(J)})}function Eb($,J){return new $({type:"transform",transform:J})}function Cb($,J){return new $({type:"optional",innerType:J})}function Sb($,J){return new $({type:"nullable",innerType:J})}function Tb($,J,Q){return new $({type:"default",innerType:J,get defaultValue(){return typeof Q==="function"?Q():N7(Q)}})}function wb($,J,Q){return new $({type:"nonoptional",innerType:J,...D(Q)})}function vb($,J){return new $({type:"success",innerType:J})}function fb($,J,Q){return new $({type:"catch",innerType:J,catchValue:typeof Q==="function"?Q:()=>Q})}function hb($,J,Q){return new $({type:"pipe",in:J,out:Q})}function kb($,J){return new $({type:"readonly",innerType:J})}function gb($,J,Q){return new $({type:"template_literal",parts:J,...D(Q)})}function yb($,J){return new $({type:"lazy",getter:J})}function xb($,J){return new $({type:"promise",innerType:J})}function KY($,J,Q){let X=D(Q);return X.abort??(X.abort=!0),new $({type:"custom",check:"custom",fn:J,...X})}function BY($,J,Q){return new $({type:"custom",check:"custom",fn:J,...D(Q)})}function qY($){let J=vH((Q)=>{return Q.addIssue=(X)=>{if(typeof X==="string")Q.issues.push(L4(X,Q.value,J._zod.def));else{let Y=X;if(Y.fatal)Y.continue=!1;Y.code??(Y.code="custom"),Y.input??(Y.input=Q.value),Y.inst??(Y.inst=J),Y.continue??(Y.continue=!J._zod.def.abort),Q.issues.push(L4(Y))}},$(Q.value,Q)});return J}function vH($,J){let Q=new o({check:"custom",...D(J)});return Q._zod.check=$,Q}function UY($){let J=new o({check:"describe"});return J._zod.onattach=[(Q)=>{let X=E1.get(Q)??{};E1.add(Q,{...X,description:$})}],J._zod.check=()=>{},J}function GY($){let J=new o({check:"meta"});return J._zod.onattach=[(Q)=>{let X=E1.get(Q)??{};E1.add(Q,{...X,...$})}],J._zod.check=()=>{},J}function HY($,J){let Q=D(J),X=Q.truthy??["true","1","yes","on","y","enabled"],Y=Q.falsy??["false","0","no","off","n","disabled"];if(Q.case!=="sensitive")X=X.map((Z)=>typeof Z==="string"?Z.toLowerCase():Z),Y=Y.map((Z)=>typeof Z==="string"?Z.toLowerCase():Z);let W=new Set(X),K=new Set(Y),B=$.Codec??d3,q=$.Boolean??p3,G=new($.String??w2)({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(W.has(O))return!0;else if(K.has(O))return!1;else return M.issues.push({code:"invalid_value",expected:"stringbool",values:[...W,...K],input:M.value,inst:L,continue:!1}),{}},reverseTransform:(Z,M)=>{if(Z===!0)return X[0]||"true";else return Y[0]||"false"},error:Q.error});return L}function v4($,J,Q,X={}){let Y=D(X),W={...D(X),check:"string_format",type:"string",format:J,fn:typeof Q==="function"?Q:(B)=>Q.test(B),...Y};if(Q instanceof RegExp)W.pattern=Q;return new $(W)}var f4=()=>{throw Error("JSON Schema conversion is not bundled into this plugin artifact")},ZY=()=>f4,G8=()=>f4,h4=f4,n=f4,k4=f4,g4=f4;var ub={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},LY=($,J,Q,X)=>{let Y=Q;Y.type="string";let{minimum:W,maximum:K,format:B,patterns:q,contentEncoding:U}=$._zod.bag;if(typeof W==="number")Y.minLength=W;if(typeof K==="number")Y.maxLength=K;if(B){if(Y.format=ub[B]??B,Y.format==="")delete Y.format;if(B==="time")delete Y.format}if(U)Y.contentEncoding=U;if(q&&q.size>0){let G=[...q];if(G.length===1)Y.pattern=G[0].source;else if(G.length>1)Y.allOf=[...G.map((H)=>({...J.target==="draft-07"||J.target==="draft-04"||J.target==="openapi-3.0"?{type:"string"}:{},pattern:H.source}))]}},MY=($,J,Q,X)=>{let Y=Q,{minimum:W,maximum:K,format:B,multipleOf:q,exclusiveMaximum:U,exclusiveMinimum:G}=$._zod.bag;if(typeof B==="string"&&B.includes("int"))Y.type="integer";else Y.type="number";if(typeof G==="number")if(J.target==="draft-04"||J.target==="openapi-3.0")Y.minimum=G,Y.exclusiveMinimum=!0;else Y.exclusiveMinimum=G;if(typeof W==="number"){if(Y.minimum=W,typeof G==="number"&&J.target!=="draft-04")if(G>=W)delete Y.minimum;else delete Y.exclusiveMinimum}if(typeof U==="number")if(J.target==="draft-04"||J.target==="openapi-3.0")Y.maximum=U,Y.exclusiveMaximum=!0;else Y.exclusiveMaximum=U;if(typeof K==="number"){if(Y.maximum=K,typeof U==="number"&&J.target!=="draft-04")if(U<=K)delete Y.maximum;else delete Y.exclusiveMaximum}if(typeof q==="number")Y.multipleOf=q},OY=($,J,Q,X)=>{Q.type="boolean"},NY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},FY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},VY=($,J,Q,X)=>{if(J.target==="openapi-3.0")Q.type="string",Q.nullable=!0,Q.enum=[null];else Q.type="null"},_Y=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},DY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},zY=($,J,Q,X)=>{Q.not={}},RY=($,J,Q,X)=>{},IY=($,J,Q,X)=>{},jY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},bY=($,J,Q,X)=>{let Y=$._zod.def,W=f3(Y.entries);if(W.every((K)=>typeof K==="number"))Q.type="number";if(W.every((K)=>typeof K==="string"))Q.type="string";Q.enum=W},PY=($,J,Q,X)=>{let Y=$._zod.def,W=[];for(let K of Y.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 W.push(Number(K));else W.push(K);if(W.length===0);else if(W.length===1){let K=W[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(W.every((K)=>typeof K==="number"))Q.type="number";if(W.every((K)=>typeof K==="string"))Q.type="string";if(W.every((K)=>typeof K==="boolean"))Q.type="boolean";if(W.every((K)=>K===null))Q.type="null";Q.enum=W}},AY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},EY=($,J,Q,X)=>{let Y=Q,W=$._zod.pattern;if(!W)throw Error("Pattern not found in template literal");Y.type="string",Y.pattern=W.source},CY=($,J,Q,X)=>{let Y=Q,W={type:"string",format:"binary",contentEncoding:"binary"},{minimum:K,maximum:B,mime:q}=$._zod.bag;if(K!==void 0)W.minLength=K;if(B!==void 0)W.maxLength=B;if(q)if(q.length===1)W.contentMediaType=q[0],Object.assign(Y,W);else Object.assign(Y,W),Y.anyOf=q.map((U)=>({contentMediaType:U}));else Object.assign(Y,W)},SY=($,J,Q,X)=>{Q.type="boolean"},TY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},wY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},vY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},fY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},hY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},kY=($,J,Q,X)=>{let Y=Q,W=$._zod.def,{minimum:K,maximum:B}=$._zod.bag;if(typeof K==="number")Y.minItems=K;if(typeof B==="number")Y.maxItems=B;Y.type="array",Y.items=n(W.element,J,{...X,path:[...X.path,"items"]})},gY=($,J,Q,X)=>{let Y=Q,W=$._zod.def;Y.type="object",Y.properties={};let K=W.shape;for(let U in K)Y.properties[U]=n(K[U],J,{...X,path:[...X.path,"properties",U]});let B=new Set(Object.keys(K)),q=new Set([...B].filter((U)=>{let G=W.shape[U]._zod;if(J.io==="input")return G.optin===void 0;else return G.optout===void 0}));if(q.size>0)Y.required=Array.from(q);if(W.catchall?._zod.def.type==="never")Y.additionalProperties=!1;else if(!W.catchall){if(J.io==="output")Y.additionalProperties=!1}else if(W.catchall)Y.additionalProperties=n(W.catchall,J,{...X,path:[...X.path,"additionalProperties"]})},Z8=($,J,Q,X)=>{let Y=$._zod.def,W=Y.inclusive===!1,K=Y.options.map((B,q)=>n(B,J,{...X,path:[...X.path,W?"oneOf":"anyOf",q]}));if(W)Q.oneOf=K;else Q.anyOf=K},yY=($,J,Q,X)=>{let Y=$._zod.def,W=n(Y.left,J,{...X,path:[...X.path,"allOf",0]}),K=n(Y.right,J,{...X,path:[...X.path,"allOf",1]}),B=(U)=>("allOf"in U)&&Object.keys(U).length===1,q=[...B(W)?W.allOf:[W],...B(K)?K.allOf:[K]];Q.allOf=q},xY=($,J,Q,X)=>{let Y=Q,W=$._zod.def;Y.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=W.items.map((L,Z)=>n(L,J,{...X,path:[...X.path,K,Z]})),U=W.rest?n(W.rest,J,{...X,path:[...X.path,B,...J.target==="openapi-3.0"?[W.items.length]:[]]}):null;if(J.target==="draft-2020-12"){if(Y.prefixItems=q,U)Y.items=U}else if(J.target==="openapi-3.0"){if(Y.items={anyOf:q},U)Y.items.anyOf.push(U);if(Y.minItems=q.length,!U)Y.maxItems=q.length}else if(Y.items=q,U)Y.additionalItems=U;let{minimum:G,maximum:H}=$._zod.bag;if(typeof G==="number")Y.minItems=G;if(typeof H==="number")Y.maxItems=H},uY=($,J,Q,X)=>{let Y=Q,W=$._zod.def;Y.type="object";let K=W.keyType,q=K._zod.bag?.patterns;if(W.mode==="loose"&&q&&q.size>0){let G=n(W.valueType,J,{...X,path:[...X.path,"patternProperties","*"]});Y.patternProperties={};for(let H of q)Y.patternProperties[H.source]=G}else{if(J.target==="draft-07"||J.target==="draft-2020-12")Y.propertyNames=n(W.keyType,J,{...X,path:[...X.path,"propertyNames"]});Y.additionalProperties=n(W.valueType,J,{...X,path:[...X.path,"additionalProperties"]})}let U=K._zod.values;if(U){let G=[...U].filter((H)=>typeof H==="string"||typeof H==="number");if(G.length>0)Y.required=G}},mY=($,J,Q,X)=>{let Y=$._zod.def,W=n(Y.innerType,J,X),K=J.seen.get($);if(J.target==="openapi-3.0")K.ref=Y.innerType,Q.nullable=!0;else Q.anyOf=[W,{type:"null"}]},lY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType},pY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType,Q.default=JSON.parse(JSON.stringify(Y.defaultValue))},cY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);if(W.ref=Y.innerType,J.io==="input")Q._prefault=JSON.parse(JSON.stringify(Y.defaultValue))},dY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType;let K;try{K=Y.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}Q.default=K},rY=($,J,Q,X)=>{let Y=$._zod.def,W=J.io==="input"?Y.in._zod.def.type==="transform"?Y.out:Y.in:Y.out;n(W,J,X);let K=J.seen.get($);K.ref=W},iY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType,Q.readOnly=!0},oY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType},L8=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType},nY=($,J,Q,X)=>{let Y=$._zod.innerType;n(Y,J,X);let W=J.seen.get($);W.ref=Y},H8={string:LY,number:MY,boolean:OY,bigint:NY,symbol:FY,null:VY,undefined:_Y,void:DY,never:zY,any:RY,unknown:IY,date:jY,enum:bY,literal:PY,nan:AY,template_literal:EY,file:CY,success:SY,custom:TY,function:wY,transform:vY,map:fY,set:hY,array:kY,object:gY,union:Z8,intersection:yY,tuple:xY,record:uY,nullable:mY,nonoptional:lY,default:pY,prefault:cY,catch:dY,pipe:rY,readonly:iY,promise:oY,optional:L8,lazy:nY};function s3($,J){if("_idmap"in $){let X=$,Y=h4({...J,processors:H8}),W={};for(let q of X._idmap.entries()){let[U,G]=q;n(G,Y)}let K={},B={registry:X,uri:J?.uri,defs:W};Y.external=B;for(let q of X._idmap.entries()){let[U,G]=q;k4(Y,G),K[U]=g4(Y,G)}if(Object.keys(W).length>0){let q=Y.target==="draft-2020-12"?"$defs":"definitions";K.__shared={[q]:W}}return{schemas:K}}let Q=h4({...J,processors:H8});return n($,Q),k4(Q,$),g4(Q,$)}class sY{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=h4({processors:H8,target:J,...$?.metadata&&{metadata:$.metadata},...$?.unrepresentable&&{unrepresentable:$.unrepresentable},...$?.override&&{override:$.override},...$?.io&&{io:$.io}})}process($,J={path:[],schemaPath:[]}){return n($,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}k4(this.ctx,$);let Q=g4(this.ctx,$),{"~standard":X,...Y}=Q;return Y}}var fH={};var J6={};B2(J6,{time:()=>eY,duration:()=>$W,datetime:()=>aY,date:()=>tY,ZodISOTime:()=>e3,ZodISODuration:()=>$6,ZodISODateTime:()=>a3,ZodISODate:()=>t3});var a3=N("ZodISODateTime",($,J)=>{CX.init($,J),r.init($,J)});function aY($){return T5(a3,$)}var t3=N("ZodISODate",($,J)=>{SX.init($,J),r.init($,J)});function tY($){return w5(t3,$)}var e3=N("ZodISOTime",($,J)=>{TX.init($,J),r.init($,J)});function eY($){return v5(e3,$)}var $6=N("ZodISODuration",($,J)=>{wX.init($,J),r.init($,J)});function $W($){return f5($6,$)}var kH=($,J)=>{x3.init($,J),$.name="ZodError",Object.defineProperties($,{format:{value:(Q)=>O4($,Q)},flatten:{value:(Q)=>M4($,Q)},addIssue:{value:(Q)=>{$.issues.push(Q),$.message=JSON.stringify($.issues,H4,2)}},addIssues:{value:(Q)=>{$.issues.push(...Q),$.message=JSON.stringify($.issues,H4,2)}},isEmpty:{get(){return $.issues.length===0}}})},gH=N("ZodError",kH),z1=N("ZodError",kH,{Parent:Error});var M8=N4(z1),O8=F4(z1),N8=V4(z1),F8=_4(z1),V8=O$(z1),_8=N$(z1),D8=F$(z1),z8=V$(z1),R8=_$(z1),I8=D$(z1),j8=z$(z1),b8=R$(z1);var g=N("ZodType",($,J)=>{return v.init($,J),Object.assign($["~standard"],{jsonSchema:{input:G8($,"input"),output:G8($,"output")}}),$.toJSONSchema=ZY($,{}),$.def=J,$.type=J.type,Object.defineProperty($,"_def",{value:J}),$.check=(...Q)=>{return $.clone(w.mergeDefs(J,{checks:[...J.checks??[],...Q.map((X)=>typeof X==="function"?{_zod:{check:X,def:{check:"custom"},onattach:[]}}:X)]}),{parent:!0})},$.with=$.check,$.clone=(Q,X)=>N1($,Q,X),$.brand=()=>$,$.register=(Q,X)=>{return Q.add($,X),$},$.parse=(Q,X)=>M8($,Q,X,{callee:$.parse}),$.safeParse=(Q,X)=>N8($,Q,X),$.parseAsync=async(Q,X)=>O8($,Q,X,{callee:$.parseAsync}),$.safeParseAsync=async(Q,X)=>F8($,Q,X),$.spa=$.safeParseAsync,$.encode=(Q,X)=>V8($,Q,X),$.decode=(Q,X)=>_8($,Q,X),$.encodeAsync=async(Q,X)=>D8($,Q,X),$.decodeAsync=async(Q,X)=>z8($,Q,X),$.safeEncode=(Q,X)=>R8($,Q,X),$.safeDecode=(Q,X)=>I8($,Q,X),$.safeEncodeAsync=async(Q,X)=>j8($,Q,X),$.safeDecodeAsync=async(Q,X)=>b8($,Q,X),$.refine=(Q,X)=>$.check(cW(Q,X)),$.superRefine=(Q)=>$.check(dW(Q)),$.overwrite=(Q)=>$.check(Q0(Q)),$.optional=()=>X6($),$.exactOptional=()=>PW($),$.nullable=()=>Y6($),$.nullish=()=>X6(Y6($)),$.nonoptional=(Q)=>wW($,Q),$.array=()=>q6($),$.or=(Q)=>i8([$,Q]),$.and=(Q)=>NW($,Q),$.transform=(Q)=>W6($,n8(Q)),$.default=(Q)=>CW($,Q),$.prefault=(Q)=>TW($,Q),$.catch=(Q)=>hW($,Q),$.pipe=(Q)=>W6($,Q),$.readonly=()=>yW($),$.describe=(Q)=>{let X=$.clone();return E1.add(X,{description:Q}),X},Object.defineProperty($,"description",{get(){return E1.get($)?.description},configurable:!0}),$.meta=(...Q)=>{if(Q.length===0)return E1.get($);let X=$.clone();return E1.add(X,Q[0]),X},$.isOptional=()=>$.safeParse(void 0).success,$.isNullable=()=>$.safeParse(null).success,$.apply=(Q)=>Q($),$}),E8=N("_ZodString",($,J)=>{w2.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>LY($,X,Y,W);let Q=$._zod.bag;$.format=Q.format??null,$.minLength=Q.minimum??null,$.maxLength=Q.maximum??null,$.regex=(...X)=>$.check(z4(...X)),$.includes=(...X)=>$.check(j4(...X)),$.startsWith=(...X)=>$.check(b4(...X)),$.endsWith=(...X)=>$.check(P4(...X)),$.min=(...X)=>$.check(y0(...X)),$.max=(...X)=>$.check(f2(...X)),$.length=(...X)=>$.check(h2(...X)),$.nonempty=(...X)=>$.check(y0(1,...X)),$.lowercase=(X)=>$.check(R4(X)),$.uppercase=(X)=>$.check(I4(X)),$.trim=()=>$.check(C4()),$.normalize=(...X)=>$.check(E4(...X)),$.toLowerCase=()=>$.check(S4()),$.toUpperCase=()=>$.check(T4()),$.slugify=()=>$.check(w4())}),x4=N("ZodString",($,J)=>{w2.init($,J),E8.init($,J),$.email=(Q)=>$.check(y$(C8,Q)),$.url=(Q)=>$.check(n3(K6,Q)),$.jwt=(Q)=>$.check(X8(c8,Q)),$.emoji=(Q)=>$.check(p$(S8,Q)),$.guid=(Q)=>$.check(o3(Q6,Q)),$.uuid=(Q)=>$.check(x$(R0,Q)),$.uuidv4=(Q)=>$.check(u$(R0,Q)),$.uuidv6=(Q)=>$.check(m$(R0,Q)),$.uuidv7=(Q)=>$.check(l$(R0,Q)),$.nanoid=(Q)=>$.check(c$(T8,Q)),$.guid=(Q)=>$.check(o3(Q6,Q)),$.cuid=(Q)=>$.check(d$(w8,Q)),$.cuid2=(Q)=>$.check(r$(v8,Q)),$.ulid=(Q)=>$.check(i$(f8,Q)),$.base64=(Q)=>$.check($8(m8,Q)),$.base64url=(Q)=>$.check(J8(l8,Q)),$.xid=(Q)=>$.check(o$(h8,Q)),$.ksuid=(Q)=>$.check(n$(k8,Q)),$.ipv4=(Q)=>$.check(s$(g8,Q)),$.ipv6=(Q)=>$.check(a$(y8,Q)),$.cidrv4=(Q)=>$.check(t$(x8,Q)),$.cidrv6=(Q)=>$.check(e$(u8,Q)),$.e164=(Q)=>$.check(Q8(p8,Q)),$.datetime=(Q)=>$.check(aY(Q)),$.date=(Q)=>$.check(tY(Q)),$.time=(Q)=>$.check(eY(Q)),$.duration=(Q)=>$.check($W(Q))});function P8($){return E5(x4,$)}var r=N("ZodStringFormat",($,J)=>{d.init($,J),E8.init($,J)}),C8=N("ZodEmail",($,J)=>{DX.init($,J),r.init($,J)});function yH($){return y$(C8,$)}var Q6=N("ZodGUID",($,J)=>{VX.init($,J),r.init($,J)});function xH($){return o3(Q6,$)}var R0=N("ZodUUID",($,J)=>{_X.init($,J),r.init($,J)});function uH($){return x$(R0,$)}function mH($){return u$(R0,$)}function lH($){return m$(R0,$)}function pH($){return l$(R0,$)}var K6=N("ZodURL",($,J)=>{zX.init($,J),r.init($,J)});function cH($){return n3(K6,$)}function dH($){return n3(K6,{protocol:/^https?$/,hostname:y1.domain,...w.normalizeParams($)})}var S8=N("ZodEmoji",($,J)=>{RX.init($,J),r.init($,J)});function rH($){return p$(S8,$)}var T8=N("ZodNanoID",($,J)=>{IX.init($,J),r.init($,J)});function iH($){return c$(T8,$)}var w8=N("ZodCUID",($,J)=>{jX.init($,J),r.init($,J)});function oH($){return d$(w8,$)}var v8=N("ZodCUID2",($,J)=>{bX.init($,J),r.init($,J)});function nH($){return r$(v8,$)}var f8=N("ZodULID",($,J)=>{PX.init($,J),r.init($,J)});function sH($){return i$(f8,$)}var h8=N("ZodXID",($,J)=>{AX.init($,J),r.init($,J)});function aH($){return o$(h8,$)}var k8=N("ZodKSUID",($,J)=>{EX.init($,J),r.init($,J)});function tH($){return n$(k8,$)}var g8=N("ZodIPv4",($,J)=>{vX.init($,J),r.init($,J)});function eH($){return s$(g8,$)}var JW=N("ZodMAC",($,J)=>{hX.init($,J),r.init($,J)});function $Z($){return S5(JW,$)}var y8=N("ZodIPv6",($,J)=>{fX.init($,J),r.init($,J)});function JZ($){return a$(y8,$)}var x8=N("ZodCIDRv4",($,J)=>{kX.init($,J),r.init($,J)});function QZ($){return t$(x8,$)}var u8=N("ZodCIDRv6",($,J)=>{gX.init($,J),r.init($,J)});function XZ($){return e$(u8,$)}var m8=N("ZodBase64",($,J)=>{xX.init($,J),r.init($,J)});function YZ($){return $8(m8,$)}var l8=N("ZodBase64URL",($,J)=>{uX.init($,J),r.init($,J)});function WZ($){return J8(l8,$)}var p8=N("ZodE164",($,J)=>{mX.init($,J),r.init($,J)});function KZ($){return Q8(p8,$)}var c8=N("ZodJWT",($,J)=>{lX.init($,J),r.init($,J)});function BZ($){return X8(c8,$)}var u4=N("ZodCustomStringFormat",($,J)=>{pX.init($,J),r.init($,J)});function qZ($,J,Q={}){return v4(u4,$,J,Q)}function UZ($){return v4(u4,"hostname",y1.hostname,$)}function GZ($){return v4(u4,"hex",y1.hex,$)}function HZ($,J){let Q=J?.enc??"hex",X=`${$}_${Q}`,Y=y1[X];if(!Y)throw Error(`Unrecognized hash format: ${X}`);return v4(u4,X,Y,J)}var m4=N("ZodNumber",($,J)=>{w$.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>MY($,X,Y,W),$.gt=(X,Y)=>$.check(_0(X,Y)),$.gte=(X,Y)=>$.check(D1(X,Y)),$.min=(X,Y)=>$.check(D1(X,Y)),$.lt=(X,Y)=>$.check(V0(X,Y)),$.lte=(X,Y)=>$.check(x1(X,Y)),$.max=(X,Y)=>$.check(x1(X,Y)),$.int=(X)=>$.check(A8(X)),$.safe=(X)=>$.check(A8(X)),$.positive=(X)=>$.check(_0(0,X)),$.nonnegative=(X)=>$.check(D1(0,X)),$.negative=(X)=>$.check(V0(0,X)),$.nonpositive=(X)=>$.check(x1(0,X)),$.multipleOf=(X,Y)=>$.check(Y2(X,Y)),$.step=(X,Y)=>$.check(Y2(X,Y)),$.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 QW($){return h5(m4,$)}var g2=N("ZodNumberFormat",($,J)=>{cX.init($,J),m4.init($,J)});function A8($){return g5(g2,$)}function ZZ($){return y5(g2,$)}function LZ($){return x5(g2,$)}function MZ($){return u5(g2,$)}function OZ($){return m5(g2,$)}var l4=N("ZodBoolean",($,J)=>{p3.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>OY($,Q,X,Y)});function XW($){return l5(l4,$)}var p4=N("ZodBigInt",($,J)=>{v$.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>NY($,X,Y,W),$.gte=(X,Y)=>$.check(D1(X,Y)),$.min=(X,Y)=>$.check(D1(X,Y)),$.gt=(X,Y)=>$.check(_0(X,Y)),$.gte=(X,Y)=>$.check(D1(X,Y)),$.min=(X,Y)=>$.check(D1(X,Y)),$.lt=(X,Y)=>$.check(V0(X,Y)),$.lte=(X,Y)=>$.check(x1(X,Y)),$.max=(X,Y)=>$.check(x1(X,Y)),$.positive=(X)=>$.check(_0(BigInt(0),X)),$.negative=(X)=>$.check(V0(BigInt(0),X)),$.nonpositive=(X)=>$.check(x1(BigInt(0),X)),$.nonnegative=(X)=>$.check(D1(BigInt(0),X)),$.multipleOf=(X,Y)=>$.check(Y2(X,Y));let Q=$._zod.bag;$.minValue=Q.minimum??null,$.maxValue=Q.maximum??null,$.format=Q.format??null});function NZ($){return c5(p4,$)}var d8=N("ZodBigIntFormat",($,J)=>{dX.init($,J),p4.init($,J)});function FZ($){return r5(d8,$)}function VZ($){return i5(d8,$)}var YW=N("ZodSymbol",($,J)=>{rX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>FY($,Q,X,Y)});function _Z($){return o5(YW,$)}var WW=N("ZodUndefined",($,J)=>{iX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>_Y($,Q,X,Y)});function DZ($){return n5(WW,$)}var KW=N("ZodNull",($,J)=>{oX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>VY($,Q,X,Y)});function BW($){return s5(KW,$)}var qW=N("ZodAny",($,J)=>{nX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>RY($,Q,X,Y)});function zZ(){return a5(qW)}var UW=N("ZodUnknown",($,J)=>{sX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>IY($,Q,X,Y)});function k2(){return t5(UW)}var GW=N("ZodNever",($,J)=>{aX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>zY($,Q,X,Y)});function r8($){return e5(GW,$)}var HW=N("ZodVoid",($,J)=>{tX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>DY($,Q,X,Y)});function RZ($){return $Y(HW,$)}var B6=N("ZodDate",($,J)=>{eX.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>jY($,X,Y,W),$.min=(X,Y)=>$.check(D1(X,Y)),$.max=(X,Y)=>$.check(x1(X,Y));let Q=$._zod.bag;$.minDate=Q.minimum?new Date(Q.minimum):null,$.maxDate=Q.maximum?new Date(Q.maximum):null});function IZ($){return JY(B6,$)}var ZW=N("ZodArray",($,J)=>{$5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>kY($,Q,X,Y),$.element=J.element,$.min=(Q,X)=>$.check(y0(Q,X)),$.nonempty=(Q)=>$.check(y0(1,Q)),$.max=(Q,X)=>$.check(f2(Q,X)),$.length=(Q,X)=>$.check(h2(Q,X)),$.unwrap=()=>$.element});function q6($,J){return YY(ZW,$,J)}function jZ($){let J=$._zod.def.shape;return o8(Object.keys(J))}var U6=N("ZodObject",($,J)=>{J5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>gY($,Q,X,Y),w.defineLazy($,"shape",()=>{return J.shape}),$.keyof=()=>o8(Object.keys($._zod.def.shape)),$.catchall=(Q)=>$.clone({...$._zod.def,catchall:Q}),$.passthrough=()=>$.clone({...$._zod.def,catchall:k2()}),$.loose=()=>$.clone({...$._zod.def,catchall:k2()}),$.strict=()=>$.clone({...$._zod.def,catchall:r8()}),$.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(s8,$,Q[0]),$.required=(...Q)=>w.required(a8,$,Q[0])});function bZ($,J){let Q={type:"object",shape:$??{},...w.normalizeParams(J)};return new U6(Q)}function PZ($,J){return new U6({type:"object",shape:$,catchall:r8(),...w.normalizeParams(J)})}function AZ($,J){return new U6({type:"object",shape:$,catchall:k2(),...w.normalizeParams(J)})}var G6=N("ZodUnion",($,J)=>{c3.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>Z8($,Q,X,Y),$.options=J.options});function i8($,J){return new G6({type:"union",options:$,...w.normalizeParams(J)})}var LW=N("ZodXor",($,J)=>{G6.init($,J),Q5.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>Z8($,Q,X,Y),$.options=J.options});function EZ($,J){return new LW({type:"union",options:$,inclusive:!1,...w.normalizeParams(J)})}var MW=N("ZodDiscriminatedUnion",($,J)=>{G6.init($,J),X5.init($,J)});function CZ($,J,Q){return new MW({type:"union",options:J,discriminator:$,...w.normalizeParams(Q)})}var OW=N("ZodIntersection",($,J)=>{Y5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>yY($,Q,X,Y)});function NW($,J){return new OW({type:"intersection",left:$,right:J})}var FW=N("ZodTuple",($,J)=>{f$.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>xY($,Q,X,Y),$.rest=(Q)=>$.clone({...$._zod.def,rest:Q})});function VW($,J,Q){let X=J instanceof v,Y=X?Q:J;return new FW({type:"tuple",items:$,rest:X?J:null,...w.normalizeParams(Y)})}var H6=N("ZodRecord",($,J)=>{W5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>uY($,Q,X,Y),$.keyType=J.keyType,$.valueType=J.valueType});function _W($,J,Q){return new H6({type:"record",keyType:$,valueType:J,...w.normalizeParams(Q)})}function SZ($,J,Q){let X=N1($);return X._zod.values=void 0,new H6({type:"record",keyType:X,valueType:J,...w.normalizeParams(Q)})}function TZ($,J,Q){return new H6({type:"record",keyType:$,valueType:J,mode:"loose",...w.normalizeParams(Q)})}var DW=N("ZodMap",($,J)=>{K5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>fY($,Q,X,Y),$.keyType=J.keyType,$.valueType=J.valueType,$.min=(...Q)=>$.check(D0(...Q)),$.nonempty=(Q)=>$.check(D0(1,Q)),$.max=(...Q)=>$.check(W2(...Q)),$.size=(...Q)=>$.check(v2(...Q))});function wZ($,J,Q){return new DW({type:"map",keyType:$,valueType:J,...w.normalizeParams(Q)})}var zW=N("ZodSet",($,J)=>{B5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>hY($,Q,X,Y),$.min=(...Q)=>$.check(D0(...Q)),$.nonempty=(Q)=>$.check(D0(1,Q)),$.max=(...Q)=>$.check(W2(...Q)),$.size=(...Q)=>$.check(v2(...Q))});function vZ($,J){return new zW({type:"set",valueType:$,...w.normalizeParams(J)})}var y4=N("ZodEnum",($,J)=>{q5.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>bY($,X,Y,W),$.enum=J.entries,$.options=Object.values(J.entries);let Q=new Set(Object.keys(J.entries));$.extract=(X,Y)=>{let W={};for(let K of X)if(Q.has(K))W[K]=J.entries[K];else throw Error(`Key ${K} not found in enum`);return new y4({...J,checks:[],...w.normalizeParams(Y),entries:W})},$.exclude=(X,Y)=>{let W={...J.entries};for(let K of X)if(Q.has(K))delete W[K];else throw Error(`Key ${K} not found in enum`);return new y4({...J,checks:[],...w.normalizeParams(Y),entries:W})}});function o8($,J){let Q=Array.isArray($)?Object.fromEntries($.map((X)=>[X,X])):$;return new y4({type:"enum",entries:Q,...w.normalizeParams(J)})}function fZ($,J){return new y4({type:"enum",entries:$,...w.normalizeParams(J)})}var RW=N("ZodLiteral",($,J)=>{U5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>PY($,Q,X,Y),$.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 hZ($,J){return new RW({type:"literal",values:Array.isArray($)?$:[$],...w.normalizeParams(J)})}var IW=N("ZodFile",($,J)=>{G5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>CY($,Q,X,Y),$.min=(Q,X)=>$.check(D0(Q,X)),$.max=(Q,X)=>$.check(W2(Q,X)),$.mime=(Q,X)=>$.check(A4(Array.isArray(Q)?Q:[Q],X))});function kZ($){return WY(IW,$)}var jW=N("ZodTransform",($,J)=>{H5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>vY($,Q,X,Y),$._zod.parse=(Q,X)=>{if(X.direction==="backward")throw new C2($.constructor.name);Q.addIssue=(W)=>{if(typeof W==="string")Q.issues.push(w.issue(W,Q.value,J));else{let K=W;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 Y=J.transform(Q.value,Q);if(Y instanceof Promise)return Y.then((W)=>{return Q.value=W,Q});return Q.value=Y,Q}});function n8($){return new jW({type:"transform",transform:$})}var s8=N("ZodOptional",($,J)=>{h$.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>L8($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function X6($){return new s8({type:"optional",innerType:$})}var bW=N("ZodExactOptional",($,J)=>{Z5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>L8($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function PW($){return new bW({type:"optional",innerType:$})}var AW=N("ZodNullable",($,J)=>{L5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>mY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function Y6($){return new AW({type:"nullable",innerType:$})}function gZ($){return X6(Y6($))}var EW=N("ZodDefault",($,J)=>{M5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>pY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType,$.removeDefault=$.unwrap});function CW($,J){return new EW({type:"default",innerType:$,get defaultValue(){return typeof J==="function"?J():w.shallowClone(J)}})}var SW=N("ZodPrefault",($,J)=>{O5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>cY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function TW($,J){return new SW({type:"prefault",innerType:$,get defaultValue(){return typeof J==="function"?J():w.shallowClone(J)}})}var a8=N("ZodNonOptional",($,J)=>{N5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>lY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function wW($,J){return new a8({type:"nonoptional",innerType:$,...w.normalizeParams(J)})}var vW=N("ZodSuccess",($,J)=>{F5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>SY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function yZ($){return new vW({type:"success",innerType:$})}var fW=N("ZodCatch",($,J)=>{V5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>dY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType,$.removeCatch=$.unwrap});function hW($,J){return new fW({type:"catch",innerType:$,catchValue:typeof J==="function"?J:()=>J})}var kW=N("ZodNaN",($,J)=>{_5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>AY($,Q,X,Y)});function xZ($){return XY(kW,$)}var t8=N("ZodPipe",($,J)=>{D5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>rY($,Q,X,Y),$.in=J.in,$.out=J.out});function W6($,J){return new t8({type:"pipe",in:$,out:J})}var e8=N("ZodCodec",($,J)=>{t8.init($,J),d3.init($,J)});function uZ($,J,Q){return new e8({type:"pipe",in:$,out:J,transform:Q.decode,reverseTransform:Q.encode})}var gW=N("ZodReadonly",($,J)=>{z5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>iY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function yW($){return new gW({type:"readonly",innerType:$})}var xW=N("ZodTemplateLiteral",($,J)=>{R5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>EY($,Q,X,Y)});function mZ($,J){return new xW({type:"template_literal",parts:$,...w.normalizeParams(J)})}var uW=N("ZodLazy",($,J)=>{b5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>nY($,Q,X,Y),$.unwrap=()=>$._zod.def.getter()});function mW($){return new uW({type:"lazy",getter:$})}var lW=N("ZodPromise",($,J)=>{j5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>oY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function lZ($){return new lW({type:"promise",innerType:$})}var pW=N("ZodFunction",($,J)=>{I5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>wY($,Q,X,Y)});function pZ($){return new pW({type:"function",input:Array.isArray($?.input)?VW($?.input):$?.input??q6(k2()),output:$?.output??k2()})}var Z6=N("ZodCustom",($,J)=>{P5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>TY($,Q,X,Y)});function cZ($){let J=new o({check:"custom"});return J._zod.check=$,J}function dZ($,J){return KY(Z6,$??(()=>!0),J)}function cW($,J={}){return BY(Z6,$,J)}function dW($){return qY($)}var rZ=UY,iZ=GY;function oZ($,J={}){let Q=new Z6({type:"custom",check:"custom",fn:(X)=>X instanceof $,abort:!0,...w.normalizeParams(J)});return Q._zod.bag.Class=$,Q._zod.check=(X)=>{if(!(X.value instanceof $))X.issues.push({code:"invalid_type",expected:$.name,input:X.value,inst:Q,path:[...Q._zod.def.path??[]]})},Q}var nZ=(...$)=>HY({Codec:e8,Boolean:l4,String:x4},...$);function sZ($){let J=mW(()=>{return i8([P8($),QW(),XW(),BW(),q6(J),_W(P8(),J)])});return J}function aZ($,J){return W6(n8($),J)}var tZ={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 eZ($){Y1({customError:$})}function $L(){return Y1().customError}var $J;(function($){})($J||($J={}));var cb=()=>{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(Y){return $[Y]??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"},X={nan:"NaN"};return(Y)=>{switch(Y.code){case"invalid_type":{let W=X[Y.expected]??Y.expected,K=z7(Y.input),B=X[K]??K;return`Invalid input: expected ${W}, received ${B}`}case"invalid_value":if(Y.values.length===1)return`Invalid input: expected ${G$(Y.values[0])}`;return`Invalid option: expected one of ${B$(Y.values,"|")}`;case"too_big":{let W=Y.inclusive?"<=":"<",K=J(Y.origin);if(K)return`Too big: expected ${Y.origin??"value"} to have ${W}${Y.maximum.toString()} ${K.unit??"elements"}`;return`Too big: expected ${Y.origin??"value"} to be ${W}${Y.maximum.toString()}`}case"too_small":{let W=Y.inclusive?">=":">",K=J(Y.origin);if(K)return`Too small: expected ${Y.origin} to have ${W}${Y.minimum.toString()} ${K.unit}`;return`Too small: expected ${Y.origin} to be ${W}${Y.minimum.toString()}`}case"invalid_format":{let W=Y;if(W.format==="starts_with")return`Invalid string: must start with "${W.prefix}"`;if(W.format==="ends_with")return`Invalid string: must end with "${W.suffix}"`;if(W.format==="includes")return`Invalid string: must include "${W.includes}"`;if(W.format==="regex")return`Invalid string: must match pattern ${W.pattern}`;return`Invalid ${Q[W.format]??Y.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${Y.divisor}`;case"unrecognized_keys":return`Unrecognized key${Y.keys.length>1?"s":""}: ${B$(Y.keys,", ")}`;case"invalid_key":return`Invalid key in ${Y.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${Y.origin}`;default:return"Invalid input"}}};function rW(){return{localeError:cb()}}var iW=()=>{throw Error("JSON Schema conversion is not bundled into this plugin artifact")};var JJ={};B2(JJ,{string:()=>db,number:()=>rb,date:()=>nb,boolean:()=>ib,bigint:()=>ob});function db($){return C5(x4,$)}function rb($){return k5(m4,$)}function ib($){return p5(l4,$)}function ob($){return d5(p4,$)}function nb($){return QY(B6,$)}Y1(rW());var sb=QJ;var JL=Object.freeze(["hard_stop","use_alternative","scope_down","manual_only","stop_and_explain"]);var L6=64,QL="Rule config exceeds CC Safety Net's safe source limit.";var ch=Object.freeze({maxSources:64,concurrency:4,maxRequests:131,maxResponseBytes:67108864});var nW=[{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"}],XJ={id:"secret.pattern.env-variant",category:"Pattern",label:".env.*",description:"Blocks environment-specific .env variants."},ab=[".bak",".backup",".copy",".disabled",".old",".orig",".save",".tmp"],tb=[{idSlug:"kube-config",label:"~/.kube/config",directoryParts:[".kube"],basename:"config"},{idSlug:"docker-config",label:"~/.docker/config.json",directoryParts:[".docker"],basename:"config.json"}],sW=[{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"]},...tb.flatMap(($)=>ab.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 YJ=[{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"]}],XL=[{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"}],eb=[".bak",".backup",".copy",".disabled",".key",".old",".orig",".pem",".save",".tmp"],aW=XL.map(($)=>({id:`secret.variant.${$.slug}.separator`,category:"Variant",label:`${$.label}-* / ${$.label}_*`,description:`Blocks ${$.label} variants with dash or underscore suffixes.`,prefix:$.prefix})),tW=XL.flatMap(($)=>eb.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}))),M6={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)$/},eW=["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:$})),$K=[{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?$/}],YL=[...nW,XJ,...sW,...aW,...tW,M6,...eW,...$K,...YJ].map(($)=>({id:$.id,category:$.category,label:$.label,...$.category==="Coding CLI config"?{defaultOff:!0}:{},..."paths"in $?{paths:$.paths}:{description:$.description}})),WL=new Set(YJ.flatMap(($)=>$.category==="Coding CLI config"?[$.id]:[])),$P=YL.map(($)=>$.id),WJ=new Set($P);var Yk=JP(import.meta.url),KL,QP=Array(L6+1).fill("over-limit"),BL=/^[^/]+\/[^/]+$/,XP=/^sha256:[a-f0-9]{64}$/,KJ=`must be an integer between ${HJ} and ${ZJ}`,YP=["version","rules","overrides","transparent_wrappers"],WP=["version","safety","workflow","destructive_command_protection","secret_protection","audit"];function qL($){if(!i1($)||!Array.isArray($.rules)||$.rules.length<=L6)return $;return{$schema:$.$schema,version:$.version,rules:QP,overrides:$.overrides,transparent_wrappers:$.transparent_wrappers}}function KP(){let $=oW,J=(_)=>{let j=$.superRefine(_);return j._zod.def.when=()=>!0,j},Q=$.enum(JL),X=$.union([$.literal("off"),$.looseObject({reason:$.string({error:"required non-empty string"}).min(1,"required non-empty string").max(o2,`must be at most ${o2} 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."),Y=$.string({error:"must be a rulebook source string"}).min(1,"must be a non-empty rulebook source string"),W=$.string({error:"must be a command string"}).regex(M2,"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(Y,{error:"must be an array of rulebook source strings"}).max(L6,QL).default([]).describe("Rulebook source strings such as project-rules or owner/repo#main/team-rules"),overrides:$.record($.string().meta({pattern:BL.source}),X).default({}).describe("Rule overrides by id"),transparent_wrappers:$.array(W,{error:"must be an array of command strings"}).default([]).describe("Commands that transparently execute a visible protected child command")}),B=(_,j)=>{if(!i1(_))return;if(Array.isArray(_.rules)&&_.rules.length<=L6){let C=new Set;_.rules.forEach((T,y)=>{if(typeof T!=="string"||T==="")return;if(T.trim()===""){j.addIssue({code:"custom",message:"must be a non-empty rulebook source string",path:["rules",y]});return}let x=o4(T);if(x){j.addIssue({code:"custom",message:x,path:["rules",y]});return}if(C.has(T)){j.addIssue({code:"custom",message:`duplicate rulebook source "${T}"`,path:["rules",y]});return}C.add(T)})}if(i1(_.overrides))for(let C of Object.keys(_.overrides)){if(BL.test(C))continue;j.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,T)=>{if(typeof C!=="string"||!M2.test(C))return;if(P.has(C)){j.addIssue({code:"custom",message:`duplicate command "${C}"`,path:["transparent_wrappers",T]});return}if(LU(C)){j.addIssue({code:"custom",message:`reserved command "${C}" cannot be a wrapper`,path:["transparent_wrappers",T]});return}P.add(C)})},q=$.preprocess(qL,K.check($.superRefine(B))),U=$.preprocess(qL,K.check(J(B))),G=$.strictObject({fail_closed:$.boolean().optional(),paranoid_rm:$.boolean().optional(),paranoid_interpreters:$.boolean().optional()}),H=(_,j)=>$.intersection($.record($.string().refine((P)=>_.has(P),{error:(P)=>`unknown ${j} 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((j,P)=>{if(!Array.isArray(j))return;let C=c2();j.forEach((T,y)=>{if(typeof T!=="string")return;let x=_(T,C);if(x)P.addIssue({code:"custom",message:x,path:[y]})})})),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(r6,"destructive command").optional(),allow_paths:L(C9).optional()}).optional(),secret_protection:$.strictObject({enabled:$.boolean().optional(),overrides:H(WJ,"secret protection").optional(),deny_paths:L(S9).optional()}).optional(),audit:$.strictObject({retention_days:$.number({error:KJ}).int(KJ).min(HJ,KJ).max(ZJ,KJ).optional().describe("Days of audit log history to keep before the sweep deletes it")}).optional()}),M=(_)=>{let j=(y,x)=>_==="legacy"?y:x,P=j("must match pattern (letters, numbers, hyphens, underscores)","must match command pattern"),C=`required non-empty string up to ${o2} characters`,T=$.looseObject({name:$.string({error:"required string"}).regex(Y0,j("must match pattern (letters, numbers, hyphens, underscores; max 64 chars)","must match rule name pattern")),command:$.string({error:j("required string","required string matching command pattern")}).regex(M2,j(P,"required string matching command pattern")),subcommand:$.string({error:j("must be a string if provided","must match command pattern")}).regex(M2,P).optional(),block_args:$.array($.string({error:j("must be a string","must be a non-empty string")}).refine((y)=>y!=="",{error:j("must not be empty","must be a non-empty string")}),{error:j("required array","required non-empty array")}).refine((y)=>y.length>0,{error:j("must have at least one element","required non-empty array")}),reason:$.string({error:j("required string",C)}).refine((y)=>y!=="",{error:j("must not be empty",C)}).refine((y)=>y.length<=o2,{error:j(`must be at most ${o2} characters`,C)}),intent:Q.optional()},{error:"must be an object"});return $.array(T,{error:j("must be an array","required array")}).check(J((y,x)=>{if(!Array.isArray(y))return;let c=new Set;y.forEach((V1,S)=>{let m=i1(V1)?V1.name:void 0;if(typeof m!=="string")return;if(c.has(m.toLowerCase())){x.addIssue({code:"custom",message:`duplicate rule name "${m}"`,path:[S,"name"]});return}c.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((_,j)=>{if(!i1(_))return;if(_.expect!=="blocked"||typeof _.rule==="string")return;j.addIssue({code:"custom",message:"required string for blocked fixtures",path:["rule"]})})),b=$.looseObject({name:$.string({error:"required string matching rule name pattern"}).regex(Y0,"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(M2,"must match command pattern"),{error:"required array"}).check(J((_,j)=>{if(!Array.isArray(_))return;let P=new Set;_.forEach((C,T)=>{if(typeof C!=="string"||!M2.test(C))return;if(P.has(C)){j.addIssue({code:"custom",message:`duplicate command "${C}"`,path:[T]});return}P.add(C)})})),rules:M("rulebook"),tests:$.array(F,{error:"must be an array if provided"}).optional()}).check(J((_,j)=>{if(!i1(_))return;let P=new Set(JK(_));if(Array.isArray(_.tests)){let T=new Set(_.tests.flatMap((y)=>i1(y)&&y.expect==="blocked"&&typeof y.rule==="string"?[y.rule]:[]));for(let y of T){if(P.has(y))continue;j.addIssue({code:"custom",message:`blocked fixture references unknown rule "${y}"`,path:["tests"]})}}if(!Array.isArray(_.allowed_commands)||!Array.isArray(_.rules))return;let C=new Set(_.allowed_commands.filter((T)=>typeof T==="string"));_.rules.forEach((T,y)=>{let x=i1(T)?T.command:void 0;if(typeof x!=="string"||C.has(x))return;j.addIssue({code:"custom",message:`"${x}" must be listed in allowed_commands`,path:["rules",y,"command"]})})})),R=$.string({error:"required string"}).refine((_)=>_.trim()!=="",{error:"required string"}),A=$.looseObject({spec:R,name:R,version:R,digest:$.string({error:"required sha256 digest"}).regex(XP,"required sha256 digest")},{error:"must be an object"}),E=$.looseObject({rulebooks:$.array($.intersection(A,$.discriminatedUnion("kind",[$.object({kind:$.literal("local-directory"),path:R}),$.object({kind:$.literal("github"),owner:R,repo:R,ref:R,commit:R,path:R,display_ref:$.unknown().optional()})],{error:(_)=>{if(!i1(_.input))return"must be an object";let j=_.input.kind;return typeof j==="string"?`unknown kind "${j}"`:"required string"}})))});return{RulesConfigSchema:q,RulesConfigDiagnosticSchema:U,RuleOverrideSchema:X,UserPolicySchema:Z,LegacyConfigSchema:O,RulebookSchema:b,RulesLockfileSchema:E}}function O6(){return KL??=KP(),KL}function UL(){return O6().RulesConfigSchema}function BP(){return O6().UserPolicySchema}function GL(){return O6().RulebookSchema}function HL(){return O6().RulesLockfileSchema}function JK($){let J=i1($)?$.rules:void 0;return(Array.isArray(J)?J:[]).flatMap((Q)=>{let X=i1(Q)?Q.name:void 0;return typeof X==="string"?[X]:[]})}function ZL($){let J=O6().RulesConfigDiagnosticSchema.safeParse($);if(J.success)return{errors:[],sources:new Set(J.data.rules)};return{errors:c4(OL(J.error.issues,YP)),sources:HP($,J.error.issues)}}function LL($){let J=BP().safeParse($);if(J.success)return[];return c4(OL(J.error.issues,WP)," ")}function c4($,J=": ",Q=" "){return[...new Set($.flatMap((X)=>ML(X,J,Q,[])))]}function ML($,J,Q,X){let Y=[...X,...$.path],W=GP(Y);if($.code==="unrecognized_keys")return $.keys.map((K)=>`${W?`${W}.`:""}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)=>ML(B,J,Q,Y))}if(Y.length===0)return[$.code==="invalid_type"?"Config must be an object":$.message];if(Y.length===1&&($.code==="too_big"||$.code==="too_small")&&$.origin==="array")return[$.message];return[`${W}${Y.length===1?Q:J}${qP($)}`]}function qP($){if($.code==="invalid_value")return`must be ${UP($.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 UP($){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 GP($){return $.map((J,Q)=>{if(typeof J==="number")return`[${J}]`;return Q===0?String(J):`.${String(J)}`}).join("")}function OL($,J){let Q=$.map((W)=>W.path[1]),X=[...new Set(Q.filter((W)=>typeof W==="string"))],Y=(W,K)=>[W.path.length===0?-1:J.indexOf(String(W.path[0])),typeof K==="number"?K:X.indexOf(String(K)),W.code==="custom"?0:1];return $.map((W,K)=>({issue:W,rank:Y(W,Q[K])})).sort((W,K)=>W.rank[0]-K.rank[0]||W.rank[1]-K.rank[1]||W.rank[2]-K.rank[2]).map((W)=>W.issue)}function HP($,J){let Q=i1($)?$.rules:void 0;if(!Array.isArray(Q))return new Set;if(J.some((Y)=>Y.path.length===1&&Y.path[0]==="rules"))return new Set;let X=new Set(J.filter((Y)=>Y.path[0]==="rules"&&typeof Y.path[1]==="number").map((Y)=>Y.path[1]));return new Set(Q.filter((Y,W)=>typeof Y==="string"&&!X.has(W)))}function i1($){return!!$&&typeof $==="object"&&!Array.isArray($)}function ZP($){return ZL($)}function QK($){try{let J=q2(LP($));if(J===null)return{config:null,errors:[]};if(!J.trim())return{config:null,errors:["Config file is empty"]};let Q=JSON.parse(J),X=ZP(Q);if(X.errors.length>0)return{config:null,errors:X.errors};let Y=UL().parse(Q);return{config:{version:1,rules:Y.rules??[],overrides:Y.overrides??{},transparent_wrappers:Y.transparent_wrappers??[]},errors:[]}}catch(J){if(J instanceof W1)return{config:null,errors:[J.message]};return{config:null,errors:["Invalid JSON"]}}}function LP($){return typeof $==="string"?P6($):$}var VP=new Set(["standard","strict","paranoid"]),_P={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:[]},audit:{retention_days:R6}};function XK($){return FP(NP(U2($)),C6)}function _L($={}){let J=IP(XK($));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 NL($){if(!I0($))return RP();let J=I0($.safety)?$.safety:{},Q=I0(J.overrides)?J.overrides:{},X=I0($.workflow)?$.workflow:{},Y=I0($.destructive_command_protection)?$.destructive_command_protection:{},W=I0($.secret_protection)?$.secret_protection:{};return{version:1,safety:{level:VP.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 X.worktree_mode==="boolean"?X.worktree_mode:!1},destructive_command_protection:{enabled:typeof Y.enabled==="boolean"?Y.enabled:!0,overrides:FL(Y.overrides,r6),allow_paths:zP(Y.allow_paths)},secret_protection:{enabled:typeof W.enabled==="boolean"?W.enabled:!0,overrides:FL(W.overrides,WJ),deny_paths:DP(W.deny_paths)},audit:{retention_days:I6(I0($.audit)?$.audit.retention_days:void 0)}}}function FL($,J){if(!I0($))return{};return Object.fromEntries(Object.entries($).flatMap(([Q,X])=>J.has(Q)&&(X==="on"||X==="off")?[[Q,X]]:[]))}function DP($){if(!Array.isArray($))return[];let J=c2();return $.filter((Q)=>S9(Q,J)===null)}function zP($){if(!Array.isArray($))return[];let J=c2();return $.filter((Q)=>C9(Q,J)===null)}function I0($){return!!$&&typeof $==="object"&&!Array.isArray($)}function RP(){return structuredClone(_P)}function IP($){let J=jP();if(!MP($)){let Q=globalThis.__CC_SAFETY_NET_EMBEDDED_POLICY__;if(!I0(Q))return{policy:J,errors:[]};return{policy:VL(NL(Q)),errors:[]}}try{let Q=OP($,"utf-8");if(!Q.trim())return{policy:J,errors:[`${$}: Config file is empty`],fallback:"defaults"};let X=JSON.parse(Q),Y=LL(X),W=VL(NL(X));if(Y.length>0)return{policy:W,errors:Y.map((K)=>`${$}: ${K}`),fallback:I0(X)?"salvaged":"defaults"};return{policy:W,errors:[]}}catch{return{policy:J,errors:[`${$}: Invalid JSON`],fallback:"defaults"}}}function DL($){let J=Object.entries($),Q=new Set(J.flatMap(([X,Y])=>Y==="on"?[X]:[]));return new Set([...[...WL].filter((X)=>!Q.has(X)),...J.flatMap(([X,Y])=>Y==="off"?[X]:[])])}function jP(){return{safety:{},worktreeMode:!1,destructiveCommandProtectionEnabled:!0,destructiveCommandRuleOverrides:{},destructiveCommandAllowPaths:[],secretProtection:{enabled:!0,disabledRules:DL({}),denyPaths:[]}}}function VL($){return{safety:bP($.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:DL($.secret_protection.overrides),denyPaths:[...$.secret_protection.deny_paths]}}}function bP($){return{level:$.level,overrides:{failClosed:$.overrides.fail_closed,paranoidRm:$.overrides.paranoid_rm,paranoidInterpreters:$.overrides.paranoid_interpreters}}}var jL="This path contains the protected policy config and you must not modify or delete it.",PP=new Set(["[","cat","file","grep","head","jq","less","ls","more","rg","sed","stat","tail","test","wc"]);function bL($){let J=H2(E0()),Q=wP($.invocation.context.executionCwd,J);if($.invocation.route.kind==="patch")return zL($.paths.map((Y)=>Y.raw),!1,$.invocation.context.executionCwd,Q,J);let X=w1($,"input-candidate");if($.invocation.route.kind==="command")return X?RL(X.shell,$.invocation.context.executionCwd,Q,J):null;if($.invocation.route.kind==="unknown"&&X){let Y=RL(X.shell,$.invocation.context.executionCwd,Q,J);if(Y)return Y}return zL($.paths.map((Y)=>Y.raw),$.invocation.route.kind==="grep"||$.invocation.route.kind==="glob"||j9($.invocation.toolName),$.invocation.context.executionCwd,Q,J)}function zL($,J,Q,X,Y){if(J)return null;let W=$.find((K)=>N6(K,Q,X,Y));return W?{target:W}:null}function RL($,J,Q,X){let Y=P9($,J,X,{findSegmentTarget:(W,K)=>AP(W,K,Q,X)?.target??null,isRedirectionTarget:(W,K)=>N6(W,K.cwd,Q,X),findMalformedTarget:(W)=>TP(W,J,Q,X)?.target??null,normalizeCwd:O1});return Y?{target:Y}:null}function AP($,J,Q,X){if(M3($))return null;let Y=X.environment,W=l1([...$],Y),K=l(W[0]??"").toLowerCase(),B=W.slice(1);if(K==="rm"&&EP(B)){let q=CP(B).find((U)=>IL(f1(U,J.variables),J.cwd,Q,X));if(q)return{target:q}}if(K==="find"){if(y9(W,1)||AQ(W,Y)){let U=(g9(p(W))??p(["."])).find((G)=>{let H=f1(G.text,J.variables);return N6(H,J.cwd,Q,X)||IL(H,J.cwd,Q,X)})?.text;if(U)return{target:U}}}if(K==="mv"){let q=A9(B).sources.find((U)=>vP(f1(U,J.variables),J.cwd,Q,X));if(q)return{target:q}}if(SP($,Y))return null;for(let q of $)for(let U of PL(q))if(N6(f1(U,J.variables),J.cwd,Q,X))return{target:U};return null}function EP($){return $.some((J)=>J==="--recursive"||J.startsWith("-")&&!J.startsWith("--")&&/[rR]/.test(J.slice(1)))}function CP($){let J=$.indexOf("--");if(J!==-1)return[...$.slice(0,J).filter((Q)=>!Q.startsWith("-")),...$.slice(J+1)];return $.filter((Q)=>!Q.startsWith("-"))}function SP($,J){let Q=l1([...$],J);if(Q.length===0)return!1;let X=l(Q[0]??"").toLowerCase();if(!PP.has(X))return!1;if(X!=="sed")return!0;return!Q.slice(1).some((Y)=>Y.startsWith("-i")||Y==="--in-place"||Y.startsWith("--in-place="))}function TP($,J,Q,X){for(let Y of $.split(/\s+/))for(let W of PL(Y))if(N6(W,J,Q,X))return{target:W};return null}function PL($){let J=$.trim().replace(/^['"]|['"]$/g,""),Q=J.indexOf("=");return Q===-1||Q===J.length-1?[J]:[J,J.slice(Q+1)]}function wP($,J){let Q=O1(XK(),$,J),X=YK(Q),Y=new Set;for(let W=X;;W=YK(W))if(Y.add(d4(W)),YK(W)===W)break;return{file:d4(Q),directory:d4(X),directoryAndAncestors:Y}}function N6($,J,Q,X){return d4(O1($,J,X))===Q.file}function IL($,J,Q,X){return Q.directoryAndAncestors.has(d4(O1($,J,X)))}function vP($,J,Q,X){let Y=d4(O1($,J,X));return Y===Q.file||Q.directoryAndAncestors.has(Y)}function d4($){return process.platform==="win32"?$.toLowerCase():$}import{homedir as fP}from"node:os";import{isAbsolute as KK,resolve as hL}from"node:path";import{fileURLToPath as hP}from"node:url";var kL="Access to a sensitive path is not allowed.",gL=new Set(["echo","printf"]),kP=new Set(["find"]),gP=new Set(["-exec","-execdir"]),yP=new Set([";","+"]),xP=new Set(["-delete","-exec","-execdir","-fls","-fprint","-fprint0","-fprintf","-ok","-okdir"]),uP=new Set(["-name","-iname","-path","-ipath","-wholename","-iwholename","-samefile"]),mP=new Set(["python","python2","python3","node","deno","bun","ruby","perl","php","rscript","osascript","bash","sh","zsh","dash","ksh"]),lP=new Set(["node","bun"]),pP=new Set(["bun","child_process","deno","dotenv","fs","subprocess"]),cP=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"]),yL=new Set(["-c","-e","-r","-E","--eval","--exec"]),dP=new Set(["src/cli/cc-safety-net.ts","dist/bin/cc-safety-net.js"]),rP=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"])]]),iP=new Set(["grep","rg"]),AL="f",EL="file",oP="files",nP=new Set(["e","f"]),sP=new Set(["regexp","file"]),aP=new Set(["e","f","A","B","C","m"]),tP=new Set(["regexp","file","after-context","before-context","context","max-count"]),eP=new Set(["|","|&"]),WK="__CC_SAFETY_NET_PIPE_INPUT__",xL=new Set(["bash","sh","zsh","dash","ksh"]),$A=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 CL($,J,Q,X,Y){let W=s4();for(let K of $){if(yA(K,J,Q?.denyPaths??[],X,W))return{target:K,ruleId:"secret.deny-path"};if(Y&&!Y.has(K))continue;let B=kA(K,J,Q,W);if(B)return{target:K,ruleId:B}}return null}function uL($,J,Q={}){let X=SL($),Y=CL(X,$.invocation.context.executionCwd,J,$.invocation.context.configCwd),W=Y?.ruleId!=="secret.deny-path"&&Q.strict===!1?SL($,{refineJavaScriptInlineData:!0}):X,K=W.length===X.length?Y:CL(X,$.invocation.context.executionCwd,J,$.invocation.context.configCwd,new Set(W));if(K?.ruleId!=="secret.deny-path"&&Q.strict===!1&&JA($))return null;return K}function JA($){if($.invocation.route.kind!=="command")return!1;let J=w1($,"input-candidate")??w1($,"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(G0(K.text))}let X=i4(Q);if(X.length===0)return!1;let Y=y2(X[0]??"").toLowerCase(),W=X.slice(1);if(Y==="test")return W.length===2&&(W[0]==="-e"||W[0]==="-f");if(Y!=="find")return!1;return!W.some((K)=>xP.has(K))}function SL($,J={}){if($.invocation.route.kind==="command"){let X=w1($,"input-candidate");return X?_6(X.shell,$.store,J):[]}if($.invocation.route.kind!=="unknown")return $.paths.map((X)=>X.raw);let Q=w1($,"input-candidate");return[...Q?_6(Q.shell,$.store,J):[],...$.paths.map((X)=>X.raw)]}function _6($,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 X=[...$.assignmentFallbacks,...zA(G0($.source),J,Q)],Y=[],W=null;for(let K of $.entries){if(K.kind==="operator"){if(!K.boundary)continue;if(Y.length>0){if(X.push(...BJ(Y,J,Q)),W!==null)X.push(...TL(W,Y,J,Q));W=eP.has(K.operator)?Y:null,Y=[]}else W=null;continue}if(K.kind==="redirection"){let B=K.target?G0(K.target):void 0;if(B&&K.targetOrder==="legacy-segment")Y.push(B);else if(B)X.push(B);continue}Y.push(G0(K.text))}if(Y.length>0){if(X.push(...BJ(Y,J,Q)),W!==null)X.push(...TL(W,Y,J,Q))}return X}function BJ($,J,Q){let X=HA($),Y=i4($);if(Y.length===0)return X;let W=Y[0]??"",K=y2(W).toLowerCase(),B=Y.slice(1),q=QA(W,K,B);if(q)return[...X,...q];if(gL.has(K))return X;if(iP.has(K))return[...X,...CA(B)];if(kP.has(K))return[...X,...ZA(B,J,Q)];if(h1.has(K))return[...X,...B.flatMap((U)=>wL("awk",U)),...B.flatMap((U)=>MA(U,J,Q)),...B.flatMap(OA)];if(pL(K)){if(xL.has(K)){let U=xq(K,B);if(U!==null&&J.getShellSyntax(U).status==="structural-limit")throw new n0}return[...X,...LA(K,B,Q)]}return[...X,...B.flatMap((U)=>wL(K,U))]}function QA($,J,Q){let X=J==="cc-safety-net"&&Q[0]==="explain",Y=(J==="bun"||J==="node")&&XA(Q[0])&&Q[1]==="explain";if(!X&&!Y)return null;let W=Y?[$,Q[0]??""]:[$],K=Q.slice(Y?2:1);for(let B=0;B<K.length;B++){let q=K[B];if(q==="--json"||q==="--help"||q==="-h")continue;if(q==="--cwd"){let U=K[B+1];if(U&&!U.startsWith("--"))W.push(U);B++;continue}return W}return W}function XA($){let J=$?.replaceAll("\\","/");return[...dP].some((Q)=>J===Q||J?.endsWith(`/${Q}`))}function TL($,J,Q,X){if(qA(J,Q,X))return YA($);let Y=UA(J);if(Y===null)return[];return WA($).flatMap((W)=>xL.has(Y)?_6(Q.getShellSyntax(W),Q,X):dL(W))}function YA($){let J=i4($);if(J.length===0)return[];let Q=y2(J[0]??"").toLowerCase();if(!gL.has(Q))return[];return J.slice(1)}function WA($){let J=i4($);if(J.length===0)return[];let Q=y2(J[0]??"").toLowerCase(),X=J.slice(1);if(Q==="echo"){let Y=X.findIndex((W)=>!/^-[neE]+$/.test(W));return[(Y===-1?[]:X.slice(Y)).join(" ")]}if(Q==="printf")return KA(X);return[]}function KA($){let J=$[0];if(J===void 0)return[];let Q=(J.match(/%%|%[bqs]/g)??[]).filter((Y)=>Y!=="%%").length;if(Q===0||$.length===1)return[mL(J)];let X=$.slice(1);return Array.from({length:Math.ceil(X.length/Q)},(Y,W)=>BA(J,X.slice(W*Q,(W+1)*Q)))}function BA($,J){let Q=0;return mL($.replace(/%%|%[bqs]/g,(X)=>{if(X==="%%")return"%";let Y=J[Q]??"";return Q++,Y}))}function mL($){return $.replace(/\\n/g,`
99
+ `)}Z.write("payload.value = newResult;"),Z.write("return payload;");let b=Z.compile();return(R,A)=>b(L,R,A)},W,K=S2,B=!w3.jitless,U=B&&O7.value,G=J.catchall,H;$._zod.parse=(L,Z)=>{H??(H=X.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(!W)W=Y(J.shape);if(L=W(L,Z),!G)return L;return SH([],M,L,Z,H,$)}return Q(L,Z)}});function FH($,J,Q,X){for(let W of $)if(W.issues.length===0)return J.value=W.value,J;let Y=$.filter((W)=>!X2(W));if(Y.length===1)return J.value=Y[0].value,Y[0];return J.issues.push({code:"invalid_union",input:J.value,inst:Q,errors:$.map((W)=>W.issues.map((K)=>P1(K,X,Y1())))}),J}var c3=N("$ZodUnion",($,J)=>{v.init($,J),u($._zod,"optin",()=>J.options.some((Y)=>Y._zod.optin==="optional")?"optional":void 0),u($._zod,"optout",()=>J.options.some((Y)=>Y._zod.optout==="optional")?"optional":void 0),u($._zod,"values",()=>{if(J.options.every((Y)=>Y._zod.values))return new Set(J.options.flatMap((Y)=>Array.from(Y._zod.values)));return}),u($._zod,"pattern",()=>{if(J.options.every((Y)=>Y._zod.pattern)){let Y=J.options.map((W)=>W._zod.pattern);return new RegExp(`^(${Y.map((W)=>h3(W.source)).join("|")})$`)}return});let Q=J.options.length===1,X=J.options[0]._zod.run;$._zod.parse=(Y,W)=>{if(Q)return X(Y,W);let K=!1,B=[];for(let q of J.options){let U=q._zod.run({value:Y.value,issues:[]},W);if(U instanceof Promise)B.push(U),K=!0;else{if(U.issues.length===0)return U;B.push(U)}}if(!K)return FH(B,Y,$,W);return Promise.all(B).then((q)=>{return FH(q,Y,$,W)})}});function VH($,J,Q,X){let Y=$.filter((W)=>W.issues.length===0);if(Y.length===1)return J.value=Y[0].value,J;if(Y.length===0)J.issues.push({code:"invalid_union",input:J.value,inst:Q,errors:$.map((W)=>W.issues.map((K)=>P1(K,X,Y1())))});else J.issues.push({code:"invalid_union",input:J.value,inst:Q,errors:[],inclusive:!1});return J}var Q5=N("$ZodXor",($,J)=>{c3.init($,J),J.inclusive=!1;let Q=J.options.length===1,X=J.options[0]._zod.run;$._zod.parse=(Y,W)=>{if(Q)return X(Y,W);let K=!1,B=[];for(let q of J.options){let U=q._zod.run({value:Y.value,issues:[]},W);if(U instanceof Promise)B.push(U),K=!0;else B.push(U)}if(!K)return VH(B,Y,$,W);return Promise.all(B).then((q)=>{return VH(q,Y,$,W)})}}),X5=N("$ZodDiscriminatedUnion",($,J)=>{J.inclusive=!1,c3.init($,J);let Q=$._zod.parse;u($._zod,"propValues",()=>{let Y={};for(let W of J.options){let K=W._zod.propValues;if(!K||Object.keys(K).length===0)throw Error(`Invalid discriminated union option at index "${J.options.indexOf(W)}"`);for(let[B,q]of Object.entries(K)){if(!Y[B])Y[B]=new Set;for(let U of q)Y[B].add(U)}}return Y});let X=Z4(()=>{let Y=J.options,W=new Map;for(let K of Y){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(W.has(q))throw Error(`Duplicate discriminator value "${String(q)}"`);W.set(q,K)}}return W});$._zod.parse=(Y,W)=>{let K=Y.value;if(!S2(K))return Y.issues.push({code:"invalid_type",expected:"object",input:K,inst:$}),Y;let B=X.value.get(K?.[J.discriminator]);if(B)return B._zod.run(Y,W);if(J.unionFallback)return Q(Y,W);return Y.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:J.discriminator,input:K,path:[J.discriminator],inst:$}),Y}}),Y5=N("$ZodIntersection",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value,W=J.left._zod.run({value:Y,issues:[]},X),K=J.right._zod.run({value:Y,issues:[]},X);if(W instanceof Promise||K instanceof Promise)return Promise.all([W,K]).then(([q,U])=>{return _H(Q,q,U)});return _H(Q,W,K)}});function FX($,J){if($===J)return{valid:!0,data:$};if($ instanceof Date&&J instanceof Date&&+$===+J)return{valid:!0,data:$};if(Q2($)&&Q2(J)){let Q=Object.keys(J),X=Object.keys($).filter((W)=>Q.indexOf(W)!==-1),Y={...$,...J};for(let W of X){let K=FX($[W],J[W]);if(!K.valid)return{valid:!1,mergeErrorPath:[W,...K.mergeErrorPath]};Y[W]=K.data}return{valid:!0,data:Y}}if(Array.isArray($)&&Array.isArray(J)){if($.length!==J.length)return{valid:!1,mergeErrorPath:[]};let Q=[];for(let X=0;X<$.length;X++){let Y=$[X],W=J[X],K=FX(Y,W);if(!K.valid)return{valid:!1,mergeErrorPath:[X,...K.mergeErrorPath]};Q.push(K.data)}return{valid:!0,data:Q}}return{valid:!1,mergeErrorPath:[]}}function _H($,J,Q){let X=new Map,Y;for(let B of J.issues)if(B.code==="unrecognized_keys"){Y??(Y=B);for(let q of B.keys){if(!X.has(q))X.set(q,{});X.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(!X.has(q))X.set(q,{});X.get(q).r=!0}else $.issues.push(B);let W=[...X].filter(([,B])=>B.l&&B.r).map(([B])=>B);if(W.length&&Y)$.issues.push({...Y,keys:W});if(X2($))return $;let K=FX(J.value,Q.value);if(!K.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(K.mergeErrorPath)}`);return $.value=K.data,$}var f$=N("$ZodTuple",($,J)=>{v.init($,J);let Q=J.items;$._zod.parse=(X,Y)=>{let W=X.value;if(!Array.isArray(W))return X.issues.push({input:W,inst:$,expected:"tuple",code:"invalid_type"}),X;X.value=[];let K=[],B=[...Q].reverse().findIndex((G)=>G._zod.optin!=="optional"),q=B===-1?0:Q.length-B;if(!J.rest){let G=W.length>Q.length,H=W.length<q-1;if(G||H)return X.issues.push({...G?{code:"too_big",maximum:Q.length,inclusive:!0}:{code:"too_small",minimum:Q.length},input:W,inst:$,origin:"array"}),X}let U=-1;for(let G of Q){if(U++,U>=W.length){if(U>=q)continue}let H=G._zod.run({value:W[U],issues:[]},Y);if(H instanceof Promise)K.push(H.then((L)=>A$(L,X,U)));else A$(H,X,U)}if(J.rest){let G=W.slice(Q.length);for(let H of G){U++;let L=J.rest._zod.run({value:H,issues:[]},Y);if(L instanceof Promise)K.push(L.then((Z)=>A$(Z,X,U)));else A$(L,X,U)}}if(K.length)return Promise.all(K).then(()=>X);return X}});function A$($,J,Q){if($.issues.length)J.issues.push(...g1(Q,$.issues));J.value[Q]=$.value}var W5=N("$ZodRecord",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value;if(!Q2(Y))return Q.issues.push({expected:"record",code:"invalid_type",input:Y,inst:$}),Q;let W=[],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:Y[U],issues:[]},X);if(G instanceof Promise)W.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 Y)if(!B.has(U))q=q??[],q.push(U);if(q&&q.length>0)Q.issues.push({code:"unrecognized_keys",input:Y,inst:$,keys:q})}else{Q.value={};for(let B of Reflect.ownKeys(Y)){if(B==="__proto__")continue;let q=J.keyType._zod.run({value:B,issues:[]},X);if(q instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof B==="string"&&u3.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:[]},X);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]=Y[B];else Q.issues.push({code:"invalid_key",origin:"record",issues:q.issues.map((H)=>P1(H,X,Y1())),input:B,path:[B],inst:$});continue}let G=J.valueType._zod.run({value:Y[B],issues:[]},X);if(G instanceof Promise)W.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(W.length)return Promise.all(W).then(()=>Q);return Q}}),K5=N("$ZodMap",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value;if(!(Y instanceof Map))return Q.issues.push({expected:"map",code:"invalid_type",input:Y,inst:$}),Q;let W=[];Q.value=new Map;for(let[K,B]of Y){let q=J.keyType._zod.run({value:K,issues:[]},X),U=J.valueType._zod.run({value:B,issues:[]},X);if(q instanceof Promise||U instanceof Promise)W.push(Promise.all([q,U]).then(([G,H])=>{DH(G,H,Q,K,Y,$,X)}));else DH(q,U,Q,K,Y,$,X)}if(W.length)return Promise.all(W).then(()=>Q);return Q}});function DH($,J,Q,X,Y,W,K){if($.issues.length)if(k3.has(typeof X))Q.issues.push(...g1(X,$.issues));else Q.issues.push({code:"invalid_key",origin:"map",input:Y,inst:W,issues:$.issues.map((B)=>P1(B,K,Y1()))});if(J.issues.length)if(k3.has(typeof X))Q.issues.push(...g1(X,J.issues));else Q.issues.push({origin:"map",code:"invalid_element",input:Y,inst:W,key:X,issues:J.issues.map((B)=>P1(B,K,Y1()))});Q.value.set($.value,J.value)}var B5=N("$ZodSet",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value;if(!(Y instanceof Set))return Q.issues.push({input:Y,inst:$,expected:"set",code:"invalid_type"}),Q;let W=[];Q.value=new Set;for(let K of Y){let B=J.valueType._zod.run({value:K,issues:[]},X);if(B instanceof Promise)W.push(B.then((q)=>zH(q,Q)));else zH(B,Q)}if(W.length)return Promise.all(W).then(()=>Q);return Q}});function zH($,J){if($.issues.length)J.issues.push(...$.issues);J.value.add($.value)}var q5=N("$ZodEnum",($,J)=>{v.init($,J);let Q=f3(J.entries),X=new Set(Q);$._zod.values=X,$._zod.pattern=new RegExp(`^(${Q.filter((Y)=>k3.has(typeof Y)).map((Y)=>typeof Y==="string"?r1(Y):Y.toString()).join("|")})$`),$._zod.parse=(Y,W)=>{let K=Y.value;if(X.has(K))return Y;return Y.issues.push({code:"invalid_value",values:Q,input:K,inst:$}),Y}}),U5=N("$ZodLiteral",($,J)=>{if(v.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((X)=>typeof X==="string"?r1(X):X?r1(X.toString()):String(X)).join("|")})$`),$._zod.parse=(X,Y)=>{let W=X.value;if(Q.has(W))return X;return X.issues.push({code:"invalid_value",values:J.values,input:W,inst:$}),X}}),G5=N("$ZodFile",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{let Y=Q.value;if(Y instanceof File)return Q;return Q.issues.push({expected:"file",code:"invalid_type",input:Y,inst:$}),Q}}),H5=N("$ZodTransform",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{if(X.direction==="backward")throw new C2($.constructor.name);let Y=J.transform(Q.value,Q);if(X.async)return(Y instanceof Promise?Y:Promise.resolve(Y)).then((K)=>{return Q.value=K,Q});if(Y instanceof Promise)throw new F0;return Q.value=Y,Q}});function RH($,J){if($.issues.length&&J===void 0)return{issues:[],value:void 0};return $}var h$=N("$ZodOptional",($,J)=>{v.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,X)=>{if(J.innerType._zod.optin==="optional"){let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>RH(W,Q.value));return RH(Y,Q.value)}if(Q.value===void 0)return Q;return J.innerType._zod.run(Q,X)}}),Z5=N("$ZodExactOptional",($,J)=>{h$.init($,J),u($._zod,"values",()=>J.innerType._zod.values),u($._zod,"pattern",()=>J.innerType._zod.pattern),$._zod.parse=(Q,X)=>{return J.innerType._zod.run(Q,X)}}),L5=N("$ZodNullable",($,J)=>{v.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,X)=>{if(Q.value===null)return Q;return J.innerType._zod.run(Q,X)}}),M5=N("$ZodDefault",($,J)=>{v.init($,J),$._zod.optin="optional",u($._zod,"values",()=>J.innerType._zod.values),$._zod.parse=(Q,X)=>{if(X.direction==="backward")return J.innerType._zod.run(Q,X);if(Q.value===void 0)return Q.value=J.defaultValue,Q;let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>IH(W,J));return IH(Y,J)}});function IH($,J){if($.value===void 0)$.value=J.defaultValue;return $}var O5=N("$ZodPrefault",($,J)=>{v.init($,J),$._zod.optin="optional",u($._zod,"values",()=>J.innerType._zod.values),$._zod.parse=(Q,X)=>{if(X.direction==="backward")return J.innerType._zod.run(Q,X);if(Q.value===void 0)Q.value=J.defaultValue;return J.innerType._zod.run(Q,X)}}),N5=N("$ZodNonOptional",($,J)=>{v.init($,J),u($._zod,"values",()=>{let Q=J.innerType._zod.values;return Q?new Set([...Q].filter((X)=>X!==void 0)):void 0}),$._zod.parse=(Q,X)=>{let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>jH(W,$));return jH(Y,$)}});function jH($,J){if(!$.issues.length&&$.value===void 0)$.issues.push({code:"invalid_type",expected:"nonoptional",input:$.value,inst:J});return $}var F5=N("$ZodSuccess",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{if(X.direction==="backward")throw new C2("ZodSuccess");let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>{return Q.value=W.issues.length===0,Q});return Q.value=Y.issues.length===0,Q}}),V5=N("$ZodCatch",($,J)=>{v.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,X)=>{if(X.direction==="backward")return J.innerType._zod.run(Q,X);let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>{if(Q.value=W.value,W.issues.length)Q.value=J.catchValue({...Q,error:{issues:W.issues.map((K)=>P1(K,X,Y1()))},input:Q.value}),Q.issues=[];return Q});if(Q.value=Y.value,Y.issues.length)Q.value=J.catchValue({...Q,error:{issues:Y.issues.map((W)=>P1(W,X,Y1()))},input:Q.value}),Q.issues=[];return Q}}),_5=N("$ZodNaN",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{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}}),D5=N("$ZodPipe",($,J)=>{v.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,X)=>{if(X.direction==="backward"){let W=J.out._zod.run(Q,X);if(W instanceof Promise)return W.then((K)=>E$(K,J.in,X));return E$(W,J.in,X)}let Y=J.in._zod.run(Q,X);if(Y instanceof Promise)return Y.then((W)=>E$(W,J.out,X));return E$(Y,J.out,X)}});function E$($,J,Q){if($.issues.length)return $.aborted=!0,$;return J._zod.run({value:$.value,issues:$.issues},Q)}var d3=N("$ZodCodec",($,J)=>{v.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,X)=>{if((X.direction||"forward")==="forward"){let W=J.in._zod.run(Q,X);if(W instanceof Promise)return W.then((K)=>C$(K,J,X));return C$(W,J,X)}else{let W=J.out._zod.run(Q,X);if(W instanceof Promise)return W.then((K)=>C$(K,J,X));return C$(W,J,X)}}});function C$($,J,Q){if($.issues.length)return $.aborted=!0,$;if((Q.direction||"forward")==="forward"){let Y=J.transform($.value,$);if(Y instanceof Promise)return Y.then((W)=>S$($,W,J.out,Q));return S$($,Y,J.out,Q)}else{let Y=J.reverseTransform($.value,$);if(Y instanceof Promise)return Y.then((W)=>S$($,W,J.in,Q));return S$($,Y,J.in,Q)}}function S$($,J,Q,X){if($.issues.length)return $.aborted=!0,$;return Q._zod.run({value:J,issues:$.issues},X)}var z5=N("$ZodReadonly",($,J)=>{v.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,X)=>{if(X.direction==="backward")return J.innerType._zod.run(Q,X);let Y=J.innerType._zod.run(Q,X);if(Y instanceof Promise)return Y.then(bH);return bH(Y)}});function bH($){return $.value=Object.freeze($.value),$}var R5=N("$ZodTemplateLiteral",($,J)=>{v.init($,J);let Q=[];for(let X of J.parts)if(typeof X==="object"&&X!==null){if(!X._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...X._zod.traits].shift()}`);let Y=X._zod.pattern instanceof RegExp?X._zod.pattern.source:X._zod.pattern;if(!Y)throw Error(`Invalid template literal part: ${X._zod.traits}`);let W=Y.startsWith("^")?1:0,K=Y.endsWith("$")?Y.length-1:Y.length;Q.push(Y.slice(W,K))}else if(X===null||F7.has(typeof X))Q.push(r1(`${X}`));else throw Error(`Invalid template literal part: ${X}`);$._zod.pattern=new RegExp(`^${Q.join("")}$`),$._zod.parse=(X,Y)=>{if(typeof X.value!=="string")return X.issues.push({input:X.value,inst:$,expected:"string",code:"invalid_type"}),X;if($._zod.pattern.lastIndex=0,!$._zod.pattern.test(X.value))return X.issues.push({input:X.value,inst:$,code:"invalid_format",format:J.format??"template_literal",pattern:$._zod.pattern.source}),X;return X}}),I5=N("$ZodFunction",($,J)=>{return v.init($,J),$._def=J,$._zod.def=J,$.implement=(Q)=>{if(typeof Q!=="function")throw Error("implement() must be called with a function");return function(...X){let Y=$._def.input?L$($._def.input,X):X,W=Reflect.apply(Q,this,Y);if($._def.output)return L$($._def.output,W);return W}},$.implementAsync=(Q)=>{if(typeof Q!=="function")throw Error("implementAsync() must be called with a function");return async function(...X){let Y=$._def.input?await M$($._def.input,X):X,W=await Reflect.apply(Q,this,Y);if($._def.output)return await M$($._def.output,W);return W}},$._zod.parse=(Q,X)=>{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 X=$.constructor;if(Array.isArray(Q[0]))return new X({type:"function",input:new f$({type:"tuple",items:Q[0],rest:Q[1]}),output:$._def.output});return new X({type:"function",input:Q[0],output:$._def.output})},$.output=(Q)=>{return new $.constructor({type:"function",input:$._def.input,output:Q})},$}),j5=N("$ZodPromise",($,J)=>{v.init($,J),$._zod.parse=(Q,X)=>{return Promise.resolve(Q.value).then((Y)=>J.innerType._zod.run({value:Y,issues:[]},X))}}),b5=N("$ZodLazy",($,J)=>{v.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,X)=>{return $._zod.innerType._zod.run(Q,X)}}),P5=N("$ZodCustom",($,J)=>{o.init($,J),v.init($,J),$._zod.parse=(Q,X)=>{return Q},$._zod.check=(Q)=>{let X=Q.value,Y=J.fn(X);if(Y instanceof Promise)return Y.then((W)=>PH(W,Q,X,$));PH(Y,Q,X,$);return}});function PH($,J,Q,X){if(!$){let Y={code:"custom",input:Q,inst:X,path:[...X._zod.def.path??[]],continue:!X._zod.def.abort};if(X._zod.def.params)Y.params=X._zod.def.params;J.issues.push(L4(Y))}}var r3={};var wH,k$=Symbol("ZodOutput"),g$=Symbol("ZodInput");class A5{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 X={...Q,...this._map.get($)};return Object.keys(X).length?X:void 0}return this._map.get($)}has($){return this._map.has($)}}function i3(){return new A5}(wH=globalThis).__zod_globalRegistry??(wH.__zod_globalRegistry=i3());var E1=globalThis.__zod_globalRegistry;function E5($,J){return new $({type:"string",...D(J)})}function C5($,J){return new $({type:"string",coerce:!0,...D(J)})}function y$($,J){return new $({type:"string",format:"email",check:"string_format",abort:!1,...D(J)})}function o3($,J){return new $({type:"string",format:"guid",check:"string_format",abort:!1,...D(J)})}function x$($,J){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,...D(J)})}function u$($,J){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...D(J)})}function m$($,J){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...D(J)})}function l$($,J){return new $({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...D(J)})}function n3($,J){return new $({type:"string",format:"url",check:"string_format",abort:!1,...D(J)})}function p$($,J){return new $({type:"string",format:"emoji",check:"string_format",abort:!1,...D(J)})}function c$($,J){return new $({type:"string",format:"nanoid",check:"string_format",abort:!1,...D(J)})}function d$($,J){return new $({type:"string",format:"cuid",check:"string_format",abort:!1,...D(J)})}function r$($,J){return new $({type:"string",format:"cuid2",check:"string_format",abort:!1,...D(J)})}function i$($,J){return new $({type:"string",format:"ulid",check:"string_format",abort:!1,...D(J)})}function o$($,J){return new $({type:"string",format:"xid",check:"string_format",abort:!1,...D(J)})}function n$($,J){return new $({type:"string",format:"ksuid",check:"string_format",abort:!1,...D(J)})}function s$($,J){return new $({type:"string",format:"ipv4",check:"string_format",abort:!1,...D(J)})}function a$($,J){return new $({type:"string",format:"ipv6",check:"string_format",abort:!1,...D(J)})}function S5($,J){return new $({type:"string",format:"mac",check:"string_format",abort:!1,...D(J)})}function t$($,J){return new $({type:"string",format:"cidrv4",check:"string_format",abort:!1,...D(J)})}function e$($,J){return new $({type:"string",format:"cidrv6",check:"string_format",abort:!1,...D(J)})}function $8($,J){return new $({type:"string",format:"base64",check:"string_format",abort:!1,...D(J)})}function J8($,J){return new $({type:"string",format:"base64url",check:"string_format",abort:!1,...D(J)})}function Q8($,J){return new $({type:"string",format:"e164",check:"string_format",abort:!1,...D(J)})}function X8($,J){return new $({type:"string",format:"jwt",check:"string_format",abort:!1,...D(J)})}var Y8={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function T5($,J){return new $({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...D(J)})}function w5($,J){return new $({type:"string",format:"date",check:"string_format",...D(J)})}function v5($,J){return new $({type:"string",format:"time",check:"string_format",precision:null,...D(J)})}function f5($,J){return new $({type:"string",format:"duration",check:"string_format",...D(J)})}function h5($,J){return new $({type:"number",checks:[],...D(J)})}function k5($,J){return new $({type:"number",coerce:!0,checks:[],...D(J)})}function g5($,J){return new $({type:"number",check:"number_format",abort:!1,format:"safeint",...D(J)})}function y5($,J){return new $({type:"number",check:"number_format",abort:!1,format:"float32",...D(J)})}function x5($,J){return new $({type:"number",check:"number_format",abort:!1,format:"float64",...D(J)})}function u5($,J){return new $({type:"number",check:"number_format",abort:!1,format:"int32",...D(J)})}function m5($,J){return new $({type:"number",check:"number_format",abort:!1,format:"uint32",...D(J)})}function l5($,J){return new $({type:"boolean",...D(J)})}function p5($,J){return new $({type:"boolean",coerce:!0,...D(J)})}function c5($,J){return new $({type:"bigint",...D(J)})}function d5($,J){return new $({type:"bigint",coerce:!0,...D(J)})}function r5($,J){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...D(J)})}function i5($,J){return new $({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...D(J)})}function o5($,J){return new $({type:"symbol",...D(J)})}function n5($,J){return new $({type:"undefined",...D(J)})}function s5($,J){return new $({type:"null",...D(J)})}function a5($){return new $({type:"any"})}function t5($){return new $({type:"unknown"})}function e5($,J){return new $({type:"never",...D(J)})}function $Y($,J){return new $({type:"void",...D(J)})}function JY($,J){return new $({type:"date",...D(J)})}function QY($,J){return new $({type:"date",coerce:!0,...D(J)})}function XY($,J){return new $({type:"nan",...D(J)})}function V0($,J){return new j$({check:"less_than",...D(J),value:$,inclusive:!1})}function x1($,J){return new j$({check:"less_than",...D(J),value:$,inclusive:!0})}function _0($,J){return new b$({check:"greater_than",...D(J),value:$,inclusive:!1})}function D1($,J){return new b$({check:"greater_than",...D(J),value:$,inclusive:!0})}function W8($){return _0(0,$)}function K8($){return V0(0,$)}function B8($){return x1(0,$)}function q8($){return D1(0,$)}function Y2($,J){return new t7({check:"multiple_of",...D(J),value:$})}function W2($,J){return new JX({check:"max_size",...D(J),maximum:$})}function D0($,J){return new QX({check:"min_size",...D(J),minimum:$})}function v2($,J){return new XX({check:"size_equals",...D(J),size:$})}function f2($,J){return new YX({check:"max_length",...D(J),maximum:$})}function y0($,J){return new WX({check:"min_length",...D(J),minimum:$})}function h2($,J){return new KX({check:"length_equals",...D(J),length:$})}function z4($,J){return new BX({check:"string_format",format:"regex",...D(J),pattern:$})}function R4($){return new qX({check:"string_format",format:"lowercase",...D($)})}function I4($){return new UX({check:"string_format",format:"uppercase",...D($)})}function j4($,J){return new GX({check:"string_format",format:"includes",...D(J),includes:$})}function b4($,J){return new HX({check:"string_format",format:"starts_with",...D(J),prefix:$})}function P4($,J){return new ZX({check:"string_format",format:"ends_with",...D(J),suffix:$})}function U8($,J,Q){return new LX({check:"property",property:$,schema:J,...D(Q)})}function A4($,J){return new MX({check:"mime_type",mime:$,...D(J)})}function Q0($){return new OX({check:"overwrite",tx:$})}function E4($){return Q0((J)=>J.normalize($))}function C4(){return Q0(($)=>$.trim())}function S4(){return Q0(($)=>$.toLowerCase())}function T4(){return Q0(($)=>$.toUpperCase())}function w4(){return Q0(($)=>M7($))}function YY($,J,Q){return new $({type:"array",element:J,...D(Q)})}function Fb($,J,Q){return new $({type:"union",options:J,...D(Q)})}function Vb($,J,Q){return new $({type:"union",options:J,inclusive:!1,...D(Q)})}function _b($,J,Q,X){return new $({type:"union",options:Q,discriminator:J,...D(X)})}function Db($,J,Q){return new $({type:"intersection",left:J,right:Q})}function zb($,J,Q,X){let Y=Q instanceof v;return new $({type:"tuple",items:J,rest:Y?Q:null,...D(Y?X:Q)})}function Rb($,J,Q,X){return new $({type:"record",keyType:J,valueType:Q,...D(X)})}function Ib($,J,Q,X){return new $({type:"map",keyType:J,valueType:Q,...D(X)})}function jb($,J,Q){return new $({type:"set",valueType:J,...D(Q)})}function bb($,J,Q){let X=Array.isArray(J)?Object.fromEntries(J.map((Y)=>[Y,Y])):J;return new $({type:"enum",entries:X,...D(Q)})}function Pb($,J,Q){return new $({type:"enum",entries:J,...D(Q)})}function Ab($,J,Q){return new $({type:"literal",values:Array.isArray(J)?J:[J],...D(Q)})}function WY($,J){return new $({type:"file",...D(J)})}function Eb($,J){return new $({type:"transform",transform:J})}function Cb($,J){return new $({type:"optional",innerType:J})}function Sb($,J){return new $({type:"nullable",innerType:J})}function Tb($,J,Q){return new $({type:"default",innerType:J,get defaultValue(){return typeof Q==="function"?Q():N7(Q)}})}function wb($,J,Q){return new $({type:"nonoptional",innerType:J,...D(Q)})}function vb($,J){return new $({type:"success",innerType:J})}function fb($,J,Q){return new $({type:"catch",innerType:J,catchValue:typeof Q==="function"?Q:()=>Q})}function hb($,J,Q){return new $({type:"pipe",in:J,out:Q})}function kb($,J){return new $({type:"readonly",innerType:J})}function gb($,J,Q){return new $({type:"template_literal",parts:J,...D(Q)})}function yb($,J){return new $({type:"lazy",getter:J})}function xb($,J){return new $({type:"promise",innerType:J})}function KY($,J,Q){let X=D(Q);return X.abort??(X.abort=!0),new $({type:"custom",check:"custom",fn:J,...X})}function BY($,J,Q){return new $({type:"custom",check:"custom",fn:J,...D(Q)})}function qY($){let J=vH((Q)=>{return Q.addIssue=(X)=>{if(typeof X==="string")Q.issues.push(L4(X,Q.value,J._zod.def));else{let Y=X;if(Y.fatal)Y.continue=!1;Y.code??(Y.code="custom"),Y.input??(Y.input=Q.value),Y.inst??(Y.inst=J),Y.continue??(Y.continue=!J._zod.def.abort),Q.issues.push(L4(Y))}},$(Q.value,Q)});return J}function vH($,J){let Q=new o({check:"custom",...D(J)});return Q._zod.check=$,Q}function UY($){let J=new o({check:"describe"});return J._zod.onattach=[(Q)=>{let X=E1.get(Q)??{};E1.add(Q,{...X,description:$})}],J._zod.check=()=>{},J}function GY($){let J=new o({check:"meta"});return J._zod.onattach=[(Q)=>{let X=E1.get(Q)??{};E1.add(Q,{...X,...$})}],J._zod.check=()=>{},J}function HY($,J){let Q=D(J),X=Q.truthy??["true","1","yes","on","y","enabled"],Y=Q.falsy??["false","0","no","off","n","disabled"];if(Q.case!=="sensitive")X=X.map((Z)=>typeof Z==="string"?Z.toLowerCase():Z),Y=Y.map((Z)=>typeof Z==="string"?Z.toLowerCase():Z);let W=new Set(X),K=new Set(Y),B=$.Codec??d3,q=$.Boolean??p3,G=new($.String??w2)({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(W.has(O))return!0;else if(K.has(O))return!1;else return M.issues.push({code:"invalid_value",expected:"stringbool",values:[...W,...K],input:M.value,inst:L,continue:!1}),{}},reverseTransform:(Z,M)=>{if(Z===!0)return X[0]||"true";else return Y[0]||"false"},error:Q.error});return L}function v4($,J,Q,X={}){let Y=D(X),W={...D(X),check:"string_format",type:"string",format:J,fn:typeof Q==="function"?Q:(B)=>Q.test(B),...Y};if(Q instanceof RegExp)W.pattern=Q;return new $(W)}var f4=()=>{throw Error("JSON Schema conversion is not bundled into this plugin artifact")},ZY=()=>f4,G8=()=>f4,h4=f4,n=f4,k4=f4,g4=f4;var ub={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},LY=($,J,Q,X)=>{let Y=Q;Y.type="string";let{minimum:W,maximum:K,format:B,patterns:q,contentEncoding:U}=$._zod.bag;if(typeof W==="number")Y.minLength=W;if(typeof K==="number")Y.maxLength=K;if(B){if(Y.format=ub[B]??B,Y.format==="")delete Y.format;if(B==="time")delete Y.format}if(U)Y.contentEncoding=U;if(q&&q.size>0){let G=[...q];if(G.length===1)Y.pattern=G[0].source;else if(G.length>1)Y.allOf=[...G.map((H)=>({...J.target==="draft-07"||J.target==="draft-04"||J.target==="openapi-3.0"?{type:"string"}:{},pattern:H.source}))]}},MY=($,J,Q,X)=>{let Y=Q,{minimum:W,maximum:K,format:B,multipleOf:q,exclusiveMaximum:U,exclusiveMinimum:G}=$._zod.bag;if(typeof B==="string"&&B.includes("int"))Y.type="integer";else Y.type="number";if(typeof G==="number")if(J.target==="draft-04"||J.target==="openapi-3.0")Y.minimum=G,Y.exclusiveMinimum=!0;else Y.exclusiveMinimum=G;if(typeof W==="number"){if(Y.minimum=W,typeof G==="number"&&J.target!=="draft-04")if(G>=W)delete Y.minimum;else delete Y.exclusiveMinimum}if(typeof U==="number")if(J.target==="draft-04"||J.target==="openapi-3.0")Y.maximum=U,Y.exclusiveMaximum=!0;else Y.exclusiveMaximum=U;if(typeof K==="number"){if(Y.maximum=K,typeof U==="number"&&J.target!=="draft-04")if(U<=K)delete Y.maximum;else delete Y.exclusiveMaximum}if(typeof q==="number")Y.multipleOf=q},OY=($,J,Q,X)=>{Q.type="boolean"},NY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},FY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},VY=($,J,Q,X)=>{if(J.target==="openapi-3.0")Q.type="string",Q.nullable=!0,Q.enum=[null];else Q.type="null"},_Y=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},DY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},zY=($,J,Q,X)=>{Q.not={}},RY=($,J,Q,X)=>{},IY=($,J,Q,X)=>{},jY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},bY=($,J,Q,X)=>{let Y=$._zod.def,W=f3(Y.entries);if(W.every((K)=>typeof K==="number"))Q.type="number";if(W.every((K)=>typeof K==="string"))Q.type="string";Q.enum=W},PY=($,J,Q,X)=>{let Y=$._zod.def,W=[];for(let K of Y.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 W.push(Number(K));else W.push(K);if(W.length===0);else if(W.length===1){let K=W[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(W.every((K)=>typeof K==="number"))Q.type="number";if(W.every((K)=>typeof K==="string"))Q.type="string";if(W.every((K)=>typeof K==="boolean"))Q.type="boolean";if(W.every((K)=>K===null))Q.type="null";Q.enum=W}},AY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},EY=($,J,Q,X)=>{let Y=Q,W=$._zod.pattern;if(!W)throw Error("Pattern not found in template literal");Y.type="string",Y.pattern=W.source},CY=($,J,Q,X)=>{let Y=Q,W={type:"string",format:"binary",contentEncoding:"binary"},{minimum:K,maximum:B,mime:q}=$._zod.bag;if(K!==void 0)W.minLength=K;if(B!==void 0)W.maxLength=B;if(q)if(q.length===1)W.contentMediaType=q[0],Object.assign(Y,W);else Object.assign(Y,W),Y.anyOf=q.map((U)=>({contentMediaType:U}));else Object.assign(Y,W)},SY=($,J,Q,X)=>{Q.type="boolean"},TY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},wY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},vY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},fY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},hY=($,J,Q,X)=>{if(J.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},kY=($,J,Q,X)=>{let Y=Q,W=$._zod.def,{minimum:K,maximum:B}=$._zod.bag;if(typeof K==="number")Y.minItems=K;if(typeof B==="number")Y.maxItems=B;Y.type="array",Y.items=n(W.element,J,{...X,path:[...X.path,"items"]})},gY=($,J,Q,X)=>{let Y=Q,W=$._zod.def;Y.type="object",Y.properties={};let K=W.shape;for(let U in K)Y.properties[U]=n(K[U],J,{...X,path:[...X.path,"properties",U]});let B=new Set(Object.keys(K)),q=new Set([...B].filter((U)=>{let G=W.shape[U]._zod;if(J.io==="input")return G.optin===void 0;else return G.optout===void 0}));if(q.size>0)Y.required=Array.from(q);if(W.catchall?._zod.def.type==="never")Y.additionalProperties=!1;else if(!W.catchall){if(J.io==="output")Y.additionalProperties=!1}else if(W.catchall)Y.additionalProperties=n(W.catchall,J,{...X,path:[...X.path,"additionalProperties"]})},Z8=($,J,Q,X)=>{let Y=$._zod.def,W=Y.inclusive===!1,K=Y.options.map((B,q)=>n(B,J,{...X,path:[...X.path,W?"oneOf":"anyOf",q]}));if(W)Q.oneOf=K;else Q.anyOf=K},yY=($,J,Q,X)=>{let Y=$._zod.def,W=n(Y.left,J,{...X,path:[...X.path,"allOf",0]}),K=n(Y.right,J,{...X,path:[...X.path,"allOf",1]}),B=(U)=>("allOf"in U)&&Object.keys(U).length===1,q=[...B(W)?W.allOf:[W],...B(K)?K.allOf:[K]];Q.allOf=q},xY=($,J,Q,X)=>{let Y=Q,W=$._zod.def;Y.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=W.items.map((L,Z)=>n(L,J,{...X,path:[...X.path,K,Z]})),U=W.rest?n(W.rest,J,{...X,path:[...X.path,B,...J.target==="openapi-3.0"?[W.items.length]:[]]}):null;if(J.target==="draft-2020-12"){if(Y.prefixItems=q,U)Y.items=U}else if(J.target==="openapi-3.0"){if(Y.items={anyOf:q},U)Y.items.anyOf.push(U);if(Y.minItems=q.length,!U)Y.maxItems=q.length}else if(Y.items=q,U)Y.additionalItems=U;let{minimum:G,maximum:H}=$._zod.bag;if(typeof G==="number")Y.minItems=G;if(typeof H==="number")Y.maxItems=H},uY=($,J,Q,X)=>{let Y=Q,W=$._zod.def;Y.type="object";let K=W.keyType,q=K._zod.bag?.patterns;if(W.mode==="loose"&&q&&q.size>0){let G=n(W.valueType,J,{...X,path:[...X.path,"patternProperties","*"]});Y.patternProperties={};for(let H of q)Y.patternProperties[H.source]=G}else{if(J.target==="draft-07"||J.target==="draft-2020-12")Y.propertyNames=n(W.keyType,J,{...X,path:[...X.path,"propertyNames"]});Y.additionalProperties=n(W.valueType,J,{...X,path:[...X.path,"additionalProperties"]})}let U=K._zod.values;if(U){let G=[...U].filter((H)=>typeof H==="string"||typeof H==="number");if(G.length>0)Y.required=G}},mY=($,J,Q,X)=>{let Y=$._zod.def,W=n(Y.innerType,J,X),K=J.seen.get($);if(J.target==="openapi-3.0")K.ref=Y.innerType,Q.nullable=!0;else Q.anyOf=[W,{type:"null"}]},lY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType},pY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType,Q.default=JSON.parse(JSON.stringify(Y.defaultValue))},cY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);if(W.ref=Y.innerType,J.io==="input")Q._prefault=JSON.parse(JSON.stringify(Y.defaultValue))},dY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType;let K;try{K=Y.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}Q.default=K},rY=($,J,Q,X)=>{let Y=$._zod.def,W=J.io==="input"?Y.in._zod.def.type==="transform"?Y.out:Y.in:Y.out;n(W,J,X);let K=J.seen.get($);K.ref=W},iY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType,Q.readOnly=!0},oY=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType},L8=($,J,Q,X)=>{let Y=$._zod.def;n(Y.innerType,J,X);let W=J.seen.get($);W.ref=Y.innerType},nY=($,J,Q,X)=>{let Y=$._zod.innerType;n(Y,J,X);let W=J.seen.get($);W.ref=Y},H8={string:LY,number:MY,boolean:OY,bigint:NY,symbol:FY,null:VY,undefined:_Y,void:DY,never:zY,any:RY,unknown:IY,date:jY,enum:bY,literal:PY,nan:AY,template_literal:EY,file:CY,success:SY,custom:TY,function:wY,transform:vY,map:fY,set:hY,array:kY,object:gY,union:Z8,intersection:yY,tuple:xY,record:uY,nullable:mY,nonoptional:lY,default:pY,prefault:cY,catch:dY,pipe:rY,readonly:iY,promise:oY,optional:L8,lazy:nY};function s3($,J){if("_idmap"in $){let X=$,Y=h4({...J,processors:H8}),W={};for(let q of X._idmap.entries()){let[U,G]=q;n(G,Y)}let K={},B={registry:X,uri:J?.uri,defs:W};Y.external=B;for(let q of X._idmap.entries()){let[U,G]=q;k4(Y,G),K[U]=g4(Y,G)}if(Object.keys(W).length>0){let q=Y.target==="draft-2020-12"?"$defs":"definitions";K.__shared={[q]:W}}return{schemas:K}}let Q=h4({...J,processors:H8});return n($,Q),k4(Q,$),g4(Q,$)}class sY{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=h4({processors:H8,target:J,...$?.metadata&&{metadata:$.metadata},...$?.unrepresentable&&{unrepresentable:$.unrepresentable},...$?.override&&{override:$.override},...$?.io&&{io:$.io}})}process($,J={path:[],schemaPath:[]}){return n($,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}k4(this.ctx,$);let Q=g4(this.ctx,$),{"~standard":X,...Y}=Q;return Y}}var fH={};var J6={};B2(J6,{time:()=>eY,duration:()=>$W,datetime:()=>aY,date:()=>tY,ZodISOTime:()=>e3,ZodISODuration:()=>$6,ZodISODateTime:()=>a3,ZodISODate:()=>t3});var a3=N("ZodISODateTime",($,J)=>{CX.init($,J),r.init($,J)});function aY($){return T5(a3,$)}var t3=N("ZodISODate",($,J)=>{SX.init($,J),r.init($,J)});function tY($){return w5(t3,$)}var e3=N("ZodISOTime",($,J)=>{TX.init($,J),r.init($,J)});function eY($){return v5(e3,$)}var $6=N("ZodISODuration",($,J)=>{wX.init($,J),r.init($,J)});function $W($){return f5($6,$)}var kH=($,J)=>{x3.init($,J),$.name="ZodError",Object.defineProperties($,{format:{value:(Q)=>O4($,Q)},flatten:{value:(Q)=>M4($,Q)},addIssue:{value:(Q)=>{$.issues.push(Q),$.message=JSON.stringify($.issues,H4,2)}},addIssues:{value:(Q)=>{$.issues.push(...Q),$.message=JSON.stringify($.issues,H4,2)}},isEmpty:{get(){return $.issues.length===0}}})},gH=N("ZodError",kH),z1=N("ZodError",kH,{Parent:Error});var M8=N4(z1),O8=F4(z1),N8=V4(z1),F8=_4(z1),V8=O$(z1),_8=N$(z1),D8=F$(z1),z8=V$(z1),R8=_$(z1),I8=D$(z1),j8=z$(z1),b8=R$(z1);var g=N("ZodType",($,J)=>{return v.init($,J),Object.assign($["~standard"],{jsonSchema:{input:G8($,"input"),output:G8($,"output")}}),$.toJSONSchema=ZY($,{}),$.def=J,$.type=J.type,Object.defineProperty($,"_def",{value:J}),$.check=(...Q)=>{return $.clone(w.mergeDefs(J,{checks:[...J.checks??[],...Q.map((X)=>typeof X==="function"?{_zod:{check:X,def:{check:"custom"},onattach:[]}}:X)]}),{parent:!0})},$.with=$.check,$.clone=(Q,X)=>N1($,Q,X),$.brand=()=>$,$.register=(Q,X)=>{return Q.add($,X),$},$.parse=(Q,X)=>M8($,Q,X,{callee:$.parse}),$.safeParse=(Q,X)=>N8($,Q,X),$.parseAsync=async(Q,X)=>O8($,Q,X,{callee:$.parseAsync}),$.safeParseAsync=async(Q,X)=>F8($,Q,X),$.spa=$.safeParseAsync,$.encode=(Q,X)=>V8($,Q,X),$.decode=(Q,X)=>_8($,Q,X),$.encodeAsync=async(Q,X)=>D8($,Q,X),$.decodeAsync=async(Q,X)=>z8($,Q,X),$.safeEncode=(Q,X)=>R8($,Q,X),$.safeDecode=(Q,X)=>I8($,Q,X),$.safeEncodeAsync=async(Q,X)=>j8($,Q,X),$.safeDecodeAsync=async(Q,X)=>b8($,Q,X),$.refine=(Q,X)=>$.check(cW(Q,X)),$.superRefine=(Q)=>$.check(dW(Q)),$.overwrite=(Q)=>$.check(Q0(Q)),$.optional=()=>X6($),$.exactOptional=()=>PW($),$.nullable=()=>Y6($),$.nullish=()=>X6(Y6($)),$.nonoptional=(Q)=>wW($,Q),$.array=()=>q6($),$.or=(Q)=>i8([$,Q]),$.and=(Q)=>NW($,Q),$.transform=(Q)=>W6($,n8(Q)),$.default=(Q)=>CW($,Q),$.prefault=(Q)=>TW($,Q),$.catch=(Q)=>hW($,Q),$.pipe=(Q)=>W6($,Q),$.readonly=()=>yW($),$.describe=(Q)=>{let X=$.clone();return E1.add(X,{description:Q}),X},Object.defineProperty($,"description",{get(){return E1.get($)?.description},configurable:!0}),$.meta=(...Q)=>{if(Q.length===0)return E1.get($);let X=$.clone();return E1.add(X,Q[0]),X},$.isOptional=()=>$.safeParse(void 0).success,$.isNullable=()=>$.safeParse(null).success,$.apply=(Q)=>Q($),$}),E8=N("_ZodString",($,J)=>{w2.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>LY($,X,Y,W);let Q=$._zod.bag;$.format=Q.format??null,$.minLength=Q.minimum??null,$.maxLength=Q.maximum??null,$.regex=(...X)=>$.check(z4(...X)),$.includes=(...X)=>$.check(j4(...X)),$.startsWith=(...X)=>$.check(b4(...X)),$.endsWith=(...X)=>$.check(P4(...X)),$.min=(...X)=>$.check(y0(...X)),$.max=(...X)=>$.check(f2(...X)),$.length=(...X)=>$.check(h2(...X)),$.nonempty=(...X)=>$.check(y0(1,...X)),$.lowercase=(X)=>$.check(R4(X)),$.uppercase=(X)=>$.check(I4(X)),$.trim=()=>$.check(C4()),$.normalize=(...X)=>$.check(E4(...X)),$.toLowerCase=()=>$.check(S4()),$.toUpperCase=()=>$.check(T4()),$.slugify=()=>$.check(w4())}),x4=N("ZodString",($,J)=>{w2.init($,J),E8.init($,J),$.email=(Q)=>$.check(y$(C8,Q)),$.url=(Q)=>$.check(n3(K6,Q)),$.jwt=(Q)=>$.check(X8(c8,Q)),$.emoji=(Q)=>$.check(p$(S8,Q)),$.guid=(Q)=>$.check(o3(Q6,Q)),$.uuid=(Q)=>$.check(x$(R0,Q)),$.uuidv4=(Q)=>$.check(u$(R0,Q)),$.uuidv6=(Q)=>$.check(m$(R0,Q)),$.uuidv7=(Q)=>$.check(l$(R0,Q)),$.nanoid=(Q)=>$.check(c$(T8,Q)),$.guid=(Q)=>$.check(o3(Q6,Q)),$.cuid=(Q)=>$.check(d$(w8,Q)),$.cuid2=(Q)=>$.check(r$(v8,Q)),$.ulid=(Q)=>$.check(i$(f8,Q)),$.base64=(Q)=>$.check($8(m8,Q)),$.base64url=(Q)=>$.check(J8(l8,Q)),$.xid=(Q)=>$.check(o$(h8,Q)),$.ksuid=(Q)=>$.check(n$(k8,Q)),$.ipv4=(Q)=>$.check(s$(g8,Q)),$.ipv6=(Q)=>$.check(a$(y8,Q)),$.cidrv4=(Q)=>$.check(t$(x8,Q)),$.cidrv6=(Q)=>$.check(e$(u8,Q)),$.e164=(Q)=>$.check(Q8(p8,Q)),$.datetime=(Q)=>$.check(aY(Q)),$.date=(Q)=>$.check(tY(Q)),$.time=(Q)=>$.check(eY(Q)),$.duration=(Q)=>$.check($W(Q))});function P8($){return E5(x4,$)}var r=N("ZodStringFormat",($,J)=>{d.init($,J),E8.init($,J)}),C8=N("ZodEmail",($,J)=>{DX.init($,J),r.init($,J)});function yH($){return y$(C8,$)}var Q6=N("ZodGUID",($,J)=>{VX.init($,J),r.init($,J)});function xH($){return o3(Q6,$)}var R0=N("ZodUUID",($,J)=>{_X.init($,J),r.init($,J)});function uH($){return x$(R0,$)}function mH($){return u$(R0,$)}function lH($){return m$(R0,$)}function pH($){return l$(R0,$)}var K6=N("ZodURL",($,J)=>{zX.init($,J),r.init($,J)});function cH($){return n3(K6,$)}function dH($){return n3(K6,{protocol:/^https?$/,hostname:y1.domain,...w.normalizeParams($)})}var S8=N("ZodEmoji",($,J)=>{RX.init($,J),r.init($,J)});function rH($){return p$(S8,$)}var T8=N("ZodNanoID",($,J)=>{IX.init($,J),r.init($,J)});function iH($){return c$(T8,$)}var w8=N("ZodCUID",($,J)=>{jX.init($,J),r.init($,J)});function oH($){return d$(w8,$)}var v8=N("ZodCUID2",($,J)=>{bX.init($,J),r.init($,J)});function nH($){return r$(v8,$)}var f8=N("ZodULID",($,J)=>{PX.init($,J),r.init($,J)});function sH($){return i$(f8,$)}var h8=N("ZodXID",($,J)=>{AX.init($,J),r.init($,J)});function aH($){return o$(h8,$)}var k8=N("ZodKSUID",($,J)=>{EX.init($,J),r.init($,J)});function tH($){return n$(k8,$)}var g8=N("ZodIPv4",($,J)=>{vX.init($,J),r.init($,J)});function eH($){return s$(g8,$)}var JW=N("ZodMAC",($,J)=>{hX.init($,J),r.init($,J)});function $Z($){return S5(JW,$)}var y8=N("ZodIPv6",($,J)=>{fX.init($,J),r.init($,J)});function JZ($){return a$(y8,$)}var x8=N("ZodCIDRv4",($,J)=>{kX.init($,J),r.init($,J)});function QZ($){return t$(x8,$)}var u8=N("ZodCIDRv6",($,J)=>{gX.init($,J),r.init($,J)});function XZ($){return e$(u8,$)}var m8=N("ZodBase64",($,J)=>{xX.init($,J),r.init($,J)});function YZ($){return $8(m8,$)}var l8=N("ZodBase64URL",($,J)=>{uX.init($,J),r.init($,J)});function WZ($){return J8(l8,$)}var p8=N("ZodE164",($,J)=>{mX.init($,J),r.init($,J)});function KZ($){return Q8(p8,$)}var c8=N("ZodJWT",($,J)=>{lX.init($,J),r.init($,J)});function BZ($){return X8(c8,$)}var u4=N("ZodCustomStringFormat",($,J)=>{pX.init($,J),r.init($,J)});function qZ($,J,Q={}){return v4(u4,$,J,Q)}function UZ($){return v4(u4,"hostname",y1.hostname,$)}function GZ($){return v4(u4,"hex",y1.hex,$)}function HZ($,J){let Q=J?.enc??"hex",X=`${$}_${Q}`,Y=y1[X];if(!Y)throw Error(`Unrecognized hash format: ${X}`);return v4(u4,X,Y,J)}var m4=N("ZodNumber",($,J)=>{w$.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>MY($,X,Y,W),$.gt=(X,Y)=>$.check(_0(X,Y)),$.gte=(X,Y)=>$.check(D1(X,Y)),$.min=(X,Y)=>$.check(D1(X,Y)),$.lt=(X,Y)=>$.check(V0(X,Y)),$.lte=(X,Y)=>$.check(x1(X,Y)),$.max=(X,Y)=>$.check(x1(X,Y)),$.int=(X)=>$.check(A8(X)),$.safe=(X)=>$.check(A8(X)),$.positive=(X)=>$.check(_0(0,X)),$.nonnegative=(X)=>$.check(D1(0,X)),$.negative=(X)=>$.check(V0(0,X)),$.nonpositive=(X)=>$.check(x1(0,X)),$.multipleOf=(X,Y)=>$.check(Y2(X,Y)),$.step=(X,Y)=>$.check(Y2(X,Y)),$.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 QW($){return h5(m4,$)}var g2=N("ZodNumberFormat",($,J)=>{cX.init($,J),m4.init($,J)});function A8($){return g5(g2,$)}function ZZ($){return y5(g2,$)}function LZ($){return x5(g2,$)}function MZ($){return u5(g2,$)}function OZ($){return m5(g2,$)}var l4=N("ZodBoolean",($,J)=>{p3.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>OY($,Q,X,Y)});function XW($){return l5(l4,$)}var p4=N("ZodBigInt",($,J)=>{v$.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>NY($,X,Y,W),$.gte=(X,Y)=>$.check(D1(X,Y)),$.min=(X,Y)=>$.check(D1(X,Y)),$.gt=(X,Y)=>$.check(_0(X,Y)),$.gte=(X,Y)=>$.check(D1(X,Y)),$.min=(X,Y)=>$.check(D1(X,Y)),$.lt=(X,Y)=>$.check(V0(X,Y)),$.lte=(X,Y)=>$.check(x1(X,Y)),$.max=(X,Y)=>$.check(x1(X,Y)),$.positive=(X)=>$.check(_0(BigInt(0),X)),$.negative=(X)=>$.check(V0(BigInt(0),X)),$.nonpositive=(X)=>$.check(x1(BigInt(0),X)),$.nonnegative=(X)=>$.check(D1(BigInt(0),X)),$.multipleOf=(X,Y)=>$.check(Y2(X,Y));let Q=$._zod.bag;$.minValue=Q.minimum??null,$.maxValue=Q.maximum??null,$.format=Q.format??null});function NZ($){return c5(p4,$)}var d8=N("ZodBigIntFormat",($,J)=>{dX.init($,J),p4.init($,J)});function FZ($){return r5(d8,$)}function VZ($){return i5(d8,$)}var YW=N("ZodSymbol",($,J)=>{rX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>FY($,Q,X,Y)});function _Z($){return o5(YW,$)}var WW=N("ZodUndefined",($,J)=>{iX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>_Y($,Q,X,Y)});function DZ($){return n5(WW,$)}var KW=N("ZodNull",($,J)=>{oX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>VY($,Q,X,Y)});function BW($){return s5(KW,$)}var qW=N("ZodAny",($,J)=>{nX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>RY($,Q,X,Y)});function zZ(){return a5(qW)}var UW=N("ZodUnknown",($,J)=>{sX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>IY($,Q,X,Y)});function k2(){return t5(UW)}var GW=N("ZodNever",($,J)=>{aX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>zY($,Q,X,Y)});function r8($){return e5(GW,$)}var HW=N("ZodVoid",($,J)=>{tX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>DY($,Q,X,Y)});function RZ($){return $Y(HW,$)}var B6=N("ZodDate",($,J)=>{eX.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>jY($,X,Y,W),$.min=(X,Y)=>$.check(D1(X,Y)),$.max=(X,Y)=>$.check(x1(X,Y));let Q=$._zod.bag;$.minDate=Q.minimum?new Date(Q.minimum):null,$.maxDate=Q.maximum?new Date(Q.maximum):null});function IZ($){return JY(B6,$)}var ZW=N("ZodArray",($,J)=>{$5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>kY($,Q,X,Y),$.element=J.element,$.min=(Q,X)=>$.check(y0(Q,X)),$.nonempty=(Q)=>$.check(y0(1,Q)),$.max=(Q,X)=>$.check(f2(Q,X)),$.length=(Q,X)=>$.check(h2(Q,X)),$.unwrap=()=>$.element});function q6($,J){return YY(ZW,$,J)}function jZ($){let J=$._zod.def.shape;return o8(Object.keys(J))}var U6=N("ZodObject",($,J)=>{J5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>gY($,Q,X,Y),w.defineLazy($,"shape",()=>{return J.shape}),$.keyof=()=>o8(Object.keys($._zod.def.shape)),$.catchall=(Q)=>$.clone({...$._zod.def,catchall:Q}),$.passthrough=()=>$.clone({...$._zod.def,catchall:k2()}),$.loose=()=>$.clone({...$._zod.def,catchall:k2()}),$.strict=()=>$.clone({...$._zod.def,catchall:r8()}),$.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(s8,$,Q[0]),$.required=(...Q)=>w.required(a8,$,Q[0])});function bZ($,J){let Q={type:"object",shape:$??{},...w.normalizeParams(J)};return new U6(Q)}function PZ($,J){return new U6({type:"object",shape:$,catchall:r8(),...w.normalizeParams(J)})}function AZ($,J){return new U6({type:"object",shape:$,catchall:k2(),...w.normalizeParams(J)})}var G6=N("ZodUnion",($,J)=>{c3.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>Z8($,Q,X,Y),$.options=J.options});function i8($,J){return new G6({type:"union",options:$,...w.normalizeParams(J)})}var LW=N("ZodXor",($,J)=>{G6.init($,J),Q5.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>Z8($,Q,X,Y),$.options=J.options});function EZ($,J){return new LW({type:"union",options:$,inclusive:!1,...w.normalizeParams(J)})}var MW=N("ZodDiscriminatedUnion",($,J)=>{G6.init($,J),X5.init($,J)});function CZ($,J,Q){return new MW({type:"union",options:J,discriminator:$,...w.normalizeParams(Q)})}var OW=N("ZodIntersection",($,J)=>{Y5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>yY($,Q,X,Y)});function NW($,J){return new OW({type:"intersection",left:$,right:J})}var FW=N("ZodTuple",($,J)=>{f$.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>xY($,Q,X,Y),$.rest=(Q)=>$.clone({...$._zod.def,rest:Q})});function VW($,J,Q){let X=J instanceof v,Y=X?Q:J;return new FW({type:"tuple",items:$,rest:X?J:null,...w.normalizeParams(Y)})}var H6=N("ZodRecord",($,J)=>{W5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>uY($,Q,X,Y),$.keyType=J.keyType,$.valueType=J.valueType});function _W($,J,Q){return new H6({type:"record",keyType:$,valueType:J,...w.normalizeParams(Q)})}function SZ($,J,Q){let X=N1($);return X._zod.values=void 0,new H6({type:"record",keyType:X,valueType:J,...w.normalizeParams(Q)})}function TZ($,J,Q){return new H6({type:"record",keyType:$,valueType:J,mode:"loose",...w.normalizeParams(Q)})}var DW=N("ZodMap",($,J)=>{K5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>fY($,Q,X,Y),$.keyType=J.keyType,$.valueType=J.valueType,$.min=(...Q)=>$.check(D0(...Q)),$.nonempty=(Q)=>$.check(D0(1,Q)),$.max=(...Q)=>$.check(W2(...Q)),$.size=(...Q)=>$.check(v2(...Q))});function wZ($,J,Q){return new DW({type:"map",keyType:$,valueType:J,...w.normalizeParams(Q)})}var zW=N("ZodSet",($,J)=>{B5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>hY($,Q,X,Y),$.min=(...Q)=>$.check(D0(...Q)),$.nonempty=(Q)=>$.check(D0(1,Q)),$.max=(...Q)=>$.check(W2(...Q)),$.size=(...Q)=>$.check(v2(...Q))});function vZ($,J){return new zW({type:"set",valueType:$,...w.normalizeParams(J)})}var y4=N("ZodEnum",($,J)=>{q5.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>bY($,X,Y,W),$.enum=J.entries,$.options=Object.values(J.entries);let Q=new Set(Object.keys(J.entries));$.extract=(X,Y)=>{let W={};for(let K of X)if(Q.has(K))W[K]=J.entries[K];else throw Error(`Key ${K} not found in enum`);return new y4({...J,checks:[],...w.normalizeParams(Y),entries:W})},$.exclude=(X,Y)=>{let W={...J.entries};for(let K of X)if(Q.has(K))delete W[K];else throw Error(`Key ${K} not found in enum`);return new y4({...J,checks:[],...w.normalizeParams(Y),entries:W})}});function o8($,J){let Q=Array.isArray($)?Object.fromEntries($.map((X)=>[X,X])):$;return new y4({type:"enum",entries:Q,...w.normalizeParams(J)})}function fZ($,J){return new y4({type:"enum",entries:$,...w.normalizeParams(J)})}var RW=N("ZodLiteral",($,J)=>{U5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>PY($,Q,X,Y),$.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 hZ($,J){return new RW({type:"literal",values:Array.isArray($)?$:[$],...w.normalizeParams(J)})}var IW=N("ZodFile",($,J)=>{G5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>CY($,Q,X,Y),$.min=(Q,X)=>$.check(D0(Q,X)),$.max=(Q,X)=>$.check(W2(Q,X)),$.mime=(Q,X)=>$.check(A4(Array.isArray(Q)?Q:[Q],X))});function kZ($){return WY(IW,$)}var jW=N("ZodTransform",($,J)=>{H5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>vY($,Q,X,Y),$._zod.parse=(Q,X)=>{if(X.direction==="backward")throw new C2($.constructor.name);Q.addIssue=(W)=>{if(typeof W==="string")Q.issues.push(w.issue(W,Q.value,J));else{let K=W;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 Y=J.transform(Q.value,Q);if(Y instanceof Promise)return Y.then((W)=>{return Q.value=W,Q});return Q.value=Y,Q}});function n8($){return new jW({type:"transform",transform:$})}var s8=N("ZodOptional",($,J)=>{h$.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>L8($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function X6($){return new s8({type:"optional",innerType:$})}var bW=N("ZodExactOptional",($,J)=>{Z5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>L8($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function PW($){return new bW({type:"optional",innerType:$})}var AW=N("ZodNullable",($,J)=>{L5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>mY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function Y6($){return new AW({type:"nullable",innerType:$})}function gZ($){return X6(Y6($))}var EW=N("ZodDefault",($,J)=>{M5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>pY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType,$.removeDefault=$.unwrap});function CW($,J){return new EW({type:"default",innerType:$,get defaultValue(){return typeof J==="function"?J():w.shallowClone(J)}})}var SW=N("ZodPrefault",($,J)=>{O5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>cY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function TW($,J){return new SW({type:"prefault",innerType:$,get defaultValue(){return typeof J==="function"?J():w.shallowClone(J)}})}var a8=N("ZodNonOptional",($,J)=>{N5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>lY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function wW($,J){return new a8({type:"nonoptional",innerType:$,...w.normalizeParams(J)})}var vW=N("ZodSuccess",($,J)=>{F5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>SY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function yZ($){return new vW({type:"success",innerType:$})}var fW=N("ZodCatch",($,J)=>{V5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>dY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType,$.removeCatch=$.unwrap});function hW($,J){return new fW({type:"catch",innerType:$,catchValue:typeof J==="function"?J:()=>J})}var kW=N("ZodNaN",($,J)=>{_5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>AY($,Q,X,Y)});function xZ($){return XY(kW,$)}var t8=N("ZodPipe",($,J)=>{D5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>rY($,Q,X,Y),$.in=J.in,$.out=J.out});function W6($,J){return new t8({type:"pipe",in:$,out:J})}var e8=N("ZodCodec",($,J)=>{t8.init($,J),d3.init($,J)});function uZ($,J,Q){return new e8({type:"pipe",in:$,out:J,transform:Q.decode,reverseTransform:Q.encode})}var gW=N("ZodReadonly",($,J)=>{z5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>iY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function yW($){return new gW({type:"readonly",innerType:$})}var xW=N("ZodTemplateLiteral",($,J)=>{R5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>EY($,Q,X,Y)});function mZ($,J){return new xW({type:"template_literal",parts:$,...w.normalizeParams(J)})}var uW=N("ZodLazy",($,J)=>{b5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>nY($,Q,X,Y),$.unwrap=()=>$._zod.def.getter()});function mW($){return new uW({type:"lazy",getter:$})}var lW=N("ZodPromise",($,J)=>{j5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>oY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function lZ($){return new lW({type:"promise",innerType:$})}var pW=N("ZodFunction",($,J)=>{I5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>wY($,Q,X,Y)});function pZ($){return new pW({type:"function",input:Array.isArray($?.input)?VW($?.input):$?.input??q6(k2()),output:$?.output??k2()})}var Z6=N("ZodCustom",($,J)=>{P5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>TY($,Q,X,Y)});function cZ($){let J=new o({check:"custom"});return J._zod.check=$,J}function dZ($,J){return KY(Z6,$??(()=>!0),J)}function cW($,J={}){return BY(Z6,$,J)}function dW($){return qY($)}var rZ=UY,iZ=GY;function oZ($,J={}){let Q=new Z6({type:"custom",check:"custom",fn:(X)=>X instanceof $,abort:!0,...w.normalizeParams(J)});return Q._zod.bag.Class=$,Q._zod.check=(X)=>{if(!(X.value instanceof $))X.issues.push({code:"invalid_type",expected:$.name,input:X.value,inst:Q,path:[...Q._zod.def.path??[]]})},Q}var nZ=(...$)=>HY({Codec:e8,Boolean:l4,String:x4},...$);function sZ($){let J=mW(()=>{return i8([P8($),QW(),XW(),BW(),q6(J),_W(P8(),J)])});return J}function aZ($,J){return W6(n8($),J)}var tZ={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 eZ($){Y1({customError:$})}function $L(){return Y1().customError}var $J;(function($){})($J||($J={}));var cb=()=>{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(Y){return $[Y]??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"},X={nan:"NaN"};return(Y)=>{switch(Y.code){case"invalid_type":{let W=X[Y.expected]??Y.expected,K=z7(Y.input),B=X[K]??K;return`Invalid input: expected ${W}, received ${B}`}case"invalid_value":if(Y.values.length===1)return`Invalid input: expected ${G$(Y.values[0])}`;return`Invalid option: expected one of ${B$(Y.values,"|")}`;case"too_big":{let W=Y.inclusive?"<=":"<",K=J(Y.origin);if(K)return`Too big: expected ${Y.origin??"value"} to have ${W}${Y.maximum.toString()} ${K.unit??"elements"}`;return`Too big: expected ${Y.origin??"value"} to be ${W}${Y.maximum.toString()}`}case"too_small":{let W=Y.inclusive?">=":">",K=J(Y.origin);if(K)return`Too small: expected ${Y.origin} to have ${W}${Y.minimum.toString()} ${K.unit}`;return`Too small: expected ${Y.origin} to be ${W}${Y.minimum.toString()}`}case"invalid_format":{let W=Y;if(W.format==="starts_with")return`Invalid string: must start with "${W.prefix}"`;if(W.format==="ends_with")return`Invalid string: must end with "${W.suffix}"`;if(W.format==="includes")return`Invalid string: must include "${W.includes}"`;if(W.format==="regex")return`Invalid string: must match pattern ${W.pattern}`;return`Invalid ${Q[W.format]??Y.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${Y.divisor}`;case"unrecognized_keys":return`Unrecognized key${Y.keys.length>1?"s":""}: ${B$(Y.keys,", ")}`;case"invalid_key":return`Invalid key in ${Y.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${Y.origin}`;default:return"Invalid input"}}};function rW(){return{localeError:cb()}}var iW=()=>{throw Error("JSON Schema conversion is not bundled into this plugin artifact")};var JJ={};B2(JJ,{string:()=>db,number:()=>rb,date:()=>nb,boolean:()=>ib,bigint:()=>ob});function db($){return C5(x4,$)}function rb($){return k5(m4,$)}function ib($){return p5(l4,$)}function ob($){return d5(p4,$)}function nb($){return QY(B6,$)}Y1(rW());var sb=QJ;var JL=Object.freeze(["hard_stop","use_alternative","scope_down","manual_only","stop_and_explain"]);var L6=64,QL="Rule config exceeds CC Safety Net's safe source limit.";var ch=Object.freeze({maxSources:64,concurrency:4,maxRequests:131,maxResponseBytes:67108864});var nW=[{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"}],XJ={id:"secret.pattern.env-variant",category:"Pattern",label:".env.*",description:"Blocks environment-specific .env variants."},ab=[".bak",".backup",".copy",".disabled",".old",".orig",".save",".tmp"],tb=[{idSlug:"kube-config",label:"~/.kube/config",directoryParts:[".kube"],basename:"config"},{idSlug:"docker-config",label:"~/.docker/config.json",directoryParts:[".docker"],basename:"config.json"}],sW=[{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"]},...tb.flatMap(($)=>ab.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 YJ=[{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"]}],XL=[{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"}],eb=[".bak",".backup",".copy",".disabled",".key",".old",".orig",".pem",".save",".tmp"],aW=XL.map(($)=>({id:`secret.variant.${$.slug}.separator`,category:"Variant",label:`${$.label}-* / ${$.label}_*`,description:`Blocks ${$.label} variants with dash or underscore suffixes.`,prefix:$.prefix})),tW=XL.flatMap(($)=>eb.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}))),M6={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)$/},eW=["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:$})),$K=[{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?$/}],YL=[...nW,XJ,...sW,...aW,...tW,M6,...eW,...$K,...YJ].map(($)=>({id:$.id,category:$.category,label:$.label,...$.category==="Coding CLI config"?{defaultOff:!0}:{},..."paths"in $?{paths:$.paths}:{description:$.description}})),WL=new Set(YJ.flatMap(($)=>$.category==="Coding CLI config"?[$.id]:[])),$P=YL.map(($)=>$.id),WJ=new Set($P);var Yk=JP(import.meta.url),KL,QP=Array(L6+1).fill("over-limit"),BL=/^[^/]+\/[^/]+$/,XP=/^sha256:[a-f0-9]{64}$/,KJ=`must be an integer between ${HJ} and ${ZJ}`,YP=["version","rules","overrides","transparent_wrappers"],WP=["version","safety","workflow","destructive_command_protection","secret_protection","audit"];function qL($){if(!i1($)||!Array.isArray($.rules)||$.rules.length<=L6)return $;return{$schema:$.$schema,version:$.version,rules:QP,overrides:$.overrides,transparent_wrappers:$.transparent_wrappers}}function KP(){let $=oW,J=(_)=>{let j=$.superRefine(_);return j._zod.def.when=()=>!0,j},Q=$.enum(JL),X=$.union([$.literal("off"),$.looseObject({reason:$.string({error:"required non-empty string"}).min(1,"required non-empty string").max(o2,`must be at most ${o2} 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."),Y=$.string({error:"must be a rulebook source string"}).min(1,"must be a non-empty rulebook source string"),W=$.string({error:"must be a command string"}).regex(M2,"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(Y,{error:"must be an array of rulebook source strings"}).max(L6,QL).default([]).describe("Rulebook source strings such as project-rules or owner/repo#main/team-rules"),overrides:$.record($.string().meta({pattern:BL.source}),X).default({}).describe("Rule overrides by id"),transparent_wrappers:$.array(W,{error:"must be an array of command strings"}).default([]).describe("Commands that transparently execute a visible protected child command")}),B=(_,j)=>{if(!i1(_))return;if(Array.isArray(_.rules)&&_.rules.length<=L6){let C=new Set;_.rules.forEach((T,y)=>{if(typeof T!=="string"||T==="")return;if(T.trim()===""){j.addIssue({code:"custom",message:"must be a non-empty rulebook source string",path:["rules",y]});return}let x=o4(T);if(x){j.addIssue({code:"custom",message:x,path:["rules",y]});return}if(C.has(T)){j.addIssue({code:"custom",message:`duplicate rulebook source "${T}"`,path:["rules",y]});return}C.add(T)})}if(i1(_.overrides))for(let C of Object.keys(_.overrides)){if(BL.test(C))continue;j.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,T)=>{if(typeof C!=="string"||!M2.test(C))return;if(P.has(C)){j.addIssue({code:"custom",message:`duplicate command "${C}"`,path:["transparent_wrappers",T]});return}if(LU(C)){j.addIssue({code:"custom",message:`reserved command "${C}" cannot be a wrapper`,path:["transparent_wrappers",T]});return}P.add(C)})},q=$.preprocess(qL,K.check($.superRefine(B))),U=$.preprocess(qL,K.check(J(B))),G=$.strictObject({fail_closed:$.boolean().optional(),paranoid_rm:$.boolean().optional(),paranoid_interpreters:$.boolean().optional()}),H=(_,j)=>$.intersection($.record($.string().refine((P)=>_.has(P),{error:(P)=>`unknown ${j} 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((j,P)=>{if(!Array.isArray(j))return;let C=c2();j.forEach((T,y)=>{if(typeof T!=="string")return;let x=_(T,C);if(x)P.addIssue({code:"custom",message:x,path:[y]})})})),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(r6,"destructive command").optional(),allow_paths:L(C9).optional()}).optional(),secret_protection:$.strictObject({enabled:$.boolean().optional(),overrides:H(WJ,"secret protection").optional(),deny_paths:L(S9).optional()}).optional(),audit:$.strictObject({retention_days:$.number({error:KJ}).int(KJ).min(HJ,KJ).max(ZJ,KJ).optional().describe("Days of audit log history to keep before the sweep deletes it")}).optional()}),M=(_)=>{let j=(y,x)=>_==="legacy"?y:x,P=j("must match pattern (letters, numbers, hyphens, underscores)","must match command pattern"),C=`required non-empty string up to ${o2} characters`,T=$.looseObject({name:$.string({error:"required string"}).regex(Y0,j("must match pattern (letters, numbers, hyphens, underscores; max 64 chars)","must match rule name pattern")),command:$.string({error:j("required string","required string matching command pattern")}).regex(M2,j(P,"required string matching command pattern")),subcommand:$.string({error:j("must be a string if provided","must match command pattern")}).regex(M2,P).optional(),block_args:$.array($.string({error:j("must be a string","must be a non-empty string")}).refine((y)=>y!=="",{error:j("must not be empty","must be a non-empty string")}),{error:j("required array","required non-empty array")}).refine((y)=>y.length>0,{error:j("must have at least one element","required non-empty array")}),reason:$.string({error:j("required string",C)}).refine((y)=>y!=="",{error:j("must not be empty",C)}).refine((y)=>y.length<=o2,{error:j(`must be at most ${o2} characters`,C)}),intent:Q.optional()},{error:"must be an object"});return $.array(T,{error:j("must be an array","required array")}).check(J((y,x)=>{if(!Array.isArray(y))return;let c=new Set;y.forEach((V1,S)=>{let m=i1(V1)?V1.name:void 0;if(typeof m!=="string")return;if(c.has(m.toLowerCase())){x.addIssue({code:"custom",message:`duplicate rule name "${m}"`,path:[S,"name"]});return}c.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((_,j)=>{if(!i1(_))return;if(_.expect!=="blocked"||typeof _.rule==="string")return;j.addIssue({code:"custom",message:"required string for blocked fixtures",path:["rule"]})})),b=$.looseObject({name:$.string({error:"required string matching rule name pattern"}).regex(Y0,"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(M2,"must match command pattern"),{error:"required array"}).check(J((_,j)=>{if(!Array.isArray(_))return;let P=new Set;_.forEach((C,T)=>{if(typeof C!=="string"||!M2.test(C))return;if(P.has(C)){j.addIssue({code:"custom",message:`duplicate command "${C}"`,path:[T]});return}P.add(C)})})),rules:M("rulebook"),tests:$.array(F,{error:"must be an array if provided"}).optional()}).check(J((_,j)=>{if(!i1(_))return;let P=new Set(JK(_));if(Array.isArray(_.tests)){let T=new Set(_.tests.flatMap((y)=>i1(y)&&y.expect==="blocked"&&typeof y.rule==="string"?[y.rule]:[]));for(let y of T){if(P.has(y))continue;j.addIssue({code:"custom",message:`blocked fixture references unknown rule "${y}"`,path:["tests"]})}}if(!Array.isArray(_.allowed_commands)||!Array.isArray(_.rules))return;let C=new Set(_.allowed_commands.filter((T)=>typeof T==="string"));_.rules.forEach((T,y)=>{let x=i1(T)?T.command:void 0;if(typeof x!=="string"||C.has(x))return;j.addIssue({code:"custom",message:`"${x}" must be listed in allowed_commands`,path:["rules",y,"command"]})})})),R=$.string({error:"required string"}).refine((_)=>_.trim()!=="",{error:"required string"}),A=$.looseObject({spec:R,name:R,version:R,digest:$.string({error:"required sha256 digest"}).regex(XP,"required sha256 digest")},{error:"must be an object"}),E=$.looseObject({rulebooks:$.array($.intersection(A,$.discriminatedUnion("kind",[$.object({kind:$.literal("local-directory"),path:R}),$.object({kind:$.literal("github"),owner:R,repo:R,ref:R,commit:R,path:R,display_ref:$.unknown().optional()})],{error:(_)=>{if(!i1(_.input))return"must be an object";let j=_.input.kind;return typeof j==="string"?`unknown kind "${j}"`:"required string"}})))});return{RulesConfigSchema:q,RulesConfigDiagnosticSchema:U,RuleOverrideSchema:X,UserPolicySchema:Z,LegacyConfigSchema:O,RulebookSchema:b,RulesLockfileSchema:E}}function O6(){return KL??=KP(),KL}function UL(){return O6().RulesConfigSchema}function BP(){return O6().UserPolicySchema}function GL(){return O6().RulebookSchema}function HL(){return O6().RulesLockfileSchema}function JK($){let J=i1($)?$.rules:void 0;return(Array.isArray(J)?J:[]).flatMap((Q)=>{let X=i1(Q)?Q.name:void 0;return typeof X==="string"?[X]:[]})}function ZL($){let J=O6().RulesConfigDiagnosticSchema.safeParse($);if(J.success)return{errors:[],sources:new Set(J.data.rules)};return{errors:c4(OL(J.error.issues,YP)),sources:HP($,J.error.issues)}}function LL($){let J=BP().safeParse($);if(J.success)return[];return c4(OL(J.error.issues,WP)," ")}function c4($,J=": ",Q=" "){return[...new Set($.flatMap((X)=>ML(X,J,Q,[])))]}function ML($,J,Q,X){let Y=[...X,...$.path],W=GP(Y);if($.code==="unrecognized_keys")return $.keys.map((K)=>`${W?`${W}.`:""}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)=>ML(B,J,Q,Y))}if(Y.length===0)return[$.code==="invalid_type"?"Config must be an object":$.message];if(Y.length===1&&($.code==="too_big"||$.code==="too_small")&&$.origin==="array")return[$.message];return[`${W}${Y.length===1?Q:J}${qP($)}`]}function qP($){if($.code==="invalid_value")return`must be ${UP($.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 UP($){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 GP($){return $.map((J,Q)=>{if(typeof J==="number")return`[${J}]`;return Q===0?String(J):`.${String(J)}`}).join("")}function OL($,J){let Q=$.map((W)=>W.path[1]),X=[...new Set(Q.filter((W)=>typeof W==="string"))],Y=(W,K)=>[W.path.length===0?-1:J.indexOf(String(W.path[0])),typeof K==="number"?K:X.indexOf(String(K)),W.code==="custom"?0:1];return $.map((W,K)=>({issue:W,rank:Y(W,Q[K])})).sort((W,K)=>W.rank[0]-K.rank[0]||W.rank[1]-K.rank[1]||W.rank[2]-K.rank[2]).map((W)=>W.issue)}function HP($,J){let Q=i1($)?$.rules:void 0;if(!Array.isArray(Q))return new Set;if(J.some((Y)=>Y.path.length===1&&Y.path[0]==="rules"))return new Set;let X=new Set(J.filter((Y)=>Y.path[0]==="rules"&&typeof Y.path[1]==="number").map((Y)=>Y.path[1]));return new Set(Q.filter((Y,W)=>typeof Y==="string"&&!X.has(W)))}function i1($){return!!$&&typeof $==="object"&&!Array.isArray($)}function ZP($){return ZL($)}function QK($){try{let J=q2(LP($));if(J===null)return{config:null,errors:[]};if(!J.trim())return{config:null,errors:["Config file is empty"]};let Q=JSON.parse(J),X=ZP(Q);if(X.errors.length>0)return{config:null,errors:X.errors};let Y=UL().parse(Q);return{config:{version:1,rules:Y.rules??[],overrides:Y.overrides??{},transparent_wrappers:Y.transparent_wrappers??[]},errors:[]}}catch(J){if(J instanceof W1)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 LP($){return typeof $==="string"?P6($):$}var VP=new Set(["standard","strict","paranoid"]),_P={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:[]},audit:{retention_days:R6}};function XK($){return FP(NP(U2($)),C6)}function _L($={}){let J=IP(XK($));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 NL($){if(!I0($))return RP();let J=I0($.safety)?$.safety:{},Q=I0(J.overrides)?J.overrides:{},X=I0($.workflow)?$.workflow:{},Y=I0($.destructive_command_protection)?$.destructive_command_protection:{},W=I0($.secret_protection)?$.secret_protection:{};return{version:1,safety:{level:VP.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 X.worktree_mode==="boolean"?X.worktree_mode:!1},destructive_command_protection:{enabled:typeof Y.enabled==="boolean"?Y.enabled:!0,overrides:FL(Y.overrides,r6),allow_paths:zP(Y.allow_paths)},secret_protection:{enabled:typeof W.enabled==="boolean"?W.enabled:!0,overrides:FL(W.overrides,WJ),deny_paths:DP(W.deny_paths)},audit:{retention_days:I6(I0($.audit)?$.audit.retention_days:void 0)}}}function FL($,J){if(!I0($))return{};return Object.fromEntries(Object.entries($).flatMap(([Q,X])=>J.has(Q)&&(X==="on"||X==="off")?[[Q,X]]:[]))}function DP($){if(!Array.isArray($))return[];let J=c2();return $.filter((Q)=>S9(Q,J)===null)}function zP($){if(!Array.isArray($))return[];let J=c2();return $.filter((Q)=>C9(Q,J)===null)}function I0($){return!!$&&typeof $==="object"&&!Array.isArray($)}function RP(){return structuredClone(_P)}function IP($){let J=jP();if(!MP($)){let Q=globalThis.__CC_SAFETY_NET_EMBEDDED_POLICY__;if(!I0(Q))return{policy:J,errors:[]};return{policy:VL(NL(Q)),errors:[]}}try{let Q=OP($,"utf-8");if(!Q.trim())return{policy:J,errors:[`${$}: Config file is empty`],fallback:"defaults"};let X=JSON.parse(Q),Y=LL(X),W=VL(NL(X));if(Y.length>0)return{policy:W,errors:Y.map((K)=>`${$}: ${K}`),fallback:I0(X)?"salvaged":"defaults"};return{policy:W,errors:[]}}catch(Q){let X=Q instanceof Error?Q.message:String(Q);return{policy:J,errors:[`${$}: ${Q instanceof SyntaxError?"Invalid JSON":X}`],fallback:"defaults"}}}function DL($){let J=Object.entries($),Q=new Set(J.flatMap(([X,Y])=>Y==="on"?[X]:[]));return new Set([...[...WL].filter((X)=>!Q.has(X)),...J.flatMap(([X,Y])=>Y==="off"?[X]:[])])}function jP(){return{safety:{},worktreeMode:!1,destructiveCommandProtectionEnabled:!0,destructiveCommandRuleOverrides:{},destructiveCommandAllowPaths:[],secretProtection:{enabled:!0,disabledRules:DL({}),denyPaths:[]}}}function VL($){return{safety:bP($.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:DL($.secret_protection.overrides),denyPaths:[...$.secret_protection.deny_paths]}}}function bP($){return{level:$.level,overrides:{failClosed:$.overrides.fail_closed,paranoidRm:$.overrides.paranoid_rm,paranoidInterpreters:$.overrides.paranoid_interpreters}}}var jL="This path contains the protected policy config and you must not modify or delete it.",PP=new Set(["[","cat","file","grep","head","jq","less","ls","more","rg","sed","stat","tail","test","wc"]);function bL($){let J=H2(E0()),Q=wP($.invocation.context.executionCwd,J);if($.invocation.route.kind==="patch")return zL($.paths.map((Y)=>Y.raw),!1,$.invocation.context.executionCwd,Q,J);let X=w1($,"input-candidate");if($.invocation.route.kind==="command")return X?RL(X.shell,$.invocation.context.executionCwd,Q,J):null;if($.invocation.route.kind==="unknown"&&X){let Y=RL(X.shell,$.invocation.context.executionCwd,Q,J);if(Y)return Y}return zL($.paths.map((Y)=>Y.raw),$.invocation.route.kind==="grep"||$.invocation.route.kind==="glob"||j9($.invocation.toolName),$.invocation.context.executionCwd,Q,J)}function zL($,J,Q,X,Y){if(J)return null;let W=$.find((K)=>N6(K,Q,X,Y));return W?{target:W}:null}function RL($,J,Q,X){let Y=P9($,J,X,{findSegmentTarget:(W,K)=>AP(W,K,Q,X)?.target??null,isRedirectionTarget:(W,K)=>N6(W,K.cwd,Q,X),findMalformedTarget:(W)=>TP(W,J,Q,X)?.target??null,normalizeCwd:O1});return Y?{target:Y}:null}function AP($,J,Q,X){if(M3($))return null;let Y=X.environment,W=l1([...$],Y),K=l(W[0]??"").toLowerCase(),B=W.slice(1);if(K==="rm"&&EP(B)){let q=CP(B).find((U)=>IL(f1(U,J.variables),J.cwd,Q,X));if(q)return{target:q}}if(K==="find"){if(y9(W,1)||AQ(W,Y)){let U=(g9(p(W))??p(["."])).find((G)=>{let H=f1(G.text,J.variables);return N6(H,J.cwd,Q,X)||IL(H,J.cwd,Q,X)})?.text;if(U)return{target:U}}}if(K==="mv"){let q=A9(B).sources.find((U)=>vP(f1(U,J.variables),J.cwd,Q,X));if(q)return{target:q}}if(SP($,Y))return null;for(let q of $)for(let U of PL(q))if(N6(f1(U,J.variables),J.cwd,Q,X))return{target:U};return null}function EP($){return $.some((J)=>J==="--recursive"||J.startsWith("-")&&!J.startsWith("--")&&/[rR]/.test(J.slice(1)))}function CP($){let J=$.indexOf("--");if(J!==-1)return[...$.slice(0,J).filter((Q)=>!Q.startsWith("-")),...$.slice(J+1)];return $.filter((Q)=>!Q.startsWith("-"))}function SP($,J){let Q=l1([...$],J);if(Q.length===0)return!1;let X=l(Q[0]??"").toLowerCase();if(!PP.has(X))return!1;if(X!=="sed")return!0;return!Q.slice(1).some((Y)=>Y.startsWith("-i")||Y==="--in-place"||Y.startsWith("--in-place="))}function TP($,J,Q,X){for(let Y of $.split(/\s+/))for(let W of PL(Y))if(N6(W,J,Q,X))return{target:W};return null}function PL($){let J=$.trim().replace(/^['"]|['"]$/g,""),Q=J.indexOf("=");return Q===-1||Q===J.length-1?[J]:[J,J.slice(Q+1)]}function wP($,J){let Q=O1(XK(),$,J),X=YK(Q),Y=new Set;for(let W=X;;W=YK(W))if(Y.add(d4(W)),YK(W)===W)break;return{file:d4(Q),directory:d4(X),directoryAndAncestors:Y}}function N6($,J,Q,X){return d4(O1($,J,X))===Q.file}function IL($,J,Q,X){return Q.directoryAndAncestors.has(d4(O1($,J,X)))}function vP($,J,Q,X){let Y=d4(O1($,J,X));return Y===Q.file||Q.directoryAndAncestors.has(Y)}function d4($){return process.platform==="win32"?$.toLowerCase():$}import{homedir as fP}from"node:os";import{isAbsolute as KK,resolve as hL}from"node:path";import{fileURLToPath as hP}from"node:url";var kL="Access to a sensitive path is not allowed.",gL=new Set(["echo","printf"]),kP=new Set(["find"]),gP=new Set(["-exec","-execdir"]),yP=new Set([";","+"]),xP=new Set(["-delete","-exec","-execdir","-fls","-fprint","-fprint0","-fprintf","-ok","-okdir"]),uP=new Set(["-name","-iname","-path","-ipath","-wholename","-iwholename","-samefile"]),mP=new Set(["python","python2","python3","node","deno","bun","ruby","perl","php","rscript","osascript","bash","sh","zsh","dash","ksh"]),lP=new Set(["node","bun"]),pP=new Set(["bun","child_process","deno","dotenv","fs","subprocess"]),cP=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"]),yL=new Set(["-c","-e","-r","-E","--eval","--exec"]),dP=new Set(["src/cli/cc-safety-net.ts","dist/bin/cc-safety-net.js"]),rP=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"])]]),iP=new Set(["grep","rg"]),AL="f",EL="file",oP="files",nP=new Set(["e","f"]),sP=new Set(["regexp","file"]),aP=new Set(["e","f","A","B","C","m"]),tP=new Set(["regexp","file","after-context","before-context","context","max-count"]),eP=new Set(["|","|&"]),WK="__CC_SAFETY_NET_PIPE_INPUT__",xL=new Set(["bash","sh","zsh","dash","ksh"]),$A=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 CL($,J,Q,X,Y){let W=s4();for(let K of $){if(yA(K,J,Q?.denyPaths??[],X,W))return{target:K,ruleId:"secret.deny-path"};if(Y&&!Y.has(K))continue;let B=kA(K,J,Q,W);if(B)return{target:K,ruleId:B}}return null}function uL($,J,Q={}){let X=SL($),Y=CL(X,$.invocation.context.executionCwd,J,$.invocation.context.configCwd),W=Y?.ruleId!=="secret.deny-path"&&Q.strict===!1?SL($,{refineJavaScriptInlineData:!0}):X,K=W.length===X.length?Y:CL(X,$.invocation.context.executionCwd,J,$.invocation.context.configCwd,new Set(W));if(K?.ruleId!=="secret.deny-path"&&Q.strict===!1&&JA($))return null;return K}function JA($){if($.invocation.route.kind!=="command")return!1;let J=w1($,"input-candidate")??w1($,"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(G0(K.text))}let X=i4(Q);if(X.length===0)return!1;let Y=y2(X[0]??"").toLowerCase(),W=X.slice(1);if(Y==="test")return W.length===2&&(W[0]==="-e"||W[0]==="-f");if(Y!=="find")return!1;return!W.some((K)=>xP.has(K))}function SL($,J={}){if($.invocation.route.kind==="command"){let X=w1($,"input-candidate");return X?_6(X.shell,$.store,J):[]}if($.invocation.route.kind!=="unknown")return $.paths.map((X)=>X.raw);let Q=w1($,"input-candidate");return[...Q?_6(Q.shell,$.store,J):[],...$.paths.map((X)=>X.raw)]}function _6($,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 X=[...$.assignmentFallbacks,...zA(G0($.source),J,Q)],Y=[],W=null;for(let K of $.entries){if(K.kind==="operator"){if(!K.boundary)continue;if(Y.length>0){if(X.push(...BJ(Y,J,Q)),W!==null)X.push(...TL(W,Y,J,Q));W=eP.has(K.operator)?Y:null,Y=[]}else W=null;continue}if(K.kind==="redirection"){let B=K.target?G0(K.target):void 0;if(B&&K.targetOrder==="legacy-segment")Y.push(B);else if(B)X.push(B);continue}Y.push(G0(K.text))}if(Y.length>0){if(X.push(...BJ(Y,J,Q)),W!==null)X.push(...TL(W,Y,J,Q))}return X}function BJ($,J,Q){let X=HA($),Y=i4($);if(Y.length===0)return X;let W=Y[0]??"",K=y2(W).toLowerCase(),B=Y.slice(1),q=QA(W,K,B);if(q)return[...X,...q];if(gL.has(K))return X;if(iP.has(K))return[...X,...CA(B)];if(kP.has(K))return[...X,...ZA(B,J,Q)];if(h1.has(K))return[...X,...B.flatMap((U)=>wL("awk",U)),...B.flatMap((U)=>MA(U,J,Q)),...B.flatMap(OA)];if(pL(K)){if(xL.has(K)){let U=xq(K,B);if(U!==null&&J.getShellSyntax(U).status==="structural-limit")throw new n0}return[...X,...LA(K,B,Q)]}return[...X,...B.flatMap((U)=>wL(K,U))]}function QA($,J,Q){let X=J==="cc-safety-net"&&Q[0]==="explain",Y=(J==="bun"||J==="node")&&XA(Q[0])&&Q[1]==="explain";if(!X&&!Y)return null;let W=Y?[$,Q[0]??""]:[$],K=Q.slice(Y?2:1);for(let B=0;B<K.length;B++){let q=K[B];if(q==="--json"||q==="--help"||q==="-h")continue;if(q==="--cwd"){let U=K[B+1];if(U&&!U.startsWith("--"))W.push(U);B++;continue}return W}return W}function XA($){let J=$?.replaceAll("\\","/");return[...dP].some((Q)=>J===Q||J?.endsWith(`/${Q}`))}function TL($,J,Q,X){if(qA(J,Q,X))return YA($);let Y=UA(J);if(Y===null)return[];return WA($).flatMap((W)=>xL.has(Y)?_6(Q.getShellSyntax(W),Q,X):dL(W))}function YA($){let J=i4($);if(J.length===0)return[];let Q=y2(J[0]??"").toLowerCase();if(!gL.has(Q))return[];return J.slice(1)}function WA($){let J=i4($);if(J.length===0)return[];let Q=y2(J[0]??"").toLowerCase(),X=J.slice(1);if(Q==="echo"){let Y=X.findIndex((W)=>!/^-[neE]+$/.test(W));return[(Y===-1?[]:X.slice(Y)).join(" ")]}if(Q==="printf")return KA(X);return[]}function KA($){let J=$[0];if(J===void 0)return[];let Q=(J.match(/%%|%[bqs]/g)??[]).filter((Y)=>Y!=="%%").length;if(Q===0||$.length===1)return[mL(J)];let X=$.slice(1);return Array.from({length:Math.ceil(X.length/Q)},(Y,W)=>BA(J,X.slice(W*Q,(W+1)*Q)))}function BA($,J){let Q=0;return mL($.replace(/%%|%[bqs]/g,(X)=>{if(X==="%%")return"%";let Y=J[Q]??"";return Q++,Y}))}function mL($){return $.replace(/\\n/g,`
100
100
  `).replace(/\\t/g,"\t").replace(/\\r/g,"\r")}function qA($,J,Q){let X=i4($);if(X.length===0||y2(X[0]??"").toLowerCase()!=="xargs")return!1;let Y=j2(X),W=X.slice(Y.childStart);if(W.length===0)return!1;if(Y.replacementToken==="")return!1;let K=Y.replacementToken,B=K===null?[...W,WK]:W.map((q)=>q.split(K).join(WK));return BJ(B,J,Q).some((q)=>q.includes(WK))}function UA($){let J=i4($);if(J.length===0)return null;let Q=y2(J[0]??"").toLowerCase();if(!pL(Q))return null;return GA(Q,J.slice(1))?Q:null}function GA($,J){let Q=lL($);for(let X=0;X<J.length;X++){let Y=J[X];if(Y===void 0)break;if(yL.has(Y)||cL($,Y)||/^--(?:eval|exec)=/.test(Y))return!1;if(Y==="-")return!0;if(Y.startsWith("-")){if(Q==="python"&&Y==="-m")return!1;if($A.get(Q)?.has(Y))X++;continue}return!1}return!0}function lL($){return/^python\d/.test($)?"python":$}function HA($){let J=[];for(let Q of $){if(oL(Q))continue;let X=/^[A-Za-z_][A-Za-z0-9_]*=(.*)$/.exec(Q);if(X===null)break;if(X[1]!==void 0&&X[1]!=="")J.push(X[1])}return J}function wL($,J){if(J==="--")return[];let Q=[],X=J.indexOf("=");if(X>0&&X<J.length-1)Q.push(J.slice(X+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 ZA($,J,Q){let X=$.findIndex((W)=>W.startsWith("-")||W==="("||W==="!"||W===";"),Y=[...$.slice(0,X===-1?$.length:X)];for(let W=0;W<$.length;W++){if(!gP.has($[W]??""))continue;let K=$.slice(W+1),B=K.findIndex((G)=>yP.has(G)),q=B===-1?K:K.slice(0,B),U=BJ(q,J,Q);if(Y.push(...U.filter((G)=>G!=="{}")),!U.includes("{}"))continue;Y.push(...$.slice(0,W).flatMap((G,H,L)=>{if(!uP.has(G))return[];let Z=L[H+1];return Z===void 0?[]:[Z,Z.replace(/^\*+\//,"").replace(/\/\*+$/g,"").replace(/^\*+/,"").replace(/\*+$/g,"")]}))}return Y}function pL($){return mP.has($)||/^python\d/.test($)}function LA($,J,Q){let X=[];for(let Y=0;Y<J.length;Y++){let W=J[Y];if(W===void 0)break;if(yL.has(W)||cL($,W)){let B=J[Y+1];if(B!==void 0)X.push(...vL($,B,Q)),Y++;continue}let K=/^--(?:eval|exec)=(.*)$/.exec(W);if(K!==null&&K[1]!==void 0){X.push(...vL($,K[1],Q));continue}if(!W.startsWith("-"))X.push(W)}return X}function cL($,J){if(!J.startsWith("-")||J.startsWith("--")||J.length<=2)return!1;return rP.get(J[J.length-1]??"")?.has(lL($))??!1}function MA($,J,Q){if(!$.includes("system"))return[];return IQ($)?.commands.flatMap((X)=>_6(J.getShellSyntax(X),J,Q))??[]}function OA($){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 dL($){let J=Array.from($.matchAll(/(['"`])((?:\\.|(?!\1).)*)\1/g)).map((X)=>X[2]).filter((X)=>X!==void 0&&X!==""),Q=($.match(/[\w./~@+-]*[./~][\w./~@+-]*/g)??[]).filter((X)=>X!=="process.versions.sqlite"||J.some((Y)=>Y.includes(X)));return[...J,...J.flatMap(rL),...Q]}function vL($,J,Q){let X=dL(J);if(!Q.refineJavaScriptInlineData||!lP.has($)||X.length===0)return X;let Y=NA(J);return Y!==null&&!VA(Y)?[]:X}function NA($){let J=$.split("");for(let Q=0;Q<$.length;Q++){let X=$[Q];if(X!=="'"&&X!=='"'&&X!=="`")continue;if(X==="`"&&FA($,Q))return null;J[Q]=" ";let Y=!1;for(let W=Q+1;W<$.length;W++){let K=$[W];if(J[W]=" ",K==="\\"){if(W++,W<$.length)J[W]=" ";continue}if(X==="`"&&K==="$"&&$[W+1]==="{")return null;if(X!=="`"&&(K===`
101
101
  `||K==="\r"))return null;if(K!==X)continue;Q=W,Y=!0;break}if(!Y)return null}return J.join("")}function FA($,J){for(let Q=J-1;Q>=0;Q--){let X=$[Q];if(!X||/\s/.test(X))continue;return/[\w$\])]/.test(X)}return!1}function VA($){for(let J of $.matchAll(/[A-Za-z_$][A-Za-z0-9_$]*/g)){let Q=J[0],X=J.index;if(pP.has(Q.toLowerCase()))return!0;let Y=Q.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[_$\s]+/).map((W)=>W.toLowerCase());if(!Y.some((W)=>cP.has(W)))continue;if(Y.length>1)return!0;if(_A($,X)===".")return!0;if(DA($,X+Q.length)==="(")return!0}return!1}function _A($,J){for(let Q=J-1;Q>=0;Q--)if(!/\s/.test($[Q]??""))return $[Q];return}function DA($,J){for(let Q=J;Q<$.length;Q++)if(!/\s/.test($[Q]??""))return $[Q];return}function zA($,J,Q){return PA($).flatMap((X)=>{let Y=J.getShellSyntax(X);if(Y.status==="invalid")return[];return[..._6(Y,J,Q),...RA(Y)?IA(Y):[]]})}function RA($){let J=$.entries;for(let Q=0;Q<J.length;Q++){let X=J[Q];if(X?.kind!=="word"||y2(G0(X.text)).toLowerCase()!=="base64")continue;for(let Y=Q+1;Y<J.length;Y++){let W=J[Y];if(W?.kind==="operator")break;if(W?.kind!=="word")continue;let K=G0(W.text);if(K==="--decode"||!K.startsWith("--")&&K.startsWith("-")&&/[dD]/.test(K))return!0}}return!1}function IA($){return $.entries.flatMap((J)=>J.kind==="word"?[G0(J.text)]:J.kind==="redirection"&&J.target?[G0(J.target)]:[]).flatMap(rL)}function rL($){let J=bA($);if(J===null)return[];let Q=Buffer.from(J,"base64").toString("utf8");if(Q===""||jA(Q))return[];return Buffer.from(Q,"utf8").toString("base64").replace(/=+$/g,"")===J.replace(/=+$/g,"")?[Q]:[]}function jA($){return Array.from($).some((J)=>{let Q=J.charCodeAt(0);return Q<32||Q===127})}function bA($){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 X=0;X<$.length;X++){let Y=$[X];if(!Y)break;if(G3(Y,Q))continue;if(iL($,X,Q)){let W=AA($,X+1);if(W!==null)J.push(W.body),X=W.endIndex;continue}if(!Q.inSingle&&Y==="`"){let W=EA($,X);if(W!==null)J.push(W.body),X=W.endIndex}}return J}function AA($,J){let Q={inSingle:!1,inDouble:!1,escaped:!1},X=1;for(let Y=J+1;Y<$.length;Y++){let W=$[Y];if(!W)break;if(G3(W,Q))continue;if(iL($,Y,Q)){X++,Y++;continue}if(!Q.inSingle&&!Q.inDouble&&W===")"){if(X--,X===0)return{body:$.slice(J+1,Y),endIndex:Y}}}return null}function EA($,J){let Q=!1;for(let X=J+1;X<$.length;X++){let Y=$[X];if(!Y)break;if(Q){Q=!1;continue}if(Y==="\\"){Q=!0;continue}if(Y==="`")return{body:$.slice(J+1,X),endIndex:X}}return null}function iL($,J,Q){return!Q.inSingle&&$[J]==="$"&&$[J+1]==="("&&$[J+2]!=="("}function CA($){let J=[],Q=[],X=!1,Y=!1,W=!1;for(let q=0;q<$.length;q++){let U=$[q];if(U===void 0)break;if(!W&&U==="--"){W=!0;continue}if(W){Q.push(U);continue}let G=/^--([^=]+)(?:=(.*))?$/.exec(U);if(G!==null){let H=G[1]??"",L=G[2];if(H===oP)Y=!0;if(sP.has(H))X=!0;if(L!==void 0){if(H===EL)J.push(L);continue}if(tP.has(H)){let Z=$[q+1];if(H===EL&&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(nP.has(O))X=!0;if(aP.has(O)){L=O,Z=H.slice(M+1);break}}if(L!=="")if(Z.length>0){if(L===AL)J.push(Z)}else{let M=$[q+1];if(L===AL&&M!==void 0)J.push(M);q++}continue}Q.push(U)}let B=!X&&!Y?Q.slice(1):Q;return[...J,...B]}function i4($){let J=$.findIndex((Q)=>!oL(Q)&&!/^[A-Za-z_][A-Za-z0-9_]*=.*/.test(Q));return J===-1?[]:[...$.slice(J)]}function oL($){return $==="env"||$==="command"||$==="builtin"||$==="sudo"}var SA=new Set(["id_rsa.pub","id_ed25519.pub","id_ecdsa.pub"]),TA=".env.",wA=new Set([".env.example",".env.sample",".env.template",".env.defaults"]),vA=[".env.example.",".env.sample."],fA=new Set(["node_modules","__pycache__"]),hA=[["vendor","bundle"],["vendor","cache"]];function kA($,J,Q,X){let Y=u0($,J,X);if(!Y)return null;let W=G1(Y.split("/").pop()??""),K=G1(Y);if(wA.has(W)||vA.some((U)=>W.startsWith(U)))return null;for(let U of sW){let G=U.suffixParts.join("/");if((K===`~/${G}`||K.startsWith(`~/${G}/`))&&x0(U.id,Q))return U.id}let B=gA(Y,J,Q,X);if(B)return B;if(SA.has(W))return null;for(let U of nW)if(W===U.basename&&x0(U.id,Q))return U.id;if(W.startsWith(TA)&&x0(XJ.id,Q))return XJ.id;for(let U of aW)if(W.length>U.prefix.length&&W.startsWith(U.prefix)){let G=W.slice(U.prefix.length)[0];if((G==="-"||G==="_")&&x0(U.id,Q))return U.id}for(let U of tW)if(W.length>U.prefix.length&&W.startsWith(U.prefix)){if(W.slice(U.prefix.length)===U.suffix&&x0(U.id,Q))return U.id}if(xA(K))return null;if(!W.includes(".")&&M6.pattern.test(W)&&x0(M6.id,Q))return M6.id;let q=uA(W,Q);if(q)return q;return null}function gA($,J,Q,X){return YJ.find((Y)=>{if(!x0(Y.id,Q))return!1;switch(Y.id){case"secret.cli.claude-code":return $1($,Q1(process.env.CLAUDE_CONFIG_DIR,"~/.claude",J,X),[".credentials.json"]);case"secret.cli.claude-code.config":{let W=G1($).split("/");return $1($,Q1(process.env.CLAUDE_CONFIG_DIR,"~/.claude",J,X),["settings.json","settings.local.json"])||V6($,"~/.claude.json",J,X)||W.at(-1)==="settings.local.json"&&W.at(-2)===".claude"||W.at(-1)===".mcp.json"}case"secret.cli.antigravity":return $1($,u0("~/.gemini/config",J,X),["hooks.json","mcp_config.json"]);case"secret.cli.codex":{let W=Q1(process.env.CODEX_HOME,"~/.codex",J,X);return $1($,W,["auth.json",".credentials.json"])||F6($,W,["secrets",".sandbox-secrets"])}case"secret.cli.codex.config":{let W=Q1(process.env.CODEX_HOME,"~/.codex",J,X),K=G1($).split("/").at(-1)??"";return $1($,W,["config.toml"])||K.endsWith(".config.toml")&&$1($,W,[K])}case"secret.cli.gemini":return $1($,F1(Q1(process.env.GEMINI_CLI_HOME,"~",J,X),".gemini"),["oauth_creds.json","mcp-oauth-tokens.json","a2a-oauth-tokens.json","gemini-credentials.json"]);case"secret.cli.gemini.config":{let W=G1($).split("/"),K=process.env.ProgramData?[F1(Q1(process.env.ProgramData,"",J,X),"gemini-cli")]:[];return $1($,F1(Q1(process.env.GEMINI_CLI_HOME,"~",J,X),".gemini"),["settings.json","google_accounts.json"])||W.at(-1)==="settings.json"&&W.at(-2)===".gemini"||(process.env.GEMINI_CLI_SYSTEM_SETTINGS_PATH?.trim()?V6($,process.env.GEMINI_CLI_SYSTEM_SETTINGS_PATH,J,X):!1)||["/Library/Application Support/GeminiCli","/etc/gemini-cli",...K].some((B)=>$1($,u0(B,J,X),["settings.json"]))}case"secret.cli.copilot-cli":{let W=Q1(process.env.COPILOT_HOME,"~/.copilot",J,X);return $1($,W,["config.json"])||F6($,W,["mcp-oauth-config","mcp-secrets"])}case"secret.cli.copilot-cli.config":return $1($,Q1(process.env.COPILOT_HOME,"~/.copilot",J,X),["mcp-config.json"]);case"secret.cli.kimi-code":{let W=Q1(process.env.KIMI_CODE_HOME,"~/.kimi-code",J,X),K=Q1(process.env.KIMI_SHARE_DIR,"~/.kimi",J,X);return $1($,W,["server.token"])||F6($,W,["credentials"])||F6($,K,["credentials","mcp-oauth"])}case"secret.cli.kimi-code.config":{let W=["config.toml","mcp.json"],K=G1($).split("/");return K.at(-1)==="mcp.json"&&K.at(-2)===".kimi-code"||$1($,Q1(process.env.KIMI_CODE_HOME,"~/.kimi-code",J,X),W)||$1($,Q1(process.env.KIMI_SHARE_DIR,"~/.kimi",J,X),[...W,"config.json","config.json.bak"])}case"secret.cli.opencode":{let W=F1(Q1(process.env.XDG_DATA_HOME,"~/.local/share",J,X),"opencode"),K=G1($).split("/").at(-1)??"",B=process.env.OPENCODE_DB?.trim(),q=B&&B!==":memory:"?[B,`${B}-wal`,`${B}-shm`]:[];return $1($,W,["auth.json","mcp-auth.json"])||/^opencode(-.+)?\.db(-wal|-shm)?$/.test(K)&&$1($,W,[K])||q.some((U)=>V6($,U,J,X))}case"secret.cli.opencode.config":{let W=process.env.OPENCODE_CONFIG_DIR?Q1(process.env.OPENCODE_CONFIG_DIR,"~/.config/opencode",J,X):F1(Q1(process.env.XDG_CONFIG_HOME,"~/.config",J,X),"opencode"),K=process.env.ProgramData?[F1(Q1(process.env.ProgramData,"",J,X),"opencode")]:[],B=["opencode.json","opencode.jsonc"];return B.includes(G1($).split("/").at(-1)??"")||$1($,W,B)||(process.env.OPENCODE_CONFIG?.trim()?V6($,process.env.OPENCODE_CONFIG,J,X):!1)||["/Library/Application Support/opencode","/etc/opencode",...K].some((q)=>$1($,u0(q,J,X),B))}case"secret.cli.pi":return $1($,Q1(process.env.PI_CODING_AGENT_DIR,"~/.pi/agent",J,X),["auth.json"]);case"secret.cli.pi.config":return $1($,Q1(process.env.PI_CODING_AGENT_DIR,"~/.pi/agent",J,X),["models.json"]);case"secret.cli.amp":{let W=u0("~",J,X);return[F1(Q1(process.env.XDG_DATA_HOME,"~/.local/share",J,X),"amp"),F1(W,".local","share","amp")].some((B)=>$1($,B,["secrets.json"]))||F6($,F1(W,".amp"),["oauth"])}case"secret.cli.amp.config":{let W=["settings.json","settings.jsonc"],K=[F1(Q1(process.env.XDG_CONFIG_HOME,"~/.config",J,X),"amp"),F1(u0("~",J,X),".config","amp")],B=G1($).split("/");return K.some((q)=>$1($,q,W))||B.at(-2)===".amp"&&W.includes(B.at(-1)??"")||(process.env.AMP_SETTINGS_FILE?.trim()?V6($,process.env.AMP_SETTINGS_FILE,J,X):!1)}case"secret.cli.cursor":{let W=F1(Q1(process.env.XDG_CONFIG_HOME,"~/.config",J,X),"cursor"),K=F1(Q1(process.env.CURSOR_DATA_DIR,"~/.cursor",J,X),"projects");return $1($,u0("~/.cursor",J,X),["auth.json"])||$1($,W,["auth.json"])||G1($).split("/").at(-1)==="mcp-auth.json"&&qJ(G1($),G1(K))}case"secret.cli.cursor.config":{let W=G1($).split("/");return W.at(-1)==="mcp.json"&&W.at(-2)===".cursor"}default:return!1}})?.id??null}function Q1($,J,Q,X){return u0($?.trim()?$:J,Q,X)}function $1($,J,Q){return Q.some((X)=>nL($,F1(J,X)))}function F6($,J,Q){return Q.some((X)=>qJ(G1($),G1(F1(J,X))))}function V6($,J,Q,X){return nL($,u0(J,Q,X))}function nL($,J){return G1($)===G1(J)}function F1($,...J){return r4([$,...J].filter(Boolean).join("/"))}function yA($,J,Q,X,Y){if(Q.length===0)return!1;let W=G1(fL($,J,Y));return Q.some((K)=>qJ(W,G1(fL(K,X,Y))))}function xA($){let J=$.split("/");return J.some((Q)=>fA.has(Q))||hA.some(([Q,X])=>J.some((Y,W)=>Y===Q&&J[W+1]===X))}function uA($,J){let Q=$.lastIndexOf("."),X=Q>0&&Q<$.length-1?$.slice(Q+1):"";if(X==="")return null;for(let Y of eW)if(X===Y.extension&&x0(Y.id,J))return Y.id;for(let Y of $K)if(Y.pattern.test(X)&&x0(Y.id,J))return Y.id;return null}function G1($){return $.toLowerCase()}function x0($,J){if(!J?.disabledRules)return!0;if(Array.isArray(J.disabledRules))return!J.disabledRules.includes($);return!J.disabledRules.has($)}function u0($,J,Q){let{home:X,normalized:Y}=sL($,Q);if(!Y)return"";if(!X)return Y;let W=aL(Y,X),K=KK(W)?W:r4(hL(J,W)),B=r4(J1(K,i0,Q));if(!qJ(B,X)){if(KK(W))return B;return B===K?Y:B}let q=B.slice(X.length);return q?`~${q}`:"~"}function fL($,J,Q){let{home:X,normalized:Y}=sL($,Q);if(!Y)return"";let W=X?aL(Y,X):Y;return r4(J1(KK(W)?W:hL(J,W),i0,Q))}function sL($,J){let Q=process.env.HOME??fP(),X=Q?r4(J1(Q,i0,J)):"",Y=r4(mA(G0($)));return{home:X,normalized:Y}}function mA($){if(!$.trim().toLowerCase().startsWith("file:"))return $;try{return hP($)}catch{return $}}function aL($,J){if($==="~")return J;if($.startsWith("~/"))return F1(J,$.slice(2));return $}function r4($){let J=$.trim().replace(/\\/g,"/").replace(/\/{2,}/g,"/").replace(/^\.\//,"");if(J==="/")return J;return J.replace(/\/+$/g,"")}function qJ($,J){return $===J||$.startsWith(J.endsWith("/")?J:`${J}/`)}function y2($){return $.split(/[\\/]/).pop()?.replace(/\.exe$/i,"")??$}import{dirname as UJ}from"node:path";var tL="Rulebook exceeds CC Safety Net's safe validation limits.",eL="Additional rulebook validation errors were omitted.",X0=Object.freeze({maxAllowedCommands:1024,maxRules:1024,maxTests:2048,maxBlockArgsPerRule:1024,maxTotalBlockArgs:16384,maxStringCodeUnits:1048576,maxAggregateStringCodeUnits:4194304,maxFixtureCommandCodeUnits:131072,maxValidationErrors:64});function $M($){if(BK($.allowed_commands,X0.maxAllowedCommands)||BK($.rules,X0.maxRules)||BK($.tests,X0.maxTests))return!1;let{maxAggregateStringCodeUnits:J,maxTotalBlockArgs:Q}=X0,X=(Y,W=!1)=>{if(typeof Y!=="string")return!0;if(Y.length>X0.maxStringCodeUnits||W&&Y.length>X0.maxFixtureCommandCodeUnits||Y.length>J)return!1;return J-=Y.length,!0};if(!X($.name)||!X($.version)||!X($.description)||!X($.author)||!X($.migrated_from))return!1;if(Array.isArray($.allowed_commands)){for(let Y of $.allowed_commands)if(!X(Y))return!1}if(Array.isArray($.rules))for(let Y of $.rules){if(!Y||typeof Y!=="object")continue;let W=Y;if(!X(W.name)||!X(W.command)||!X(W.subcommand)||!X(W.reason)||!X(W.intent))return!1;if(!Array.isArray(W.block_args))continue;if(W.block_args.length>X0.maxBlockArgsPerRule||W.block_args.length>Q)return!1;Q-=W.block_args.length;for(let K of W.block_args)if(!X(K))return!1}if(Array.isArray($.tests))for(let Y of $.tests){if(!Y||typeof Y!=="object")continue;let W=Y;if(!X(W.command,!0)||!X(W.expect)||!X(W.rule))return!1}return!0}function BK($,J){return Array.isArray($)&&$.length>J}function lA($){if(!pA($))return{errors:["Rulebook must be an object"],ruleNames:new Set};if(!$M($))return{errors:[tL],ruleNames:new Set};let J=GL().safeParse($),Q=[...$.rulebook_version===1?[]:["rulebook_version must be 1"],...J.success?[]:c4(J.error.issues,": ",": ")];return{errors:Q.length>X0.maxValidationErrors?[...Q.slice(0,X0.maxValidationErrors),eL]:Q,ruleNames:new Set(JK($).map((X)=>X.toLowerCase()))}}function qK($){let J=lA($);if(J.errors.length>0)throw Error(J.errors.join("; "));return $}function pA($){return!!$&&typeof $==="object"&&!Array.isArray($)}function UK($){if(E6($.spec))return rA($);return dA($)}function dA($){if(!Y0.test($.spec))return`Local rulebook sources must be bare names matching ${Y0}: ${$.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 rA($){let J=o4($.spec);if(J)return J;let Q=A6($.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 JM($){let J=typeof $==="string"?$:$.path;try{let Q=q2(typeof $==="string"?P6($):$);if(Q===null)return{lock:null,errors:[]};let X=JSON.parse(Q);if(!X||typeof X!=="object")return{lock:null,errors:[`malformed lockfile ${J}: must be an object`]};let Y=X;if(Y.version!==1||!Array.isArray(Y.rulebooks))return{lock:null,errors:[`malformed lockfile ${J}`]};let W=HL().safeParse(Y),K=Y.rulebooks.flatMap((q,U)=>{let G=W.success?[]:W.error.issues.filter((L)=>L.path[1]===U);if(G.length>0)return c4(G).map((L)=>`${J}: ${L}`);let H=UK(q);return H?[`${J}: rulebooks[${U}]: ${H}`]:[]});if(!W.success||K.length>0)return{lock:null,errors:[`malformed lockfile ${J}`,...K]};return{lock:{version:1,rulebooks:W.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 W1)return{lock:null,errors:[Q.message]};return{lock:null,errors:["malformed lockfile"]}}}import{createHash as iA}from"node:crypto";var Pg=Object.freeze({timeoutMs:15000,metadataBytes:524288,commitBytes:262144,treeBytes:16777216,rawBytes:4194304});function QM($){return`sha256:${iA("sha256").update($).digest("hex")}`}function BM($={}){let J=CK($),Q=!1;try{Q=zK(J.userConfigTarget,J.projectConfigTarget)}catch(L){if(L instanceof W1)return aA(J,L.message);throw L}let X=QK(J.userConfigTarget),Y=Q?{config:null,errors:[]}:QK(J.projectConfigTarget),W=KM(J.userConfigPath,X.errors),K=KM(J.projectConfigPath,Y.errors),B=new Set,q=X.config?XM(X.config,J.userLockPath,UJ(J.userConfigPath),$,"user",J.userScope,B):D6(),U=Y.config?XM(Y.config,J.projectLockPath,UJ(J.projectConfigPath),$,"project",J.projectScope,B):D6(),G=X.config?.overrides??{},H=Y.config?.overrides??{};return{rules:[...YM(q.rules,G),...YM(U.rules,H)],transparent_wrappers:nA(X.config,Y.config),rulebooks:[...q.rulebooks,...U.rulebooks],errors:[...W,...K,...q.errors,...U.errors],warnings:[...q.warnings,...U.warnings,...q.canValidateOverrides?WM(G,q.knownRuleIds,J.userConfigPath):[],...q.canValidateOverrides?sA(H,q.knownRuleIds,J.projectConfigPath):[],...U.canValidateOverrides?WM(H,U.knownRuleIds,J.projectConfigPath):[]],userConfig:X.config??void 0,projectConfig:Y.config??void 0,...J}}function XM($,J,Q,X,Y,W=m0(UJ(UJ(Q)),Y==="user"?"user policy":"project policy"),K=new Set){let B;try{B=b0(W,J)}catch(V){if(V instanceof W1)return{...D6(),errors:[V.message],canValidateOverrides:!1};throw V}let q=JM(B);if(q.errors.length>0)return{...D6(),errors:q.errors,canValidateOverrides:!1};let U=q.lock;if(!U&&$.rules.length>0)return{...D6(),errors:[`missing lockfile ${J}; run ${c0}`],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 ${c0}`),[];let b=oA(F,Q,X,W);if(b.errors.length>0||!b.rulebook)return L.push(...b.errors),[];let R=b.rulebook;if(K.has(R.name))return Z.push(`duplicate active rulebook name "${R.name}" for ${V}; keeping the first and ignoring this one, so its rules are not active; rename one of them, then run ${c0}`),[];return K.add(R.name),[{rules:R.rules.map((A)=>({...A,name:`${R.name}/${A.name}`})),rulebook:{source:Y,spec:F.spec,name:R.name,version:R.version,rules:R.rules.map((A)=>`${R.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 oA($,J,Q,X){let Y=VJ($,_J(J,Q)),W;try{W=q2(b0(X,Y))}catch(B){if(B instanceof W1)return{rulebook:null,errors:[B.message]};throw B}if(W===null)return{rulebook:null,errors:[`missing cache entry for ${$.spec}; run ${c0}`]};if(QM(W)!==$.digest)return{rulebook:null,errors:[`cache digest mismatch for ${$.spec}; run ${c0}`]};let K;try{K=JSON.parse(W)}catch{return{rulebook:null,errors:[`invalid cached rulebook for ${$.spec}`]}}try{qK(K)}catch(B){return{rulebook:null,errors:[`invalid cached rulebook for ${$.spec}: ${B instanceof Error?B.message:"invalid rulebook"}`]}}return{rulebook:K,errors:[]}}function nA($,J){return[...new Set([...$?.transparent_wrappers??[],...J?.transparent_wrappers??[]])]}function YM($,J){return $.flatMap((Q)=>{let X=J[Q.name];if(X==="off")return[];if(X&&typeof X==="object")return[{...Q,intent:X.intent??Q.intent,reason:X.reason}];return[Q]})}function WM($,J,Q){return Object.keys($).filter((X)=>!J.has(X)).map((X)=>`unknown override key "${X}" in ${Q}; only that override is ignored and other overrides and rules keep their configured state; correct or remove it in that file`)}function sA($,J,Q){return Object.keys($).filter((X)=>J.has(X)).map((X)=>`project override cannot target user-scoped rule "${X}" in ${Q}; only that override is ignored and the rule keeps its user-configured state; remove it from that file`)}function KM($,J){return J.map((Q)=>Q.startsWith("Unable to access ")?Q:`${$}: ${Q}`)}function aA($,J){return{rules:[],transparent_wrappers:[],rulebooks:[],errors:[J],warnings:[],userConfigPath:$.userConfigPath,projectConfigPath:$.projectConfigPath,userLockPath:$.userLockPath,projectLockPath:$.projectLockPath}}function D6(){return{rules:[],rulebooks:[],entries:[],knownRuleIds:new Set,errors:[],warnings:[],canValidateOverrides:!0}}function qM($={}){let J=BM($),Q=_L($),X={rules:J.rules,transparentWrappers:J.transparent_wrappers,safety:XE(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]}},Y={...J.userConfig?.overrides??{},...J.projectConfig?.overrides??{}},W=Object.freeze(Object.fromEntries(X.rules.map((K)=>{let B=J.rulebooks.find((U)=>U.rules.includes(K.name)),q=Y[K.name];return[K.name,Object.freeze({id:K.name,...B?{rulebook:Object.freeze({name:B.name,version:B.version}),...JE(B.spec)?{source:B.spec}:{}}:{},...q&&typeof q==="object"?{override:Object.freeze({type:"reason",reason:q.reason})}:{}})]})));return QE(X,tA(J,Q),W)}function tA($,J){let Q=$E(J);if($.errors.length===0&&$.warnings.length===0&&!Q)return;return{diagnostics:[...$.errors,...$.warnings,...J.errors],reason:YE($.errors.length>0?eA($.errors):void 0,$.warnings.length>0?GK($.warnings.join("; ")):void 0,Q)}}function eA($){return`${GK($.join("; "))} Those rule sources are not active; every other rule and all built-in protections still apply`}function $E($){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 JE($){return/^(?:[A-Za-z0-9_.-]+$|https:\/\/github\.com\/|github:|gh:|[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+(?:#|$))/.test($)}function QE($,J,Q=Object.freeze({})){let X=UM(structuredClone($));if(!J)return Object.freeze({state:"ready",policy:X,diagnostics:Object.freeze([]),ruleMetadata:Q});return Object.freeze({state:"degraded",policy:X,diagnostics:Object.freeze([...J.diagnostics]),reason:J.reason,ruleMetadata:Q})}function XE($){let J=$.overrides,Q={...J?.failClosed!==void 0?{failClosed:J.failClosed}:{},...J?.paranoidRm!==void 0?{paranoidRm:J.paranoidRm}:{},...J?.paranoidInterpreters!==void 0?{paranoidInterpreters:J.paranoidInterpreters}:{}};return{...$.level!==void 0?{level:$.level}:{},...Object.keys(Q).length>0?{overrides:Q}:{}}}function UM($){if(typeof $!=="object"||$===null)return $;for(let J of Object.values($))UM(J);return Object.freeze($)}function YE(...$){return GK($.filter((J)=>!!J).join("; "))}function GK($){return/[.!?]$/.test($)?$:`${$}.`}class K2 extends Error{stage;evaluation;name="GuardEvaluationError";constructor($,J,Q){super(`CC Safety Net ${$} dependency failed`,{cause:Q});this.stage=$;this.evaluation=J}}var WE={findPolicyMutation:bL,findGitMetadataMutation:cq,resolveGitMetadata:LQ,loadPolicySnapshot:qM,findSensitiveTarget:uL,analyzeCommand:XH,getModes:U7};function GM($,J={}){let Q={...WE,...J.dependencies},X=qE($),Y=z6($)?$.command:X,W=x2("policy-protection",Y,()=>b9($,J.factParserDependencies)),K=w1(W,"declared-command");if(z6($)&&$.command?.trim()&&K?.program.status==="limited")return{stage:"command-analysis",decision:{kind:"deny",reason:A0,intent:"stop_and_explain",evidence:[{kind:"command",command:$.command,segment:$.command}]}};if(w1(W,"input-candidate")?.program.status==="limited")return{stage:"command-validation",decision:{kind:"deny",reason:dK,intent:"stop_and_explain",evidence:[]}};let B=x2("policy-protection",Y,()=>Q.resolveGitMetadata($.context.executionCwd)),q=x2("policy-protection",Y,()=>Q.findPolicyMutation(W));if(q){let V=Y??q.target;return{stage:"policy-protection",decision:{kind:"deny",reason:jL,intent:"hard_stop",evidence:[{kind:"command",command:V,segment:q.target},{kind:"path",target:q.target}]}}}let U=x2("policy-protection",Y,()=>Q.findGitMetadataMutation(W,B));if(U){let V=Y??U.target;return{stage:"policy-protection",decision:{kind:"deny",reason:p1,intent:"hard_stop",evidence:[{kind:"command",command:V,segment:U.target},{kind:"path",target:U.target}]}}}let G=x2("config-load",Y,()=>Q.loadPolicySnapshot({...J.policyOptions,cwd:$.context.configCwd})),H=G.policy,L=Q.getModes(H),Z={level:L.effectiveLevel,...KE(G)},M=H.secretProtection.enabled===!1?null:x2("secret-protection",Y,()=>Q.findSensitiveTarget(W,H.secretProtection,{strict:z6($)?L.strict:void 0}));if(M){let V=Y??M.target;return{stage:"secret-protection",...Z,decision:{kind:"deny",reason:kL,intent:"hard_stop",ruleId:M.ruleId,evidence:[{kind:"command",command:V,segment:M.target},{kind:"path",target:M.target}]}}}if(!z6($))return{stage:"non-command",...Z,decision:{kind:"allow"}};if(!$.command||$.command.trim()==="")return{...HK("command-validation",Y),...Z};let O=x2("command-analysis",Y,()=>{return Q.analyzeCommand($.command,{cwd:$.context.executionCwd,shell:$.route.shell,policySnapshot:G,environment:E0(),protectedGitMetadata:B,effectiveCapabilities:L.capabilities,strict:L.strict,paranoidRm:L.paranoidRm,paranoidInterpreters:L.paranoidInterpreters,worktreeMode:L.worktreeMode},BE(W),W.store)});if(O)return{stage:"command-analysis",...Z,decision:O};return{stage:"command-analysis",...Z,decision:{kind:"allow"}}}function KE($){if($.state==="ready")return{};return{configFallback:{reason:$.reason}}}function BE($){return w1($,"declared-command")?.program}function qE($){try{return J4($.input)}catch(J){let Q=z6($)?$.command:void 0;throw new K2("policy-protection",HK("policy-protection",J instanceof w0?void 0:Q),J)}}function x2($,J,Q){try{return Q()}catch(X){throw new K2($,HK($,X instanceof w0?void 0:J),X)}}function HK($,J){return{stage:$,decision:{kind:"deny",reason:w6,intent:"stop_and_explain",evidence:J?[{kind:"command",command:J,segment:J}]:[]}}}function z6($){return $.route.kind==="command"}function ZM($,J){try{let Q=GM($,J.guard);return HM($,Q,J),Q}catch(Q){if(!(Q instanceof K2))throw Q;throw HM($,Q.evaluation,J,!(Q.cause instanceof w0),{stage:Q.stage,errorCode:UE(Q.cause)}),Q}}function HM($,J,Q,X=!0,Y){uK(xK($,J,Q.guard?.auditAllowed??!1,X,Y),Q.audit.getSessionId,{agent:Q.audit.agent,shape:Q.audit.shape,homeDir:Q.audit.homeDir})}function UE($){if($ instanceof o1)return"path-canonicalization-limit";if($ instanceof w0)return"tool-input-limit";if($ instanceof n0)return"structural-shell-syntax-limit";return"unexpected-error"}var MM="exec",GE=new Set(["auto","gateway"]);function OM($){$.on("before_tool_call",HE($),{matcher:[MM],priority:50})}function HE($,J={}){return(Q,X)=>{if(X.abortSignal?.aborted)return ZK(jJ());let Y=ZE(Q,X,$);if(!Y)return;let W=()=>X.sessionId??X.sessionKey;if("malformed"in Y)return mK(Y.denial,W,{agent:"openclaw",toolName:Y.denial.toolName,cwd:Y.cwd}),ZK(Y.denial);try{let K=ZM(Y,{guard:{auditAllowed:B7(),dependencies:J.guardDependencies},audit:{agent:"openclaw",getSessionId:W}});return LM(K,K.stage!=="config-state")}catch(K){if(!(K instanceof K2))throw K;if(k0(B1.debug))console.error(`CC Safety Net debug: openclaw before_tool_call analysis failed: ${sK(K.cause)}`);return LM(K.evaluation,!0)}}}function ZE($,J,Q){if(!$||typeof $!=="object")return u2(null);let X=$.toolName;if(typeof X!=="string"||X.trim()==="")return u2(null);if(X!==MM)return;let Y=$.params;if(!Y||typeof Y!=="object"||Array.isArray(Y))return u2(null,X);let W=Y,K=W.command;if(typeof K!=="string"||K.trim()==="")return u2(null,X);if(W.host!==void 0&&!GE.has(W.host))return u2(null,X,K);let B=LE(Q,J.agentId);if(!B)return u2(null,X,K);let q=ME(B,W);if(!q)return u2(B,X,K,typeof W.workdir==="string"?W.workdir:void 0);return Y$(X,W,{kind:"command",shell:"auto"},{configCwd:B,executionCwd:q},K)}function LE($,J){if(typeof J!=="string"||J.trim()==="")return;try{let Q=$.runtime.agent.resolveAgentWorkspaceDir($.config,J);if(typeof Q!=="string"||Q.trim()==="")return;return T6(".",[Q])}catch{return}}function ME($,J){if(!Object.hasOwn(J,"workdir")||J.workdir===void 0)return $;let Q=J.workdir;if(typeof Q!=="string"||Q.trim()==="")return;return T6(Q,[$])}function u2($,J,Q,X){return{malformed:!0,denial:jJ({command:Q,segment:X,toolName:J}),cwd:$}}function LM($,J){let Q=oK($,{includeEvidence:J});return Q?ZK(Q):void 0}function ZK($){return{block:!0,blockReason:nK($)}}var Dy={...OK,register:OM};export{Dy as default};