dal-code 1.0.29 → 1.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
  3. package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
  4. package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
  5. package/dist/node_modules/@dalcode/dal-guard/src/index.js +1 -1
  6. package/dist/node_modules/@dalcode/dal-guard/src/mode.js +2 -2
  7. package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
  8. package/dist/node_modules/@dalcode/dal-interactive/package.json +2 -2
  9. package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
  10. package/dist/node_modules/@dalcode/dal-lsp/package.json +3 -3
  11. package/dist/node_modules/@dalcode/dal-mcp/package.json +5 -5
  12. package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
  13. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +2 -2
  14. package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
  15. package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +2 -2
  16. package/dist/node_modules/@dalcode/dal-plugins/package.json +2 -2
  17. package/dist/node_modules/@dalcode/dal-review/package.json +3 -3
  18. package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
  19. package/dist/node_modules/@dalcode/dal-router/package.json +4 -4
  20. package/dist/node_modules/@dalcode/dal-skills/package.json +4 -3
  21. package/dist/node_modules/@dalcode/dal-skills/src/catalog.js +2 -0
  22. package/dist/node_modules/@dalcode/dal-skills/src/index.js +12 -11
  23. package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
  24. package/dist/node_modules/@dalcode/dal-telemetry/package.json +2 -2
  25. package/dist/node_modules/@dalcode/dal-terminal/package.json +2 -2
  26. package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
  27. package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
  28. package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
  29. package/dist/node_modules/@dalcode/dal-workflow/src/todo.js +2 -2
  30. package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
  31. package/dist/node_modules/@earendil-works/chord/package.json +1 -1
  32. package/dist/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  33. package/dist/node_modules/@earendil-works/pi-ai/dist/cli.js +0 -0
  34. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  35. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
  36. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
  37. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google-vertex.json +1 -1
  38. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
  39. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/meta.json +1 -1
  40. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
  41. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
  42. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  43. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
  44. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  45. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.js +1 -1
  46. package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
  47. package/dist/node_modules/@earendil-works/pi-client/package.json +3 -3
  48. package/dist/node_modules/@earendil-works/pi-codemode/package.json +1 -1
  49. package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +1 -1
  50. package/dist/node_modules/@earendil-works/pi-mcp/package.json +1 -1
  51. package/dist/node_modules/@earendil-works/pi-protocol/package.json +2 -2
  52. package/dist/node_modules/@earendil-works/pi-server/package.json +3 -3
  53. package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  54. package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
  55. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  56. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  57. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  58. package/examples/extensions/gondolin/package-lock.json +2 -2
  59. package/examples/extensions/gondolin/package.json +1 -1
  60. package/examples/extensions/sandbox/package-lock.json +2 -2
  61. package/examples/extensions/sandbox/package.json +1 -1
  62. package/examples/extensions/with-deps/package-lock.json +2 -2
  63. package/examples/extensions/with-deps/package.json +1 -1
  64. package/npm-shrinkwrap.json +2 -2
  65. package/package.json +1 -1
  66. package/dist/bundle/chunks/anthropic-messages-AZKHNVAG.js +0 -5
  67. package/dist/bundle/chunks/anthropic.js +0 -74
  68. package/dist/bundle/chunks/azure-openai-responses-LA3FYF3J.js +0 -1
  69. package/dist/bundle/chunks/bedrock-converse-stream.js +0 -82
  70. package/dist/bundle/chunks/chunk-4HEMJ3PG.js +0 -1140
  71. package/dist/bundle/chunks/chunk-4L3WN2XY.js +0 -1
  72. package/dist/bundle/chunks/chunk-4UTLMBZZ.js +0 -13
  73. package/dist/bundle/chunks/chunk-4XT6IQQ6.js +0 -1
  74. package/dist/bundle/chunks/chunk-5M7W2EDY.js +0 -3
  75. package/dist/bundle/chunks/chunk-5ULSWE2O.js +0 -43
  76. package/dist/bundle/chunks/chunk-6CYCI3EJ.js +0 -11
  77. package/dist/bundle/chunks/chunk-7ZC4UXSL.js +0 -1
  78. package/dist/bundle/chunks/chunk-ABVPQ2YN.js +0 -14
  79. package/dist/bundle/chunks/chunk-DRQDKNXA.js +0 -1
  80. package/dist/bundle/chunks/chunk-F5ZABL6Z.js +0 -19
  81. package/dist/bundle/chunks/chunk-GYI2XXNW.js +0 -10
  82. package/dist/bundle/chunks/chunk-H3QXYIF7.js +0 -30
  83. package/dist/bundle/chunks/chunk-HC56T2OZ.js +0 -134
  84. package/dist/bundle/chunks/chunk-HMFU7ZIF.js +0 -1
  85. package/dist/bundle/chunks/chunk-JEMNLK2O.js +0 -10
  86. package/dist/bundle/chunks/chunk-L2ZPNLYD.js +0 -1
  87. package/dist/bundle/chunks/chunk-LPXNMA2W.js +0 -1
  88. package/dist/bundle/chunks/chunk-PGXDEOVV.js +0 -1
  89. package/dist/bundle/chunks/chunk-PJACZCIR.js +0 -1
  90. package/dist/bundle/chunks/chunk-PMRZO46Y.js +0 -1
  91. package/dist/bundle/chunks/chunk-PRRNXB7S.js +0 -1
  92. package/dist/bundle/chunks/chunk-PRXLTI3Y.js +0 -81
  93. package/dist/bundle/chunks/chunk-Q6IMZXWD.js +0 -129
  94. package/dist/bundle/chunks/chunk-R4YWRKK4.js +0 -7
  95. package/dist/bundle/chunks/chunk-RDZVAGPR.js +0 -1
  96. package/dist/bundle/chunks/chunk-S3GGRYIO.js +0 -5
  97. package/dist/bundle/chunks/chunk-TEPMHNKQ.js +0 -1
  98. package/dist/bundle/chunks/chunk-TRDNDS6A.js +0 -3
  99. package/dist/bundle/chunks/chunk-USJZMAIR.js +0 -1
  100. package/dist/bundle/chunks/chunk-UTB4DTYQ.js +0 -1
  101. package/dist/bundle/chunks/chunk-WXULTH2D.js +0 -1
  102. package/dist/bundle/chunks/chunk-YKF7PQCJ.js +0 -1
  103. package/dist/bundle/chunks/chunk-YTERFI73.js +0 -1
  104. package/dist/bundle/chunks/chunk-ZBURYEWF.js +0 -1
  105. package/dist/bundle/chunks/chunk-ZKDITC7J.js +0 -35
  106. package/dist/bundle/chunks/cli-2LJMKSUZ.js +0 -50
  107. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-6WEJUIW2.js +0 -1
  108. package/dist/bundle/chunks/codemode-worker.js +0 -470
  109. package/dist/bundle/chunks/dist-37IE4EWG.js +0 -10
  110. package/dist/bundle/chunks/easter-egg-3d-GHWWTBZN.js +0 -1
  111. package/dist/bundle/chunks/execute-JU22LJZT.js +0 -489
  112. package/dist/bundle/chunks/github-copilot.js +0 -1
  113. package/dist/bundle/chunks/google-generative-ai-RFPHNE43.js +0 -1
  114. package/dist/bundle/chunks/google-vertex-QDNCMHLE.js +0 -1
  115. package/dist/bundle/chunks/http-proxy-6TR4MP55.js +0 -1
  116. package/dist/bundle/chunks/https-proxy-agent-2VXB7436.js +0 -12
  117. package/dist/bundle/chunks/image-resize-worker.js +0 -1
  118. package/dist/bundle/chunks/jiti-loader-C3NU2SDH.js +0 -20
  119. package/dist/bundle/chunks/jiti-static-loader-E6ANQD5T.js +0 -1
  120. package/dist/bundle/chunks/kimi-coding.js +0 -1
  121. package/dist/bundle/chunks/lib-TEDK3E5I.js +0 -8
  122. package/dist/bundle/chunks/llama-cpp-classify-FYN623RH.js +0 -21
  123. package/dist/bundle/chunks/meta.js +0 -1
  124. package/dist/bundle/chunks/mistral-conversations-YHX5TRKG.js +0 -4
  125. package/dist/bundle/chunks/multipart-parser-SQ6GDJL7.js +0 -2
  126. package/dist/bundle/chunks/node-N5BSDOA5.js +0 -15
  127. package/dist/bundle/chunks/node-TWVVAGPO.js +0 -1
  128. package/dist/bundle/chunks/openai-chatgpt.js +0 -74
  129. package/dist/bundle/chunks/openai-codex-responses-UZEMMAYZ.js +0 -9
  130. package/dist/bundle/chunks/openai-codex.js +0 -74
  131. package/dist/bundle/chunks/openai-completions-H6WMELZZ.js +0 -6
  132. package/dist/bundle/chunks/openai-decisions-URHWCZPN.js +0 -4
  133. package/dist/bundle/chunks/openai-responses-7X65PCAB.js +0 -2
  134. package/dist/bundle/chunks/openrouter-images-DUPG5DZO.js +0 -1
  135. package/dist/bundle/chunks/openrouter.js +0 -74
  136. package/dist/bundle/chunks/pi-messages-YHKPQIHC.js +0 -7
  137. package/dist/bundle/chunks/radius.js +0 -74
  138. package/dist/bundle/chunks/runtime-LLITCT4N.js +0 -1
  139. package/dist/bundle/chunks/src-UK77SYZE.js +0 -3
  140. package/dist/bundle/chunks/typesafe-system-one-N7PKHI2N.js +0 -1
  141. package/dist/bundle/chunks/virtual-modules-H32OTUCD.js +0 -1
  142. package/dist/bundle/chunks/xai.js +0 -1
  143. package/dist/bundle/cli-runtime.js +0 -2
  144. package/dist/bundle/cli.js +0 -2
  145. package/dist/bundle/index.js +0 -1
  146. package/dist/bundle/rpc-entry.js +0 -2
  147. package/dist/core/key-id-schema.js +0 -1
  148. package/dist/core/keybindings-schema.js +0 -1
  149. package/dist/core/settings-defaults.js +0 -1
  150. package/dist/core/settings-schema.js +0 -1
  151. package/dist/modes/interactive/components/daxnuts.js +0 -1
  152. package/dist/modes/interactive/theme/theme-schema.js +0 -12
  153. package/dist/modes/interactive/theme/theme-tokens.js +0 -1
  154. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/compat-schema.js +0 -1
  155. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/model-schema.js +0 -1
