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,8 +1,8 @@
1
1
  // cc-safety-net managed Amp plugin. Do not edit. Reinstall with: npx -y cc-safety-net install --amp
2
- // version: 2.0.3
2
+ // version: 2.0.5
3
3
  // @bun
4
4
  var NO=Object.defineProperty;var FO=($)=>$;function VO($,J){this[$]=FO.bind(null,J)}var B2=($,J)=>{for(var Q in J)NO($,Q,{get:J[Q],enumerable:!0,configurable:!0,set:VO.bind(J,Q)})};import{randomBytes as ZM}from"crypto";import{appendFileSync as LM,mkdirSync as OM}from"fs";import{homedir as MM,userInfo as NM}from"os";import{isAbsolute as FM,join as IJ}from"path";var _O=[/\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 R0($){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 DO(J)}function DO($){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 _O)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 EK,readdirSync as eO,readFileSync as wK,rmdirSync as $M,statSync as SK,unlinkSync as JM,utimesSync as QM,writeFileSync as XM}from"fs";import{dirname as YM,join as l2}from"path";var j6=30,HJ=1,ZJ=365;function R6($){if(typeof $!=="number"||!Number.isInteger($))return 30;if($<1)return 1;return $>365?365:$}import{homedir as yO}from"os";import{dirname as l0,isAbsolute as xO,join as p0,relative as uO,resolve as P0,sep as mO}from"path";import{closeSync as zO,constants as OK,fstatSync as IO,fsyncSync as AE,lstatSync as MK,mkdirSync as EE,openSync as jO,readdirSync as SE,readFileSync as RO,realpathSync as b6,renameSync as CE,rmdirSync as TE,statSync as bO,unlinkSync as wE,writeFileSync as vE}from"fs";import{isAbsolute as NK,join as FK,normalize as PO,parse as AO,relative as LJ,resolve as OJ,sep as MJ}from"path";var EO=Symbol("PolicyFilesystemScope"),SO=Symbol("PolicyFilesystemTarget"),CO=OK.O_NOFOLLOW??0;class W1 extends Error{constructor($){super(`Unable to access ${$} filesystem safely.`);this.name="PolicyFilesystemError"}}function m0($,J){return{[EO]:!0,root:OJ($),label:J}}function VK($,J){let Q=PO(J);if(J===""||NK(J)||Q===".."||Q.startsWith(`..${MJ}`))throw new W1($.label);return{[SO]:!0,scope:$,relativePath:Q,path:FK($.root,Q)}}function b0($,J){let Q=LJ($.root,OJ(J));return VK($,Q)}function A6($,J="rules policy"){let Q=OJ($),X=AO(Q).dir;return VK(m0(X,J),LJ(X,Q))}function q2($){try{if(!P6($,!1).exists)return null;let Q=jO($.path,OK.O_RDONLY|CO);try{let X=IO(Q);if(!X.isFile())throw new W1($.scope.label);let Y=RO(Q,"utf-8"),W=MK($.path);if(!W.isFile()||W.isSymbolicLink()||X.dev!==W.dev||X.ino!==W.ino)throw new W1($.scope.label);return P6($,!1),Y}finally{zO(Q)}}catch(J){vO($.scope.label,J)}}function _K($,J){if($.path===J.path)return!0;try{if(!P6($,!1).exists||!P6(J,!1).exists)return!1;return b6($.path)===b6(J.path)}catch(Q){if(Q instanceof W1)throw Q;throw new W1($.scope.label)}}function P6($,J,Q="file"){let X=TO($.scope);if(!X)return{exists:!1};let Y=$.relativePath.split(MJ);for(let W of Y.keys()){let K=FK($.scope.root,...Y.slice(0,W+1)),B=DK(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);wO(X,b6(K),$.scope.label)}return{exists:!0}}function TO($){if(!DK($.root))return null;if(!bO($.root).isDirectory())throw new W1($.label);return b6($.root)}function wO($,J,Q){let X=LJ($,J);if(X===".."||X.startsWith(`..${MJ}`)||NK(X))throw new W1(Q)}function DK($){try{return MK($)}catch(J){if(fO(J)&&J.code==="ENOENT")return null;throw J}}function vO($,J){if(J instanceof W1)throw J;throw new W1($)}function fO($){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 zK=/^([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)#(.+)$/;var hO=/^[A-Za-z0-9._-]+$/,kO=".cc-safety-net/rules".replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),gO="rulebook.json".replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),IK=new RegExp(`^${kO}/(${Y0.source.slice(1,-1)})/${gO}$`);function jK($){return`.cc-safety-net/rules/${$}/rulebook.json`}function o4($){if(S6($))try{return E6($),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 E6($){if($.startsWith("github:"))throw Error(`Invalid rulebook source: ${$}`);let J=$.match(zK);if(!J?.[1]||!J[2]||!J[3])throw Error(`Invalid GitHub rulebook source: ${$}`);let[Q,X,...Y]=J[3].split("/");if(!Q||!hO.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:jK(X),name:X}}function S6($){return zK.test($)}var bK="rule.json",C6="policy.json",lO="rule.lock";var PK=".cc-safety-net",pO="rules",RK="cache",cO="CC_SAFETY_NET_HOME",c0="`cc-safety-net rule sync`";function dO($){return P0($??process.cwd(),FJ)}function rO($){return p0(dO($),bK)}function U2($){return $?.userConfigDir??($?.userConfigPath?l0($.userConfigPath):p0(iO(),pO))}function iO(){let $=process.env[cO];return $?P0($):p0(yO(),PK)}function oO($){return p0(U2($),bK)}function n4($){return p0(l0($),lO)}function AK($){let J=$.userConfigPath??oO($),Q=$.projectConfigPath??rO($.cwd),X=nO(J,$),Y=sO(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 nO($,J){let Q=J.userConfigPath?l0(l0(P0(J.userConfigPath))):l0(P0(J.userConfigDir??U2(J)));return m0(Q,"user policy")}function sO($,J){let Q=P0(J.cwd??process.cwd()),X=P0($),Y=uO(Q,X);if(Y!==".."&&!Y.startsWith(`..${mO}`)&&!xO(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(tO(J),"rulebooks",`${aO($)}--${Q.slice(0,12)}`,NJ)}function _J($,J){let Q=J;return{cacheConfigDir:$,cwd:J.cwd,global:Q.global}}function aO($){return($.kind==="github"&&$.display_ref?`${$.owner}/${$.repo}#${$.display_ref}/${$.name}`:$.spec).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"rulebook"}function tO($){let J=$?.cacheConfigDir??U2($),Q=$;if(Q&&!Q.global&&Q.cwd&&P0(J)===P0(Q.cwd))return p0(P0(Q.cwd),PK,RK);return p0(l0(J),RK)}var zJ=86400000,WM=".last-prune",KM=/^\d{4}-\d{2}$/,BM=/^((\d{4}-\d{2})-\d{2})-.+\.jsonl$/,CK=($)=>Math.floor($/zJ);function qM($){try{let J=l2(YM(U2($)),C6),Q=JSON.parse(wK(J,"utf-8"));return R6(Q?.audit?.retention_days)}catch{return j6}}function vK($,J=()=>new Date){try{let Q=J().getTime();if(!SK($,{throwIfNoEntry:!1})?.isDirectory())return;let X=l2($,WM),Y=SK(X,{throwIfNoEntry:!1})?.mtimeMs;if(Y!==void 0&&CK(Y)===CK(Q))return;let W=Q-qM()*zJ,K=new Date(Q).toISOString().slice(0,7);for(let B of DJ($)){if(B.isDirectory()){UM(l2($,B.name),W,K);continue}if(B.isFile()&&B.name.endsWith(".jsonl"))GM(l2($,B.name),W)}XM(X,"",{mode:384}),QM(X,Q/1000,Q/1000)}catch{}}function UM($,J,Q){for(let X of DJ($)){if(!X.isDirectory()||!KM.test(X.name))continue;let Y=l2($,X.name);for(let W of DJ(Y)){if(!W.isFile())continue;let K=BM.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;fK(l2(Y,W.name))}if(X.name!==Q)TK(Y)}TK($)}function GM($,J){try{let Q=EK($);if(Q.mtimeMs>=J)return;let X=wK($,"utf-8").split(`
5
- `).filter((Y)=>Y.trim()).map(HM);if(X.length===0)return;if(X.some((Y)=>Y===void 0||Y>=J))return;if(EK($).mtimeMs!==Q.mtimeMs)return;fK($)}catch{}}function HM($){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 eO($,{withFileTypes:!0,encoding:"utf8"})}catch{return[]}}function fK($){try{JM($)}catch{}}function TK($){try{$M($)}catch{}}var VM="2.0.3",_M=1e4,DM=2000,zM=256,IM=32768;function jM($){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 RM($){return($??"").replace(/[^A-Za-z0-9]/g,"-").slice(0,180)||"no-cwd"}function jJ($,J,Q,X,Y,W={}){let K=jM($);if(!K)return;let B=W.homeDir??hK();if(!B)return;let q=bM(B);if(!q)return;try{let U=(W.now??(()=>new Date))().toISOString(),G=T6(R0(J),_M),H=T6(R0(Q),DM),L=W.toolName?T6(R0(W.toolName),zM):void 0,Z=Y===null?void 0:T6(R0(Y),IM),O=IJ(q,RM(Z?.value??null),U.slice(0,7));OM(O,{recursive:!0,mode:448});let M=IJ(O,`${U.slice(0,10)}-${K}.jsonl`),V={ts:U,id:(W.createId??(()=>ZM(8).toString("hex")))(),v:VM,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};LM(M,`${JSON.stringify(V)}
5
+ `).filter((Y)=>Y.trim()).map(HM);if(X.length===0)return;if(X.some((Y)=>Y===void 0||Y>=J))return;if(EK($).mtimeMs!==Q.mtimeMs)return;fK($)}catch{}}function HM($){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 eO($,{withFileTypes:!0,encoding:"utf8"})}catch{return[]}}function fK($){try{JM($)}catch{}}function TK($){try{$M($)}catch{}}var VM="2.0.5",_M=1e4,DM=2000,zM=256,IM=32768;function jM($){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 RM($){return($??"").replace(/[^A-Za-z0-9]/g,"-").slice(0,180)||"no-cwd"}function jJ($,J,Q,X,Y,W={}){let K=jM($);if(!K)return;let B=W.homeDir??hK();if(!B)return;let q=bM(B);if(!q)return;try{let U=(W.now??(()=>new Date))().toISOString(),G=T6(R0(J),_M),H=T6(R0(Q),DM),L=W.toolName?T6(R0(W.toolName),zM):void 0,Z=Y===null?void 0:T6(R0(Y),IM),O=IJ(q,RM(Z?.value??null),U.slice(0,7));OM(O,{recursive:!0,mode:448});let M=IJ(O,`${U.slice(0,10)}-${K}.jsonl`),V={ts:U,id:(W.createId??(()=>ZM(8).toString("hex")))(),v:VM,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};LM(M,`${JSON.stringify(V)}
6
6
  `,{encoding:"utf-8",mode:384}),vK(q,W.now)}catch{}}function T6($,J){return{value:$.slice(0,J),truncated:$.length>J}}function hK($=process.env.CC_SAFETY_NET_AUDIT_HOME||process.env.HOME){let J=$||MM()||NM().homedir;return J&&FM(J)?J:null}function bM($=hK()){return $?IJ($,".cc-safety-net","logs"):null}function gK($,J,Q,X=!0,Y){if(J.decision.kind==="allow"){if(!Q||$.route.kind!=="command")return;let B=kK($);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?kK($):"");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 kK($){return"command"in $?$.command??"":""}function yK($,J,Q){if(!$)return;let X;try{X=J()}catch{return}if(typeof X!=="string"||!X.trim())return;jJ(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 xK($,J,Q){let X;try{X=J()}catch{return}if(typeof X!=="string"||!X.trim())return;jJ(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 vM,statSync as fM}from"fs";import{isAbsolute as mK,relative as hM,resolve as kM,sep as gM}from"path";import{dirname as PM,isAbsolute as AM,parse as EM,sep as SM}from"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=AM(J)?TM(J):"",Y=X||$;for(let W of wM(X?J.slice(X.length):J)){if(W===""||W===".")continue;if(W===".."){Y=PM(Y);continue}let K=CM(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 CM($,J){return $.endsWith("/")||$.endsWith("\\")?`${$}${J}`:`${$}${SM}${J}`}function TM($){return EM($).root}function wM($){let J=process.platform==="win32"?/[\\/]+/:/\/+/;return $.split(J)}function w6($,J){if(G2($))return;let Q=J.flatMap((Y)=>uK(Y));if(!Q[0])return;let X=uK(mK($)?$:kM(Q[0],$))[0];if(!X)return;return Q.some((Y)=>lK(X,Y))?X:void 0}function uK($){try{let J=vM($);return fM(J).isDirectory()?[J]:[]}catch{return[]}}function lK($,J){let Q=hM(J,$);return Q===""||Q!==".."&&!Q.startsWith(`..${gM}`)&&!mK(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.",pK="CC Safety Net could not validate the command because its structure exceeds safe analysis limits.",v6="CC Safety Net failed closed because command analysis failed unexpectedly. This is not caused by your command. Report it to the user.";function dK($){let{reason:J,command:Q,segment:X,toolName:Y}=$,W=$.maxLen??200,K=$.redact??((q)=>q),B=`BLOCKED by CC Safety Net
7
7
 
8
8
  Reason: ${K(J)}`;if($.ruleId)B+=`
@@ -97,6 +97,6 @@ ${yM($.intent??"manual_only")}`,B}function yM($){switch($){case"hard_stop":retur
97
97
  newResult[${E}] = ${A}.value;
98
98
  }
99
99
 
100
- `)}Z.write("payload.value = newResult;"),Z.write("return payload;");let b=Z.compile();return(I,A)=>b(L,I,A)},W,K=C2,B=!v3.jitless,U=B&&M7.value,G=J.catchall,H;$._zod.parse=(L,Z)=>{H??(H=X.value);let O=L.value;if(!K(O))return L.issues.push({expected:"object",code:"invalid_type",input:O,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 CH([],O,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 d3=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)=>k3(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)=>{d3.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,d3.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(!C2(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"&&m3.test(B)&&q.issues.length&&q.issues.some((H)=>H.code==="invalid_type"&&H.expected==="number")){let H=J.keyType._zod.run({value:Number(B),issues:[]},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(g3.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(g3.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=h3(J.entries),X=new Set(Q);$._zod.values=X,$._zod.pattern=new RegExp(`^(${Q.filter((Y)=>g3.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 S2($.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 IH($,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(`^(${k3(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)=>IH(W,Q.value));return IH(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(`^(${k3(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)}}),O5=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)=>jH(W,J));return jH(Y,J)}});function jH($,J){if($.value===void 0)$.value=J.defaultValue;return $}var M5=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)=>RH(W,$));return RH(Y,$)}});function RH($,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 S2("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 r3=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)=>S$(K,J,X));return S$(W,J,X)}else{let W=J.out._zod.run(Q,X);if(W instanceof Promise)return W.then((K)=>S$(K,J,X));return S$(W,J,X)}}});function S$($,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)=>C$($,W,J.out,Q));return C$($,Y,J.out,Q)}else{let Y=J.reverseTransform($.value,$);if(Y instanceof Promise)return Y.then((W)=>C$($,W,J.in,Q));return C$($,Y,J.in,Q)}}function C$($,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 I5=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}}),j5=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 O$($._def.input,X):X,W=await Reflect.apply(Q,this,Y);if($._def.output)return await O$($._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})},$}),R5=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 i3={};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 o3(){return new A5}(wH=globalThis).__zod_globalRegistry??(wH.__zod_globalRegistry=o3());var E1=globalThis.__zod_globalRegistry;function E5($,J){return new $({type:"string",...D(J)})}function S5($,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 n3($,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 s3($,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 C5($,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 R$({check:"less_than",...D(J),value:$,inclusive:!1})}function x1($,J){return new R$({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 I4($){return new qX({check:"string_format",format:"lowercase",...D($)})}function j4($){return new UX({check:"string_format",format:"uppercase",...D($)})}function R4($,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 OX({check:"mime_type",mime:$,...D(J)})}function Q0($){return new MX({check:"overwrite",tx:$})}function E4($){return Q0((J)=>J.normalize($))}function S4(){return Q0(($)=>$.trim())}function C4(){return Q0(($)=>$.toLowerCase())}function T4(){return Q0(($)=>$.toUpperCase())}function w4(){return Q0(($)=>O7($))}function YY($,J,Q){return new $({type:"array",element:J,...D(Q)})}function Ib($,J,Q){return new $({type:"union",options:J,...D(Q)})}function jb($,J,Q){return new $({type:"union",options:J,inclusive:!1,...D(Q)})}function Rb($,J,Q,X){return new $({type:"union",options:Q,discriminator:J,...D(X)})}function bb($,J,Q){return new $({type:"intersection",left:J,right:Q})}function Pb($,J,Q,X){let Y=Q instanceof v;return new $({type:"tuple",items:J,rest:Y?Q:null,...D(Y?X:Q)})}function Ab($,J,Q,X){return new $({type:"record",keyType:J,valueType:Q,...D(X)})}function Eb($,J,Q,X){return new $({type:"map",keyType:J,valueType:Q,...D(X)})}function Sb($,J,Q){return new $({type:"set",valueType:J,...D(Q)})}function Cb($,J,Q){let X=Array.isArray(J)?Object.fromEntries(J.map((Y)=>[Y,Y])):J;return new $({type:"enum",entries:X,...D(Q)})}function Tb($,J,Q){return new $({type:"enum",entries:J,...D(Q)})}function wb($,J,Q){return new $({type:"literal",values:Array.isArray(J)?J:[J],...D(Q)})}function WY($,J){return new $({type:"file",...D(J)})}function vb($,J){return new $({type:"transform",transform:J})}function fb($,J){return new $({type:"optional",innerType:J})}function hb($,J){return new $({type:"nullable",innerType:J})}function kb($,J,Q){return new $({type:"default",innerType:J,get defaultValue(){return typeof Q==="function"?Q():N7(Q)}})}function gb($,J,Q){return new $({type:"nonoptional",innerType:J,...D(Q)})}function yb($,J){return new $({type:"success",innerType:J})}function xb($,J,Q){return new $({type:"catch",innerType:J,catchValue:typeof Q==="function"?Q:()=>Q})}function ub($,J,Q){return new $({type:"pipe",in:J,out:Q})}function mb($,J){return new $({type:"readonly",innerType:J})}function lb($,J,Q){return new $({type:"template_literal",parts:J,...D(Q)})}function pb($,J){return new $({type:"lazy",getter:J})}function cb($,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??r3,q=$.Boolean??c3,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,O)=>{let M=Z;if(Q.case!=="sensitive")M=M.toLowerCase();if(W.has(M))return!0;else if(K.has(M))return!1;else return O.issues.push({code:"invalid_value",expected:"stringbool",values:[...W,...K],input:O.value,inst:L,continue:!1}),{}},reverseTransform:(Z,O)=>{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 db={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=db[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}))]}},OY=($,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},MY=($,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={}},IY=($,J,Q,X)=>{},jY=($,J,Q,X)=>{},RY=($,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=h3(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},SY=($,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)},CY=($,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:OY,boolean:MY,bigint:NY,symbol:FY,null:VY,undefined:_Y,void:DY,never:zY,any:IY,unknown:jY,date:RY,enum:bY,literal:PY,nan:AY,template_literal:EY,file:SY,success:CY,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 a3($,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 Q6={};B2(Q6,{time:()=>eY,duration:()=>$W,datetime:()=>aY,date:()=>tY,ZodISOTime:()=>$6,ZodISODuration:()=>J6,ZodISODateTime:()=>t3,ZodISODate:()=>e3});var t3=N("ZodISODateTime",($,J)=>{SX.init($,J),r.init($,J)});function aY($){return T5(t3,$)}var e3=N("ZodISODate",($,J)=>{CX.init($,J),r.init($,J)});function tY($){return w5(e3,$)}var $6=N("ZodISOTime",($,J)=>{TX.init($,J),r.init($,J)});function eY($){return v5($6,$)}var J6=N("ZodISODuration",($,J)=>{wX.init($,J),r.init($,J)});function $W($){return f5(J6,$)}var kH=($,J)=>{u3.init($,J),$.name="ZodError",Object.defineProperties($,{format:{value:(Q)=>M4($,Q)},flatten:{value:(Q)=>O4($,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 O8=N4(z1),M8=F4(z1),N8=V4(z1),F8=_4(z1),V8=M$(z1),_8=N$(z1),D8=F$(z1),z8=V$(z1),I8=_$(z1),j8=D$(z1),R8=z$(z1),b8=I$(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)=>O8($,Q,X,{callee:$.parse}),$.safeParse=(Q,X)=>N8($,Q,X),$.parseAsync=async(Q,X)=>M8($,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)=>I8($,Q,X),$.safeDecode=(Q,X)=>j8($,Q,X),$.safeEncodeAsync=async(Q,X)=>R8($,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=()=>Y6($),$.exactOptional=()=>PW($),$.nullable=()=>W6($),$.nullish=()=>Y6(W6($)),$.nonoptional=(Q)=>wW($,Q),$.array=()=>U6($),$.or=(Q)=>i8([$,Q]),$.and=(Q)=>NW($,Q),$.transform=(Q)=>K6($,n8(Q)),$.default=(Q)=>SW($,Q),$.prefault=(Q)=>TW($,Q),$.catch=(Q)=>hW($,Q),$.pipe=(Q)=>K6($,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(R4(...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(I4(X)),$.uppercase=(X)=>$.check(j4(X)),$.trim=()=>$.check(S4()),$.normalize=(...X)=>$.check(E4(...X)),$.toLowerCase=()=>$.check(C4()),$.toUpperCase=()=>$.check(T4()),$.slugify=()=>$.check(w4())}),x4=N("ZodString",($,J)=>{w2.init($,J),E8.init($,J),$.email=(Q)=>$.check(y$(S8,Q)),$.url=(Q)=>$.check(s3(B6,Q)),$.jwt=(Q)=>$.check(X8(c8,Q)),$.emoji=(Q)=>$.check(p$(C8,Q)),$.guid=(Q)=>$.check(n3(X6,Q)),$.uuid=(Q)=>$.check(x$(I0,Q)),$.uuidv4=(Q)=>$.check(u$(I0,Q)),$.uuidv6=(Q)=>$.check(m$(I0,Q)),$.uuidv7=(Q)=>$.check(l$(I0,Q)),$.nanoid=(Q)=>$.check(c$(T8,Q)),$.guid=(Q)=>$.check(n3(X6,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)}),S8=N("ZodEmail",($,J)=>{DX.init($,J),r.init($,J)});function yH($){return y$(S8,$)}var X6=N("ZodGUID",($,J)=>{VX.init($,J),r.init($,J)});function xH($){return n3(X6,$)}var I0=N("ZodUUID",($,J)=>{_X.init($,J),r.init($,J)});function uH($){return x$(I0,$)}function mH($){return u$(I0,$)}function lH($){return m$(I0,$)}function pH($){return l$(I0,$)}var B6=N("ZodURL",($,J)=>{zX.init($,J),r.init($,J)});function cH($){return s3(B6,$)}function dH($){return s3(B6,{protocol:/^https?$/,hostname:y1.domain,...w.normalizeParams($)})}var C8=N("ZodEmoji",($,J)=>{IX.init($,J),r.init($,J)});function rH($){return p$(C8,$)}var T8=N("ZodNanoID",($,J)=>{jX.init($,J),r.init($,J)});function iH($){return c$(T8,$)}var w8=N("ZodCUID",($,J)=>{RX.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 C5(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)=>OY($,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 OZ($){return u5(g2,$)}function MZ($){return m5(g2,$)}var l4=N("ZodBoolean",($,J)=>{c3.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>MY($,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)=>IY($,Q,X,Y)});function zZ(){return a5(qW)}var UW=N("ZodUnknown",($,J)=>{sX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>jY($,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 IZ($){return $Y(HW,$)}var q6=N("ZodDate",($,J)=>{eX.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>RY($,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 jZ($){return JY(q6,$)}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 U6($,J){return YY(ZW,$,J)}function RZ($){let J=$._zod.def.shape;return o8(Object.keys(J))}var G6=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 G6(Q)}function PZ($,J){return new G6({type:"object",shape:$,catchall:r8(),...w.normalizeParams(J)})}function AZ($,J){return new G6({type:"object",shape:$,catchall:k2(),...w.normalizeParams(J)})}var H6=N("ZodUnion",($,J)=>{d3.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>Z8($,Q,X,Y),$.options=J.options});function i8($,J){return new H6({type:"union",options:$,...w.normalizeParams(J)})}var LW=N("ZodXor",($,J)=>{H6.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 OW=N("ZodDiscriminatedUnion",($,J)=>{H6.init($,J),X5.init($,J)});function SZ($,J,Q){return new OW({type:"union",options:J,discriminator:$,...w.normalizeParams(Q)})}var MW=N("ZodIntersection",($,J)=>{Y5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>yY($,Q,X,Y)});function NW($,J){return new MW({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 Z6=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 Z6({type:"record",keyType:$,valueType:J,...w.normalizeParams(Q)})}function CZ($,J,Q){let X=N1($);return X._zod.values=void 0,new Z6({type:"record",keyType:X,valueType:J,...w.normalizeParams(Q)})}function TZ($,J,Q){return new Z6({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 IW=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 IW({type:"literal",values:Array.isArray($)?$:[$],...w.normalizeParams(J)})}var jW=N("ZodFile",($,J)=>{G5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>SY($,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(jW,$)}var RW=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 S2($.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 RW({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 Y6($){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 W6($){return new AW({type:"nullable",innerType:$})}function gZ($){return Y6(W6($))}var EW=N("ZodDefault",($,J)=>{O5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>pY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType,$.removeDefault=$.unwrap});function SW($,J){return new EW({type:"default",innerType:$,get defaultValue(){return typeof J==="function"?J():w.shallowClone(J)}})}var CW=N("ZodPrefault",($,J)=>{M5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>cY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function TW($,J){return new CW({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)=>CY($,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 K6($,J){return new t8({type:"pipe",in:$,out:J})}var e8=N("ZodCodec",($,J)=>{t8.init($,J),r3.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)=>{I5.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)=>{R5.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)=>{j5.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??U6(k2()),output:$?.output??k2()})}var L6=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(L6,$??(()=>!0),J)}function cW($,J={}){return BY(L6,$,J)}function dW($){return qY($)}var rZ=UY,iZ=GY;function oZ($,J={}){let Q=new L6({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(),U6(J),_W(P8(),J)])});return J}function aZ($,J){return K6(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 nb=()=>{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:nb()}}var iW=()=>{throw Error("JSON Schema conversion is not bundled into this plugin artifact")};var JJ={};B2(JJ,{string:()=>sb,number:()=>ab,date:()=>$P,boolean:()=>tb,bigint:()=>eb});function sb($){return S5(x4,$)}function ab($){return k5(m4,$)}function tb($){return p5(l4,$)}function eb($){return d5(p4,$)}function $P($){return QY(q6,$)}Y1(rW());var JP=QJ;var JL=Object.freeze(["hard_stop","use_alternative","scope_down","manual_only","stop_and_explain"]);var O6=64,QL="Rule config exceeds CC Safety Net's safe source limit.";var nh=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."},QP=[".bak",".backup",".copy",".disabled",".old",".orig",".save",".tmp"],XP=[{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"]},...XP.flatMap(($)=>QP.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"}],YP=[".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(($)=>YP.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]:[])),WP=YL.map(($)=>$.id),WJ=new Set(WP);var Uk=KP(import.meta.url),KL,BP=Array(O6+1).fill("over-limit"),BL=/^[^/]+\/[^/]+$/,qP=/^sha256:[a-f0-9]{64}$/,KJ=`must be an integer between ${HJ} and ${ZJ}`,UP=["version","rules","overrides","transparent_wrappers"],GP=["version","safety","workflow","destructive_command_protection","secret_protection","audit"];function qL($){if(!i1($)||!Array.isArray($.rules)||$.rules.length<=O6)return $;return{$schema:$.$schema,version:$.version,rules:BP,overrides:$.overrides,transparent_wrappers:$.transparent_wrappers}}function HP(){let $=oW,J=(_)=>{let R=$.superRefine(_);return R._zod.def.when=()=>!0,R},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(O2,"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(O6,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=(_,R)=>{if(!i1(_))return;if(Array.isArray(_.rules)&&_.rules.length<=O6){let S=new Set;_.rules.forEach((T,y)=>{if(typeof T!=="string"||T==="")return;if(T.trim()===""){R.addIssue({code:"custom",message:"must be a non-empty rulebook source string",path:["rules",y]});return}let x=o4(T);if(x){R.addIssue({code:"custom",message:x,path:["rules",y]});return}if(S.has(T)){R.addIssue({code:"custom",message:`duplicate rulebook source "${T}"`,path:["rules",y]});return}S.add(T)})}if(i1(_.overrides))for(let S of Object.keys(_.overrides)){if(BL.test(S))continue;R.addIssue({code:"custom",message:"must use <rulebook-name>/<rule-name>",path:["overrides",S]})}if(!Array.isArray(_.transparent_wrappers))return;let P=new Set;_.transparent_wrappers.forEach((S,T)=>{if(typeof S!=="string"||!O2.test(S))return;if(P.has(S)){R.addIssue({code:"custom",message:`duplicate command "${S}"`,path:["transparent_wrappers",T]});return}if(LU(S)){R.addIssue({code:"custom",message:`reserved command "${S}" cannot be a wrapper`,path:["transparent_wrappers",T]});return}P.add(S)})},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=(_,R)=>$.intersection($.record($.string().refine((P)=>_.has(P),{error:(P)=>`unknown ${R} rule id "${String(P.input)}"`}),$.unknown()),$.record($.string(),$.enum(["on","off"]))),L=(_)=>$.array($.string({error:"must be a non-empty path string"}),{error:"must be an array of paths"}).check(J((R,P)=>{if(!Array.isArray(R))return;let S=c2();R.forEach((T,y)=>{if(typeof T!=="string")return;let x=_(T,S);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(i6,"destructive command").optional(),allow_paths:L(C9).optional()}).optional(),secret_protection:$.strictObject({enabled:$.boolean().optional(),overrides:H(WJ,"secret protection").optional(),deny_paths:L(T9).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()}),O=(_)=>{let R=(y,x)=>_==="legacy"?y:x,P=R("must match pattern (letters, numbers, hyphens, underscores)","must match command pattern"),S=`required non-empty string up to ${o2} characters`,T=$.looseObject({name:$.string({error:"required string"}).regex(Y0,R("must match pattern (letters, numbers, hyphens, underscores; max 64 chars)","must match rule name pattern")),command:$.string({error:R("required string","required string matching command pattern")}).regex(O2,R(P,"required string matching command pattern")),subcommand:$.string({error:R("must be a string if provided","must match command pattern")}).regex(O2,P).optional(),block_args:$.array($.string({error:R("must be a string","must be a non-empty string")}).refine((y)=>y!=="",{error:R("must not be empty","must be a non-empty string")}),{error:R("required array","required non-empty array")}).refine((y)=>y.length>0,{error:R("must have at least one element","required non-empty array")}),reason:$.string({error:R("required string",S)}).refine((y)=>y!=="",{error:R("must not be empty",S)}).refine((y)=>y.length<=o2,{error:R(`must be at most ${o2} characters`,S)}),intent:Q.optional()},{error:"must be an object"});return $.array(T,{error:R("must be an array","required array")}).check(J((y,x)=>{if(!Array.isArray(y))return;let c=new Set;y.forEach((V1,C)=>{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:[C,"name"]});return}c.add(m.toLowerCase())})}))},M=$.looseObject({version:$.literal(1),rules:O("legacy").optional()}),V="required string matching rule name pattern",F=$.looseObject({command:$.string({error:"required non-empty string"}).refine((_)=>_.trim()!=="",{error:"required non-empty string"}),expect:$.enum(["blocked","allowed"]),rule:$.string({error:"must be a string if provided"}).optional()},{error:"must be an object"}).check(J((_,R)=>{if(!i1(_))return;if(_.expect!=="blocked"||typeof _.rule==="string")return;R.addIssue({code:"custom",message:"required string for blocked fixtures",path:["rule"]})})),b=$.looseObject({name:$.string({error:"required string matching rule name pattern"}).regex(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(O2,"must match command pattern"),{error:"required array"}).check(J((_,R)=>{if(!Array.isArray(_))return;let P=new Set;_.forEach((S,T)=>{if(typeof S!=="string"||!O2.test(S))return;if(P.has(S)){R.addIssue({code:"custom",message:`duplicate command "${S}"`,path:[T]});return}P.add(S)})})),rules:O("rulebook"),tests:$.array(F,{error:"must be an array if provided"}).optional()}).check(J((_,R)=>{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;R.addIssue({code:"custom",message:`blocked fixture references unknown rule "${y}"`,path:["tests"]})}}if(!Array.isArray(_.allowed_commands)||!Array.isArray(_.rules))return;let S=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"||S.has(x))return;R.addIssue({code:"custom",message:`"${x}" must be listed in allowed_commands`,path:["rules",y,"command"]})})})),I=$.string({error:"required string"}).refine((_)=>_.trim()!=="",{error:"required string"}),A=$.looseObject({spec:I,name:I,version:I,digest:$.string({error:"required sha256 digest"}).regex(qP,"required sha256 digest")},{error:"must be an object"}),E=$.looseObject({rulebooks:$.array($.intersection(A,$.discriminatedUnion("kind",[$.object({kind:$.literal("local-directory"),path:I}),$.object({kind:$.literal("github"),owner:I,repo:I,ref:I,commit:I,path:I,display_ref:$.unknown().optional()})],{error:(_)=>{if(!i1(_.input))return"must be an object";let R=_.input.kind;return typeof R==="string"?`unknown kind "${R}"`:"required string"}})))});return{RulesConfigSchema:q,RulesConfigDiagnosticSchema:U,RuleOverrideSchema:X,UserPolicySchema:Z,LegacyConfigSchema:M,RulebookSchema:b,RulesLockfileSchema:E}}function N6(){return KL??=HP(),KL}function UL(){return N6().RulesConfigSchema}function ZP(){return N6().UserPolicySchema}function GL(){return N6().RulebookSchema}function HL(){return N6().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=N6().RulesConfigDiagnosticSchema.safeParse($);if(J.success)return{errors:[],sources:new Set(J.data.rules)};return{errors:c4(ML(J.error.issues,UP)),sources:NP($,J.error.issues)}}function LL($){let J=ZP().safeParse($);if(J.success)return[];return c4(ML(J.error.issues,GP)," ")}function c4($,J=": ",Q=" "){return[...new Set($.flatMap((X)=>OL(X,J,Q,[])))]}function OL($,J,Q,X){let Y=[...X,...$.path],W=MP(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)=>OL(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}${LP($)}`]}function LP($){if($.code==="invalid_value")return`must be ${OP($.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 OP($){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 MP($){return $.map((J,Q)=>{if(typeof J==="number")return`[${J}]`;return Q===0?String(J):`.${String(J)}`}).join("")}function ML($,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 NP($,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 FP($){return ZL($)}function QK($){try{let J=q2(VP($));if(J===null)return{config:null,errors:[]};if(!J.trim())return{config:null,errors:["Config file is empty"]};let Q=JSON.parse(J),X=FP(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 VP($){return typeof $==="string"?A6($):$}var jP=new Set(["standard","strict","paranoid"]),RP={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:j6}};function XK($){return IP(zP(U2($)),C6)}function _L($={}){let J=EP(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(!j0($))return AP();let J=j0($.safety)?$.safety:{},Q=j0(J.overrides)?J.overrides:{},X=j0($.workflow)?$.workflow:{},Y=j0($.destructive_command_protection)?$.destructive_command_protection:{},W=j0($.secret_protection)?$.secret_protection:{};return{version:1,safety:{level:jP.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,i6),allow_paths:PP(Y.allow_paths)},secret_protection:{enabled:typeof W.enabled==="boolean"?W.enabled:!0,overrides:FL(W.overrides,WJ),deny_paths:bP(W.deny_paths)},audit:{retention_days:R6(j0($.audit)?$.audit.retention_days:void 0)}}}function FL($,J){if(!j0($))return{};return Object.fromEntries(Object.entries($).flatMap(([Q,X])=>J.has(Q)&&(X==="on"||X==="off")?[[Q,X]]:[]))}function bP($){if(!Array.isArray($))return[];let J=c2();return $.filter((Q)=>T9(Q,J)===null)}function PP($){if(!Array.isArray($))return[];let J=c2();return $.filter((Q)=>C9(Q,J)===null)}function j0($){return!!$&&typeof $==="object"&&!Array.isArray($)}function AP(){return structuredClone(RP)}function EP($){let J=SP();if(!_P($)){let Q=globalThis.__CC_SAFETY_NET_EMBEDDED_POLICY__;if(!j0(Q))return{policy:J,errors:[]};return{policy:VL(NL(Q)),errors:[]}}try{let Q=DP($,"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:j0(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 SP(){return{safety:{},worktreeMode:!1,destructiveCommandProtectionEnabled:!0,destructiveCommandRuleOverrides:{},destructiveCommandAllowPaths:[],secretProtection:{enabled:!0,disabledRules:DL({}),denyPaths:[]}}}function VL($){return{safety:CP($.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 CP($){return{level:$.level,overrides:{failClosed:$.overrides.fail_closed,paranoidRm:$.overrides.paranoid_rm,paranoidInterpreters:$.overrides.paranoid_interpreters}}}var RL="This path contains the protected policy config and you must not modify or delete it.",TP=new Set(["[","cat","file","grep","head","jq","less","ls","more","rg","sed","stat","tail","test","wc"]);function bL($){let J=H2(E0()),Q=gP($.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?IL(X.shell,$.invocation.context.executionCwd,Q,J):null;if($.invocation.route.kind==="unknown"&&X){let Y=IL(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"||b9($.invocation.toolName),$.invocation.context.executionCwd,Q,J)}function zL($,J,Q,X,Y){if(J)return null;let W=$.find((K)=>F6(K,Q,X,Y));return W?{target:W}:null}function IL($,J,Q,X){let Y=A9($,J,X,{findSegmentTarget:(W,K)=>wP(W,K,Q,X)?.target??null,isRedirectionTarget:(W,K)=>F6(W,K.cwd,Q,X),findMalformedTarget:(W)=>kP(W,J,Q,X)?.target??null,normalizeCwd:M1});return Y?{target:Y}:null}function wP($,J,Q,X){if(O3($))return null;let Y=X.environment,W=l1([...$],Y),K=l(W[0]??"").toLowerCase(),B=W.slice(1);if(K==="rm"&&vP(B)){let q=fP(B).find((U)=>jL(f1(U,J.variables),J.cwd,Q,X));if(q)return{target:q}}if(K==="find"){if(x9(W,1)||AQ(W,Y)){let U=(y9(p(W))??p(["."])).find((G)=>{let H=f1(G.text,J.variables);return F6(H,J.cwd,Q,X)||jL(H,J.cwd,Q,X)})?.text;if(U)return{target:U}}}if(K==="mv"){let q=E9(B).sources.find((U)=>yP(f1(U,J.variables),J.cwd,Q,X));if(q)return{target:q}}if(hP($,Y))return null;for(let q of $)for(let U of PL(q))if(F6(f1(U,J.variables),J.cwd,Q,X))return{target:U};return null}function vP($){return $.some((J)=>J==="--recursive"||J.startsWith("-")&&!J.startsWith("--")&&/[rR]/.test(J.slice(1)))}function fP($){let J=$.indexOf("--");if(J!==-1)return[...$.slice(0,J).filter((Q)=>!Q.startsWith("-")),...$.slice(J+1)];return $.filter((Q)=>!Q.startsWith("-"))}function hP($,J){let Q=l1([...$],J);if(Q.length===0)return!1;let X=l(Q[0]??"").toLowerCase();if(!TP.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 kP($,J,Q,X){for(let Y of $.split(/\s+/))for(let W of PL(Y))if(F6(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 gP($,J){let Q=M1(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 F6($,J,Q,X){return d4(M1($,J,X))===Q.file}function jL($,J,Q,X){return Q.directoryAndAncestors.has(d4(M1($,J,X)))}function yP($,J,Q,X){let Y=d4(M1($,J,X));return Y===Q.file||Q.directoryAndAncestors.has(Y)}function d4($){return process.platform==="win32"?$.toLowerCase():$}import{homedir as xP}from"os";import{isAbsolute as KK,resolve as hL}from"path";import{fileURLToPath as uP}from"url";var kL="Access to a sensitive path is not allowed.",gL=new Set(["echo","printf"]),mP=new Set(["find"]),lP=new Set(["-exec","-execdir"]),pP=new Set([";","+"]),cP=new Set(["-delete","-exec","-execdir","-fls","-fprint","-fprint0","-fprintf","-ok","-okdir"]),dP=new Set(["-name","-iname","-path","-ipath","-wholename","-iwholename","-samefile"]),rP=new Set(["python","python2","python3","node","deno","bun","ruby","perl","php","rscript","osascript","bash","sh","zsh","dash","ksh"]),iP=new Set(["node","bun"]),oP=new Set(["bun","child_process","deno","dotenv","fs","subprocess"]),nP=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"]),sP=new Set(["src/cli/cc-safety-net.ts","dist/bin/cc-safety-net.js"]),aP=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"])]]),tP=new Set(["grep","rg"]),AL="f",EL="file",eP="files",$A=new Set(["e","f"]),JA=new Set(["regexp","file"]),QA=new Set(["e","f","A","B","C","m"]),XA=new Set(["regexp","file","after-context","before-context","context","max-count"]),YA=new Set(["|","|&"]),WK="__CC_SAFETY_NET_PIPE_INPUT__",xL=new Set(["bash","sh","zsh","dash","ksh"]),WA=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 SL($,J,Q,X,Y){let W=s4();for(let K of $){if(pA(K,J,Q?.denyPaths??[],X,W))return{target:K,ruleId:"secret.deny-path"};if(Y&&!Y.has(K))continue;let B=mA(K,J,Q,W);if(B)return{target:K,ruleId:B}}return null}function uL($,J,Q={}){let X=CL($),Y=SL(X,$.invocation.context.executionCwd,J,$.invocation.context.configCwd),W=Y?.ruleId!=="secret.deny-path"&&Q.strict===!1?CL($,{refineJavaScriptInlineData:!0}):X,K=W.length===X.length?Y:SL(X,$.invocation.context.executionCwd,J,$.invocation.context.configCwd,new Set(W));if(K?.ruleId!=="secret.deny-path"&&Q.strict===!1&&KA($))return null;return K}function KA($){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)=>cP.has(K))}function CL($,J={}){if($.invocation.route.kind==="command"){let X=w1($,"input-candidate");return X?D6(X.shell,$.store,J):[]}if($.invocation.route.kind!=="unknown")return $.paths.map((X)=>X.raw);let Q=w1($,"input-candidate");return[...Q?D6(Q.shell,$.store,J):[],...$.paths.map((X)=>X.raw)]}function D6($,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,...PA(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=YA.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=NA($),Y=i4($);if(Y.length===0)return X;let W=Y[0]??"",K=y2(W).toLowerCase(),B=Y.slice(1),q=BA(W,K,B);if(q)return[...X,...q];if(gL.has(K))return X;if(tP.has(K))return[...X,...fA(B)];if(mP.has(K))return[...X,...FA(B,J,Q)];if(h1.has(K))return[...X,...B.flatMap((U)=>wL("awk",U)),...B.flatMap((U)=>_A(U,J,Q)),...B.flatMap(DA)];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,...VA(K,B,Q)]}return[...X,...B.flatMap((U)=>wL(K,U))]}function BA($,J,Q){let X=J==="cc-safety-net"&&Q[0]==="explain",Y=(J==="bun"||J==="node")&&qA(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 qA($){let J=$?.replaceAll("\\","/");return[...sP].some((Q)=>J===Q||J?.endsWith(`/${Q}`))}function TL($,J,Q,X){if(LA(J,Q,X))return UA($);let Y=OA(J);if(Y===null)return[];return GA($).flatMap((W)=>xL.has(Y)?D6(Q.getShellSyntax(W),Q,X):dL(W))}function UA($){let J=i4($);if(J.length===0)return[];let Q=y2(J[0]??"").toLowerCase();if(!gL.has(Q))return[];return J.slice(1)}function GA($){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 HA(X);return[]}function HA($){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)=>ZA(J,X.slice(W*Q,(W+1)*Q)))}function ZA($,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
+ `)}Z.write("payload.value = newResult;"),Z.write("return payload;");let b=Z.compile();return(I,A)=>b(L,I,A)},W,K=C2,B=!v3.jitless,U=B&&M7.value,G=J.catchall,H;$._zod.parse=(L,Z)=>{H??(H=X.value);let O=L.value;if(!K(O))return L.issues.push({expected:"object",code:"invalid_type",input:O,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 CH([],O,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 d3=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)=>k3(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)=>{d3.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,d3.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(!C2(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"&&m3.test(B)&&q.issues.length&&q.issues.some((H)=>H.code==="invalid_type"&&H.expected==="number")){let H=J.keyType._zod.run({value:Number(B),issues:[]},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(g3.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(g3.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=h3(J.entries),X=new Set(Q);$._zod.values=X,$._zod.pattern=new RegExp(`^(${Q.filter((Y)=>g3.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 S2($.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 IH($,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(`^(${k3(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)=>IH(W,Q.value));return IH(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(`^(${k3(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)}}),O5=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)=>jH(W,J));return jH(Y,J)}});function jH($,J){if($.value===void 0)$.value=J.defaultValue;return $}var M5=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)=>RH(W,$));return RH(Y,$)}});function RH($,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 S2("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 r3=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)=>S$(K,J,X));return S$(W,J,X)}else{let W=J.out._zod.run(Q,X);if(W instanceof Promise)return W.then((K)=>S$(K,J,X));return S$(W,J,X)}}});function S$($,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)=>C$($,W,J.out,Q));return C$($,Y,J.out,Q)}else{let Y=J.reverseTransform($.value,$);if(Y instanceof Promise)return Y.then((W)=>C$($,W,J.in,Q));return C$($,Y,J.in,Q)}}function C$($,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 I5=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}}),j5=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 O$($._def.input,X):X,W=await Reflect.apply(Q,this,Y);if($._def.output)return await O$($._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})},$}),R5=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 i3={};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 o3(){return new A5}(wH=globalThis).__zod_globalRegistry??(wH.__zod_globalRegistry=o3());var E1=globalThis.__zod_globalRegistry;function E5($,J){return new $({type:"string",...D(J)})}function S5($,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 n3($,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 s3($,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 C5($,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 R$({check:"less_than",...D(J),value:$,inclusive:!1})}function x1($,J){return new R$({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 I4($){return new qX({check:"string_format",format:"lowercase",...D($)})}function j4($){return new UX({check:"string_format",format:"uppercase",...D($)})}function R4($,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 OX({check:"mime_type",mime:$,...D(J)})}function Q0($){return new MX({check:"overwrite",tx:$})}function E4($){return Q0((J)=>J.normalize($))}function S4(){return Q0(($)=>$.trim())}function C4(){return Q0(($)=>$.toLowerCase())}function T4(){return Q0(($)=>$.toUpperCase())}function w4(){return Q0(($)=>O7($))}function YY($,J,Q){return new $({type:"array",element:J,...D(Q)})}function Ib($,J,Q){return new $({type:"union",options:J,...D(Q)})}function jb($,J,Q){return new $({type:"union",options:J,inclusive:!1,...D(Q)})}function Rb($,J,Q,X){return new $({type:"union",options:Q,discriminator:J,...D(X)})}function bb($,J,Q){return new $({type:"intersection",left:J,right:Q})}function Pb($,J,Q,X){let Y=Q instanceof v;return new $({type:"tuple",items:J,rest:Y?Q:null,...D(Y?X:Q)})}function Ab($,J,Q,X){return new $({type:"record",keyType:J,valueType:Q,...D(X)})}function Eb($,J,Q,X){return new $({type:"map",keyType:J,valueType:Q,...D(X)})}function Sb($,J,Q){return new $({type:"set",valueType:J,...D(Q)})}function Cb($,J,Q){let X=Array.isArray(J)?Object.fromEntries(J.map((Y)=>[Y,Y])):J;return new $({type:"enum",entries:X,...D(Q)})}function Tb($,J,Q){return new $({type:"enum",entries:J,...D(Q)})}function wb($,J,Q){return new $({type:"literal",values:Array.isArray(J)?J:[J],...D(Q)})}function WY($,J){return new $({type:"file",...D(J)})}function vb($,J){return new $({type:"transform",transform:J})}function fb($,J){return new $({type:"optional",innerType:J})}function hb($,J){return new $({type:"nullable",innerType:J})}function kb($,J,Q){return new $({type:"default",innerType:J,get defaultValue(){return typeof Q==="function"?Q():N7(Q)}})}function gb($,J,Q){return new $({type:"nonoptional",innerType:J,...D(Q)})}function yb($,J){return new $({type:"success",innerType:J})}function xb($,J,Q){return new $({type:"catch",innerType:J,catchValue:typeof Q==="function"?Q:()=>Q})}function ub($,J,Q){return new $({type:"pipe",in:J,out:Q})}function mb($,J){return new $({type:"readonly",innerType:J})}function lb($,J,Q){return new $({type:"template_literal",parts:J,...D(Q)})}function pb($,J){return new $({type:"lazy",getter:J})}function cb($,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??r3,q=$.Boolean??c3,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,O)=>{let M=Z;if(Q.case!=="sensitive")M=M.toLowerCase();if(W.has(M))return!0;else if(K.has(M))return!1;else return O.issues.push({code:"invalid_value",expected:"stringbool",values:[...W,...K],input:O.value,inst:L,continue:!1}),{}},reverseTransform:(Z,O)=>{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 db={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=db[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}))]}},OY=($,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},MY=($,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={}},IY=($,J,Q,X)=>{},jY=($,J,Q,X)=>{},RY=($,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=h3(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},SY=($,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)},CY=($,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:OY,boolean:MY,bigint:NY,symbol:FY,null:VY,undefined:_Y,void:DY,never:zY,any:IY,unknown:jY,date:RY,enum:bY,literal:PY,nan:AY,template_literal:EY,file:SY,success:CY,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 a3($,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 Q6={};B2(Q6,{time:()=>eY,duration:()=>$W,datetime:()=>aY,date:()=>tY,ZodISOTime:()=>$6,ZodISODuration:()=>J6,ZodISODateTime:()=>t3,ZodISODate:()=>e3});var t3=N("ZodISODateTime",($,J)=>{SX.init($,J),r.init($,J)});function aY($){return T5(t3,$)}var e3=N("ZodISODate",($,J)=>{CX.init($,J),r.init($,J)});function tY($){return w5(e3,$)}var $6=N("ZodISOTime",($,J)=>{TX.init($,J),r.init($,J)});function eY($){return v5($6,$)}var J6=N("ZodISODuration",($,J)=>{wX.init($,J),r.init($,J)});function $W($){return f5(J6,$)}var kH=($,J)=>{u3.init($,J),$.name="ZodError",Object.defineProperties($,{format:{value:(Q)=>M4($,Q)},flatten:{value:(Q)=>O4($,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 O8=N4(z1),M8=F4(z1),N8=V4(z1),F8=_4(z1),V8=M$(z1),_8=N$(z1),D8=F$(z1),z8=V$(z1),I8=_$(z1),j8=D$(z1),R8=z$(z1),b8=I$(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)=>O8($,Q,X,{callee:$.parse}),$.safeParse=(Q,X)=>N8($,Q,X),$.parseAsync=async(Q,X)=>M8($,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)=>I8($,Q,X),$.safeDecode=(Q,X)=>j8($,Q,X),$.safeEncodeAsync=async(Q,X)=>R8($,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=()=>Y6($),$.exactOptional=()=>PW($),$.nullable=()=>W6($),$.nullish=()=>Y6(W6($)),$.nonoptional=(Q)=>wW($,Q),$.array=()=>U6($),$.or=(Q)=>i8([$,Q]),$.and=(Q)=>NW($,Q),$.transform=(Q)=>K6($,n8(Q)),$.default=(Q)=>SW($,Q),$.prefault=(Q)=>TW($,Q),$.catch=(Q)=>hW($,Q),$.pipe=(Q)=>K6($,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(R4(...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(I4(X)),$.uppercase=(X)=>$.check(j4(X)),$.trim=()=>$.check(S4()),$.normalize=(...X)=>$.check(E4(...X)),$.toLowerCase=()=>$.check(C4()),$.toUpperCase=()=>$.check(T4()),$.slugify=()=>$.check(w4())}),x4=N("ZodString",($,J)=>{w2.init($,J),E8.init($,J),$.email=(Q)=>$.check(y$(S8,Q)),$.url=(Q)=>$.check(s3(B6,Q)),$.jwt=(Q)=>$.check(X8(c8,Q)),$.emoji=(Q)=>$.check(p$(C8,Q)),$.guid=(Q)=>$.check(n3(X6,Q)),$.uuid=(Q)=>$.check(x$(I0,Q)),$.uuidv4=(Q)=>$.check(u$(I0,Q)),$.uuidv6=(Q)=>$.check(m$(I0,Q)),$.uuidv7=(Q)=>$.check(l$(I0,Q)),$.nanoid=(Q)=>$.check(c$(T8,Q)),$.guid=(Q)=>$.check(n3(X6,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)}),S8=N("ZodEmail",($,J)=>{DX.init($,J),r.init($,J)});function yH($){return y$(S8,$)}var X6=N("ZodGUID",($,J)=>{VX.init($,J),r.init($,J)});function xH($){return n3(X6,$)}var I0=N("ZodUUID",($,J)=>{_X.init($,J),r.init($,J)});function uH($){return x$(I0,$)}function mH($){return u$(I0,$)}function lH($){return m$(I0,$)}function pH($){return l$(I0,$)}var B6=N("ZodURL",($,J)=>{zX.init($,J),r.init($,J)});function cH($){return s3(B6,$)}function dH($){return s3(B6,{protocol:/^https?$/,hostname:y1.domain,...w.normalizeParams($)})}var C8=N("ZodEmoji",($,J)=>{IX.init($,J),r.init($,J)});function rH($){return p$(C8,$)}var T8=N("ZodNanoID",($,J)=>{jX.init($,J),r.init($,J)});function iH($){return c$(T8,$)}var w8=N("ZodCUID",($,J)=>{RX.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 C5(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)=>OY($,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 OZ($){return u5(g2,$)}function MZ($){return m5(g2,$)}var l4=N("ZodBoolean",($,J)=>{c3.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>MY($,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)=>IY($,Q,X,Y)});function zZ(){return a5(qW)}var UW=N("ZodUnknown",($,J)=>{sX.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>jY($,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 IZ($){return $Y(HW,$)}var q6=N("ZodDate",($,J)=>{eX.init($,J),g.init($,J),$._zod.processJSONSchema=(X,Y,W)=>RY($,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 jZ($){return JY(q6,$)}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 U6($,J){return YY(ZW,$,J)}function RZ($){let J=$._zod.def.shape;return o8(Object.keys(J))}var G6=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 G6(Q)}function PZ($,J){return new G6({type:"object",shape:$,catchall:r8(),...w.normalizeParams(J)})}function AZ($,J){return new G6({type:"object",shape:$,catchall:k2(),...w.normalizeParams(J)})}var H6=N("ZodUnion",($,J)=>{d3.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>Z8($,Q,X,Y),$.options=J.options});function i8($,J){return new H6({type:"union",options:$,...w.normalizeParams(J)})}var LW=N("ZodXor",($,J)=>{H6.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 OW=N("ZodDiscriminatedUnion",($,J)=>{H6.init($,J),X5.init($,J)});function SZ($,J,Q){return new OW({type:"union",options:J,discriminator:$,...w.normalizeParams(Q)})}var MW=N("ZodIntersection",($,J)=>{Y5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>yY($,Q,X,Y)});function NW($,J){return new MW({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 Z6=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 Z6({type:"record",keyType:$,valueType:J,...w.normalizeParams(Q)})}function CZ($,J,Q){let X=N1($);return X._zod.values=void 0,new Z6({type:"record",keyType:X,valueType:J,...w.normalizeParams(Q)})}function TZ($,J,Q){return new Z6({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 IW=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 IW({type:"literal",values:Array.isArray($)?$:[$],...w.normalizeParams(J)})}var jW=N("ZodFile",($,J)=>{G5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>SY($,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(jW,$)}var RW=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 S2($.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 RW({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 Y6($){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 W6($){return new AW({type:"nullable",innerType:$})}function gZ($){return Y6(W6($))}var EW=N("ZodDefault",($,J)=>{O5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>pY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType,$.removeDefault=$.unwrap});function SW($,J){return new EW({type:"default",innerType:$,get defaultValue(){return typeof J==="function"?J():w.shallowClone(J)}})}var CW=N("ZodPrefault",($,J)=>{M5.init($,J),g.init($,J),$._zod.processJSONSchema=(Q,X,Y)=>cY($,Q,X,Y),$.unwrap=()=>$._zod.def.innerType});function TW($,J){return new CW({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)=>CY($,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 K6($,J){return new t8({type:"pipe",in:$,out:J})}var e8=N("ZodCodec",($,J)=>{t8.init($,J),r3.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)=>{I5.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)=>{R5.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)=>{j5.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??U6(k2()),output:$?.output??k2()})}var L6=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(L6,$??(()=>!0),J)}function cW($,J={}){return BY(L6,$,J)}function dW($){return qY($)}var rZ=UY,iZ=GY;function oZ($,J={}){let Q=new L6({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(),U6(J),_W(P8(),J)])});return J}function aZ($,J){return K6(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 nb=()=>{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:nb()}}var iW=()=>{throw Error("JSON Schema conversion is not bundled into this plugin artifact")};var JJ={};B2(JJ,{string:()=>sb,number:()=>ab,date:()=>$P,boolean:()=>tb,bigint:()=>eb});function sb($){return S5(x4,$)}function ab($){return k5(m4,$)}function tb($){return p5(l4,$)}function eb($){return d5(p4,$)}function $P($){return QY(q6,$)}Y1(rW());var JP=QJ;var JL=Object.freeze(["hard_stop","use_alternative","scope_down","manual_only","stop_and_explain"]);var O6=64,QL="Rule config exceeds CC Safety Net's safe source limit.";var nh=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."},QP=[".bak",".backup",".copy",".disabled",".old",".orig",".save",".tmp"],XP=[{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"]},...XP.flatMap(($)=>QP.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"}],YP=[".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(($)=>YP.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]:[])),WP=YL.map(($)=>$.id),WJ=new Set(WP);var Uk=KP(import.meta.url),KL,BP=Array(O6+1).fill("over-limit"),BL=/^[^/]+\/[^/]+$/,qP=/^sha256:[a-f0-9]{64}$/,KJ=`must be an integer between ${HJ} and ${ZJ}`,UP=["version","rules","overrides","transparent_wrappers"],GP=["version","safety","workflow","destructive_command_protection","secret_protection","audit"];function qL($){if(!i1($)||!Array.isArray($.rules)||$.rules.length<=O6)return $;return{$schema:$.$schema,version:$.version,rules:BP,overrides:$.overrides,transparent_wrappers:$.transparent_wrappers}}function HP(){let $=oW,J=(_)=>{let R=$.superRefine(_);return R._zod.def.when=()=>!0,R},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(O2,"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(O6,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=(_,R)=>{if(!i1(_))return;if(Array.isArray(_.rules)&&_.rules.length<=O6){let S=new Set;_.rules.forEach((T,y)=>{if(typeof T!=="string"||T==="")return;if(T.trim()===""){R.addIssue({code:"custom",message:"must be a non-empty rulebook source string",path:["rules",y]});return}let x=o4(T);if(x){R.addIssue({code:"custom",message:x,path:["rules",y]});return}if(S.has(T)){R.addIssue({code:"custom",message:`duplicate rulebook source "${T}"`,path:["rules",y]});return}S.add(T)})}if(i1(_.overrides))for(let S of Object.keys(_.overrides)){if(BL.test(S))continue;R.addIssue({code:"custom",message:"must use <rulebook-name>/<rule-name>",path:["overrides",S]})}if(!Array.isArray(_.transparent_wrappers))return;let P=new Set;_.transparent_wrappers.forEach((S,T)=>{if(typeof S!=="string"||!O2.test(S))return;if(P.has(S)){R.addIssue({code:"custom",message:`duplicate command "${S}"`,path:["transparent_wrappers",T]});return}if(LU(S)){R.addIssue({code:"custom",message:`reserved command "${S}" cannot be a wrapper`,path:["transparent_wrappers",T]});return}P.add(S)})},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=(_,R)=>$.intersection($.record($.string().refine((P)=>_.has(P),{error:(P)=>`unknown ${R} rule id "${String(P.input)}"`}),$.unknown()),$.record($.string(),$.enum(["on","off"]))),L=(_)=>$.array($.string({error:"must be a non-empty path string"}),{error:"must be an array of paths"}).check(J((R,P)=>{if(!Array.isArray(R))return;let S=c2();R.forEach((T,y)=>{if(typeof T!=="string")return;let x=_(T,S);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(i6,"destructive command").optional(),allow_paths:L(C9).optional()}).optional(),secret_protection:$.strictObject({enabled:$.boolean().optional(),overrides:H(WJ,"secret protection").optional(),deny_paths:L(T9).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()}),O=(_)=>{let R=(y,x)=>_==="legacy"?y:x,P=R("must match pattern (letters, numbers, hyphens, underscores)","must match command pattern"),S=`required non-empty string up to ${o2} characters`,T=$.looseObject({name:$.string({error:"required string"}).regex(Y0,R("must match pattern (letters, numbers, hyphens, underscores; max 64 chars)","must match rule name pattern")),command:$.string({error:R("required string","required string matching command pattern")}).regex(O2,R(P,"required string matching command pattern")),subcommand:$.string({error:R("must be a string if provided","must match command pattern")}).regex(O2,P).optional(),block_args:$.array($.string({error:R("must be a string","must be a non-empty string")}).refine((y)=>y!=="",{error:R("must not be empty","must be a non-empty string")}),{error:R("required array","required non-empty array")}).refine((y)=>y.length>0,{error:R("must have at least one element","required non-empty array")}),reason:$.string({error:R("required string",S)}).refine((y)=>y!=="",{error:R("must not be empty",S)}).refine((y)=>y.length<=o2,{error:R(`must be at most ${o2} characters`,S)}),intent:Q.optional()},{error:"must be an object"});return $.array(T,{error:R("must be an array","required array")}).check(J((y,x)=>{if(!Array.isArray(y))return;let c=new Set;y.forEach((V1,C)=>{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:[C,"name"]});return}c.add(m.toLowerCase())})}))},M=$.looseObject({version:$.literal(1),rules:O("legacy").optional()}),V="required string matching rule name pattern",F=$.looseObject({command:$.string({error:"required non-empty string"}).refine((_)=>_.trim()!=="",{error:"required non-empty string"}),expect:$.enum(["blocked","allowed"]),rule:$.string({error:"must be a string if provided"}).optional()},{error:"must be an object"}).check(J((_,R)=>{if(!i1(_))return;if(_.expect!=="blocked"||typeof _.rule==="string")return;R.addIssue({code:"custom",message:"required string for blocked fixtures",path:["rule"]})})),b=$.looseObject({name:$.string({error:"required string matching rule name pattern"}).regex(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(O2,"must match command pattern"),{error:"required array"}).check(J((_,R)=>{if(!Array.isArray(_))return;let P=new Set;_.forEach((S,T)=>{if(typeof S!=="string"||!O2.test(S))return;if(P.has(S)){R.addIssue({code:"custom",message:`duplicate command "${S}"`,path:[T]});return}P.add(S)})})),rules:O("rulebook"),tests:$.array(F,{error:"must be an array if provided"}).optional()}).check(J((_,R)=>{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;R.addIssue({code:"custom",message:`blocked fixture references unknown rule "${y}"`,path:["tests"]})}}if(!Array.isArray(_.allowed_commands)||!Array.isArray(_.rules))return;let S=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"||S.has(x))return;R.addIssue({code:"custom",message:`"${x}" must be listed in allowed_commands`,path:["rules",y,"command"]})})})),I=$.string({error:"required string"}).refine((_)=>_.trim()!=="",{error:"required string"}),A=$.looseObject({spec:I,name:I,version:I,digest:$.string({error:"required sha256 digest"}).regex(qP,"required sha256 digest")},{error:"must be an object"}),E=$.looseObject({rulebooks:$.array($.intersection(A,$.discriminatedUnion("kind",[$.object({kind:$.literal("local-directory"),path:I}),$.object({kind:$.literal("github"),owner:I,repo:I,ref:I,commit:I,path:I,display_ref:$.unknown().optional()})],{error:(_)=>{if(!i1(_.input))return"must be an object";let R=_.input.kind;return typeof R==="string"?`unknown kind "${R}"`:"required string"}})))});return{RulesConfigSchema:q,RulesConfigDiagnosticSchema:U,RuleOverrideSchema:X,UserPolicySchema:Z,LegacyConfigSchema:M,RulebookSchema:b,RulesLockfileSchema:E}}function N6(){return KL??=HP(),KL}function UL(){return N6().RulesConfigSchema}function ZP(){return N6().UserPolicySchema}function GL(){return N6().RulebookSchema}function HL(){return N6().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=N6().RulesConfigDiagnosticSchema.safeParse($);if(J.success)return{errors:[],sources:new Set(J.data.rules)};return{errors:c4(ML(J.error.issues,UP)),sources:NP($,J.error.issues)}}function LL($){let J=ZP().safeParse($);if(J.success)return[];return c4(ML(J.error.issues,GP)," ")}function c4($,J=": ",Q=" "){return[...new Set($.flatMap((X)=>OL(X,J,Q,[])))]}function OL($,J,Q,X){let Y=[...X,...$.path],W=MP(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)=>OL(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}${LP($)}`]}function LP($){if($.code==="invalid_value")return`must be ${OP($.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 OP($){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 MP($){return $.map((J,Q)=>{if(typeof J==="number")return`[${J}]`;return Q===0?String(J):`.${String(J)}`}).join("")}function ML($,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 NP($,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 FP($){return ZL($)}function QK($){try{let J=q2(VP($));if(J===null)return{config:null,errors:[]};if(!J.trim())return{config:null,errors:["Config file is empty"]};let Q=JSON.parse(J),X=FP(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 VP($){return typeof $==="string"?A6($):$}var jP=new Set(["standard","strict","paranoid"]),RP={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:j6}};function XK($){return IP(zP(U2($)),C6)}function _L($={}){let J=EP(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(!j0($))return AP();let J=j0($.safety)?$.safety:{},Q=j0(J.overrides)?J.overrides:{},X=j0($.workflow)?$.workflow:{},Y=j0($.destructive_command_protection)?$.destructive_command_protection:{},W=j0($.secret_protection)?$.secret_protection:{};return{version:1,safety:{level:jP.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,i6),allow_paths:PP(Y.allow_paths)},secret_protection:{enabled:typeof W.enabled==="boolean"?W.enabled:!0,overrides:FL(W.overrides,WJ),deny_paths:bP(W.deny_paths)},audit:{retention_days:R6(j0($.audit)?$.audit.retention_days:void 0)}}}function FL($,J){if(!j0($))return{};return Object.fromEntries(Object.entries($).flatMap(([Q,X])=>J.has(Q)&&(X==="on"||X==="off")?[[Q,X]]:[]))}function bP($){if(!Array.isArray($))return[];let J=c2();return $.filter((Q)=>T9(Q,J)===null)}function PP($){if(!Array.isArray($))return[];let J=c2();return $.filter((Q)=>C9(Q,J)===null)}function j0($){return!!$&&typeof $==="object"&&!Array.isArray($)}function AP(){return structuredClone(RP)}function EP($){let J=SP();if(!_P($)){let Q=globalThis.__CC_SAFETY_NET_EMBEDDED_POLICY__;if(!j0(Q))return{policy:J,errors:[]};return{policy:VL(NL(Q)),errors:[]}}try{let Q=DP($,"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:j0(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 SP(){return{safety:{},worktreeMode:!1,destructiveCommandProtectionEnabled:!0,destructiveCommandRuleOverrides:{},destructiveCommandAllowPaths:[],secretProtection:{enabled:!0,disabledRules:DL({}),denyPaths:[]}}}function VL($){return{safety:CP($.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 CP($){return{level:$.level,overrides:{failClosed:$.overrides.fail_closed,paranoidRm:$.overrides.paranoid_rm,paranoidInterpreters:$.overrides.paranoid_interpreters}}}var RL="This path contains the protected policy config and you must not modify or delete it.",TP=new Set(["[","cat","file","grep","head","jq","less","ls","more","rg","sed","stat","tail","test","wc"]);function bL($){let J=H2(E0()),Q=gP($.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?IL(X.shell,$.invocation.context.executionCwd,Q,J):null;if($.invocation.route.kind==="unknown"&&X){let Y=IL(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"||b9($.invocation.toolName),$.invocation.context.executionCwd,Q,J)}function zL($,J,Q,X,Y){if(J)return null;let W=$.find((K)=>F6(K,Q,X,Y));return W?{target:W}:null}function IL($,J,Q,X){let Y=A9($,J,X,{findSegmentTarget:(W,K)=>wP(W,K,Q,X)?.target??null,isRedirectionTarget:(W,K)=>F6(W,K.cwd,Q,X),findMalformedTarget:(W)=>kP(W,J,Q,X)?.target??null,normalizeCwd:M1});return Y?{target:Y}:null}function wP($,J,Q,X){if(O3($))return null;let Y=X.environment,W=l1([...$],Y),K=l(W[0]??"").toLowerCase(),B=W.slice(1);if(K==="rm"&&vP(B)){let q=fP(B).find((U)=>jL(f1(U,J.variables),J.cwd,Q,X));if(q)return{target:q}}if(K==="find"){if(x9(W,1)||AQ(W,Y)){let U=(y9(p(W))??p(["."])).find((G)=>{let H=f1(G.text,J.variables);return F6(H,J.cwd,Q,X)||jL(H,J.cwd,Q,X)})?.text;if(U)return{target:U}}}if(K==="mv"){let q=E9(B).sources.find((U)=>yP(f1(U,J.variables),J.cwd,Q,X));if(q)return{target:q}}if(hP($,Y))return null;for(let q of $)for(let U of PL(q))if(F6(f1(U,J.variables),J.cwd,Q,X))return{target:U};return null}function vP($){return $.some((J)=>J==="--recursive"||J.startsWith("-")&&!J.startsWith("--")&&/[rR]/.test(J.slice(1)))}function fP($){let J=$.indexOf("--");if(J!==-1)return[...$.slice(0,J).filter((Q)=>!Q.startsWith("-")),...$.slice(J+1)];return $.filter((Q)=>!Q.startsWith("-"))}function hP($,J){let Q=l1([...$],J);if(Q.length===0)return!1;let X=l(Q[0]??"").toLowerCase();if(!TP.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 kP($,J,Q,X){for(let Y of $.split(/\s+/))for(let W of PL(Y))if(F6(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 gP($,J){let Q=M1(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 F6($,J,Q,X){return d4(M1($,J,X))===Q.file}function jL($,J,Q,X){return Q.directoryAndAncestors.has(d4(M1($,J,X)))}function yP($,J,Q,X){let Y=d4(M1($,J,X));return Y===Q.file||Q.directoryAndAncestors.has(Y)}function d4($){return process.platform==="win32"?$.toLowerCase():$}import{homedir as xP}from"os";import{isAbsolute as KK,resolve as hL}from"path";import{fileURLToPath as uP}from"url";var kL="Access to a sensitive path is not allowed.",gL=new Set(["echo","printf"]),mP=new Set(["find"]),lP=new Set(["-exec","-execdir"]),pP=new Set([";","+"]),cP=new Set(["-delete","-exec","-execdir","-fls","-fprint","-fprint0","-fprintf","-ok","-okdir"]),dP=new Set(["-name","-iname","-path","-ipath","-wholename","-iwholename","-samefile"]),rP=new Set(["python","python2","python3","node","deno","bun","ruby","perl","php","rscript","osascript","bash","sh","zsh","dash","ksh"]),iP=new Set(["node","bun"]),oP=new Set(["bun","child_process","deno","dotenv","fs","subprocess"]),nP=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"]),sP=new Set(["src/cli/cc-safety-net.ts","dist/bin/cc-safety-net.js"]),aP=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"])]]),tP=new Set(["grep","rg"]),AL="f",EL="file",eP="files",$A=new Set(["e","f"]),JA=new Set(["regexp","file"]),QA=new Set(["e","f","A","B","C","m"]),XA=new Set(["regexp","file","after-context","before-context","context","max-count"]),YA=new Set(["|","|&"]),WK="__CC_SAFETY_NET_PIPE_INPUT__",xL=new Set(["bash","sh","zsh","dash","ksh"]),WA=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 SL($,J,Q,X,Y){let W=s4();for(let K of $){if(pA(K,J,Q?.denyPaths??[],X,W))return{target:K,ruleId:"secret.deny-path"};if(Y&&!Y.has(K))continue;let B=mA(K,J,Q,W);if(B)return{target:K,ruleId:B}}return null}function uL($,J,Q={}){let X=CL($),Y=SL(X,$.invocation.context.executionCwd,J,$.invocation.context.configCwd),W=Y?.ruleId!=="secret.deny-path"&&Q.strict===!1?CL($,{refineJavaScriptInlineData:!0}):X,K=W.length===X.length?Y:SL(X,$.invocation.context.executionCwd,J,$.invocation.context.configCwd,new Set(W));if(K?.ruleId!=="secret.deny-path"&&Q.strict===!1&&KA($))return null;return K}function KA($){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)=>cP.has(K))}function CL($,J={}){if($.invocation.route.kind==="command"){let X=w1($,"input-candidate");return X?D6(X.shell,$.store,J):[]}if($.invocation.route.kind!=="unknown")return $.paths.map((X)=>X.raw);let Q=w1($,"input-candidate");return[...Q?D6(Q.shell,$.store,J):[],...$.paths.map((X)=>X.raw)]}function D6($,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,...PA(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=YA.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=NA($),Y=i4($);if(Y.length===0)return X;let W=Y[0]??"",K=y2(W).toLowerCase(),B=Y.slice(1),q=BA(W,K,B);if(q)return[...X,...q];if(gL.has(K))return X;if(tP.has(K))return[...X,...fA(B)];if(mP.has(K))return[...X,...FA(B,J,Q)];if(h1.has(K))return[...X,...B.flatMap((U)=>wL("awk",U)),...B.flatMap((U)=>_A(U,J,Q)),...B.flatMap(DA)];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,...VA(K,B,Q)]}return[...X,...B.flatMap((U)=>wL(K,U))]}function BA($,J,Q){let X=J==="cc-safety-net"&&Q[0]==="explain",Y=(J==="bun"||J==="node")&&qA(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 qA($){let J=$?.replaceAll("\\","/");return[...sP].some((Q)=>J===Q||J?.endsWith(`/${Q}`))}function TL($,J,Q,X){if(LA(J,Q,X))return UA($);let Y=OA(J);if(Y===null)return[];return GA($).flatMap((W)=>xL.has(Y)?D6(Q.getShellSyntax(W),Q,X):dL(W))}function UA($){let J=i4($);if(J.length===0)return[];let Q=y2(J[0]??"").toLowerCase();if(!gL.has(Q))return[];return J.slice(1)}function GA($){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 HA(X);return[]}function HA($){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)=>ZA(J,X.slice(W*Q,(W+1)*Q)))}function ZA($,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,`
101
101
  `).replace(/\\t/g,"\t").replace(/\\r/g,"\r")}function LA($,J,Q){let X=i4($);if(X.length===0||y2(X[0]??"").toLowerCase()!=="xargs")return!1;let Y=R2(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 OA($){let J=i4($);if(J.length===0)return null;let Q=y2(J[0]??"").toLowerCase();if(!pL(Q))return null;return MA(Q,J.slice(1))?Q:null}function MA($,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(WA.get(Q)?.has(Y))X++;continue}return!1}return!0}function lL($){return/^python\d/.test($)?"python":$}function NA($){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 FA($,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(!lP.has($[W]??""))continue;let K=$.slice(W+1),B=K.findIndex((G)=>pP.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(!dP.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 rP.has($)||/^python\d/.test($)}function VA($,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 aP.get(J[J.length-1]??"")?.has(lL($))??!1}function _A($,J,Q){if(!$.includes("system"))return[];return jQ($)?.commands.flatMap((X)=>D6(J.getShellSyntax(X),J,Q))??[]}function DA($){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||!iP.has($)||X.length===0)return X;let Y=zA(J);return Y!==null&&!jA(Y)?[]:X}function zA($){let J=$.split("");for(let Q=0;Q<$.length;Q++){let X=$[Q];if(X!=="'"&&X!=='"'&&X!=="`")continue;if(X==="`"&&IA($,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===`
102
102
  `||K==="\r"))return null;if(K!==X)continue;Q=W,Y=!0;break}if(!Y)return null}return J.join("")}function IA($,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 jA($){for(let J of $.matchAll(/[A-Za-z_$][A-Za-z0-9_$]*/g)){let Q=J[0],X=J.index;if(oP.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)=>nP.has(W)))continue;if(Y.length>1)return!0;if(RA($,X)===".")return!0;if(bA($,X+Q.length)==="(")return!0}return!1}function RA($,J){for(let Q=J-1;Q>=0;Q--)if(!/\s/.test($[Q]??""))return $[Q];return}function bA($,J){for(let Q=J;Q<$.length;Q++)if(!/\s/.test($[Q]??""))return $[Q];return}function PA($,J,Q){return TA($).flatMap((X)=>{let Y=J.getShellSyntax(X);if(Y.status==="invalid")return[];return[...D6(Y,J,Q),...AA(Y)?EA(Y):[]]})}function AA($){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 EA($){return $.entries.flatMap((J)=>J.kind==="word"?[G0(J.text)]:J.kind==="redirection"&&J.target?[G0(J.target)]:[]).flatMap(rL)}function rL($){let J=CA($);if(J===null)return[];let Q=Buffer.from(J,"base64").toString("utf8");if(Q===""||SA(Q))return[];return Buffer.from(Q,"utf8").toString("base64").replace(/=+$/g,"")===J.replace(/=+$/g,"")?[Q]:[]}function SA($){return Array.from($).some((J)=>{let Q=J.charCodeAt(0);return Q<32||Q===127})}function CA($){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 TA($){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=wA($,X+1);if(W!==null)J.push(W.body),X=W.endIndex;continue}if(!Q.inSingle&&Y==="`"){let W=vA($,X);if(W!==null)J.push(W.body),X=W.endIndex}}return J}function wA($,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 vA($,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 fA($){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===eP)Y=!0;if(JA.has(H))X=!0;if(L!==void 0){if(H===EL)J.push(L);continue}if(XA.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 O=0;O<H.length;O++){let M=H[O]??"";if($A.has(M))X=!0;if(QA.has(M)){L=M,Z=H.slice(O+1);break}}if(L!=="")if(Z.length>0){if(L===AL)J.push(Z)}else{let O=$[q+1];if(L===AL&&O!==void 0)J.push(O);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 hA=new Set(["id_rsa.pub","id_ed25519.pub","id_ecdsa.pub"]),kA=".env.",gA=new Set([".env.example",".env.sample",".env.template",".env.defaults"]),yA=[".env.example.",".env.sample."],xA=new Set(["node_modules","__pycache__"]),uA=[["vendor","bundle"],["vendor","cache"]];function mA($,J,Q,X){let Y=u0($,J,X);if(!Y)return null;let W=G1(Y.split("/").pop()??""),K=G1(Y);if(gA.has(W)||yA.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=lA(Y,J,Q,X);if(B)return B;if(hA.has(W))return null;for(let U of nW)if(W===U.basename&&x0(U.id,Q))return U.id;if(W.startsWith(kA)&&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(cA(K))return null;if(!W.includes(".")&&M6.pattern.test(W)&&x0(M6.id,Q))return M6.id;let q=dA(W,Q);if(q)return q;return null}function lA($,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"])||_6($,"~/.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"])||V6($,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()?_6($,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"])||V6($,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"])||V6($,W,["credentials"])||V6($,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)=>_6($,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()?_6($,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"]))||V6($,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()?_6($,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 V6($,J,Q){return Q.some((X)=>qJ(G1($),G1(F1(J,X))))}function _6($,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 pA($,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 cA($){let J=$.split("/");return J.some((Q)=>xA.has(Q))||uA.some(([Q,X])=>J.some((Y,W)=>Y===Q&&J[W+1]===X))}function dA($,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??xP(),X=Q?r4(J1(Q,i0,J)):"",Y=r4(rA(G0($)));return{home:X,normalized:Y}}function rA($){if(!$.trim().toLowerCase().startsWith("file:"))return $;try{return uP($)}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"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 $O($){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 iA($){if(!oA($))return{errors:["Rulebook must be an object"],ruleNames:new Set};if(!$O($))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=iA($);if(J.errors.length>0)throw Error(J.errors.join("; "));return $}function oA($){return!!$&&typeof $==="object"&&!Array.isArray($)}function UK($){if(S6($.spec))return aA($);return sA($)}function sA($){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 aA($){let J=o4($.spec);if(J)return J;let Q=E6($.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 JO($){let J=typeof $==="string"?$:$.path;try{let Q=q2(typeof $==="string"?A6($):$);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 tA}from"crypto";var Tg=Object.freeze({timeoutMs:15000,metadataBytes:524288,commitBytes:262144,treeBytes:16777216,rawBytes:4194304});function QO($){return`sha256:${tA("sha256").update($).digest("hex")}`}function BO($={}){let J=AK($),Q=!1;try{Q=_K(J.userConfigTarget,J.projectConfigTarget)}catch(L){if(L instanceof W1)return QE(J,L.message);throw L}let X=QK(J.userConfigTarget),Y=Q?{config:null,errors:[]}:QK(J.projectConfigTarget),W=KO(J.userConfigPath,X.errors),K=KO(J.projectConfigPath,Y.errors),B=new Set,q=X.config?XO(X.config,J.userLockPath,UJ(J.userConfigPath),$,"user",J.userScope,B):z6(),U=Y.config?XO(Y.config,J.projectLockPath,UJ(J.projectConfigPath),$,"project",J.projectScope,B):z6(),G=X.config?.overrides??{},H=Y.config?.overrides??{};return{rules:[...YO(q.rules,G),...YO(U.rules,H)],transparent_wrappers:$E(X.config,Y.config),rulebooks:[...q.rulebooks,...U.rulebooks],errors:[...W,...K,...q.errors,...U.errors],warnings:[...q.warnings,...U.warnings,...q.canValidateOverrides?WO(G,q.knownRuleIds,J.userConfigPath):[],...q.canValidateOverrides?JE(H,q.knownRuleIds,J.projectConfigPath):[],...U.canValidateOverrides?WO(H,U.knownRuleIds,J.projectConfigPath):[]],userConfig:X.config??void 0,projectConfig:Y.config??void 0,...J}}function XO($,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{...z6(),errors:[V.message],canValidateOverrides:!1};throw V}let q=JO(B);if(q.errors.length>0)return{...z6(),errors:q.errors,canValidateOverrides:!1};let U=q.lock;if(!U&&$.rules.length>0)return{...z6(),errors:[`missing lockfile ${J}; run ${c0}`],canValidateOverrides:!1};let G=U?.rulebooks??[],H=new Map(G.map((V)=>[V.spec,V])),L=[],Z=[],O=$.rules.flatMap((V)=>{let F=H.get(V);if(!F)return L.push(`missing lock entry for ${V}; run ${c0}`),[];let b=eA(F,Q,X,W);if(b.errors.length>0||!b.rulebook)return L.push(...b.errors),[];let I=b.rulebook;if(K.has(I.name))return Z.push(`duplicate active rulebook name "${I.name}" for ${V}; keeping the first and ignoring this one, so its rules are not active; rename one of them, then run ${c0}`),[];return K.add(I.name),[{rules:I.rules.map((A)=>({...A,name:`${I.name}/${A.name}`})),rulebook:{source:Y,spec:F.spec,name:I.name,version:I.version,rules:I.rules.map((A)=>`${I.name}/${A.name}`)}}]}),M=O.flatMap((V)=>V.rules);return{rules:M,rulebooks:O.map((V)=>V.rulebook),entries:G,knownRuleIds:new Set(M.map((V)=>V.name)),errors:L,warnings:Z,canValidateOverrides:L.length===0}}function eA($,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(QO(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 $E($,J){return[...new Set([...$?.transparent_wrappers??[],...J?.transparent_wrappers??[]])]}function YO($,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 WO($,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 JE($,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 KO($,J){return J.map((Q)=>Q.startsWith("Unable to access ")?Q:`${$}: ${Q}`)}function QE($,J){return{rules:[],transparent_wrappers:[],rulebooks:[],errors:[J],warnings:[],userConfigPath:$.userConfigPath,projectConfigPath:$.projectConfigPath,userLockPath:$.userLockPath,projectLockPath:$.projectLockPath}}function z6(){return{rules:[],rulebooks:[],entries:[],knownRuleIds:new Set,errors:[],warnings:[],canValidateOverrides:!0}}function qO($={}){let J=BO($),Q=_L($),X={rules:J.rules,transparentWrappers:J.transparent_wrappers,safety:qE(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}),...KE(B.spec)?{source:B.spec}:{}}:{},...q&&typeof q==="object"?{override:Object.freeze({type:"reason",reason:q.reason})}:{}})]})));return BE(X,XE(J,Q),W)}function XE($,J){let Q=WE(J);if($.errors.length===0&&$.warnings.length===0&&!Q)return;return{diagnostics:[...$.errors,...$.warnings,...J.errors],reason:UE($.errors.length>0?YE($.errors):void 0,$.warnings.length>0?GK($.warnings.join("; ")):void 0,Q)}}function YE($){return`${GK($.join("; "))} Those rule sources are not active; every other rule and all built-in protections still apply`}function WE($){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 KE($){return/^(?:[A-Za-z0-9_.-]+$|https:\/\/github\.com\/|github:|gh:|[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+(?:#|$))/.test($)}function BE($,J,Q=Object.freeze({})){let X=UO(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 qE($){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 UO($){if(typeof $!=="object"||$===null)return $;for(let J of Object.values($))UO(J);return Object.freeze($)}function UE(...$){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 GE={findPolicyMutation:bL,findGitMetadataMutation:cq,resolveGitMetadata:LQ,loadPolicySnapshot:qO,findSensitiveTarget:uL,analyzeCommand:XH,getModes:U7};function GO($,J={}){let Q={...GE,...J.dependencies},X=LE($),Y=I6($)?$.command:X,W=x2("policy-protection",Y,()=>P9($,J.factParserDependencies)),K=w1(W,"declared-command");if(I6($)&&$.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:pK,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:RL,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,...HE(G)},O=H.secretProtection.enabled===!1?null:x2("secret-protection",Y,()=>Q.findSensitiveTarget(W,H.secretProtection,{strict:I6($)?L.strict:void 0}));if(O){let V=Y??O.target;return{stage:"secret-protection",...Z,decision:{kind:"deny",reason:kL,intent:"hard_stop",ruleId:O.ruleId,evidence:[{kind:"command",command:V,segment:O.target},{kind:"path",target:O.target}]}}}if(!I6($))return{stage:"non-command",...Z,decision:{kind:"allow"}};if(!$.command||$.command.trim()==="")return{...HK("command-validation",Y),...Z};let M=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},ZE(W),W.store)});if(M)return{stage:"command-analysis",...Z,decision:M};return{stage:"command-analysis",...Z,decision:{kind:"allow"}}}function HE($){if($.state==="ready")return{};return{configFallback:{reason:$.reason}}}function ZE($){return w1($,"declared-command")?.program}function LE($){try{return J4($.input)}catch(J){let Q=I6($)?$.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:v6,intent:"stop_and_explain",evidence:J?[{kind:"command",command:J,segment:J}]:[]}}}function I6($){return $.route.kind==="command"}function ZO($,J){try{let Q=GO($,J.guard);return HO($,Q,J),Q}catch(Q){if(!(Q instanceof K2))throw Q;throw HO($,Q.evaluation,J,!(Q.cause instanceof w0),{stage:Q.stage,errorCode:OE(Q.cause)}),Q}}function HO($,J,Q,X=!0,Y){yK(gK($,J,Q.guard?.auditAllowed??!1,X,Y),Q.audit.getSessionId,{agent:Q.audit.agent,shape:Q.audit.shape,homeDir:Q.audit.homeDir})}function OE($){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 OO=NE();function NE($={}){return(J,Q)=>FE(J,Q,$)}function FE($,J,Q){let X=VE($,J),Y=()=>zE($);if("malformed"in X)return xK(X.denial,Y,{agent:"amp",toolName:X.denial.toolName,cwd:X.cwd}),MO(X.denial);try{let W=ZO(X,{guard:{auditAllowed:B7(),policyOptions:Q.policyOptions,dependencies:Q.guardDependencies},audit:{agent:"amp",getSessionId:Y}});return LO(W,W.stage!=="config-state")}catch(W){if(!(W instanceof K2))throw W;if(k0(B1.debug))console.error(`CC Safety Net debug: amp tool.call analysis failed: ${nK(W.cause)}`);return LO(W.evaluation,X.route.kind==="command")}}function VE($,J){if(!$||typeof $!=="object")return u2(null);let Q=$;if(typeof Q.tool!=="string"||Q.tool.trim()==="")return u2(null);if(!Q.input||typeof Q.input!=="object")return u2(null,Q.tool);let X=_E(J);if(!X)return u2(null,Q.tool);let Y=DE(J,$);if(!Y.ok)return u2(X,Q.tool);if(!Y.command)return w3(Q.tool,Q.input,{kind:qQ(Q.tool)},{configCwd:X,executionCwd:X},null);if(typeof Y.command.command!=="string"||Y.command.command.trim()==="")return u2(X,Q.tool);let W=typeof Y.command.dir==="string"?w6(Y.command.dir,[X]):X;if(!W)return u2(X,Q.tool,Y.command.command,Y.command.dir);return w3(Q.tool,Q.input,{kind:"command",shell:"posix"},{configCwd:X,executionCwd:W},Y.command.command)}function _E($){let J=$.system.workspaceRoot;if(!J)return;try{let Q=$.helpers.filePathFromURI(J);if(typeof Q!=="string"||Q.trim()==="")return;return w6(".",[Q])}catch{return}}function DE($,J){try{return{ok:!0,command:$.helpers.shellCommandFromToolCall(J)}}catch{return{ok:!1}}}function zE($){if(!$||typeof $!=="object")return;let J=$.thread?.id;return typeof J==="string"&&J.trim()!==""?J:void 0}function u2($,J,Q,X){return{malformed:!0,denial:iK({command:Q,segment:X,toolName:J}),cwd:$}}function LO($,J){let Q=rK($,{includeEvidence:J});return Q?MO(Q):{action:"allow"}}function MO($){return{action:"reject-and-continue",message:oK($)}}function IE($){$.on("tool.call",(J)=>OO(J,$))}export{IE as default};