@@ -1,10 +0,0 @@
1
- var Bn=Object.defineProperty;var i=(t,e)=>Bn(t,"name",{value:e,configurable:!0});import{createRequire as Fn}from"node:module";const Cp=Fn(import.meta.url);import{createHttpProxyServer as zn,logForDebugging as f}from"./chunk-4UTLMBZZ.js";import{__commonJS as kt,__export as Vn,__require as Mr,__toESM as Jt}from"./chunk-4L3WN2XY.js";var Wn=kt({"node_modules/@pondwader/socks5-server/dist/index.js"(t,e){"use strict";var r=Object.create,a=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,c=i((p,x)=>{for(var E in x)a(p,E,{get:x[E],enumerable:!0})},"__export2"),u=i((p,x,E,U)=>{if(x&&typeof x=="object"||typeof x=="function")for(let G of o(x))!l.call(p,G)&&G!==E&&a(p,G,{get:i(()=>x[G],"get"),enumerable:!(U=n(x,G))||U.enumerable});return p},"__copyProps"),y=i((p,x,E)=>(E=p!=null?r(s(p)):{},u(x||!p||!p.__esModule?a(E,"default",{value:p,enumerable:!0}):E,p)),"__toESM2"),d=i(p=>u(a({},"__esModule",{value:!0}),p),"__toCommonJS"),O={};c(O,{Socks5Server:i(()=>H,"Socks5Server"),createServer:i(()=>q,"createServer"),defaultConnectionHandler:i(()=>K,"defaultConnectionHandler")}),e.exports=d(O);var $=y(Mr("net")),I=(p=>(p[p.connect=1]="connect",p[p.bind=2]="bind",p[p.udp=3]="udp",p))(I||{}),j=(p=>(p[p.REQUEST_GRANTED=0]="REQUEST_GRANTED",p[p.GENERAL_FAILURE=1]="GENERAL_FAILURE",p[p.CONNECTION_NOT_ALLOWED=2]="CONNECTION_NOT_ALLOWED",p[p.NETWORK_UNREACHABLE=3]="NETWORK_UNREACHABLE",p[p.HOST_UNREACHABLE=4]="HOST_UNREACHABLE",p[p.CONNECTION_REFUSED=5]="CONNECTION_REFUSED",p[p.TTL_EXPIRED=6]="TTL_EXPIRED",p[p.COMMAND_NOT_SUPPORTED=7]="COMMAND_NOT_SUPPORTED",p[p.ADDRESS_TYPE_NOT_SUPPORTED=8]="ADDRESS_TYPE_NOT_SUPPORTED",p))(j||{}),W=class{static{i(this,"Socks5Connection")}constructor(p,x){this.errorHandler=()=>{},this.metadata={},this.socket=x,this.server=p,x.on("error",this.errorHandler),x.pause(),this.handleGreeting()}readBytes(p){return new Promise(x=>{let E=Buffer.allocUnsafe(p),U=0,G=i(C=>{let k=Math.min(C.length,p-U);C.copy(E,U,0,k),U+=k,!(U<p)&&(this.socket.removeListener("data",G),this.socket.push(C.subarray(k)),x(E),this.socket.pause())},"dataListener");this.socket.on("data",G),this.socket.resume()})}async handleGreeting(){if((await this.readBytes(1)).readUInt8()!==5)return this.socket.destroy();let p=(await this.readBytes(1)).readUInt8();if(p>128||p===0)return this.socket.destroy();let x=await this.readBytes(p),E=this.server.authHandler?2:0;if(!x.includes(E))return this.socket.write(Buffer.from([5,255])),this.socket.destroy();this.socket.write(Buffer.from([5,E])),this.server.authHandler?this.handleUserPassword():this.handleConnectionRequest()}async handleUserPassword(){await this.readBytes(1);let p=(await this.readBytes(1)).readUint8(),x=(await this.readBytes(p)).toString(),E=(await this.readBytes(1)).readUint8(),U=(await this.readBytes(E)).toString();this.username=x,this.password=U;let G=!1,C=i(()=>{G||(G=!0,this.socket.write(Buffer.from([1,0])),this.handleConnectionRequest())},"acceptCallback"),k=i(()=>{G||(G=!0,this.socket.write(Buffer.from([1,1])),this.socket.destroy())},"denyCallback"),P=await this.server.authHandler(this,C,k);P===!0?C():P===!1&&k()}async handleConnectionRequest(){await this.readBytes(1);let p=(await this.readBytes(1))[0],x=I[p];if(!x)return this.socket.destroy();this.command=x,await this.readBytes(1);let E=(await this.readBytes(1)).readUInt8(),U="";switch(E){case 1:U=(await this.readBytes(4)).join(".");break;case 3:let D=(await this.readBytes(1)).readUInt8();U=(await this.readBytes(D)).toString();break;case 4:let te=await this.readBytes(16);for(let ae=0;ae<16;ae++)ae%2===0&&ae>0&&(U+=":"),U+=`${te[ae]<16?"0":""}${te[ae].toString(16)}`;break;default:this.socket.destroy();return}let G=(await this.readBytes(2)).readUInt16BE();if(!this.server.supportedCommands.has(x))return this.socket.write(Buffer.from([5,7])),this.socket.destroy();this.destAddress=U,this.destPort=G;let C=!1,k=i(()=>{C||(C=!0,this.connect())},"acceptCallback");if(!this.server.rulesetValidator)return k();let P=i(()=>{C||(C=!0,this.socket.write(Buffer.from([5,2,0,1,0,0,0,0,0,0])),this.socket.destroy())},"denyCallback"),R=await this.server.rulesetValidator(this,k,P);R===!0?k():R===!1&&P()}connect(){this.socket.removeListener("error",this.errorHandler),this.server.connectionHandler(this,p=>{if(j[p]===void 0)throw new Error(`"${p}" is not a valid status.`);this.socket.write(Buffer.from([5,j[p],0,1,0,0,0,0,0,0])),p!=="REQUEST_GRANTED"&&this.socket.destroy()}),this.socket.resume()}},L=y(Mr("net"));function K(p,x){if(p.command!=="connect")return x("COMMAND_NOT_SUPPORTED");p.socket.on("error",()=>{});let E=L.default.createConnection({host:p.destAddress,port:p.destPort});E.setNoDelay();let U=!1;return E.on("error",G=>{if(!U)switch(G.code){case"EINVAL":case"ENOENT":case"ENOTFOUND":case"ETIMEDOUT":case"EADDRNOTAVAIL":case"EHOSTUNREACH":x("HOST_UNREACHABLE");break;case"ENETUNREACH":x("NETWORK_UNREACHABLE");break;case"ECONNREFUSED":x("CONNECTION_REFUSED");break;default:x("GENERAL_FAILURE")}}),E.on("ready",()=>{U=!0,x("REQUEST_GRANTED"),p.socket.pipe(E).pipe(p.socket)}),p.socket.on("close",()=>E.destroy()),E}i(K,"connectionHandler_default");var H=class{static{i(this,"Socks5Server")}constructor(){this.supportedCommands=new Set(["connect"]),this.connectionHandler=K,this.server=$.default.createServer(p=>{p.setNoDelay(),this._handleConnection(p)})}listen(...p){return this.server.listen(...p),this}close(p){return this.server.close(p),this}setAuthHandler(p){return this.authHandler=p,this}disableAuthHandler(){return this.authHandler=void 0,this}setRulesetValidator(p){return this.rulesetValidator=p,this}disableRulesetValidator(){return this.rulesetValidator=void 0,this}setConnectionHandler(p){return this.connectionHandler=p,this}useDefaultConnectionHandler(){return this.connectionHandler=K,this}_handleConnection(p){return new W(this,p),this}};function q(p){let x=new H;return p?.auth&&x.setAuthHandler(E=>E.username===p.auth.username&&E.password===p.auth.password),p?.port&&x.listen(p.port,p.hostname),x}i(q,"createServer2")}}),Hn=kt({"node_modules/shell-quote/quote.js"(t,e){"use strict";var r=["||","&&",";;&",";;",";&","|&","<(",">(","<<<","<<-","<<",">>",">&",">|","&>>","&>","<&","<>","&",";","(",")","|","<",">"],a=/[\n\r\u2028\u2029]/,n=/[\s#!"$&'():;<=>@\\^`|~]/g;e.exports=function(o){var s=!1;return o.map(function(l){if(s&&typeof l=="string"&&a.test(l))throw new TypeError("a token after a `comment` must not contain line terminators");if(l==="")return"''";if(l&&typeof l=="object"){if("op"in l&&l.op==="glob"){if(typeof l.pattern!="string")throw new TypeError("glob token requires a string `pattern`");if(a.test(l.pattern))throw new TypeError("glob `pattern` must not contain line terminators");return l.pattern===""?"''":l.pattern.replace(n,"\\$&")}if("op"in l&&typeof l.op=="string"){if(r.indexOf(l.op)<0)throw new TypeError("invalid `op` value: "+JSON.stringify(l.op));return l.op.replace(/[\s\S]/g,"\\$&")}if("comment"in l&&typeof l.comment=="string"){if(a.test(l.comment))throw new TypeError("`comment` must not contain line terminators");return s=!0,"#"+l.comment}throw new TypeError("unrecognized object token shape")}return/'/.test(l)&&/!/.test(l)?"'"+l.replace(/'/g,`'"'"'`)+"'":/["\s\\]/.test(l)&&!/'/.test(l)?"'"+l+"'":/["'\s]/.test(l)?'"'+l.replace(/(["\\$`])/g,"\\$1")+'"':String(l).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}~])/g,"$1\\$2")}).join(" ")}}}),Gn=kt({"node_modules/shell-quote/parse.js"(t,e){"use strict";var r="(?:"+["\\|\\|","\\&(?:\\&|>>?)",";;\\&?","[;|]\\&","\\<\\(","\\<\\<\\<","\\<\\<-","\\<\\<(?!\\()",">>",">[&|(]","<[&>]","[&;()|<>]"].join("|")+")",a=new RegExp("^"+r+"$"),n="|&;()<> \\t",o="'([^']*?)'",s="(?:\\\\[\\s\\S]|[^\\\\'])*?",l="\\$'"+s+"'",c=new RegExp("\\$'"+s+"(?:(')|\\\\?$)","g"),u="abeEfnrtv",y=`\x07\b\x1B\x1B\f
2
- \r \v`,d=/^#$/,O="'",$='"',I="$",j="",W=4294967296;for(L=0;L<4;L++)j+=(W*Math.random()).toString(16);var L,K=new RegExp("^"+j);function H(C,k){for(var P=k.lastIndex,R=[],D;D=k.exec(C);)R[R.length]=D,k.lastIndex===D.index&&(k.lastIndex+=1);return k.lastIndex=P,R}i(H,"matchAll");function q(C,k,P){var R=typeof C=="function"?C(P):C[P];return typeof R>"u"&&P!=""?R="":typeof R>"u"&&(R="$"),typeof R=="object"?k+j+JSON.stringify(R)+j:k+R}i(q,"getVar");var p=/\\([0-7]{1,3}|x[\dA-Fa-f]{1,2}|u[\dA-Fa-f]{1,4}|U[\dA-Fa-f]{1,8}|c(?:\\\\|[\s\S])|[abeEfnrtv\\'"?])/g;function x(C,k){var P=k.charAt(0);if(P==="c"){var R=k.charAt(1);return R==="?"?"\x7F":String.fromCharCode(R.charCodeAt(0)&31)}if(P==="x"||P==="u"||P==="U"){var D=parseInt(k.slice(1),16);return D>1114111?C:String.fromCharCode.apply(null,D>65535?[55232+(D>>10),56320+(D&1023)]:[D])}if(P>="0"&&P<="7")return String.fromCharCode(parseInt(k,8)&255);var te=u.indexOf(k);return te<0?k:y.charAt(te)}i(x,"expandAnsiCEscape");function E(C){return C.replace(p,x).split("\0")[0]}i(E,"expandAnsiC");function U(C,k){return c.lastIndex=k,!!c.exec(C)[1]}i(U,"closesAnsiC");function G(C,k,P){P||(P={});var R=P.escape||"\\",D=P.splitUnquoted===!0?`
3
- `:typeof P.splitUnquoted=="string"?P.splitUnquoted:"",te="(\\"+R+`['"$\\`+R+n+"]|\\$\\$|\\$(?!"+l.slice(2)+`)|[^\\s'"$`+n+"])+",ae='"(?:\\'+R+'[\\s\\S]|[^"\\'+R+'])*"',Ye=new RegExp(["("+r+")","("+l+"|"+te+"|"+ae+"|"+o+")+"].join("|"),"g"),jr=H(C,Ye);if(jr.length===0)return[];k||(k={});var Ir=!1;return jr.map(function(Ie){var B=Ie[0];if(!B||Ir)return;if(a.test(B))return{op:B};var ve=!1,Vt=!1,V="",Q=[],Wt=!1,de=null,Ht=!1,F;function Dr(){F+=1;var Y,Xe,Yt=B.charAt(F);if(Yt==="{"){if(F+=1,B.charAt(F)==="}")throw new Error("Bad substitution: "+B.slice(F-2,F+1));var xt=1;for(Y=F;xt>0&&Y<B.length;)B.charAt(Y)==="{"&&B.charAt(Y-1)==="$"?xt+=1:B.charAt(Y)==="}"&&(xt-=1),Y+=1;if(xt!==0)throw new Error("Bad substitution: "+B.slice(F));Y-=1,Xe=B.slice(F,Y),F=Y}else if(/[*@#?$!-]/.test(Yt))Xe=Yt;else{var Xt=B.slice(F);Y=Xt.match(/[^\w\d_]/),Y?(Xe=Xt.slice(0,Y.index),F+=Y.index-1):(Xe=Xt,F=B.length)}return q(k,"",Xe)}i(Dr,"parseEnvVar");function Gt(){if(de!==null){if(de===0)V!==""&&(Q[Q.length]=V,V="");else{Q[Q.length]=V,V="";for(var Y=1;Y<de;Y+=1)Q[Q.length]=""}de=null}}for(i(Gt,"flushRun"),F=0;F<B.length;F++){var z=B.charAt(F);if(D&&z!==I&&Gt(),Ht=Ht||!ve&&(z==="*"||z==="?"),Vt)V+=z,Vt=!1;else if(ve)z===ve?ve=!1:ve==O?V+=z:z===R?(F+=1,z=B.charAt(F),z===$||z===R||z===I?V+=z:V+=R+z):z===I?V+=Dr():V+=z;else if(z===$||z===O)ve=z,Wt=!0;else{if(a.test(z))return{op:B};if(d.test(z)){Ir=!0;var Zr={comment:C.slice(Ie.index+F+1)};return V.length?[V,Zr]:[Zr]}else if(z===R)Vt=!0;else if(z===I&&B.charAt(F+1)===O&&U(B,F))Gt(),Wt=!0,V+=E(B.slice(F+2,c.lastIndex-1)),F=c.lastIndex-1;else if(z===I){var qt=Dr();if(!D)V+=qt;else for(var Kt=0;Kt<qt.length;Kt+=1){var be=qt.charAt(Kt);D.indexOf(be)<0?(Gt(),V+=be):de===null?de=be===" "||be===" "||be===`
4
- `?0:1:be!==" "&&be!==" "&&be!==`
5
- `&&(de+=1)}}else V+=z}}if(Ht)return{op:"glob",pattern:V};if(D){if(de!==null&&de>0){Q[Q.length]=V,V="";for(var Lr=1;Lr<de;Lr+=1)Q[Q.length]=""}return(V!==""||Wt&&Q.length===0)&&(Q[Q.length]=V),Q}return V}).reduce(function(Ie,B){return typeof B>"u"||[].concat(B).forEach(function(ve){Ie[Ie.length]=ve}),Ie},[])}i(G,"parseInternal"),e.exports=function(C,k,P){var R=G(C,k,P);return typeof k!="function"?R:R.reduce(function(D,te){if(typeof te=="object")return D[D.length]=te,D;var ae=te.split(RegExp("("+j+".*?"+j+")","g"));return ae.length===1?(D[D.length]=ae[0],D):(ae.filter(Boolean).forEach(function(Ye){D[D.length]=K.test(Ye)?JSON.parse(Ye.split(j)[1]):Ye}),D)},[])}}}),Ur=kt({"node_modules/shell-quote/index.js"(t){"use strict";t.quote=Hn(),t.parse=Gn()}}),qn=Jt(Wn(),1);function Kn(t){let e=(0,qn.createServer)();return e.setRulesetValidator(async r=>{try{let a=r.destAddress,n=r.destPort;return f(`Connection request to ${a}:${n}`),await t.filter(n,a)?(f(`Connection allowed to ${a}:${n}`),!0):(f(`Connection blocked to ${a}:${n}`,{level:"error"}),!1)}catch(a){return f(`Error validating connection: ${a}`,{level:"error"}),!1}}),{server:e,getPort(){try{let r=e?.server;if(r&&typeof r?.address=="function"){let a=r.address();if(a&&typeof a=="object"&&"port"in a)return a.port}}catch(r){f(`Error getting port: ${r}`,{level:"error"})}},listen(r,a){return new Promise((n,o)=>{let s=i(()=>{let l=this.getPort();l?(f(`SOCKS proxy listening on ${a}:${l}`),n(l)):o(new Error("Failed to get SOCKS proxy server port"))},"listeningCallback");e.listen(r,a,s)})},async close(){return new Promise((r,a)=>{e.close(n=>{if(n){let o=n.message?.toLowerCase()||"";if(!(o.includes("not running")||o.includes("already closed")||o.includes("not listening"))){a(n);return}}r()})})},unref(){try{let r=e?.server;r&&typeof r?.unref=="function"&&r.unref()}catch(r){f(`Error calling unref: ${r}`,{level:"error"})}}}}i(Kn,"createSocksProxyServer");var Yn=typeof global=="object"&&global&&global.Object===Object&&global,Br=Yn,Xn=typeof self=="object"&&self&&self.Object===Object&&self,Jn=Br||Xn||Function("return this")(),ue=Jn,Qn=ue.Symbol,De=Qn,Fr=Object.prototype,ei=Fr.hasOwnProperty,ti=Fr.toString,Je=De?De.toStringTag:void 0;function ri(t){var e=ei.call(t,Je),r=t[Je];try{t[Je]=void 0;var a=!0}catch{}var n=ti.call(t);return a&&(e?t[Je]=r:delete t[Je]),n}i(ri,"getRawTag");var ai=ri,ni=Object.prototype,ii=ni.toString;function si(t){return ii.call(t)}i(si,"objectToString");var oi=si,li="[object Null]",ci="[object Undefined]",zr=De?De.toStringTag:void 0;function di(t){return t==null?t===void 0?ci:li:zr&&zr in Object(t)?ai(t):oi(t)}i(di,"baseGetTag");var Qe=di;function ui(t){return t!=null&&typeof t=="object"}i(ui,"isObjectLike");var et=ui,pi=Array.isArray,Qt=pi;function hi(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}i(hi,"isObject");var tt=hi,fi="[object AsyncFunction]",mi="[object Function]",gi="[object GeneratorFunction]",yi="[object Proxy]";function _i(t){if(!tt(t))return!1;var e=Qe(t);return e==mi||e==gi||e==fi||e==yi}i(_i,"isFunction");var Vr=_i,vi=ue["__core-js_shared__"],er=vi,Wr=(function(){var t=/[^.]+$/.exec(er&&er.keys&&er.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function bi(t){return!!Wr&&Wr in t}i(bi,"isMasked");var wi=bi,xi=Function.prototype,ki=xi.toString;function Si(t){if(t!=null){try{return ki.call(t)}catch{}try{return t+""}catch{}}return""}i(Si,"toSource");var Ae=Si,Ti=/[\\^$.*+?()[\]{}|]/g,Oi=/^\[object .+?Constructor\]$/,Ai=Function.prototype,Ei=Object.prototype,Ci=Ai.toString,Pi=Ei.hasOwnProperty,Ri=RegExp("^"+Ci.call(Pi).replace(Ti,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ni(t){if(!tt(t)||wi(t))return!1;var e=Vr(t)?Ri:Oi;return e.test(Ae(t))}i(Ni,"baseIsNative");var $i=Ni;function ji(t,e){return t?.[e]}i(ji,"getValue");var Ii=ji;function Di(t,e){var r=Ii(t,e);return $i(r)?r:void 0}i(Di,"getNative");var Ee=Di,Zi=Ee(ue,"WeakMap"),tr=Zi,Hr=Object.create,Li=(function(){function t(){}return i(t,"object"),function(e){if(!tt(e))return{};if(Hr)return Hr(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}})(),Mi=Li;function Ui(t,e){var r=-1,a=t.length;for(e||(e=Array(a));++r<a;)e[r]=t[r];return e}i(Ui,"copyArray");var Bi=Ui,Fi=(function(){try{var t=Ee(Object,"defineProperty");return t({},"",{}),t}catch{}})(),Gr=Fi;function zi(t,e){for(var r=-1,a=t==null?0:t.length;++r<a&&e(t[r],r,t)!==!1;);return t}i(zi,"arrayEach");var Vi=zi,Wi=9007199254740991,Hi=/^(?:0|[1-9]\d*)$/;function Gi(t,e){var r=typeof t;return e=e??Wi,!!e&&(r=="number"||r!="symbol"&&Hi.test(t))&&t>-1&&t%1==0&&t<e}i(Gi,"isIndex");var qi=Gi;function Ki(t,e,r){e=="__proto__"&&Gr?Gr(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}i(Ki,"baseAssignValue");var qr=Ki;function Yi(t,e){return t===e||t!==t&&e!==e}i(Yi,"eq");var Kr=Yi,Xi=Object.prototype,Ji=Xi.hasOwnProperty;function Qi(t,e,r){var a=t[e];(!(Ji.call(t,e)&&Kr(a,r))||r===void 0&&!(e in t))&&qr(t,e,r)}i(Qi,"assignValue");var Yr=Qi;function es(t,e,r,a){var n=!r;r||(r={});for(var o=-1,s=e.length;++o<s;){var l=e[o],c=a?a(r[l],t[l],l,r,t):void 0;c===void 0&&(c=t[l]),n?qr(r,l,c):Yr(r,l,c)}return r}i(es,"copyObject");var St=es,ts=9007199254740991;function rs(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=ts}i(rs,"isLength");var Xr=rs;function as(t){return t!=null&&Xr(t.length)&&!Vr(t)}i(as,"isArrayLike");var Jr=as,ns=Object.prototype;function is(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||ns;return t===r}i(is,"isPrototype");var rr=is;function ss(t,e){for(var r=-1,a=Array(t);++r<t;)a[r]=e(r);return a}i(ss,"baseTimes");var os=ss,ls="[object Arguments]";function cs(t){return et(t)&&Qe(t)==ls}i(cs,"baseIsArguments");var Qr=cs,ea=Object.prototype,ds=ea.hasOwnProperty,us=ea.propertyIsEnumerable,ps=Qr((function(){return arguments})())?Qr:function(t){return et(t)&&ds.call(t,"callee")&&!us.call(t,"callee")},hs=ps;function fs(){return!1}i(fs,"stubFalse");var ms=fs,ta=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ra=ta&&typeof module=="object"&&module&&!module.nodeType&&module,gs=ra&&ra.exports===ta,aa=gs?ue.Buffer:void 0,ys=aa?aa.isBuffer:void 0,_s=ys||ms,na=_s,vs="[object Arguments]",bs="[object Array]",ws="[object Boolean]",xs="[object Date]",ks="[object Error]",Ss="[object Function]",Ts="[object Map]",Os="[object Number]",As="[object Object]",Es="[object RegExp]",Cs="[object Set]",Ps="[object String]",Rs="[object WeakMap]",Ns="[object ArrayBuffer]",$s="[object DataView]",js="[object Float32Array]",Is="[object Float64Array]",Ds="[object Int8Array]",Zs="[object Int16Array]",Ls="[object Int32Array]",Ms="[object Uint8Array]",Us="[object Uint8ClampedArray]",Bs="[object Uint16Array]",Fs="[object Uint32Array]",M={};M[js]=M[Is]=M[Ds]=M[Zs]=M[Ls]=M[Ms]=M[Us]=M[Bs]=M[Fs]=!0,M[vs]=M[bs]=M[Ns]=M[ws]=M[$s]=M[xs]=M[ks]=M[Ss]=M[Ts]=M[Os]=M[As]=M[Es]=M[Cs]=M[Ps]=M[Rs]=!1;function zs(t){return et(t)&&Xr(t.length)&&!!M[Qe(t)]}i(zs,"baseIsTypedArray");var Vs=zs;function Ws(t){return function(e){return t(e)}}i(Ws,"baseUnary");var ar=Ws,ia=typeof exports=="object"&&exports&&!exports.nodeType&&exports,rt=ia&&typeof module=="object"&&module&&!module.nodeType&&module,Hs=rt&&rt.exports===ia,nr=Hs&&Br.process,Gs=(function(){try{var t=rt&&rt.require&&rt.require("util").types;return t||nr&&nr.binding&&nr.binding("util")}catch{}})(),Ze=Gs,sa=Ze&&Ze.isTypedArray,qs=sa?ar(sa):Vs,Ks=qs,Ys=Object.prototype,Xs=Ys.hasOwnProperty;function Js(t,e){var r=Qt(t),a=!r&&hs(t),n=!r&&!a&&na(t),o=!r&&!a&&!n&&Ks(t),s=r||a||n||o,l=s?os(t.length,String):[],c=l.length;for(var u in t)(e||Xs.call(t,u))&&!(s&&(u=="length"||n&&(u=="offset"||u=="parent")||o&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||qi(u,c)))&&l.push(u);return l}i(Js,"arrayLikeKeys");var oa=Js;function Qs(t,e){return function(r){return t(e(r))}}i(Qs,"overArg");var la=Qs,eo=la(Object.keys,Object),to=eo,ro=Object.prototype,ao=ro.hasOwnProperty;function no(t){if(!rr(t))return to(t);var e=[];for(var r in Object(t))ao.call(t,r)&&r!="constructor"&&e.push(r);return e}i(no,"baseKeys");var io=no;function so(t){return Jr(t)?oa(t):io(t)}i(so,"keys");var ir=so;function oo(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}i(oo,"nativeKeysIn");var lo=oo,co=Object.prototype,uo=co.hasOwnProperty;function po(t){if(!tt(t))return lo(t);var e=rr(t),r=[];for(var a in t)a=="constructor"&&(e||!uo.call(t,a))||r.push(a);return r}i(po,"baseKeysIn");var ho=po;function fo(t){return Jr(t)?oa(t,!0):ho(t)}i(fo,"keysIn");var sr=fo,mo=Ee(Object,"create"),at=mo;function go(){this.__data__=at?at(null):{},this.size=0}i(go,"hashClear");var yo=go;function _o(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}i(_o,"hashDelete");var vo=_o,bo="__lodash_hash_undefined__",wo=Object.prototype,xo=wo.hasOwnProperty;function ko(t){var e=this.__data__;if(at){var r=e[t];return r===bo?void 0:r}return xo.call(e,t)?e[t]:void 0}i(ko,"hashGet");var So=ko,To=Object.prototype,Oo=To.hasOwnProperty;function Ao(t){var e=this.__data__;return at?e[t]!==void 0:Oo.call(e,t)}i(Ao,"hashHas");var Eo=Ao,Co="__lodash_hash_undefined__";function Po(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=at&&e===void 0?Co:e,this}i(Po,"hashSet");var Ro=Po;function Le(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var a=t[e];this.set(a[0],a[1])}}i(Le,"Hash"),Le.prototype.clear=yo,Le.prototype.delete=vo,Le.prototype.get=So,Le.prototype.has=Eo,Le.prototype.set=Ro;var ca=Le;function No(){this.__data__=[],this.size=0}i(No,"listCacheClear");var $o=No;function jo(t,e){for(var r=t.length;r--;)if(Kr(t[r][0],e))return r;return-1}i(jo,"assocIndexOf");var Tt=jo,Io=Array.prototype,Do=Io.splice;function Zo(t){var e=this.__data__,r=Tt(e,t);if(r<0)return!1;var a=e.length-1;return r==a?e.pop():Do.call(e,r,1),--this.size,!0}i(Zo,"listCacheDelete");var Lo=Zo;function Mo(t){var e=this.__data__,r=Tt(e,t);return r<0?void 0:e[r][1]}i(Mo,"listCacheGet");var Uo=Mo;function Bo(t){return Tt(this.__data__,t)>-1}i(Bo,"listCacheHas");var Fo=Bo;function zo(t,e){var r=this.__data__,a=Tt(r,t);return a<0?(++this.size,r.push([t,e])):r[a][1]=e,this}i(zo,"listCacheSet");var Vo=zo;function Me(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var a=t[e];this.set(a[0],a[1])}}i(Me,"ListCache"),Me.prototype.clear=$o,Me.prototype.delete=Lo,Me.prototype.get=Uo,Me.prototype.has=Fo,Me.prototype.set=Vo;var Ot=Me,Wo=Ee(ue,"Map"),nt=Wo;function Ho(){this.size=0,this.__data__={hash:new ca,map:new(nt||Ot),string:new ca}}i(Ho,"mapCacheClear");var Go=Ho;function qo(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}i(qo,"isKeyable");var Ko=qo;function Yo(t,e){var r=t.__data__;return Ko(e)?r[typeof e=="string"?"string":"hash"]:r.map}i(Yo,"getMapData");var At=Yo;function Xo(t){var e=At(this,t).delete(t);return this.size-=e?1:0,e}i(Xo,"mapCacheDelete");var Jo=Xo;function Qo(t){return At(this,t).get(t)}i(Qo,"mapCacheGet");var el=Qo;function tl(t){return At(this,t).has(t)}i(tl,"mapCacheHas");var rl=tl;function al(t,e){var r=At(this,t),a=r.size;return r.set(t,e),this.size+=r.size==a?0:1,this}i(al,"mapCacheSet");var nl=al;function Ue(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var a=t[e];this.set(a[0],a[1])}}i(Ue,"MapCache"),Ue.prototype.clear=Go,Ue.prototype.delete=Jo,Ue.prototype.get=el,Ue.prototype.has=rl,Ue.prototype.set=nl;var il=Ue;function sl(t,e){for(var r=-1,a=e.length,n=t.length;++r<a;)t[n+r]=e[r];return t}i(sl,"arrayPush");var da=sl,ol=la(Object.getPrototypeOf,Object),ua=ol;function ll(){this.__data__=new Ot,this.size=0}i(ll,"stackClear");var cl=ll;function dl(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}i(dl,"stackDelete");var ul=dl;function pl(t){return this.__data__.get(t)}i(pl,"stackGet");var hl=pl;function fl(t){return this.__data__.has(t)}i(fl,"stackHas");var ml=fl,gl=200;function yl(t,e){var r=this.__data__;if(r instanceof Ot){var a=r.__data__;if(!nt||a.length<gl-1)return a.push([t,e]),this.size=++r.size,this;r=this.__data__=new il(a)}return r.set(t,e),this.size=r.size,this}i(yl,"stackSet");var _l=yl;function Be(t){var e=this.__data__=new Ot(t);this.size=e.size}i(Be,"Stack"),Be.prototype.clear=cl,Be.prototype.delete=ul,Be.prototype.get=hl,Be.prototype.has=ml,Be.prototype.set=_l;var vl=Be;function bl(t,e){return t&&St(e,ir(e),t)}i(bl,"baseAssign");var wl=bl;function xl(t,e){return t&&St(e,sr(e),t)}i(xl,"baseAssignIn");var kl=xl,pa=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ha=pa&&typeof module=="object"&&module&&!module.nodeType&&module,Sl=ha&&ha.exports===pa,fa=Sl?ue.Buffer:void 0,ma=fa?fa.allocUnsafe:void 0;function Tl(t,e){if(e)return t.slice();var r=t.length,a=ma?ma(r):new t.constructor(r);return t.copy(a),a}i(Tl,"cloneBuffer");var Ol=Tl;function Al(t,e){for(var r=-1,a=t==null?0:t.length,n=0,o=[];++r<a;){var s=t[r];e(s,r,t)&&(o[n++]=s)}return o}i(Al,"arrayFilter");var El=Al;function Cl(){return[]}i(Cl,"stubArray");var ga=Cl,Pl=Object.prototype,Rl=Pl.propertyIsEnumerable,ya=Object.getOwnPropertySymbols,Nl=ya?function(t){return t==null?[]:(t=Object(t),El(ya(t),function(e){return Rl.call(t,e)}))}:ga,or=Nl;function $l(t,e){return St(t,or(t),e)}i($l,"copySymbols");var jl=$l,Il=Object.getOwnPropertySymbols,Dl=Il?function(t){for(var e=[];t;)da(e,or(t)),t=ua(t);return e}:ga,_a=Dl;function Zl(t,e){return St(t,_a(t),e)}i(Zl,"copySymbolsIn");var Ll=Zl;function Ml(t,e,r){var a=e(t);return Qt(t)?a:da(a,r(t))}i(Ml,"baseGetAllKeys");var va=Ml;function Ul(t){return va(t,ir,or)}i(Ul,"getAllKeys");var Bl=Ul;function Fl(t){return va(t,sr,_a)}i(Fl,"getAllKeysIn");var zl=Fl,Vl=Ee(ue,"DataView"),lr=Vl,Wl=Ee(ue,"Promise"),cr=Wl,Hl=Ee(ue,"Set"),dr=Hl,ba="[object Map]",Gl="[object Object]",wa="[object Promise]",xa="[object Set]",ka="[object WeakMap]",Sa="[object DataView]",ql=Ae(lr),Kl=Ae(nt),Yl=Ae(cr),Xl=Ae(dr),Jl=Ae(tr),Ce=Qe;(lr&&Ce(new lr(new ArrayBuffer(1)))!=Sa||nt&&Ce(new nt)!=ba||cr&&Ce(cr.resolve())!=wa||dr&&Ce(new dr)!=xa||tr&&Ce(new tr)!=ka)&&(Ce=i(function(t){var e=Qe(t),r=e==Gl?t.constructor:void 0,a=r?Ae(r):"";if(a)switch(a){case ql:return Sa;case Kl:return ba;case Yl:return wa;case Xl:return xa;case Jl:return ka}return e},"getTag"));var ur=Ce,Ql=Object.prototype,ec=Ql.hasOwnProperty;function tc(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&ec.call(t,"index")&&(r.index=t.index,r.input=t.input),r}i(tc,"initCloneArray");var rc=tc,ac=ue.Uint8Array,Ta=ac;function nc(t){var e=new t.constructor(t.byteLength);return new Ta(e).set(new Ta(t)),e}i(nc,"cloneArrayBuffer");var pr=nc;function ic(t,e){var r=e?pr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}i(ic,"cloneDataView");var sc=ic,oc=/\w*$/;function lc(t){var e=new t.constructor(t.source,oc.exec(t));return e.lastIndex=t.lastIndex,e}i(lc,"cloneRegExp");var cc=lc,Oa=De?De.prototype:void 0,Aa=Oa?Oa.valueOf:void 0;function dc(t){return Aa?Object(Aa.call(t)):{}}i(dc,"cloneSymbol");var uc=dc;function pc(t,e){var r=e?pr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}i(pc,"cloneTypedArray");var hc=pc,fc="[object Boolean]",mc="[object Date]",gc="[object Map]",yc="[object Number]",_c="[object RegExp]",vc="[object Set]",bc="[object String]",wc="[object Symbol]",xc="[object ArrayBuffer]",kc="[object DataView]",Sc="[object Float32Array]",Tc="[object Float64Array]",Oc="[object Int8Array]",Ac="[object Int16Array]",Ec="[object Int32Array]",Cc="[object Uint8Array]",Pc="[object Uint8ClampedArray]",Rc="[object Uint16Array]",Nc="[object Uint32Array]";function $c(t,e,r){var a=t.constructor;switch(e){case xc:return pr(t);case fc:case mc:return new a(+t);case kc:return sc(t,r);case Sc:case Tc:case Oc:case Ac:case Ec:case Cc:case Pc:case Rc:case Nc:return hc(t,r);case gc:return new a;case yc:case bc:return new a(t);case _c:return cc(t);case vc:return new a;case wc:return uc(t)}}i($c,"initCloneByTag");var jc=$c;function Ic(t){return typeof t.constructor=="function"&&!rr(t)?Mi(ua(t)):{}}i(Ic,"initCloneObject");var Dc=Ic,Zc="[object Map]";function Lc(t){return et(t)&&ur(t)==Zc}i(Lc,"baseIsMap");var Mc=Lc,Ea=Ze&&Ze.isMap,Uc=Ea?ar(Ea):Mc,Bc=Uc,Fc="[object Set]";function zc(t){return et(t)&&ur(t)==Fc}i(zc,"baseIsSet");var Vc=zc,Ca=Ze&&Ze.isSet,Wc=Ca?ar(Ca):Vc,Hc=Wc,Gc=1,qc=2,Kc=4,Pa="[object Arguments]",Yc="[object Array]",Xc="[object Boolean]",Jc="[object Date]",Qc="[object Error]",Ra="[object Function]",ed="[object GeneratorFunction]",td="[object Map]",rd="[object Number]",Na="[object Object]",ad="[object RegExp]",nd="[object Set]",id="[object String]",sd="[object Symbol]",od="[object WeakMap]",ld="[object ArrayBuffer]",cd="[object DataView]",dd="[object Float32Array]",ud="[object Float64Array]",pd="[object Int8Array]",hd="[object Int16Array]",fd="[object Int32Array]",md="[object Uint8Array]",gd="[object Uint8ClampedArray]",yd="[object Uint16Array]",_d="[object Uint32Array]",Z={};Z[Pa]=Z[Yc]=Z[ld]=Z[cd]=Z[Xc]=Z[Jc]=Z[dd]=Z[ud]=Z[pd]=Z[hd]=Z[fd]=Z[td]=Z[rd]=Z[Na]=Z[ad]=Z[nd]=Z[id]=Z[sd]=Z[md]=Z[gd]=Z[yd]=Z[_d]=!0,Z[Qc]=Z[Ra]=Z[od]=!1;function Et(t,e,r,a,n,o){var s,l=e&Gc,c=e&qc,u=e&Kc;if(r&&(s=n?r(t,a,n,o):r(t)),s!==void 0)return s;if(!tt(t))return t;var y=Qt(t);if(y){if(s=rc(t),!l)return Bi(t,s)}else{var d=ur(t),O=d==Ra||d==ed;if(na(t))return Ol(t,l);if(d==Na||d==Pa||O&&!n){if(s=c||O?{}:Dc(t),!l)return c?Ll(t,kl(s,t)):jl(t,wl(s,t))}else{if(!Z[d])return n?t:{};s=jc(t,d,l)}}o||(o=new vl);var $=o.get(t);if($)return $;o.set(t,s),Hc(t)?t.forEach(function(W){s.add(Et(W,e,r,W,t,o))}):Bc(t)&&t.forEach(function(W,L){s.set(L,Et(W,e,r,L,t,o))});var I=u?c?zl:Bl:c?sr:ir,j=y?void 0:I(t);return Vi(j||t,function(W,L){j&&(L=W,W=t[L]),Yr(s,L,Et(W,e,r,L,t,o))}),s}i(Et,"baseClone");var vd=Et,bd=1,wd=4;function xd(t){return vd(t,bd|wd)}i(xd,"cloneDeep");var kd=xd;function pe(){switch(process.platform){case"darwin":return"macos";case"linux":return"linux";case"win32":return"windows";default:return"unknown"}}i(pe,"getPlatform");import*as $a from"fs";var Fe=Jt(Ur(),1);import{randomBytes as Sd}from"node:crypto";import*as ne from"fs";import{spawn as ja,spawnSync as hr}from"node:child_process";import{tmpdir as Ia}from"node:os";import X,{join as Da}from"node:path";import{spawnSync as Td}from"child_process";import{execFile as Od}from"child_process";function Ad(){try{return Td("which",["rg"],{stdio:"ignore",timeout:1e3}).status===0}catch{return!1}}i(Ad,"hasRipgrepSync");async function Ed(t,e,r,a={command:"rg"}){let{command:n,args:o=[]}=a;return new Promise((s,l)=>{Od(n,[...o,...t,e],{maxBuffer:2e7,signal:r,timeout:1e4},(c,u,y)=>{if(!c){s(u.trim().split(`
6
- `).filter(Boolean));return}if(c.code===1){s([]);return}l(new Error(`ripgrep failed with exit code ${c.code}: ${y||c.message}`))})})}i(Ed,"ripGrep");import{homedir as fr}from"os";import*as we from"path";import*as Za from"fs";var mr=[".gitconfig",".gitmodules",".bashrc",".bash_profile",".zshrc",".zprofile",".profile",".ripgreprc",".mcp.json"],Cd=[".git",".vscode",".idea"];function La(){return[...Cd.filter(t=>t!==".git"),".claude/commands",".claude/agents"]}i(La,"getDangerousDirectories");function Ma(t){return t.toLowerCase()}i(Ma,"normalizeCaseForComparison");function me(t){return t.includes("*")||t.includes("?")||t.includes("[")||t.includes("]")}i(me,"containsGlobChars");function Ct(t){return t.replace(/\/\*\*$/,"")}i(Ct,"removeTrailingGlobSuffix");function Ua(t,e){let r=we.normalize(t),a=we.normalize(e);if(a===r||r.startsWith("/tmp/")&&a==="/private"+r||r.startsWith("/var/")&&a==="/private"+r||r.startsWith("/private/tmp/")&&a===r||r.startsWith("/private/var/")&&a===r)return!1;if(a==="/"||a.split("/").filter(Boolean).length<=1||r.startsWith(a+"/"))return!0;let n=r;if((r.startsWith("/tmp/")||r.startsWith("/var/"))&&(n="/private"+r),n!==r&&n.startsWith(a+"/"))return!0;let o=a.startsWith(r+"/"),s=n!==r&&a.startsWith(n+"/");return a!==r&&!(n!==r&&a===n)&&!o&&!s}i(Ua,"isSymlinkOutsideBoundary");function ge(t){let e=process.cwd(),r=t;if(t==="~"?r=fr():t.startsWith("~/")?r=fr()+t.slice(1):t.startsWith("./")||t.startsWith("../")?r=we.resolve(e,t):we.isAbsolute(t)||(r=we.resolve(e,t)),me(r)){let a=r.split(/[*?[\]]/)[0];if(a&&a!=="/"){let n=a.endsWith("/")?a.slice(0,-1):we.dirname(a);try{let o=Za.realpathSync(n);if(!Ua(n,o)){let s=r.slice(n.length);return o+s}}catch{}}return r}try{let a=Za.realpathSync(r);Ua(r,a)||(r=a)}catch{}return r}i(ge,"normalizePathForSandbox");function Pt(){let t=fr();return["/dev/stdout","/dev/stderr","/dev/null","/dev/tty","/dev/dtracehelper","/dev/autofs_nowait","/tmp/claude","/private/tmp/claude",we.join(t,".npm/_logs"),we.join(t,".claude/debug")]}i(Pt,"getDefaultWritePaths");function Ba(t,e){let r=["SANDBOX_RUNTIME=1",`TMPDIR=${process.env.CLAUDE_TMPDIR||"/tmp/claude"}`];if(!t&&!e)return r;let a=["localhost","127.0.0.1","::1","*.local",".local","169.254.0.0/16","10.0.0.0/8","172.16.0.0/12","192.168.0.0/16"].join(",");return r.push(`NO_PROXY=${a}`),r.push(`no_proxy=${a}`),t&&(r.push(`HTTP_PROXY=http://localhost:${t}`),r.push(`HTTPS_PROXY=http://localhost:${t}`),r.push(`http_proxy=http://localhost:${t}`),r.push(`https_proxy=http://localhost:${t}`)),e&&(r.push(`ALL_PROXY=socks5h://localhost:${e}`),r.push(`all_proxy=socks5h://localhost:${e}`),pe()==="macos"&&r.push(`GIT_SSH_COMMAND=ssh -o ProxyCommand='nc -X 5 -x localhost:${e} %h %p'`),r.push(`FTP_PROXY=socks5h://localhost:${e}`),r.push(`ftp_proxy=socks5h://localhost:${e}`),r.push(`RSYNC_PROXY=localhost:${e}`),r.push(`DOCKER_HTTP_PROXY=http://localhost:${t||e}`),r.push(`DOCKER_HTTPS_PROXY=http://localhost:${t||e}`),t&&(r.push("CLOUDSDK_PROXY_TYPE=https"),r.push("CLOUDSDK_PROXY_ADDRESS=localhost"),r.push(`CLOUDSDK_PROXY_PORT=${t}`)),r.push(`GRPC_PROXY=socks5h://localhost:${e}`),r.push(`grpc_proxy=socks5h://localhost:${e}`)),r}i(Ba,"generateProxyEnvVars");function Fa(t){let e=t.slice(0,100);return Buffer.from(e).toString("base64")}i(Fa,"encodeSandboxedCommand");function Pd(t){return Buffer.from(t,"base64").toString("utf8")}i(Pd,"decodeSandboxedCommand");import{join as xe,dirname as za}from"node:path";import{fileURLToPath as Va}from"node:url";import*as Rt from"node:fs";function Wa(){let t=process.arch;switch(t){case"x64":case"x86_64":return"x64";case"arm64":case"aarch64":return"arm64";case"ia32":case"x86":return f("[SeccompFilter] 32-bit x86 (ia32) is not currently supported due to missing socketcall() syscall blocking. The current seccomp filter only blocks socket(AF_UNIX, ...), but on 32-bit x86, socketcall() can be used to bypass this.",{level:"error"}),null;default:return f(`[SeccompFilter] Unsupported architecture: ${t}. Only x64 and arm64 are supported.`),null}}i(Wa,"getVendorArchitecture");function Ha(t){if(t){if(Rt.existsSync(t))return f(`[SeccompFilter] Using BPF filter from expected path: ${t}`),t;f(`[SeccompFilter] Expected path provided but file not found: ${t}`)}let e=Wa();if(!e)return f(`[SeccompFilter] Cannot find pre-generated BPF filter: unsupported architecture ${process.arch}`),null;f(`[SeccompFilter] Detected architecture: ${e}`);let r=za(Va(import.meta.url)),a=xe("vendor","seccomp",e,"unix-block.bpf"),n=[xe(r,a),xe(r,"..","..",a),xe(r,"..",a)];for(let o of n)if(Rt.existsSync(o))return f(`[SeccompFilter] Found pre-generated BPF filter: ${o} (${e})`),o;return f(`[SeccompFilter] Pre-generated BPF filter not found in any expected location (${e})`),null}i(Ha,"getPreGeneratedBpfPath");function gr(t){if(t){if(Rt.existsSync(t))return f(`[SeccompFilter] Using apply-seccomp binary from expected path: ${t}`),t;f(`[SeccompFilter] Expected path provided but file not found: ${t}`)}let e=Wa();if(!e)return f(`[SeccompFilter] Cannot find apply-seccomp binary: unsupported architecture ${process.arch}`),null;f(`[SeccompFilter] Looking for apply-seccomp binary for architecture: ${e}`);let r=za(Va(import.meta.url)),a=xe("vendor","seccomp",e,"apply-seccomp"),n=[xe(r,a),xe(r,"..","..",a),xe(r,"..",a)];for(let o of n)if(Rt.existsSync(o))return f(`[SeccompFilter] Found apply-seccomp binary: ${o} (${e})`),o;return f(`[SeccompFilter] apply-seccomp binary not found in any expected location (${e})`),null}i(gr,"getApplySeccompBinaryPath");function Rd(t){let e=Ha(t);return e?(f("[SeccompFilter] Using pre-generated BPF filter"),e):(f("[SeccompFilter] Pre-generated BPF filter not available for this architecture. Only x64 and arm64 are supported.",{level:"error"}),null)}i(Rd,"generateSeccompFilter");var yr=3;function Nd(t,e){let r=t.split(X.sep),a="";for(let n of r){if(!n)continue;let o=a+X.sep+n;try{if(ne.lstatSync(o).isSymbolicLink()&&e.some(s=>o.startsWith(s+"/")||o===s))return o}catch{break}a=o}return null}i(Nd,"findSymlinkInPath");function $d(t){let e=t.split(X.sep),r="";for(let a of e){if(!a)continue;let n=r+X.sep+a;if(!ne.existsSync(n))return n;r=n}return t}i($d,"findFirstNonExistentComponent");async function jd(t={command:"rg"},e=yr,r=!1,a){let n=process.cwd(),o=new AbortController,s=a??o.signal,l=La(),c=[...mr.map(d=>X.resolve(n,d)),...l.map(d=>X.resolve(n,d)),X.resolve(n,".git/hooks")];r||c.push(X.resolve(n,".git/config"));let u=[];for(let d of mr)u.push("--iglob",d);for(let d of l)u.push("--iglob",`**/${d}/**`);u.push("--iglob","**/.git/hooks/**"),r||u.push("--iglob","**/.git/config");let y=[];try{y=await Ed(["--files","--hidden","--max-depth",String(e),...u,"-g","!**/node_modules/**"],n,s,t)}catch(d){f(`[Sandbox] ripgrep scan failed: ${d}`)}for(let d of y){let O=X.resolve(n,d),$=!1;for(let I of[...l,".git"]){let j=Ma(I),W=O.split(X.sep),L=W.findIndex(K=>Ma(K)===j);if(L!==-1){if(I===".git"){let K=W.slice(0,L+1).join(X.sep);d.includes(".git/hooks")?c.push(X.join(K,"hooks")):d.includes(".git/config")&&c.push(X.join(K,"config"))}else c.push(W.slice(0,L+1).join(X.sep));$=!0;break}}$||c.push(O)}return[...new Set(c)]}i(jd,"linuxGetMandatoryDenyPaths");var _r=new Set,Ga=!1;function Id(){Ga||(process.on("exit",()=>{for(let t of _r);}),Ga=!0)}i(Id,"registerSeccompCleanupHandler");function Dd(t=!1,e){try{let r=hr("which",["bwrap"],{stdio:"ignore",timeout:1e3}),a=hr("which",["socat"],{stdio:"ignore",timeout:1e3}),n=r.status===0&&a.status===0;if(!t){let o=Ha(e?.bpfPath)!==null,s=gr(e?.applyPath)!==null;(!o||!s)&&f(`[Sandbox Linux] Seccomp filtering not available (missing binaries for ${process.arch}). Sandbox will run without Unix socket blocking (allowAllUnixSockets mode). This is less restrictive but still provides filesystem and network isolation.`,{level:"warn"})}return n}catch{return!1}}i(Dd,"hasLinuxSandboxDependenciesSync");async function Zd(t,e){let r=Sd(8).toString("hex"),a=Da(Ia(),`claude-http-${r}.sock`),n=Da(Ia(),`claude-socks-${r}.sock`),o=[`UNIX-LISTEN:${a},fork,reuseaddr`,`TCP:localhost:${t},keepalive,keepidle=10,keepintvl=5,keepcnt=3`];f(`Starting HTTP bridge: socat ${o.join(" ")}`);let s=ja("socat",o,{stdio:"ignore"});if(!s.pid)throw new Error("Failed to start HTTP bridge process");s.on("error",y=>{f(`HTTP bridge process error: ${y}`,{level:"error"})}),s.on("exit",(y,d)=>{f(`HTTP bridge process exited with code ${y}, signal ${d}`,{level:y===0?"info":"error"})});let l=[`UNIX-LISTEN:${n},fork,reuseaddr`,`TCP:localhost:${e},keepalive,keepidle=10,keepintvl=5,keepcnt=3`];f(`Starting SOCKS bridge: socat ${l.join(" ")}`);let c=ja("socat",l,{stdio:"ignore"});if(!c.pid){if(s.pid)try{process.kill(s.pid,"SIGTERM")}catch{}throw new Error("Failed to start SOCKS bridge process")}c.on("error",y=>{f(`SOCKS bridge process error: ${y}`,{level:"error"})}),c.on("exit",(y,d)=>{f(`SOCKS bridge process exited with code ${y}, signal ${d}`,{level:y===0?"info":"error"})});let u=5;for(let y=0;y<u;y++){if(!s.pid||s.killed||!c.pid||c.killed)throw new Error("Linux bridge process died unexpectedly");try{if(ne.existsSync(a)&&ne.existsSync(n)){f(`Linux bridges ready after ${y+1} attempts`);break}}catch(d){f(`Error checking sockets (attempt ${y+1}): ${d}`,{level:"error"})}if(y===u-1){if(s.pid)try{process.kill(s.pid,"SIGTERM")}catch{}if(c.pid)try{process.kill(c.pid,"SIGTERM")}catch{}throw new Error(`Failed to create bridge sockets after ${u} attempts`)}await new Promise(d=>setTimeout(d,y*100))}return{httpSocketPath:a,socksSocketPath:n,httpBridgeProcess:s,socksBridgeProcess:c,httpProxyPort:t,socksProxyPort:e}}i(Zd,"initializeLinuxNetworkBridge");function Ld(t,e,r,a,n,o){let s=n||"bash",l=[`socat TCP-LISTEN:3128,fork,reuseaddr UNIX-CONNECT:${t} >/dev/null 2>&1 &`,`socat TCP-LISTEN:1080,fork,reuseaddr UNIX-CONNECT:${e} >/dev/null 2>&1 &`,'trap "kill %1 %2 2>/dev/null; exit" EXIT'];if(a){let c=gr(o);if(!c)throw new Error("apply-seccomp binary not found. This should have been caught earlier. Ensure vendor/seccomp/{x64,arm64}/apply-seccomp binaries are included in the package.");let u=Fe.default.quote([c,a,s,"-c",r]),y=[...l,u].join(`
7
- `);return`${s} -c ${Fe.default.quote([y])}`}else{let c=[...l,`eval ${Fe.default.quote([r])}`].join(`
8
- `);return`${s} -c ${Fe.default.quote([c])}`}}i(Ld,"buildSandboxCommand");async function Md(t,e,r={command:"rg"},a=yr,n=!1,o){let s=[];if(e){s.push("--ro-bind","/","/");let c=[];for(let y of e.allowOnly||[]){let d=ge(y);if(f(`[Sandbox Linux] Processing write path: ${y} -> ${d}`),d.startsWith("/dev/")){f(`[Sandbox Linux] Skipping /dev path: ${d}`);continue}if(!ne.existsSync(d)){f(`[Sandbox Linux] Skipping non-existent write path: ${d}`);continue}s.push("--bind",d,d),c.push(d)}let u=[...e.denyWithinAllow||[],...await jd(r,a,n,o)];for(let y of u){let d=ge(y);if(d.startsWith("/dev/"))continue;let O=Nd(d,c);if(O){s.push("--ro-bind","/dev/null",O),f(`[Sandbox Linux] Mounted /dev/null at symlink ${O} to prevent symlink replacement attack`);continue}if(!ne.existsSync(d)){let $=X.dirname(d);for(;$!=="/"&&!ne.existsSync($);)$=X.dirname($);if(c.some(I=>$.startsWith(I+"/")||$===I||d.startsWith(I+"/"))){let I=$d(d);s.push("--ro-bind","/dev/null",I),f(`[Sandbox Linux] Mounted /dev/null at ${I} to block creation of ${d}`)}else f(`[Sandbox Linux] Skipping non-existent deny path not within allowed paths: ${d}`);continue}c.some($=>d.startsWith($+"/")||d===$)?s.push("--ro-bind",d,d):f(`[Sandbox Linux] Skipping deny path not within allowed paths: ${d}`)}}else s.push("--bind","/","/");let l=[...t?.denyOnly||[]];ne.existsSync("/etc/ssh/ssh_config.d")&&l.push("/etc/ssh/ssh_config.d");for(let c of l){let u=ge(c);if(!ne.existsSync(u)){f(`[Sandbox Linux] Skipping non-existent read deny path: ${u}`);continue}ne.statSync(u).isDirectory()?s.push("--tmpfs",u):s.push("--ro-bind","/dev/null",u)}return s}i(Md,"generateFilesystemArgs");async function Ud(t){let{command:e,needsNetworkRestriction:r,httpSocketPath:a,socksSocketPath:n,httpProxyPort:o,socksProxyPort:s,readConfig:l,writeConfig:c,enableWeakerNestedSandbox:u,allowAllUnixSockets:y,binShell:d,ripgrepConfig:O={command:"rg"},mandatoryDenySearchDepth:$=yr,allowGitConfig:I=!1,seccompConfig:j,abortSignal:W}=t,L=l&&l.denyOnly.length>0,K=c!==void 0;if(!r&&!L&&!K)return e;let H=["--new-session","--die-with-parent"],q;try{if(y?y&&f("[Sandbox Linux] Skipping seccomp filter - allowAllUnixSockets is enabled"):(q=Rd(j?.bpfPath)??void 0,q?(q.includes("/vendor/seccomp/")||(_r.add(q),Id()),f("[Sandbox Linux] Generated seccomp BPF filter for Unix socket blocking")):f("[Sandbox Linux] Seccomp filter not available (missing binaries). Continuing without Unix socket blocking - sandbox will still provide filesystem and network isolation but Unix sockets will be allowed.",{level:"warn"})),r&&(H.push("--unshare-net"),a&&n)){if(!ne.existsSync(a))throw new Error(`Linux HTTP bridge socket does not exist: ${a}. The bridge process may have died. Try reinitializing the sandbox.`);if(!ne.existsSync(n))throw new Error(`Linux SOCKS bridge socket does not exist: ${n}. The bridge process may have died. Try reinitializing the sandbox.`);H.push("--bind",a,a),H.push("--bind",n,n);let k=Ba(3128,1080);H.push(...k.flatMap(P=>{let R=P.indexOf("="),D=P.slice(0,R),te=P.slice(R+1);return["--setenv",D,te]})),o!==void 0&&H.push("--setenv","CLAUDE_CODE_HOST_HTTP_PROXY_PORT",String(o)),s!==void 0&&H.push("--setenv","CLAUDE_CODE_HOST_SOCKS_PROXY_PORT",String(s))}let p=await Md(l,c,O,$,I,W);H.push(...p),H.push("--dev","/dev"),H.push("--unshare-pid"),u||H.push("--proc","/proc");let x=d||"bash",E=hr("which",[x],{encoding:"utf8"});if(E.status!==0)throw new Error(`Shell '${x}' not found in PATH`);let U=E.stdout.trim();if(H.push("--",U,"-c"),r&&a&&n){let k=Ld(a,n,e,q,U,j?.applyPath);H.push(k)}else if(q){let k=gr(j?.applyPath);if(!k)throw new Error("apply-seccomp binary not found. This should have been caught earlier. Ensure vendor/seccomp/{x64,arm64}/apply-seccomp binaries are included in the package.");let P=Fe.default.quote([k,q,U,"-c",e]);H.push(P)}else H.push(e);let G=Fe.default.quote(["bwrap",...H]),C=[];return r&&C.push("network"),(L||K)&&C.push("filesystem"),q&&C.push("seccomp(unix-block)"),f(`[Sandbox Linux] Wrapped command with bwrap (${C.join(", ")} restrictions)`),G}catch(p){throw q&&!q.includes("/vendor/seccomp/")&&_r.delete(q),p}}i(Ud,"wrapCommandWithSandboxLinux");var Bd=Jt(Ur(),1);import{spawn as Fd,spawnSync as zd}from"child_process";import*as Pe from"path";function Vd(t=!1){let e=process.cwd(),r=[];for(let a of mr)r.push(Pe.resolve(e,a)),r.push(`**/${a}`);for(let a of La())r.push(Pe.resolve(e,a)),r.push(`**/${a}/**`);return r.push(Pe.resolve(e,".git/hooks")),r.push("**/.git/hooks/**"),t||(r.push(Pe.resolve(e,".git/config")),r.push("**/.git/config")),[...new Set(r)]}i(Vd,"macGetMandatoryDenyPatterns");var qa=`_${Math.random().toString(36).slice(2,11)}_SBX`;function Nt(t){return"^"+t.replace(/[.^$+{}()|\\]/g,"\\$&").replace(/\[([^\]]*?)$/g,"\\[$1").replace(/\*\*\//g,"__GLOBSTAR_SLASH__").replace(/\*\*/g,"__GLOBSTAR__").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]").replace(/__GLOBSTAR_SLASH__/g,"(.*/)?").replace(/__GLOBSTAR__/g,".*")+"$"}i(Nt,"globToRegex");function Wd(t){return`CMD64_${Fa(t)}_END_${qa}`}i(Wd,"generateLogTag");function Ka(t){let e=[],r=Pe.dirname(t);for(;r!=="/"&&r!==".";){e.push(r);let a=Pe.dirname(r);if(a===r)break;r=a}return e}i(Ka,"getAncestorDirectories");function Ya(t,e){let r=[];for(let a of t){let n=ge(a);if(me(n)){let o=Nt(n);r.push("(deny file-write-unlink",` (regex ${re(o)})`,` (with message "${e}"))`);let s=n.split(/[*?[\]]/)[0];if(s&&s!=="/"){let l=s.endsWith("/")?s.slice(0,-1):Pe.dirname(s);r.push("(deny file-write-unlink",` (literal ${re(l)})`,` (with message "${e}"))`);for(let c of Ka(l))r.push("(deny file-write-unlink",` (literal ${re(c)})`,` (with message "${e}"))`)}}else{r.push("(deny file-write-unlink",` (subpath ${re(n)})`,` (with message "${e}"))`);for(let o of Ka(n))r.push("(deny file-write-unlink",` (literal ${re(o)})`,` (with message "${e}"))`)}}return r}i(Ya,"generateMoveBlockingRules");function Hd(t,e){if(!t)return["(allow file-read*)"];let r=[];r.push("(allow file-read*)");for(let a of t.denyOnly||[]){let n=ge(a);if(me(n)){let o=Nt(n);r.push("(deny file-read*",` (regex ${re(o)})`,` (with message "${e}"))`)}else r.push("(deny file-read*",` (subpath ${re(n)})`,` (with message "${e}"))`)}return r.push(...Ya(t.denyOnly||[],e)),r}i(Hd,"generateReadRules");function Gd(t,e,r=!1){if(!t)return["(allow file-write*)"];let a=[],n=Kd();for(let s of n){let l=ge(s);a.push("(allow file-write*",` (subpath ${re(l)})`,` (with message "${e}"))`)}for(let s of t.allowOnly||[]){let l=ge(s);if(me(l)){let c=Nt(l);a.push("(allow file-write*",` (regex ${re(c)})`,` (with message "${e}"))`)}else a.push("(allow file-write*",` (subpath ${re(l)})`,` (with message "${e}"))`)}let o=[...t.denyWithinAllow||[],...Vd(r)];for(let s of o){let l=ge(s);if(me(l)){let c=Nt(l);a.push("(deny file-write*",` (regex ${re(c)})`,` (with message "${e}"))`)}else a.push("(deny file-write*",` (subpath ${re(l)})`,` (with message "${e}"))`)}return a.push(...Ya(o,e)),a}i(Gd,"generateWriteRules");function qd({readConfig:t,writeConfig:e,httpProxyPort:r,socksProxyPort:a,needsNetworkRestriction:n,allowUnixSockets:o,allowAllUnixSockets:s,allowLocalBinding:l,allowPty:c,allowGitConfig:u=!1,logTag:y}){let d=["(version 1)",`(deny default (with message "${y}"))`,"",`; LogTag: ${y}`,"","; Essential permissions - based on Chrome sandbox policy","; Process permissions","(allow process-exec)","(allow process-fork)","(allow process-info* (target same-sandbox))","(allow signal (target same-sandbox))","(allow mach-priv-task-port (target same-sandbox))","","; User preferences","(allow user-preference-read)","","; Mach IPC - specific services only (no wildcard)","(allow mach-lookup",' (global-name "com.apple.audio.systemsoundserver")',' (global-name "com.apple.distributed_notifications@Uv3")',' (global-name "com.apple.FontObjectsServer")',' (global-name "com.apple.fonts")',' (global-name "com.apple.logd")',' (global-name "com.apple.lsd.mapdb")',' (global-name "com.apple.PowerManagement.control")',' (global-name "com.apple.system.logger")',' (global-name "com.apple.system.notification_center")',' (global-name "com.apple.trustd.agent")',' (global-name "com.apple.system.opendirectoryd.libinfo")',' (global-name "com.apple.system.opendirectoryd.membership")',' (global-name "com.apple.bsd.dirhelper")',' (global-name "com.apple.securityd.xpc")',' (global-name "com.apple.coreservices.launchservicesd")',")","","; POSIX IPC - shared memory","(allow ipc-posix-shm)","","; POSIX IPC - semaphores for Python multiprocessing","(allow ipc-posix-sem)","","; IOKit - specific operations only","(allow iokit-open",' (iokit-registry-entry-class "IOSurfaceRootUserClient")',' (iokit-registry-entry-class "RootDomainUserClient")',' (iokit-user-client-class "IOSurfaceSendRight")',")","","; IOKit properties","(allow iokit-get-properties)","","; Specific safe system-sockets, doesn't allow network access","(allow system-socket (require-all (socket-domain AF_SYSTEM) (socket-protocol 2)))","","; sysctl - specific sysctls only","(allow sysctl-read",' (sysctl-name "hw.activecpu")',' (sysctl-name "hw.busfrequency_compat")',' (sysctl-name "hw.byteorder")',' (sysctl-name "hw.cacheconfig")',' (sysctl-name "hw.cachelinesize_compat")',' (sysctl-name "hw.cpufamily")',' (sysctl-name "hw.cpufrequency")',' (sysctl-name "hw.cpufrequency_compat")',' (sysctl-name "hw.cputype")',' (sysctl-name "hw.l1dcachesize_compat")',' (sysctl-name "hw.l1icachesize_compat")',' (sysctl-name "hw.l2cachesize_compat")',' (sysctl-name "hw.l3cachesize_compat")',' (sysctl-name "hw.logicalcpu")',' (sysctl-name "hw.logicalcpu_max")',' (sysctl-name "hw.machine")',' (sysctl-name "hw.memsize")',' (sysctl-name "hw.ncpu")',' (sysctl-name "hw.nperflevels")',' (sysctl-name "hw.packages")',' (sysctl-name "hw.pagesize_compat")',' (sysctl-name "hw.pagesize")',' (sysctl-name "hw.physicalcpu")',' (sysctl-name "hw.physicalcpu_max")',' (sysctl-name "hw.tbfrequency_compat")',' (sysctl-name "hw.vectorunit")',' (sysctl-name "kern.argmax")',' (sysctl-name "kern.bootargs")',' (sysctl-name "kern.hostname")',' (sysctl-name "kern.maxfiles")',' (sysctl-name "kern.maxfilesperproc")',' (sysctl-name "kern.maxproc")',' (sysctl-name "kern.ngroups")',' (sysctl-name "kern.osproductversion")',' (sysctl-name "kern.osrelease")',' (sysctl-name "kern.ostype")',' (sysctl-name "kern.osvariant_status")',' (sysctl-name "kern.osversion")',' (sysctl-name "kern.secure_kernel")',' (sysctl-name "kern.tcsm_available")',' (sysctl-name "kern.tcsm_enable")',' (sysctl-name "kern.usrstack64")',' (sysctl-name "kern.version")',' (sysctl-name "kern.willshutdown")',' (sysctl-name "machdep.cpu.brand_string")',' (sysctl-name "machdep.ptrauth_enabled")',' (sysctl-name "security.mac.lockdown_mode_state")',' (sysctl-name "sysctl.proc_cputype")',' (sysctl-name "vm.loadavg")',' (sysctl-name-prefix "hw.optional.arm")',' (sysctl-name-prefix "hw.optional.arm.")',' (sysctl-name-prefix "hw.optional.armv8_")',' (sysctl-name-prefix "hw.perflevel")',' (sysctl-name-prefix "kern.proc.all")',' (sysctl-name-prefix "kern.proc.pgrp.")',' (sysctl-name-prefix "kern.proc.pid.")',' (sysctl-name-prefix "machdep.cpu.")',' (sysctl-name-prefix "net.routetable.")',")","","; V8 thread calculations","(allow sysctl-write",' (sysctl-name "kern.tcsm_enable")',")","","; Distributed notifications","(allow distributed-notification-post)","","; Specific mach-lookup permissions for security operations",'(allow mach-lookup (global-name "com.apple.SecurityServer"))',"","; File I/O on device files",'(allow file-ioctl (literal "/dev/null"))','(allow file-ioctl (literal "/dev/zero"))','(allow file-ioctl (literal "/dev/random"))','(allow file-ioctl (literal "/dev/urandom"))','(allow file-ioctl (literal "/dev/dtracehelper"))','(allow file-ioctl (literal "/dev/tty"))',"","(allow file-ioctl file-read-data file-write-data"," (require-all",' (literal "/dev/null")'," (vnode-type CHARACTER-DEVICE)"," )",")",""];if(d.push("; Network"),!n)d.push("(allow network*)");else{if(l&&(d.push('(allow network-bind (local ip "localhost:*"))'),d.push('(allow network-inbound (local ip "localhost:*"))'),d.push('(allow network-outbound (local ip "localhost:*"))')),s)d.push('(allow network* (subpath "/"))');else if(o&&o.length>0)for(let O of o){let $=ge(O);d.push(`(allow network* (subpath ${re($)}))`)}r!==void 0&&(d.push(`(allow network-bind (local ip "localhost:${r}"))`),d.push(`(allow network-inbound (local ip "localhost:${r}"))`),d.push(`(allow network-outbound (remote ip "localhost:${r}"))`)),a!==void 0&&(d.push(`(allow network-bind (local ip "localhost:${a}"))`),d.push(`(allow network-inbound (local ip "localhost:${a}"))`),d.push(`(allow network-outbound (remote ip "localhost:${a}"))`))}return d.push(""),d.push("; File read"),d.push(...Hd(t,y)),d.push(""),d.push("; File write"),d.push(...Gd(e,y,u)),c&&(d.push(""),d.push("; Pseudo-terminal (pty) support"),d.push("(allow pseudo-tty)"),d.push("(allow file-ioctl"),d.push(' (literal "/dev/ptmx")'),d.push(' (regex #"^/dev/ttys")'),d.push(")"),d.push("(allow file-read* file-write*"),d.push(' (literal "/dev/ptmx")'),d.push(' (regex #"^/dev/ttys")'),d.push(")")),d.join(`
9
- `)}i(qd,"generateSandboxProfile");function re(t){return JSON.stringify(t)}i(re,"escapePath");function Kd(){let t=process.env.TMPDIR;if(!t)return[];if(!t.match(/^\/(private\/)?var\/folders\/[^/]{2}\/[^/]+\/T\/?$/))return[];let e=t.replace(/\/T\/?$/,"");return e.startsWith("/private/var/")?[e,e.replace("/private","")]:e.startsWith("/var/")?[e,"/private"+e]:[e]}i(Kd,"getTmpdirParentIfMacOSPattern");function Yd(t){let{command:e,needsNetworkRestriction:r,httpProxyPort:a,socksProxyPort:n,allowUnixSockets:o,allowAllUnixSockets:s,allowLocalBinding:l,readConfig:c,writeConfig:u,allowPty:y,allowGitConfig:d=!1,binShell:O}=t,$=c&&c.denyOnly.length>0;if(!r&&!$&&u===void 0)return e;let I=Wd(e),j=qd({readConfig:c,writeConfig:u,httpProxyPort:a,socksProxyPort:n,needsNetworkRestriction:r,allowUnixSockets:o,allowAllUnixSockets:s,allowLocalBinding:l,allowPty:y,allowGitConfig:d,logTag:I}),W=Ba(a,n),L=O||"bash",K=zd("which",[L],{encoding:"utf8"});if(K.status!==0)throw new Error(`Shell '${L}' not found in PATH`);let H=K.stdout.trim(),q=Bd.default.quote(["env",...W,"sandbox-exec","-p",j,H,"-c",e]);return f(`[Sandbox macOS] Applied restrictions - network: ${!!(a||n)}, read: ${c?"allowAllExcept"in c?"allowAllExcept":"denyAllExcept":"none"}, write: ${u?"allowAllExcept"in u?"allowAllExcept":"denyAllExcept":"none"}`),q}i(Yd,"wrapCommandWithSandboxMacOS");function Xd(t,e){let r=/CMD64_(.+?)_END/,a=/Sandbox:\s+(.+)$/,n=e?.["*"]||[],o=e?Object.entries(e).filter(([l])=>l!=="*"):[],s=Fd("log",["stream","--predicate",`(eventMessage ENDSWITH "${qa}")`,"--style","compact"]);return s.stdout?.on("data",l=>{let c=l.toString().split(`
10
- `),u=c.find(j=>j.includes("Sandbox:")&&j.includes("deny")),y=c.find(j=>j.startsWith("CMD64_"));if(!u)return;let d=u.match(a);if(!d?.[1])return;let O=d[1],$,I;if(y&&(I=y.match(r)?.[1],I))try{$=Pd(I)}catch{}if(!(O.includes("mDNSResponder")||O.includes("mach-lookup com.apple.diagnosticd")||O.includes("mach-lookup com.apple.analyticsd"))){if(e&&$){if(n.length>0&&n.some(j=>O.includes(j)))return;for(let[j,W]of o)if($.includes(j)&&W.some(L=>O.includes(L)))return}t({line:O,command:$,encodedCommand:I,timestamp:new Date})}}),s.stderr?.on("data",l=>{f(`[Sandbox Monitor] Log stream stderr: ${l.toString()}`)}),s.on("error",l=>{f(`[Sandbox Monitor] Failed to start log stream: ${l.message}`)}),s.on("exit",l=>{f(`[Sandbox Monitor] Log stream exited with code: ${l}`)}),()=>{f("[Sandbox Monitor] Stopping log monitor"),s.kill("SIGTERM")}}i(Xd,"startMacOSSandboxLogMonitor");var Xa=class{static{i(this,"SandboxViolationStore")}constructor(){this.violations=[],this.totalCount=0,this.maxSize=100,this.listeners=new Set}addViolation(t){this.violations.push(t),this.totalCount++,this.violations.length>this.maxSize&&(this.violations=this.violations.slice(-this.maxSize)),this.notifyListeners()}getViolations(t){return t===void 0?[...this.violations]:this.violations.slice(-t)}getCount(){return this.violations.length}getTotalCount(){return this.totalCount}getViolationsForCommand(t){let e=Fa(t);return this.violations.filter(r=>r.encodedCommand===e)}clear(){this.violations=[],this.notifyListeners()}subscribe(t){return this.listeners.add(t),t(this.getViolations()),()=>{this.listeners.delete(t)}}notifyListeners(){let t=this.getViolations();this.listeners.forEach(e=>e(t))}};import{EOL as vr}from"node:os";var w,ze,Re,ie,ke,Ja=!1,$t,jt=new Xa;function Jd(){if(Ja)return;let t=i(()=>br().catch(e=>{f(`Cleanup failed in registerCleanup ${e}`,{level:"error"})}),"cleanupHandler");process.once("exit",t),process.once("SIGINT",t),process.once("SIGTERM",t),Ja=!0}i(Jd,"registerCleanup");function Qa(t,e){if(e.startsWith("*.")){let r=e.substring(2);return t.toLowerCase().endsWith("."+r.toLowerCase())}return t.toLowerCase()===e.toLowerCase()}i(Qa,"matchesDomainPattern");async function en(t,e,r){if(!w)return f("No config available, denying network request"),!1;for(let a of w.network.deniedDomains)if(Qa(e,a))return f(`Denied by config rule: ${e}:${t}`),!1;for(let a of w.network.allowedDomains)if(Qa(e,a))return f(`Allowed by config rule: ${e}:${t}`),!0;if(!r)return f(`No matching config rule, denying: ${e}:${t}`),!1;f(`No matching config rule, asking user: ${e}:${t}`);try{return await r({host:e,port:t})?(f(`User allowed: ${e}:${t}`),!0):(f(`User denied: ${e}:${t}`),!1)}catch(a){return f(`Error in permission callback: ${a}`,{level:"error"}),!1}}i(en,"filterNetworkRequest");async function Qd(t){return ze=zn({filter:i((e,r)=>en(e,r,t),"filter")}),new Promise((e,r)=>{if(!ze){r(new Error("HTTP proxy server undefined before listen"));return}let a=ze;a.once("error",r),a.once("listening",()=>{let n=a.address();n&&typeof n=="object"?(a.unref(),f(`HTTP proxy listening on localhost:${n.port}`),e(n.port)):r(new Error("Failed to get proxy server address"))}),a.listen(0,"127.0.0.1")})}i(Qd,"startHttpProxyServer");async function eu(t){return Re=Kn({filter:i((e,r)=>en(e,r,t),"filter")}),new Promise((e,r)=>{if(!Re){r(new Error("SOCKS proxy server undefined before listen"));return}Re.listen(0,"127.0.0.1").then(a=>{Re?.unref(),e(a)}).catch(r)})}i(eu,"startSocksProxyServer");async function tu(t,e,r=!1){if(ke){await ke;return}if(w=t,!rn()){let a=pe(),n="Sandbox dependencies are not available on this system.";throw a==="linux"?n+=" Required: ripgrep (rg), bubblewrap (bwrap), and socat.":a==="macos"?n+=" Required: ripgrep (rg).":n+=` Platform '${a}' is not supported.`,new Error(n)}r&&pe()==="macos"&&($t=Xd(jt.addViolation.bind(jt),w.ignoreViolations),f("Started macOS sandbox log monitor")),Jd(),ke=(async()=>{try{let a;w.network.httpProxyPort!==void 0?(a=w.network.httpProxyPort,f(`Using external HTTP proxy on port ${a}`)):a=await Qd(e);let n;w.network.socksProxyPort!==void 0?(n=w.network.socksProxyPort,f(`Using external SOCKS proxy on port ${n}`)):n=await eu(e);let o;pe()==="linux"&&(o=await Zd(a,n));let s={httpProxyPort:a,socksProxyPort:n,linuxBridge:o};return ie=s,f("Network infrastructure initialized"),s}catch(a){throw ke=void 0,ie=void 0,br().catch(n=>{f(`Cleanup failed in initializationPromise ${n}`,{level:"error"})}),a}})(),await ke}i(tu,"initialize");function tn(t){return["macos","linux"].includes(t)}i(tn,"isSupportedPlatform");function ru(){return w!==void 0}i(ru,"isSandboxingEnabled");function rn(t){let e=pe();if(!tn(e)||(t??w?.ripgrep)?.command===void 0&&!Ad())return!1;if(e==="linux"){let r=w?.network?.allowAllUnixSockets??!1,a=w?.seccomp;return Dd(r,a)}return!0}i(rn,"checkDependencies");function au(){return w?{denyOnly:w.filesystem.denyRead.map(t=>Ct(t)).filter(t=>pe()==="linux"&&me(t)?(f(`Skipping glob pattern on Linux: ${t}`),!1):!0)}:{denyOnly:[]}}i(au,"getFsReadConfig");function nu(){if(!w)return{allowOnly:Pt(),denyWithinAllow:[]};let t=w.filesystem.allowWrite.map(r=>Ct(r)).filter(r=>pe()==="linux"&&me(r)?(f(`Skipping glob pattern on Linux: ${r}`),!1):!0),e=w.filesystem.denyWrite.map(r=>Ct(r)).filter(r=>pe()==="linux"&&me(r)?(f(`Skipping glob pattern on Linux: ${r}`),!1):!0);return{allowOnly:[...Pt(),...t],denyWithinAllow:e}}i(nu,"getFsWriteConfig");function iu(){if(!w)return{};let t=w.network.allowedDomains,e=w.network.deniedDomains;return{...t.length>0&&{allowedHosts:t},...e.length>0&&{deniedHosts:e}}}i(iu,"getNetworkRestrictionConfig");function an(){return w?.network?.allowUnixSockets}i(an,"getAllowUnixSockets");function nn(){return w?.network?.allowAllUnixSockets}i(nn,"getAllowAllUnixSockets");function sn(){return w?.network?.allowLocalBinding}i(sn,"getAllowLocalBinding");function on(){return w?.ignoreViolations}i(on,"getIgnoreViolations");function ln(){return w?.enableWeakerNestedSandbox}i(ln,"getEnableWeakerNestedSandbox");function su(){return w?.ripgrep??{command:"rg"}}i(su,"getRipgrepConfig");function ou(){return w?.mandatoryDenySearchDepth??3}i(ou,"getMandatoryDenySearchDepth");function cn(){return w?.filesystem?.allowGitConfig??!1}i(cn,"getAllowGitConfig");function lu(){return w?.seccomp}i(lu,"getSeccompConfig");function dn(){return ie?.httpProxyPort}i(dn,"getProxyPort");function un(){return ie?.socksProxyPort}i(un,"getSocksProxyPort");function pn(){return ie?.linuxBridge?.httpSocketPath}i(pn,"getLinuxHttpSocketPath");function hn(){return ie?.linuxBridge?.socksSocketPath}i(hn,"getLinuxSocksSocketPath");async function fn(){if(!w)return!1;if(ke)try{return await ke,!0}catch{return!1}return ie!==void 0}i(fn,"waitForNetworkInitialization");async function cu(t,e,r,a){let n=pe(),o=r?.filesystem?.allowWrite??w?.filesystem.allowWrite??[],s={allowOnly:[...Pt(),...o],denyWithinAllow:r?.filesystem?.denyWrite??w?.filesystem.denyWrite??[]},l={denyOnly:r?.filesystem?.denyRead??w?.filesystem.denyRead??[]},c=r?.network?.allowedDomains!==void 0||w?.network?.allowedDomains!==void 0,u=r?.network?.allowedDomains??w?.network.allowedDomains??[],y=c,d=u.length>0;d&&await fn();let O=r?.allowPty??w?.allowPty;switch(n){case"macos":return Yd({command:t,needsNetworkRestriction:y,httpProxyPort:d?dn():void 0,socksProxyPort:d?un():void 0,readConfig:l,writeConfig:s,allowUnixSockets:an(),allowAllUnixSockets:nn(),allowLocalBinding:sn(),ignoreViolations:on(),allowPty:O,allowGitConfig:cn(),binShell:e});case"linux":return Ud({command:t,needsNetworkRestriction:y,httpSocketPath:d?pn():void 0,socksSocketPath:d?hn():void 0,httpProxyPort:d?ie?.httpProxyPort:void 0,socksProxyPort:d?ie?.socksProxyPort:void 0,readConfig:l,writeConfig:s,enableWeakerNestedSandbox:ln(),allowAllUnixSockets:nn(),binShell:e,ripgrepConfig:su(),mandatoryDenySearchDepth:ou(),allowGitConfig:cn(),seccompConfig:lu(),abortSignal:a});default:throw new Error(`Sandbox configuration is not supported on platform: ${n}`)}}i(cu,"wrapWithSandbox");function du(){return w}i(du,"getConfig");function uu(t){w=kd(t),f("Sandbox configuration updated")}i(uu,"updateConfig");async function br(){if($t&&($t(),$t=void 0),ie?.linuxBridge){let{httpSocketPath:e,socksSocketPath:r,httpBridgeProcess:a,socksBridgeProcess:n}=ie.linuxBridge,o=[];if(a.pid&&!a.killed)try{process.kill(a.pid,"SIGTERM"),f("Sent SIGTERM to HTTP bridge process"),o.push(new Promise(s=>{a.once("exit",()=>{f("HTTP bridge process exited"),s()}),setTimeout(()=>{if(!a.killed){f("HTTP bridge did not exit, forcing SIGKILL",{level:"warn"});try{a.pid&&process.kill(a.pid,"SIGKILL")}catch{}}s()},5e3)}))}catch(s){s.code!=="ESRCH"&&f(`Error killing HTTP bridge: ${s}`,{level:"error"})}if(n.pid&&!n.killed)try{process.kill(n.pid,"SIGTERM"),f("Sent SIGTERM to SOCKS bridge process"),o.push(new Promise(s=>{n.once("exit",()=>{f("SOCKS bridge process exited"),s()}),setTimeout(()=>{if(!n.killed){f("SOCKS bridge did not exit, forcing SIGKILL",{level:"warn"});try{n.pid&&process.kill(n.pid,"SIGKILL")}catch{}}s()},5e3)}))}catch(s){s.code!=="ESRCH"&&f(`Error killing SOCKS bridge: ${s}`,{level:"error"})}if(await Promise.all(o),e)try{$a.rmSync(e,{force:!0}),f("Cleaned up HTTP socket")}catch(s){f(`HTTP socket cleanup error: ${s}`,{level:"error"})}if(r)try{$a.rmSync(r,{force:!0}),f("Cleaned up SOCKS socket")}catch(s){f(`SOCKS socket cleanup error: ${s}`,{level:"error"})}}let t=[];if(ze){let e=ze,r=new Promise(a=>{e.close(n=>{n&&n.message!=="Server is not running."&&f(`Error closing HTTP proxy server: ${n.message}`,{level:"error"}),a()})});t.push(r)}if(Re){let e=Re.close().catch(r=>{f(`Error closing SOCKS proxy server: ${r.message}`,{level:"error"})});t.push(e)}await Promise.all(t),ze=void 0,Re=void 0,ie=void 0,ke=void 0}i(br,"reset");function pu(){return jt}i(pu,"getSandboxViolationStore");function hu(t,e){if(!w)return e;let r=jt.getViolationsForCommand(t);if(r.length===0)return e;let a=e;a+=vr+"<sandbox_violations>"+vr;for(let n of r)a+=n.line+vr;return a+="</sandbox_violations>",a}i(hu,"annotateStderrWithSandboxFailures");function fu(){if(pe()!=="linux"||!w)return[];let t=[],e=[...w.filesystem.denyRead,...w.filesystem.allowWrite,...w.filesystem.denyWrite];for(let r of e){let a=Ct(r);me(a)&&t.push(r)}return t}i(fu,"getLinuxGlobPatternWarnings");var mu={initialize:tu,isSupportedPlatform:tn,isSandboxingEnabled:ru,checkDependencies:rn,getFsReadConfig:au,getFsWriteConfig:nu,getNetworkRestrictionConfig:iu,getAllowUnixSockets:an,getAllowLocalBinding:sn,getIgnoreViolations:on,getEnableWeakerNestedSandbox:ln,getProxyPort:dn,getSocksProxyPort:un,getLinuxHttpSocketPath:pn,getLinuxSocksSocketPath:hn,waitForNetworkInitialization:fn,wrapWithSandbox:cu,reset:br,getSandboxViolationStore:pu,annotateStderrWithSandboxFailures:hu,getLinuxGlobPatternWarnings:fu,getConfig:du,updateConfig:uu},N={};Vn(N,{BRAND:i(()=>Bu,"BRAND"),DIRTY:i(()=>We,"DIRTY"),EMPTY_PATH:i(()=>vu,"EMPTY_PATH"),INVALID:i(()=>v,"INVALID"),NEVER:i(()=>Sp,"NEVER"),OK:i(()=>J,"OK"),ParseStatus:i(()=>ee,"ParseStatus"),Schema:i(()=>T,"Schema"),ZodAny:i(()=>Ge,"ZodAny"),ZodArray:i(()=>je,"ZodArray"),ZodBigInt:i(()=>ot,"ZodBigInt"),ZodBoolean:i(()=>lt,"ZodBoolean"),ZodBranded:i(()=>Or,"ZodBranded"),ZodCatch:i(()=>vt,"ZodCatch"),ZodDate:i(()=>ct,"ZodDate"),ZodDefault:i(()=>_t,"ZodDefault"),ZodDiscriminatedUnion:i(()=>bn,"ZodDiscriminatedUnion"),ZodEffects:i(()=>le,"ZodEffects"),ZodEnum:i(()=>gt,"ZodEnum"),ZodError:i(()=>oe,"ZodError"),ZodFirstPartyTypeKind:i(()=>b,"ZodFirstPartyTypeKind"),ZodFunction:i(()=>xn,"ZodFunction"),ZodIntersection:i(()=>ht,"ZodIntersection"),ZodIssueCode:i(()=>h,"ZodIssueCode"),ZodLazy:i(()=>ft,"ZodLazy"),ZodLiteral:i(()=>mt,"ZodLiteral"),ZodMap:i(()=>Mt,"ZodMap"),ZodNaN:i(()=>Bt,"ZodNaN"),ZodNativeEnum:i(()=>yt,"ZodNativeEnum"),ZodNever:i(()=>_e,"ZodNever"),ZodNull:i(()=>ut,"ZodNull"),ZodNullable:i(()=>Oe,"ZodNullable"),ZodNumber:i(()=>st,"ZodNumber"),ZodObject:i(()=>se,"ZodObject"),ZodOptional:i(()=>fe,"ZodOptional"),ZodParsedType:i(()=>g,"ZodParsedType"),ZodPipeline:i(()=>Ar,"ZodPipeline"),ZodPromise:i(()=>Ke,"ZodPromise"),ZodReadonly:i(()=>bt,"ZodReadonly"),ZodRecord:i(()=>wn,"ZodRecord"),ZodSchema:i(()=>T,"ZodSchema"),ZodSet:i(()=>Ut,"ZodSet"),ZodString:i(()=>He,"ZodString"),ZodSymbol:i(()=>Zt,"ZodSymbol"),ZodTransformer:i(()=>le,"ZodTransformer"),ZodTuple:i(()=>Te,"ZodTuple"),ZodType:i(()=>T,"ZodType"),ZodUndefined:i(()=>dt,"ZodUndefined"),ZodUnion:i(()=>pt,"ZodUnion"),ZodUnknown:i(()=>$e,"ZodUnknown"),ZodVoid:i(()=>Lt,"ZodVoid"),addIssueToContext:i(()=>m,"addIssueToContext"),any:i(()=>Yu,"any"),array:i(()=>ep,"array"),bigint:i(()=>Wu,"bigint"),boolean:i(()=>En,"boolean"),coerce:i(()=>kp,"coerce"),custom:i(()=>Tn,"custom"),date:i(()=>Hu,"date"),datetimeRegex:i(()=>vn,"datetimeRegex"),defaultErrorMap:i(()=>Ve,"defaultErrorMap"),discriminatedUnion:i(()=>np,"discriminatedUnion"),effect:i(()=>Cn,"effect"),enum:i(()=>hp,"enum"),function:i(()=>dp,"function"),getErrorMap:i(()=>It,"getErrorMap"),getParsedType:i(()=>ye,"getParsedType"),instanceof:i(()=>zu,"instanceof"),intersection:i(()=>ip,"intersection"),isAborted:i(()=>xr,"isAborted"),isAsync:i(()=>it,"isAsync"),isDirty:i(()=>kr,"isDirty"),isValid:i(()=>Ne,"isValid"),late:i(()=>Fu,"late"),lazy:i(()=>up,"lazy"),literal:i(()=>pp,"literal"),makeIssue:i(()=>Dt,"makeIssue"),map:i(()=>lp,"map"),nan:i(()=>Vu,"nan"),nativeEnum:i(()=>fp,"nativeEnum"),never:i(()=>Ju,"never"),null:i(()=>Ku,"null"),nullable:i(()=>yp,"nullable"),number:i(()=>An,"number"),object:i(()=>tp,"object"),objectUtil:i(()=>wr,"objectUtil"),oboolean:i(()=>xp,"oboolean"),onumber:i(()=>wp,"onumber"),optional:i(()=>gp,"optional"),ostring:i(()=>bp,"ostring"),pipeline:i(()=>vp,"pipeline"),preprocess:i(()=>_p,"preprocess"),promise:i(()=>mp,"promise"),quotelessJson:i(()=>gu,"quotelessJson"),record:i(()=>op,"record"),set:i(()=>cp,"set"),setErrorMap:i(()=>_u,"setErrorMap"),strictObject:i(()=>rp,"strictObject"),string:i(()=>On,"string"),symbol:i(()=>Gu,"symbol"),transformer:i(()=>Cn,"transformer"),tuple:i(()=>sp,"tuple"),undefined:i(()=>qu,"undefined"),union:i(()=>ap,"union"),unknown:i(()=>Xu,"unknown"),util:i(()=>A,"util"),void:i(()=>Qu,"void")});var A;(function(t){t.assertEqual=n=>{};function e(n){}i(e,"assertIs"),t.assertIs=e;function r(n){throw new Error}i(r,"assertNever"),t.assertNever=r,t.arrayToEnum=n=>{let o={};for(let s of n)o[s]=s;return o},t.getValidEnumValues=n=>{let o=t.objectKeys(n).filter(l=>typeof n[n[l]]!="number"),s={};for(let l of o)s[l]=n[l];return t.objectValues(s)},t.objectValues=n=>t.objectKeys(n).map(function(o){return n[o]}),t.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let o=[];for(let s in n)Object.prototype.hasOwnProperty.call(n,s)&&o.push(s);return o},t.find=(n,o)=>{for(let s of n)if(o(s))return s},t.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function a(n,o=" | "){return n.map(s=>typeof s=="string"?`'${s}'`:s).join(o)}i(a,"joinValues"),t.joinValues=a,t.jsonStringifyReplacer=(n,o)=>typeof o=="bigint"?o.toString():o})(A||(A={}));var wr;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(wr||(wr={}));var g=A.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ye=i(t=>{switch(typeof t){case"undefined":return g.undefined;case"string":return g.string;case"number":return Number.isNaN(t)?g.nan:g.number;case"boolean":return g.boolean;case"function":return g.function;case"bigint":return g.bigint;case"symbol":return g.symbol;case"object":return Array.isArray(t)?g.array:t===null?g.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?g.promise:typeof Map<"u"&&t instanceof Map?g.map:typeof Set<"u"&&t instanceof Set?g.set:typeof Date<"u"&&t instanceof Date?g.date:g.object;default:return g.unknown}},"getParsedType"),h=A.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),gu=i(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),oe=class In extends Error{static{i(this,"_ZodError")}get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(o){return o.message},a={_errors:[]},n=i(o=>{for(let s of o.issues)if(s.code==="invalid_union")s.unionErrors.map(n);else if(s.code==="invalid_return_type")n(s.returnTypeError);else if(s.code==="invalid_arguments")n(s.argumentsError);else if(s.path.length===0)a._errors.push(r(s));else{let l=a,c=0;for(;c<s.path.length;){let u=s.path[c];c===s.path.length-1?(l[u]=l[u]||{_errors:[]},l[u]._errors.push(r(s))):l[u]=l[u]||{_errors:[]},l=l[u],c++}}},"processError");return n(this),a}static assert(e){if(!(e instanceof In))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,A.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},a=[];for(let n of this.issues)if(n.path.length>0){let o=n.path[0];r[o]=r[o]||[],r[o].push(e(n))}else a.push(e(n));return{formErrors:a,fieldErrors:r}}get formErrors(){return this.flatten()}};oe.create=t=>new oe(t);var yu=i((t,e)=>{let r;switch(t.code){case h.invalid_type:t.received===g.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case h.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,A.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:r=`Unrecognized key(s) in object: ${A.joinValues(t.keys,", ")}`;break;case h.invalid_union:r="Invalid input";break;case h.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${A.joinValues(t.options)}`;break;case h.invalid_enum_value:r=`Invalid enum value. Expected ${A.joinValues(t.options)}, received '${t.received}'`;break;case h.invalid_arguments:r="Invalid function arguments";break;case h.invalid_return_type:r="Invalid function return type";break;case h.invalid_date:r="Invalid date";break;case h.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:A.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case h.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case h.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case h.custom:r="Invalid input";break;case h.invalid_intersection_types:r="Intersection results could not be merged";break;case h.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case h.not_finite:r="Number must be finite";break;default:r=e.defaultError,A.assertNever(t)}return{message:r}},"errorMap"),Ve=yu,mn=Ve;function _u(t){mn=t}i(_u,"setErrorMap");function It(){return mn}i(It,"getErrorMap");var Dt=i(t=>{let{data:e,path:r,errorMaps:a,issueData:n}=t,o=[...r,...n.path||[]],s={...n,path:o};if(n.message!==void 0)return{...n,path:o,message:n.message};let l="",c=a.filter(u=>!!u).slice().reverse();for(let u of c)l=u(s,{data:e,defaultError:l}).message;return{...n,path:o,message:l}},"makeIssue"),vu=[];function m(t,e){let r=It(),a=Dt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Ve?void 0:Ve].filter(n=>!!n)});t.common.issues.push(a)}i(m,"addIssueToContext");var ee=class Dn{static{i(this,"_ParseStatus")}constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let a=[];for(let n of r){if(n.status==="aborted")return v;n.status==="dirty"&&e.dirty(),a.push(n.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,r){let a=[];for(let n of r){let o=await n.key,s=await n.value;a.push({key:o,value:s})}return Dn.mergeObjectSync(e,a)}static mergeObjectSync(e,r){let a={};for(let n of r){let{key:o,value:s}=n;if(o.status==="aborted"||s.status==="aborted")return v;o.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof s.value<"u"||n.alwaysSet)&&(a[o.value]=s.value)}return{status:e.value,value:a}}},v=Object.freeze({status:"aborted"}),We=i(t=>({status:"dirty",value:t}),"DIRTY"),J=i(t=>({status:"valid",value:t}),"OK"),xr=i(t=>t.status==="aborted","isAborted"),kr=i(t=>t.status==="dirty","isDirty"),Ne=i(t=>t.status==="valid","isValid"),it=i(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),_;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(_||(_={}));var he=class{static{i(this,"ParseInputLazyPath")}constructor(t,e,r,a){this._cachedPath=[],this.parent=t,this.data=e,this._path=r,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},gn=i((t,e)=>{if(Ne(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new oe(t.common.issues);return this._error=r,this._error}}},"handleResult");function S(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:a,description:n}=t;if(e&&(r||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:i((o,s)=>{let{message:l}=t;return o.code==="invalid_enum_value"?{message:l??s.defaultError}:typeof s.data>"u"?{message:l??a??s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:l??r??s.defaultError}},"errorMap"),description:n}}i(S,"processCreateParams");var T=class{static{i(this,"ZodType")}get description(){return this._def.description}_getType(t){return ye(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:ye(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ee,ctx:{common:t.parent.common,data:t.data,parsedType:ye(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let e=this._parse(t);if(it(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(t){let e=this._parse(t);return Promise.resolve(e)}parse(t,e){let r=this.safeParse(t,e);if(r.success)return r.data;throw r.error}safeParse(t,e){let r={common:{issues:[],async:e?.async??!1,contextualErrorMap:e?.errorMap},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ye(t)},a=this._parseSync({data:t,path:r.path,parent:r});return gn(r,a)}"~validate"(t){let e={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ye(t)};if(!this["~standard"].async)try{let r=this._parseSync({data:t,path:[],parent:e});return Ne(r)?{value:r.value}:{issues:e.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),e.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:e}).then(r=>Ne(r)?{value:r.value}:{issues:e.common.issues})}async parseAsync(t,e){let r=await this.safeParseAsync(t,e);if(r.success)return r.data;throw r.error}async safeParseAsync(t,e){let r={common:{issues:[],contextualErrorMap:e?.errorMap,async:!0},path:e?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ye(t)},a=this._parse({data:t,path:r.path,parent:r}),n=await(it(a)?a:Promise.resolve(a));return gn(r,n)}refine(t,e){let r=i(a=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(a):e,"getIssueProperties");return this._refinement((a,n)=>{let o=t(a),s=i(()=>n.addIssue({code:h.custom,...r(a)}),"setError");return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(s(),!1)):o?!0:(s(),!1)})}refinement(t,e){return this._refinement((r,a)=>t(r)?!0:(a.addIssue(typeof e=="function"?e(r,a):e),!1))}_refinement(t){return new le({schema:this,typeName:b.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:i(e=>this["~validate"](e),"validate")}}optional(){return fe.create(this,this._def)}nullable(){return Oe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return je.create(this)}promise(){return Ke.create(this,this._def)}or(t){return pt.create([this,t],this._def)}and(t){return ht.create(this,t,this._def)}transform(t){return new le({...S(this._def),schema:this,typeName:b.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let e=typeof t=="function"?t:()=>t;return new _t({...S(this._def),innerType:this,defaultValue:e,typeName:b.ZodDefault})}brand(){return new Or({typeName:b.ZodBranded,type:this,...S(this._def)})}catch(t){let e=typeof t=="function"?t:()=>t;return new vt({...S(this._def),innerType:this,catchValue:e,typeName:b.ZodCatch})}describe(t){let e=this.constructor;return new e({...this._def,description:t})}pipe(t){return Ar.create(this,t)}readonly(){return bt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},bu=/^c[^\s-]{8,}$/i,wu=/^[0-9a-z]+$/,xu=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ku=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Su=/^[a-z0-9_-]{21}$/i,Tu=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ou=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Au=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Eu="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Sr,Cu=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Pu=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Ru=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Nu=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,$u=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ju=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,yn="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Iu=new RegExp(`^${yn}$`);function _n(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}i(_n,"timeRegexSource");function Du(t){return new RegExp(`^${_n(t)}$`)}i(Du,"timeRegex");function vn(t){let e=`${yn}T${_n(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}i(vn,"datetimeRegex");function Zu(t,e){return!!((e==="v4"||!e)&&Cu.test(t)||(e==="v6"||!e)&&Ru.test(t))}i(Zu,"isValidIP");function Lu(t,e){if(!Tu.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(a));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}i(Lu,"isValidJWT");function Mu(t,e){return!!((e==="v4"||!e)&&Pu.test(t)||(e==="v6"||!e)&&Nu.test(t))}i(Mu,"isValidCidr");var He=class wt extends T{static{i(this,"_ZodString")}_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){let n=this._getOrReturnCtx(e);return m(n,{code:h.invalid_type,expected:g.string,received:n.parsedType}),v}let r=new ee,a;for(let n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(a=this._getOrReturnCtx(e,a),m(a,{code:h.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind==="max")e.data.length>n.value&&(a=this._getOrReturnCtx(e,a),m(a,{code:h.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),r.dirty());else if(n.kind==="length"){let o=e.data.length>n.value,s=e.data.length<n.value;(o||s)&&(a=this._getOrReturnCtx(e,a),o?m(a,{code:h.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):s&&m(a,{code:h.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),r.dirty())}else if(n.kind==="email")Au.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"email",code:h.invalid_string,message:n.message}),r.dirty());else if(n.kind==="emoji")Sr||(Sr=new RegExp(Eu,"u")),Sr.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"emoji",code:h.invalid_string,message:n.message}),r.dirty());else if(n.kind==="uuid")ku.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"uuid",code:h.invalid_string,message:n.message}),r.dirty());else if(n.kind==="nanoid")Su.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"nanoid",code:h.invalid_string,message:n.message}),r.dirty());else if(n.kind==="cuid")bu.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"cuid",code:h.invalid_string,message:n.message}),r.dirty());else if(n.kind==="cuid2")wu.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"cuid2",code:h.invalid_string,message:n.message}),r.dirty());else if(n.kind==="ulid")xu.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"ulid",code:h.invalid_string,message:n.message}),r.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),m(a,{validation:"url",code:h.invalid_string,message:n.message}),r.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"regex",code:h.invalid_string,message:n.message}),r.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(a=this._getOrReturnCtx(e,a),m(a,{code:h.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),r.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(a=this._getOrReturnCtx(e,a),m(a,{code:h.invalid_string,validation:{startsWith:n.value},message:n.message}),r.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(a=this._getOrReturnCtx(e,a),m(a,{code:h.invalid_string,validation:{endsWith:n.value},message:n.message}),r.dirty()):n.kind==="datetime"?vn(n).test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{code:h.invalid_string,validation:"datetime",message:n.message}),r.dirty()):n.kind==="date"?Iu.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{code:h.invalid_string,validation:"date",message:n.message}),r.dirty()):n.kind==="time"?Du(n).test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{code:h.invalid_string,validation:"time",message:n.message}),r.dirty()):n.kind==="duration"?Ou.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"duration",code:h.invalid_string,message:n.message}),r.dirty()):n.kind==="ip"?Zu(e.data,n.version)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"ip",code:h.invalid_string,message:n.message}),r.dirty()):n.kind==="jwt"?Lu(e.data,n.alg)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"jwt",code:h.invalid_string,message:n.message}),r.dirty()):n.kind==="cidr"?Mu(e.data,n.version)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"cidr",code:h.invalid_string,message:n.message}),r.dirty()):n.kind==="base64"?$u.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"base64",code:h.invalid_string,message:n.message}),r.dirty()):n.kind==="base64url"?ju.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"base64url",code:h.invalid_string,message:n.message}),r.dirty()):A.assertNever(n);return{status:r.value,value:e.data}}_regex(e,r,a){return this.refinement(n=>e.test(n),{validation:r,code:h.invalid_string,..._.errToObj(a)})}_addCheck(e){return new wt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",..._.errToObj(e)})}url(e){return this._addCheck({kind:"url",..._.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",..._.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",..._.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",..._.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",..._.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",..._.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",..._.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",..._.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",..._.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",..._.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",..._.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",..._.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,..._.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,..._.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",..._.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,..._.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,..._.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,..._.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,..._.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,..._.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,..._.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,..._.errToObj(r)})}nonempty(e){return this.min(1,_.errToObj(e))}trim(){return new wt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new wt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new wt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};He.create=t=>new He({checks:[],typeName:b.ZodString,coerce:t?.coerce??!1,...S(t)});function Uu(t,e){let r=(t.toString().split(".")[1]||"").length,a=(e.toString().split(".")[1]||"").length,n=r>a?r:a,o=Number.parseInt(t.toFixed(n).replace(".","")),s=Number.parseInt(e.toFixed(n).replace(".",""));return o%s/10**n}i(Uu,"floatSafeRemainder");var st=class Cr extends T{static{i(this,"_ZodNumber")}constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==g.number){let n=this._getOrReturnCtx(e);return m(n,{code:h.invalid_type,expected:g.number,received:n.parsedType}),v}let r,a=new ee;for(let n of this._def.checks)n.kind==="int"?A.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:h.invalid_type,expected:"integer",received:"float",message:n.message}),a.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty()):n.kind==="multipleOf"?Uu(e.data,n.value)!==0&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:h.not_finite,message:n.message}),a.dirty()):A.assertNever(n);return{status:a.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,_.toString(r))}gt(e,r){return this.setLimit("min",e,!1,_.toString(r))}lte(e,r){return this.setLimit("max",e,!0,_.toString(r))}lt(e,r){return this.setLimit("max",e,!1,_.toString(r))}setLimit(e,r,a,n){return new Cr({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:a,message:_.toString(n)}]})}_addCheck(e){return new Cr({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:_.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:_.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:_.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:_.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:_.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&A.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(r===null||a.value>r)&&(r=a.value):a.kind==="max"&&(e===null||a.value<e)&&(e=a.value)}return Number.isFinite(r)&&Number.isFinite(e)}};st.create=t=>new st({checks:[],typeName:b.ZodNumber,coerce:t?.coerce||!1,...S(t)});var ot=class Pr extends T{static{i(this,"_ZodBigInt")}constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==g.bigint)return this._getInvalidInput(e);let r,a=new ee;for(let n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):A.assertNever(n);return{status:a.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return m(r,{code:h.invalid_type,expected:g.bigint,received:r.parsedType}),v}gte(e,r){return this.setLimit("min",e,!0,_.toString(r))}gt(e,r){return this.setLimit("min",e,!1,_.toString(r))}lte(e,r){return this.setLimit("max",e,!0,_.toString(r))}lt(e,r){return this.setLimit("max",e,!1,_.toString(r))}setLimit(e,r,a,n){return new Pr({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:a,message:_.toString(n)}]})}_addCheck(e){return new Pr({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:_.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};ot.create=t=>new ot({checks:[],typeName:b.ZodBigInt,coerce:t?.coerce??!1,...S(t)});var lt=class extends T{static{i(this,"ZodBoolean")}_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==g.boolean){let e=this._getOrReturnCtx(t);return m(e,{code:h.invalid_type,expected:g.boolean,received:e.parsedType}),v}return J(t.data)}};lt.create=t=>new lt({typeName:b.ZodBoolean,coerce:t?.coerce||!1,...S(t)});var ct=class Zn extends T{static{i(this,"_ZodDate")}_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){let n=this._getOrReturnCtx(e);return m(n,{code:h.invalid_type,expected:g.date,received:n.parsedType}),v}if(Number.isNaN(e.data.getTime())){let n=this._getOrReturnCtx(e);return m(n,{code:h.invalid_date}),v}let r=new ee,a;for(let n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(a=this._getOrReturnCtx(e,a),m(a,{code:h.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),r.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(a=this._getOrReturnCtx(e,a),m(a,{code:h.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),r.dirty()):A.assertNever(n);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Zn({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:_.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:_.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};ct.create=t=>new ct({checks:[],coerce:t?.coerce||!1,typeName:b.ZodDate,...S(t)});var Zt=class extends T{static{i(this,"ZodSymbol")}_parse(t){if(this._getType(t)!==g.symbol){let e=this._getOrReturnCtx(t);return m(e,{code:h.invalid_type,expected:g.symbol,received:e.parsedType}),v}return J(t.data)}};Zt.create=t=>new Zt({typeName:b.ZodSymbol,...S(t)});var dt=class extends T{static{i(this,"ZodUndefined")}_parse(t){if(this._getType(t)!==g.undefined){let e=this._getOrReturnCtx(t);return m(e,{code:h.invalid_type,expected:g.undefined,received:e.parsedType}),v}return J(t.data)}};dt.create=t=>new dt({typeName:b.ZodUndefined,...S(t)});var ut=class extends T{static{i(this,"ZodNull")}_parse(t){if(this._getType(t)!==g.null){let e=this._getOrReturnCtx(t);return m(e,{code:h.invalid_type,expected:g.null,received:e.parsedType}),v}return J(t.data)}};ut.create=t=>new ut({typeName:b.ZodNull,...S(t)});var Ge=class extends T{static{i(this,"ZodAny")}constructor(){super(...arguments),this._any=!0}_parse(t){return J(t.data)}};Ge.create=t=>new Ge({typeName:b.ZodAny,...S(t)});var $e=class extends T{static{i(this,"ZodUnknown")}constructor(){super(...arguments),this._unknown=!0}_parse(t){return J(t.data)}};$e.create=t=>new $e({typeName:b.ZodUnknown,...S(t)});var _e=class extends T{static{i(this,"ZodNever")}_parse(t){let e=this._getOrReturnCtx(t);return m(e,{code:h.invalid_type,expected:g.never,received:e.parsedType}),v}};_e.create=t=>new _e({typeName:b.ZodNever,...S(t)});var Lt=class extends T{static{i(this,"ZodVoid")}_parse(t){if(this._getType(t)!==g.undefined){let e=this._getOrReturnCtx(t);return m(e,{code:h.invalid_type,expected:g.void,received:e.parsedType}),v}return J(t.data)}};Lt.create=t=>new Lt({typeName:b.ZodVoid,...S(t)});var je=class Ft extends T{static{i(this,"_ZodArray")}_parse(e){let{ctx:r,status:a}=this._processInputParams(e),n=this._def;if(r.parsedType!==g.array)return m(r,{code:h.invalid_type,expected:g.array,received:r.parsedType}),v;if(n.exactLength!==null){let s=r.data.length>n.exactLength.value,l=r.data.length<n.exactLength.value;(s||l)&&(m(r,{code:s?h.too_big:h.too_small,minimum:l?n.exactLength.value:void 0,maximum:s?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),a.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(m(r,{code:h.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),a.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(m(r,{code:h.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),a.dirty()),r.common.async)return Promise.all([...r.data].map((s,l)=>n.type._parseAsync(new he(r,s,r.path,l)))).then(s=>ee.mergeArray(a,s));let o=[...r.data].map((s,l)=>n.type._parseSync(new he(r,s,r.path,l)));return ee.mergeArray(a,o)}get element(){return this._def.type}min(e,r){return new Ft({...this._def,minLength:{value:e,message:_.toString(r)}})}max(e,r){return new Ft({...this._def,maxLength:{value:e,message:_.toString(r)}})}length(e,r){return new Ft({...this._def,exactLength:{value:e,message:_.toString(r)}})}nonempty(e){return this.min(1,e)}};je.create=(t,e)=>new je({type:t,minLength:null,maxLength:null,exactLength:null,typeName:b.ZodArray,...S(e)});function qe(t){if(t instanceof se){let e={};for(let r in t.shape){let a=t.shape[r];e[r]=fe.create(qe(a))}return new se({...t._def,shape:i(()=>e,"shape")})}else return t instanceof je?new je({...t._def,type:qe(t.element)}):t instanceof fe?fe.create(qe(t.unwrap())):t instanceof Oe?Oe.create(qe(t.unwrap())):t instanceof Te?Te.create(t.items.map(e=>qe(e))):t}i(qe,"deepPartialify");var se=class ce extends T{static{i(this,"_ZodObject")}constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=A.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==g.object){let c=this._getOrReturnCtx(e);return m(c,{code:h.invalid_type,expected:g.object,received:c.parsedType}),v}let{status:r,ctx:a}=this._processInputParams(e),{shape:n,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof _e&&this._def.unknownKeys==="strip"))for(let c in a.data)o.includes(c)||s.push(c);let l=[];for(let c of o){let u=n[c],y=a.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new he(a,y,a.path,c)),alwaysSet:c in a.data})}if(this._def.catchall instanceof _e){let c=this._def.unknownKeys;if(c==="passthrough")for(let u of s)l.push({key:{status:"valid",value:u},value:{status:"valid",value:a.data[u]}});else if(c==="strict")s.length>0&&(m(a,{code:h.unrecognized_keys,keys:s}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let u of s){let y=a.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new he(a,y,a.path,u)),alwaysSet:u in a.data})}}return a.common.async?Promise.resolve().then(async()=>{let c=[];for(let u of l){let y=await u.key,d=await u.value;c.push({key:y,value:d,alwaysSet:u.alwaysSet})}return c}).then(c=>ee.mergeObjectSync(r,c)):ee.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return _.errToObj,new ce({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:i((r,a)=>{let n=this._def.errorMap?.(r,a).message??a.defaultError;return r.code==="unrecognized_keys"?{message:_.errToObj(e).message??n}:{message:n}},"errorMap")}:{}})}strip(){return new ce({...this._def,unknownKeys:"strip"})}passthrough(){return new ce({...this._def,unknownKeys:"passthrough"})}extend(e){return new ce({...this._def,shape:i(()=>({...this._def.shape(),...e}),"shape")})}merge(e){return new ce({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:i(()=>({...this._def.shape(),...e._def.shape()}),"shape"),typeName:b.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new ce({...this._def,catchall:e})}pick(e){let r={};for(let a of A.objectKeys(e))e[a]&&this.shape[a]&&(r[a]=this.shape[a]);return new ce({...this._def,shape:i(()=>r,"shape")})}omit(e){let r={};for(let a of A.objectKeys(this.shape))e[a]||(r[a]=this.shape[a]);return new ce({...this._def,shape:i(()=>r,"shape")})}deepPartial(){return qe(this)}partial(e){let r={};for(let a of A.objectKeys(this.shape)){let n=this.shape[a];e&&!e[a]?r[a]=n:r[a]=n.optional()}return new ce({...this._def,shape:i(()=>r,"shape")})}required(e){let r={};for(let a of A.objectKeys(this.shape))if(e&&!e[a])r[a]=this.shape[a];else{let n=this.shape[a];for(;n instanceof fe;)n=n._def.innerType;r[a]=n}return new ce({...this._def,shape:i(()=>r,"shape")})}keyof(){return kn(A.objectKeys(this.shape))}};se.create=(t,e)=>new se({shape:i(()=>t,"shape"),unknownKeys:"strip",catchall:_e.create(),typeName:b.ZodObject,...S(e)}),se.strictCreate=(t,e)=>new se({shape:i(()=>t,"shape"),unknownKeys:"strict",catchall:_e.create(),typeName:b.ZodObject,...S(e)}),se.lazycreate=(t,e)=>new se({shape:t,unknownKeys:"strip",catchall:_e.create(),typeName:b.ZodObject,...S(e)});var pt=class extends T{static{i(this,"ZodUnion")}_parse(t){let{ctx:e}=this._processInputParams(t),r=this._def.options;function a(n){for(let s of n)if(s.result.status==="valid")return s.result;for(let s of n)if(s.result.status==="dirty")return e.common.issues.push(...s.ctx.common.issues),s.result;let o=n.map(s=>new oe(s.ctx.common.issues));return m(e,{code:h.invalid_union,unionErrors:o}),v}if(i(a,"handleResults"),e.common.async)return Promise.all(r.map(async n=>{let o={...e,common:{...e.common,issues:[]},parent:null};return{result:await n._parseAsync({data:e.data,path:e.path,parent:o}),ctx:o}})).then(a);{let n,o=[];for(let l of r){let c={...e,common:{...e.common,issues:[]},parent:null},u=l._parseSync({data:e.data,path:e.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!n&&(n={result:u,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(n)return e.common.issues.push(...n.ctx.common.issues),n.result;let s=o.map(l=>new oe(l));return m(e,{code:h.invalid_union,unionErrors:s}),v}}get options(){return this._def.options}};pt.create=(t,e)=>new pt({options:t,typeName:b.ZodUnion,...S(e)});var Se=i(t=>t instanceof ft?Se(t.schema):t instanceof le?Se(t.innerType()):t instanceof mt?[t.value]:t instanceof gt?t.options:t instanceof yt?A.objectValues(t.enum):t instanceof _t?Se(t._def.innerType):t instanceof dt?[void 0]:t instanceof ut?[null]:t instanceof fe?[void 0,...Se(t.unwrap())]:t instanceof Oe?[null,...Se(t.unwrap())]:t instanceof Or||t instanceof bt?Se(t.unwrap()):t instanceof vt?Se(t._def.innerType):[],"getDiscriminator"),bn=class Ln extends T{static{i(this,"_ZodDiscriminatedUnion")}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==g.object)return m(r,{code:h.invalid_type,expected:g.object,received:r.parsedType}),v;let a=this.discriminator,n=r.data[a],o=this.optionsMap.get(n);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(m(r,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,a){let n=new Map;for(let o of r){let s=Se(o.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let l of s){if(n.has(l))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(l)}`);n.set(l,o)}}return new Ln({typeName:b.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:n,...S(a)})}};function Tr(t,e){let r=ye(t),a=ye(e);if(t===e)return{valid:!0,data:t};if(r===g.object&&a===g.object){let n=A.objectKeys(e),o=A.objectKeys(t).filter(l=>n.indexOf(l)!==-1),s={...t,...e};for(let l of o){let c=Tr(t[l],e[l]);if(!c.valid)return{valid:!1};s[l]=c.data}return{valid:!0,data:s}}else if(r===g.array&&a===g.array){if(t.length!==e.length)return{valid:!1};let n=[];for(let o=0;o<t.length;o++){let s=t[o],l=e[o],c=Tr(s,l);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return r===g.date&&a===g.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}i(Tr,"mergeValues");var ht=class extends T{static{i(this,"ZodIntersection")}_parse(t){let{status:e,ctx:r}=this._processInputParams(t),a=i((n,o)=>{if(xr(n)||xr(o))return v;let s=Tr(n.value,o.value);return s.valid?((kr(n)||kr(o))&&e.dirty(),{status:e.value,value:s.data}):(m(r,{code:h.invalid_intersection_types}),v)},"handleParsed");return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([n,o])=>a(n,o)):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};ht.create=(t,e,r)=>new ht({left:t,right:e,typeName:b.ZodIntersection,...S(r)});var Te=class Mn extends T{static{i(this,"_ZodTuple")}_parse(e){let{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==g.array)return m(a,{code:h.invalid_type,expected:g.array,received:a.parsedType}),v;if(a.data.length<this._def.items.length)return m(a,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&a.data.length>this._def.items.length&&(m(a,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let n=[...a.data].map((o,s)=>{let l=this._def.items[s]||this._def.rest;return l?l._parse(new he(a,o,a.path,s)):null}).filter(o=>!!o);return a.common.async?Promise.all(n).then(o=>ee.mergeArray(r,o)):ee.mergeArray(r,n)}get items(){return this._def.items}rest(e){return new Mn({...this._def,rest:e})}};Te.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Te({items:t,typeName:b.ZodTuple,rest:null,...S(e)})};var wn=class Rr extends T{static{i(this,"_ZodRecord")}get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==g.object)return m(a,{code:h.invalid_type,expected:g.object,received:a.parsedType}),v;let n=[],o=this._def.keyType,s=this._def.valueType;for(let l in a.data)n.push({key:o._parse(new he(a,l,a.path,l)),value:s._parse(new he(a,a.data[l],a.path,l)),alwaysSet:l in a.data});return a.common.async?ee.mergeObjectAsync(r,n):ee.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(e,r,a){return r instanceof T?new Rr({keyType:e,valueType:r,typeName:b.ZodRecord,...S(a)}):new Rr({keyType:He.create(),valueType:e,typeName:b.ZodRecord,...S(r)})}},Mt=class extends T{static{i(this,"ZodMap")}get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:e,ctx:r}=this._processInputParams(t);if(r.parsedType!==g.map)return m(r,{code:h.invalid_type,expected:g.map,received:r.parsedType}),v;let a=this._def.keyType,n=this._def.valueType,o=[...r.data.entries()].map(([s,l],c)=>({key:a._parse(new he(r,s,r.path,[c,"key"])),value:n._parse(new he(r,l,r.path,[c,"value"]))}));if(r.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let l of o){let c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return v;(c.status==="dirty"||u.status==="dirty")&&e.dirty(),s.set(c.value,u.value)}return{status:e.value,value:s}})}else{let s=new Map;for(let l of o){let c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return v;(c.status==="dirty"||u.status==="dirty")&&e.dirty(),s.set(c.value,u.value)}return{status:e.value,value:s}}}};Mt.create=(t,e,r)=>new Mt({valueType:e,keyType:t,typeName:b.ZodMap,...S(r)});var Ut=class Nr extends T{static{i(this,"_ZodSet")}_parse(e){let{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==g.set)return m(a,{code:h.invalid_type,expected:g.set,received:a.parsedType}),v;let n=this._def;n.minSize!==null&&a.data.size<n.minSize.value&&(m(a,{code:h.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&a.data.size>n.maxSize.value&&(m(a,{code:h.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());let o=this._def.valueType;function s(c){let u=new Set;for(let y of c){if(y.status==="aborted")return v;y.status==="dirty"&&r.dirty(),u.add(y.value)}return{status:r.value,value:u}}i(s,"finalizeSet");let l=[...a.data.values()].map((c,u)=>o._parse(new he(a,c,a.path,u)));return a.common.async?Promise.all(l).then(c=>s(c)):s(l)}min(e,r){return new Nr({...this._def,minSize:{value:e,message:_.toString(r)}})}max(e,r){return new Nr({...this._def,maxSize:{value:e,message:_.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Ut.create=(t,e)=>new Ut({valueType:t,minSize:null,maxSize:null,typeName:b.ZodSet,...S(e)});var xn=class zt extends T{static{i(this,"_ZodFunction")}constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==g.function)return m(r,{code:h.invalid_type,expected:g.function,received:r.parsedType}),v;function a(l,c){return Dt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,It(),Ve].filter(u=>!!u),issueData:{code:h.invalid_arguments,argumentsError:c}})}i(a,"makeArgsIssue");function n(l,c){return Dt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,It(),Ve].filter(u=>!!u),issueData:{code:h.invalid_return_type,returnTypeError:c}})}i(n,"makeReturnsIssue");let o={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof Ke){let l=this;return J(async function(...c){let u=new oe([]),y=await l._def.args.parseAsync(c,o).catch(O=>{throw u.addIssue(a(c,O)),u}),d=await Reflect.apply(s,this,y);return await l._def.returns._def.type.parseAsync(d,o).catch(O=>{throw u.addIssue(n(d,O)),u})})}else{let l=this;return J(function(...c){let u=l._def.args.safeParse(c,o);if(!u.success)throw new oe([a(c,u.error)]);let y=Reflect.apply(s,this,u.data),d=l._def.returns.safeParse(y,o);if(!d.success)throw new oe([n(y,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new zt({...this._def,args:Te.create(e).rest($e.create())})}returns(e){return new zt({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,a){return new zt({args:e||Te.create([]).rest($e.create()),returns:r||$e.create(),typeName:b.ZodFunction,...S(a)})}},ft=class extends T{static{i(this,"ZodLazy")}get schema(){return this._def.getter()}_parse(t){let{ctx:e}=this._processInputParams(t);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}};ft.create=(t,e)=>new ft({getter:t,typeName:b.ZodLazy,...S(e)});var mt=class extends T{static{i(this,"ZodLiteral")}_parse(t){if(t.data!==this._def.value){let e=this._getOrReturnCtx(t);return m(e,{received:e.data,code:h.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:t.data}}get value(){return this._def.value}};mt.create=(t,e)=>new mt({value:t,typeName:b.ZodLiteral,...S(e)});function kn(t,e){return new gt({values:t,typeName:b.ZodEnum,...S(e)})}i(kn,"createZodEnum");var gt=class $r extends T{static{i(this,"_ZodEnum")}_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),a=this._def.values;return m(r,{expected:A.joinValues(a),received:r.parsedType,code:h.invalid_type}),v}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),a=this._def.values;return m(r,{received:r.data,code:h.invalid_enum_value,options:a}),v}return J(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return $r.create(e,{...this._def,...r})}exclude(e,r=this._def){return $r.create(this.options.filter(a=>!e.includes(a)),{...this._def,...r})}};gt.create=kn;var yt=class extends T{static{i(this,"ZodNativeEnum")}_parse(t){let e=A.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==g.string&&r.parsedType!==g.number){let a=A.objectValues(e);return m(r,{expected:A.joinValues(a),received:r.parsedType,code:h.invalid_type}),v}if(this._cache||(this._cache=new Set(A.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let a=A.objectValues(e);return m(r,{received:r.data,code:h.invalid_enum_value,options:a}),v}return J(t.data)}get enum(){return this._def.values}};yt.create=(t,e)=>new yt({values:t,typeName:b.ZodNativeEnum,...S(e)});var Ke=class extends T{static{i(this,"ZodPromise")}unwrap(){return this._def.type}_parse(t){let{ctx:e}=this._processInputParams(t);if(e.parsedType!==g.promise&&e.common.async===!1)return m(e,{code:h.invalid_type,expected:g.promise,received:e.parsedType}),v;let r=e.parsedType===g.promise?e.data:Promise.resolve(e.data);return J(r.then(a=>this._def.type.parseAsync(a,{path:e.path,errorMap:e.common.contextualErrorMap})))}};Ke.create=(t,e)=>new Ke({type:t,typeName:b.ZodPromise,...S(e)});var le=class extends T{static{i(this,"ZodEffects")}innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===b.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:e,ctx:r}=this._processInputParams(t),a=this._def.effect||null,n={addIssue:i(o=>{m(r,o),o.fatal?e.abort():e.dirty()},"addIssue"),get path(){return r.path}};if(n.addIssue=n.addIssue.bind(n),a.type==="preprocess"){let o=a.transform(r.data,n);if(r.common.async)return Promise.resolve(o).then(async s=>{if(e.value==="aborted")return v;let l=await this._def.schema._parseAsync({data:s,path:r.path,parent:r});return l.status==="aborted"?v:l.status==="dirty"||e.value==="dirty"?We(l.value):l});{if(e.value==="aborted")return v;let s=this._def.schema._parseSync({data:o,path:r.path,parent:r});return s.status==="aborted"?v:s.status==="dirty"||e.value==="dirty"?We(s.value):s}}if(a.type==="refinement"){let o=i(s=>{let l=a.refinement(s,n);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s},"executeRefinement");if(r.common.async===!1){let s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?v:(s.status==="dirty"&&e.dirty(),o(s.value),{status:e.value,value:s.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(s=>s.status==="aborted"?v:(s.status==="dirty"&&e.dirty(),o(s.value).then(()=>({status:e.value,value:s.value}))))}if(a.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ne(o))return v;let s=a.transform(o.value,n);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:s}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Ne(o)?Promise.resolve(a.transform(o.value,n)).then(s=>({status:e.value,value:s})):v);A.assertNever(a)}};le.create=(t,e,r)=>new le({schema:t,typeName:b.ZodEffects,effect:e,...S(r)}),le.createWithPreprocess=(t,e,r)=>new le({schema:e,effect:{type:"preprocess",transform:t},typeName:b.ZodEffects,...S(r)});var fe=class extends T{static{i(this,"ZodOptional")}_parse(t){return this._getType(t)===g.undefined?J(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};fe.create=(t,e)=>new fe({innerType:t,typeName:b.ZodOptional,...S(e)});var Oe=class extends T{static{i(this,"ZodNullable")}_parse(t){return this._getType(t)===g.null?J(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Oe.create=(t,e)=>new Oe({innerType:t,typeName:b.ZodNullable,...S(e)});var _t=class extends T{static{i(this,"ZodDefault")}_parse(t){let{ctx:e}=this._processInputParams(t),r=e.data;return e.parsedType===g.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:e.path,parent:e})}removeDefault(){return this._def.innerType}};_t.create=(t,e)=>new _t({innerType:t,typeName:b.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...S(e)});var vt=class extends T{static{i(this,"ZodCatch")}_parse(t){let{ctx:e}=this._processInputParams(t),r={...e,common:{...e.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return it(a)?a.then(n=>({status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new oe(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new oe(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};vt.create=(t,e)=>new vt({innerType:t,typeName:b.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...S(e)});var Bt=class extends T{static{i(this,"ZodNaN")}_parse(t){if(this._getType(t)!==g.nan){let e=this._getOrReturnCtx(t);return m(e,{code:h.invalid_type,expected:g.nan,received:e.parsedType}),v}return{status:"valid",value:t.data}}};Bt.create=t=>new Bt({typeName:b.ZodNaN,...S(t)});var Bu=Symbol("zod_brand"),Or=class extends T{static{i(this,"ZodBranded")}_parse(t){let{ctx:e}=this._processInputParams(t),r=e.data;return this._def.type._parse({data:r,path:e.path,parent:e})}unwrap(){return this._def.type}},Ar=class Un extends T{static{i(this,"_ZodPipeline")}_parse(e){let{status:r,ctx:a}=this._processInputParams(e);if(a.common.async)return(async()=>{let n=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return n.status==="aborted"?v:n.status==="dirty"?(r.dirty(),We(n.value)):this._def.out._parseAsync({data:n.value,path:a.path,parent:a})})();{let n=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return n.status==="aborted"?v:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:a.path,parent:a})}}static create(e,r){return new Un({in:e,out:r,typeName:b.ZodPipeline})}},bt=class extends T{static{i(this,"ZodReadonly")}_parse(t){let e=this._def.innerType._parse(t),r=i(a=>(Ne(a)&&(a.value=Object.freeze(a.value)),a),"freeze");return it(e)?e.then(a=>r(a)):r(e)}unwrap(){return this._def.innerType}};bt.create=(t,e)=>new bt({innerType:t,typeName:b.ZodReadonly,...S(e)});function Sn(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}i(Sn,"cleanParams");function Tn(t,e={},r){return t?Ge.create().superRefine((a,n)=>{let o=t(a);if(o instanceof Promise)return o.then(s=>{if(!s){let l=Sn(e,a),c=l.fatal??r??!0;n.addIssue({code:"custom",...l,fatal:c})}});if(!o){let s=Sn(e,a),l=s.fatal??r??!0;n.addIssue({code:"custom",...s,fatal:l})}}):Ge.create()}i(Tn,"custom");var Fu={object:se.lazycreate},b;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(b||(b={}));var zu=i((t,e={message:`Input not instance of ${t.name}`})=>Tn(r=>r instanceof t,e),"instanceOfType"),On=He.create,An=st.create,Vu=Bt.create,Wu=ot.create,En=lt.create,Hu=ct.create,Gu=Zt.create,qu=dt.create,Ku=ut.create,Yu=Ge.create,Xu=$e.create,Ju=_e.create,Qu=Lt.create,ep=je.create,tp=se.create,rp=se.strictCreate,ap=pt.create,np=bn.create,ip=ht.create,sp=Te.create,op=wn.create,lp=Mt.create,cp=Ut.create,dp=xn.create,up=ft.create,pp=mt.create,hp=gt.create,fp=yt.create,mp=Ke.create,Cn=le.create,gp=fe.create,yp=Oe.create,_p=le.createWithPreprocess,vp=Ar.create,bp=i(()=>On().optional(),"ostring"),wp=i(()=>An().optional(),"onumber"),xp=i(()=>En().optional(),"oboolean"),kp={string:i((t=>He.create({...t,coerce:!0})),"string"),number:i((t=>st.create({...t,coerce:!0})),"number"),boolean:i((t=>lt.create({...t,coerce:!0})),"boolean"),bigint:i((t=>ot.create({...t,coerce:!0})),"bigint"),date:i((t=>ct.create({...t,coerce:!0})),"date")},Sp=v,Pn=N.string().refine(t=>{if(t.includes("://")||t.includes("/")||t.includes(":"))return!1;if(t==="localhost")return!0;if(t.startsWith("*.")){let e=t.slice(2);if(!e.includes(".")||e.startsWith(".")||e.endsWith("."))return!1;let r=e.split(".");return r.length>=2&&r.every(a=>a.length>0)}return t.includes("*")?!1:t.includes(".")&&!t.startsWith(".")&&!t.endsWith(".")},{message:'Invalid domain pattern. Must be a valid domain (e.g., "example.com") or wildcard (e.g., "*.example.com"). Overly broad patterns like "*.com" or "*" are not allowed for security reasons.'}),Er=N.string().min(1,"Path cannot be empty"),Rn=N.object({allowedDomains:N.array(Pn).describe('List of allowed domains (e.g., ["github.com", "*.npmjs.org"])'),deniedDomains:N.array(Pn).describe("List of denied domains"),allowUnixSockets:N.array(N.string()).optional().describe("Unix socket paths that are allowed (macOS only)"),allowAllUnixSockets:N.boolean().optional().describe("Allow ALL Unix sockets (Linux only - disables Unix socket blocking)"),allowLocalBinding:N.boolean().optional().describe("Whether to allow binding to local ports (default: false)"),httpProxyPort:N.number().int().min(1).max(65535).optional().describe("Port of an external HTTP proxy to use instead of starting a local one. When provided, the library will skip starting its own HTTP proxy and use this port. The external proxy must handle domain filtering."),socksProxyPort:N.number().int().min(1).max(65535).optional().describe("Port of an external SOCKS proxy to use instead of starting a local one. When provided, the library will skip starting its own SOCKS proxy and use this port. The external proxy must handle domain filtering.")}),Nn=N.object({denyRead:N.array(Er).describe("Paths denied for reading"),allowWrite:N.array(Er).describe("Paths allowed for writing"),denyWrite:N.array(Er).describe("Paths denied for writing (takes precedence over allowWrite)"),allowGitConfig:N.boolean().optional().describe("Allow writes to .git/config files (default: false). Enables git remote URL updates while keeping .git/hooks protected.")}),$n=N.record(N.string(),N.array(N.string())).describe('Map of command patterns to filesystem paths to ignore violations for. Use "*" to match all commands'),jn=N.object({command:N.string().describe('The ripgrep command to execute (e.g., "rg", "claude")'),args:N.array(N.string()).optional().describe('Additional arguments to pass before ripgrep args (e.g., ["--ripgrep"])')}),Tp=N.object({bpfPath:N.string().optional().describe("Path to the unix-block.bpf filter file"),applyPath:N.string().optional().describe("Path to the apply-seccomp binary")}),Op=N.object({network:Rn.describe("Network restrictions configuration"),filesystem:Nn.describe("Filesystem restrictions configuration"),ignoreViolations:$n.optional().describe("Optional configuration for ignoring specific violations"),enableWeakerNestedSandbox:N.boolean().optional().describe("Enable weaker nested sandbox mode (for Docker environments)"),ripgrep:jn.optional().describe('Custom ripgrep configuration (default: { command: "rg" })'),mandatoryDenySearchDepth:N.number().int().min(1).max(10).optional().describe("Maximum directory depth to search for dangerous files on Linux (default: 3). Higher values provide more protection but slower performance."),allowPty:N.boolean().optional().describe("Allow pseudo-terminal (pty) operations (macOS only)"),seccomp:Tp.optional().describe("Custom seccomp binary paths (Linux only).")});export{Nn as FilesystemConfigSchema,$n as IgnoreViolationsConfigSchema,Rn as NetworkConfigSchema,jn as RipgrepConfigSchema,mu as SandboxManager,Op as SandboxRuntimeConfigSchema,Xa as SandboxViolationStore,Pt as getDefaultWritePaths};
@@ -1 +0,0 @@
1
- var Ft=Object.defineProperty;var S=(t,e)=>Ft(t,"name",{value:e,configurable:!0});import{createRequire as Ht}from"node:module";const ve=Ht(import.meta.url);import{ARMIN_HEIGHT as zt,ARMIN_WIDTH as Vt,isArminPixel as Zt}from"./chunk-WXULTH2D.js";import{backgroundAnsi as Wt,colorToRgb as Bt,foregroundAnsi as Gt,formatKeyText as Kt,getKeybindings as St,indexedColor as qt,rgbColor as $t,theme as G,visibleWidth as Jt}from"./chunk-HC56T2OZ.js";import"./chunk-S3GGRYIO.js";import"./chunk-4L3WN2XY.js";var it=.7,W=.1,nt=1.3,jt=.1;function Yt(t,e,r,n){let i=[];for(let a=0;a<e;a++)for(let c=0;c<t;c++){let y=r(c,a);y&&i.push({home:[c,a,0],color:y})}return{columns:t,rows:e,blocks:i,cameraDistance:n.cameraDistance,radius:Math.hypot(t/2,e/2,1+it/2),widthShare:n.widthShare,puzzleMoves:S(a=>n.puzzleMoves(a,i.length),"puzzleMoves"),origin:n.origin}}S(Yt,"createModel");var Qt=[228,138,122],te=[79,142,179],ee=[234,182,93],re=["ccc.","b.c.","bb.y","b..y"],ie={c:Qt,b:te,y:ee};function ne(t){return Yt(4,4,(e,r)=>ie[re[r][e]],{cameraDistance:10,widthShare:.35,puzzleMoves:S(e=>e<.4?2:1,"puzzleMoves"),origin:t})}S(ne,"piLogoModel");function ae(t){return Yt(Vt,zt,(e,r)=>Zt(e,r)?t:void 0,{cameraDistance:80,widthShare:.45,puzzleMoves:S((e,r)=>Math.round(r*(.03+e*.04)),"puzzleMoves"),origin:void 0})}S(ae,"arminModel");var at=W+nt+3,K=.3,Q=12,lt=1,_t=.6,mt=K*Q+lt+_t,le=[[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]];function se(t,e){let{columns:r,rows:n}=t,i=t.blocks.map(l=>l.home),a=[i],c=new Set,y=e*7919+1,o=S(()=>tt(y++),"next"),f=S(([l,M,h])=>((h+1)*n+M)*r+l,"key");for(let l=0;l<Q;l++){let M=new Set(i.map(f)),h=[...i],d=new Set,Y=t.puzzleMoves(o());for(let x=0;x<Y;x++){let s=[];for(let _=0;_<i.length;_++){if(d.has(_))continue;let[k,X,g]=i[_];for(let[I,v,L]of le){let R=[k+I,X+v,g+L];R[0]<0||R[0]>=r||R[1]<0||R[1]>=n||R[2]<-1||R[2]>1||M.has(f(R))||s.push({block:_,target:R})}}let p=s.filter(_=>!c.has(_.block)),m=p.length>0?p:s,u=m[Math.floor(o()*m.length)];if(!u)break;M.add(f(u.target)),h[u.block]=u.target,d.add(u.block)}c.clear();for(let x of d)c.add(x);i=h,a.push(i)}return a}S(se,"shuffleSteps");var oe=1e3/30,wt=.35,Et=.55,Rt=.12,vt=W+Et+Rt+wt,he=.5,ce=1.1,me=2.5,fe=2,ue=.018,It=[[255,255,255],[170,195,255],[255,225,170],[255,190,205]],z=5,de=.3,q=6,$=3,Tt=32,Lt=8,Xt=3,ge=.5,ft=[1,8,2,16,4,32,64,128],ut=Array.from({length:256},(t,e)=>String.fromCharCode(10240+e)),J=Dt([-.45,-.6,.75]),dt=Dt([J[0],J[1],J[2]+1]);function Dt(t){let e=Math.hypot(t[0],t[1],t[2]);return[t[0]/e,t[1]/e,t[2]/e]}S(Dt,"normalize");function Z(t){return t<0?0:t>1?1:t}S(Z,"clamp01");function U(t){let e=Z(t);return e*e*e*(e*(e*6-15)+10)}S(U,"smooth");function xe(t){let e=1-Z(t);return 1-e*e*e}S(xe,"easeOut");function V(t,e,r){return[t[0]+(e[0]-t[0])*r,t[1]+(e[1]-t[1])*r,t[2]+(e[2]-t[2])*r]}S(V,"mix");function tt(t){let e=Math.imul(t^2654435769,2246822507);return e^=e>>>13,e=Math.imul(e,3266489909),e^=e>>>16,(e>>>0)/4294967296}S(tt,"hash");function kt([t,e,r]){return .2126*t+.7152*e+.0722*r>128}S(kt,"isLight");function et(t){let{r:e,g:r,b:n}=Bt(t);return[e,r,n]}S(et,"toRgb");function pe(t,e){return t.trim()===""?0:/^[.,:;'`\-_·]$/.test(t)?2:/^[\u2500-\u257f]$/.test(t)?3:4+Math.floor(e*3)}S(pe,"glyphInk");var Me=new Intl.Segmenter;function ye(t,e,r,n){let i=S(a=>et(qt(a)),"palette");return t.map(a=>{let c=[],y,o,f=!1,l=!1,M=S(Y=>{let x=Y===""?["0"]:Y.split(";");for(let s=0;s<x.length;s++){let p=x[s].split(":").map(u=>Number.parseInt(u,10)),m=p[0]??0;if(m===38||m===48){let u;if(p.length>1)u=p.slice(1).filter(k=>!Number.isNaN(k));else{let k=Number.parseInt(x[s+1]??"",10),X=k===5?2:k===2?4:1;u=x.slice(s+1,s+1+X).map(g=>Number.parseInt(g,10)),s+=X}let _;u[0]===5&&u[1]!==void 0?_=i(u[1]):u[0]===2&&u.length>=4&&(_=[u[1],u[2],u[3]]),_&&(m===38?y=_:o=_)}else m===0?(y=void 0,o=void 0,f=!1,l=!1):m===2?f=!0:m===22?f=!1:m===7?l=!0:m===27?l=!1:m>=30&&m<=37?y=i(m-30):m>=90&&m<=97?y=i(m-90+8):m===39?y=void 0:m>=40&&m<=47?o=i(m-40):m>=100&&m<=107?o=i(m-100+8):m===49&&(o=void 0)}},"applySgr"),h=S(Y=>{for(let{segment:x}of Me.segment(Y)){let s=Jt(x);if(s===0||c.length+s>e)continue;let p=y??r,m=o;l&&(p=o??n,m=y??r),f&&(p=V(p,m??n,.4));let u={text:x,width:s,fg:p,bg:m,delay:0,ink:0,seed:0};c.push(u),s===2&&c.push({...u,text:"",width:0})}},"pushText"),d=0;for(;d<a.length;){let Y=a.indexOf("\x1B",d);if(Y===-1){h(a.slice(d));break}Y>d&&h(a.slice(d,Y));let x=a[Y+1];if(x==="["){let s=Y+2;for(;s<a.length&&(a.charCodeAt(s)<64||a.charCodeAt(s)>126);)s++;a[s]==="m"&&M(a.slice(Y+2,s)),d=s+1}else if(x==="]"||x==="_"||x==="P"||x==="^"){let s=a.indexOf("\x07",Y+2),p=a.indexOf("\x1B\\",Y+2);if(s===-1&&p===-1)break;d=s!==-1&&(p===-1||s<p)?s+1:p+2}else d=Y+2}return c})}S(ye,"parseScreen");function Ae(t,e,r){let[n,i,a,c,y,o]=[Math.sin(t),Math.cos(t),Math.sin(e),Math.cos(e),Math.sin(r),Math.cos(r)],f=[i,0,n,0,1,0,-n,0,i],l=[1,0,0,0,c,-a,0,a,c],M=[o,-y,0,y,o,0,0,0,1];return Pt(M,Pt(l,f))}S(Ae,"rotation");function Pt(t,e){let r=new Array(9);for(let n=0;n<3;n++)for(let i=0;i<3;i++)r[n*3+i]=t[n*3]*e[i]+t[n*3+1]*e[3+i]+t[n*3+2]*e[6+i];return r}S(Pt,"multiply");var st=1.4,Ot=Math.PI*2/mt,be=.6,Se=at+K*Q+lt+_t/2;function Ct(t){let e=t-W;if(e<=0)return 0;let r=e/st;return r<1?Ot*st*(r**6-3*r**5+2.5*r**4):Ot*(st*.5+e-st)}S(Ct,"baseSpinPhase");var Ye=Math.PI*2-Ct(Se)%(Math.PI*2);function gt(t){return Ct(t)+Ye*U((t-W)/nt)}S(gt,"spinPhase");function Ut(t){let e=gt(t);return e-be*Math.sin(e)}S(Ut,"spinAngle");var _e=class{static{S(this,"BlockRaster")}bits=new Uint8Array(0);counts=new Uint8Array(0);rgb=new Float32Array(0);haloAmount=new Float32Array(0);haloRgb=new Float32Array(0);width=0;height=0;depth=new Float32Array(0);faceIds=new Uint16Array(0);dirty;haloDirty;cameraDistance;constructor(t){this.cameraDistance=t}render(t,e,r,n,i,a){let c=t*2,y=e*4;if(t!==this.width||e!==this.height)this.width=t,this.height=e,this.bits=new Uint8Array(t*e),this.counts=new Uint8Array(t*e),this.rgb=new Float32Array(t*e*3),this.haloAmount=new Float32Array(t*e),this.haloRgb=new Float32Array(t*e*3),this.haloDirty=void 0,this.depth=new Float32Array(c*y).fill(1/0),this.faceIds=new Uint16Array(c*y),this.dirty=void 0;else if(this.dirty){let{minX:A,minY:w,maxX:b,maxY:D}=this.dirty;for(let E=w;E<=D;E++)this.bits.fill(0,E*t+A,E*t+b+1),this.counts.fill(0,E*t+A,E*t+b+1),this.rgb.fill(0,(E*t+A)*3,(E*t+b+1)*3);this.dirty=void 0}if(this.haloDirty){let{minX:A,minY:w,maxX:b,maxY:D}=this.haloDirty;for(let E=w;E<=D;E++)this.haloAmount.fill(0,E*t+A,E*t+b+1),this.haloRgb.fill(0,(E*t+A)*3,(E*t+b+1)*3);this.haloDirty=void 0}let o=Ae(r.yaw,r.pitch,r.roll),{centerX:f,centerY:l,scale:M}=r,h=this.cameraDistance,d=[o[6]*h,o[7]*h,o[8]*h],Y=kt(i),x=this.visibleFaces(o,d,r,n,c,y,Y);if(x.length===0)return;let s=c,p=y,m=-1,u=-1;for(let A of x)s=Math.min(s,A.minX),p=Math.min(p,A.minY),m=Math.max(m,A.maxX),u=Math.max(u,A.maxY);if(m<s||u<p)return;let _=this.depth,k=this.faceIds;for(let A=0;A<x.length;A++){let w=x[A],b=w.axis,D=(b+1)%3,E=(b+2)%3,O=d[b],C=d[D],N=d[E],F=o[b]/M,ht=o[D]/M,P=o[E]/M,H=(w.minX+.5-f)/M;for(let B=w.minY;B<=w.maxY;B++){let ct=(B+.5-l)/M,xt=o[b]*H+o[3+b]*ct-o[6+b]*h,pt=o[D]*H+o[3+D]*ct-o[6+D]*h,Mt=o[E]*H+o[3+E]*ct-o[6+E]*h,rt=B*c+w.minX;for(let yt=w.minX;yt<=w.maxX;yt++,rt++){let j=(w.plane-O)/xt;if(j>0&&j<_[rt]){let At=C+j*pt,bt=N+j*Mt;At>=w.uMin&&At<=w.uMax&&bt>=w.vMin&&bt<=w.vMax&&(_[rt]=j,k[rt]=A+1)}xt+=F,pt+=ht,Mt+=P}}}let X=this.bits,g=this.counts,I=this.rgb,v=t,L=e,R=-1,T=-1;for(let A=p;A<=u;A++){let w=A*c+s;for(let b=s;b<=m;b++,w++){let D=k[w];if(D===0)continue;let E=x[D-1],O=Z(.15-h*(1-_[w])*.12)*(Y?.5:1);k[w]=0,_[w]=1/0;let C=b>>1,N=A>>2,F=N*t+C;X[F]|=ft[(A&3)*2+(b&1)],g[F]++,I[F*3]+=E.red+(i[0]-E.red)*O,I[F*3+1]+=E.green+(i[1]-E.green)*O,I[F*3+2]+=E.blue+(i[2]-E.blue)*O,C<v&&(v=C),C>R&&(R=C),N<L&&(L=N),N>T&&(T=N)}}R>=0&&(this.dirty={minX:v,minY:L,maxX:R,maxY:T}),a>0&&this.renderHalo(a)}renderHalo(t){let e=this.dirty;if(!e)return;let{width:r,height:n,counts:i,rgb:a}=this,c=Math.max(0,e.minX-q),y=Math.min(r-1,e.maxX+q),o=Math.max(0,e.minY-$),f=Math.min(n-1,e.maxY+$),l=y-c+1,M=S(s=>{let p=Array.from({length:s*2+1},(u,_)=>s+1-Math.abs(_-s)),m=p.reduce((u,_)=>u+_,0);return p.map(u=>u/m)},"tent"),h=M(q),d=M($),Y=e.maxY-e.minY+1,x=new Float32Array(Y*l*4);for(let s=e.minY;s<=e.maxY;s++)for(let p=c;p<=y;p++){let m=0,u=0,_=0,k=0;for(let g=-q;g<=q;g++){let I=p+g;if(I<e.minX||I>e.maxX)continue;let v=s*r+I,L=i[v];if(L===0)continue;let R=h[g+q]/8;m+=L*R,u+=a[v*3]*R,_+=a[v*3+1]*R,k+=a[v*3+2]*R}let X=((s-e.minY)*l+(p-c))*4;x[X]=m,x[X+1]=u,x[X+2]=_,x[X+3]=k}for(let s=o;s<=f;s++)for(let p=c;p<=y;p++){let m=0,u=0,_=0,k=0;for(let v=-$;v<=$;v++){let L=s+v;if(L<e.minY||L>e.maxY)continue;let R=d[v+$],T=((L-e.minY)*l+(p-c))*4;m+=x[T]*R,u+=x[T+1]*R,_+=x[T+2]*R,k+=x[T+3]*R}let X=s*r+p,g=i[X];if(g>0&&g/8>m&&(m=g/8,u=a[X*3]/g*m,_=a[X*3+1]/g*m,k=a[X*3+2]/g*m),m<=0)continue;let I=Math.round(t*Math.min(1,m)**.7*Tt)/Tt;I<=0||(this.haloAmount[X]=I,this.haloRgb[X*3]=Math.round(u/m/z)*z,this.haloRgb[X*3+1]=Math.round(_/m/z)*z,this.haloRgb[X*3+2]=Math.round(k/m/z)*z)}this.haloDirty={minX:c,minY:o,maxX:y,maxY:f}}visibleFaces(t,e,r,n,i,a,c){let y=[],o=this.cameraDistance;for(let f of n)for(let l=0;l<3;l++){let M=(l+1)%3,h=(l+2)%3;for(let d of[-1,1]){let Y=d>0?f.max[l]:f.min[l];if((e[l]-Y)*d<=0||n.some(T=>T!==f&&(d>0?T.min[l]:T.max[l])===Y&&T.min[M]<=f.min[M]&&T.max[M]>=f.max[M]&&T.min[h]<=f.min[h]&&T.max[h]>=f.max[h]))continue;let x=1/0,s=1/0,p=-1/0,m=-1/0,u=[0,0,0];for(let T of[f.min[M],f.max[M]])for(let A of[f.min[h],f.max[h]]){u[l]=Y,u[M]=T,u[h]=A;let w=t[0]*u[0]+t[1]*u[1]+t[2]*u[2],b=t[3]*u[0]+t[4]*u[1]+t[5]*u[2],D=t[6]*u[0]+t[7]*u[1]+t[8]*u[2],E=r.scale*o/(o-D),O=r.centerX+w*E,C=r.centerY+b*E;x=Math.min(x,O),s=Math.min(s,C),p=Math.max(p,O),m=Math.max(m,C)}let _={minX:Math.max(0,Math.floor(x)),minY:Math.max(0,Math.floor(s)),maxX:Math.min(i-1,Math.ceil(p)),maxY:Math.min(a-1,Math.ceil(m))};if(_.maxX<_.minX||_.maxY<_.minY)continue;let k=t[l]*d,X=t[3+l]*d,g=t[6+l]*d,I=Math.max(0,k*J[0]+X*J[1]+g*J[2]),v=Math.max(0,k*.8-g*.3),L=c?0:Math.max(0,k*dt[0]+X*dt[1]+g*dt[2])**24*.6*255,R=c?Math.min(1,.55+I*.45+v*.1):.45+I*.78+v*.25;y.push({axis:l,plane:Y,uMin:f.min[M],uMax:f.max[M],vMin:f.min[h],vMax:f.max[h],..._,red:Math.min(255,f.color[0]*R+L),green:Math.min(255,f.color[1]*R+L),blue:Math.min(255,f.color[2]*R+L)})}}return y}},ot=!1;async function we(t,e,r){if(ot)return;ot=!0;let n=await t.queryTerminalColors({timeoutMs:100}),i=G.appearance==="dark",a=S((l,M)=>l?[l.r,l.g,l.b]:M,"toRgbTuple"),c={foreground:a(n.foreground,et(G.colors.text)),background:a(n.background,i?[0,0,0]:[255,255,255])};if(t.hasOverlay()){ot=!1;return}let y=r.kind==="armin"?ae(et(G.colors.accent)):ne({column:r.column,row:r.row}),o=new Nt(t,e,y,c,()=>{ot=!1,f.hide()}),f=t.showOverlay(o,{anchor:"top-left",width:"100%",maxHeight:"100%"})}S(we,"playEasterEgg3d");var Nt=class{static{S(this,"EasterEgg3dAnimation")}tui;screen;model;foreground;background;onDone;startTime=performance.now();lastRender=performance.now();timer;exit;shuffle;screenWidth=-1;screenHeight=-1;stars=[];cells=[];ansiCache=new Map;raster;constructor(t,e,r,n,i){this.tui=t,this.screen=e,this.model=r,this.raster=new _e(r.cameraDistance),this.foreground=n.foreground,this.background=n.background,this.onDone=i,this.timer=setInterval(()=>{this.exit&&this.exitProgress()>=1||performance.now()-this.lastRender>1e3?this.finish():this.tui.requestRender()},oe),this.timer.unref?.()}close(){if(this.exit){this.finish();return}let t=this.elapsed(),e=Ut(t),r=Math.PI*2;this.exit={start:performance.now(),time:t,yaw:e,targetYaw:Math.ceil(e/r)*r,offsets:this.blockOffsets(t)}}handleInput(t){let e=St();(e.matches(t,"tui.select.cancel")||e.matches(t,"app.clear"))&&this.close()}handleMouse(t){return t.type==="click"&&this.close(),{handled:!0,render:!1}}invalidate(){this.screenWidth=-1,this.screenHeight=-1,this.ansiCache.clear()}render(t){let e=Math.max(1,this.tui.terminal.rows),r=this.foreground,n=this.background;this.lastRender=performance.now(),(t!==this.screenWidth||e!==this.screenHeight)&&(this.screenWidth=t,this.screenHeight=e,this.cells=this.prepareCells(t,r),this.stars=this.prepareStars(t,e));let i,a,c,y,o;if(this.exit){let g=this.exitProgress(),I=Z(g/.8),v=1-U(I);i=Math.min(this.exit.time,vt)*(1-g),a=this.pose(t,e,this.flyProgress(this.exit.time)*v,this.exit.time),a.yaw=this.exit.yaw+(this.exit.targetYaw-this.exit.yaw)*xe(I),a.pitch*=v,a.roll*=v,c=this.hintAlpha(this.exit.time)*(1-U(g/.2)),y=this.starAlpha(this.exit.time)*(1-U(g/.3));let L=1-U(g/.5);o=this.exit.offsets.map(([R,T,A])=>[R*L,T*L,A*L])}else{let g=this.elapsed();i=g,a=this.pose(t,e,this.flyProgress(g),g),c=this.hintAlpha(g),y=this.starAlpha(g),o=this.blockOffsets(g)}let{columns:f,rows:l}=this.model,M=this.model.blocks.map((g,I)=>{let[v,L,R]=o[I],T=g.home[0]-f/2+v,A=g.home[1]-l/2+L;return{min:[T,A,R-it/2],max:[T+1,A+1,R+it/2],color:g.color}}),h=this.raster;h.render(t,e,a,M,n,kt(n)?de:0);let d=S((g,I)=>{let v=h.haloAmount[g];if(v<=0)return I;let L=h.haloRgb;return V(I??n,[L[g*3],L[g*3+1],L[g*3+2]],v)},"halo"),Y=U(i/he),x=U(i/.6)*.3,s=i<vt||Y<1,p=this.hint(t,e,c,n),m=Math.floor(i*14),u=this.elapsed(),_=Math.round(y*Lt)/Lt,k=S(g=>{if(_<=0)return;let I=this.stars[g];if(!I)return;let v=Math.round((.5+.5*Math.sin(u*I.speed+I.phase))*Xt)/Xt;return{text:I.glyph,fg:V(n,V(r,I.tint,.5),I.strength*(.7+.3*v)*_)}},"starfield"),X=[];for(let g=0;g<e;g++){let I=this.cells[g]??[],v="",L=-1,R=-1,T=S((A,w,b)=>{let D=w?this.pack(w):-1,E=b?this.pack(b):-1;D!==L&&A!==" "&&(v+=w?this.ansi(D,!1):"\x1B[39m",L=D),E!==R&&(v+=b?this.ansi(E,!0):"\x1B[49m",R=E),v+=A},"emit");for(let A=0;A<t;A++){let w=g*t+A,b=s?I[A]:void 0,D=d(w,b?.bg&&Y<1?V(b.bg,n,Y):void 0);if(p&&g===p.row&&A>=p.start&&A<p.start+p.text.length){let P=A-p.start;T(p.text[P],P<p.keyLength?p.keyColor:p.color,D);continue}let E=h.bits[w];if(E){let P=z*h.counts[w],H=h.rgb,B=[Math.round(H[w*3]/P)*z,Math.round(H[w*3+1]/P)*z,Math.round(H[w*3+2]/P)*z];T(ut[E],B,D);continue}if(!b){let P=k(w);T(P?.text??" ",P?.fg,D);continue}let O=(i-b.delay)/wt;if(O<0&&b.width===2&&!h.bits[w+1]){T(b.text,V(b.fg,n,x),D),A++;continue}if(O<0&&b.width===1){T(b.text,V(b.fg,n,x),D);continue}let C=O<0?b.ink:Math.round(b.ink*(1-Z(O)));if(C<=0){let P=k(w);T(P?.text??" ",P?.fg,D);continue}let N=0,F=0;for(let P=0;F<C&&P<32;P++){let H=ft[Math.floor(tt(b.seed*7919+m*131+P)*8)];N&H||(N|=H,F++)}let ht=x+(1-x)*Z(O)**.8;T(ut[N],V(b.fg,n,ht),D)}X.push(`${v}\x1B[0m`)}return X}elapsed(){return(performance.now()-this.startTime)/1e3}exitProgress(){return this.exit?Z((performance.now()-this.exit.start)/1e3/ce):0}finish(){this.timer&&(clearInterval(this.timer),this.timer=void 0,this.onDone())}blockOffsets(t){let e=this.model.blocks,r=S(()=>e.map(()=>[0,0,0]),"home");if(t<at)return r();let n=Math.floor((t-at)/mt),i=t-at-n*mt;this.shuffle?.cycle!==n&&(this.shuffle={cycle:n,steps:se(this.model,n)});let a=this.shuffle.steps,c=S((o,f)=>{let l=e[f].home;return[o[0]-l[0],o[1]-l[1],o[2]-l[2]]},"offset"),y=K*Q;if(i<y){let o=Math.floor(i/K),f=U((i-o*K)/K);return a[o].map((l,M)=>{let h=c(l,M),d=c(a[o+1][M],M);return[h[0]+(d[0]-h[0])*f,h[1]+(d[1]-h[1])*f,h[2]+(d[2]-h[2])*f]})}if(i<y+lt){let o=(i-y)/lt,f=1-U(o),l=Math.sin(Math.PI*Z(o))*.8;return a[Q].map((M,h)=>{let[d,Y,x]=c(M,h);return[d*f,Y*f,x*f+(h%2===0?l:-l)]})}return r()}flyProgress(t){return U((t-W)/nt)}starAlpha(t){return U((t-me)/fe)}hintAlpha(t){return U((t-W-nt)/ge)}pose(t,e,r,n){let{columns:i,rows:a,cameraDistance:c,radius:y,widthShare:o,origin:f}=this.model,l=y*(c/(c-y)),M=f?2*(c-it/2)/c:jt,h=Math.max(M,Math.min(t*2*o,(e*4-8)*.48)/l),d=t,Y=e*2-2,x=f?f.column*2+i:d,s=f?f.row*4+a:Y;return{centerX:x+(d-x)*r,centerY:s+(Y-s)*r,scale:M*(h/M)**r,yaw:Ut(n),pitch:.3*Math.sin(gt(n))*r,roll:.06*Math.sin(2*gt(n))*r}}hint(t,e,r,n){if(r<=0)return;let i=Kt(St().getKeys("tui.select.cancel")[0]??"escape"),a=`${i} to return`;if(!(a.length>t))return{row:e-2,start:Math.floor((t-a.length)/2),text:a,keyLength:i.length,keyColor:V(n,et(G.colors.muted),r),color:V(n,et(G.colors.dim),r)}}prepareStars(t,e){let r=new Array(t*e);for(let n=0;n<t*e;n++){if(tt(n*3+20973)>=ue)continue;let i=S(a=>tt(n*7+a*40503),"random");r[n]={glyph:ut[ft[Math.floor(i(1)*8)]],tint:It[Math.floor(i(2)*It.length)],strength:.1+i(3)*.12,phase:i(4)*Math.PI*2,speed:.4+i(5)*.8}}return r}prepareCells(t,e){let r=ye(this.screen,t,e,this.background),n=Math.max(1,this.tui.terminal.rows),{columns:i,rows:a,origin:c}=this.model,y=c?c.column+i/2:t/2,o=c?c.row+a/4:n/2,f=Math.hypot(Math.max(y,t-y),Math.max(o,n-o)*2);for(let l=0;l<r.length;l++){let M=r[l];for(let h=0;h<M.length;h++){let d=M[h],Y=d.width===0?M[h-1]:d,x=tt(l*65537+h);if(d.width!==0){let s=Math.hypot(h-y,(l-o)*2)/f;d.delay=W+s*Et+x*Rt}else d.delay=Y.delay;d.seed=l*65537+h,d.ink=pe(Y.text,x)}}if(c)for(let l=c.row;l<c.row+Math.ceil(a/2);l++){let M=r[l];if(M)for(let h=c.column;h<c.column+i;h++){let d=M[h];d&&(d.text=" ",d.width=1,d.ink=0,d.bg=void 0)}}return r}pack(t){return Math.round(t[0])<<16|Math.round(t[1])<<8|Math.round(t[2])}ansi(t,e){let r=t*2+(e?1:0),n=this.ansiCache.get(r);if(n===void 0){let i=$t(t>>16&255,t>>8&255,t&255),a=G.getColorMode();n=e?Wt(i,a):Gt(i,a),this.ansiCache.set(r,n)}return n}};export{Nt as EasterEgg3dAnimation,we as playEasterEgg3d};